@jskit-ai/realtime 0.1.62 → 0.1.64
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/package.descriptor.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export default Object.freeze({
|
|
2
2
|
packageVersion: 1,
|
|
3
3
|
packageId: "@jskit-ai/realtime",
|
|
4
|
-
version: "0.1.
|
|
4
|
+
version: "0.1.64",
|
|
5
5
|
kind: "runtime",
|
|
6
6
|
description: "Thin, generic realtime runtime wrappers for socket.io server and client.",
|
|
7
7
|
options: {
|
|
@@ -94,7 +94,7 @@ export default Object.freeze({
|
|
|
94
94
|
mutations: {
|
|
95
95
|
dependencies: {
|
|
96
96
|
runtime: {
|
|
97
|
-
"@jskit-ai/kernel": "0.1.
|
|
97
|
+
"@jskit-ai/kernel": "0.1.65",
|
|
98
98
|
"@socket.io/redis-adapter": "^8.3.0",
|
|
99
99
|
"redis": "^5.8.2",
|
|
100
100
|
"socket.io": "^4.8.3",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/realtime",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.64",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node --test"
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@socket.io/redis-adapter": "^8.3.0",
|
|
19
|
-
"@jskit-ai/kernel": "0.1.
|
|
19
|
+
"@jskit-ai/kernel": "0.1.65",
|
|
20
20
|
"redis": "^5.8.2",
|
|
21
21
|
"socket.io": "^4.8.3",
|
|
22
22
|
"socket.io-client": "^4.8.3"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createSocketIoClient, disconnectSocketIoClient } from "./runtime.js";
|
|
2
2
|
import { normalizeObject, normalizeText } from "@jskit-ai/kernel/shared/support/normalize";
|
|
3
3
|
import { createProviderLogger as createSharedProviderLogger } from "@jskit-ai/kernel/shared/support/providerLogger";
|
|
4
|
-
import { resolveClientBootstrapDebugEnabled } from "@jskit-ai/kernel/client";
|
|
4
|
+
import { getClientAppConfig, resolveClientBootstrapDebugEnabled, resolveMobileConfig } from "@jskit-ai/kernel/client";
|
|
5
5
|
import RealtimeConnectionIndicator from "./components/RealtimeConnectionIndicator.js";
|
|
6
6
|
import { resolveRealtimeClientListeners } from "./listeners.js";
|
|
7
7
|
|
|
@@ -11,11 +11,14 @@ const REALTIME_RUNTIME_CLIENT_API = Object.freeze({
|
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
function resolveRealtimeClientConfig(app) {
|
|
14
|
-
const appConfig =
|
|
14
|
+
const appConfig = normalizeObject(getClientAppConfig());
|
|
15
15
|
const env = app && typeof app.has === "function" && app.has("jskit.client.env") ? normalizeObject(app.make("jskit.client.env")) : {};
|
|
16
16
|
const realtime = normalizeObject(appConfig.realtime);
|
|
17
17
|
const realtimeClient = normalizeObject(appConfig.realtimeClient);
|
|
18
|
-
const
|
|
18
|
+
const mobileConfig = resolveMobileConfig({
|
|
19
|
+
mobile: normalizeObject(appConfig.mobile)
|
|
20
|
+
});
|
|
21
|
+
const url = normalizeText(realtimeClient.url || (mobileConfig.enabled === true ? mobileConfig.apiBaseUrl : ""));
|
|
19
22
|
const options = normalizeObject(realtimeClient.options);
|
|
20
23
|
const explicitDebugEnabled =
|
|
21
24
|
typeof realtimeClient.debug === "boolean"
|
|
@@ -2,6 +2,7 @@ import assert from "node:assert/strict";
|
|
|
2
2
|
import test from "node:test";
|
|
3
3
|
import { createServer } from "node:http";
|
|
4
4
|
import { installServiceRegistrationApi } from "@jskit-ai/kernel/server/runtime";
|
|
5
|
+
import { CLIENT_APP_CONFIG_GLOBAL_KEY, setClientAppConfig } from "../../kernel/client/appConfig.js";
|
|
5
6
|
|
|
6
7
|
import { RealtimeServiceProvider } from "../src/server/RealtimeServiceProvider.js";
|
|
7
8
|
import { RealtimeClientProvider } from "../src/client/RealtimeClientProvider.js";
|
|
@@ -247,6 +248,50 @@ test("RealtimeClientProvider registers runtime realtime client api", () => {
|
|
|
247
248
|
assert.equal(typeof api.disconnectSocketIoClient, "function");
|
|
248
249
|
});
|
|
249
250
|
|
|
251
|
+
test("RealtimeClientProvider uses mobile.apiBaseUrl when realtimeClient.url is unset", () => {
|
|
252
|
+
const previousAppConfig = globalThis[CLIENT_APP_CONFIG_GLOBAL_KEY];
|
|
253
|
+
const calls = [];
|
|
254
|
+
const socket = {
|
|
255
|
+
on() {},
|
|
256
|
+
off() {},
|
|
257
|
+
disconnect() {}
|
|
258
|
+
};
|
|
259
|
+
try {
|
|
260
|
+
setClientAppConfig({
|
|
261
|
+
mobile: {
|
|
262
|
+
enabled: true,
|
|
263
|
+
apiBaseUrl: "http://127.0.0.1:3000"
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
const app = createSingletonApp();
|
|
268
|
+
app.instance("runtime.realtime.client", {
|
|
269
|
+
createSocketIoClient(input = {}) {
|
|
270
|
+
calls.push(input);
|
|
271
|
+
return socket;
|
|
272
|
+
},
|
|
273
|
+
disconnectSocketIoClient() {}
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
const provider = new RealtimeClientProvider();
|
|
277
|
+
provider.register(app);
|
|
278
|
+
|
|
279
|
+
assert.equal(app.make("runtime.realtime.client.socket"), socket);
|
|
280
|
+
assert.deepEqual(calls, [
|
|
281
|
+
{
|
|
282
|
+
url: "http://127.0.0.1:3000",
|
|
283
|
+
options: {}
|
|
284
|
+
}
|
|
285
|
+
]);
|
|
286
|
+
} finally {
|
|
287
|
+
if (previousAppConfig === undefined) {
|
|
288
|
+
delete globalThis[CLIENT_APP_CONFIG_GLOBAL_KEY];
|
|
289
|
+
} else {
|
|
290
|
+
globalThis[CLIENT_APP_CONFIG_GLOBAL_KEY] = previousAppConfig;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
|
|
250
295
|
test("RealtimeClientProvider boots socket listeners and disconnects on shutdown", async () => {
|
|
251
296
|
const app = createSingletonApp();
|
|
252
297
|
const provider = new RealtimeClientProvider();
|