@nymphjs/pubsub 1.0.0-beta.11 → 1.0.0-beta.111
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/CHANGELOG.md +454 -0
- package/README.md +8 -8
- package/dist/PubSub.d.ts +77 -12
- package/dist/PubSub.js +467 -103
- package/dist/PubSub.js.map +1 -1
- package/dist/PubSub.test.js +394 -65
- package/dist/PubSub.test.js.map +1 -1
- package/dist/PubSub.types.d.ts +6 -1
- package/dist/PubSub.types.js +1 -2
- package/dist/conf/d.d.ts +23 -0
- package/dist/conf/d.js +1 -2
- package/dist/conf/defaults.d.ts +1 -1
- package/dist/conf/defaults.js +4 -4
- package/dist/conf/defaults.js.map +1 -1
- package/dist/conf/index.d.ts +2 -2
- package/dist/conf/index.js +2 -8
- package/dist/conf/index.js.map +1 -1
- package/dist/createServer.d.ts +2 -2
- package/dist/createServer.js +14 -15
- package/dist/createServer.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +7 -27
- package/dist/index.js.map +1 -1
- package/jest.config.js +11 -2
- package/package.json +23 -23
- package/src/PubSub.test.ts +467 -101
- package/src/PubSub.ts +548 -286
- package/src/PubSub.types.ts +2 -1
- package/src/conf/defaults.ts +2 -2
- package/src/conf/index.ts +2 -2
- package/src/createServer.ts +8 -8
- package/src/index.ts +4 -4
- package/tsconfig.json +5 -3
- package/typedoc.json +4 -0
package/src/PubSub.types.ts
CHANGED
package/src/conf/defaults.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Config } from './d';
|
|
1
|
+
import { Config } from './d.js';
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
originIsAllowed: () => {
|
|
5
5
|
throw new Error(
|
|
6
|
-
'You must provide a "originIsAllowed" function to PubSub config to determine if client origin is allowed.'
|
|
6
|
+
'You must provide a "originIsAllowed" function to PubSub config to determine if client origin is allowed.',
|
|
7
7
|
);
|
|
8
8
|
},
|
|
9
9
|
entries: ['ws://127.0.0.1:8080/'],
|
package/src/conf/index.ts
CHANGED
package/src/createServer.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import http from 'node:http';
|
|
2
|
+
import type { Nymph } from '@nymphjs/nymph';
|
|
3
|
+
import ws from 'websocket';
|
|
4
4
|
|
|
5
|
-
import { Config, ConfigDefaults as defaults } from './conf';
|
|
6
|
-
import PubSub from './PubSub';
|
|
5
|
+
import { Config, ConfigDefaults as defaults } from './conf/index.js';
|
|
6
|
+
import PubSub from './PubSub.js';
|
|
7
7
|
|
|
8
8
|
export default function createServer(
|
|
9
9
|
port = 8080,
|
|
10
10
|
config: Partial<Config> = {},
|
|
11
|
-
nymph: Nymph
|
|
11
|
+
nymph: Nymph,
|
|
12
12
|
) {
|
|
13
13
|
const server = http.createServer((_request, response) => {
|
|
14
14
|
response.writeHead(404);
|
|
@@ -19,11 +19,11 @@ export default function createServer(
|
|
|
19
19
|
(config.logger ?? defaults.logger)(
|
|
20
20
|
'log',
|
|
21
21
|
new Date().toISOString(),
|
|
22
|
-
`Nymph-PubSub server started listening on port ${port}
|
|
22
|
+
`Nymph-PubSub server started listening on port ${port}.`,
|
|
23
23
|
);
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
const wsServer = new
|
|
26
|
+
const wsServer = new ws.server({
|
|
27
27
|
httpServer: listener,
|
|
28
28
|
// You should not use autoAcceptConnections for production
|
|
29
29
|
// applications, as it defeats all standard cross-origin protection
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * from './conf';
|
|
1
|
+
export * from './conf/index.js';
|
|
2
2
|
|
|
3
|
-
import PubSub from './PubSub';
|
|
3
|
+
import PubSub from './PubSub.js';
|
|
4
4
|
export { PubSub };
|
|
5
5
|
|
|
6
|
-
export * from './PubSub.types';
|
|
6
|
+
export * from './PubSub.types.js';
|
|
7
7
|
|
|
8
|
-
import createServer from './createServer';
|
|
8
|
+
import createServer from './createServer.js';
|
|
9
9
|
export { createServer };
|
|
10
10
|
export default createServer;
|
package/tsconfig.json
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
"extends": "@tsconfig/recommended/tsconfig.json",
|
|
3
3
|
|
|
4
4
|
"compilerOptions": {
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"module": "ES2022",
|
|
6
|
+
"moduleResolution": "node",
|
|
7
|
+
"lib": ["ES2022"],
|
|
8
|
+
"target": "ES2022",
|
|
7
9
|
"noImplicitAny": true,
|
|
8
|
-
"removeComments":
|
|
10
|
+
"removeComments": false,
|
|
9
11
|
"sourceMap": true,
|
|
10
12
|
"outDir": "dist",
|
|
11
13
|
"resolveJsonModule": true,
|
package/typedoc.json
ADDED