@indiegems/gem-web-sdk 13.4.3 → 14.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.
@@ -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.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
 
@@ -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,470 @@ 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
+ <a id="gemgametogglesetting"></a>
7316
+
7317
+ ## GemGameToggleSetting
7318
+
7319
+ ```ts
7320
+ interface GemGameToggleSetting
7321
+ ```
7322
+
7323
+ An on/off setting — Music, Color help.
7324
+
7325
+ <a id="gemgametogglesetting-id"></a>
7326
+
7327
+ ## GemGameToggleSetting.id
7328
+
7329
+ ```ts
7330
+ readonly id: string
7331
+ ```
7332
+
7333
+ Your own name for the setting — 1 to 40 of `A-Z a-z 0-9 _ -`, unique in
7334
+ one declaration. It is what [GemGameSettingChange.id](#gemgamesettingchange-id) carries back.
7335
+
7336
+ <a id="gemgametogglesetting-label"></a>
7337
+
7338
+ ## GemGameToggleSetting.label
7339
+
7340
+ ```ts
7341
+ readonly label: string
7342
+ ```
7343
+
7344
+ What the player reads, 1 to 40 characters, **already in the player's
7345
+ language** (`gem.prefs.locale`): the Arcade does not translate it. Cut at
7346
+ 40 characters.
7347
+
7348
+ <a id="gemgametogglesetting-icon"></a>
7349
+
7350
+ ## GemGameToggleSetting.icon
7351
+
7352
+ ```ts
7353
+ readonly icon?: GemGameSettingIcon
7354
+ ```
7355
+
7356
+ One of the Arcade's icon codes; a code this SDK does not know is left out
7357
+ (with a warning) and the setting is kept with the generic glyph.
7358
+
7359
+ <a id="gemgametogglesetting-kind"></a>
7360
+
7361
+ ## GemGameToggleSetting.kind
7362
+
7363
+ ```ts
7364
+ readonly kind: "toggle"
7365
+ ```
7366
+
7367
+ `'toggle'`: what kind of setting this is.
7368
+
7369
+ <a id="gemgametogglesetting-value"></a>
7370
+
7371
+ ## GemGameToggleSetting.value
7372
+
7373
+ ```ts
7374
+ readonly value: boolean
7375
+ ```
7376
+
7377
+ Whether it is on now.
7378
+
7379
+ <a id="gemgametogglesetting-quick"></a>
7380
+
7381
+ ## GemGameToggleSetting.quick
7382
+
7383
+ ```ts
7384
+ readonly quick?: boolean
7385
+ ```
7386
+
7387
+ Ask for this toggle in the menu's quick row, beside the Arcade's own Sound
7388
+ and Vibration. The first two toggles that ask get it; a third is shown only
7389
+ in the settings list.
7390
+
7391
+ <a id="gemgameslidersetting"></a>
7392
+
7393
+ ## GemGameSliderSetting
7394
+
7395
+ ```ts
7396
+ interface GemGameSliderSetting
7397
+ ```
7398
+
7399
+ A number between two ends — Music volume, Game speed.
7400
+
7401
+ <a id="gemgameslidersetting-id"></a>
7402
+
7403
+ ## GemGameSliderSetting.id
7404
+
7405
+ ```ts
7406
+ readonly id: string
7407
+ ```
7408
+
7409
+ Your own name for the setting — 1 to 40 of `A-Z a-z 0-9 _ -`, unique in
7410
+ one declaration. It is what [GemGameSettingChange.id](#gemgamesettingchange-id) carries back.
7411
+
7412
+ <a id="gemgameslidersetting-label"></a>
7413
+
7414
+ ## GemGameSliderSetting.label
7415
+
7416
+ ```ts
7417
+ readonly label: string
7418
+ ```
7419
+
7420
+ What the player reads, 1 to 40 characters, **already in the player's
7421
+ language** (`gem.prefs.locale`): the Arcade does not translate it. Cut at
7422
+ 40 characters.
7423
+
7424
+ <a id="gemgameslidersetting-icon"></a>
7425
+
7426
+ ## GemGameSliderSetting.icon
7427
+
7428
+ ```ts
7429
+ readonly icon?: GemGameSettingIcon
7430
+ ```
7431
+
7432
+ One of the Arcade's icon codes; a code this SDK does not know is left out
7433
+ (with a warning) and the setting is kept with the generic glyph.
7434
+
7435
+ <a id="gemgameslidersetting-kind"></a>
7436
+
7437
+ ## GemGameSliderSetting.kind
7438
+
7439
+ ```ts
7440
+ readonly kind: "slider"
7441
+ ```
7442
+
7443
+ `'slider'`: what kind of setting this is.
7444
+
7445
+ <a id="gemgameslidersetting-value"></a>
7446
+
7447
+ ## GemGameSliderSetting.value
7448
+
7449
+ ```ts
7450
+ readonly value: number
7451
+ ```
7452
+
7453
+ The number now. Clamped into `[min, max]` and snapped onto `step` before it
7454
+ is sent.
7455
+
7456
+ <a id="gemgameslidersetting-min"></a>
7457
+
7458
+ ## GemGameSliderSetting.min
7459
+
7460
+ ```ts
7461
+ readonly min?: number
7462
+ ```
7463
+
7464
+ The lowest value, `0` when left out. Within ±1 000 000, below `max`.
7465
+
7466
+ <a id="gemgameslidersetting-max"></a>
7467
+
7468
+ ## GemGameSliderSetting.max
7469
+
7470
+ ```ts
7471
+ readonly max?: number
7472
+ ```
7473
+
7474
+ The highest value, `100` when left out. Within ±1 000 000, above `min`.
7475
+
7476
+ <a id="gemgameslidersetting-step"></a>
7477
+
7478
+ ## GemGameSliderSetting.step
7479
+
7480
+ ```ts
7481
+ readonly step?: number
7482
+ ```
7483
+
7484
+ The increment from `min`, `1` when left out. Greater than `0`.
7485
+
7486
+ <a id="gemgamesettingoption"></a>
7487
+
7488
+ ## GemGameSettingOption
7489
+
7490
+ ```ts
7491
+ interface GemGameSettingOption
7492
+ ```
7493
+
7494
+ One answer of a [GemGameChoiceSetting](#gemgamechoicesetting).
7495
+
7496
+ <a id="gemgamesettingoption-id"></a>
7497
+
7498
+ ## GemGameSettingOption.id
7499
+
7500
+ ```ts
7501
+ readonly id: string
7502
+ ```
7503
+
7504
+ Your own name for the answer, 1 to 40 of `A-Z a-z 0-9 _ -`.
7505
+
7506
+ <a id="gemgamesettingoption-label"></a>
7507
+
7508
+ ## GemGameSettingOption.label
7509
+
7510
+ ```ts
7511
+ readonly label: string
7512
+ ```
7513
+
7514
+ What the player reads, 1 to 40 characters, already translated.
7515
+
7516
+ <a id="gemgamechoicesetting"></a>
7517
+
7518
+ ## GemGameChoiceSetting
7519
+
7520
+ ```ts
7521
+ interface GemGameChoiceSetting
7522
+ ```
7523
+
7524
+ One of two to four answers — Difficulty: Easy, Normal, Hard.
7525
+
7526
+ <a id="gemgamechoicesetting-id"></a>
7527
+
7528
+ ## GemGameChoiceSetting.id
7529
+
7530
+ ```ts
7531
+ readonly id: string
7532
+ ```
7533
+
7534
+ Your own name for the setting — 1 to 40 of `A-Z a-z 0-9 _ -`, unique in
7535
+ one declaration. It is what [GemGameSettingChange.id](#gemgamesettingchange-id) carries back.
7536
+
7537
+ <a id="gemgamechoicesetting-label"></a>
7538
+
7539
+ ## GemGameChoiceSetting.label
7540
+
7541
+ ```ts
7542
+ readonly label: string
7543
+ ```
7544
+
7545
+ What the player reads, 1 to 40 characters, **already in the player's
7546
+ language** (`gem.prefs.locale`): the Arcade does not translate it. Cut at
7547
+ 40 characters.
7548
+
7549
+ <a id="gemgamechoicesetting-icon"></a>
7550
+
7551
+ ## GemGameChoiceSetting.icon
7552
+
7553
+ ```ts
7554
+ readonly icon?: GemGameSettingIcon
7555
+ ```
7556
+
7557
+ One of the Arcade's icon codes; a code this SDK does not know is left out
7558
+ (with a warning) and the setting is kept with the generic glyph.
7559
+
7560
+ <a id="gemgamechoicesetting-kind"></a>
7561
+
7562
+ ## GemGameChoiceSetting.kind
7563
+
7564
+ ```ts
7565
+ readonly kind: "choice"
7566
+ ```
7567
+
7568
+ `'choice'`: what kind of setting this is.
7569
+
7570
+ <a id="gemgamechoicesetting-value"></a>
7571
+
7572
+ ## GemGameChoiceSetting.value
7573
+
7574
+ ```ts
7575
+ readonly value: string
7576
+ ```
7577
+
7578
+ The `id` of the option chosen now.
7579
+
7580
+ <a id="gemgamechoicesetting-options"></a>
7581
+
7582
+ ## GemGameChoiceSetting.options
7583
+
7584
+ ```ts
7585
+ readonly options: readonly GemGameSettingOption[]
7586
+ ```
7587
+
7588
+ Two to four answers, ids unique. A fifth and later are left out.
7589
+
7590
+ <a id="gemgamesetting"></a>
7591
+
7592
+ ## GemGameSetting
7593
+
7594
+ ```ts
7595
+ type GemGameSetting = GemGameToggleSetting | GemGameSliderSetting | GemGameChoiceSetting
7596
+ ```
7597
+
7598
+ One of your game's settings, as `gem.settings.declare` mirrors it into the
7599
+ Arcade's menu: a toggle, a slider or a choice.
7600
+
7601
+ <a id="gemgamesettingchange"></a>
7602
+
7603
+ ## GemGameSettingChange
7604
+
7605
+ ```ts
7606
+ interface GemGameSettingChange
7607
+ ```
7608
+
7609
+ The player changed one of your declared settings in the Arcade's menu.
7610
+
7611
+ <a id="gemgamesettingchange-id"></a>
7612
+
7613
+ ## GemGameSettingChange.id
7614
+
7615
+ ```ts
7616
+ readonly id: string
7617
+ ```
7618
+
7619
+ The setting's `id`, from your latest declaration.
7620
+
7621
+ <a id="gemgamesettingchange-value"></a>
7622
+
7623
+ ## GemGameSettingChange.value
7624
+
7625
+ ```ts
7626
+ readonly value: GemGameSettingValue
7627
+ ```
7628
+
7629
+ The new value, of the setting's kind: a `boolean` for a toggle, a `number`
7630
+ inside a slider's range and on its step, an option's `id` for a choice.
7631
+
7632
+ <a id="gamesettingsapi"></a>
7633
+
7634
+ ## GameSettingsApi
7635
+
7636
+ ```ts
7637
+ interface GameSettingsApi
7638
+ ```
7639
+
7640
+ `gem.settings` — mirror up to eight of your game's own settings into the
7641
+ Arcade's Gem menu. Your own settings button and screen stay: this is a
7642
+ second door to a few of the same settings, never the only one.
7643
+
7644
+ <a id="gamesettingsapi-declare"></a>
7645
+
7646
+ ## GameSettingsApi.declare
7647
+
7648
+ ```ts
7649
+ declare(settings: readonly GemGameSetting[]): boolean
7650
+ ```
7651
+
7652
+ Show up to eight of your settings in the Arcade's menu, in this order — the
7653
+ whole list each time, the latest call winning. `declare([])` takes them
7654
+ all back out.
7655
+
7656
+ ```js
7657
+ gem.settings.declare([
7658
+ { id: 'music', label: t('Music'), kind: 'toggle', value: music.on, quick: true, icon: 'music' },
7659
+ { id: 'speed', label: t('Game speed'), kind: 'slider', value: speed, min: 0.5, max: 2, step: 0.25 },
7660
+ ]);
7661
+ ```
7662
+
7663
+ **Keep your own settings button and screen** — top-right, on every screen.
7664
+ This mirrors a few of those settings; it never replaces them, and an
7665
+ embedder that draws no game settings shows none of it.
7666
+
7667
+ **Declare again whenever your own screen changes a value**, so the menu
7668
+ never shows a stale one. Mark at most two toggles `quick` (good ones:
7669
+ Music, Sound effects, Color help). **Never declare the Arcade's own
7670
+ settings** — master volume or mute, vibration, graphics quality, controls:
7671
+ the Arcade already has them and they reach you as `gem.prefs`.
7672
+
7673
+ An entry that breaks a rule is left out, with a warning through your
7674
+ `log`; nothing throws.
7675
+
7676
+ | Parameter | Type | Description |
7677
+ | --- | --- | --- |
7678
+ | `settings` | `readonly GemGameSetting[]` | Up to eight settings, in the order to show them. |
7679
+
7680
+ **Returns.** `true` when the Arcade has been told, or will be within half a
7681
+ second; `false` before the bridge is up (the list is held and sent when
7682
+ it connects), under an embedder that draws no game settings, and for an
7683
+ argument that is not an array.
7684
+
7685
+ <a id="gamesettingsapi-onchange"></a>
7686
+
7687
+ ## GameSettingsApi.onChange
7688
+
7689
+ ```ts
7690
+ onChange(handler: (change: GemGameSettingChange) => void): () => void
7691
+ ```
7692
+
7693
+ Called when the player changes one of your declared settings in the
7694
+ Arcade's menu. Apply it at once, **even while paused** — the menu holds
7695
+ the pause, and the player should hear the music stop while it is open —
7696
+ and keep it where you keep that setting's other changes.
7697
+
7698
+ ```js
7699
+ gem.settings.onChange(({ id, value }) => {
7700
+ if (id === 'music') setMusic(value === true);
7701
+ });
7702
+ ```
7703
+
7704
+ The SDK has already written the new value into your declaration, so there
7705
+ is no need to declare again for this change.
7706
+
7707
+ | Parameter | Type |
7708
+ | --- | --- |
7709
+ | `handler` | `(change: GemGameSettingChange) => void` |
7710
+
7711
+ **Returns.** A function that removes the handler.
7712
+
7225
7713
  <a id="arcade_embedders"></a>
7226
7714
 
7227
7715
  ## ARCADE_EMBEDDERS
@@ -9298,6 +9786,35 @@ camera.pitch += t.pitch;
9298
9786
 
9299
9787
  See the guide's "Camera and look controls" section.
9300
9788
 
9789
+ <a id="gem-settings"></a>
9790
+
9791
+ ## Gem.settings
9792
+
9793
+ ```ts
9794
+ readonly settings: GameSettingsApi
9795
+ ```
9796
+
9797
+ Mirror up to eight of your game's own settings — Music, Color help, Game
9798
+ speed — into the Arcade's Gem menu, and hear when the player changes one
9799
+ there. Up to two toggles can sit in the menu's quick row.
9800
+
9801
+ ```js
9802
+ gem.settings.declare([
9803
+ { id: 'music', label: t('Music'), kind: 'toggle', value: music.on, quick: true, icon: 'music' },
9804
+ ]);
9805
+ gem.settings.onChange(({ id, value }) => {
9806
+ if (id === 'music') setMusic(value === true); // even while paused
9807
+ });
9808
+ ```
9809
+
9810
+ **A mirror, never a replacement: your game still draws its own settings
9811
+ button and screen**, and every setting you declare is on that screen too.
9812
+ Declare again whenever your screen changes a value. Never declare the
9813
+ Arcade's own settings — master volume or mute, vibration, graphics,
9814
+ controls; they reach you as `gem.prefs`.
9815
+
9816
+ See the guide's "Game settings" section.
9817
+
9301
9818
  <a id="gem-analytics"></a>
9302
9819
 
9303
9820
  ## 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.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