playertwo-sdk 0.2.11 → 0.2.12
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 +65 -65
- package/index.d.ts +5 -5
- package/index.mjs +5 -6
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# playertwo-sdk
|
|
2
2
|
|
|
3
|
-
The game SDK for [PlayerTwo](https://playertwo.
|
|
3
|
+
The game SDK for [PlayerTwo](https://playertwo.plus), with TypeScript types. Trophies, XP and levels, stats,
|
|
4
4
|
leaderboards, cloud saves, presence, invites, add-ons, in-game purchases, donations to you, the player's avatar, travel
|
|
5
5
|
between games, and multiplayer rooms with no server of your own (voice chat, worlds, replays and your own server code in `room.js`
|
|
6
6
|
included).
|
|
@@ -9,8 +9,8 @@ PlayerTwo is a game store and a launchpad. Games are sold (or free) to play in t
|
|
|
9
9
|
let players back a game while it is being made, paid to its developer stage by stage as they post proof. A web game
|
|
10
10
|
hosted on PlayerTwo gets its own address on `playertwo.cc` and every service below through one account per player.
|
|
11
11
|
|
|
12
|
-
- Docs: https://playertwo.
|
|
13
|
-
- Everything a game gets, with a link to its part of the docs: https://playertwo.
|
|
12
|
+
- Docs: https://playertwo.plus/docs/sdk
|
|
13
|
+
- Everything a game gets, with a link to its part of the docs: https://playertwo.plus/llms.txt
|
|
14
14
|
- Source of these packages, examples and Markdown docs: https://github.com/TheDudeCommits/playertwo-sdk
|
|
15
15
|
|
|
16
16
|
## Install
|
|
@@ -31,7 +31,7 @@ Or no install at all: the SDK itself is one script.
|
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
On PlayerTwo the script is already in your game's page. `init()` from the npm package uses that copy, and loads
|
|
34
|
-
`https://playertwo.
|
|
34
|
+
`https://playertwo.plus/sdk/v1.js` only when the page doesn't have it (on localhost, say).
|
|
35
35
|
|
|
36
36
|
## Quick start
|
|
37
37
|
|
|
@@ -61,58 +61,58 @@ sync.on("leave", (id) => removeMesh(id));
|
|
|
61
61
|
```
|
|
62
62
|
|
|
63
63
|
Every call returns a promise. A refusal rejects with an `Error` that has a `code` and a `status` (the codes:
|
|
64
|
-
https://playertwo.
|
|
64
|
+
https://playertwo.plus/docs/sdk#call-errors). Off PlayerTwo and off localhost, `init()` rejects after 1.5 seconds
|
|
65
65
|
with code `not-on-player-two`; with `{ required: true }` the page says "Play this on PlayerTwo" and stops.
|
|
66
66
|
|
|
67
67
|
## What it gives your game
|
|
68
68
|
|
|
69
69
|
| Feature | Calls | Docs |
|
|
70
70
|
| --- | --- | --- |
|
|
71
|
-
| Who is playing | `p2.player`, `p2.game`, `p2.me()` | [call-me](https://playertwo.
|
|
72
|
-
| Trophies, XP and levels | `p2.trophies.list()`, `p2.trophies.unlock(key)` | [call-trophies](https://playertwo.
|
|
73
|
-
| Leaderboards | `p2.scores.submit(board, value)`, `p2.scores.list(board, { around, friends, limit })` | [call-scores](https://playertwo.
|
|
74
|
-
| Stats | `p2.stats.get()`, `.get(key)`, `.set(key, n)`, `.add(key, n?)` | [call-stats](https://playertwo.
|
|
75
|
-
| Cloud saves (8 slots, 1 MB each) | `p2.saves.list()`, `.get(slot)`, `.put(slot, data, { version })`, `.delete(slot)` | [call-saves](https://playertwo.
|
|
76
|
-
| Add-ons (sold on the game's page) | `p2.addons.list()`, `p2.addons.has(key)` | [addons](https://playertwo.
|
|
77
|
-
| In-game purchases | `p2.store.list()`, `.owned()`, `.buy(key)`, `.pay(chargeId)` | [purchases](https://playertwo.
|
|
78
|
-
| Donations to you | `p2.donate.available()`, `.open()`, `.button({ corner, parent })` | [donate](https://playertwo.
|
|
79
|
-
| Presence | `p2.presence.set(line, { join })` | [call-presence](https://playertwo.
|
|
80
|
-
| Identity and invites | `p2.identity()`, `p2.invite(params)`, `p2.params` | [call-identity](https://playertwo.
|
|
81
|
-
| Loading and play events | `p2.loading.done()`, `p2.gameplay.start()`, `.stop()` | [call-gameplay](https://playertwo.
|
|
82
|
-
| Your game's own events, in your studio's analytics | `p2.track(name, data)` | [call-track](https://playertwo.
|
|
83
|
-
| Its errors, caught by themselves | `p2.errors.report(error, where)`, `p2.errors.off()` | [call-crashes](https://playertwo.
|
|
84
|
-
| Feeds: outside data PlayerTwo fetches for your game | `p2.feeds.get(name)` | [feeds](https://playertwo.
|
|
85
|
-
| The overlay, and closing | `p2.on("overlay", fn)`, `p2.on("flush", fn)` | [call-overlay](https://playertwo.
|
|
86
|
-
| On air in the Plaza | `p2.onAir` | [call-air](https://playertwo.
|
|
87
|
-
| Test mode and demos | `p2.test`, `p2.demo` | [test](https://playertwo.
|
|
88
|
-
| The player's avatar, 2D and 3D | `p2.avatar()`, `p2.items.list()` | [travel#avatar](https://playertwo.
|
|
89
|
-
| Travel with the party | `p2.travel.to(slug, { params, place })`, `.home()`, `.links()` | [travel#travel](https://playertwo.
|
|
71
|
+
| Who is playing | `p2.player`, `p2.game`, `p2.me()` | [call-me](https://playertwo.plus/docs/sdk#call-me) |
|
|
72
|
+
| Trophies, XP and levels | `p2.trophies.list()`, `p2.trophies.unlock(key)` | [call-trophies](https://playertwo.plus/docs/sdk#call-trophies) |
|
|
73
|
+
| Leaderboards | `p2.scores.submit(board, value)`, `p2.scores.list(board, { around, friends, limit })` | [call-scores](https://playertwo.plus/docs/sdk#call-scores) |
|
|
74
|
+
| Stats | `p2.stats.get()`, `.get(key)`, `.set(key, n)`, `.add(key, n?)` | [call-stats](https://playertwo.plus/docs/sdk#call-stats) |
|
|
75
|
+
| Cloud saves (8 slots, 1 MB each) | `p2.saves.list()`, `.get(slot)`, `.put(slot, data, { version })`, `.delete(slot)` | [call-saves](https://playertwo.plus/docs/sdk#call-saves) |
|
|
76
|
+
| Add-ons (sold on the game's page) | `p2.addons.list()`, `p2.addons.has(key)` | [addons](https://playertwo.plus/docs/sdk#addons) |
|
|
77
|
+
| In-game purchases | `p2.store.list()`, `.owned()`, `.buy(key)`, `.pay(chargeId)` | [purchases](https://playertwo.plus/docs/sdk#purchases) |
|
|
78
|
+
| Donations to you | `p2.donate.available()`, `.open()`, `.button({ corner, parent })` | [donate](https://playertwo.plus/docs/sdk#donate) |
|
|
79
|
+
| Presence | `p2.presence.set(line, { join })` | [call-presence](https://playertwo.plus/docs/sdk#call-presence) |
|
|
80
|
+
| Identity and invites | `p2.identity()`, `p2.invite(params)`, `p2.params` | [call-identity](https://playertwo.plus/docs/sdk#call-identity) |
|
|
81
|
+
| Loading and play events | `p2.loading.done()`, `p2.gameplay.start()`, `.stop()` | [call-gameplay](https://playertwo.plus/docs/sdk#call-gameplay) |
|
|
82
|
+
| Your game's own events, in your studio's analytics | `p2.track(name, data)` | [call-track](https://playertwo.plus/docs/sdk#call-track) |
|
|
83
|
+
| Its errors, caught by themselves | `p2.errors.report(error, where)`, `p2.errors.off()` | [call-crashes](https://playertwo.plus/docs/sdk#call-crashes) |
|
|
84
|
+
| Feeds: outside data PlayerTwo fetches for your game | `p2.feeds.get(name)` | [feeds](https://playertwo.plus/docs/sdk#feeds) |
|
|
85
|
+
| The overlay, and closing | `p2.on("overlay", fn)`, `p2.on("flush", fn)` | [call-overlay](https://playertwo.plus/docs/sdk#call-overlay) |
|
|
86
|
+
| On air in the Plaza | `p2.onAir` | [call-air](https://playertwo.plus/docs/sdk#call-air) |
|
|
87
|
+
| Test mode and demos | `p2.test`, `p2.demo` | [test](https://playertwo.plus/docs/sdk#test) |
|
|
88
|
+
| The player's avatar, 2D and 3D | `p2.avatar()`, `p2.items.list()` | [travel#avatar](https://playertwo.plus/docs/sdk/travel#avatar) |
|
|
89
|
+
| Travel with the party | `p2.travel.to(slug, { params, place })`, `.home()`, `.links()` | [travel#travel](https://playertwo.plus/docs/sdk/travel#travel) |
|
|
90
90
|
|
|
91
91
|
Multiplayer, through `p2.rooms`:
|
|
92
92
|
|
|
93
93
|
| Feature | Calls | Docs |
|
|
94
94
|
| --- | --- | --- |
|
|
95
|
-
| Matches, private codes, parties | `p2.rooms.join({ mode, size, teams, skill, together, code, room })`, `.create()`, `.party()` | [rooms-join](https://playertwo.
|
|
96
|
-
| Messages and shared state | `room.send(type, data, { to, fast })`, `room.on("message:<type>")`, `room.set`, `room.get`, `room.state` | [rooms-talk](https://playertwo.
|
|
97
|
-
| Smooth movement | `room.sync(object, options)` | [rooms-sync](https://playertwo.
|
|
98
|
-
| Ping, stats, the room's clock | `room.ping()`, `room.stats()`, `room.now()` | [rooms-fast](https://playertwo.
|
|
99
|
-
| Your server code (`room.js`) | see below | [rooms-scripted](https://playertwo.
|
|
100
|
-
| Input-run rooms (client prediction, corrected by the server's state) | `room.inputs({ state, input, step })` | [rooms-inputs](https://playertwo.
|
|
101
|
-
| Corrections and lag-compensated hits | `onSync`, `room.correct`, `room.past` (room.js); `sync.seen(id)` | [rooms-corrections](https://playertwo.
|
|
102
|
-
| Server-moved objects | `room.objects()` (page), `room.objects.set` (room.js) | [rooms-objects](https://playertwo.
|
|
103
|
-
| Physics engines in WebAssembly | a `room/` folder | [rooms-engines](https://playertwo.
|
|
104
|
-
| Outside data, checked (a feed's signed items, relayed by a page) | `checkFeedItem(key, item, sig)` (room.js) | [rooms-feeds](https://playertwo.
|
|
105
|
-
| Teams and party matches | `{ teams, together }`, `room.team(id, n)` | [rooms-teams](https://playertwo.
|
|
106
|
-
| Matching by skill (Elo by mode) | `{ skill: true }`, `room.result(places)` | [rooms-matching](https://playertwo.
|
|
107
|
-
| Ranked boards and server-given trophies | `room.score`, `room.trophy` (room.js) | [rooms-ranked](https://playertwo.
|
|
108
|
-
| Watching and replays | `p2.rooms.live()`, `.watch({ room })`, `.replays()`, `.replay(id)`, `room.record()` | [rooms-watch](https://playertwo.
|
|
109
|
-
| Worlds of up to 256 an area | `p2.rooms.world(name, { area })` | [rooms-worlds](https://playertwo.
|
|
110
|
-
| Voice chat (24 a room) | `room.voice.join()`, `.leave()`, `.mute()`, `.volume(id, v)`, `.speaking(id)` | [rooms-voice](https://playertwo.
|
|
111
|
-
| A bad connection, on purpose | `p2.rooms.simulate({ lag, jitter, loss })` or `?p2-net=150,30,0.02` | [rooms-simulate](https://playertwo.
|
|
95
|
+
| Matches, private codes, parties | `p2.rooms.join({ mode, size, teams, skill, together, code, room })`, `.create()`, `.party()` | [rooms-join](https://playertwo.plus/docs/sdk#rooms-join) |
|
|
96
|
+
| Messages and shared state | `room.send(type, data, { to, fast })`, `room.on("message:<type>")`, `room.set`, `room.get`, `room.state` | [rooms-talk](https://playertwo.plus/docs/sdk#rooms-talk) |
|
|
97
|
+
| Smooth movement | `room.sync(object, options)` | [rooms-sync](https://playertwo.plus/docs/sdk#rooms-sync) |
|
|
98
|
+
| Ping, stats, the room's clock | `room.ping()`, `room.stats()`, `room.now()` | [rooms-fast](https://playertwo.plus/docs/sdk#rooms-fast) |
|
|
99
|
+
| Your server code (`room.js`) | see below | [rooms-scripted](https://playertwo.plus/docs/sdk#rooms-scripted) |
|
|
100
|
+
| Input-run rooms (client prediction, corrected by the server's state) | `room.inputs({ state, input, step })` | [rooms-inputs](https://playertwo.plus/docs/sdk#rooms-inputs) |
|
|
101
|
+
| Corrections and lag-compensated hits | `onSync`, `room.correct`, `room.past` (room.js); `sync.seen(id)` | [rooms-corrections](https://playertwo.plus/docs/sdk#rooms-corrections) |
|
|
102
|
+
| Server-moved objects | `room.objects()` (page), `room.objects.set` (room.js) | [rooms-objects](https://playertwo.plus/docs/sdk#rooms-objects) |
|
|
103
|
+
| Physics engines in WebAssembly | a `room/` folder | [rooms-engines](https://playertwo.plus/docs/sdk#rooms-engines) |
|
|
104
|
+
| Outside data, checked (a feed's signed items, relayed by a page) | `checkFeedItem(key, item, sig)` (room.js) | [rooms-feeds](https://playertwo.plus/docs/sdk#rooms-feeds) |
|
|
105
|
+
| Teams and party matches | `{ teams, together }`, `room.team(id, n)` | [rooms-teams](https://playertwo.plus/docs/sdk#rooms-teams) |
|
|
106
|
+
| Matching by skill (Elo by mode) | `{ skill: true }`, `room.result(places)` | [rooms-matching](https://playertwo.plus/docs/sdk#rooms-matching) |
|
|
107
|
+
| Ranked boards and server-given trophies | `room.score`, `room.trophy` (room.js) | [rooms-ranked](https://playertwo.plus/docs/sdk#rooms-ranked) |
|
|
108
|
+
| Watching and replays | `p2.rooms.live()`, `.watch({ room })`, `.replays()`, `.replay(id)`, `room.record()` | [rooms-watch](https://playertwo.plus/docs/sdk#rooms-watch) |
|
|
109
|
+
| Worlds of up to 256 an area | `p2.rooms.world(name, { area })` | [rooms-worlds](https://playertwo.plus/docs/sdk#rooms-worlds) |
|
|
110
|
+
| Voice chat (24 a room) | `room.voice.join()`, `.leave()`, `.mute()`, `.volume(id, v)`, `.speaking(id)` | [rooms-voice](https://playertwo.plus/docs/sdk#rooms-voice) |
|
|
111
|
+
| A bad connection, on purpose | `p2.rooms.simulate({ lag, jitter, loss })` or `?p2-net=150,30,0.02` | [rooms-simulate](https://playertwo.plus/docs/sdk#rooms-simulate) |
|
|
112
112
|
|
|
113
113
|
Rooms are 1 to 64 players (256 in an area of a world) and are for games hosted on PlayerTwo (a build you push, or
|
|
114
114
|
your own site served through PlayerTwo). A release never mixes versions in a room. All limits:
|
|
115
|
-
https://playertwo.
|
|
115
|
+
https://playertwo.plus/docs/sdk#rooms-limits.
|
|
116
116
|
|
|
117
117
|
## A room's server: `playertwo-sdk/room`
|
|
118
118
|
|
|
@@ -174,17 +174,17 @@ export function onMessage(room, player, type, data) {
|
|
|
174
174
|
|
|
175
175
|
A feed is public (anyone can read `GET /api/v1/games/<slug>/feeds/<name>`); its secret, put into a header's
|
|
176
176
|
`{{secret}}` as it is fetched, never leaves PlayerTwo. A game nobody opened in the last 24 hours has its feeds left
|
|
177
|
-
alone until someone does. Every rule: https://playertwo.
|
|
177
|
+
alone until someone does. Every rule: https://playertwo.plus/docs/sdk#feeds-setup.
|
|
178
178
|
|
|
179
179
|
## Building without PlayerTwo
|
|
180
180
|
|
|
181
181
|
On localhost, a stand-in answers every call from memory, and two tabs are two players. If your dev server serves
|
|
182
182
|
`/room.js`, the first tab runs it as the room's server. Give the stand-in your trophies, add-ons, products and params
|
|
183
183
|
with `init({ local: { ... } })` (and what `p2.feeds.get` answers, `local.feeds`); `local: true` (or `{ force: true }`) uses it wherever the game runs. There, `p2.track` and errors are said in the console. Voice needs a
|
|
184
|
-
room on PlayerTwo. Docs: https://playertwo.
|
|
184
|
+
room on PlayerTwo. Docs: https://playertwo.plus/docs/sdk#start-local.
|
|
185
185
|
|
|
186
186
|
On PlayerTwo you, your team and your playtesters play in test mode (`p2.test` is true): every call works, nothing is
|
|
187
|
-
paid, and what you earn is kept apart. Docs: https://playertwo.
|
|
187
|
+
paid, and what you earn is kept apart. Docs: https://playertwo.plus/docs/sdk#test.
|
|
188
188
|
|
|
189
189
|
Using the script tag and only want the types of the global `PlayerTwo`? Add `"types": ["playertwo-sdk"]` to your
|
|
190
190
|
`tsconfig.json`, or `/// <reference types="playertwo-sdk" />` at the top of a file.
|
|
@@ -196,8 +196,8 @@ makes at its own prices with your game key (`p2.store.pay(chargeId)`). PlayerTwo
|
|
|
196
196
|
and the payment from their PlayerTwo balance (USDC on Base). You get 80% of every in-game purchase, PlayerTwo keeps
|
|
197
197
|
20% (less your backers' share if your game raised with a share of its sales). Add-ons sold on the game's page are split
|
|
198
198
|
as its sales are: PlayerTwo keeps 20%. Every purchase gives your game a signed receipt (a JWT typed `p2-buy`, RS256,
|
|
199
|
-
keys at https://playertwo.
|
|
200
|
-
https://playertwo.
|
|
199
|
+
keys at https://playertwo.plus/.well-known/p2-keys.json) and your studio's webhooks a `purchase` event. Docs:
|
|
200
|
+
https://playertwo.plus/docs/sdk#purchases.
|
|
201
201
|
|
|
202
202
|
## Donations
|
|
203
203
|
|
|
@@ -207,54 +207,54 @@ or inside the game. Inside the game, your own button calls `p2.donate.open()` to
|
|
|
207
207
|
`p2.donate.button()` puts PlayerTwo's pixel-heart "Support the dev" button in a corner (or inside an element of yours);
|
|
208
208
|
`p2.donate.available()` says whether donations are on inside the game. The entire donation, minus the transaction fees,
|
|
209
209
|
goes to your studio: PlayerTwo takes no cut. A donation buys nothing in the game, and the game never learns who gave
|
|
210
|
-
or how much, so it never belongs in your shop. Docs: https://playertwo.
|
|
210
|
+
or how much, so it never belongs in your shop. Docs: https://playertwo.plus/docs/sdk#donate.
|
|
211
211
|
|
|
212
212
|
## Your game's own server
|
|
213
213
|
|
|
214
214
|
A game key (`p2g_...`, made in your studio) lets your server check a session or a signed identity from
|
|
215
215
|
`p2.identity()`, give server-only trophies, post to trusted leaderboards, read add-ons, make and check charges, use up
|
|
216
|
-
consumables and report matches, under `https://playertwo.
|
|
217
|
-
https://playertwo.
|
|
216
|
+
consumables and report matches, under `https://playertwo.plus/api/v1/sdk/server/...`. Docs:
|
|
217
|
+
https://playertwo.plus/docs/sdk#server and https://playertwo.plus/docs/sdk/connect (a game played on its own site).
|
|
218
218
|
|
|
219
219
|
## Putting it on PlayerTwo
|
|
220
220
|
|
|
221
221
|
A whole game to start from: `npm create playertwo-game@latest my-game` (a small multiplayer Three.js game with rooms
|
|
222
222
|
and `room.js`, see [create-playertwo-game](https://www.npmjs.com/package/create-playertwo-game)).
|
|
223
223
|
|
|
224
|
-
1. Submit the game at https://playertwo.
|
|
224
|
+
1. Submit the game at https://playertwo.plus/submit (that gives it its address, `your-game`).
|
|
225
225
|
2. Make an agent key in your studio, under Agents.
|
|
226
226
|
3. Push the build:
|
|
227
227
|
|
|
228
228
|
```
|
|
229
|
-
curl -fsSLO https://playertwo.
|
|
229
|
+
curl -fsSLO https://playertwo.plus/cli/p2.mjs
|
|
230
230
|
P2_AGENT_KEY=p2_agent_... node p2.mjs push dist --game your-game --version 1.0.0
|
|
231
231
|
```
|
|
232
232
|
|
|
233
233
|
It plays at `https://your-game.playertwo.cc/` in PlayerTwo's player, with no code changes. A pushed folder may be up to
|
|
234
|
-
5 GB and 20,000 files; only the files PlayerTwo doesn't have yet are sent. Docs: https://playertwo.
|
|
234
|
+
5 GB and 20,000 files; only the files PlayerTwo doesn't have yet are sent. Docs: https://playertwo.plus/docs/hosting.
|
|
235
235
|
|
|
236
236
|
## For AI agents: MCP and the agent API
|
|
237
237
|
|
|
238
|
-
PlayerTwo runs an MCP server (Streamable HTTP) at `https://playertwo.
|
|
238
|
+
PlayerTwo runs an MCP server (Streamable HTTP) at `https://playertwo.plus/api/mcp`:
|
|
239
239
|
|
|
240
240
|
```
|
|
241
|
-
claude mcp add --transport http player-two https://playertwo.
|
|
242
|
-
claude mcp add --transport http player-two https://playertwo.
|
|
241
|
+
claude mcp add --transport http player-two https://playertwo.plus/api/mcp
|
|
242
|
+
claude mcp add --transport http player-two https://playertwo.plus/api/mcp --header "Authorization: Bearer p2_agent_..."
|
|
243
243
|
```
|
|
244
244
|
|
|
245
245
|
The first line is enough for the public tools, which need no key: `get_submission_guide` and `check_game`, and
|
|
246
246
|
`search_games`, `list_games`, `get_game_facts`, `get_sdk_docs` and `where_to_publish`. Tools that change a game
|
|
247
247
|
(submit it, edit its page, upload media and web builds, define trophies, leaderboards and products, roll back builds,
|
|
248
|
-
post updates, read its rooms) need the player's agent key, made in their studio on playertwo.
|
|
248
|
+
post updates, read its rooms) need the player's agent key, made in their studio on playertwo.plus under Agents, or no
|
|
249
249
|
key at all in a client that signs in (Claude's and ChatGPT's connectors, Claude Code, Cursor): the first time it calls
|
|
250
|
-
one, the player is asked to sign in to PlayerTwo and allow it (OAuth 2.1 with PKCE). Its
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
- The agent API: `GET https://playertwo.
|
|
254
|
-
`POST https://playertwo.
|
|
255
|
-
- OpenAPI 3.1 spec: https://playertwo.
|
|
256
|
-
- For language models: https://playertwo.
|
|
257
|
-
- Docs: https://playertwo.
|
|
250
|
+
one, the player is asked to sign in to PlayerTwo and allow it (OAuth 2.1 with PKCE). Its server card is at
|
|
251
|
+
https://playertwo.plus/.well-known/mcp.json.
|
|
252
|
+
|
|
253
|
+
- The agent API: `GET https://playertwo.plus/api/v1/agent/guide` explains every field; submit with
|
|
254
|
+
`POST https://playertwo.plus/api/v1/agent/games` `{ "draft": { ... }, "publish": true }`.
|
|
255
|
+
- OpenAPI 3.1 spec: https://playertwo.plus/openapi.json
|
|
256
|
+
- For language models: https://playertwo.plus/llms.txt
|
|
257
|
+
- Docs: https://playertwo.plus/docs#agents
|
|
258
258
|
|
|
259
259
|
## License
|
|
260
260
|
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Types for PlayerTwo's game SDK, https://playertwo.
|
|
3
|
-
* keep these in step with its part 4, "the helpers the game uses", and part 4b, "rooms"). Docs: https://playertwo.
|
|
2
|
+
* Types for PlayerTwo's game SDK, https://playertwo.plus/sdk/v1.js (its source: public/sdk/v1.js in PlayerTwo's code;
|
|
3
|
+
* keep these in step with its part 4, "the helpers the game uses", and part 4b, "rooms"). Docs: https://playertwo.plus/docs/sdk
|
|
4
4
|
*
|
|
5
5
|
* import { init } from "playertwo-sdk"; // or the global PlayerTwo, from the script tag
|
|
6
6
|
* const p2 = await init();
|
|
@@ -762,7 +762,7 @@ export interface Door {
|
|
|
762
762
|
/** Travel to other games on PlayerTwo, with the player's party. In PlayerTwo's player on the web; elsewhere each
|
|
763
763
|
rejects with code "no-travel". */
|
|
764
764
|
export interface Travel {
|
|
765
|
-
/** To another game, by its address (playertwo.
|
|
765
|
+
/** To another game, by its address (playertwo.plus/game/<slug>): it is given p2.params (yours, then `from`, this
|
|
766
766
|
game's address, and `place`). Resolves as the player goes; this page is closed after. */
|
|
767
767
|
to(slug: string, options?: { params?: Record<string, string>; place?: string }): Promise<{ to: { slug: string; title: string }; params: Record<string, string> }>;
|
|
768
768
|
/** Back to the Plaza, where every game on PlayerTwo has its screen. */
|
|
@@ -900,13 +900,13 @@ export interface PlayerTwoGlobal {
|
|
|
900
900
|
}
|
|
901
901
|
|
|
902
902
|
declare global {
|
|
903
|
-
/** PlayerTwo's SDK, from https://playertwo.
|
|
903
|
+
/** PlayerTwo's SDK, from https://playertwo.plus/sdk/v1.js (on PlayerTwo, already in the page). */
|
|
904
904
|
var PlayerTwo: PlayerTwoGlobal;
|
|
905
905
|
}
|
|
906
906
|
|
|
907
907
|
/** Where the SDK is loaded from when the page doesn't have it. */
|
|
908
908
|
export const SDK_URL: string;
|
|
909
|
-
/** Where it is looked for, in turn: SDK_URL (playertwo.
|
|
909
|
+
/** Where it is looked for, in turn: SDK_URL (playertwo.plus). */
|
|
910
910
|
export const SDK_URLS: readonly string[];
|
|
911
911
|
|
|
912
912
|
/** window.PlayerTwo, loading the script from `src`, else from each of SDK_URLS in turn, if the page doesn't have it. */
|
package/index.mjs
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
// playertwo-sdk: PlayerTwo's game SDK for code that is bundled (Vite, webpack, esbuild). The SDK itself is one
|
|
2
|
-
// script, https://playertwo.
|
|
2
|
+
// script, https://playertwo.plus/sdk/v1.js, which PlayerTwo's games host puts in a hosted game's page; this uses that
|
|
3
3
|
// copy when the page has it, and otherwise loads the script and waits for it. Types: index.d.ts. Docs:
|
|
4
|
-
// https://playertwo.
|
|
4
|
+
// https://playertwo.plus/docs/sdk
|
|
5
5
|
//
|
|
6
6
|
// import { init } from "playertwo-sdk";
|
|
7
7
|
// const p2 = await init(); // the same as PlayerTwo.init(), with the same options
|
|
8
8
|
|
|
9
|
-
export const SDK_URL = "https://playertwo.
|
|
10
|
-
/** Where the script is looked for, in turn:
|
|
11
|
-
|
|
12
|
-
export const SDK_URLS = [SDK_URL, "https://playertwo.plus/sdk/v1.js"];
|
|
9
|
+
export const SDK_URL = "https://playertwo.plus/sdk/v1.js";
|
|
10
|
+
/** Where the script is looked for, in turn: PlayerTwo's address, playertwo.plus. */
|
|
11
|
+
export const SDK_URLS = [SDK_URL];
|
|
13
12
|
|
|
14
13
|
let loading = null;
|
|
15
14
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "playertwo-sdk",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "SDK for HTML5 and browser games on PlayerTwo (playertwo.
|
|
3
|
+
"version": "0.2.12",
|
|
4
|
+
"description": "SDK for HTML5 and browser games on PlayerTwo (playertwo.plus): trophies, leaderboards, stats, cloud saves, in-game purchases, donations to the developer, your own events and errors in your analytics, feeds of outside data, voice chat and multiplayer rooms with server-side room code.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"playertwo",
|
|
7
7
|
"player-two",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"typescript",
|
|
25
25
|
"threejs"
|
|
26
26
|
],
|
|
27
|
-
"homepage": "https://playertwo.
|
|
27
|
+
"homepage": "https://playertwo.plus/docs/sdk",
|
|
28
28
|
"bugs": {
|
|
29
29
|
"url": "https://github.com/TheDudeCommits/playertwo-sdk/issues"
|
|
30
30
|
},
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"directory": "packages/sdk"
|
|
35
35
|
},
|
|
36
36
|
"license": "MIT",
|
|
37
|
-
"author": "PlayerTwo <hello@playertwo.
|
|
37
|
+
"author": "PlayerTwo <hello@playertwo.plus>",
|
|
38
38
|
"type": "module",
|
|
39
39
|
"main": "./index.mjs",
|
|
40
40
|
"module": "./index.mjs",
|