@voltro/react-native 0.86.0 → 0.87.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.
package/dist/devices.js CHANGED
@@ -3,7 +3,7 @@ var e = [
3
3
  "ios",
4
4
  "android",
5
5
  "web"
6
- ], t = (t) => typeof t == "string" && e.includes(t), n = "_voltro_devices", r = "en", i = "UTC", a = () => {
6
+ ], t = (t) => typeof t == "string" && e.includes(t), n = "_voltro_push_devices", r = "en", i = "UTC", a = () => {
7
7
  if (typeof navigator < "u" && typeof navigator.language == "string") return navigator.language;
8
8
  }, o = () => {
9
9
  try {
package/dist/index.d.ts CHANGED
@@ -253,7 +253,7 @@ export declare const DEVICE_PLATFORMS: ReadonlyArray<DevicePlatform>;
253
253
  export declare type DevicePlatform = 'ios' | 'android' | 'web';
254
254
 
255
255
  /**
256
- * The normalised row, ready to upsert into `_voltro_devices`. `locale` and
256
+ * The normalised row, ready to upsert into `_voltro_push_devices`. `locale` and
257
257
  * `timezone` are resolved (never `undefined`); `registeredAt` is the moment we
258
258
  * built this. `userId` / `tenantId` are NOT here on purpose — they are the
259
259
  * server's to stamp from the authenticated request, never trusted from the
@@ -297,7 +297,7 @@ export declare interface DeviceRegistrationInput {
297
297
  }
298
298
 
299
299
  /** The framework table name devices are stored in — shared with `./schema`. */
300
- export declare const DEVICES_TABLE = "_voltro_devices";
300
+ export declare const DEVICES_TABLE = "_voltro_push_devices";
301
301
 
302
302
  /**
303
303
  * The transport that actually persists a device. The app supplies it — usually
@@ -415,6 +415,7 @@ export declare interface MobileApiBinding {
415
415
  /** `ws(s)://host:port/ws`. On a device this is NOT localhost — see
416
416
  * {@link resolveDevWsUrl}. */
417
417
  readonly wsUrl: string;
418
+ readonly roleEndpoints?: unknown;
418
419
  readonly headers?: ResolvableHeaders | undefined;
419
420
  readonly recovery?: MountedApi['recovery'];
420
421
  /** Durable local mirror of this api's subscriptions, resolved per
@@ -532,7 +533,7 @@ export { OnlineSource }
532
533
  * )
533
534
  * ```
534
535
  *
535
- * Idempotent by construction: the `_voltro_devices` unique key is
536
+ * Idempotent by construction: the `_voltro_push_devices` unique key is
536
537
  * `(platform, token)`, so calling this again with the same token updates the
537
538
  * existing row (locale/timezone/lastSeen) instead of inserting a duplicate. A
538
539
  * ROTATED token is a new registration; reaping the stale one is the sender
@@ -617,8 +618,10 @@ export declare interface SqliteDatabaseLike {
617
618
  *
618
619
  * `reconnect()` on the returned handle forces a fresh socket for every api —
619
620
  * call it after a sign-in or a tenant switch so the connection re-resolves who
620
- * it is. The supervisor blanks caches across that swap on purpose: the next
621
- * subject may be entitled to less than the previous one.
621
+ * it is. Its promise resolves once every api runs on the rebuilt socket; await
622
+ * it before calling as the new subject. The supervisor blanks caches across
623
+ * that swap on purpose: the next subject may be entitled to less than the
624
+ * previous one.
622
625
  */
623
626
  export declare const startMobileApis: (options: StartMobileApisOptions) => SupervisorHandle;
624
627
 
@@ -1,57 +1,70 @@
1
- import { buildApiRuntime as e, recoveryCoordinatorFor as t, startApiSupervisor as n } from "@voltro/client";
1
+ import { buildApiRuntime as e, makeApiRoleSocketTracker as t, recoveryCoordinatorFor as n, startApiSupervisor as r } from "@voltro/client";
2
2
  //#region src/mobileRuntime.ts
3
- var r = (e, t) => {
3
+ var i = (e, t) => {
4
4
  let n = typeof t == "object" && !Array.isArray(t) ? void 0 : t, r = globalThis.WebSocket;
5
5
  if (r === void 0) throw Error("startMobileApis: no global WebSocket. React Native provides one; if you are running these bindings somewhere else, pass `webSocketConstructor`.");
6
6
  return n === void 0 ? new r(e) : new r(e, n);
7
- }, i = (e, t, n) => (r, i) => {
7
+ }, a = (e, t, n) => (r, i) => {
8
8
  let a = e(r, i);
9
9
  return a.addEventListener("open", () => t()), a.addEventListener("close", () => n("close")), a.addEventListener("error", () => n("error")), a;
10
- }, a = (t) => {
11
- let a = t.webSocketConstructor ?? r;
12
- return n({
13
- apis: t.apis.map((e) => ({
10
+ }, o = (n) => {
11
+ let o = n.webSocketConstructor ?? i;
12
+ return r({
13
+ apis: n.apis.map((e) => ({
14
14
  name: e.name,
15
15
  group: e.group,
16
16
  descriptors: e.descriptors,
17
17
  wsUrl: e.wsUrl,
18
+ roleEndpoints: e.roleEndpoints,
18
19
  ...e.headers === void 0 ? {} : { headers: e.headers },
19
20
  ...e.recovery === void 0 ? {} : { recovery: e.recovery },
20
21
  ...e.mirror === void 0 ? {} : { mirror: e.mirror }
21
22
  })),
22
- ...t.retryDelayMs === void 0 ? {} : { retryDelayMs: t.retryDelayMs },
23
- onChange: t.onChange,
24
- buildClient: async (t, n, r, o, s, c) => await e({
25
- name: t.name,
26
- generation: n,
27
- wsUrl: t.wsUrl,
28
- group: t.group,
29
- ...t.headers === void 0 ? {} : { headers: t.headers },
30
- ...t.mirror === void 0 ? {} : { mirror: t.mirror },
31
- descriptors: t.descriptors,
32
- ...s === void 0 ? {} : { errorBus: s },
33
- ...c === void 0 ? {} : { recovery: c },
34
- webSocketConstructor: i(a, r, o)
35
- })
23
+ ...n.retryDelayMs === void 0 ? {} : { retryDelayMs: n.retryDelayMs },
24
+ onChange: n.onChange,
25
+ buildClient: async (n, r, i, s, c, l) => {
26
+ let u = t(n.group, n.wsUrl, n.roleEndpoints, i, s);
27
+ return await e({
28
+ name: n.name,
29
+ generation: r,
30
+ wsUrl: n.wsUrl,
31
+ roleEndpoints: n.roleEndpoints,
32
+ group: n.group,
33
+ ...n.headers === void 0 ? {} : { headers: n.headers },
34
+ ...n.mirror === void 0 ? {} : { mirror: n.mirror },
35
+ descriptors: n.descriptors,
36
+ ...c === void 0 ? {} : { errorBus: c },
37
+ ...l === void 0 ? {} : { recovery: l },
38
+ webSocketConstructor: (e, t) => {
39
+ let n = u.begin(e);
40
+ try {
41
+ return a(o, n.open, n.issue)(e, t);
42
+ } catch (e) {
43
+ throw n.issue("error"), e;
44
+ }
45
+ }
46
+ });
47
+ }
36
48
  });
37
- }, o = (e, t, n = "/ws") => {
49
+ }, s = (e, t, n = "/ws") => {
38
50
  let r = (e ?? "").split(":")[0];
39
51
  return r === void 0 || r === "" || r === "localhost" || r === "127.0.0.1" ? `ws://localhost:${t}${n}` : `ws://${r}:${t}${n}`;
40
- }, s = (e, n) => {
52
+ }, c = (e, t) => {
41
53
  let r = /* @__PURE__ */ new Map();
42
54
  for (let i of e) {
43
- let e = n.get(i.name);
55
+ let e = t.get(i.name);
44
56
  e !== void 0 && r.set(i.name, {
45
57
  runtime: e.runtime,
46
58
  cache: e.cache,
47
59
  client: e.client,
60
+ ...e.subjectSignal === void 0 ? {} : { subjectSignal: e.subjectSignal },
48
61
  descriptors: i.descriptors,
49
62
  inspectBaseUrl: i.wsUrl.replace(/^ws/, "http").replace(/\/ws$/, ""),
50
63
  errorBus: e.errorBus,
51
- recovery: e.recovery ?? t(e.errorBus, i.name, i.recovery)
64
+ recovery: e.recovery ?? n(e.errorBus, i.name, i.recovery)
52
65
  });
53
66
  }
54
67
  return r;
55
68
  };
56
69
  //#endregion
57
- export { r as defaultWebSocketConstructor, o as resolveDevWsUrl, a as startMobileApis, s as toApiHandles, i as wireSocket };
70
+ export { i as defaultWebSocketConstructor, s as resolveDevWsUrl, o as startMobileApis, c as toApiHandles, a as wireSocket };
package/dist/schema.d.ts CHANGED
@@ -10,9 +10,9 @@ export declare const deviceLocaleFor: (store: DataStore) => (subjectId: string)
10
10
  declare type DevicePlatform = 'ios' | 'android' | 'web';
11
11
 
12
12
  /** The framework table name devices are stored in — shared with `./schema`. */
13
- export declare const DEVICES_TABLE = "_voltro_devices";
13
+ export declare const DEVICES_TABLE = "_voltro_push_devices";
14
14
 
15
- export declare const devicesTable: Table<"_voltro_devices", FieldDefinitions<{
15
+ export declare const devicesTable: Table<"_voltro_push_devices", FieldDefinitions<{
16
16
  readonly id: ColumnBuilder<string, "id", boolean>;
17
17
  readonly tenantId: ColumnBuilder<string | null, "text", boolean>;
18
18
  readonly userId: ColumnBuilder<string, "text", boolean>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltro/react-native",
3
- "version": "0.86.0",
3
+ "version": "0.87.0",
4
4
  "description": "React Native bindings for the framework: device-registration primitive, background-sync state machine, offline-first client defaults + connection-status surface, and the deep-link declaration shape — the credential-free mobile plumbing on top of the RN-safe React client.",
5
5
  "keywords": [
6
6
  "voltro",
@@ -38,9 +38,9 @@
38
38
  "node": ">=24.0.0"
39
39
  },
40
40
  "dependencies": {
41
- "@voltro/client": "0.86.0",
42
- "@voltro/database": "0.86.0",
43
- "@voltro/local-first": "0.86.0"
41
+ "@voltro/client": "0.87.0",
42
+ "@voltro/database": "0.87.0",
43
+ "@voltro/local-first": "0.87.0"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "react": "^19.0.0"