@eleven-am/pondsocket 0.1.217 → 0.1.219
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/README.md +84 -164
- package/{abstracts → dist/abstracts}/types.d.ts +3 -3
- package/{contexts → dist/contexts}/baseContext.d.ts +3 -1
- package/{contexts → dist/contexts}/baseContext.js +6 -0
- package/{contexts → dist/contexts}/eventContext.d.ts +2 -2
- package/{contexts → dist/contexts}/joinContext.js +8 -2
- package/dist/contexts/outgoingContext.d.ts +36 -0
- package/{contexts → dist/contexts}/outgoingContext.js +12 -6
- package/{engines → dist/engines}/channelEngine.d.ts +3 -1
- package/{engines → dist/engines}/channelEngine.js +103 -13
- package/{engines → dist/engines}/endpointEngine.d.ts +2 -1
- package/{engines → dist/engines}/endpointEngine.js +29 -11
- package/{engines → dist/engines}/lobbyEngine.js +14 -9
- package/{index.d.ts → dist/index.d.ts} +1 -0
- package/dist/matcher/matcher.js +17 -0
- package/{server → dist/server}/server.d.ts +8 -4
- package/{server → dist/server}/server.js +112 -33
- package/{types.d.ts → dist/types.d.ts} +6 -6
- package/{wrappers → dist/wrappers}/channel.d.ts +13 -5
- package/{wrappers → dist/wrappers}/channel.js +22 -6
- package/{wrappers → dist/wrappers}/endpoint.d.ts +4 -2
- package/{wrappers → dist/wrappers}/pondChannel.d.ts +4 -4
- package/{wrappers → dist/wrappers}/pondChannel.js +6 -6
- package/package.json +48 -64
- package/contexts/outgoingContext.d.ts +0 -28
- package/matcher/matcher.js +0 -74
- /package/{abstracts → dist/abstracts}/distributor.d.ts +0 -0
- /package/{abstracts → dist/abstracts}/distributor.js +0 -0
- /package/{abstracts → dist/abstracts}/middleware.d.ts +0 -0
- /package/{abstracts → dist/abstracts}/middleware.js +0 -0
- /package/{abstracts → dist/abstracts}/types.js +0 -0
- /package/{contexts → dist/contexts}/connectionContext.d.ts +0 -0
- /package/{contexts → dist/contexts}/connectionContext.js +0 -0
- /package/{contexts → dist/contexts}/eventContext.js +0 -0
- /package/{contexts → dist/contexts}/joinContext.d.ts +0 -0
- /package/{engines → dist/engines}/lobbyEngine.d.ts +0 -0
- /package/{engines → dist/engines}/presenceEngine.d.ts +0 -0
- /package/{engines → dist/engines}/presenceEngine.js +0 -0
- /package/{errors → dist/errors}/httpError.d.ts +0 -0
- /package/{errors → dist/errors}/httpError.js +0 -0
- /package/{index.js → dist/index.js} +0 -0
- /package/{matcher → dist/matcher}/matcher.d.ts +0 -0
- /package/{types.js → dist/types.js} +0 -0
- /package/{wrappers → dist/wrappers}/endpoint.js +0 -0
package/matcher/matcher.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseAddress = parseAddress;
|
|
4
|
-
function pathToRegexp(path) {
|
|
5
|
-
const parts = path.split('/');
|
|
6
|
-
const regexpParts = parts.map((part) => {
|
|
7
|
-
if (part.startsWith(':')) {
|
|
8
|
-
return '([^/]+)';
|
|
9
|
-
}
|
|
10
|
-
else if (part === '*') {
|
|
11
|
-
return '(.*)';
|
|
12
|
-
}
|
|
13
|
-
return part;
|
|
14
|
-
});
|
|
15
|
-
return new RegExp(`^${regexpParts.join('/')}$`);
|
|
16
|
-
}
|
|
17
|
-
function getParams(path, route) {
|
|
18
|
-
const regexp = pathToRegexp(route);
|
|
19
|
-
const match = path.match(regexp);
|
|
20
|
-
if (!match) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
const cleanRoute = route.replace(/:/g, '');
|
|
24
|
-
const cleanMatch = cleanRoute.match(regexp);
|
|
25
|
-
if (!cleanMatch) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
const keys = cleanMatch.slice(1).filter((s) => s !== '');
|
|
29
|
-
const values = match.slice(1).filter((s) => s !== '');
|
|
30
|
-
if (keys.length !== values.length) {
|
|
31
|
-
return {};
|
|
32
|
-
}
|
|
33
|
-
return keys.reduce((params, key, index) => {
|
|
34
|
-
if (key === '*') {
|
|
35
|
-
params[key] = `/${values.slice(index).join('/')}`.replace(/\/+/g, '/');
|
|
36
|
-
return params;
|
|
37
|
-
}
|
|
38
|
-
params[key] = values[index];
|
|
39
|
-
return params;
|
|
40
|
-
}, {});
|
|
41
|
-
}
|
|
42
|
-
function getQuery(query) {
|
|
43
|
-
if (!query) {
|
|
44
|
-
return {};
|
|
45
|
-
}
|
|
46
|
-
const searchParams = new URLSearchParams(query);
|
|
47
|
-
const params = {};
|
|
48
|
-
searchParams.forEach((value, key) => {
|
|
49
|
-
params[key] = value;
|
|
50
|
-
});
|
|
51
|
-
return params;
|
|
52
|
-
}
|
|
53
|
-
function parseAddress(route, address) {
|
|
54
|
-
if (route instanceof RegExp) {
|
|
55
|
-
const match = address.match(route);
|
|
56
|
-
if (!match) {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
params: {},
|
|
61
|
-
query: {},
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
const [path, queryParams] = address.split('?');
|
|
65
|
-
const params = getParams(path, route);
|
|
66
|
-
if (!params) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
const query = getQuery(queryParams);
|
|
70
|
-
return {
|
|
71
|
-
params,
|
|
72
|
-
query,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|