@oxyhq/services 14.0.1 → 14.1.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/lib/commonjs/ui/session/createSessionClient.js +10 -1
- package/lib/commonjs/ui/session/createSessionClient.js.map +1 -1
- package/lib/module/ui/session/createSessionClient.js +10 -1
- package/lib/module/ui/session/createSessionClient.js.map +1 -1
- package/lib/typescript/commonjs/ui/session/createSessionClient.d.ts +7 -0
- package/lib/typescript/commonjs/ui/session/createSessionClient.d.ts.map +1 -1
- package/lib/typescript/module/ui/session/createSessionClient.d.ts +7 -0
- package/lib/typescript/module/ui/session/createSessionClient.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/ui/session/__tests__/createSessionClient.test.ts +28 -0
- package/src/ui/session/createSessionClient.ts +9 -1
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.createSessionClient = createSessionClient;
|
|
7
7
|
var _core = require("@oxyhq/core");
|
|
8
|
+
var _socket = require("socket.io-client");
|
|
8
9
|
var _sessionClientHost = require("./sessionClientHost.js");
|
|
9
10
|
var _tokenTransport = require("./tokenTransport.js");
|
|
10
11
|
/**
|
|
@@ -13,12 +14,20 @@ var _tokenTransport = require("./tokenTransport.js");
|
|
|
13
14
|
* `OxyServices` instance, and returns both the client and the host — the host
|
|
14
15
|
* is returned (not just the client) so `OxyContext` (Fase 3-B) can call
|
|
15
16
|
* `host.setCurrentAccountId(...)` as the active account changes.
|
|
17
|
+
*
|
|
18
|
+
* `socket.io-client`'s `io` is STATICALLY imported and injected as the
|
|
19
|
+
* `SessionClient` `socketFactory` (socket.io-client is a real dependency of
|
|
20
|
+
* `@oxyhq/services`). This is what keeps realtime session sync working in the
|
|
21
|
+
* Metro/Expo-web bundle: core's lazy dynamic `import('socket.io-client')` of a
|
|
22
|
+
* bare specifier does not resolve reliably against the published core dist, so
|
|
23
|
+
* the app-bundled static import is the reliable source of the factory.
|
|
16
24
|
*/
|
|
17
25
|
function createSessionClient(oxyServices) {
|
|
18
26
|
const host = (0, _sessionClientHost.createSessionClientHost)(oxyServices);
|
|
19
27
|
const transport = (0, _tokenTransport.createTokenTransport)(oxyServices);
|
|
20
28
|
const client = new _core.SessionClient(host, {
|
|
21
|
-
transport
|
|
29
|
+
transport,
|
|
30
|
+
socketFactory: _socket.io
|
|
22
31
|
});
|
|
23
32
|
return {
|
|
24
33
|
client,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_core","require","_sessionClientHost","_tokenTransport","createSessionClient","oxyServices","host","createSessionClientHost","transport","createTokenTransport","client","SessionClient"],"sourceRoot":"../../../../src","sources":["ui/session/createSessionClient.ts"],"mappings":";;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,
|
|
1
|
+
{"version":3,"names":["_core","require","_socket","_sessionClientHost","_tokenTransport","createSessionClient","oxyServices","host","createSessionClientHost","transport","createTokenTransport","client","SessionClient","socketFactory","io"],"sourceRoot":"../../../../src","sources":["ui/session/createSessionClient.ts"],"mappings":";;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,kBAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,mBAAmBA,CAACC,WAAwB,EAG1D;EACA,MAAMC,IAAI,GAAG,IAAAC,0CAAuB,EAACF,WAAW,CAAC;EACjD,MAAMG,SAAS,GAAG,IAAAC,oCAAoB,EAACJ,WAAW,CAAC;EACnD,MAAMK,MAAM,GAAG,IAAIC,mBAAa,CAACL,IAAI,EAAE;IAAEE,SAAS;IAAEI,aAAa,EAAEC;EAAG,CAAC,CAAC;EACxE,OAAO;IAAEH,MAAM;IAAEJ;EAAK,CAAC;AACzB","ignoreList":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { SessionClient } from '@oxyhq/core';
|
|
4
|
+
import { io } from 'socket.io-client';
|
|
4
5
|
import { createSessionClientHost } from "./sessionClientHost.js";
|
|
5
6
|
import { createTokenTransport } from "./tokenTransport.js";
|
|
6
7
|
|
|
@@ -10,12 +11,20 @@ import { createTokenTransport } from "./tokenTransport.js";
|
|
|
10
11
|
* `OxyServices` instance, and returns both the client and the host — the host
|
|
11
12
|
* is returned (not just the client) so `OxyContext` (Fase 3-B) can call
|
|
12
13
|
* `host.setCurrentAccountId(...)` as the active account changes.
|
|
14
|
+
*
|
|
15
|
+
* `socket.io-client`'s `io` is STATICALLY imported and injected as the
|
|
16
|
+
* `SessionClient` `socketFactory` (socket.io-client is a real dependency of
|
|
17
|
+
* `@oxyhq/services`). This is what keeps realtime session sync working in the
|
|
18
|
+
* Metro/Expo-web bundle: core's lazy dynamic `import('socket.io-client')` of a
|
|
19
|
+
* bare specifier does not resolve reliably against the published core dist, so
|
|
20
|
+
* the app-bundled static import is the reliable source of the factory.
|
|
13
21
|
*/
|
|
14
22
|
export function createSessionClient(oxyServices) {
|
|
15
23
|
const host = createSessionClientHost(oxyServices);
|
|
16
24
|
const transport = createTokenTransport(oxyServices);
|
|
17
25
|
const client = new SessionClient(host, {
|
|
18
|
-
transport
|
|
26
|
+
transport,
|
|
27
|
+
socketFactory: io
|
|
19
28
|
});
|
|
20
29
|
return {
|
|
21
30
|
client,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SessionClient","createSessionClientHost","createTokenTransport","createSessionClient","oxyServices","host","transport","client"],"sourceRoot":"../../../../src","sources":["ui/session/createSessionClient.ts"],"mappings":";;AACA,SAASA,aAAa,QAAQ,aAAa;AAC3C,SAASC,uBAAuB,QAAQ,wBAAqB;AAC7D,SAASC,oBAAoB,QAAQ,qBAAkB;;AAEvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAACC,WAAwB,EAG1D;EACA,MAAMC,IAAI,GAAGJ,uBAAuB,CAACG,WAAW,CAAC;EACjD,MAAME,SAAS,GAAGJ,oBAAoB,CAACE,WAAW,CAAC;EACnD,MAAMG,MAAM,GAAG,
|
|
1
|
+
{"version":3,"names":["SessionClient","io","createSessionClientHost","createTokenTransport","createSessionClient","oxyServices","host","transport","client","socketFactory"],"sourceRoot":"../../../../src","sources":["ui/session/createSessionClient.ts"],"mappings":";;AACA,SAASA,aAAa,QAAQ,aAAa;AAC3C,SAASC,EAAE,QAAQ,kBAAkB;AACrC,SAASC,uBAAuB,QAAQ,wBAAqB;AAC7D,SAASC,oBAAoB,QAAQ,qBAAkB;;AAEvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAACC,WAAwB,EAG1D;EACA,MAAMC,IAAI,GAAGJ,uBAAuB,CAACG,WAAW,CAAC;EACjD,MAAME,SAAS,GAAGJ,oBAAoB,CAACE,WAAW,CAAC;EACnD,MAAMG,MAAM,GAAG,IAAIR,aAAa,CAACM,IAAI,EAAE;IAAEC,SAAS;IAAEE,aAAa,EAAER;EAAG,CAAC,CAAC;EACxE,OAAO;IAAEO,MAAM;IAAEF;EAAK,CAAC;AACzB","ignoreList":[]}
|
|
@@ -7,6 +7,13 @@ import { createSessionClientHost } from './sessionClientHost';
|
|
|
7
7
|
* `OxyServices` instance, and returns both the client and the host — the host
|
|
8
8
|
* is returned (not just the client) so `OxyContext` (Fase 3-B) can call
|
|
9
9
|
* `host.setCurrentAccountId(...)` as the active account changes.
|
|
10
|
+
*
|
|
11
|
+
* `socket.io-client`'s `io` is STATICALLY imported and injected as the
|
|
12
|
+
* `SessionClient` `socketFactory` (socket.io-client is a real dependency of
|
|
13
|
+
* `@oxyhq/services`). This is what keeps realtime session sync working in the
|
|
14
|
+
* Metro/Expo-web bundle: core's lazy dynamic `import('socket.io-client')` of a
|
|
15
|
+
* bare specifier does not resolve reliably against the published core dist, so
|
|
16
|
+
* the app-bundled static import is the reliable source of the factory.
|
|
10
17
|
*/
|
|
11
18
|
export declare function createSessionClient(oxyServices: OxyServices): {
|
|
12
19
|
client: SessionClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSessionClient.d.ts","sourceRoot":"","sources":["../../../../../src/ui/session/createSessionClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"createSessionClient.d.ts","sourceRoot":"","sources":["../../../../../src/ui/session/createSessionClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAG9D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG;IAC7D,MAAM,EAAE,aAAa,CAAC;IACtB,IAAI,EAAE,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;CAClD,CAKA"}
|
|
@@ -7,6 +7,13 @@ import { createSessionClientHost } from './sessionClientHost.js';
|
|
|
7
7
|
* `OxyServices` instance, and returns both the client and the host — the host
|
|
8
8
|
* is returned (not just the client) so `OxyContext` (Fase 3-B) can call
|
|
9
9
|
* `host.setCurrentAccountId(...)` as the active account changes.
|
|
10
|
+
*
|
|
11
|
+
* `socket.io-client`'s `io` is STATICALLY imported and injected as the
|
|
12
|
+
* `SessionClient` `socketFactory` (socket.io-client is a real dependency of
|
|
13
|
+
* `@oxyhq/services`). This is what keeps realtime session sync working in the
|
|
14
|
+
* Metro/Expo-web bundle: core's lazy dynamic `import('socket.io-client')` of a
|
|
15
|
+
* bare specifier does not resolve reliably against the published core dist, so
|
|
16
|
+
* the app-bundled static import is the reliable source of the factory.
|
|
10
17
|
*/
|
|
11
18
|
export declare function createSessionClient(oxyServices: OxyServices): {
|
|
12
19
|
client: SessionClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSessionClient.d.ts","sourceRoot":"","sources":["../../../../../src/ui/session/createSessionClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"createSessionClient.d.ts","sourceRoot":"","sources":["../../../../../src/ui/session/createSessionClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAqB,CAAC;AAG9D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG;IAC7D,MAAM,EAAE,aAAa,CAAC;IACtB,IAAI,EAAE,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;CAClD,CAKA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxyhq/services",
|
|
3
|
-
"version": "14.0
|
|
3
|
+
"version": "14.1.0",
|
|
4
4
|
"description": "OxyHQ Expo/React Native SDK — UI components, screens, and native features",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"@oxyhq/contracts": "0.8.0"
|
|
110
110
|
},
|
|
111
111
|
"devDependencies": {
|
|
112
|
-
"@oxyhq/core": "^5.
|
|
112
|
+
"@oxyhq/core": "^5.5.0",
|
|
113
113
|
"nativewind": "5.0.0-preview.3",
|
|
114
114
|
"react-native-css": "^3.0.0",
|
|
115
115
|
"@react-native-async-storage/async-storage": "^2.0.0",
|
|
@@ -153,7 +153,7 @@
|
|
|
153
153
|
"peerDependencies": {
|
|
154
154
|
"@expo/vector-icons": "^15.0.3",
|
|
155
155
|
"@oxyhq/bloom": ">=0.16.0",
|
|
156
|
-
"@oxyhq/core": "^5.
|
|
156
|
+
"@oxyhq/core": "^5.5.0",
|
|
157
157
|
"@react-native-async-storage/async-storage": "^2.0.0",
|
|
158
158
|
"@react-native-community/netinfo": "^11.4.1",
|
|
159
159
|
"@tanstack/query-async-storage-persister": "^5.101",
|
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
import { SessionClient } from '@oxyhq/core';
|
|
2
|
+
|
|
3
|
+
type Handler = (...args: unknown[]) => void;
|
|
4
|
+
class FakeSocket {
|
|
5
|
+
connected = false;
|
|
6
|
+
on(_event: string, _cb: Handler) {}
|
|
7
|
+
off(_event: string, _cb?: Handler) {}
|
|
8
|
+
connect() { this.connected = true; }
|
|
9
|
+
disconnect() { this.connected = false; }
|
|
10
|
+
}
|
|
11
|
+
const ioMock = jest.fn((_uri: string, _opts?: Record<string, unknown>) => new FakeSocket());
|
|
12
|
+
// `createSessionClient` STATICALLY imports `io` from socket.io-client and injects it as
|
|
13
|
+
// the SessionClient `socketFactory`; this mock stands in for that real dependency so the
|
|
14
|
+
// wiring test can assert the factory reaches — and is invoked by — the client.
|
|
15
|
+
jest.mock('socket.io-client', () => ({ __esModule: true, io: (...args: unknown[]) => ioMock(...(args as [string, Record<string, unknown>?])) }));
|
|
16
|
+
|
|
2
17
|
import { createSessionClient } from '../createSessionClient';
|
|
3
18
|
|
|
4
19
|
function fakeOxy() {
|
|
@@ -38,4 +53,17 @@ describe('createSessionClient', () => {
|
|
|
38
53
|
host.setCurrentAccountId('u1');
|
|
39
54
|
expect(host.getCurrentAccountId()).toBe('u1');
|
|
40
55
|
});
|
|
56
|
+
|
|
57
|
+
test('injects the statically-imported socket.io factory — start() opens a socket without the lazy loader', async () => {
|
|
58
|
+
ioMock.mockClear();
|
|
59
|
+
const oxy = fakeOxy();
|
|
60
|
+
|
|
61
|
+
const { client } = createSessionClient(oxy as never);
|
|
62
|
+
await client.start();
|
|
63
|
+
|
|
64
|
+
// The injected `io` was used to open the session socket at the base URL.
|
|
65
|
+
expect(ioMock).toHaveBeenCalledTimes(1);
|
|
66
|
+
expect(ioMock).toHaveBeenCalledWith('https://api.oxy.so', expect.objectContaining({ transports: ['websocket'] }));
|
|
67
|
+
client.stop();
|
|
68
|
+
});
|
|
41
69
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { OxyServices } from '@oxyhq/core';
|
|
2
2
|
import { SessionClient } from '@oxyhq/core';
|
|
3
|
+
import { io } from 'socket.io-client';
|
|
3
4
|
import { createSessionClientHost } from './sessionClientHost';
|
|
4
5
|
import { createTokenTransport } from './tokenTransport';
|
|
5
6
|
|
|
@@ -9,6 +10,13 @@ import { createTokenTransport } from './tokenTransport';
|
|
|
9
10
|
* `OxyServices` instance, and returns both the client and the host — the host
|
|
10
11
|
* is returned (not just the client) so `OxyContext` (Fase 3-B) can call
|
|
11
12
|
* `host.setCurrentAccountId(...)` as the active account changes.
|
|
13
|
+
*
|
|
14
|
+
* `socket.io-client`'s `io` is STATICALLY imported and injected as the
|
|
15
|
+
* `SessionClient` `socketFactory` (socket.io-client is a real dependency of
|
|
16
|
+
* `@oxyhq/services`). This is what keeps realtime session sync working in the
|
|
17
|
+
* Metro/Expo-web bundle: core's lazy dynamic `import('socket.io-client')` of a
|
|
18
|
+
* bare specifier does not resolve reliably against the published core dist, so
|
|
19
|
+
* the app-bundled static import is the reliable source of the factory.
|
|
12
20
|
*/
|
|
13
21
|
export function createSessionClient(oxyServices: OxyServices): {
|
|
14
22
|
client: SessionClient;
|
|
@@ -16,6 +24,6 @@ export function createSessionClient(oxyServices: OxyServices): {
|
|
|
16
24
|
} {
|
|
17
25
|
const host = createSessionClientHost(oxyServices);
|
|
18
26
|
const transport = createTokenTransport(oxyServices);
|
|
19
|
-
const client = new SessionClient(host, { transport });
|
|
27
|
+
const client = new SessionClient(host, { transport, socketFactory: io });
|
|
20
28
|
return { client, host };
|
|
21
29
|
}
|