@soundworks/core 4.0.0-alpha.9 → 5.0.1

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.
Files changed (144) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/README.md +14 -29
  3. package/package.json +24 -42
  4. package/src/client/Client.js +306 -256
  5. package/src/client/{Context.js → ClientContext.js} +63 -54
  6. package/src/client/ClientContextManager.js +115 -0
  7. package/src/client/{Plugin.js → ClientPlugin.js} +23 -19
  8. package/src/client/{PluginManager.js → ClientPluginManager.js} +43 -40
  9. package/src/client/ClientSocket.js +270 -0
  10. package/src/client/{StateManager.js → ClientStateManager.js} +13 -13
  11. package/src/client/index.js +36 -39
  12. package/src/common/BasePlugin.js +64 -58
  13. package/src/common/BasePluginManager.js +191 -142
  14. package/src/common/BaseStateManager.js +635 -145
  15. package/src/common/BatchedTransport.js +73 -0
  16. package/src/common/ParameterBag.js +90 -93
  17. package/src/common/PromiseStore.js +54 -0
  18. package/src/common/SharedState.js +821 -0
  19. package/src/common/SharedStateCollection.js +492 -0
  20. package/src/common/constants.js +14 -2
  21. package/src/common/logger.js +64 -68
  22. package/src/common/shared-state-types.js +82 -0
  23. package/src/common/sockets-utils.js +0 -64
  24. package/src/common/version.js +2 -0
  25. package/src/server/Server.js +552 -824
  26. package/src/server/ServerClient.js +74 -0
  27. package/src/server/{Context.js → ServerContext.js} +96 -77
  28. package/src/server/{ContextManager.js → ServerContextManager.js} +107 -87
  29. package/src/server/{Plugin.js → ServerPlugin.js} +30 -32
  30. package/src/server/ServerPluginManager.js +177 -0
  31. package/src/server/ServerSocket.js +256 -0
  32. package/src/server/ServerSockets.js +150 -0
  33. package/src/server/ServerStateManager.js +706 -0
  34. package/src/server/SharedStatePrivate.js +277 -0
  35. package/src/server/audit-network-latency.worker.js +19 -4
  36. package/src/server/{audit-schema.js → audit-state-class-description.js} +3 -2
  37. package/src/server/create-http-server.js +127 -0
  38. package/src/server/crypto.js +8 -7
  39. package/src/server/index.js +60 -17
  40. package/types/client/Client.d.ts +95 -70
  41. package/types/client/{Context.d.ts → ClientContext.d.ts} +59 -34
  42. package/types/client/{ContextManager.d.ts → ClientContextManager.d.ts} +19 -22
  43. package/types/client/ClientPlugin.d.ts +51 -0
  44. package/types/client/ClientPluginManager.d.ts +112 -0
  45. package/types/client/ClientSocket.d.ts +76 -0
  46. package/types/client/{StateManager.d.ts → ClientStateManager.d.ts} +18 -21
  47. package/types/client/index.d.ts +33 -6
  48. package/types/common/BasePlugin.d.ts +64 -53
  49. package/types/common/BasePluginManager.d.ts +84 -39
  50. package/types/common/BaseStateManager.d.ts +227 -49
  51. package/types/common/BatchedTransport.d.ts +17 -0
  52. package/types/common/ParameterBag.d.ts +73 -76
  53. package/types/common/PromiseStore.d.ts +11 -0
  54. package/types/common/SharedState.d.ts +291 -0
  55. package/types/common/SharedStateCollection.d.ts +311 -0
  56. package/types/common/constants.d.ts +10 -3
  57. package/types/common/logger.d.ts +8 -6
  58. package/types/common/shared-state-types.d.ts +95 -0
  59. package/types/common/sockets-utils.d.ts +0 -5
  60. package/types/common/version.d.ts +2 -0
  61. package/types/server/Server.d.ts +215 -136
  62. package/types/server/ServerClient.d.ts +45 -0
  63. package/types/server/ServerContext.d.ts +209 -0
  64. package/types/server/ServerContextManager.d.ts +75 -0
  65. package/types/server/ServerPlugin.d.ts +57 -0
  66. package/types/server/ServerPluginManager.d.ts +115 -0
  67. package/types/server/ServerSocket.d.ts +69 -0
  68. package/types/server/ServerSockets.d.ts +42 -0
  69. package/types/server/ServerStateManager.d.ts +284 -0
  70. package/types/server/SharedStatePrivate.d.ts +23 -0
  71. package/types/server/audit-network-latency.worker.d.ts +2 -2
  72. package/types/server/{audit-schema.d.ts → audit-state-class-description.d.ts} +8 -9
  73. package/types/server/create-http-server.d.ts +5 -0
  74. package/types/server/crypto.d.ts +4 -0
  75. package/types/server/index.d.ts +51 -3
  76. package/.eslintrc +0 -15
  77. package/.github/workflows/gh-pages.yml +0 -31
  78. package/.github/workflows/unit-tests.yml +0 -18
  79. package/src/client/ContextManager.js +0 -111
  80. package/src/client/SharedState.js +0 -84
  81. package/src/client/SharedStateCollection.js +0 -35
  82. package/src/client/Socket.js +0 -402
  83. package/src/common/BaseSharedState.js +0 -583
  84. package/src/common/BaseSharedStateCollection.js +0 -179
  85. package/src/common/SharedStatePrivate.js +0 -192
  86. package/src/common/promise-store.js +0 -25
  87. package/src/server/Client.js +0 -55
  88. package/src/server/PluginManager.js +0 -170
  89. package/src/server/SharedState.js +0 -85
  90. package/src/server/SharedStateCollection.js +0 -36
  91. package/src/server/Socket.js +0 -396
  92. package/src/server/Sockets.js +0 -224
  93. package/src/server/StateManager.js +0 -620
  94. package/tsconfig.json +0 -21
  95. package/types/client/Client.d.ts.map +0 -1
  96. package/types/client/Context.d.ts.map +0 -1
  97. package/types/client/ContextManager.d.ts.map +0 -1
  98. package/types/client/Plugin.d.ts +0 -53
  99. package/types/client/Plugin.d.ts.map +0 -1
  100. package/types/client/PluginManager.d.ts +0 -96
  101. package/types/client/PluginManager.d.ts.map +0 -1
  102. package/types/client/SharedState.d.ts +0 -85
  103. package/types/client/SharedState.d.ts.map +0 -1
  104. package/types/client/Socket.d.ts +0 -138
  105. package/types/client/Socket.d.ts.map +0 -1
  106. package/types/client/StateManager.d.ts.map +0 -1
  107. package/types/client/index.d.ts.map +0 -1
  108. package/types/common/BasePlugin.d.ts.map +0 -1
  109. package/types/common/BasePluginManager.d.ts.map +0 -1
  110. package/types/common/BaseSharedState.d.ts +0 -173
  111. package/types/common/BaseSharedState.d.ts.map +0 -1
  112. package/types/common/BaseStateManager.d.ts.map +0 -1
  113. package/types/common/ParameterBag.d.ts.map +0 -1
  114. package/types/common/SharedStatePrivate.d.ts +0 -20
  115. package/types/common/SharedStatePrivate.d.ts.map +0 -1
  116. package/types/common/constants.d.ts.map +0 -1
  117. package/types/common/logger.d.ts.map +0 -1
  118. package/types/common/promise-store.d.ts +0 -4
  119. package/types/common/promise-store.d.ts.map +0 -1
  120. package/types/common/sockets-utils.d.ts.map +0 -1
  121. package/types/common/utils.d.ts +0 -5
  122. package/types/common/utils.d.ts.map +0 -1
  123. package/types/server/Client.d.ts +0 -40
  124. package/types/server/Client.d.ts.map +0 -1
  125. package/types/server/Context.d.ts +0 -59
  126. package/types/server/Context.d.ts.map +0 -1
  127. package/types/server/ContextManager.d.ts +0 -69
  128. package/types/server/ContextManager.d.ts.map +0 -1
  129. package/types/server/Plugin.d.ts +0 -70
  130. package/types/server/Plugin.d.ts.map +0 -1
  131. package/types/server/PluginManager.d.ts +0 -91
  132. package/types/server/PluginManager.d.ts.map +0 -1
  133. package/types/server/Server.d.ts.map +0 -1
  134. package/types/server/SharedState.d.ts +0 -86
  135. package/types/server/SharedState.d.ts.map +0 -1
  136. package/types/server/Socket.d.ts +0 -128
  137. package/types/server/Socket.d.ts.map +0 -1
  138. package/types/server/Sockets.d.ts +0 -73
  139. package/types/server/Sockets.d.ts.map +0 -1
  140. package/types/server/StateManager.d.ts +0 -190
  141. package/types/server/StateManager.d.ts.map +0 -1
  142. package/types/server/audit-network-latency.worker.d.ts.map +0 -1
  143. package/types/server/audit-schema.d.ts.map +0 -1
  144. package/types/server/index.d.ts.map +0 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,102 @@
1
+ ## v5.0.0 - 2025-01-30
2
+
3
+ ### Breaking
4
+
5
+ _Note that most breaking changes won't break but trigger a warning._
6
+
7
+ Change `SharedState` semantics:
8
+
9
+ - rename `SharedStateClassSchema` to `SharedStateClassDescription`
10
+ - rename `SharedState#schemaName` to `SharedState#className`
11
+ - rename `SharedState#getSchema()` to `SharedState#getDescription()`
12
+ - rename `SharedStateCollection#schemaName` to `SharedStateCollection#className`
13
+ - rename `SharedStateCollection#getSchema()` to `SharedStateCollection#getDescription()`
14
+ - rename `BaseStateManager.getSchema` to `BaseStateManager.getClassDescription`
15
+ - rename `ServerStateManager.registerSchema` to `ServerStateManager.defineClass`
16
+ - rename `ServerStateManager.deleteSchema` to `ServerStateManager.deleteClass`
17
+ - drop support for `context` in `SharedState.set(updates, context)`
18
+ - rename `ClientDescription.target` to `ClientDescription.runtime`
19
+ - rename `ServerEnvConfig.subpath` to `ServerEnvConfig.baseUlr`
20
+ - move `Server#useDefaultApplicationTemplate` into helpers: `configureHttpRouter(server)`
21
+ - review plugin creation API
22
+
23
+ ### Feat
24
+
25
+ - allow `SharedState.set(key, value)`
26
+ - implement `ServerStateManager#registerCreateHook` and `ServerStateManager#registerDeleteHook`
27
+ - implement `SharedStateCollection#onChange` --> `onChange`
28
+
29
+ ### Fix
30
+
31
+ - harmonize all error messages
32
+
33
+ ## v4.0.0-alpha.29 - 2024-09-23
34
+
35
+ - Feat: add required option for SharedState parameter
36
+ - Chore: Renamed all classes to avoid namespace in doc and improve typescript support
37
+ - Chore: improve shared states abstractions naming
38
+
39
+ ## v4.0.0-alpha.28 - 2024-09-06
40
+
41
+ - Fix: make it can work without `node_modules` when bundled to `.cjs` for use in Max
42
+
43
+ ## v4.0.0-alpha.27 - 2024-09-06
44
+
45
+ - Fix: assign to `const`
46
+
47
+ ## v4.0.0-alpha.26 - 2024-09-05
48
+
49
+ - Fix: improve reconnect strategy in case of socket connection failure
50
+
51
+ ## v4.0.0-alpha.25 - 2024-05-24
52
+
53
+ - Fix: better default behavior for WebSocket connection URL
54
+
55
+ ## v4.0.0-alpha.24 - 2024-05-24
56
+
57
+ - Fix: unexpected behavior with new `serverAddress` behavior on browser clients and self-signed certificates
58
+
59
+ ## v4.0.0-alpha.23 - 2024-05-24
60
+
61
+ - Breaking: remove binary socket
62
+ - Fix: do not terminate socket on missed heartbeat, which seems to create false positive, just warn instead
63
+ - Refactor: some work toward upgrading code to ES2022
64
+
65
+ ## v4.0.0-alpha.22 - 2024-05-16
66
+
67
+ - Feat: allow configuring socket endpoint on browser clients
68
+ - Feat: check and warn if version inconsistency between server and client
69
+
70
+ ## v4.0.0-alpha.21 - 2024-05-06
71
+
72
+ - Fix: prevent multiple 'close' events
73
+ - Fix: disable heartbeat check on client-side, was unstable
74
+ - Feat: introduce 'local' option for SharedState parameters
75
+ - Feat: ability to filter parameters of interest in SharedState
76
+
77
+ ## v4.0.0-alpha.20 - 2024-02-19
78
+
79
+ - Refactor heartbeat - #86
80
+ - Refactor state collection - #85
81
+ - Fix issue with self signed certs and config generated by wizard - #84
82
+
83
+ ## v4.0.0-alpha.19 - 2024-01-17
84
+
85
+ - Hot fix for #85
86
+
87
+ ## v4.0.0-alpha.18 - 2024-01-15
88
+
89
+ - Batch network message for SharedStates
90
+
91
+ ## v4.0.0-alpha.17 - 2023-12-16
92
+
93
+ - Support bundling the server to common js for Max externals
94
+
95
+ ## v4.0.0-alpha.16 - 2023-12-15
96
+
97
+ - Improve StateCollection performances
98
+
99
+ ## v4.0.0-alpha.15 - 2023-12-13
100
+
101
+ - Fix several issues with shared states
102
+ - **Breaking Change**: by default, `StateManager::observe` and `SharedStateCollection` now retrieve locally created states
package/README.md CHANGED
@@ -3,64 +3,49 @@
3
3
  [![npm version](https://badge.fury.io/js/@soundworks%2Fcore.svg)](https://badge.fury.io/js/@soundworks%2Fcore)
4
4
  [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
5
5
 
6
- ![soundworks-logo](./assets/logo-200x200.png)
6
+ ![soundworks-logo](./misc/assets/logo-200x200.png)
7
7
 
8
8
  Open-source creative coding framework for distributed applications based on Web technologies.
9
9
 
10
10
  Primarily focused on music, **soundworks** aims at supporting rapid development of real-time distributed applications using _JavaScript_. It provides abstractions to hide the complexity of the network and to foster very rapid-prototyping and trial-and-error workflows that are typical in artistic practices.
11
11
 
12
- *__WARNING: The version 4 of `@soundworks/core` is under heavy development.__*
13
-
14
- ## Getting Started
15
-
16
- The best and most simple way to start using **soundworks** is to use the `@soundworks/create` wizard.
17
-
18
- ```sh
19
- npx @soundworks/create@latest
20
- ```
21
-
22
- ![./assets/soundworks-create-min.gif](./assets/soundworks-create-min.gif)
23
-
24
- See [https://soundworks.dev/tutorials/getting-started.html](https://soundworks.dev/tutorials/getting-started.html) for more informations on the wizard and how to start with **soundworks**.
25
-
26
- <!--
27
12
  ## Documentation
28
13
 
29
14
  - Guides and Tutorials: [https://soundworks.dev](https://soundworks.dev)
30
15
  - API: [https://soundworks.dev/api](https://soundworks.dev/api)
31
- -->
32
16
 
33
- ## API
17
+ ## Getting started
34
18
 
35
- The API is not publicly published for now. To access the API documentation locally, just clone this repository, go to the v4 branch and launch some http server in the docs directory. For example, using the [serve](https://www.npmjs.com/package/serve) package:
19
+ The best and most simple way to start using **soundworks** is to use the `@soundworks/create` wizard.
36
20
 
37
21
  ```sh
38
- git clone https://github.com/collective-soundworks/soundworks.git
39
- cd soundworks
40
- git checkout v4
41
- serve docs
22
+ npx @soundworks/create@latest
42
23
  ```
43
24
 
44
- Feel welcome to open an [issue](https://github.com/collective-soundworks/soundworks/issues) or a PR if you find any inconsistency, error or missing information in the documentation.
25
+ ![soundworks-create](./misc/assets/soundworks-create-min.gif)
45
26
 
46
- ## Share with Us
27
+ See [https://soundworks.dev/tutorials/getting-started.html](https://soundworks.dev/tutorials/getting-started.html) for more information on the wizard and how to start using **soundworks**.
47
28
 
48
- If you made an application using **soundworks** please let us know here: https://github.com/collective-soundworks/soundworks/discussions/61
29
+ ## Misc
49
30
 
50
- ## TypeScript Support
31
+ ### TypeScript support
51
32
 
52
33
  Basic TypeScript support will be proposed in a (hopefully) near future.
53
34
 
54
35
  However, for maintenance reasons, we aim at following the TC39 and W3C specifications as close as possible. Therefore, we will wait for the https://github.com/tc39/proposal-type-annotations proposal to reach stage 3 to update the source code in a more integrated manner.
55
36
 
56
- ## Install
37
+ ### Manual install
57
38
 
58
- Note that the `@soundworks/core` package is automatically installed when creating an application using the `@soundworks/create` wizard, so most of the time you should not have to install this package manually. See [https://soundworks.dev/guides/getting-started.html](https://soundworks.dev/guides/getting-started.html) for more informations on the **soundworks** wizard.
39
+ Note that the `@soundworks/core` package is automatically installed when creating an application using the `@soundworks/create` wizard, so most of the time you should not have to install this package manually. See [https://soundworks.dev/guides/getting-started.html](https://soundworks.dev/guides/getting-started.html) for more information on the **soundworks** wizard.
59
40
 
60
41
  ```
61
42
  npm install @soundworks/core
62
43
  ```
63
44
 
45
+ ## Share with Us
46
+
47
+ If you made an application using **soundworks** please let us know here: https://github.com/collective-soundworks/soundworks/discussions/61
48
+
64
49
  ## Credits
65
50
 
66
51
  [https://soundworks.dev/credits.html](https://soundworks.dev/credits.html)
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@soundworks/core",
3
- "version": "4.0.0-alpha.9",
3
+ "version": "5.0.1",
4
4
  "description": "Open-source creative coding framework for distributed applications based on Web technologies",
5
- "authors": [
5
+ "collaborators": [
6
6
  "Benjamin Matuszewski",
7
+ "Jean-Philippe Lambert",
7
8
  "Sébastien Robaszkiewicz",
8
9
  "Norbert Schnell"
9
10
  ],
@@ -43,59 +44,40 @@
43
44
  "node": ">=16.0.0"
44
45
  },
45
46
  "scripts": {
46
- "doc": "rm -Rf docs && jsdoc -c .jsdoc.json --verbose && cp -R assets docs/",
47
+ "doc": "npm run types && rm -rf docs && jsdoc -c .jsdoc --verbose && cp -R misc/assets docs/",
47
48
  "lint": "npx eslint src",
48
- "test": "mocha",
49
- "toc": "markdown-toc -i README.md",
50
- "types": "rm -Rf types && tsc",
51
- "preversion": "npm run toc && git commit -am 'docs: build' --allow-empty"
49
+ "test": "npx mocha tests/*/*.spec.js",
50
+ "test:only": "npx mocha",
51
+ "types": "rm -rf types && tsc",
52
+ "preversion": "npm run lint && npm run test && node ./misc/scripts/generate-version-file.js $npm_new_version && npm run types",
53
+ "postversion": "node ./misc/scripts/check-changelog.js && git commit -am \"$npm_new_version\" --allow-empty"
52
54
  },
53
55
  "dependencies": {
54
- "@ircam/sc-gettime": "^1.0.1",
55
- "@ircam/sc-utils": "^1.1.1",
56
+ "@ircam/sc-utils": "^1.8.0",
56
57
  "chalk": "^5.3.0",
57
- "columnify": "^1.6.0",
58
- "compression": "^1.7.1",
59
- "cross-fetch": "^3.1.8",
60
- "express": "^4.18.1",
61
58
  "fast-deep-equal": "^3.1.3",
62
- "fast-text-encoding": "^1.0.0",
63
59
  "isomorphic-ws": "^5.0.0",
64
- "keyv": "^4.2.2",
65
- "keyv-file": "^0.2.0",
66
- "lodash.clonedeep": "^4.5.0",
67
- "lodash.merge": "^4.6.2",
60
+ "keyv": "^4.5.4",
61
+ "keyv-file": "^0.3.1",
62
+ "lodash": "^4.17.21",
68
63
  "pem": "^1.14.8",
69
- "template-literal": "^1.0.4",
70
- "uuid": "^9.0.0",
71
- "window-or-global": "^1.0.1",
72
- "ws": "^8.12.0"
64
+ "uuid": "^9.0.1",
65
+ "ws": "^8.17.0"
73
66
  },
74
67
  "devDependencies": {
75
- "@ircam/eslint-config": "^1.3.0",
76
- "chai": "^4.3.6",
77
- "chai-shallow-deep-equal": "^1.4.6",
78
- "commitizen": "^4.2.5",
79
- "cz-conventional-changelog": "^3.3.0",
80
- "docdash": "^2.0.1",
81
- "dotenv": "^16.3.1",
82
- "eslint": "^8.44.0",
83
- "eslint-plugin-jsdoc": "^46.4.3",
84
- "generate-changelog": "^1.8.0",
85
- "jsdoc": "^4.0.0",
86
- "markdown-toc": "^1.2.0",
87
- "mocha": "^10.2.0",
88
- "puppeteer": "^20.7.4",
68
+ "@ircam/eslint-config": "^2.0.1",
69
+ "chai": "^5.1.1",
70
+ "docdash": "^2.0.2",
71
+ "dotenv": "^16.4.5",
72
+ "eslint": "^9.18.0",
73
+ "jsdoc": "^4.0.3",
74
+ "mocha": "^10.4.0",
75
+ "puppeteer": "^22.9.0",
89
76
  "tcp-ping": "^0.1.1",
90
- "typescript": "^5.1.6"
77
+ "typescript": "^5.4.5"
91
78
  },
92
79
  "optionalDependencies": {
93
80
  "bufferutil": "^4.0.5",
94
81
  "utf-8-validate": "^5.0.7"
95
- },
96
- "config": {
97
- "commitizen": {
98
- "path": "./node_modules/cz-conventional-changelog"
99
- }
100
82
  }
101
83
  }