@indiegems/gem-web-sdk 16.2.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.
@@ -1,6 +1,6 @@
1
1
  # The browser surface — API reference
2
2
 
3
- Generated from `@indiegems/gem-web-sdk/sdk` v16.2.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.
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
 
@@ -5587,6 +5587,406 @@ only if you are instrumenting something that runs before the SDK exists.
5587
5587
  | --- | --- |
5588
5588
  | `options` | `BootTimelineOptions` |
5589
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
+
5590
5990
  <a id="listchallengesoptions"></a>
5591
5991
 
5592
5992
  ## ListChallengesOptions
@@ -10816,6 +11216,31 @@ exactly as given, and call `purchase(skuId)` from the player's press. After
10816
11216
 
10817
11217
  **Guides.** [arcade-and-store](../arcade-and-store.md)
10818
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
+
10819
11244
  <a id="gem-avatarpickeravailable"></a>
10820
11245
 
10821
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.2.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.
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