@pluv/platform-node 0.32.3 → 0.32.4
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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +55 -0
- package/dist/index.d.mts +15 -8
- package/dist/index.d.ts +15 -8
- package/dist/index.js +18 -2
- package/dist/index.mjs +20 -2
- package/package.json +6 -6
- package/src/NodePlatform.ts +20 -8
- package/src/platformNode.ts +5 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/platform-node@0.32.
|
|
2
|
+
> @pluv/platform-node@0.32.4 build /home/runner/work/pluv/pluv/packages/platform-node
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --dts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
[34mCLI[39m Target: es6
|
|
9
9
|
[34mESM[39m Build start
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
|
-
[32mESM[39m [1mdist/index.mjs [22m[
|
|
12
|
-
[32mESM[39m ⚡️ Build success in
|
|
13
|
-
[32mCJS[39m [1mdist/index.js [22m[32m9.
|
|
14
|
-
[32mCJS[39m ⚡️ Build success in
|
|
11
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m8.13 KB[39m
|
|
12
|
+
[32mESM[39m ⚡️ Build success in 108ms
|
|
13
|
+
[32mCJS[39m [1mdist/index.js [22m[32m9.89 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 109ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 5762ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m4.22 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m4.22 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
# @pluv/platform-node
|
|
2
2
|
|
|
3
|
+
## 0.32.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fd054db: Add support for adding metadata to context when creating a room.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { createIO } from "@pluv/io";
|
|
11
|
+
|
|
12
|
+
// If using Cloudflare
|
|
13
|
+
import { platformCloudflare } from "@pluv/platform-cloudflare";
|
|
14
|
+
|
|
15
|
+
const io = createIO({
|
|
16
|
+
// ...
|
|
17
|
+
platform: platformCloudflare<CloudflareEnv, { myCustomData: string }>(),
|
|
18
|
+
context: ({
|
|
19
|
+
env,
|
|
20
|
+
state,
|
|
21
|
+
// This is now available on the context function
|
|
22
|
+
meta,
|
|
23
|
+
}) => ({ env, state, meta }),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const ioServer = io.server();
|
|
27
|
+
|
|
28
|
+
ioServer.createRoom("my-room", {
|
|
29
|
+
// ...
|
|
30
|
+
// This will now be a required property when creating a room
|
|
31
|
+
meta: { myCustomData: "hello world" },
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// If using Node.js
|
|
35
|
+
import { platformNode } from "@pluv/platform-node";
|
|
36
|
+
|
|
37
|
+
const io = createIO({
|
|
38
|
+
// ...
|
|
39
|
+
platform: platformNode<{ myCustomData: string }>(),
|
|
40
|
+
context: ({
|
|
41
|
+
// This is now available on the context function
|
|
42
|
+
meta,
|
|
43
|
+
}) => ({ env, state, meta }),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const ioServer = io.server();
|
|
47
|
+
|
|
48
|
+
ioServer.createRoom("my-room", {
|
|
49
|
+
// ...
|
|
50
|
+
// This will now be a required property when creating a room
|
|
51
|
+
meta: { myCustomData: "hello world" },
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
- @pluv/io@0.32.4
|
|
56
|
+
- @pluv/types@0.32.4
|
|
57
|
+
|
|
3
58
|
## 0.32.3
|
|
4
59
|
|
|
5
60
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WebSocket, Server as Server$1 } from 'ws';
|
|
2
2
|
export { WebSocket } from 'ws';
|
|
3
3
|
import { AbstractWebSocket, WebSocketSerializedState, AbstractEventMap, AbstractListener, AbstractWebSocketConfig, WebSocketRegistrationMode, AbstractPersistence, AbstractPubSub, AbstractPlatform, ConvertWebSocketConfig, AbstractPlatformConfig, PluvServer, InferInitContextType } from '@pluv/io';
|
|
4
|
-
import { JsonObject, MaybePromise, Maybe, InferIOAuthorizeUser, InferIOAuthorize, InferIOAuthorizeRequired } from '@pluv/types';
|
|
4
|
+
import { JsonObject, JsonPrimitive, MaybePromise, Maybe, InferIOAuthorizeUser, InferIOAuthorize, InferIOAuthorizeRequired } from '@pluv/types';
|
|
5
5
|
import { IncomingMessage, Server, ServerResponse } from 'node:http';
|
|
6
6
|
|
|
7
7
|
type NodeWebSocketConfig = AbstractWebSocketConfig;
|
|
@@ -20,7 +20,12 @@ declare class NodeWebSocket extends AbstractWebSocket<WebSocket> {
|
|
|
20
20
|
terminate(): void;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
type
|
|
23
|
+
type NodePlatformRoomContext<TMeta extends Record<string, JsonPrimitive>> = keyof TMeta extends never ? {
|
|
24
|
+
meta?: undefined;
|
|
25
|
+
} : {
|
|
26
|
+
meta: TMeta;
|
|
27
|
+
};
|
|
28
|
+
type NodePlatformConfig<TMeta extends Record<string, JsonPrimitive>> = {
|
|
24
29
|
mode?: WebSocketRegistrationMode;
|
|
25
30
|
} & ({
|
|
26
31
|
persistence?: undefined;
|
|
@@ -28,19 +33,21 @@ type NodePlatformConfig = {
|
|
|
28
33
|
} | {
|
|
29
34
|
persistence: AbstractPersistence;
|
|
30
35
|
pubSub: AbstractPubSub;
|
|
31
|
-
})
|
|
32
|
-
|
|
36
|
+
}) & {
|
|
37
|
+
context?: NodePlatformRoomContext<TMeta>;
|
|
38
|
+
};
|
|
39
|
+
declare class NodePlatform<TMeta extends Record<string, JsonPrimitive> = {}> extends AbstractPlatform<NodeWebSocket, {
|
|
33
40
|
req: IncomingMessage;
|
|
34
|
-
},
|
|
41
|
+
}, NodePlatformRoomContext<TMeta>> {
|
|
35
42
|
readonly _registrationMode: WebSocketRegistrationMode;
|
|
36
|
-
constructor(config?: NodePlatformConfig);
|
|
43
|
+
constructor(config?: NodePlatformConfig<TMeta>);
|
|
37
44
|
acceptWebSocket(webSocket: NodeWebSocket): Promise<void>;
|
|
38
45
|
convertWebSocket(webSocket: WebSocket, config: ConvertWebSocketConfig): NodeWebSocket;
|
|
39
46
|
getLastPing(webSocket: NodeWebSocket): number | null;
|
|
40
47
|
getSerializedState(webSocket: WebSocket): WebSocketSerializedState | null;
|
|
41
48
|
getSessionId(webSocket: WebSocket): string | null;
|
|
42
49
|
getWebSockets(): readonly WebSocket[];
|
|
43
|
-
initialize(config: AbstractPlatformConfig<
|
|
50
|
+
initialize(config: AbstractPlatformConfig<NodePlatformRoomContext<TMeta>>): this;
|
|
44
51
|
parseData(data: string | ArrayBuffer): Record<string, any>;
|
|
45
52
|
randomUUID(): string;
|
|
46
53
|
setSerializedState(webSocket: NodeWebSocket, state: WebSocketSerializedState): void;
|
|
@@ -71,6 +78,6 @@ interface CreatePluvHandlerResult {
|
|
|
71
78
|
}
|
|
72
79
|
declare const createPluvHandler: <TPluvServer extends PluvServer<NodePlatform, any, any, any>>(config: CreatePluvHandlerConfig<TPluvServer>) => CreatePluvHandlerResult;
|
|
73
80
|
|
|
74
|
-
declare const platformNode: (config?: NodePlatformConfig) => NodePlatform
|
|
81
|
+
declare const platformNode: <TMeta extends Record<string, JsonPrimitive> = {}>(config?: NodePlatformConfig<TMeta>) => NodePlatform<TMeta>;
|
|
75
82
|
|
|
76
83
|
export { type AuthorizeFunction, type AuthorizeFunctionContext, type CreatePluvHandlerConfig, NodePlatform, type NodePlatformConfig, createPluvHandler, platformNode };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WebSocket, Server as Server$1 } from 'ws';
|
|
2
2
|
export { WebSocket } from 'ws';
|
|
3
3
|
import { AbstractWebSocket, WebSocketSerializedState, AbstractEventMap, AbstractListener, AbstractWebSocketConfig, WebSocketRegistrationMode, AbstractPersistence, AbstractPubSub, AbstractPlatform, ConvertWebSocketConfig, AbstractPlatformConfig, PluvServer, InferInitContextType } from '@pluv/io';
|
|
4
|
-
import { JsonObject, MaybePromise, Maybe, InferIOAuthorizeUser, InferIOAuthorize, InferIOAuthorizeRequired } from '@pluv/types';
|
|
4
|
+
import { JsonObject, JsonPrimitive, MaybePromise, Maybe, InferIOAuthorizeUser, InferIOAuthorize, InferIOAuthorizeRequired } from '@pluv/types';
|
|
5
5
|
import { IncomingMessage, Server, ServerResponse } from 'node:http';
|
|
6
6
|
|
|
7
7
|
type NodeWebSocketConfig = AbstractWebSocketConfig;
|
|
@@ -20,7 +20,12 @@ declare class NodeWebSocket extends AbstractWebSocket<WebSocket> {
|
|
|
20
20
|
terminate(): void;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
type
|
|
23
|
+
type NodePlatformRoomContext<TMeta extends Record<string, JsonPrimitive>> = keyof TMeta extends never ? {
|
|
24
|
+
meta?: undefined;
|
|
25
|
+
} : {
|
|
26
|
+
meta: TMeta;
|
|
27
|
+
};
|
|
28
|
+
type NodePlatformConfig<TMeta extends Record<string, JsonPrimitive>> = {
|
|
24
29
|
mode?: WebSocketRegistrationMode;
|
|
25
30
|
} & ({
|
|
26
31
|
persistence?: undefined;
|
|
@@ -28,19 +33,21 @@ type NodePlatformConfig = {
|
|
|
28
33
|
} | {
|
|
29
34
|
persistence: AbstractPersistence;
|
|
30
35
|
pubSub: AbstractPubSub;
|
|
31
|
-
})
|
|
32
|
-
|
|
36
|
+
}) & {
|
|
37
|
+
context?: NodePlatformRoomContext<TMeta>;
|
|
38
|
+
};
|
|
39
|
+
declare class NodePlatform<TMeta extends Record<string, JsonPrimitive> = {}> extends AbstractPlatform<NodeWebSocket, {
|
|
33
40
|
req: IncomingMessage;
|
|
34
|
-
},
|
|
41
|
+
}, NodePlatformRoomContext<TMeta>> {
|
|
35
42
|
readonly _registrationMode: WebSocketRegistrationMode;
|
|
36
|
-
constructor(config?: NodePlatformConfig);
|
|
43
|
+
constructor(config?: NodePlatformConfig<TMeta>);
|
|
37
44
|
acceptWebSocket(webSocket: NodeWebSocket): Promise<void>;
|
|
38
45
|
convertWebSocket(webSocket: WebSocket, config: ConvertWebSocketConfig): NodeWebSocket;
|
|
39
46
|
getLastPing(webSocket: NodeWebSocket): number | null;
|
|
40
47
|
getSerializedState(webSocket: WebSocket): WebSocketSerializedState | null;
|
|
41
48
|
getSessionId(webSocket: WebSocket): string | null;
|
|
42
49
|
getWebSockets(): readonly WebSocket[];
|
|
43
|
-
initialize(config: AbstractPlatformConfig<
|
|
50
|
+
initialize(config: AbstractPlatformConfig<NodePlatformRoomContext<TMeta>>): this;
|
|
44
51
|
parseData(data: string | ArrayBuffer): Record<string, any>;
|
|
45
52
|
randomUUID(): string;
|
|
46
53
|
setSerializedState(webSocket: NodeWebSocket, state: WebSocketSerializedState): void;
|
|
@@ -71,6 +78,6 @@ interface CreatePluvHandlerResult {
|
|
|
71
78
|
}
|
|
72
79
|
declare const createPluvHandler: <TPluvServer extends PluvServer<NodePlatform, any, any, any>>(config: CreatePluvHandlerConfig<TPluvServer>) => CreatePluvHandlerResult;
|
|
73
80
|
|
|
74
|
-
declare const platformNode: (config?: NodePlatformConfig) => NodePlatform
|
|
81
|
+
declare const platformNode: <TMeta extends Record<string, JsonPrimitive> = {}>(config?: NodePlatformConfig<TMeta>) => NodePlatform<TMeta>;
|
|
75
82
|
|
|
76
83
|
export { type AuthorizeFunction, type AuthorizeFunctionContext, type CreatePluvHandlerConfig, NodePlatform, type NodePlatformConfig, createPluvHandler, platformNode };
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,22 @@ var __create = Object.create;
|
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
8
22
|
var __export = (target, all) => {
|
|
9
23
|
for (var name in all)
|
|
10
24
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -232,8 +246,10 @@ var NodeWebSocket = class extends import_io.AbstractWebSocket {
|
|
|
232
246
|
// src/NodePlatform.ts
|
|
233
247
|
var NodePlatform = class _NodePlatform extends import_io2.AbstractPlatform {
|
|
234
248
|
constructor(config = {}) {
|
|
235
|
-
const { mode = "attached", persistence, pubSub } = config;
|
|
236
|
-
super(
|
|
249
|
+
const { context, mode = "attached", persistence, pubSub } = config;
|
|
250
|
+
super(__spreadValues({
|
|
251
|
+
context
|
|
252
|
+
}, persistence && pubSub ? { persistence, pubSub } : {}));
|
|
237
253
|
this._registrationMode = mode;
|
|
238
254
|
}
|
|
239
255
|
acceptWebSocket(webSocket) {
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
1
17
|
var __async = (__this, __arguments, generator) => {
|
|
2
18
|
return new Promise((resolve, reject) => {
|
|
3
19
|
var fulfilled = (value) => {
|
|
@@ -196,8 +212,10 @@ var NodeWebSocket = class extends AbstractWebSocket {
|
|
|
196
212
|
// src/NodePlatform.ts
|
|
197
213
|
var NodePlatform = class _NodePlatform extends AbstractPlatform {
|
|
198
214
|
constructor(config = {}) {
|
|
199
|
-
const { mode = "attached", persistence, pubSub } = config;
|
|
200
|
-
super(
|
|
215
|
+
const { context, mode = "attached", persistence, pubSub } = config;
|
|
216
|
+
super(__spreadValues({
|
|
217
|
+
context
|
|
218
|
+
}, persistence && pubSub ? { persistence, pubSub } : {}));
|
|
201
219
|
this._registrationMode = mode;
|
|
202
220
|
}
|
|
203
221
|
acceptWebSocket(webSocket) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/platform-node",
|
|
3
|
-
"version": "0.32.
|
|
3
|
+
"version": "0.32.4",
|
|
4
4
|
"description": "@pluv/io adapter for node.js",
|
|
5
5
|
"author": "leedavidcs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,19 +17,19 @@
|
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@types/node": "^22.7.
|
|
20
|
+
"@types/node": "^22.7.8",
|
|
21
21
|
"@types/ws": "^8.5.12",
|
|
22
22
|
"path-to-regexp": "^8.2.0",
|
|
23
|
-
"@pluv/io": "^0.32.
|
|
24
|
-
"@pluv/types": "^0.32.
|
|
23
|
+
"@pluv/io": "^0.32.4",
|
|
24
|
+
"@pluv/types": "^0.32.4"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"eslint": "^8.57.0",
|
|
28
28
|
"tsup": "^8.3.0",
|
|
29
29
|
"typescript": "^5.6.3",
|
|
30
30
|
"ws": "^8.18.0",
|
|
31
|
-
"@pluv/tsconfig": "^0.32.
|
|
32
|
-
"eslint-config-pluv": "^0.32.
|
|
31
|
+
"@pluv/tsconfig": "^0.32.4",
|
|
32
|
+
"eslint-config-pluv": "^0.32.4"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"ws": "^8.0.0"
|
package/src/NodePlatform.ts
CHANGED
|
@@ -7,24 +7,36 @@ import type {
|
|
|
7
7
|
WebSocketSerializedState,
|
|
8
8
|
} from "@pluv/io";
|
|
9
9
|
import { AbstractPlatform } from "@pluv/io";
|
|
10
|
+
import type { JsonPrimitive } from "@pluv/types";
|
|
10
11
|
import crypto from "node:crypto";
|
|
11
12
|
import type { IncomingMessage } from "node:http";
|
|
12
13
|
import { TextDecoder } from "node:util";
|
|
13
14
|
import type { WebSocket } from "ws";
|
|
14
15
|
import { NodeWebSocket } from "./NodeWebSocket";
|
|
15
16
|
|
|
16
|
-
export type
|
|
17
|
+
export type NodePlatformRoomContext<TMeta extends Record<string, JsonPrimitive>> = keyof TMeta extends never
|
|
18
|
+
? { meta?: undefined }
|
|
19
|
+
: { meta: TMeta };
|
|
20
|
+
|
|
21
|
+
export type NodePlatformConfig<TMeta extends Record<string, JsonPrimitive>> = { mode?: WebSocketRegistrationMode } & (
|
|
17
22
|
| { persistence?: undefined; pubSub?: undefined }
|
|
18
23
|
| { persistence: AbstractPersistence; pubSub: AbstractPubSub }
|
|
19
|
-
);
|
|
24
|
+
) & { context?: NodePlatformRoomContext<TMeta> };
|
|
20
25
|
|
|
21
|
-
export class NodePlatform extends
|
|
26
|
+
export class NodePlatform<TMeta extends Record<string, JsonPrimitive> = {}> extends AbstractPlatform<
|
|
27
|
+
NodeWebSocket,
|
|
28
|
+
{ req: IncomingMessage },
|
|
29
|
+
NodePlatformRoomContext<TMeta>
|
|
30
|
+
> {
|
|
22
31
|
readonly _registrationMode: WebSocketRegistrationMode;
|
|
23
32
|
|
|
24
|
-
constructor(config: NodePlatformConfig = {}) {
|
|
25
|
-
const { mode = "attached", persistence, pubSub } = config;
|
|
33
|
+
constructor(config: NodePlatformConfig<TMeta> = {}) {
|
|
34
|
+
const { context, mode = "attached", persistence, pubSub } = config;
|
|
26
35
|
|
|
27
|
-
super(
|
|
36
|
+
super({
|
|
37
|
+
context,
|
|
38
|
+
...(persistence && pubSub ? { persistence, pubSub } : {}),
|
|
39
|
+
});
|
|
28
40
|
|
|
29
41
|
this._registrationMode = mode;
|
|
30
42
|
}
|
|
@@ -55,13 +67,13 @@ export class NodePlatform extends AbstractPlatform<NodeWebSocket, { req: Incomin
|
|
|
55
67
|
return [];
|
|
56
68
|
}
|
|
57
69
|
|
|
58
|
-
public initialize(config: AbstractPlatformConfig<
|
|
70
|
+
public initialize(config: AbstractPlatformConfig<NodePlatformRoomContext<TMeta>>): this {
|
|
59
71
|
return new NodePlatform({
|
|
60
72
|
context: config.context,
|
|
61
73
|
mode: this._registrationMode,
|
|
62
74
|
persistence: this.persistence,
|
|
63
75
|
pubSub: this.pubSub,
|
|
64
|
-
} as NodePlatformConfig)._initialize() as this;
|
|
76
|
+
} as NodePlatformConfig<TMeta>)._initialize() as this;
|
|
65
77
|
}
|
|
66
78
|
|
|
67
79
|
public parseData(data: string | ArrayBuffer): Record<string, any> {
|
package/src/platformNode.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import type { JsonPrimitive } from "@pluv/types";
|
|
1
2
|
import type { NodePlatformConfig } from "./NodePlatform";
|
|
2
3
|
import { NodePlatform } from "./NodePlatform";
|
|
3
4
|
|
|
4
|
-
export const platformNode =
|
|
5
|
-
|
|
5
|
+
export const platformNode = <TMeta extends Record<string, JsonPrimitive> = {}>(
|
|
6
|
+
config: NodePlatformConfig<TMeta> = {},
|
|
7
|
+
): NodePlatform<TMeta> => {
|
|
8
|
+
return new NodePlatform<TMeta>(config);
|
|
6
9
|
};
|