@tesana/sdk 1.0.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/README.md +86 -0
- package/dist/tesana.esm.js +1441 -0
- package/dist/tesana.iife.js +1451 -0
- package/package.json +49 -0
- package/src/tesana.js +1441 -0
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# @tesana/sdk
|
|
2
|
+
|
|
3
|
+
Tesana's play-time SDK. It gives a web game a player identity, cloud saves that
|
|
4
|
+
follow that player to another device, leaderboards, achievements, and the
|
|
5
|
+
in-game coin shop — without the game talking to any of those services directly.
|
|
6
|
+
|
|
7
|
+
The SDK is what the global `window.Tesana` is. In a game published on Tesana the
|
|
8
|
+
platform injects it and hands over the player and the game's identity; the game
|
|
9
|
+
just calls it.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @tesana/sdk
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Use
|
|
18
|
+
|
|
19
|
+
An exported game boots from the global, because Tesana's own guidance forbids
|
|
20
|
+
importing a package into game code:
|
|
21
|
+
|
|
22
|
+
```html
|
|
23
|
+
<script src="https://unpkg.com/@tesana/sdk/dist/tesana.iife.js"></script>
|
|
24
|
+
<script type="module">
|
|
25
|
+
const tesana = await window.__TESANA_READY__;
|
|
26
|
+
const save = await tesana.db.get("save");
|
|
27
|
+
</script>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Bundled or module code can import it instead, which is the same client:
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
import Tesana from "@tesana/sdk";
|
|
34
|
+
|
|
35
|
+
const tesana = await Tesana.init();
|
|
36
|
+
await tesana.db.set("save", { level: 7 });
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`init()` accepts `{ gameId, endpoint, playerToken }`. With none of them it reads
|
|
40
|
+
`window.__TESANA__`, then asks the host page over `postMessage`, and finally
|
|
41
|
+
falls back to a guest identity — so a game still runs with no host, no network
|
|
42
|
+
and nobody signed in. Never gate the game itself behind a service call
|
|
43
|
+
succeeding.
|
|
44
|
+
|
|
45
|
+
### Surfaces
|
|
46
|
+
|
|
47
|
+
| | |
|
|
48
|
+
|---|---|
|
|
49
|
+
| `tesana.db` | Cloud saves — `get` / `set` / `list` / `collection` |
|
|
50
|
+
| `tesana.scores` | Leaderboards — `submit` / `top` / `me` / `best` |
|
|
51
|
+
| `tesana.achievements` | Badges — `list` / `unlocked` / `unlock` / `progress` |
|
|
52
|
+
| `tesana.shop` | In-game shop — `catalog` / `items` / `buy` / `entitlements` / `inventory` |
|
|
53
|
+
| `tesana.economy` | Coins — `balance` / `packs` / `topUp` / `signIn` |
|
|
54
|
+
| `tesana.multiplayer` | Open lobbies — `list` / `create` / `join` / `quickJoin` / `send` / `on` |
|
|
55
|
+
| `tesana.player` | Identity — `login({ tesanaUserId })` |
|
|
56
|
+
| `tesana.vanity` | The game's own address on tesana.ai |
|
|
57
|
+
| `tesana.ads` | Ads, when the host allows them |
|
|
58
|
+
|
|
59
|
+
Leaderboards and achievements are client-reported, so they are a ranking to show
|
|
60
|
+
off rather than a prize table; nothing here mints coins or grants entitlements.
|
|
61
|
+
A counted achievement is decided by the server, not the game.
|
|
62
|
+
|
|
63
|
+
### Offline behaviour
|
|
64
|
+
|
|
65
|
+
Every call resolves rather than throwing when there is no host, no endpoint or
|
|
66
|
+
no network. Saves read as empty, the shop reports `no_host`, and the game plays.
|
|
67
|
+
Real money is never the game's business — `topUp()` asks the host to run
|
|
68
|
+
checkout, and the price shown is read from the service.
|
|
69
|
+
|
|
70
|
+
## Building this package
|
|
71
|
+
|
|
72
|
+
The published artifact is generated, not hand-written:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npm run build:sdk # writes dist/tesana.iife.js and dist/tesana.esm.js
|
|
76
|
+
npm run version:sdk -- 1.2.0 # bumps VERSION and package.json together
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
`build.js` refuses to build if `VERSION` in `src/tesana.js` and `version` in
|
|
80
|
+
`package.json` disagree — the engine derives each game's pinned `/sdk/v<major>/`
|
|
81
|
+
URL from the first and npm resolves the second, so a mismatch would publish a
|
|
82
|
+
package whose declared version is not the SDK inside it.
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
Proprietary. Copyright Tesana. All rights reserved. Not for redistribution.
|