@indiegems/gem-web-sdk 16.1.0 → 16.3.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/CHANGELOG.md +26 -0
- package/README.md +2 -1
- package/dist/function.d.ts +27 -3
- package/dist/game.d.ts +77 -4
- package/dist/gem-web-sdk.conformance.js +3 -3
- package/dist/gem-web-sdk.esm.js +3 -3
- package/dist/gem-web-sdk.function.js +3 -3
- package/dist/gem-web-sdk.game.js +3 -3
- package/dist/gem-web-sdk.min.js +3 -3
- package/dist/gem-web-sdk.sdk.js +3 -3
- package/dist/gem-web-sdk.server.js +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/sdk.d.ts +79 -4
- package/dist/server-api.d.ts +3 -0
- package/dist/server.d.ts +3 -0
- package/docs/api/api-reference-function.md +169 -5
- package/docs/api/api-reference-game.md +594 -5
- package/docs/api/api-reference-server.md +1 -1
- package/docs/api/reference.json +761 -17
- package/docs/arcade-and-store.md +6 -0
- package/docs/brand-art.md +14 -3
- package/docs/branding.md +160 -0
- package/docs/changelog.md +26 -0
- package/docs/getting-started.md +1 -1
- package/docs/manifest.json +17 -12
- package/docs/saving-player-progress.md +171 -5
- package/docs/server-bundles.md +2 -2
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The browser surface — API reference
|
|
2
2
|
|
|
3
|
-
Generated from `@indiegems/gem-web-sdk/sdk` v16.
|
|
3
|
+
Generated from `@indiegems/gem-web-sdk/sdk` v16.3.0, the version of the package this file ships in. Every symbol below carries an explicit anchor, its `anchor` in `reference.json` beside this file.
|
|
4
4
|
|
|
5
5
|
`@indiegems/gem-web-sdk/sdk` is the one import a game writes, wherever its code runs. `@indiegems/gem-web-sdk/game` exports exactly the symbols on this page and nothing else, for a build that wants only this half.
|
|
6
6
|
|
|
@@ -2085,9 +2085,11 @@ readonly etag: string
|
|
|
2085
2085
|
|
|
2086
2086
|
This save's version, which changes whenever the save does.
|
|
2087
2087
|
|
|
2088
|
-
NOT something to pass back on a write —
|
|
2089
|
-
|
|
2090
|
-
|
|
2088
|
+
NOT something to pass back on a write — the SDK remembers the version of
|
|
2089
|
+
each slot you last loaded or wrote and sends it for you, so a write that
|
|
2090
|
+
would replace a save you never saw is refused as `save_conflict`. This is
|
|
2091
|
+
how a game holding a copy tells whether the stored save is still the one
|
|
2092
|
+
it has.
|
|
2091
2093
|
|
|
2092
2094
|
<a id="saverecord-metadata"></a>
|
|
2093
2095
|
|
|
@@ -2180,7 +2182,7 @@ has already agreed to the write. Re-read before assuming what is stored.
|
|
|
2180
2182
|
## GemSaveError.reason
|
|
2181
2183
|
|
|
2182
2184
|
```ts
|
|
2183
|
-
readonly reason: "upload_failed" | "download_failed" | "save_timeout" | "save_malformed"
|
|
2185
|
+
readonly reason: "upload_failed" | "download_failed" | "save_timeout" | "save_malformed" | "save_conflict" | "load_failed"
|
|
2184
2186
|
```
|
|
2185
2187
|
|
|
2186
2188
|
Which part failed.
|
|
@@ -2190,15 +2192,31 @@ Which part failed.
|
|
|
2190
2192
|
- `save_timeout` — a hop did not finish in the time the call allows.
|
|
2191
2193
|
- `save_malformed` — the answer, or the stored payload, was not what it
|
|
2192
2194
|
claims to be.
|
|
2195
|
+
- `save_conflict` — a write was refused because the stored save changed
|
|
2196
|
+
since this game last loaded or wrote it: another device or tab saved
|
|
2197
|
+
in between. Nothing was written.
|
|
2198
|
+
- `load_failed` — a write was refused before anything was sent, because
|
|
2199
|
+
the last load of this slot failed, so what the write would replace is
|
|
2200
|
+
unknown — it could be the player's real progress.
|
|
2193
2201
|
|
|
2194
2202
|
`save_timeout`, and a one-off `upload_failed` or `download_failed`, are
|
|
2195
2203
|
worth one retry. `save_malformed` is not: the same bytes will fail the
|
|
2196
2204
|
same way.
|
|
2197
2205
|
|
|
2206
|
+
Neither is `save_conflict` or `load_failed`: resending the same write
|
|
2207
|
+
fails the same way. Load the slot again and decide what to write from
|
|
2208
|
+
what is stored — merge, or ask the player. Pass `overwrite: true` only to
|
|
2209
|
+
replace whatever is stored on purpose.
|
|
2210
|
+
|
|
2198
2211
|
An `upload_failed` that repeats on EVERY save, for every player, is not
|
|
2199
2212
|
transient either — it is a platform-side misconfiguration, and retrying
|
|
2200
2213
|
is a loop rather than a recovery. See the saves guide.
|
|
2201
2214
|
|
|
2215
|
+
A RATE LIMIT IS NOT ONE OF THESE. Refused for the rate on any leg — the
|
|
2216
|
+
platform, the upload, the download — a save or load rejects as
|
|
2217
|
+
`GemApiError` reason `rate_limited`, with `retryAfterSeconds` when a wait
|
|
2218
|
+
was named.
|
|
2219
|
+
|
|
2202
2220
|
<a id="putsaveoptions"></a>
|
|
2203
2221
|
|
|
2204
2222
|
## PutSaveOptions
|
|
@@ -2239,6 +2257,10 @@ Cancel the write.
|
|
|
2239
2257
|
A save is several hops, so a cancelled write can land after the platform
|
|
2240
2258
|
has already agreed to it. Re-read rather than assuming nothing was stored.
|
|
2241
2259
|
|
|
2260
|
+
A write that replaced earlier ones still waiting on its slot carries them,
|
|
2261
|
+
so cancelling it before it goes out cancels them too. Cancelling a write
|
|
2262
|
+
that a later one replaced rejects only this call; the later write goes on.
|
|
2263
|
+
|
|
2242
2264
|
<a id="putsaveoptions-timeoutms"></a>
|
|
2243
2265
|
|
|
2244
2266
|
## PutSaveOptions.timeoutMs
|
|
@@ -2261,6 +2283,68 @@ to do something about it.
|
|
|
2261
2283
|
It does not make a save faster. Three round trips plus the payload is what
|
|
2262
2284
|
a save costs; this only decides when to stop waiting.
|
|
2263
2285
|
|
|
2286
|
+
It counts from the call, so a write waiting for the one before it on the
|
|
2287
|
+
same slot spends it waiting. A rate limit whose wait it will not cover
|
|
2288
|
+
rejects at once as `GemApiError` reason `rate_limited`, not as
|
|
2289
|
+
`save_timeout`.
|
|
2290
|
+
|
|
2291
|
+
It stays this call's when a later write replaces this one: running out
|
|
2292
|
+
rejects only this call, and the later write goes on. The write that is
|
|
2293
|
+
sent runs on the newest call's `timeoutMs`, and running out of that rejects
|
|
2294
|
+
every call it carries.
|
|
2295
|
+
|
|
2296
|
+
<a id="putsaveoptions-teardown"></a>
|
|
2297
|
+
|
|
2298
|
+
## PutSaveOptions.teardown
|
|
2299
|
+
|
|
2300
|
+
```ts
|
|
2301
|
+
readonly teardown?: boolean
|
|
2302
|
+
```
|
|
2303
|
+
|
|
2304
|
+
This is the last write before the page goes away: send it without waiting
|
|
2305
|
+
for the spacing between writes to one slot.
|
|
2306
|
+
|
|
2307
|
+
Writes to one slot go out a few seconds apart, and a write made sooner
|
|
2308
|
+
waits its turn. Set this on the write you make from
|
|
2309
|
+
[GemTerminationNotice](#gemterminationnotice) or `pagehide`, with a `timeoutMs` inside the
|
|
2310
|
+
time you have.
|
|
2311
|
+
|
|
2312
|
+
IT STILL WAITS FOR A WRITE ALREADY IN FLIGHT to the same slot, and it
|
|
2313
|
+
still honours a rate-limit hold: when the hold outlasts `timeoutMs` the
|
|
2314
|
+
write rejects at once as `rate_limited`, and nothing is sent. Not for
|
|
2315
|
+
ordinary saves — the spacing is what keeps a save loop from spending the
|
|
2316
|
+
rate limit.
|
|
2317
|
+
|
|
2318
|
+
A later write that replaces this one while it waits keeps it: the write
|
|
2319
|
+
that goes out skips the spacing when any call it carries set `teardown`.
|
|
2320
|
+
Not across a player change: a call replaced after the signed-in player
|
|
2321
|
+
changed is refused as `save_conflict`, and its `teardown` goes with it.
|
|
2322
|
+
|
|
2323
|
+
<a id="putsaveoptions-overwrite"></a>
|
|
2324
|
+
|
|
2325
|
+
## PutSaveOptions.overwrite
|
|
2326
|
+
|
|
2327
|
+
```ts
|
|
2328
|
+
readonly overwrite?: boolean
|
|
2329
|
+
```
|
|
2330
|
+
|
|
2331
|
+
Write even if it replaces a save this game has not loaded.
|
|
2332
|
+
|
|
2333
|
+
Without it, a write to a slot whose last load FAILED is refused as
|
|
2334
|
+
`load_failed`, and a write is refused as `save_conflict` when the stored
|
|
2335
|
+
save changed since you last loaded or wrote it. Both refusals protect the
|
|
2336
|
+
player's real progress from a game that started from defaults.
|
|
2337
|
+
|
|
2338
|
+
Set it only when replacing whatever is stored is what you mean — a "new
|
|
2339
|
+
game" the player confirmed, or the player choosing this device's progress
|
|
2340
|
+
after a conflict. Never set it to get past a failed load.
|
|
2341
|
+
|
|
2342
|
+
A later write that replaces this one while it waits keeps it: the write
|
|
2343
|
+
that goes out overwrites when any call it carries set `overwrite`. A call
|
|
2344
|
+
that gives up first (its `signal` or `timeoutMs`) takes it back, and so
|
|
2345
|
+
does one replaced after the signed-in player changed: it is refused as
|
|
2346
|
+
`save_conflict`, so one player's "new game" never overwrites the next's.
|
|
2347
|
+
|
|
2264
2348
|
<a id="putbytesoptions"></a>
|
|
2265
2349
|
|
|
2266
2350
|
## PutBytesOptions
|
|
@@ -2304,6 +2388,10 @@ Cancel the write.
|
|
|
2304
2388
|
A save is several hops, so a cancelled write can land after the platform
|
|
2305
2389
|
has already agreed to it. Re-read rather than assuming nothing was stored.
|
|
2306
2390
|
|
|
2391
|
+
A write that replaced earlier ones still waiting on its slot carries them,
|
|
2392
|
+
so cancelling it before it goes out cancels them too. Cancelling a write
|
|
2393
|
+
that a later one replaced rejects only this call; the later write goes on.
|
|
2394
|
+
|
|
2307
2395
|
<a id="putbytesoptions-timeoutms"></a>
|
|
2308
2396
|
|
|
2309
2397
|
## PutBytesOptions.timeoutMs
|
|
@@ -2326,6 +2414,68 @@ to do something about it.
|
|
|
2326
2414
|
It does not make a save faster. Three round trips plus the payload is what
|
|
2327
2415
|
a save costs; this only decides when to stop waiting.
|
|
2328
2416
|
|
|
2417
|
+
It counts from the call, so a write waiting for the one before it on the
|
|
2418
|
+
same slot spends it waiting. A rate limit whose wait it will not cover
|
|
2419
|
+
rejects at once as `GemApiError` reason `rate_limited`, not as
|
|
2420
|
+
`save_timeout`.
|
|
2421
|
+
|
|
2422
|
+
It stays this call's when a later write replaces this one: running out
|
|
2423
|
+
rejects only this call, and the later write goes on. The write that is
|
|
2424
|
+
sent runs on the newest call's `timeoutMs`, and running out of that rejects
|
|
2425
|
+
every call it carries.
|
|
2426
|
+
|
|
2427
|
+
<a id="putbytesoptions-teardown"></a>
|
|
2428
|
+
|
|
2429
|
+
## PutBytesOptions.teardown
|
|
2430
|
+
|
|
2431
|
+
```ts
|
|
2432
|
+
readonly teardown?: boolean
|
|
2433
|
+
```
|
|
2434
|
+
|
|
2435
|
+
This is the last write before the page goes away: send it without waiting
|
|
2436
|
+
for the spacing between writes to one slot.
|
|
2437
|
+
|
|
2438
|
+
Writes to one slot go out a few seconds apart, and a write made sooner
|
|
2439
|
+
waits its turn. Set this on the write you make from
|
|
2440
|
+
[GemTerminationNotice](#gemterminationnotice) or `pagehide`, with a `timeoutMs` inside the
|
|
2441
|
+
time you have.
|
|
2442
|
+
|
|
2443
|
+
IT STILL WAITS FOR A WRITE ALREADY IN FLIGHT to the same slot, and it
|
|
2444
|
+
still honours a rate-limit hold: when the hold outlasts `timeoutMs` the
|
|
2445
|
+
write rejects at once as `rate_limited`, and nothing is sent. Not for
|
|
2446
|
+
ordinary saves — the spacing is what keeps a save loop from spending the
|
|
2447
|
+
rate limit.
|
|
2448
|
+
|
|
2449
|
+
A later write that replaces this one while it waits keeps it: the write
|
|
2450
|
+
that goes out skips the spacing when any call it carries set `teardown`.
|
|
2451
|
+
Not across a player change: a call replaced after the signed-in player
|
|
2452
|
+
changed is refused as `save_conflict`, and its `teardown` goes with it.
|
|
2453
|
+
|
|
2454
|
+
<a id="putbytesoptions-overwrite"></a>
|
|
2455
|
+
|
|
2456
|
+
## PutBytesOptions.overwrite
|
|
2457
|
+
|
|
2458
|
+
```ts
|
|
2459
|
+
readonly overwrite?: boolean
|
|
2460
|
+
```
|
|
2461
|
+
|
|
2462
|
+
Write even if it replaces a save this game has not loaded.
|
|
2463
|
+
|
|
2464
|
+
Without it, a write to a slot whose last load FAILED is refused as
|
|
2465
|
+
`load_failed`, and a write is refused as `save_conflict` when the stored
|
|
2466
|
+
save changed since you last loaded or wrote it. Both refusals protect the
|
|
2467
|
+
player's real progress from a game that started from defaults.
|
|
2468
|
+
|
|
2469
|
+
Set it only when replacing whatever is stored is what you mean — a "new
|
|
2470
|
+
game" the player confirmed, or the player choosing this device's progress
|
|
2471
|
+
after a conflict. Never set it to get past a failed load.
|
|
2472
|
+
|
|
2473
|
+
A later write that replaces this one while it waits keeps it: the write
|
|
2474
|
+
that goes out overwrites when any call it carries set `overwrite`. A call
|
|
2475
|
+
that gives up first (its `signal` or `timeoutMs`) takes it back, and so
|
|
2476
|
+
does one replaced after the signed-in player changed: it is refused as
|
|
2477
|
+
`save_conflict`, so one player's "new game" never overwrites the next's.
|
|
2478
|
+
|
|
2329
2479
|
<a id="putbytesoptions-contenttype"></a>
|
|
2330
2480
|
|
|
2331
2481
|
## PutBytesOptions.contentType
|
|
@@ -2368,6 +2518,20 @@ await gem.me.saves.put('slot1', { level: 7, checkpoint: 'bridge' });
|
|
|
2368
2518
|
const state = await gem.me.saves.get('slot1');
|
|
2369
2519
|
```
|
|
2370
2520
|
|
|
2521
|
+
LOAD BEFORE YOU SAVE. Each write carries the version of the slot your last
|
|
2522
|
+
load or write found, so a write that would replace a save this game has not
|
|
2523
|
+
seen — another device's, or the player's real progress after a load that
|
|
2524
|
+
failed — is refused as `save_conflict` or `load_failed` rather than stored.
|
|
2525
|
+
After a failed load, play on without saving and load again later; pass
|
|
2526
|
+
`overwrite: true` only when the player chose to start over.
|
|
2527
|
+
|
|
2528
|
+
ONE WRITE PER SLOT AT A TIME. A write made while another to the same slot is
|
|
2529
|
+
in flight waits for it, and a later one replaces it: the newest value is the
|
|
2530
|
+
one sent, and every caller it replaced resolves with it, keeping its own
|
|
2531
|
+
`signal`, `timeoutMs`, `teardown` and `overwrite`. Writes to one slot
|
|
2532
|
+
go out a few seconds apart (`teardown: true` skips that), and after a
|
|
2533
|
+
`rate_limited` answer none goes out until the wait it named is over.
|
|
2534
|
+
|
|
2371
2535
|
WHAT IS DELIBERATELY NOT HERE: no autosave timer, no save format, no
|
|
2372
2536
|
migration. Those are your game's, and a platform that guessed at them would
|
|
2373
2537
|
guess wrong.
|
|
@@ -5423,6 +5587,406 @@ only if you are instrumenting something that runs before the SDK exists.
|
|
|
5423
5587
|
| --- | --- |
|
|
5424
5588
|
| `options` | `BootTimelineOptions` |
|
|
5425
5589
|
|
|
5590
|
+
<a id="brandingtheme"></a>
|
|
5591
|
+
|
|
5592
|
+
## BrandingTheme
|
|
5593
|
+
|
|
5594
|
+
```ts
|
|
5595
|
+
type BrandingTheme = "light" | "dark"
|
|
5596
|
+
```
|
|
5597
|
+
|
|
5598
|
+
A theme a variant is drawn for.
|
|
5599
|
+
|
|
5600
|
+
<a id="brandingvariant"></a>
|
|
5601
|
+
|
|
5602
|
+
## BrandingVariant
|
|
5603
|
+
|
|
5604
|
+
```ts
|
|
5605
|
+
interface BrandingVariant
|
|
5606
|
+
```
|
|
5607
|
+
|
|
5608
|
+
One file of a [BrandingAsset](#brandingasset): a render at one size and density, a
|
|
5609
|
+
scalable image, or the one file of a sound or a font.
|
|
5610
|
+
|
|
5611
|
+
<a id="brandingvariant-url"></a>
|
|
5612
|
+
|
|
5613
|
+
## BrandingVariant.url
|
|
5614
|
+
|
|
5615
|
+
```ts
|
|
5616
|
+
readonly url: string
|
|
5617
|
+
```
|
|
5618
|
+
|
|
5619
|
+
The file's URL, absolute and on the platform's own host. Content-hashed,
|
|
5620
|
+
so a re-render is a new URL: look it up each session rather than storing
|
|
5621
|
+
one in a save or your build.
|
|
5622
|
+
|
|
5623
|
+
<a id="brandingvariant-type"></a>
|
|
5624
|
+
|
|
5625
|
+
## BrandingVariant.type
|
|
5626
|
+
|
|
5627
|
+
```ts
|
|
5628
|
+
readonly type: string
|
|
5629
|
+
```
|
|
5630
|
+
|
|
5631
|
+
Its MIME type, such as `image/png` or `image/svg+xml`.
|
|
5632
|
+
|
|
5633
|
+
<a id="brandingvariant-bytes"></a>
|
|
5634
|
+
|
|
5635
|
+
## BrandingVariant.bytes
|
|
5636
|
+
|
|
5637
|
+
```ts
|
|
5638
|
+
readonly bytes: number
|
|
5639
|
+
```
|
|
5640
|
+
|
|
5641
|
+
Its size in bytes.
|
|
5642
|
+
|
|
5643
|
+
<a id="brandingvariant-width"></a>
|
|
5644
|
+
|
|
5645
|
+
## BrandingVariant.width
|
|
5646
|
+
|
|
5647
|
+
```ts
|
|
5648
|
+
readonly width?: number
|
|
5649
|
+
```
|
|
5650
|
+
|
|
5651
|
+
An image's width in pixels (an SVG's in its viewBox units).
|
|
5652
|
+
|
|
5653
|
+
<a id="brandingvariant-height"></a>
|
|
5654
|
+
|
|
5655
|
+
## BrandingVariant.height
|
|
5656
|
+
|
|
5657
|
+
```ts
|
|
5658
|
+
readonly height?: number
|
|
5659
|
+
```
|
|
5660
|
+
|
|
5661
|
+
An image's height in pixels (an SVG's in its viewBox units).
|
|
5662
|
+
|
|
5663
|
+
<a id="brandingvariant-size"></a>
|
|
5664
|
+
|
|
5665
|
+
## BrandingVariant.size
|
|
5666
|
+
|
|
5667
|
+
```ts
|
|
5668
|
+
readonly size?: number
|
|
5669
|
+
```
|
|
5670
|
+
|
|
5671
|
+
The CSS px box this render was made for, with [BrandingVariant.density](#brandingvariant-density).
|
|
5672
|
+
Absent on a render meant for any box up to its width.
|
|
5673
|
+
|
|
5674
|
+
<a id="brandingvariant-density"></a>
|
|
5675
|
+
|
|
5676
|
+
## BrandingVariant.density
|
|
5677
|
+
|
|
5678
|
+
```ts
|
|
5679
|
+
readonly density?: number
|
|
5680
|
+
```
|
|
5681
|
+
|
|
5682
|
+
Device pixels per CSS px of a render made for [BrandingVariant.size](#brandingvariant-size).
|
|
5683
|
+
|
|
5684
|
+
<a id="brandingvariant-vector"></a>
|
|
5685
|
+
|
|
5686
|
+
## BrandingVariant.vector
|
|
5687
|
+
|
|
5688
|
+
```ts
|
|
5689
|
+
readonly vector?: true
|
|
5690
|
+
```
|
|
5691
|
+
|
|
5692
|
+
`true` on a scalable image: it draws crisply at any size.
|
|
5693
|
+
|
|
5694
|
+
<a id="brandingvariant-theme"></a>
|
|
5695
|
+
|
|
5696
|
+
## BrandingVariant.theme
|
|
5697
|
+
|
|
5698
|
+
```ts
|
|
5699
|
+
readonly theme?: BrandingTheme
|
|
5700
|
+
```
|
|
5701
|
+
|
|
5702
|
+
The one theme the file is for. Absent: either theme.
|
|
5703
|
+
|
|
5704
|
+
<a id="brandingasset"></a>
|
|
5705
|
+
|
|
5706
|
+
## BrandingAsset
|
|
5707
|
+
|
|
5708
|
+
```ts
|
|
5709
|
+
interface BrandingAsset
|
|
5710
|
+
```
|
|
5711
|
+
|
|
5712
|
+
One asset in the platform's branding manifest.
|
|
5713
|
+
|
|
5714
|
+
<a id="brandingasset-id"></a>
|
|
5715
|
+
|
|
5716
|
+
## BrandingAsset.id
|
|
5717
|
+
|
|
5718
|
+
```ts
|
|
5719
|
+
readonly id: string
|
|
5720
|
+
```
|
|
5721
|
+
|
|
5722
|
+
What a game asks for: `'gem-logo'`, `'gems-mark'`. Never renamed.
|
|
5723
|
+
|
|
5724
|
+
<a id="brandingasset-kind"></a>
|
|
5725
|
+
|
|
5726
|
+
## BrandingAsset.kind
|
|
5727
|
+
|
|
5728
|
+
```ts
|
|
5729
|
+
readonly kind: string
|
|
5730
|
+
```
|
|
5731
|
+
|
|
5732
|
+
`'image'`, `'audio'` or `'font'` today. The platform may add more, so
|
|
5733
|
+
compare it rather than switching on it exhaustively.
|
|
5734
|
+
|
|
5735
|
+
<a id="brandingasset-variants"></a>
|
|
5736
|
+
|
|
5737
|
+
## BrandingAsset.variants
|
|
5738
|
+
|
|
5739
|
+
```ts
|
|
5740
|
+
readonly variants: readonly BrandingVariant[]
|
|
5741
|
+
```
|
|
5742
|
+
|
|
5743
|
+
Every file of it, smallest first. Never empty.
|
|
5744
|
+
|
|
5745
|
+
<a id="brandinglookup"></a>
|
|
5746
|
+
|
|
5747
|
+
## BrandingLookup
|
|
5748
|
+
|
|
5749
|
+
```ts
|
|
5750
|
+
type BrandingLookup = { outcome: "ok"; url: string; variant: BrandingVariant; asset: BrandingAsset } | { outcome: "not_found" | "unavailable" }
|
|
5751
|
+
```
|
|
5752
|
+
|
|
5753
|
+
What a branding lookup resolves with. Only `ok` carries a URL.
|
|
5754
|
+
|
|
5755
|
+
- `ok`: the platform has it, and `url` is the file picked for what you asked.
|
|
5756
|
+
- `not_found`: the manifest was read and has no asset with that id and kind,
|
|
5757
|
+
or none of its files fits the theme you asked for. Draw nothing for it.
|
|
5758
|
+
- `unavailable`: the manifest could not be read — offline, a network error,
|
|
5759
|
+
a Content-Security-Policy that leaves out `https://gemarcade.com`. Draw the
|
|
5760
|
+
copy you bundled from the package's `brand/` folder, if there is one.
|
|
5761
|
+
|
|
5762
|
+
<a id="brandinglist"></a>
|
|
5763
|
+
|
|
5764
|
+
## BrandingList
|
|
5765
|
+
|
|
5766
|
+
```ts
|
|
5767
|
+
type BrandingList = { outcome: "ok"; assets: readonly BrandingAsset[] } | { outcome: "unavailable" }
|
|
5768
|
+
```
|
|
5769
|
+
|
|
5770
|
+
What [BrandingApi.list](#brandingapi-list) resolves with.
|
|
5771
|
+
|
|
5772
|
+
<a id="brandingimageoptions"></a>
|
|
5773
|
+
|
|
5774
|
+
## BrandingImageOptions
|
|
5775
|
+
|
|
5776
|
+
```ts
|
|
5777
|
+
interface BrandingImageOptions
|
|
5778
|
+
```
|
|
5779
|
+
|
|
5780
|
+
How to pick one image from an asset's variants.
|
|
5781
|
+
|
|
5782
|
+
<a id="brandingimageoptions-size"></a>
|
|
5783
|
+
|
|
5784
|
+
## BrandingImageOptions.size
|
|
5785
|
+
|
|
5786
|
+
```ts
|
|
5787
|
+
readonly size?: number
|
|
5788
|
+
```
|
|
5789
|
+
|
|
5790
|
+
The CSS px box you draw it in. A render made for exactly that box wins;
|
|
5791
|
+
then a scalable image; then the narrowest render wide enough for
|
|
5792
|
+
`size × density`. Leave it out for the largest: the scalable image, or
|
|
5793
|
+
else the widest render.
|
|
5794
|
+
|
|
5795
|
+
<a id="brandingimageoptions-density"></a>
|
|
5796
|
+
|
|
5797
|
+
## BrandingImageOptions.density
|
|
5798
|
+
|
|
5799
|
+
```ts
|
|
5800
|
+
readonly density?: number
|
|
5801
|
+
```
|
|
5802
|
+
|
|
5803
|
+
Device pixels per CSS px. Defaults to the screen's `devicePixelRatio`;
|
|
5804
|
+
pass `3` for a canvas or texture you scale down yourself.
|
|
5805
|
+
|
|
5806
|
+
<a id="brandingimageoptions-theme"></a>
|
|
5807
|
+
|
|
5808
|
+
## BrandingImageOptions.theme
|
|
5809
|
+
|
|
5810
|
+
```ts
|
|
5811
|
+
readonly theme?: BrandingTheme
|
|
5812
|
+
```
|
|
5813
|
+
|
|
5814
|
+
Prefer a file drawn for this theme. Files for the other theme are never picked.
|
|
5815
|
+
|
|
5816
|
+
<a id="brandingassetoptions"></a>
|
|
5817
|
+
|
|
5818
|
+
## BrandingAssetOptions
|
|
5819
|
+
|
|
5820
|
+
```ts
|
|
5821
|
+
interface BrandingAssetOptions
|
|
5822
|
+
```
|
|
5823
|
+
|
|
5824
|
+
What [BrandingApi.get](#brandingapi-get) takes: the asset's kind, and how to pick a file.
|
|
5825
|
+
|
|
5826
|
+
<a id="brandingassetoptions-size"></a>
|
|
5827
|
+
|
|
5828
|
+
## BrandingAssetOptions.size
|
|
5829
|
+
|
|
5830
|
+
```ts
|
|
5831
|
+
readonly size?: number
|
|
5832
|
+
```
|
|
5833
|
+
|
|
5834
|
+
The CSS px box you draw it in. A render made for exactly that box wins;
|
|
5835
|
+
then a scalable image; then the narrowest render wide enough for
|
|
5836
|
+
`size × density`. Leave it out for the largest: the scalable image, or
|
|
5837
|
+
else the widest render.
|
|
5838
|
+
|
|
5839
|
+
<a id="brandingassetoptions-density"></a>
|
|
5840
|
+
|
|
5841
|
+
## BrandingAssetOptions.density
|
|
5842
|
+
|
|
5843
|
+
```ts
|
|
5844
|
+
readonly density?: number
|
|
5845
|
+
```
|
|
5846
|
+
|
|
5847
|
+
Device pixels per CSS px. Defaults to the screen's `devicePixelRatio`;
|
|
5848
|
+
pass `3` for a canvas or texture you scale down yourself.
|
|
5849
|
+
|
|
5850
|
+
<a id="brandingassetoptions-theme"></a>
|
|
5851
|
+
|
|
5852
|
+
## BrandingAssetOptions.theme
|
|
5853
|
+
|
|
5854
|
+
```ts
|
|
5855
|
+
readonly theme?: BrandingTheme
|
|
5856
|
+
```
|
|
5857
|
+
|
|
5858
|
+
Prefer a file drawn for this theme. Files for the other theme are never picked.
|
|
5859
|
+
|
|
5860
|
+
<a id="brandingassetoptions-kind"></a>
|
|
5861
|
+
|
|
5862
|
+
## BrandingAssetOptions.kind
|
|
5863
|
+
|
|
5864
|
+
```ts
|
|
5865
|
+
readonly kind: string
|
|
5866
|
+
```
|
|
5867
|
+
|
|
5868
|
+
The kind you expect: `'image'`, `'audio'` or `'font'`. An asset of another
|
|
5869
|
+
kind answers `not_found`. `size` and `density` apply to images only; for
|
|
5870
|
+
any other kind the first file wins.
|
|
5871
|
+
|
|
5872
|
+
<a id="brandingcurrency"></a>
|
|
5873
|
+
|
|
5874
|
+
## BrandingCurrency
|
|
5875
|
+
|
|
5876
|
+
```ts
|
|
5877
|
+
type BrandingCurrency = "GEMS" | "ARCADE_TICKETS"
|
|
5878
|
+
```
|
|
5879
|
+
|
|
5880
|
+
The platform currencies with a mark: Gems and Coins.
|
|
5881
|
+
|
|
5882
|
+
<a id="brandingapi"></a>
|
|
5883
|
+
|
|
5884
|
+
## BrandingApi
|
|
5885
|
+
|
|
5886
|
+
```ts
|
|
5887
|
+
interface BrandingApi
|
|
5888
|
+
```
|
|
5889
|
+
|
|
5890
|
+
The platform's branding, as the platform serves it now. `gem.branding` is
|
|
5891
|
+
one of these. Nothing here rejects but a bad argument.
|
|
5892
|
+
|
|
5893
|
+
<a id="brandingapi-get"></a>
|
|
5894
|
+
|
|
5895
|
+
## BrandingApi.get
|
|
5896
|
+
|
|
5897
|
+
```ts
|
|
5898
|
+
get(id: string, options: BrandingAssetOptions): Promise<BrandingLookup>
|
|
5899
|
+
```
|
|
5900
|
+
|
|
5901
|
+
Any asset in the platform's branding manifest, by id and kind — including
|
|
5902
|
+
ones added after this SDK was released.
|
|
5903
|
+
|
|
5904
|
+
```js
|
|
5905
|
+
const logo = await gem.branding.get('gem-logo', { kind: 'image', size: 64 });
|
|
5906
|
+
if (logo.outcome === 'ok') img.src = logo.url;
|
|
5907
|
+
```
|
|
5908
|
+
|
|
5909
|
+
| Parameter | Type |
|
|
5910
|
+
| --- | --- |
|
|
5911
|
+
| `id` | `string` |
|
|
5912
|
+
| `options` | `BrandingAssetOptions` |
|
|
5913
|
+
|
|
5914
|
+
**Returns.** Resolves `ok`, `not_found` or `unavailable`. Rejects only for an
|
|
5915
|
+
argument that is not one (an empty id, a size that is not a positive
|
|
5916
|
+
number).
|
|
5917
|
+
|
|
5918
|
+
<a id="brandingapi-logo"></a>
|
|
5919
|
+
|
|
5920
|
+
## BrandingApi.logo
|
|
5921
|
+
|
|
5922
|
+
```ts
|
|
5923
|
+
logo(options?: BrandingImageOptions): Promise<BrandingLookup>
|
|
5924
|
+
```
|
|
5925
|
+
|
|
5926
|
+
The Indie Gems logo, the brand gem. Scalable: draw it at 32 CSS px or more,
|
|
5927
|
+
as served (`docs/branding.md` has the usage rules).
|
|
5928
|
+
|
|
5929
|
+
| Parameter | Type |
|
|
5930
|
+
| --- | --- |
|
|
5931
|
+
| `options` | `BrandingImageOptions` |
|
|
5932
|
+
|
|
5933
|
+
<a id="brandingapi-wordmark"></a>
|
|
5934
|
+
|
|
5935
|
+
## BrandingApi.wordmark
|
|
5936
|
+
|
|
5937
|
+
```ts
|
|
5938
|
+
wordmark(options?: BrandingImageOptions): Promise<BrandingLookup>
|
|
5939
|
+
```
|
|
5940
|
+
|
|
5941
|
+
The Gem Arcade wordmark. Draw it at 60 CSS px wide or more, as served.
|
|
5942
|
+
|
|
5943
|
+
| Parameter | Type |
|
|
5944
|
+
| --- | --- |
|
|
5945
|
+
| `options` | `BrandingImageOptions` |
|
|
5946
|
+
|
|
5947
|
+
<a id="brandingapi-currencymark"></a>
|
|
5948
|
+
|
|
5949
|
+
## BrandingApi.currencyMark
|
|
5950
|
+
|
|
5951
|
+
```ts
|
|
5952
|
+
currencyMark(currency: BrandingCurrency, options?: BrandingImageOptions): Promise<BrandingLookup>
|
|
5953
|
+
```
|
|
5954
|
+
|
|
5955
|
+
The mark of a platform currency, by its slug: `'GEMS'` or
|
|
5956
|
+
`'ARCADE_TICKETS'` (Coins). Pass `size: 20` or `32` for the inline icon
|
|
5957
|
+
beside an amount, or leave it out for the hero art of a reward screen.
|
|
5958
|
+
`docs/brand-art.md` says where each may be drawn.
|
|
5959
|
+
|
|
5960
|
+
| Parameter | Type |
|
|
5961
|
+
| --- | --- |
|
|
5962
|
+
| `currency` | `BrandingCurrency` |
|
|
5963
|
+
| `options` | `BrandingImageOptions` |
|
|
5964
|
+
|
|
5965
|
+
<a id="brandingapi-trophy"></a>
|
|
5966
|
+
|
|
5967
|
+
## BrandingApi.trophy
|
|
5968
|
+
|
|
5969
|
+
```ts
|
|
5970
|
+
trophy(options?: BrandingImageOptions): Promise<BrandingLookup>
|
|
5971
|
+
```
|
|
5972
|
+
|
|
5973
|
+
The trophy, for where your game shows what a player has achieved.
|
|
5974
|
+
|
|
5975
|
+
| Parameter | Type |
|
|
5976
|
+
| --- | --- |
|
|
5977
|
+
| `options` | `BrandingImageOptions` |
|
|
5978
|
+
|
|
5979
|
+
<a id="brandingapi-list"></a>
|
|
5980
|
+
|
|
5981
|
+
## BrandingApi.list
|
|
5982
|
+
|
|
5983
|
+
```ts
|
|
5984
|
+
list(): Promise<BrandingList>
|
|
5985
|
+
```
|
|
5986
|
+
|
|
5987
|
+
Every asset the platform serves, or `unavailable` when the manifest could
|
|
5988
|
+
not be read.
|
|
5989
|
+
|
|
5426
5990
|
<a id="listchallengesoptions"></a>
|
|
5427
5991
|
|
|
5428
5992
|
## ListChallengesOptions
|
|
@@ -10652,6 +11216,31 @@ exactly as given, and call `purchase(skuId)` from the player's press. After
|
|
|
10652
11216
|
|
|
10653
11217
|
**Guides.** [arcade-and-store](../arcade-and-store.md)
|
|
10654
11218
|
|
|
11219
|
+
<a id="gem-branding"></a>
|
|
11220
|
+
|
|
11221
|
+
## Gem.branding
|
|
11222
|
+
|
|
11223
|
+
```ts
|
|
11224
|
+
readonly branding: BrandingApi
|
|
11225
|
+
```
|
|
11226
|
+
|
|
11227
|
+
The platform's branding — the Indie Gems logo, the Gem Arcade wordmark,
|
|
11228
|
+
the Gems and Coins marks and the trophy — as the platform serves it now,
|
|
11229
|
+
so a changed mark reaches your game with no republish.
|
|
11230
|
+
|
|
11231
|
+
Look up any asset by id and kind with `get`, or use `logo`, `wordmark`,
|
|
11232
|
+
`currencyMark` and `trophy`. Every URL is on the platform's own host.
|
|
11233
|
+
Nothing rejects but a bad argument: an asset the platform does not list is
|
|
11234
|
+
`not_found`, and a manifest that could not be read is `unavailable`, when
|
|
11235
|
+
you draw the copy you bundled from `brand/` instead.
|
|
11236
|
+
|
|
11237
|
+
```js
|
|
11238
|
+
const logo = await gem.branding.logo();
|
|
11239
|
+
if (logo.outcome === 'ok') menuLogo.src = logo.url;
|
|
11240
|
+
```
|
|
11241
|
+
|
|
11242
|
+
**Guides.** [branding](../branding.md)
|
|
11243
|
+
|
|
10655
11244
|
<a id="gem-avatarpickeravailable"></a>
|
|
10656
11245
|
|
|
10657
11246
|
## Gem.avatarPickerAvailable
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The server surface — API reference
|
|
2
2
|
|
|
3
|
-
Generated from `@indiegems/gem-web-sdk/sdk` v16.
|
|
3
|
+
Generated from `@indiegems/gem-web-sdk/sdk` v16.3.0, the version of the package this file ships in. Every symbol below carries an explicit anchor, its `anchor` in `reference.json` beside this file.
|
|
4
4
|
|
|
5
5
|
`@indiegems/gem-web-sdk/sdk` is the one import a game writes, wherever its code runs. `@indiegems/gem-web-sdk/server` exports exactly the symbols on this page and nothing else, for a build that wants only this half.
|
|
6
6
|
|