@bbearai/react-native 0.6.2 → 0.7.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 (3) hide show
  1. package/dist/index.js +538 -149
  2. package/dist/index.mjs +539 -150
  3. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -276,7 +276,7 @@ var PostgrestBuilder = class {
276
276
  * ```
277
277
  */
278
278
  constructor(builder) {
279
- var _builder$shouldThrowO, _builder$isMaybeSingl;
279
+ var _builder$shouldThrowO, _builder$isMaybeSingl, _builder$urlLengthLim;
280
280
  this.shouldThrowOnError = false;
281
281
  this.method = builder.method;
282
282
  this.url = builder.url;
@@ -286,6 +286,7 @@ var PostgrestBuilder = class {
286
286
  this.shouldThrowOnError = (_builder$shouldThrowO = builder.shouldThrowOnError) !== null && _builder$shouldThrowO !== void 0 ? _builder$shouldThrowO : false;
287
287
  this.signal = builder.signal;
288
288
  this.isMaybeSingle = (_builder$isMaybeSingl = builder.isMaybeSingle) !== null && _builder$isMaybeSingl !== void 0 ? _builder$isMaybeSingl : false;
289
+ this.urlLengthLimit = (_builder$urlLengthLim = builder.urlLengthLimit) !== null && _builder$urlLengthLim !== void 0 ? _builder$urlLengthLim : 8e3;
289
290
  if (builder.fetch) this.fetch = builder.fetch;
290
291
  else this.fetch = fetch;
291
292
  }
@@ -386,6 +387,8 @@ var PostgrestBuilder = class {
386
387
  if (!this.shouldThrowOnError) res = res.catch((fetchError) => {
387
388
  var _fetchError$name2;
388
389
  let errorDetails = "";
390
+ let hint = "";
391
+ let code = "";
389
392
  const cause = fetchError === null || fetchError === void 0 ? void 0 : fetchError.cause;
390
393
  if (cause) {
391
394
  var _cause$message, _cause$code, _fetchError$name, _cause$name;
@@ -402,12 +405,22 @@ ${cause.stack}`;
402
405
  var _fetchError$stack;
403
406
  errorDetails = (_fetchError$stack = fetchError === null || fetchError === void 0 ? void 0 : fetchError.stack) !== null && _fetchError$stack !== void 0 ? _fetchError$stack : "";
404
407
  }
408
+ const urlLength = this.url.toString().length;
409
+ if ((fetchError === null || fetchError === void 0 ? void 0 : fetchError.name) === "AbortError" || (fetchError === null || fetchError === void 0 ? void 0 : fetchError.code) === "ABORT_ERR") {
410
+ code = "";
411
+ hint = "Request was aborted (timeout or manual cancellation)";
412
+ if (urlLength > this.urlLengthLimit) hint += `. Note: Your request URL is ${urlLength} characters, which may exceed server limits. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [many IDs])), consider using an RPC function to pass values server-side.`;
413
+ } else if ((cause === null || cause === void 0 ? void 0 : cause.name) === "HeadersOverflowError" || (cause === null || cause === void 0 ? void 0 : cause.code) === "UND_ERR_HEADERS_OVERFLOW") {
414
+ code = "";
415
+ hint = "HTTP headers exceeded server limits (typically 16KB)";
416
+ if (urlLength > this.urlLengthLimit) hint += `. Your request URL is ${urlLength} characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead.`;
417
+ }
405
418
  return {
406
419
  error: {
407
420
  message: `${(_fetchError$name2 = fetchError === null || fetchError === void 0 ? void 0 : fetchError.name) !== null && _fetchError$name2 !== void 0 ? _fetchError$name2 : "FetchError"}: ${fetchError === null || fetchError === void 0 ? void 0 : fetchError.message}`,
408
421
  details: errorDetails,
409
- hint: "",
410
- code: ""
422
+ hint,
423
+ code
411
424
  },
412
425
  data: null,
413
426
  count: null,
@@ -1049,11 +1062,12 @@ var PostgrestQueryBuilder = class {
1049
1062
  * )
1050
1063
  * ```
1051
1064
  */
1052
- constructor(url, { headers = {}, schema, fetch: fetch$1 }) {
1065
+ constructor(url, { headers = {}, schema, fetch: fetch$1, urlLengthLimit = 8e3 }) {
1053
1066
  this.url = url;
1054
1067
  this.headers = new Headers(headers);
1055
1068
  this.schema = schema;
1056
1069
  this.fetch = fetch$1;
1070
+ this.urlLengthLimit = urlLengthLimit;
1057
1071
  }
1058
1072
  /**
1059
1073
  * Clone URL and headers to prevent shared state between operations.
@@ -1106,7 +1120,8 @@ var PostgrestQueryBuilder = class {
1106
1120
  url,
1107
1121
  headers,
1108
1122
  schema: this.schema,
1109
- fetch: this.fetch
1123
+ fetch: this.fetch,
1124
+ urlLengthLimit: this.urlLengthLimit
1110
1125
  });
1111
1126
  }
1112
1127
  /**
@@ -1154,7 +1169,8 @@ var PostgrestQueryBuilder = class {
1154
1169
  headers,
1155
1170
  schema: this.schema,
1156
1171
  body: values,
1157
- fetch: (_this$fetch = this.fetch) !== null && _this$fetch !== void 0 ? _this$fetch : fetch
1172
+ fetch: (_this$fetch = this.fetch) !== null && _this$fetch !== void 0 ? _this$fetch : fetch,
1173
+ urlLengthLimit: this.urlLengthLimit
1158
1174
  });
1159
1175
  }
1160
1176
  /**
@@ -1263,7 +1279,8 @@ var PostgrestQueryBuilder = class {
1263
1279
  headers,
1264
1280
  schema: this.schema,
1265
1281
  body: values,
1266
- fetch: (_this$fetch2 = this.fetch) !== null && _this$fetch2 !== void 0 ? _this$fetch2 : fetch
1282
+ fetch: (_this$fetch2 = this.fetch) !== null && _this$fetch2 !== void 0 ? _this$fetch2 : fetch,
1283
+ urlLengthLimit: this.urlLengthLimit
1267
1284
  });
1268
1285
  }
1269
1286
  /**
@@ -1298,7 +1315,8 @@ var PostgrestQueryBuilder = class {
1298
1315
  headers,
1299
1316
  schema: this.schema,
1300
1317
  body: values,
1301
- fetch: (_this$fetch3 = this.fetch) !== null && _this$fetch3 !== void 0 ? _this$fetch3 : fetch
1318
+ fetch: (_this$fetch3 = this.fetch) !== null && _this$fetch3 !== void 0 ? _this$fetch3 : fetch,
1319
+ urlLengthLimit: this.urlLengthLimit
1302
1320
  });
1303
1321
  }
1304
1322
  /**
@@ -1330,10 +1348,62 @@ var PostgrestQueryBuilder = class {
1330
1348
  url,
1331
1349
  headers,
1332
1350
  schema: this.schema,
1333
- fetch: (_this$fetch4 = this.fetch) !== null && _this$fetch4 !== void 0 ? _this$fetch4 : fetch
1351
+ fetch: (_this$fetch4 = this.fetch) !== null && _this$fetch4 !== void 0 ? _this$fetch4 : fetch,
1352
+ urlLengthLimit: this.urlLengthLimit
1334
1353
  });
1335
1354
  }
1336
1355
  };
1356
+ function _typeof(o) {
1357
+ "@babel/helpers - typeof";
1358
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
1359
+ return typeof o$1;
1360
+ } : function(o$1) {
1361
+ return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
1362
+ }, _typeof(o);
1363
+ }
1364
+ function toPrimitive(t, r) {
1365
+ if ("object" != _typeof(t) || !t) return t;
1366
+ var e = t[Symbol.toPrimitive];
1367
+ if (void 0 !== e) {
1368
+ var i = e.call(t, r || "default");
1369
+ if ("object" != _typeof(i)) return i;
1370
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1371
+ }
1372
+ return ("string" === r ? String : Number)(t);
1373
+ }
1374
+ function toPropertyKey(t) {
1375
+ var i = toPrimitive(t, "string");
1376
+ return "symbol" == _typeof(i) ? i : i + "";
1377
+ }
1378
+ function _defineProperty(e, r, t) {
1379
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
1380
+ value: t,
1381
+ enumerable: true,
1382
+ configurable: true,
1383
+ writable: true
1384
+ }) : e[r] = t, e;
1385
+ }
1386
+ function ownKeys(e, r) {
1387
+ var t = Object.keys(e);
1388
+ if (Object.getOwnPropertySymbols) {
1389
+ var o = Object.getOwnPropertySymbols(e);
1390
+ r && (o = o.filter(function(r$1) {
1391
+ return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
1392
+ })), t.push.apply(t, o);
1393
+ }
1394
+ return t;
1395
+ }
1396
+ function _objectSpread2(e) {
1397
+ for (var r = 1; r < arguments.length; r++) {
1398
+ var t = null != arguments[r] ? arguments[r] : {};
1399
+ r % 2 ? ownKeys(Object(t), true).forEach(function(r$1) {
1400
+ _defineProperty(e, r$1, t[r$1]);
1401
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
1402
+ Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
1403
+ });
1404
+ }
1405
+ return e;
1406
+ }
1337
1407
  var PostgrestClient = class PostgrestClient2 {
1338
1408
  /**
1339
1409
  * Creates a PostgREST client.
@@ -1343,6 +1413,8 @@ var PostgrestClient = class PostgrestClient2 {
1343
1413
  * @param options.headers - Custom headers
1344
1414
  * @param options.schema - Postgres schema to switch to
1345
1415
  * @param options.fetch - Custom fetch
1416
+ * @param options.timeout - Optional timeout in milliseconds for all requests. When set, requests will automatically abort after this duration to prevent indefinite hangs.
1417
+ * @param options.urlLengthLimit - Maximum URL length in characters before warnings/errors are triggered. Defaults to 8000.
1346
1418
  * @example
1347
1419
  * ```ts
1348
1420
  * import PostgrestClient from '@supabase/postgrest-js'
@@ -1350,14 +1422,38 @@ var PostgrestClient = class PostgrestClient2 {
1350
1422
  * const postgrest = new PostgrestClient('https://xyzcompany.supabase.co/rest/v1', {
1351
1423
  * headers: { apikey: 'public-anon-key' },
1352
1424
  * schema: 'public',
1425
+ * timeout: 30000, // 30 second timeout
1353
1426
  * })
1354
1427
  * ```
1355
1428
  */
1356
- constructor(url, { headers = {}, schema, fetch: fetch$1 } = {}) {
1429
+ constructor(url, { headers = {}, schema, fetch: fetch$1, timeout, urlLengthLimit = 8e3 } = {}) {
1357
1430
  this.url = url;
1358
1431
  this.headers = new Headers(headers);
1359
1432
  this.schemaName = schema;
1360
- this.fetch = fetch$1;
1433
+ this.urlLengthLimit = urlLengthLimit;
1434
+ const originalFetch = fetch$1 !== null && fetch$1 !== void 0 ? fetch$1 : globalThis.fetch;
1435
+ if (timeout !== void 0 && timeout > 0) this.fetch = (input, init) => {
1436
+ const controller = new AbortController();
1437
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
1438
+ const existingSignal = init === null || init === void 0 ? void 0 : init.signal;
1439
+ if (existingSignal) {
1440
+ if (existingSignal.aborted) {
1441
+ clearTimeout(timeoutId);
1442
+ return originalFetch(input, init);
1443
+ }
1444
+ const abortHandler = () => {
1445
+ clearTimeout(timeoutId);
1446
+ controller.abort();
1447
+ };
1448
+ existingSignal.addEventListener("abort", abortHandler, { once: true });
1449
+ return originalFetch(input, _objectSpread2(_objectSpread2({}, init), {}, { signal: controller.signal })).finally(() => {
1450
+ clearTimeout(timeoutId);
1451
+ existingSignal.removeEventListener("abort", abortHandler);
1452
+ });
1453
+ }
1454
+ return originalFetch(input, _objectSpread2(_objectSpread2({}, init), {}, { signal: controller.signal })).finally(() => clearTimeout(timeoutId));
1455
+ };
1456
+ else this.fetch = originalFetch;
1361
1457
  }
1362
1458
  /**
1363
1459
  * Perform a query on a table or a view.
@@ -1369,7 +1465,8 @@ var PostgrestClient = class PostgrestClient2 {
1369
1465
  return new PostgrestQueryBuilder(new URL(`${this.url}/${relation}`), {
1370
1466
  headers: new Headers(this.headers),
1371
1467
  schema: this.schemaName,
1372
- fetch: this.fetch
1468
+ fetch: this.fetch,
1469
+ urlLengthLimit: this.urlLengthLimit
1373
1470
  });
1374
1471
  }
1375
1472
  /**
@@ -1383,7 +1480,8 @@ var PostgrestClient = class PostgrestClient2 {
1383
1480
  return new PostgrestClient2(this.url, {
1384
1481
  headers: this.headers,
1385
1482
  schema,
1386
- fetch: this.fetch
1483
+ fetch: this.fetch,
1484
+ urlLengthLimit: this.urlLengthLimit
1387
1485
  });
1388
1486
  }
1389
1487
  /**
@@ -1446,7 +1544,8 @@ var PostgrestClient = class PostgrestClient2 {
1446
1544
  headers,
1447
1545
  schema: this.schemaName,
1448
1546
  body,
1449
- fetch: (_this$fetch = this.fetch) !== null && _this$fetch !== void 0 ? _this$fetch : fetch
1547
+ fetch: (_this$fetch = this.fetch) !== null && _this$fetch !== void 0 ? _this$fetch : fetch,
1548
+ urlLengthLimit: this.urlLengthLimit
1450
1549
  });
1451
1550
  }
1452
1551
  };
@@ -1568,7 +1667,7 @@ Suggested solution: ${env.workaround}`;
1568
1667
  var websocket_factory_default = WebSocketFactory;
1569
1668
 
1570
1669
  // ../../node_modules/@supabase/realtime-js/dist/module/lib/version.js
1571
- var version = "2.93.2";
1670
+ var version = "2.95.3";
1572
1671
 
1573
1672
  // ../../node_modules/@supabase/realtime-js/dist/module/lib/constants.js
1574
1673
  var DEFAULT_VERSION = `realtime-js/${version}`;
@@ -3055,6 +3154,9 @@ Option 2: Install and provide the "ws" package:
3055
3154
  */
3056
3155
  async removeChannel(channel) {
3057
3156
  const status = await channel.unsubscribe();
3157
+ if (status === "ok") {
3158
+ this._remove(channel);
3159
+ }
3058
3160
  if (this.channels.length === 0) {
3059
3161
  this.disconnect();
3060
3162
  }
@@ -4223,37 +4325,37 @@ var isValidBucketName = (bucketName) => {
4223
4325
  if (bucketName.includes("/") || bucketName.includes("\\")) return false;
4224
4326
  return /^[\w!.\*'() &$@=;:+,?-]+$/.test(bucketName);
4225
4327
  };
4226
- function _typeof(o) {
4328
+ function _typeof2(o) {
4227
4329
  "@babel/helpers - typeof";
4228
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
4330
+ return _typeof2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
4229
4331
  return typeof o$1;
4230
4332
  } : function(o$1) {
4231
4333
  return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
4232
- }, _typeof(o);
4334
+ }, _typeof2(o);
4233
4335
  }
4234
- function toPrimitive(t, r) {
4235
- if ("object" != _typeof(t) || !t) return t;
4336
+ function toPrimitive2(t, r) {
4337
+ if ("object" != _typeof2(t) || !t) return t;
4236
4338
  var e = t[Symbol.toPrimitive];
4237
4339
  if (void 0 !== e) {
4238
4340
  var i = e.call(t, r || "default");
4239
- if ("object" != _typeof(i)) return i;
4341
+ if ("object" != _typeof2(i)) return i;
4240
4342
  throw new TypeError("@@toPrimitive must return a primitive value.");
4241
4343
  }
4242
4344
  return ("string" === r ? String : Number)(t);
4243
4345
  }
4244
- function toPropertyKey(t) {
4245
- var i = toPrimitive(t, "string");
4246
- return "symbol" == _typeof(i) ? i : i + "";
4346
+ function toPropertyKey2(t) {
4347
+ var i = toPrimitive2(t, "string");
4348
+ return "symbol" == _typeof2(i) ? i : i + "";
4247
4349
  }
4248
- function _defineProperty(e, r, t) {
4249
- return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
4350
+ function _defineProperty2(e, r, t) {
4351
+ return (r = toPropertyKey2(r)) in e ? Object.defineProperty(e, r, {
4250
4352
  value: t,
4251
4353
  enumerable: true,
4252
4354
  configurable: true,
4253
4355
  writable: true
4254
4356
  }) : e[r] = t, e;
4255
4357
  }
4256
- function ownKeys(e, r) {
4358
+ function ownKeys2(e, r) {
4257
4359
  var t = Object.keys(e);
4258
4360
  if (Object.getOwnPropertySymbols) {
4259
4361
  var o = Object.getOwnPropertySymbols(e);
@@ -4263,12 +4365,12 @@ function ownKeys(e, r) {
4263
4365
  }
4264
4366
  return t;
4265
4367
  }
4266
- function _objectSpread2(e) {
4368
+ function _objectSpread22(e) {
4267
4369
  for (var r = 1; r < arguments.length; r++) {
4268
4370
  var t = null != arguments[r] ? arguments[r] : {};
4269
- r % 2 ? ownKeys(Object(t), true).forEach(function(r$1) {
4270
- _defineProperty(e, r$1, t[r$1]);
4271
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
4371
+ r % 2 ? ownKeys2(Object(t), true).forEach(function(r$1) {
4372
+ _defineProperty2(e, r$1, t[r$1]);
4373
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys2(Object(t)).forEach(function(r$1) {
4272
4374
  Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
4273
4375
  });
4274
4376
  }
@@ -4305,13 +4407,13 @@ var _getRequestParams = (method, options, parameters, body) => {
4305
4407
  method,
4306
4408
  headers: (options === null || options === void 0 ? void 0 : options.headers) || {}
4307
4409
  };
4308
- if (method === "GET" || method === "HEAD" || !body) return _objectSpread2(_objectSpread2({}, params), parameters);
4410
+ if (method === "GET" || method === "HEAD" || !body) return _objectSpread22(_objectSpread22({}, params), parameters);
4309
4411
  if (isPlainObject(body)) {
4310
- params.headers = _objectSpread2({ "Content-Type": "application/json" }, options === null || options === void 0 ? void 0 : options.headers);
4412
+ params.headers = _objectSpread22({ "Content-Type": "application/json" }, options === null || options === void 0 ? void 0 : options.headers);
4311
4413
  params.body = JSON.stringify(body);
4312
4414
  } else params.body = body;
4313
4415
  if (options === null || options === void 0 ? void 0 : options.duplex) params.duplex = options.duplex;
4314
- return _objectSpread2(_objectSpread2({}, params), parameters);
4416
+ return _objectSpread22(_objectSpread22({}, params), parameters);
4315
4417
  };
4316
4418
  async function _handleRequest(fetcher, method, url, options, parameters, body, namespace) {
4317
4419
  return new Promise((resolve, reject) => {
@@ -4320,6 +4422,7 @@ async function _handleRequest(fetcher, method, url, options, parameters, body, n
4320
4422
  if (options === null || options === void 0 ? void 0 : options.noResolveJson) return result;
4321
4423
  if (namespace === "vectors") {
4322
4424
  const contentType = result.headers.get("content-type");
4425
+ if (result.headers.get("content-length") === "0" || result.status === 204) return {};
4323
4426
  if (!contentType || !contentType.includes("application/json")) return {};
4324
4427
  }
4325
4428
  return result.json();
@@ -4338,7 +4441,7 @@ function createFetchApi(namespace = "storage") {
4338
4441
  return _handleRequest(fetcher, "PUT", url, options, parameters, body, namespace);
4339
4442
  },
4340
4443
  head: async (fetcher, url, options, parameters) => {
4341
- return _handleRequest(fetcher, "HEAD", url, _objectSpread2(_objectSpread2({}, options), {}, { noResolveJson: true }), parameters, void 0, namespace);
4444
+ return _handleRequest(fetcher, "HEAD", url, _objectSpread22(_objectSpread22({}, options), {}, { noResolveJson: true }), parameters, void 0, namespace);
4342
4445
  },
4343
4446
  remove: async (fetcher, url, body, options, parameters) => {
4344
4447
  return _handleRequest(fetcher, "DELETE", url, options, parameters, body, namespace);
@@ -4347,6 +4450,7 @@ function createFetchApi(namespace = "storage") {
4347
4450
  }
4348
4451
  var defaultApi = createFetchApi("storage");
4349
4452
  var { get, post, put, head, remove } = defaultApi;
4453
+ var vectorsApi = createFetchApi("vectors");
4350
4454
  var BaseApiClient = class {
4351
4455
  /**
4352
4456
  * Creates a new BaseApiClient instance
@@ -4510,8 +4614,8 @@ var StorageFileApi = class extends BaseApiClient {
4510
4614
  var _this = this;
4511
4615
  return _this.handleOperation(async () => {
4512
4616
  let body;
4513
- const options = _objectSpread2(_objectSpread2({}, DEFAULT_FILE_OPTIONS), fileOptions);
4514
- let headers = _objectSpread2(_objectSpread2({}, _this.headers), method === "POST" && { "x-upsert": String(options.upsert) });
4617
+ const options = _objectSpread22(_objectSpread22({}, DEFAULT_FILE_OPTIONS), fileOptions);
4618
+ let headers = _objectSpread22(_objectSpread22({}, _this.headers), method === "POST" && { "x-upsert": String(options.upsert) });
4515
4619
  const metadata = options.metadata;
4516
4620
  if (typeof Blob !== "undefined" && fileBody instanceof Blob) {
4517
4621
  body = new FormData();
@@ -4529,10 +4633,10 @@ var StorageFileApi = class extends BaseApiClient {
4529
4633
  if (metadata) headers["x-metadata"] = _this.toBase64(_this.encodeMetadata(metadata));
4530
4634
  if ((typeof ReadableStream !== "undefined" && body instanceof ReadableStream || body && typeof body === "object" && "pipe" in body && typeof body.pipe === "function") && !options.duplex) options.duplex = "half";
4531
4635
  }
4532
- if (fileOptions === null || fileOptions === void 0 ? void 0 : fileOptions.headers) headers = _objectSpread2(_objectSpread2({}, headers), fileOptions.headers);
4636
+ if (fileOptions === null || fileOptions === void 0 ? void 0 : fileOptions.headers) headers = _objectSpread22(_objectSpread22({}, headers), fileOptions.headers);
4533
4637
  const cleanPath = _this._removeEmptyFolders(path);
4534
4638
  const _path = _this._getFinalPath(cleanPath);
4535
- const data = await (method == "PUT" ? put : post)(_this.fetch, `${_this.url}/object/${_path}`, body, _objectSpread2({ headers }, (options === null || options === void 0 ? void 0 : options.duplex) ? { duplex: options.duplex } : {}));
4639
+ const data = await (method == "PUT" ? put : post)(_this.fetch, `${_this.url}/object/${_path}`, body, _objectSpread22({ headers }, (options === null || options === void 0 ? void 0 : options.duplex) ? { duplex: options.duplex } : {}));
4536
4640
  return {
4537
4641
  path: cleanPath,
4538
4642
  id: data.Id,
@@ -4626,8 +4730,8 @@ var StorageFileApi = class extends BaseApiClient {
4626
4730
  url.searchParams.set("token", token);
4627
4731
  return _this3.handleOperation(async () => {
4628
4732
  let body;
4629
- const options = _objectSpread2({ upsert: DEFAULT_FILE_OPTIONS.upsert }, fileOptions);
4630
- const headers = _objectSpread2(_objectSpread2({}, _this3.headers), { "x-upsert": String(options.upsert) });
4733
+ const options = _objectSpread22({ upsert: DEFAULT_FILE_OPTIONS.upsert }, fileOptions);
4734
+ const headers = _objectSpread22(_objectSpread22({}, _this3.headers), { "x-upsert": String(options.upsert) });
4631
4735
  if (typeof Blob !== "undefined" && fileBody instanceof Blob) {
4632
4736
  body = new FormData();
4633
4737
  body.append("cacheControl", options.cacheControl);
@@ -4680,7 +4784,7 @@ var StorageFileApi = class extends BaseApiClient {
4680
4784
  var _this4 = this;
4681
4785
  return _this4.handleOperation(async () => {
4682
4786
  let _path = _this4._getFinalPath(path);
4683
- const headers = _objectSpread2({}, _this4.headers);
4787
+ const headers = _objectSpread22({}, _this4.headers);
4684
4788
  if (options === null || options === void 0 ? void 0 : options.upsert) headers["x-upsert"] = "true";
4685
4789
  const data = await post(_this4.fetch, `${_this4.url}/object/upload/sign/${_path}`, {}, { headers });
4686
4790
  const url = new URL(_this4.url + data.url);
@@ -4871,7 +4975,7 @@ var StorageFileApi = class extends BaseApiClient {
4871
4975
  var _this8 = this;
4872
4976
  return _this8.handleOperation(async () => {
4873
4977
  let _path = _this8._getFinalPath(path);
4874
- let data = await post(_this8.fetch, `${_this8.url}/object/sign/${_path}`, _objectSpread2({ expiresIn }, (options === null || options === void 0 ? void 0 : options.transform) ? { transform: options.transform } : {}), { headers: _this8.headers });
4978
+ let data = await post(_this8.fetch, `${_this8.url}/object/sign/${_path}`, _objectSpread22({ expiresIn }, (options === null || options === void 0 ? void 0 : options.transform) ? { transform: options.transform } : {}), { headers: _this8.headers });
4875
4979
  const downloadQueryParam = (options === null || options === void 0 ? void 0 : options.download) ? `&download=${options.download === true ? "" : options.download}` : "";
4876
4980
  return { signedUrl: encodeURI(`${_this8.url}${data.signedURL}${downloadQueryParam}`) };
4877
4981
  });
@@ -4922,7 +5026,7 @@ var StorageFileApi = class extends BaseApiClient {
4922
5026
  paths
4923
5027
  }, { headers: _this9.headers });
4924
5028
  const downloadQueryParam = (options === null || options === void 0 ? void 0 : options.download) ? `&download=${options.download === true ? "" : options.download}` : "";
4925
- return data.map((datum) => _objectSpread2(_objectSpread2({}, datum), {}, { signedUrl: datum.signedURL ? encodeURI(`${_this9.url}${datum.signedURL}${downloadQueryParam}`) : null }));
5029
+ return data.map((datum) => _objectSpread22(_objectSpread22({}, datum), {}, { signedUrl: datum.signedURL ? encodeURI(`${_this9.url}${datum.signedURL}${downloadQueryParam}`) : null }));
4926
5030
  });
4927
5031
  }
4928
5032
  /**
@@ -4931,6 +5035,7 @@ var StorageFileApi = class extends BaseApiClient {
4931
5035
  * @category File Buckets
4932
5036
  * @param path The full path and file name of the file to be downloaded. For example `folder/image.png`.
4933
5037
  * @param options.transform Transform the asset before serving it to the client.
5038
+ * @param parameters Additional fetch parameters like signal for cancellation. Supports standard fetch options including cache control.
4934
5039
  * @returns BlobDownloadBuilder instance for downloading the file
4935
5040
  *
4936
5041
  * @example Download file
@@ -4962,8 +5067,27 @@ var StorageFileApi = class extends BaseApiClient {
4962
5067
  * }
4963
5068
  * })
4964
5069
  * ```
5070
+ *
5071
+ * @example Download with cache control (useful in Edge Functions)
5072
+ * ```js
5073
+ * const { data, error } = await supabase
5074
+ * .storage
5075
+ * .from('avatars')
5076
+ * .download('folder/avatar1.png', {}, { cache: 'no-store' })
5077
+ * ```
5078
+ *
5079
+ * @example Download with abort signal
5080
+ * ```js
5081
+ * const controller = new AbortController()
5082
+ * setTimeout(() => controller.abort(), 5000)
5083
+ *
5084
+ * const { data, error } = await supabase
5085
+ * .storage
5086
+ * .from('avatars')
5087
+ * .download('folder/avatar1.png', {}, { signal: controller.signal })
5088
+ * ```
4965
5089
  */
4966
- download(path, options) {
5090
+ download(path, options, parameters) {
4967
5091
  const renderPath = typeof (options === null || options === void 0 ? void 0 : options.transform) !== "undefined" ? "render/image/authenticated" : "object";
4968
5092
  const transformationQuery = this.transformOptsToQueryString((options === null || options === void 0 ? void 0 : options.transform) || {});
4969
5093
  const queryString = transformationQuery ? `?${transformationQuery}` : "";
@@ -4971,7 +5095,7 @@ var StorageFileApi = class extends BaseApiClient {
4971
5095
  const downloadFn = () => get(this.fetch, `${this.url}/${renderPath}/${_path}${queryString}`, {
4972
5096
  headers: this.headers,
4973
5097
  noResolveJson: true
4974
- });
5098
+ }, parameters);
4975
5099
  return new BlobDownloadBuilder(downloadFn, this.shouldThrowOnError);
4976
5100
  }
4977
5101
  /**
@@ -5194,7 +5318,7 @@ var StorageFileApi = class extends BaseApiClient {
5194
5318
  async list(path, options, parameters) {
5195
5319
  var _this13 = this;
5196
5320
  return _this13.handleOperation(async () => {
5197
- const body = _objectSpread2(_objectSpread2(_objectSpread2({}, DEFAULT_SEARCH_OPTIONS), options), {}, { prefix: path || "" });
5321
+ const body = _objectSpread22(_objectSpread22(_objectSpread22({}, DEFAULT_SEARCH_OPTIONS), options), {}, { prefix: path || "" });
5198
5322
  return await post(_this13.fetch, `${_this13.url}/object/list/${_this13.bucketId}`, body, { headers: _this13.headers }, parameters);
5199
5323
  });
5200
5324
  }
@@ -5208,7 +5332,7 @@ var StorageFileApi = class extends BaseApiClient {
5208
5332
  async listV2(options, parameters) {
5209
5333
  var _this14 = this;
5210
5334
  return _this14.handleOperation(async () => {
5211
- const body = _objectSpread2({}, options);
5335
+ const body = _objectSpread22({}, options);
5212
5336
  return await post(_this14.fetch, `${_this14.url}/object/list-v2/${_this14.bucketId}`, body, { headers: _this14.headers }, parameters);
5213
5337
  });
5214
5338
  }
@@ -5235,7 +5359,7 @@ var StorageFileApi = class extends BaseApiClient {
5235
5359
  return params.join("&");
5236
5360
  }
5237
5361
  };
5238
- var version2 = "2.93.2";
5362
+ var version2 = "2.95.3";
5239
5363
  var DEFAULT_HEADERS = { "X-Client-Info": `storage-js/${version2}` };
5240
5364
  var StorageBucketApi = class extends BaseApiClient {
5241
5365
  constructor(url, headers = {}, fetch$1, opts) {
@@ -5244,7 +5368,7 @@ var StorageBucketApi = class extends BaseApiClient {
5244
5368
  if (/supabase\.(co|in|red)$/.test(baseUrl.hostname) && !baseUrl.hostname.includes("storage.supabase.")) baseUrl.hostname = baseUrl.hostname.replace("supabase.", "storage.supabase.");
5245
5369
  }
5246
5370
  const finalUrl = baseUrl.href.replace(/\/$/, "");
5247
- const finalHeaders = _objectSpread2(_objectSpread2({}, DEFAULT_HEADERS), headers);
5371
+ const finalHeaders = _objectSpread22(_objectSpread22({}, DEFAULT_HEADERS), headers);
5248
5372
  super(finalUrl, finalHeaders, fetch$1, "storage");
5249
5373
  }
5250
5374
  /**
@@ -5515,7 +5639,7 @@ var StorageAnalyticsClient = class extends BaseApiClient {
5515
5639
  */
5516
5640
  constructor(url, headers = {}, fetch$1) {
5517
5641
  const finalUrl = url.replace(/\/$/, "");
5518
- const finalHeaders = _objectSpread2(_objectSpread2({}, DEFAULT_HEADERS), headers);
5642
+ const finalHeaders = _objectSpread22(_objectSpread22({}, DEFAULT_HEADERS), headers);
5519
5643
  super(finalUrl, finalHeaders, fetch$1, "storage");
5520
5644
  }
5521
5645
  /**
@@ -5815,21 +5939,21 @@ var VectorIndexApi = class extends BaseApiClient {
5815
5939
  /** Creates a new VectorIndexApi instance */
5816
5940
  constructor(url, headers = {}, fetch$1) {
5817
5941
  const finalUrl = url.replace(/\/$/, "");
5818
- const finalHeaders = _objectSpread2(_objectSpread2({}, DEFAULT_HEADERS), {}, { "Content-Type": "application/json" }, headers);
5942
+ const finalHeaders = _objectSpread22(_objectSpread22({}, DEFAULT_HEADERS), {}, { "Content-Type": "application/json" }, headers);
5819
5943
  super(finalUrl, finalHeaders, fetch$1, "vectors");
5820
5944
  }
5821
5945
  /** Creates a new vector index within a bucket */
5822
5946
  async createIndex(options) {
5823
5947
  var _this = this;
5824
5948
  return _this.handleOperation(async () => {
5825
- return await post(_this.fetch, `${_this.url}/CreateIndex`, options, { headers: _this.headers }) || {};
5949
+ return await vectorsApi.post(_this.fetch, `${_this.url}/CreateIndex`, options, { headers: _this.headers }) || {};
5826
5950
  });
5827
5951
  }
5828
5952
  /** Retrieves metadata for a specific vector index */
5829
5953
  async getIndex(vectorBucketName, indexName) {
5830
5954
  var _this2 = this;
5831
5955
  return _this2.handleOperation(async () => {
5832
- return await post(_this2.fetch, `${_this2.url}/GetIndex`, {
5956
+ return await vectorsApi.post(_this2.fetch, `${_this2.url}/GetIndex`, {
5833
5957
  vectorBucketName,
5834
5958
  indexName
5835
5959
  }, { headers: _this2.headers });
@@ -5839,14 +5963,14 @@ var VectorIndexApi = class extends BaseApiClient {
5839
5963
  async listIndexes(options) {
5840
5964
  var _this3 = this;
5841
5965
  return _this3.handleOperation(async () => {
5842
- return await post(_this3.fetch, `${_this3.url}/ListIndexes`, options, { headers: _this3.headers });
5966
+ return await vectorsApi.post(_this3.fetch, `${_this3.url}/ListIndexes`, options, { headers: _this3.headers });
5843
5967
  });
5844
5968
  }
5845
5969
  /** Deletes a vector index and all its data */
5846
5970
  async deleteIndex(vectorBucketName, indexName) {
5847
5971
  var _this4 = this;
5848
5972
  return _this4.handleOperation(async () => {
5849
- return await post(_this4.fetch, `${_this4.url}/DeleteIndex`, {
5973
+ return await vectorsApi.post(_this4.fetch, `${_this4.url}/DeleteIndex`, {
5850
5974
  vectorBucketName,
5851
5975
  indexName
5852
5976
  }, { headers: _this4.headers }) || {};
@@ -5857,7 +5981,7 @@ var VectorDataApi = class extends BaseApiClient {
5857
5981
  /** Creates a new VectorDataApi instance */
5858
5982
  constructor(url, headers = {}, fetch$1) {
5859
5983
  const finalUrl = url.replace(/\/$/, "");
5860
- const finalHeaders = _objectSpread2(_objectSpread2({}, DEFAULT_HEADERS), {}, { "Content-Type": "application/json" }, headers);
5984
+ const finalHeaders = _objectSpread22(_objectSpread22({}, DEFAULT_HEADERS), {}, { "Content-Type": "application/json" }, headers);
5861
5985
  super(finalUrl, finalHeaders, fetch$1, "vectors");
5862
5986
  }
5863
5987
  /** Inserts or updates vectors in batch (1-500 per request) */
@@ -5865,14 +5989,14 @@ var VectorDataApi = class extends BaseApiClient {
5865
5989
  var _this = this;
5866
5990
  if (options.vectors.length < 1 || options.vectors.length > 500) throw new Error("Vector batch size must be between 1 and 500 items");
5867
5991
  return _this.handleOperation(async () => {
5868
- return await post(_this.fetch, `${_this.url}/PutVectors`, options, { headers: _this.headers }) || {};
5992
+ return await vectorsApi.post(_this.fetch, `${_this.url}/PutVectors`, options, { headers: _this.headers }) || {};
5869
5993
  });
5870
5994
  }
5871
5995
  /** Retrieves vectors by their keys in batch */
5872
5996
  async getVectors(options) {
5873
5997
  var _this2 = this;
5874
5998
  return _this2.handleOperation(async () => {
5875
- return await post(_this2.fetch, `${_this2.url}/GetVectors`, options, { headers: _this2.headers });
5999
+ return await vectorsApi.post(_this2.fetch, `${_this2.url}/GetVectors`, options, { headers: _this2.headers });
5876
6000
  });
5877
6001
  }
5878
6002
  /** Lists vectors in an index with pagination */
@@ -5885,14 +6009,14 @@ var VectorDataApi = class extends BaseApiClient {
5885
6009
  }
5886
6010
  }
5887
6011
  return _this3.handleOperation(async () => {
5888
- return await post(_this3.fetch, `${_this3.url}/ListVectors`, options, { headers: _this3.headers });
6012
+ return await vectorsApi.post(_this3.fetch, `${_this3.url}/ListVectors`, options, { headers: _this3.headers });
5889
6013
  });
5890
6014
  }
5891
6015
  /** Queries for similar vectors using approximate nearest neighbor search */
5892
6016
  async queryVectors(options) {
5893
6017
  var _this4 = this;
5894
6018
  return _this4.handleOperation(async () => {
5895
- return await post(_this4.fetch, `${_this4.url}/QueryVectors`, options, { headers: _this4.headers });
6019
+ return await vectorsApi.post(_this4.fetch, `${_this4.url}/QueryVectors`, options, { headers: _this4.headers });
5896
6020
  });
5897
6021
  }
5898
6022
  /** Deletes vectors by their keys in batch (1-500 per request) */
@@ -5900,7 +6024,7 @@ var VectorDataApi = class extends BaseApiClient {
5900
6024
  var _this5 = this;
5901
6025
  if (options.keys.length < 1 || options.keys.length > 500) throw new Error("Keys batch size must be between 1 and 500 items");
5902
6026
  return _this5.handleOperation(async () => {
5903
- return await post(_this5.fetch, `${_this5.url}/DeleteVectors`, options, { headers: _this5.headers }) || {};
6027
+ return await vectorsApi.post(_this5.fetch, `${_this5.url}/DeleteVectors`, options, { headers: _this5.headers }) || {};
5904
6028
  });
5905
6029
  }
5906
6030
  };
@@ -5908,35 +6032,35 @@ var VectorBucketApi = class extends BaseApiClient {
5908
6032
  /** Creates a new VectorBucketApi instance */
5909
6033
  constructor(url, headers = {}, fetch$1) {
5910
6034
  const finalUrl = url.replace(/\/$/, "");
5911
- const finalHeaders = _objectSpread2(_objectSpread2({}, DEFAULT_HEADERS), {}, { "Content-Type": "application/json" }, headers);
6035
+ const finalHeaders = _objectSpread22(_objectSpread22({}, DEFAULT_HEADERS), {}, { "Content-Type": "application/json" }, headers);
5912
6036
  super(finalUrl, finalHeaders, fetch$1, "vectors");
5913
6037
  }
5914
6038
  /** Creates a new vector bucket */
5915
6039
  async createBucket(vectorBucketName) {
5916
6040
  var _this = this;
5917
6041
  return _this.handleOperation(async () => {
5918
- return await post(_this.fetch, `${_this.url}/CreateVectorBucket`, { vectorBucketName }, { headers: _this.headers }) || {};
6042
+ return await vectorsApi.post(_this.fetch, `${_this.url}/CreateVectorBucket`, { vectorBucketName }, { headers: _this.headers }) || {};
5919
6043
  });
5920
6044
  }
5921
6045
  /** Retrieves metadata for a specific vector bucket */
5922
6046
  async getBucket(vectorBucketName) {
5923
6047
  var _this2 = this;
5924
6048
  return _this2.handleOperation(async () => {
5925
- return await post(_this2.fetch, `${_this2.url}/GetVectorBucket`, { vectorBucketName }, { headers: _this2.headers });
6049
+ return await vectorsApi.post(_this2.fetch, `${_this2.url}/GetVectorBucket`, { vectorBucketName }, { headers: _this2.headers });
5926
6050
  });
5927
6051
  }
5928
6052
  /** Lists vector buckets with optional filtering and pagination */
5929
6053
  async listBuckets(options = {}) {
5930
6054
  var _this3 = this;
5931
6055
  return _this3.handleOperation(async () => {
5932
- return await post(_this3.fetch, `${_this3.url}/ListVectorBuckets`, options, { headers: _this3.headers });
6056
+ return await vectorsApi.post(_this3.fetch, `${_this3.url}/ListVectorBuckets`, options, { headers: _this3.headers });
5933
6057
  });
5934
6058
  }
5935
6059
  /** Deletes a vector bucket (must be empty first) */
5936
6060
  async deleteBucket(vectorBucketName) {
5937
6061
  var _this4 = this;
5938
6062
  return _this4.handleOperation(async () => {
5939
- return await post(_this4.fetch, `${_this4.url}/DeleteVectorBucket`, { vectorBucketName }, { headers: _this4.headers }) || {};
6063
+ return await vectorsApi.post(_this4.fetch, `${_this4.url}/DeleteVectorBucket`, { vectorBucketName }, { headers: _this4.headers }) || {};
5940
6064
  });
5941
6065
  }
5942
6066
  };
@@ -6134,7 +6258,7 @@ var VectorBucketScope = class extends VectorIndexApi {
6134
6258
  */
6135
6259
  async createIndex(options) {
6136
6260
  var _superprop_getCreateIndex = () => super.createIndex, _this5 = this;
6137
- return _superprop_getCreateIndex().call(_this5, _objectSpread2(_objectSpread2({}, options), {}, { vectorBucketName: _this5.vectorBucketName }));
6261
+ return _superprop_getCreateIndex().call(_this5, _objectSpread22(_objectSpread22({}, options), {}, { vectorBucketName: _this5.vectorBucketName }));
6138
6262
  }
6139
6263
  /**
6140
6264
  *
@@ -6157,7 +6281,7 @@ var VectorBucketScope = class extends VectorIndexApi {
6157
6281
  */
6158
6282
  async listIndexes(options = {}) {
6159
6283
  var _superprop_getListIndexes = () => super.listIndexes, _this6 = this;
6160
- return _superprop_getListIndexes().call(_this6, _objectSpread2(_objectSpread2({}, options), {}, { vectorBucketName: _this6.vectorBucketName }));
6284
+ return _superprop_getListIndexes().call(_this6, _objectSpread22(_objectSpread22({}, options), {}, { vectorBucketName: _this6.vectorBucketName }));
6161
6285
  }
6162
6286
  /**
6163
6287
  *
@@ -6290,7 +6414,7 @@ var VectorIndexScope = class extends VectorDataApi {
6290
6414
  */
6291
6415
  async putVectors(options) {
6292
6416
  var _superprop_getPutVectors = () => super.putVectors, _this9 = this;
6293
- return _superprop_getPutVectors().call(_this9, _objectSpread2(_objectSpread2({}, options), {}, {
6417
+ return _superprop_getPutVectors().call(_this9, _objectSpread22(_objectSpread22({}, options), {}, {
6294
6418
  vectorBucketName: _this9.vectorBucketName,
6295
6419
  indexName: _this9.indexName
6296
6420
  }));
@@ -6319,7 +6443,7 @@ var VectorIndexScope = class extends VectorDataApi {
6319
6443
  */
6320
6444
  async getVectors(options) {
6321
6445
  var _superprop_getGetVectors = () => super.getVectors, _this10 = this;
6322
- return _superprop_getGetVectors().call(_this10, _objectSpread2(_objectSpread2({}, options), {}, {
6446
+ return _superprop_getGetVectors().call(_this10, _objectSpread22(_objectSpread22({}, options), {}, {
6323
6447
  vectorBucketName: _this10.vectorBucketName,
6324
6448
  indexName: _this10.indexName
6325
6449
  }));
@@ -6348,7 +6472,7 @@ var VectorIndexScope = class extends VectorDataApi {
6348
6472
  */
6349
6473
  async listVectors(options = {}) {
6350
6474
  var _superprop_getListVectors = () => super.listVectors, _this11 = this;
6351
- return _superprop_getListVectors().call(_this11, _objectSpread2(_objectSpread2({}, options), {}, {
6475
+ return _superprop_getListVectors().call(_this11, _objectSpread22(_objectSpread22({}, options), {}, {
6352
6476
  vectorBucketName: _this11.vectorBucketName,
6353
6477
  indexName: _this11.indexName
6354
6478
  }));
@@ -6380,7 +6504,7 @@ var VectorIndexScope = class extends VectorDataApi {
6380
6504
  */
6381
6505
  async queryVectors(options) {
6382
6506
  var _superprop_getQueryVectors = () => super.queryVectors, _this12 = this;
6383
- return _superprop_getQueryVectors().call(_this12, _objectSpread2(_objectSpread2({}, options), {}, {
6507
+ return _superprop_getQueryVectors().call(_this12, _objectSpread22(_objectSpread22({}, options), {}, {
6384
6508
  vectorBucketName: _this12.vectorBucketName,
6385
6509
  indexName: _this12.indexName
6386
6510
  }));
@@ -6408,7 +6532,7 @@ var VectorIndexScope = class extends VectorDataApi {
6408
6532
  */
6409
6533
  async deleteVectors(options) {
6410
6534
  var _superprop_getDeleteVectors = () => super.deleteVectors, _this13 = this;
6411
- return _superprop_getDeleteVectors().call(_this13, _objectSpread2(_objectSpread2({}, options), {}, {
6535
+ return _superprop_getDeleteVectors().call(_this13, _objectSpread22(_objectSpread22({}, options), {}, {
6412
6536
  vectorBucketName: _this13.vectorBucketName,
6413
6537
  indexName: _this13.indexName
6414
6538
  }));
@@ -6480,7 +6604,7 @@ var StorageClient = class extends StorageBucketApi {
6480
6604
  };
6481
6605
 
6482
6606
  // ../../node_modules/@supabase/auth-js/dist/module/lib/version.js
6483
- var version3 = "2.93.2";
6607
+ var version3 = "2.95.3";
6484
6608
 
6485
6609
  // ../../node_modules/@supabase/auth-js/dist/module/lib/constants.js
6486
6610
  var AUTO_REFRESH_TICK_DURATION_MS = 30 * 1e3;
@@ -8248,6 +8372,7 @@ var WebAuthnApi = class {
8248
8372
  * @see {@link https://w3c.github.io/webauthn/#sctn-verifying-assertion W3C WebAuthn Spec - Verifying Assertion}
8249
8373
  */
8250
8374
  async _challenge({ factorId, webauthn, friendlyName, signal }, overrides) {
8375
+ var _a;
8251
8376
  try {
8252
8377
  const { data: challengeResponse, error: challengeError } = await this.client.mfa.challenge({
8253
8378
  factorId,
@@ -8260,7 +8385,15 @@ var WebAuthnApi = class {
8260
8385
  if (challengeResponse.webauthn.type === "create") {
8261
8386
  const { user } = challengeResponse.webauthn.credential_options.publicKey;
8262
8387
  if (!user.name) {
8263
- user.name = `${user.id}:${friendlyName}`;
8388
+ const nameToUse = friendlyName;
8389
+ if (!nameToUse) {
8390
+ const currentUser = await this.client.getUser();
8391
+ const userData = currentUser.data.user;
8392
+ const fallbackName = ((_a = userData === null || userData === void 0 ? void 0 : userData.user_metadata) === null || _a === void 0 ? void 0 : _a.name) || (userData === null || userData === void 0 ? void 0 : userData.email) || (userData === null || userData === void 0 ? void 0 : userData.id) || "User";
8393
+ user.name = `${user.id}:${fallbackName}`;
8394
+ } else {
8395
+ user.name = `${user.id}:${nameToUse}`;
8396
+ }
8264
8397
  }
8265
8398
  if (!user.displayName) {
8266
8399
  user.displayName = user.name;
@@ -10770,7 +10903,7 @@ var GoTrueClient = class _GoTrueClient {
10770
10903
  * Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
10771
10904
  *
10772
10905
  * Returns authorization details including client info, scopes, and user information.
10773
- * If the API returns a redirect_uri, it means consent was already given - the caller
10906
+ * If the response includes only a redirect_url field, it means consent was already given - the caller
10774
10907
  * should handle the redirect manually if needed.
10775
10908
  */
10776
10909
  async _getAuthorizationDetails(authorizationId) {
@@ -11024,7 +11157,7 @@ var AuthClient = GoTrueClient_default;
11024
11157
  var AuthClient_default = AuthClient;
11025
11158
 
11026
11159
  // ../../node_modules/@supabase/supabase-js/dist/index.mjs
11027
- var version4 = "2.93.2";
11160
+ var version4 = "2.95.3";
11028
11161
  var JS_ENV = "";
11029
11162
  if (typeof Deno !== "undefined") JS_ENV = "deno";
11030
11163
  else if (typeof document !== "undefined") JS_ENV = "web";
@@ -11040,37 +11173,37 @@ var DEFAULT_AUTH_OPTIONS = {
11040
11173
  flowType: "implicit"
11041
11174
  };
11042
11175
  var DEFAULT_REALTIME_OPTIONS = {};
11043
- function _typeof2(o) {
11176
+ function _typeof3(o) {
11044
11177
  "@babel/helpers - typeof";
11045
- return _typeof2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
11178
+ return _typeof3 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
11046
11179
  return typeof o$1;
11047
11180
  } : function(o$1) {
11048
11181
  return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
11049
- }, _typeof2(o);
11182
+ }, _typeof3(o);
11050
11183
  }
11051
- function toPrimitive2(t, r) {
11052
- if ("object" != _typeof2(t) || !t) return t;
11184
+ function toPrimitive3(t, r) {
11185
+ if ("object" != _typeof3(t) || !t) return t;
11053
11186
  var e = t[Symbol.toPrimitive];
11054
11187
  if (void 0 !== e) {
11055
11188
  var i = e.call(t, r || "default");
11056
- if ("object" != _typeof2(i)) return i;
11189
+ if ("object" != _typeof3(i)) return i;
11057
11190
  throw new TypeError("@@toPrimitive must return a primitive value.");
11058
11191
  }
11059
11192
  return ("string" === r ? String : Number)(t);
11060
11193
  }
11061
- function toPropertyKey2(t) {
11062
- var i = toPrimitive2(t, "string");
11063
- return "symbol" == _typeof2(i) ? i : i + "";
11194
+ function toPropertyKey3(t) {
11195
+ var i = toPrimitive3(t, "string");
11196
+ return "symbol" == _typeof3(i) ? i : i + "";
11064
11197
  }
11065
- function _defineProperty2(e, r, t) {
11066
- return (r = toPropertyKey2(r)) in e ? Object.defineProperty(e, r, {
11198
+ function _defineProperty3(e, r, t) {
11199
+ return (r = toPropertyKey3(r)) in e ? Object.defineProperty(e, r, {
11067
11200
  value: t,
11068
11201
  enumerable: true,
11069
11202
  configurable: true,
11070
11203
  writable: true
11071
11204
  }) : e[r] = t, e;
11072
11205
  }
11073
- function ownKeys2(e, r) {
11206
+ function ownKeys3(e, r) {
11074
11207
  var t = Object.keys(e);
11075
11208
  if (Object.getOwnPropertySymbols) {
11076
11209
  var o = Object.getOwnPropertySymbols(e);
@@ -11080,12 +11213,12 @@ function ownKeys2(e, r) {
11080
11213
  }
11081
11214
  return t;
11082
11215
  }
11083
- function _objectSpread22(e) {
11216
+ function _objectSpread23(e) {
11084
11217
  for (var r = 1; r < arguments.length; r++) {
11085
11218
  var t = null != arguments[r] ? arguments[r] : {};
11086
- r % 2 ? ownKeys2(Object(t), true).forEach(function(r$1) {
11087
- _defineProperty2(e, r$1, t[r$1]);
11088
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys2(Object(t)).forEach(function(r$1) {
11219
+ r % 2 ? ownKeys3(Object(t), true).forEach(function(r$1) {
11220
+ _defineProperty3(e, r$1, t[r$1]);
11221
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys3(Object(t)).forEach(function(r$1) {
11089
11222
  Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
11090
11223
  });
11091
11224
  }
@@ -11107,7 +11240,7 @@ var fetchWithAuth = (supabaseKey, getAccessToken, customFetch) => {
11107
11240
  let headers = new HeadersConstructor(init === null || init === void 0 ? void 0 : init.headers);
11108
11241
  if (!headers.has("apikey")) headers.set("apikey", supabaseKey);
11109
11242
  if (!headers.has("Authorization")) headers.set("Authorization", `Bearer ${accessToken}`);
11110
- return fetch$1(input, _objectSpread22(_objectSpread22({}, init), {}, { headers }));
11243
+ return fetch$1(input, _objectSpread23(_objectSpread23({}, init), {}, { headers }));
11111
11244
  };
11112
11245
  };
11113
11246
  function ensureTrailingSlash(url) {
@@ -11118,11 +11251,11 @@ function applySettingDefaults(options, defaults) {
11118
11251
  const { db: dbOptions, auth: authOptions, realtime: realtimeOptions, global: globalOptions } = options;
11119
11252
  const { db: DEFAULT_DB_OPTIONS$1, auth: DEFAULT_AUTH_OPTIONS$1, realtime: DEFAULT_REALTIME_OPTIONS$1, global: DEFAULT_GLOBAL_OPTIONS$1 } = defaults;
11120
11253
  const result = {
11121
- db: _objectSpread22(_objectSpread22({}, DEFAULT_DB_OPTIONS$1), dbOptions),
11122
- auth: _objectSpread22(_objectSpread22({}, DEFAULT_AUTH_OPTIONS$1), authOptions),
11123
- realtime: _objectSpread22(_objectSpread22({}, DEFAULT_REALTIME_OPTIONS$1), realtimeOptions),
11254
+ db: _objectSpread23(_objectSpread23({}, DEFAULT_DB_OPTIONS$1), dbOptions),
11255
+ auth: _objectSpread23(_objectSpread23({}, DEFAULT_AUTH_OPTIONS$1), authOptions),
11256
+ realtime: _objectSpread23(_objectSpread23({}, DEFAULT_REALTIME_OPTIONS$1), realtimeOptions),
11124
11257
  storage: {},
11125
- global: _objectSpread22(_objectSpread22(_objectSpread22({}, DEFAULT_GLOBAL_OPTIONS$1), globalOptions), {}, { headers: _objectSpread22(_objectSpread22({}, (_DEFAULT_GLOBAL_OPTIO = DEFAULT_GLOBAL_OPTIONS$1 === null || DEFAULT_GLOBAL_OPTIONS$1 === void 0 ? void 0 : DEFAULT_GLOBAL_OPTIONS$1.headers) !== null && _DEFAULT_GLOBAL_OPTIO !== void 0 ? _DEFAULT_GLOBAL_OPTIO : {}), (_globalOptions$header = globalOptions === null || globalOptions === void 0 ? void 0 : globalOptions.headers) !== null && _globalOptions$header !== void 0 ? _globalOptions$header : {}) }),
11258
+ global: _objectSpread23(_objectSpread23(_objectSpread23({}, DEFAULT_GLOBAL_OPTIONS$1), globalOptions), {}, { headers: _objectSpread23(_objectSpread23({}, (_DEFAULT_GLOBAL_OPTIO = DEFAULT_GLOBAL_OPTIONS$1 === null || DEFAULT_GLOBAL_OPTIONS$1 === void 0 ? void 0 : DEFAULT_GLOBAL_OPTIONS$1.headers) !== null && _DEFAULT_GLOBAL_OPTIO !== void 0 ? _DEFAULT_GLOBAL_OPTIO : {}), (_globalOptions$header = globalOptions === null || globalOptions === void 0 ? void 0 : globalOptions.headers) !== null && _globalOptions$header !== void 0 ? _globalOptions$header : {}) }),
11126
11259
  accessToken: async () => ""
11127
11260
  };
11128
11261
  if (options.accessToken) result.accessToken = options.accessToken;
@@ -11180,7 +11313,7 @@ var SupabaseClient = class {
11180
11313
  const DEFAULTS = {
11181
11314
  db: DEFAULT_DB_OPTIONS,
11182
11315
  realtime: DEFAULT_REALTIME_OPTIONS,
11183
- auth: _objectSpread22(_objectSpread22({}, DEFAULT_AUTH_OPTIONS), {}, { storageKey: defaultStorageKey }),
11316
+ auth: _objectSpread23(_objectSpread23({}, DEFAULT_AUTH_OPTIONS), {}, { storageKey: defaultStorageKey }),
11184
11317
  global: DEFAULT_GLOBAL_OPTIONS
11185
11318
  };
11186
11319
  const settings = applySettingDefaults(options !== null && options !== void 0 ? options : {}, DEFAULTS);
@@ -11196,7 +11329,7 @@ var SupabaseClient = class {
11196
11329
  } });
11197
11330
  }
11198
11331
  this.fetch = fetchWithAuth(supabaseKey, this._getAccessToken.bind(this), settings.global.fetch);
11199
- this.realtime = this._initRealtimeClient(_objectSpread22({
11332
+ this.realtime = this._initRealtimeClient(_objectSpread23({
11200
11333
  headers: this.headers,
11201
11334
  accessToken: this._getAccessToken.bind(this)
11202
11335
  }, settings.realtime));
@@ -11204,7 +11337,9 @@ var SupabaseClient = class {
11204
11337
  this.rest = new PostgrestClient(new URL("rest/v1", baseUrl).href, {
11205
11338
  headers: this.headers,
11206
11339
  schema: settings.db.schema,
11207
- fetch: this.fetch
11340
+ fetch: this.fetch,
11341
+ timeout: settings.db.timeout,
11342
+ urlLengthLimit: settings.db.urlLengthLimit
11208
11343
  });
11209
11344
  this.storage = new StorageClient(this.storageUrl.href, this.headers, this.fetch, options === null || options === void 0 ? void 0 : options.storage);
11210
11345
  if (!settings.accessToken) this._listenForAuthEvents();
@@ -11311,7 +11446,7 @@ var SupabaseClient = class {
11311
11446
  };
11312
11447
  return new SupabaseAuthClient({
11313
11448
  url: this.authUrl.href,
11314
- headers: _objectSpread22(_objectSpread22({}, authHeaders), headers),
11449
+ headers: _objectSpread23(_objectSpread23({}, authHeaders), headers),
11315
11450
  storageKey,
11316
11451
  autoRefreshToken,
11317
11452
  persistSession,
@@ -11327,7 +11462,7 @@ var SupabaseClient = class {
11327
11462
  });
11328
11463
  }
11329
11464
  _initRealtimeClient(options) {
11330
- return new RealtimeClient(this.realtimeUrl.href, _objectSpread22(_objectSpread22({}, options), {}, { params: _objectSpread22(_objectSpread22({}, { apikey: this.supabaseKey }), options === null || options === void 0 ? void 0 : options.params) }));
11465
+ return new RealtimeClient(this.realtimeUrl.href, _objectSpread23(_objectSpread23({}, options), {}, { params: _objectSpread23(_objectSpread23({}, { apikey: this.supabaseKey }), options === null || options === void 0 ? void 0 : options.params) }));
11331
11466
  }
11332
11467
  _listenForAuthEvents() {
11333
11468
  return this.auth.onAuthStateChange((event, session) => {
@@ -11372,6 +11507,7 @@ var ContextCaptureManager = class {
11372
11507
  this.networkRequests = [];
11373
11508
  this.navigationHistory = [];
11374
11509
  this.originalConsole = {};
11510
+ this.fetchHost = null;
11375
11511
  this.isCapturing = false;
11376
11512
  }
11377
11513
  /**
@@ -11394,8 +11530,9 @@ var ContextCaptureManager = class {
11394
11530
  if (this.originalConsole.warn) console.warn = this.originalConsole.warn;
11395
11531
  if (this.originalConsole.error) console.error = this.originalConsole.error;
11396
11532
  if (this.originalConsole.info) console.info = this.originalConsole.info;
11397
- if (this.originalFetch && typeof window !== "undefined") {
11398
- window.fetch = this.originalFetch;
11533
+ if (this.originalFetch && this.fetchHost) {
11534
+ this.fetchHost.fetch = this.originalFetch;
11535
+ this.fetchHost = null;
11399
11536
  }
11400
11537
  if (typeof window !== "undefined" && typeof history !== "undefined") {
11401
11538
  if (this.originalPushState) {
@@ -11434,7 +11571,7 @@ var ContextCaptureManager = class {
11434
11571
  if (this.navigationHistory.length > 0) {
11435
11572
  return this.navigationHistory[this.navigationHistory.length - 1];
11436
11573
  }
11437
- if (typeof window !== "undefined") {
11574
+ if (typeof window !== "undefined" && window.location) {
11438
11575
  return window.location.pathname;
11439
11576
  }
11440
11577
  return "unknown";
@@ -11504,15 +11641,19 @@ var ContextCaptureManager = class {
11504
11641
  });
11505
11642
  }
11506
11643
  captureFetch() {
11507
- if (typeof window === "undefined" || typeof fetch === "undefined" || typeof document === "undefined") return;
11508
- this.originalFetch = window.fetch;
11644
+ if (typeof fetch === "undefined") return;
11645
+ const host = typeof window !== "undefined" && typeof window.fetch === "function" ? window : typeof globalThis !== "undefined" && typeof globalThis.fetch === "function" ? globalThis : null;
11646
+ if (!host) return;
11647
+ const canCloneResponse = typeof document !== "undefined";
11648
+ this.fetchHost = host;
11649
+ this.originalFetch = host.fetch;
11509
11650
  const self2 = this;
11510
- window.fetch = async function(input, init) {
11651
+ host.fetch = async function(input, init) {
11511
11652
  const startTime = Date.now();
11512
11653
  const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
11513
11654
  const method = init?.method || "GET";
11514
11655
  try {
11515
- const response = await self2.originalFetch.call(window, input, init);
11656
+ const response = await self2.originalFetch.call(host, input, init);
11516
11657
  const requestEntry = {
11517
11658
  method,
11518
11659
  url: url.slice(0, 200),
@@ -11521,7 +11662,7 @@ var ContextCaptureManager = class {
11521
11662
  duration: Date.now() - startTime,
11522
11663
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
11523
11664
  };
11524
- if (response.status >= 400) {
11665
+ if (canCloneResponse && response.status >= 400) {
11525
11666
  try {
11526
11667
  const cloned = response.clone();
11527
11668
  const body = await cloned.text();
@@ -11546,7 +11687,7 @@ var ContextCaptureManager = class {
11546
11687
  };
11547
11688
  }
11548
11689
  captureNavigation() {
11549
- if (typeof window === "undefined" || typeof history === "undefined") return;
11690
+ if (typeof window === "undefined" || typeof history === "undefined" || !window.location) return;
11550
11691
  this.trackNavigation(window.location.pathname);
11551
11692
  const self2 = this;
11552
11693
  this.originalPushState = history.pushState;
@@ -11584,13 +11725,13 @@ var ContextCaptureManager = class {
11584
11725
  return Object.keys(metrics).length > 0 ? metrics : void 0;
11585
11726
  }
11586
11727
  getEnvironmentInfo() {
11587
- if (typeof window === "undefined" || typeof navigator === "undefined") return void 0;
11728
+ if (typeof window === "undefined" || typeof navigator === "undefined" || typeof document === "undefined") return void 0;
11588
11729
  return {
11589
11730
  language: navigator.language,
11590
11731
  timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
11591
- cookiesEnabled: navigator.cookieEnabled,
11732
+ cookiesEnabled: navigator.cookieEnabled ?? false,
11592
11733
  localStorage: typeof localStorage !== "undefined",
11593
- online: navigator.onLine
11734
+ online: navigator.onLine ?? true
11594
11735
  };
11595
11736
  }
11596
11737
  };
@@ -11765,29 +11906,140 @@ var formatPgError = (e) => {
11765
11906
  const { message, code, details, hint } = e;
11766
11907
  return { message, code, details, hint };
11767
11908
  };
11909
+ var DEFAULT_API_BASE_URL = "https://app.bugbear.ai";
11910
+ var CONFIG_CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
11911
+ var CONFIG_CACHE_PREFIX = "bugbear_config_";
11768
11912
  var BugBearClient = class {
11769
11913
  constructor(config) {
11770
11914
  this.navigationHistory = [];
11771
11915
  this.reportSubmitInFlight = false;
11772
11916
  this._queue = null;
11773
11917
  this.realtimeChannels = [];
11774
- if (!config.supabaseUrl) {
11775
- throw new Error("BugBear: supabaseUrl is required. Get it from your BugBear project settings.");
11776
- }
11777
- if (!config.supabaseAnonKey) {
11778
- throw new Error("BugBear: supabaseAnonKey is required. Get it from your BugBear project settings.");
11779
- }
11918
+ this.initialized = false;
11919
+ this.initError = null;
11780
11920
  this.config = config;
11781
- this.supabase = createClient(config.supabaseUrl, config.supabaseAnonKey);
11782
- if (config.offlineQueue?.enabled) {
11921
+ if (config.apiKey) {
11922
+ this.pendingInit = this.resolveFromApiKey(config.apiKey);
11923
+ } else if (config.supabaseUrl && config.supabaseAnonKey) {
11924
+ if (!config.projectId) {
11925
+ throw new Error(
11926
+ "BugBear: projectId is required when using explicit Supabase credentials. Tip: Use apiKey instead for simpler setup \u2014 it resolves everything automatically."
11927
+ );
11928
+ }
11929
+ this.supabase = createClient(config.supabaseUrl, config.supabaseAnonKey);
11930
+ this.initialized = true;
11931
+ this.pendingInit = Promise.resolve();
11932
+ this.initOfflineQueue();
11933
+ } else {
11934
+ throw new Error(
11935
+ "BugBear: Missing configuration. Provide either:\n \u2022 apiKey (recommended) \u2014 resolves everything automatically\n \u2022 projectId + supabaseUrl + supabaseAnonKey \u2014 explicit credentials\n\nGet your API key at https://app.bugbear.ai/settings/projects"
11936
+ );
11937
+ }
11938
+ }
11939
+ /** Whether the client is ready for requests. */
11940
+ get isReady() {
11941
+ return this.initialized;
11942
+ }
11943
+ /** Wait until the client is ready. Throws if initialization failed. */
11944
+ async ready() {
11945
+ await this.pendingInit;
11946
+ if (this.initError) throw this.initError;
11947
+ }
11948
+ /**
11949
+ * Resolve Supabase credentials from a BugBear API key.
11950
+ * Checks localStorage cache first, falls back to /api/v1/config.
11951
+ */
11952
+ async resolveFromApiKey(apiKey) {
11953
+ try {
11954
+ const cached = this.readConfigCache(apiKey);
11955
+ if (cached) {
11956
+ this.applyResolvedConfig(cached);
11957
+ return;
11958
+ }
11959
+ const baseUrl = (this.config.apiBaseUrl || DEFAULT_API_BASE_URL).replace(/\/$/, "");
11960
+ const response = await fetch(`${baseUrl}/api/v1/config`, {
11961
+ headers: { Authorization: `Bearer ${apiKey}` }
11962
+ });
11963
+ if (!response.ok) {
11964
+ const body = await response.json().catch(() => ({}));
11965
+ const message = body.error || `HTTP ${response.status}`;
11966
+ throw new Error(
11967
+ `BugBear: Invalid API key \u2014 ${message}. Get yours at https://app.bugbear.ai/settings/projects`
11968
+ );
11969
+ }
11970
+ const data = await response.json();
11971
+ this.writeConfigCache(apiKey, data);
11972
+ this.applyResolvedConfig(data);
11973
+ } catch (err) {
11974
+ this.initError = err instanceof Error ? err : new Error(String(err));
11975
+ this.config.onError?.(this.initError, { context: "apikey_resolution_failed" });
11976
+ throw this.initError;
11977
+ }
11978
+ }
11979
+ /** Apply resolved credentials and create the Supabase client. */
11980
+ applyResolvedConfig(resolved) {
11981
+ this.config = {
11982
+ ...this.config,
11983
+ projectId: resolved.projectId,
11984
+ supabaseUrl: resolved.supabaseUrl,
11985
+ supabaseAnonKey: resolved.supabaseAnonKey
11986
+ };
11987
+ this.supabase = createClient(resolved.supabaseUrl, resolved.supabaseAnonKey);
11988
+ this.initialized = true;
11989
+ this.initOfflineQueue();
11990
+ }
11991
+ /** Initialize offline queue if configured. Shared by both init paths. */
11992
+ initOfflineQueue() {
11993
+ if (this.config.offlineQueue?.enabled) {
11783
11994
  this._queue = new OfflineQueue({
11784
11995
  enabled: true,
11785
- maxItems: config.offlineQueue.maxItems,
11786
- maxRetries: config.offlineQueue.maxRetries
11996
+ maxItems: this.config.offlineQueue.maxItems,
11997
+ maxRetries: this.config.offlineQueue.maxRetries
11787
11998
  });
11788
11999
  this.registerQueueHandlers();
11789
12000
  }
11790
12001
  }
12002
+ /** Read cached config from localStorage if available and not expired. */
12003
+ readConfigCache(apiKey) {
12004
+ if (typeof localStorage === "undefined") return null;
12005
+ try {
12006
+ const key = CONFIG_CACHE_PREFIX + this.hashKey(apiKey);
12007
+ const raw = localStorage.getItem(key);
12008
+ if (!raw) return null;
12009
+ const cached = JSON.parse(raw);
12010
+ if (Date.now() - cached.cachedAt > CONFIG_CACHE_TTL_MS) {
12011
+ localStorage.removeItem(key);
12012
+ return null;
12013
+ }
12014
+ return cached;
12015
+ } catch {
12016
+ return null;
12017
+ }
12018
+ }
12019
+ /** Write resolved config to localStorage cache. */
12020
+ writeConfigCache(apiKey, data) {
12021
+ if (typeof localStorage === "undefined") return;
12022
+ try {
12023
+ const key = CONFIG_CACHE_PREFIX + this.hashKey(apiKey);
12024
+ const cached = { ...data, cachedAt: Date.now() };
12025
+ localStorage.setItem(key, JSON.stringify(cached));
12026
+ } catch {
12027
+ }
12028
+ }
12029
+ /** Simple string hash for cache keys — avoids storing raw API keys. */
12030
+ hashKey(apiKey) {
12031
+ let hash = 0;
12032
+ for (let i = 0; i < apiKey.length; i++) {
12033
+ hash = (hash << 5) - hash + apiKey.charCodeAt(i) | 0;
12034
+ }
12035
+ return hash.toString(36);
12036
+ }
12037
+ /** Ensure the client is initialized before making requests. */
12038
+ async ensureReady() {
12039
+ if (this.initialized) return;
12040
+ await this.pendingInit;
12041
+ if (this.initError) throw this.initError;
12042
+ }
11791
12043
  // ── Offline Queue ─────────────────────────────────────────
11792
12044
  /**
11793
12045
  * Access the offline queue (if enabled).
@@ -11943,6 +12195,7 @@ var BugBearClient = class {
11943
12195
  * Get current user info from host app or BugBear's own auth
11944
12196
  */
11945
12197
  async getCurrentUserInfo() {
12198
+ await this.ensureReady();
11946
12199
  if (this.config.getCurrentUser) {
11947
12200
  return await this.config.getCurrentUser();
11948
12201
  }
@@ -12162,6 +12415,7 @@ var BugBearClient = class {
12162
12415
  */
12163
12416
  async getAssignment(assignmentId) {
12164
12417
  try {
12418
+ await this.ensureReady();
12165
12419
  const { data, error } = await this.supabase.from("test_assignments").select(`
12166
12420
  id,
12167
12421
  status,
@@ -12233,6 +12487,7 @@ var BugBearClient = class {
12233
12487
  */
12234
12488
  async updateAssignmentStatus(assignmentId, status, options) {
12235
12489
  try {
12490
+ await this.ensureReady();
12236
12491
  const { data: currentAssignment, error: fetchError } = await this.supabase.from("test_assignments").select("status, started_at").eq("id", assignmentId).single();
12237
12492
  if (fetchError || !currentAssignment) {
12238
12493
  console.error("BugBear: Assignment not found", {
@@ -12319,6 +12574,7 @@ var BugBearClient = class {
12319
12574
  */
12320
12575
  async reopenAssignment(assignmentId) {
12321
12576
  try {
12577
+ await this.ensureReady();
12322
12578
  const { data: current, error: fetchError } = await this.supabase.from("test_assignments").select("status").eq("id", assignmentId).single();
12323
12579
  if (fetchError || !current) {
12324
12580
  return { success: false, error: "Assignment not found" };
@@ -12358,6 +12614,7 @@ var BugBearClient = class {
12358
12614
  actualNotes = notes;
12359
12615
  }
12360
12616
  try {
12617
+ await this.ensureReady();
12361
12618
  const updateData = {
12362
12619
  status: "skipped",
12363
12620
  skip_reason: actualReason,
@@ -12527,6 +12784,7 @@ var BugBearClient = class {
12527
12784
  */
12528
12785
  async getTesterInfo() {
12529
12786
  try {
12787
+ await this.ensureReady();
12530
12788
  const userInfo = await this.getCurrentUserInfo();
12531
12789
  if (!userInfo?.email) return null;
12532
12790
  if (!this.isValidEmail(userInfo.email)) {
@@ -12818,6 +13076,7 @@ var BugBearClient = class {
12818
13076
  */
12819
13077
  async isQAEnabled() {
12820
13078
  try {
13079
+ await this.ensureReady();
12821
13080
  const { data, error } = await this.supabase.rpc("check_qa_enabled", {
12822
13081
  p_project_id: this.config.projectId
12823
13082
  });
@@ -12849,6 +13108,7 @@ var BugBearClient = class {
12849
13108
  */
12850
13109
  async uploadScreenshot(file, filename, bucket = "screenshots") {
12851
13110
  try {
13111
+ await this.ensureReady();
12852
13112
  const contentType = file.type || "image/png";
12853
13113
  const ext = contentType.includes("png") ? "png" : "jpg";
12854
13114
  const name = filename || `screenshot-${Date.now()}.${ext}`;
@@ -12889,6 +13149,7 @@ var BugBearClient = class {
12889
13149
  */
12890
13150
  async uploadImageFromUri(uri, filename, bucket = "screenshots") {
12891
13151
  try {
13152
+ await this.ensureReady();
12892
13153
  const response = await fetch(uri);
12893
13154
  const blob = await response.blob();
12894
13155
  const contentType = blob.type || "image/jpeg";
@@ -12934,15 +13195,18 @@ var BugBearClient = class {
12934
13195
  * Get device info (override in platform-specific implementations)
12935
13196
  */
12936
13197
  getDeviceInfo() {
12937
- if (typeof window !== "undefined") {
12938
- return {
12939
- platform: "web",
12940
- userAgent: navigator.userAgent,
12941
- screenSize: {
13198
+ if (typeof window !== "undefined" && typeof document !== "undefined") {
13199
+ const info = { platform: "web" };
13200
+ if (typeof navigator !== "undefined" && navigator.userAgent) {
13201
+ info.userAgent = navigator.userAgent;
13202
+ }
13203
+ if (window.screen) {
13204
+ info.screenSize = {
12942
13205
  width: window.screen.width,
12943
13206
  height: window.screen.height
12944
- }
12945
- };
13207
+ };
13208
+ }
13209
+ return info;
12946
13210
  }
12947
13211
  return { platform: "web" };
12948
13212
  }
@@ -12980,6 +13244,7 @@ var BugBearClient = class {
12980
13244
  */
12981
13245
  async getFixRequests(options) {
12982
13246
  try {
13247
+ await this.ensureReady();
12983
13248
  let query = this.supabase.from("fix_requests").select("*").eq("project_id", this.config.projectId).order("created_at", { ascending: false }).limit(options?.limit || 20);
12984
13249
  if (options?.status) {
12985
13250
  query = query.eq("status", options.status);
@@ -13051,6 +13316,7 @@ var BugBearClient = class {
13051
13316
  */
13052
13317
  async getThreadMessages(threadId) {
13053
13318
  try {
13319
+ await this.ensureReady();
13054
13320
  const { data, error } = await this.supabase.from("discussion_messages").select(`
13055
13321
  id,
13056
13322
  thread_id,
@@ -13253,6 +13519,7 @@ var BugBearClient = class {
13253
13519
  */
13254
13520
  async endSession(sessionId, options = {}) {
13255
13521
  try {
13522
+ await this.ensureReady();
13256
13523
  const { data, error } = await this.supabase.rpc("end_qa_session", {
13257
13524
  p_session_id: sessionId,
13258
13525
  p_notes: options.notes || null,
@@ -13290,6 +13557,7 @@ var BugBearClient = class {
13290
13557
  */
13291
13558
  async getSession(sessionId) {
13292
13559
  try {
13560
+ await this.ensureReady();
13293
13561
  const { data, error } = await this.supabase.from("qa_sessions").select("*").eq("id", sessionId).single();
13294
13562
  if (error || !data) return null;
13295
13563
  return this.transformSession(data);
@@ -13321,6 +13589,7 @@ var BugBearClient = class {
13321
13589
  */
13322
13590
  async addFinding(sessionId, options) {
13323
13591
  try {
13592
+ await this.ensureReady();
13324
13593
  const { data, error } = await this.supabase.rpc("add_session_finding", {
13325
13594
  p_session_id: sessionId,
13326
13595
  p_type: options.type,
@@ -13351,6 +13620,7 @@ var BugBearClient = class {
13351
13620
  */
13352
13621
  async getSessionFindings(sessionId) {
13353
13622
  try {
13623
+ await this.ensureReady();
13354
13624
  const { data, error } = await this.supabase.from("qa_findings").select("*").eq("session_id", sessionId).order("created_at", { ascending: true }).limit(100);
13355
13625
  if (error) {
13356
13626
  console.error("BugBear: Failed to fetch findings", formatPgError(error));
@@ -13367,6 +13637,7 @@ var BugBearClient = class {
13367
13637
  */
13368
13638
  async convertFindingToBug(findingId) {
13369
13639
  try {
13640
+ await this.ensureReady();
13370
13641
  const { data, error } = await this.supabase.rpc("convert_finding_to_bug", {
13371
13642
  p_finding_id: findingId
13372
13643
  });
@@ -13386,6 +13657,7 @@ var BugBearClient = class {
13386
13657
  */
13387
13658
  async dismissFinding(findingId, reason) {
13388
13659
  try {
13660
+ await this.ensureReady();
13389
13661
  const { error } = await this.supabase.from("qa_findings").update({
13390
13662
  dismissed: true,
13391
13663
  dismissed_reason: reason || null,
@@ -14952,9 +15224,9 @@ function TestListScreen({ nav }) {
14952
15224
  /* @__PURE__ */ React5.createElement(Text3, { style: [styles3.trackBtnText, isActive && { color: track.color, fontWeight: "600" }] }, track.icon, " ", track.name)
14953
15225
  );
14954
15226
  })), /* @__PURE__ */ React5.createElement(View4, { style: styles3.sortGroup }, [
14955
- { key: "priority", label: "\u2195" },
14956
- { key: "recent", label: "\u{1F550}" },
14957
- { key: "alpha", label: "AZ" }
15227
+ { key: "priority", label: "\u2195 Priority" },
15228
+ { key: "recent", label: "\u{1F550} Recent" },
15229
+ { key: "alpha", label: "A-Z" }
14958
15230
  ].map((s2) => /* @__PURE__ */ React5.createElement(
14959
15231
  TouchableOpacity3,
14960
15232
  {
@@ -16169,10 +16441,11 @@ var styles13 = StyleSheet15.create({
16169
16441
  });
16170
16442
 
16171
16443
  // src/widget/screens/IssueListScreen.tsx
16172
- import React16, { useState as useState11, useEffect as useEffect10 } from "react";
16444
+ import React16, { useState as useState11, useEffect as useEffect10, useMemo as useMemo3 } from "react";
16173
16445
  import { View as View15, Text as Text14, TouchableOpacity as TouchableOpacity13, StyleSheet as StyleSheet16 } from "react-native";
16446
+ var CATEGORIES = ["open", "done", "reopened"];
16174
16447
  var CATEGORY_CONFIG = {
16175
- open: { label: "Open Issues", accent: "#f97316", emptyIcon: "\u2705", emptyText: "No open issues" },
16448
+ open: { label: "Open", accent: "#f97316", emptyIcon: "\u2705", emptyText: "No open issues" },
16176
16449
  done: { label: "Done", accent: "#22c55e", emptyIcon: "\u{1F389}", emptyText: "No completed issues yet" },
16177
16450
  reopened: { label: "Reopened", accent: "#ef4444", emptyIcon: "\u{1F44D}", emptyText: "No reopened issues" }
16178
16451
  };
@@ -16182,11 +16455,20 @@ var SEVERITY_COLORS = {
16182
16455
  medium: "#eab308",
16183
16456
  low: "#71717a"
16184
16457
  };
16458
+ var SEVERITY_ORDER = { critical: 0, high: 1, medium: 2, low: 3 };
16185
16459
  function IssueListScreen({ nav, category }) {
16186
16460
  const { client } = useBugBear();
16461
+ const [activeCategory, setActiveCategory] = useState11(category);
16187
16462
  const [issues, setIssues] = useState11([]);
16188
16463
  const [loading, setLoading] = useState11(true);
16189
- const config = CATEGORY_CONFIG[category];
16464
+ const [counts, setCounts] = useState11(null);
16465
+ const [sortMode, setSortMode] = useState11("severity");
16466
+ const config = CATEGORY_CONFIG[activeCategory];
16467
+ useEffect10(() => {
16468
+ if (!client) return;
16469
+ client.getIssueCounts().then(setCounts).catch(() => {
16470
+ });
16471
+ }, [client]);
16190
16472
  useEffect10(() => {
16191
16473
  let cancelled = false;
16192
16474
  setLoading(true);
@@ -16196,7 +16478,7 @@ function IssueListScreen({ nav, category }) {
16196
16478
  return;
16197
16479
  }
16198
16480
  try {
16199
- const data = await client.getIssues(category);
16481
+ const data = await client.getIssues(activeCategory);
16200
16482
  if (!cancelled) {
16201
16483
  setIssues(data);
16202
16484
  }
@@ -16211,14 +16493,63 @@ function IssueListScreen({ nav, category }) {
16211
16493
  return () => {
16212
16494
  cancelled = true;
16213
16495
  };
16214
- }, [client, category]);
16215
- if (loading) {
16216
- return /* @__PURE__ */ React16.createElement(IssueListScreenSkeleton, null);
16217
- }
16218
- if (issues.length === 0) {
16219
- return /* @__PURE__ */ React16.createElement(View15, { style: styles14.emptyContainer }, /* @__PURE__ */ React16.createElement(Text14, { style: styles14.emptyIcon }, config.emptyIcon), /* @__PURE__ */ React16.createElement(Text14, { style: styles14.emptyText }, config.emptyText));
16220
- }
16221
- return /* @__PURE__ */ React16.createElement(View15, null, issues.map((issue) => /* @__PURE__ */ React16.createElement(
16496
+ }, [client, activeCategory]);
16497
+ const sortedIssues = useMemo3(() => {
16498
+ const sorted = [...issues];
16499
+ if (sortMode === "severity") {
16500
+ sorted.sort((a, b) => (SEVERITY_ORDER[a.severity || "low"] ?? 4) - (SEVERITY_ORDER[b.severity || "low"] ?? 4));
16501
+ } else {
16502
+ sorted.sort((a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime());
16503
+ }
16504
+ return sorted;
16505
+ }, [issues, sortMode]);
16506
+ return /* @__PURE__ */ React16.createElement(View15, null, /* @__PURE__ */ React16.createElement(View15, { style: styles14.tabBar }, CATEGORIES.map((cat) => {
16507
+ const catConfig = CATEGORY_CONFIG[cat];
16508
+ const isActive = activeCategory === cat;
16509
+ const count = counts?.[cat];
16510
+ return /* @__PURE__ */ React16.createElement(
16511
+ TouchableOpacity13,
16512
+ {
16513
+ key: cat,
16514
+ style: [
16515
+ styles14.tab,
16516
+ { borderBottomColor: isActive ? catConfig.accent : "transparent" }
16517
+ ],
16518
+ onPress: () => setActiveCategory(cat),
16519
+ activeOpacity: 0.7
16520
+ },
16521
+ /* @__PURE__ */ React16.createElement(Text14, { style: [
16522
+ styles14.tabLabel,
16523
+ isActive && { fontWeight: "600", color: colors.textPrimary }
16524
+ ] }, catConfig.label),
16525
+ count !== void 0 && /* @__PURE__ */ React16.createElement(View15, { style: [
16526
+ styles14.countBadge,
16527
+ {
16528
+ backgroundColor: isActive ? catConfig.accent + "18" : colors.card
16529
+ }
16530
+ ] }, /* @__PURE__ */ React16.createElement(Text14, { style: [
16531
+ styles14.countText,
16532
+ { color: isActive ? catConfig.accent : colors.textDim }
16533
+ ] }, count))
16534
+ );
16535
+ })), /* @__PURE__ */ React16.createElement(View15, { style: styles14.sortRow }, [
16536
+ { key: "severity", label: "Severity" },
16537
+ { key: "recent", label: "Recent" }
16538
+ ].map((s2) => /* @__PURE__ */ React16.createElement(
16539
+ TouchableOpacity13,
16540
+ {
16541
+ key: s2.key,
16542
+ style: [
16543
+ styles14.sortBtn,
16544
+ sortMode === s2.key && styles14.sortBtnActive
16545
+ ],
16546
+ onPress: () => setSortMode(s2.key)
16547
+ },
16548
+ /* @__PURE__ */ React16.createElement(Text14, { style: [
16549
+ styles14.sortBtnText,
16550
+ sortMode === s2.key && styles14.sortBtnTextActive
16551
+ ] }, s2.label)
16552
+ ))), loading ? /* @__PURE__ */ React16.createElement(IssueListScreenSkeleton, null) : sortedIssues.length === 0 ? /* @__PURE__ */ React16.createElement(View15, { style: styles14.emptyContainer }, /* @__PURE__ */ React16.createElement(Text14, { style: styles14.emptyIcon }, config.emptyIcon), /* @__PURE__ */ React16.createElement(Text14, { style: styles14.emptyText }, config.emptyText)) : sortedIssues.map((issue) => /* @__PURE__ */ React16.createElement(
16222
16553
  TouchableOpacity13,
16223
16554
  {
16224
16555
  key: issue.id,
@@ -16228,11 +16559,69 @@ function IssueListScreen({ nav, category }) {
16228
16559
  },
16229
16560
  /* @__PURE__ */ React16.createElement(View15, { style: styles14.topRow }, issue.severity && /* @__PURE__ */ React16.createElement(View15, { style: [styles14.severityDot, { backgroundColor: SEVERITY_COLORS[issue.severity] || colors.textDim }] }), /* @__PURE__ */ React16.createElement(Text14, { style: styles14.issueTitle, numberOfLines: 1 }, issue.title)),
16230
16561
  /* @__PURE__ */ React16.createElement(View15, { style: styles14.bottomRow }, issue.route && /* @__PURE__ */ React16.createElement(Text14, { style: styles14.routeText, numberOfLines: 1 }, issue.route), /* @__PURE__ */ React16.createElement(Text14, { style: styles14.timeText }, formatRelativeTime(issue.updatedAt))),
16231
- category === "done" && issue.verifiedByName && /* @__PURE__ */ React16.createElement(View15, { style: styles14.verifiedBadge }, /* @__PURE__ */ React16.createElement(Text14, { style: styles14.verifiedBadgeText }, "\u2714", " Verified by ", issue.verifiedByName)),
16232
- category === "reopened" && issue.originalBugTitle && /* @__PURE__ */ React16.createElement(View15, { style: styles14.reopenedBadge }, /* @__PURE__ */ React16.createElement(Text14, { style: styles14.reopenedBadgeText, numberOfLines: 1 }, "\u{1F504}", " Retest of: ", issue.originalBugTitle))
16562
+ activeCategory === "done" && issue.verifiedByName && /* @__PURE__ */ React16.createElement(View15, { style: styles14.verifiedBadge }, /* @__PURE__ */ React16.createElement(Text14, { style: styles14.verifiedBadgeText }, "\u2714", " Verified by ", issue.verifiedByName)),
16563
+ activeCategory === "reopened" && issue.originalBugTitle && /* @__PURE__ */ React16.createElement(View15, { style: styles14.reopenedBadge }, /* @__PURE__ */ React16.createElement(Text14, { style: styles14.reopenedBadgeText, numberOfLines: 1 }, "\u{1F504}", " Retest of: ", issue.originalBugTitle))
16233
16564
  )));
16234
16565
  }
16235
16566
  var styles14 = StyleSheet16.create({
16567
+ tabBar: {
16568
+ flexDirection: "row",
16569
+ borderBottomWidth: 1,
16570
+ borderBottomColor: colors.border,
16571
+ marginBottom: 8
16572
+ },
16573
+ tab: {
16574
+ flex: 1,
16575
+ flexDirection: "row",
16576
+ alignItems: "center",
16577
+ justifyContent: "center",
16578
+ gap: 6,
16579
+ paddingVertical: 8,
16580
+ paddingHorizontal: 4,
16581
+ borderBottomWidth: 2
16582
+ },
16583
+ tabLabel: {
16584
+ fontSize: 12,
16585
+ fontWeight: "400",
16586
+ color: colors.textMuted
16587
+ },
16588
+ countBadge: {
16589
+ borderRadius: 8,
16590
+ paddingHorizontal: 6,
16591
+ paddingVertical: 1,
16592
+ minWidth: 18,
16593
+ alignItems: "center"
16594
+ },
16595
+ countText: {
16596
+ fontSize: 10,
16597
+ fontWeight: "600"
16598
+ },
16599
+ sortRow: {
16600
+ flexDirection: "row",
16601
+ justifyContent: "flex-end",
16602
+ gap: 2,
16603
+ marginBottom: 8
16604
+ },
16605
+ sortBtn: {
16606
+ paddingHorizontal: 8,
16607
+ paddingVertical: 3,
16608
+ borderRadius: 6,
16609
+ borderWidth: 1,
16610
+ borderColor: "transparent"
16611
+ },
16612
+ sortBtnActive: {
16613
+ backgroundColor: colors.card,
16614
+ borderColor: colors.border
16615
+ },
16616
+ sortBtnText: {
16617
+ fontSize: 10,
16618
+ fontWeight: "400",
16619
+ color: colors.textMuted
16620
+ },
16621
+ sortBtnTextActive: {
16622
+ fontWeight: "600",
16623
+ color: colors.textPrimary
16624
+ },
16236
16625
  emptyContainer: {
16237
16626
  alignItems: "center",
16238
16627
  paddingVertical: 40