@soundworks/core 4.0.0-alpha.2 → 4.0.0-alpha.20
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/.eslintrc +0 -1
- package/.jsdoc +57 -0
- package/CHANGELOG.md +26 -0
- package/README.md +17 -51
- package/package.json +24 -31
- package/src/client/Client.js +11 -5
- package/src/client/Context.js +12 -13
- package/src/client/ContextManager.js +1 -1
- package/src/client/PluginManager.js +1 -1
- package/src/client/SharedStateCollection.js +38 -0
- package/src/client/Socket.js +60 -44
- package/src/common/BasePlugin.js +31 -21
- package/src/common/BasePluginManager.js +34 -19
- package/src/common/BaseSharedState.js +201 -68
- package/src/common/BaseSharedStateCollection.js +279 -0
- package/src/common/BaseStateManager.js +257 -36
- package/src/common/BatchedTransport.js +66 -0
- package/src/common/ParameterBag.js +92 -30
- package/src/common/PromiseStore.js +48 -0
- package/src/common/SharedStatePrivate.js +52 -43
- package/src/common/constants.js +14 -1
- package/src/common/sockets-utils.js +3 -4
- package/src/server/Client.js +7 -2
- package/src/server/ContextManager.js +4 -4
- package/src/server/PluginManager.js +1 -1
- package/src/server/Server.js +255 -41
- package/src/server/SharedState.js +0 -1
- package/src/server/SharedStateCollection.js +39 -0
- package/src/server/Socket.js +50 -49
- package/src/server/Sockets.js +31 -11
- package/src/server/StateManager.js +162 -90
- package/src/server/audit-network-latency.worker.js +16 -4
- package/src/server/crypto.js +37 -0
- package/src/common/promise-store.js +0 -25
- package/src/common/utils.js +0 -22
- package/tsconfig.json +0 -21
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { idGenerator } from './utils.js';
|
|
2
|
-
|
|
3
|
-
const generateRequestId = idGenerator();
|
|
4
|
-
const requestPromises = new Map();
|
|
5
|
-
|
|
6
|
-
export function storeRequestPromise(resolve, reject) {
|
|
7
|
-
const reqId = generateRequestId.next().value;
|
|
8
|
-
requestPromises.set(reqId, { resolve, reject });
|
|
9
|
-
|
|
10
|
-
return reqId;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function resolveRequest(reqId, data) {
|
|
14
|
-
const { resolve } = requestPromises.get(reqId);
|
|
15
|
-
requestPromises.delete(reqId);
|
|
16
|
-
|
|
17
|
-
resolve(data);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function rejectRequest(reqId, data) {
|
|
21
|
-
const { reject } = requestPromises.get(reqId);
|
|
22
|
-
requestPromises.delete(reqId);
|
|
23
|
-
|
|
24
|
-
reject(data);
|
|
25
|
-
}
|
package/src/common/utils.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// https://stackoverflow.com/questions/17575790/environment-detection-node-js-or-browser
|
|
2
|
-
export const isBrowser = new Function('try {return this===window;}catch(e){ return false;}');
|
|
3
|
-
|
|
4
|
-
export function* idGenerator() {
|
|
5
|
-
for (let i = 0; true; i++) {
|
|
6
|
-
if (i === Number.MAX_SAFE_INTEGER) {
|
|
7
|
-
i = 0;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
yield i;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function isString(val) {
|
|
15
|
-
return (typeof val === 'string' || val instanceof String);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function isFunction(func) {
|
|
19
|
-
return Object.prototype.toString.call(func) == '[object Function]' ||
|
|
20
|
-
Object.prototype.toString.call(func) == '[object AsyncFunction]';
|
|
21
|
-
}
|
|
22
|
-
|
package/tsconfig.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"include": ["src/**/*.js"],
|
|
3
|
-
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
// Tells TypeScript to read JS files, as
|
|
6
|
-
// normally they are ignored as source files
|
|
7
|
-
"allowJs": true,
|
|
8
|
-
// Generate d.ts files
|
|
9
|
-
"declaration": true,
|
|
10
|
-
// This compiler run should
|
|
11
|
-
// only output d.ts files
|
|
12
|
-
"emitDeclarationOnly": true,
|
|
13
|
-
// Types should go into this directory.
|
|
14
|
-
// Removing this would place the .d.ts files
|
|
15
|
-
// next to the .js files
|
|
16
|
-
"outDir": "types",
|
|
17
|
-
// go to js file when using IDE functions like
|
|
18
|
-
// "Go to Definition" in VSCode
|
|
19
|
-
"declarationMap": true
|
|
20
|
-
}
|
|
21
|
-
}
|