@caisual/kit 0.15.0 → 0.20.0
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/LICENSE +21 -0
- package/README.md +51 -0
- package/dist/kit.js +4 -2
- package/dist/kit.js.map +4 -4
- package/dist/node.js +48 -18
- package/dist/overlay.js +296 -157
- package/dist/overlay.js.map +4 -4
- package/dist/runtime.js +55 -22
- package/dist/types/contracts/index.d.ts +3 -0
- package/dist/types/contracts/manifest.d.ts +3 -1
- package/dist/types/contracts/overlay.d.ts +11 -0
- package/dist/types/contracts/pubblicazione-limiti.d.ts +3 -0
- package/dist/types/contracts/replay.d.ts +83 -0
- package/dist/types/contracts/room-limits.d.ts +3 -2
- package/dist/types/contracts/server-js.d.ts +10 -2
- package/dist/types/contracts/server-wasm.d.ts +19 -0
- package/dist/types/handshake.d.ts +1 -0
- package/dist/types/index.d.ts +10 -1
- package/dist/types/overlay/host-bridge.d.ts +2 -0
- package/dist/types/overlay/i18n.d.ts +139 -130
- package/dist/types/overlay/locale.d.ts +4 -0
- package/dist/types/overlay/styles.d.ts +1 -1
- package/dist/types/overlay/ui-model.d.ts +4 -0
- package/dist/types/overlay/ui.d.ts +1 -0
- package/dist/types/protocollo.d.ts +4 -1
- package/dist/types/replay/index.d.ts +65 -0
- package/dist/types/runtime/index.d.ts +1 -0
- package/dist/types/session/index.d.ts +4 -3
- package/dist/types/stanza/nucleo.d.ts +2 -0
- package/dist/types/stanza/tipi.d.ts +2 -0
- package/dist/types/stanza-client/index.d.ts +9 -1
- package/package.json +13 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Damiano Rodriguez
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# @caisual/kit
|
|
2
|
+
|
|
3
|
+
The game kit for [Caisual](https://caisual.com), a free home for small browser games with multiplayer built in.
|
|
4
|
+
|
|
5
|
+
The kit gives a published game a stable player identity, cloud saves, leaderboards, a daily challenge seed, and rooms with server-owned state, voice, matchmaking and spectators. It is one JavaScript module with no dependencies and never touches the page: the game keeps its own rendering, input and UI. Menus, lobby, invites, friends and results are drawn by the platform's standard overlay.
|
|
6
|
+
|
|
7
|
+
## Client
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @caisual/kit
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import { caisual } from '@caisual/kit';
|
|
15
|
+
|
|
16
|
+
const c = await caisual.connect();
|
|
17
|
+
console.log(c.player.name);
|
|
18
|
+
|
|
19
|
+
c.session.onChange((session) => {
|
|
20
|
+
if (session.kind === 'room') {
|
|
21
|
+
session.room.onState((state) => draw(state));
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
c.session.ready();
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
A published game can also load the same module from its own origin, without a bundler: `import { caisual } from '/__caisual/kit/v1.js'`.
|
|
28
|
+
|
|
29
|
+
## Server
|
|
30
|
+
|
|
31
|
+
`server.js` beside the manifest owns the room. It runs without Node.js APIs or network access.
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
import { defineGame } from '@caisual/kit/server';
|
|
35
|
+
|
|
36
|
+
export default defineGame({
|
|
37
|
+
tickRate: 0,
|
|
38
|
+
onMessage(room, player, message) {
|
|
39
|
+
room.broadcast(message);
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Documentation
|
|
45
|
+
|
|
46
|
+
- [Kit reference](https://caisual.com/kit.md): every call, event and limit.
|
|
47
|
+
- [Publishing guide](https://caisual.com/publish.md): the folder, the manifest and the CLI.
|
|
48
|
+
- [Guides](https://caisual.com/docs): rooms, voice, matchmaking, spectators, saves, versions, limits.
|
|
49
|
+
- [llms.txt](https://caisual.com/llms.txt): the index of every guide for coding agents.
|
|
50
|
+
|
|
51
|
+
Publish with [`@caisual/cli`](https://www.npmjs.com/package/@caisual/cli). Publishing is free; games run on caisual.com.
|