@indiegems/gem-web-sdk 13.4.3 → 14.0.1

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` v13.4.3, 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` v14.0.1, 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
 
@@ -5854,6 +5854,30 @@ connected, and only to an arcade that draws a menu.
5854
5854
  **Returns.** whether the message left the frame — `false` before the bridge is
5855
5855
  up, for an arcade with no menu, and past this frame's own limit.
5856
5856
 
5857
+ <a id="gemframe-declaresettings"></a>
5858
+
5859
+ ## GemFrame.declareSettings
5860
+
5861
+ ```ts
5862
+ declareSettings(settings: { id: string; label: string; kind: "toggle" | "slider" | "choice"; value: string | number | boolean; quick?: boolean; icon?: string; min?: number; max?: number; step?: number; options?: { id: string; label: string }[] }[]): boolean
5863
+ ```
5864
+
5865
+ Mirror up to eight of your game's own settings into the arcade's menu —
5866
+ the whole list each time, the latest one winning.
5867
+
5868
+ Prefer `gem.settings.declare`, which checks each entry, holds the list
5869
+ across a reconnect and calls your handlers when the player changes one.
5870
+ This one sends only while connected, and only to an arcade that draws game
5871
+ settings.
5872
+
5873
+ | Parameter | Type |
5874
+ | --- | --- |
5875
+ | `settings` | `{ id: string; label: string; kind: "toggle" \| "slider" \| "choice"; value: string \| number \| boolean; quick?: boolean; icon?: string; min?: number; max?: number; step?: number; options?: { id: string; label: string }[] }[]` |
5876
+
5877
+ **Returns.** whether the message left the frame — `false` before the bridge is
5878
+ up, for an arcade that draws no game settings, for a list the schema
5879
+ refuses, and past this frame's own limit.
5880
+
5857
5881
  <a id="gemframe-setgemcorner"></a>
5858
5882
 
5859
5883
  ## GemFrame.setGemCorner
@@ -7222,6 +7246,500 @@ const { accepted, why } = result.json();
7222
7246
  own `Err`. `TransportRefusal` for an input that is neither bytes nor
7223
7247
  JSON, before anything is sent. `AuthError` if the token cannot be renewed.
7224
7248
 
7249
+ <a id="gemgamesettingicon"></a>
7250
+
7251
+ ## GemGameSettingIcon
7252
+
7253
+ ```ts
7254
+ type GemGameSettingIcon = "music" | "sfx" | "voice" | "eye" | "text" | "hint" | "speed" | "bright" | "controls" | "star"
7255
+ ```
7256
+
7257
+ The icon codes a declared setting may carry — the Arcade draws the glyph. An
7258
+ icon is optional, and a setting without one gets the Arcade's generic glyph.
7259
+
7260
+ <a id="gemgamesettingvalue"></a>
7261
+
7262
+ ## GemGameSettingValue
7263
+
7264
+ ```ts
7265
+ type GemGameSettingValue = boolean | number | string
7266
+ ```
7267
+
7268
+ The value of a declared setting: `boolean` for a toggle, `number` for a
7269
+ slider, and an option's `id` for a choice.
7270
+
7271
+ <a id="gemgamesettingbase"></a>
7272
+
7273
+ ## GemGameSettingBase
7274
+
7275
+ ```ts
7276
+ interface GemGameSettingBase
7277
+ ```
7278
+
7279
+ What every declared setting has, whatever its kind.
7280
+
7281
+ <a id="gemgamesettingbase-id"></a>
7282
+
7283
+ ## GemGameSettingBase.id
7284
+
7285
+ ```ts
7286
+ readonly id: string
7287
+ ```
7288
+
7289
+ Your own name for the setting — 1 to 40 of `A-Z a-z 0-9 _ -`, unique in
7290
+ one declaration. It is what [GemGameSettingChange.id](#gemgamesettingchange-id) carries back.
7291
+
7292
+ <a id="gemgamesettingbase-label"></a>
7293
+
7294
+ ## GemGameSettingBase.label
7295
+
7296
+ ```ts
7297
+ readonly label: string
7298
+ ```
7299
+
7300
+ What the player reads, 1 to 40 characters, **already in the player's
7301
+ language** (`gem.prefs.locale`): the Arcade does not translate it. Cut at
7302
+ 40 characters.
7303
+
7304
+ <a id="gemgamesettingbase-icon"></a>
7305
+
7306
+ ## GemGameSettingBase.icon
7307
+
7308
+ ```ts
7309
+ readonly icon?: GemGameSettingIcon
7310
+ ```
7311
+
7312
+ One of the Arcade's icon codes; a code this SDK does not know is left out
7313
+ (with a warning) and the setting is kept with the generic glyph.
7314
+
7315
+ In the Gem Arcade the icon also fills its fixed quick row (Music, Sound,
7316
+ Color, Vibration): the first **toggle** with `'music'` is the Music slot
7317
+ and the first toggle with `'eye'` is the Color slot. Give those two icons
7318
+ to your music on/off and colour-help toggles, and to no other setting.
7319
+
7320
+ <a id="gemgametogglesetting"></a>
7321
+
7322
+ ## GemGameToggleSetting
7323
+
7324
+ ```ts
7325
+ interface GemGameToggleSetting
7326
+ ```
7327
+
7328
+ An on/off setting — Music, Color help.
7329
+
7330
+ <a id="gemgametogglesetting-id"></a>
7331
+
7332
+ ## GemGameToggleSetting.id
7333
+
7334
+ ```ts
7335
+ readonly id: string
7336
+ ```
7337
+
7338
+ Your own name for the setting — 1 to 40 of `A-Z a-z 0-9 _ -`, unique in
7339
+ one declaration. It is what [GemGameSettingChange.id](#gemgamesettingchange-id) carries back.
7340
+
7341
+ <a id="gemgametogglesetting-label"></a>
7342
+
7343
+ ## GemGameToggleSetting.label
7344
+
7345
+ ```ts
7346
+ readonly label: string
7347
+ ```
7348
+
7349
+ What the player reads, 1 to 40 characters, **already in the player's
7350
+ language** (`gem.prefs.locale`): the Arcade does not translate it. Cut at
7351
+ 40 characters.
7352
+
7353
+ <a id="gemgametogglesetting-icon"></a>
7354
+
7355
+ ## GemGameToggleSetting.icon
7356
+
7357
+ ```ts
7358
+ readonly icon?: GemGameSettingIcon
7359
+ ```
7360
+
7361
+ One of the Arcade's icon codes; a code this SDK does not know is left out
7362
+ (with a warning) and the setting is kept with the generic glyph.
7363
+
7364
+ In the Gem Arcade the icon also fills its fixed quick row (Music, Sound,
7365
+ Color, Vibration): the first **toggle** with `'music'` is the Music slot
7366
+ and the first toggle with `'eye'` is the Color slot. Give those two icons
7367
+ to your music on/off and colour-help toggles, and to no other setting.
7368
+
7369
+ <a id="gemgametogglesetting-kind"></a>
7370
+
7371
+ ## GemGameToggleSetting.kind
7372
+
7373
+ ```ts
7374
+ readonly kind: "toggle"
7375
+ ```
7376
+
7377
+ `'toggle'`: what kind of setting this is.
7378
+
7379
+ <a id="gemgametogglesetting-value"></a>
7380
+
7381
+ ## GemGameToggleSetting.value
7382
+
7383
+ ```ts
7384
+ readonly value: boolean
7385
+ ```
7386
+
7387
+ Whether it is on now.
7388
+
7389
+ <a id="gemgametogglesetting-quick"></a>
7390
+
7391
+ ## GemGameToggleSetting.quick
7392
+
7393
+ ```ts
7394
+ readonly quick?: boolean
7395
+ ```
7396
+
7397
+ **Ignored by the Gem Arcade**, whose quick row is fixed — Music, Sound,
7398
+ Color, Vibration — and filled by [GemGameSettingBase.icon](#gemgamesettingbase-icon)
7399
+ (`'music'`, `'eye'`), not by this flag. Kept for other embedders, which
7400
+ may show the first two toggles that ask in a quick row of their own;
7401
+ leaving it out is fine.
7402
+
7403
+ <a id="gemgameslidersetting"></a>
7404
+
7405
+ ## GemGameSliderSetting
7406
+
7407
+ ```ts
7408
+ interface GemGameSliderSetting
7409
+ ```
7410
+
7411
+ A number between two ends — Music volume, Game speed.
7412
+
7413
+ <a id="gemgameslidersetting-id"></a>
7414
+
7415
+ ## GemGameSliderSetting.id
7416
+
7417
+ ```ts
7418
+ readonly id: string
7419
+ ```
7420
+
7421
+ Your own name for the setting — 1 to 40 of `A-Z a-z 0-9 _ -`, unique in
7422
+ one declaration. It is what [GemGameSettingChange.id](#gemgamesettingchange-id) carries back.
7423
+
7424
+ <a id="gemgameslidersetting-label"></a>
7425
+
7426
+ ## GemGameSliderSetting.label
7427
+
7428
+ ```ts
7429
+ readonly label: string
7430
+ ```
7431
+
7432
+ What the player reads, 1 to 40 characters, **already in the player's
7433
+ language** (`gem.prefs.locale`): the Arcade does not translate it. Cut at
7434
+ 40 characters.
7435
+
7436
+ <a id="gemgameslidersetting-icon"></a>
7437
+
7438
+ ## GemGameSliderSetting.icon
7439
+
7440
+ ```ts
7441
+ readonly icon?: GemGameSettingIcon
7442
+ ```
7443
+
7444
+ One of the Arcade's icon codes; a code this SDK does not know is left out
7445
+ (with a warning) and the setting is kept with the generic glyph.
7446
+
7447
+ In the Gem Arcade the icon also fills its fixed quick row (Music, Sound,
7448
+ Color, Vibration): the first **toggle** with `'music'` is the Music slot
7449
+ and the first toggle with `'eye'` is the Color slot. Give those two icons
7450
+ to your music on/off and colour-help toggles, and to no other setting.
7451
+
7452
+ <a id="gemgameslidersetting-kind"></a>
7453
+
7454
+ ## GemGameSliderSetting.kind
7455
+
7456
+ ```ts
7457
+ readonly kind: "slider"
7458
+ ```
7459
+
7460
+ `'slider'`: what kind of setting this is.
7461
+
7462
+ <a id="gemgameslidersetting-value"></a>
7463
+
7464
+ ## GemGameSliderSetting.value
7465
+
7466
+ ```ts
7467
+ readonly value: number
7468
+ ```
7469
+
7470
+ The number now. Clamped into `[min, max]` and snapped onto `step` before it
7471
+ is sent.
7472
+
7473
+ <a id="gemgameslidersetting-min"></a>
7474
+
7475
+ ## GemGameSliderSetting.min
7476
+
7477
+ ```ts
7478
+ readonly min?: number
7479
+ ```
7480
+
7481
+ The lowest value, `0` when left out. Within ±1 000 000, below `max`.
7482
+
7483
+ <a id="gemgameslidersetting-max"></a>
7484
+
7485
+ ## GemGameSliderSetting.max
7486
+
7487
+ ```ts
7488
+ readonly max?: number
7489
+ ```
7490
+
7491
+ The highest value, `100` when left out. Within ±1 000 000, above `min`.
7492
+
7493
+ <a id="gemgameslidersetting-step"></a>
7494
+
7495
+ ## GemGameSliderSetting.step
7496
+
7497
+ ```ts
7498
+ readonly step?: number
7499
+ ```
7500
+
7501
+ The increment from `min`, `1` when left out. Greater than `0`.
7502
+
7503
+ <a id="gemgamesettingoption"></a>
7504
+
7505
+ ## GemGameSettingOption
7506
+
7507
+ ```ts
7508
+ interface GemGameSettingOption
7509
+ ```
7510
+
7511
+ One answer of a [GemGameChoiceSetting](#gemgamechoicesetting).
7512
+
7513
+ <a id="gemgamesettingoption-id"></a>
7514
+
7515
+ ## GemGameSettingOption.id
7516
+
7517
+ ```ts
7518
+ readonly id: string
7519
+ ```
7520
+
7521
+ Your own name for the answer, 1 to 40 of `A-Z a-z 0-9 _ -`.
7522
+
7523
+ <a id="gemgamesettingoption-label"></a>
7524
+
7525
+ ## GemGameSettingOption.label
7526
+
7527
+ ```ts
7528
+ readonly label: string
7529
+ ```
7530
+
7531
+ What the player reads, 1 to 40 characters, already translated.
7532
+
7533
+ <a id="gemgamechoicesetting"></a>
7534
+
7535
+ ## GemGameChoiceSetting
7536
+
7537
+ ```ts
7538
+ interface GemGameChoiceSetting
7539
+ ```
7540
+
7541
+ One of two to four answers — Difficulty: Easy, Normal, Hard.
7542
+
7543
+ <a id="gemgamechoicesetting-id"></a>
7544
+
7545
+ ## GemGameChoiceSetting.id
7546
+
7547
+ ```ts
7548
+ readonly id: string
7549
+ ```
7550
+
7551
+ Your own name for the setting — 1 to 40 of `A-Z a-z 0-9 _ -`, unique in
7552
+ one declaration. It is what [GemGameSettingChange.id](#gemgamesettingchange-id) carries back.
7553
+
7554
+ <a id="gemgamechoicesetting-label"></a>
7555
+
7556
+ ## GemGameChoiceSetting.label
7557
+
7558
+ ```ts
7559
+ readonly label: string
7560
+ ```
7561
+
7562
+ What the player reads, 1 to 40 characters, **already in the player's
7563
+ language** (`gem.prefs.locale`): the Arcade does not translate it. Cut at
7564
+ 40 characters.
7565
+
7566
+ <a id="gemgamechoicesetting-icon"></a>
7567
+
7568
+ ## GemGameChoiceSetting.icon
7569
+
7570
+ ```ts
7571
+ readonly icon?: GemGameSettingIcon
7572
+ ```
7573
+
7574
+ One of the Arcade's icon codes; a code this SDK does not know is left out
7575
+ (with a warning) and the setting is kept with the generic glyph.
7576
+
7577
+ In the Gem Arcade the icon also fills its fixed quick row (Music, Sound,
7578
+ Color, Vibration): the first **toggle** with `'music'` is the Music slot
7579
+ and the first toggle with `'eye'` is the Color slot. Give those two icons
7580
+ to your music on/off and colour-help toggles, and to no other setting.
7581
+
7582
+ <a id="gemgamechoicesetting-kind"></a>
7583
+
7584
+ ## GemGameChoiceSetting.kind
7585
+
7586
+ ```ts
7587
+ readonly kind: "choice"
7588
+ ```
7589
+
7590
+ `'choice'`: what kind of setting this is.
7591
+
7592
+ <a id="gemgamechoicesetting-value"></a>
7593
+
7594
+ ## GemGameChoiceSetting.value
7595
+
7596
+ ```ts
7597
+ readonly value: string
7598
+ ```
7599
+
7600
+ The `id` of the option chosen now.
7601
+
7602
+ <a id="gemgamechoicesetting-options"></a>
7603
+
7604
+ ## GemGameChoiceSetting.options
7605
+
7606
+ ```ts
7607
+ readonly options: readonly GemGameSettingOption[]
7608
+ ```
7609
+
7610
+ Two to four answers, ids unique. A fifth and later are left out.
7611
+
7612
+ <a id="gemgamesetting"></a>
7613
+
7614
+ ## GemGameSetting
7615
+
7616
+ ```ts
7617
+ type GemGameSetting = GemGameToggleSetting | GemGameSliderSetting | GemGameChoiceSetting
7618
+ ```
7619
+
7620
+ One of your game's settings, as `gem.settings.declare` mirrors it into the
7621
+ Arcade's menu: a toggle, a slider or a choice.
7622
+
7623
+ <a id="gemgamesettingchange"></a>
7624
+
7625
+ ## GemGameSettingChange
7626
+
7627
+ ```ts
7628
+ interface GemGameSettingChange
7629
+ ```
7630
+
7631
+ The player changed one of your declared settings in the Arcade's menu.
7632
+
7633
+ <a id="gemgamesettingchange-id"></a>
7634
+
7635
+ ## GemGameSettingChange.id
7636
+
7637
+ ```ts
7638
+ readonly id: string
7639
+ ```
7640
+
7641
+ The setting's `id`, from your latest declaration.
7642
+
7643
+ <a id="gemgamesettingchange-value"></a>
7644
+
7645
+ ## GemGameSettingChange.value
7646
+
7647
+ ```ts
7648
+ readonly value: GemGameSettingValue
7649
+ ```
7650
+
7651
+ The new value, of the setting's kind: a `boolean` for a toggle, a `number`
7652
+ inside a slider's range and on its step, an option's `id` for a choice.
7653
+
7654
+ <a id="gamesettingsapi"></a>
7655
+
7656
+ ## GameSettingsApi
7657
+
7658
+ ```ts
7659
+ interface GameSettingsApi
7660
+ ```
7661
+
7662
+ `gem.settings` — mirror your game's own settings, up to eight, into the
7663
+ Arcade's Gem menu. Your own settings button and screen stay: this is a
7664
+ second door to the same settings, never the only one.
7665
+
7666
+ <a id="gamesettingsapi-declare"></a>
7667
+
7668
+ ## GameSettingsApi.declare
7669
+
7670
+ ```ts
7671
+ declare(settings: readonly GemGameSetting[]): boolean
7672
+ ```
7673
+
7674
+ Show up to eight of your settings in the Arcade's menu, in this order — the
7675
+ whole list each time, the latest call winning. `declare([])` takes them
7676
+ all back out.
7677
+
7678
+ ```js
7679
+ gem.settings.declare([
7680
+ { id: 'music', label: t('Music'), kind: 'toggle', value: music.on, icon: 'music' },
7681
+ { id: 'colors', label: t('Color help'), kind: 'toggle', value: colorHelp, icon: 'eye' },
7682
+ { id: 'speed', label: t('Game speed'), kind: 'slider', value: speed, min: 0.5, max: 2, step: 0.25 },
7683
+ ]);
7684
+ ```
7685
+
7686
+ **Keep your own settings button and screen** — top-right, on every screen.
7687
+ This mirrors those settings; it never replaces them, and an embedder that
7688
+ draws no game settings shows none of it.
7689
+
7690
+ The Gem Arcade's Settings screen lists **every** setting you declare, so
7691
+ declare all of yours. Its quick row is fixed — Music, Sound, Color and
7692
+ Vibration (phones and tablets), with the Arcade's own labels: your first
7693
+ toggle with `icon: 'music'` fills Music, your first with `icon: 'eye'`
7694
+ fills Color, and a slot you do not fill stays greyed. It ignores `quick`.
7695
+
7696
+ **Declare again whenever your own screen changes a value**, so the menu
7697
+ never shows a stale one. **Never declare a second mute or vibration
7698
+ switch** — the quick row has the Arcade's own. Your game's own volume,
7699
+ music and sound-effects levels are yours to declare; graphics quality and
7700
+ the controls defaults stay the Arcade's and reach you as
7701
+ `gem.prefs.recommended`.
7702
+
7703
+ An entry that breaks a rule is left out, with a warning through your
7704
+ `log`; nothing throws.
7705
+
7706
+ | Parameter | Type | Description |
7707
+ | --- | --- | --- |
7708
+ | `settings` | `readonly GemGameSetting[]` | Up to eight settings, in the order to show them. |
7709
+
7710
+ **Returns.** `true` when the Arcade has been told, or will be within half a
7711
+ second; `false` before the bridge is up (the list is held and sent when
7712
+ it connects), under an embedder that draws no game settings, and for an
7713
+ argument that is not an array.
7714
+
7715
+ <a id="gamesettingsapi-onchange"></a>
7716
+
7717
+ ## GameSettingsApi.onChange
7718
+
7719
+ ```ts
7720
+ onChange(handler: (change: GemGameSettingChange) => void): () => void
7721
+ ```
7722
+
7723
+ Called when the player changes one of your declared settings in the
7724
+ Arcade's menu. Apply it at once, **even while paused** — the menu holds
7725
+ the pause, and the player should hear the music stop while it is open —
7726
+ and keep it where you keep that setting's other changes.
7727
+
7728
+ ```js
7729
+ gem.settings.onChange(({ id, value }) => {
7730
+ if (id === 'music') setMusic(value === true);
7731
+ });
7732
+ ```
7733
+
7734
+ The SDK has already written the new value into your declaration, so there
7735
+ is no need to declare again for this change.
7736
+
7737
+ | Parameter | Type |
7738
+ | --- | --- |
7739
+ | `handler` | `(change: GemGameSettingChange) => void` |
7740
+
7741
+ **Returns.** A function that removes the handler.
7742
+
7225
7743
  <a id="arcade_embedders"></a>
7226
7744
 
7227
7745
  ## ARCADE_EMBEDDERS
@@ -9298,6 +9816,38 @@ camera.pitch += t.pitch;
9298
9816
 
9299
9817
  See the guide's "Camera and look controls" section.
9300
9818
 
9819
+ <a id="gem-settings"></a>
9820
+
9821
+ ## Gem.settings
9822
+
9823
+ ```ts
9824
+ readonly settings: GameSettingsApi
9825
+ ```
9826
+
9827
+ Mirror your game's own settings, up to eight — Music, Color help, Game
9828
+ speed — into the Arcade's Gem menu, and hear when the player changes one
9829
+ there. The Arcade's Settings screen lists every one; its fixed quick row
9830
+ takes your first toggle with `icon: 'music'` as Music and your first with
9831
+ `icon: 'eye'` as Color (`quick` is ignored by the Gem Arcade).
9832
+
9833
+ ```js
9834
+ gem.settings.declare([
9835
+ { id: 'music', label: t('Music'), kind: 'toggle', value: music.on, icon: 'music' },
9836
+ ]);
9837
+ gem.settings.onChange(({ id, value }) => {
9838
+ if (id === 'music') setMusic(value === true); // even while paused
9839
+ });
9840
+ ```
9841
+
9842
+ **A mirror, never a replacement: your game still draws its own settings
9843
+ button and screen**, and every setting you declare is on that screen too.
9844
+ Declare again whenever your screen changes a value. Never declare a
9845
+ second mute or vibration switch — the Arcade's quick row has them; your
9846
+ own volume and music or sound-effects levels are fine, and graphics and
9847
+ controls defaults stay the Arcade's (`gem.prefs.recommended`).
9848
+
9849
+ See the guide's "Game settings" section.
9850
+
9301
9851
  <a id="gem-analytics"></a>
9302
9852
 
9303
9853
  ## Gem.analytics
@@ -1,6 +1,6 @@
1
1
  # The server surface — API reference
2
2
 
3
- Generated from `@indiegems/gem-web-sdk/sdk` v13.4.3, 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` v14.0.1, 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