@indiegems/gem-web-sdk 7.5.0 → 7.7.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.
@@ -187,9 +187,9 @@ try {
187
187
 
188
188
  `awaitBridge()` resolves when the bridge leaves `waiting` — connected, refused or closed — or at a
189
189
  bounded timeout (default 10s), with the state it settled on. **Proceed on every outcome.**
190
- `connected` is the Arcade; anything else is a boot without a parent, which your game must survive
191
- anyway. The wait costs nothing when the handshake is quick: it settles the moment the frame
192
- connects. Unframed it is never answered, because no parent ever pushes one.
190
+ `connected` is a Gem host listening; anything else is a boot with no session, which your game must
191
+ survive anyway. The wait costs nothing when the handshake is quick: it settles the moment the frame
192
+ connects, and at once when the page that framed it is refused.
193
193
 
194
194
  The measured stakes, from the first game to hit this on an iPhone: listener up at ~300ms, then a
195
195
  main-thread block — the parent's offer, queued behind the block, was delivered twenty seconds later
@@ -515,8 +515,8 @@ them**, so the whole migration for a stylesheet is one declaration per edge:
515
515
  ```
516
516
 
517
517
  The `env()` fallback is not decoration. Under a parent that has not sent the message — an older
518
- arcade, a third-party embedder, your game opened in a plain tab during development — the
519
- properties are never set and the browser's own answer stands, which is what your game did before.
518
+ arcade or dev host, a third-party embedder — the properties are never set and the browser's own
519
+ answer stands, which is what your game did before.
520
520
  Under a parent that has, the variable wins. One line, correct in both worlds. The four names are
521
521
  `--gem-safe-top`, `--gem-safe-right`, `--gem-safe-bottom` and `--gem-safe-left`.
522
522
 
@@ -538,17 +538,21 @@ the `var()` above, or read `gem.viewport`. The release checklist looks for the b
538
538
 
539
539
  ### The arcade's own controls: reserved areas
540
540
 
541
- On a phone your game is full-bleed, and the arcade keeps one cluster of its own on top of it, in the
542
- **top-left corner** of your frame: a small **Back** tab — the Gem Arcade wordmark — and, beside it,
543
- the player's wallets (Gems, Tickets, their achievement score) while they are
544
- [shown](#the-arcades-wallet-show-it-never-draw-it). The cluster stays in the top-left and runs along
545
- the top row at most about three quarters of the way across on the narrowest phone — but do not
546
- hard-code a size: read it, as below. Those rectangles of your frame are **reserved**: keep essential
547
- UI and every touch target out of them.
541
+ On a phone your game is full-bleed, and the arcade keeps one row of its own across the top of it,
542
+ with the middle left open for a centred camera:
548
543
 
549
- **The arcade never takes the right side.** Put your own settings, pause or menu button **top-right**
550
- — that corner is yours. And **do not put a back arrow of your own top-left**: it would sit under the
551
- arcade's Back tab, which leaves the game, while yours would mean something else.
544
+ - **Top-left: the Back tab** — the Gem Arcade wordmark, always there. **Do not put a back arrow of
545
+ your own top-left**: it would sit under the arcade's tab, which leaves the game, while yours would
546
+ mean something else.
547
+ - **Top-right: the player's wallets** (Gems, Tickets, their achievement score) while your screen
548
+ [shows them](#the-arcades-wallet-show-it-never-draw-it). Put your own settings, pause or menu
549
+ button top-right **below** them, at `top: var(--gem-reserved-tr-height, …)` — and when gameplay
550
+ hides the wallets with `gem.setWalletVisible(false)`, that rectangle shrinks to nothing and your
551
+ button moves up into the corner on its own.
552
+
553
+ Those rectangles of your frame are **reserved**: keep essential UI and every touch target out of
554
+ them. **Never hard-code their size or height.** They differ by phone, and in native fullscreen the
555
+ whole row may rise into the camera band — read them, as below.
552
556
 
553
557
  An inset cannot say that — as a top inset, a tab a few dozen pixels wide would take your whole top
554
558
  strip. So `gem.viewport` also carries the rectangles, in the same CSS pixels of your frame, measured
@@ -567,13 +571,21 @@ from its top-left corner:
567
571
  reserved rectangles reach in from its two edges. Push the corner's UI clear of it:
568
572
 
569
573
  ```css
570
- /* a score in the top-left corner, below the cluster */
574
+ /* settings in the top-right corner, below the wallets — and up in the corner when they are hidden */
575
+ #settings {
576
+ top: max(var(--gem-safe-top, env(safe-area-inset-top, 0px)), var(--gem-reserved-tr-height, 0px));
577
+ right: var(--gem-safe-right, 0px);
578
+ }
579
+ /* a score in the top-left corner, below the tab */
571
580
  #score {
572
581
  top: max(var(--gem-safe-top, env(safe-area-inset-top, 0px)), var(--gem-reserved-tl-height, 0px));
573
582
  left: var(--gem-safe-left, 0px);
574
583
  }
575
- /* or a row along the top, starting after it */
576
- #top-bar { padding-left: var(--gem-reserved-tl-width, 0px); }
584
+ /* or a row along the top, between the two */
585
+ #top-bar {
586
+ padding-left: var(--gem-reserved-tl-width, 0px);
587
+ padding-right: var(--gem-reserved-tr-width, 0px);
588
+ }
577
589
  ```
578
590
 
579
591
  All eight are written on every push, `0px` for a clear corner, so a rotation never leaves a stale
@@ -581,9 +593,9 @@ value; they are never set under an embedder that sends no viewport, which is wha
581
593
  fallback is for. A rectangle belongs to the corner its centre lies nearest to. For a HUD laid out
582
594
  from script, read `gem.viewport.reserved` — `[]` when nothing is covered.
583
595
 
584
- **Lay out against it whenever it changes.** Shown wallets widen the reserved area beside the tab;
585
- hiding them shrinks it back to the tab alone. A wallet the arcade pops up for a moment while they
586
- are hidden never reserves anything — it floats over your game and moves nothing.
596
+ **Lay out against it whenever it changes.** Shown wallets reserve the top-right corner; hiding them
597
+ shrinks it to nothing, and only the tab's top-left rectangle is left. A wallet the arcade pops up for
598
+ a moment while they are hidden never reserves anything — it floats over your game and moves nothing.
587
599
 
588
600
  **Older SDKs get it folded into the top inset.** A game on an SDK from before reserved areas cannot
589
601
  read the rectangles, so the arcade sends it none and instead raises `insets.top` — and so
@@ -764,7 +776,8 @@ and the release checklist checks that it does.
764
776
 
765
777
  The player's platform balances — Gems, Tickets (`ARCADE_TICKETS`) and their achievement score —
766
778
  belong to the Arcade. **Your game never draws one**, and never shows a pending state for one: the
767
- Arcade takes every figure from the platform and draws the wallets itself, beside its Back tab.
779
+ Arcade takes every figure from the platform and draws the wallets itself, in the top-right corner
780
+ of your frame on a phone.
768
781
 
769
782
  **They are shown unless your game hides them.** A game that does nothing has every wallet on show
770
783
  the whole time. The one rule: **hide them during gameplay, show them on your menus.**
@@ -780,10 +793,10 @@ pauseMenu.onOpen = () => gem.setWalletVisible(true);
780
793
  - **It is screen state, not a toggle.** Each call is the whole answer and replaces the last. Call it
781
794
  as often as you like: before the Arcade connects the state is held and sent when it does, and
782
795
  again after any reconnect; a repeat of the current state is not re-sent.
783
- - **Shown wallets take space; a pop does not.** Shown, they widen the
784
- [reserved area](#the-arcades-own-controls-reserved-areas) beside the Back tab, so lay your menu
785
- out against `--gem-reserved-tl-*`; hidden, it shrinks back to the tab. A pop floats over your game
786
- and never moves its layout.
796
+ - **Shown wallets take space; a pop does not.** Shown, they reserve the top-right
797
+ [corner](#the-arcades-own-controls-reserved-areas), so lay your menu out against
798
+ `--gem-reserved-tr-*` — your settings button sits below them; hidden, the corner is yours again and
799
+ the same `var()` moves the button up. A pop floats over your game and never moves its layout.
787
800
  - **Narrowing is optional.** On a screen that sells in one currency — a ticket store — you may show
788
801
  only that one: `gem.setWalletVisible(true, { only: ['ARCADE_TICKETS'] })`, with `'score'` for the
789
802
  achievement score. Use it only there; leaving it out shows every wallet, which is always safe.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indiegems/gem-web-sdk",
3
- "version": "7.5.0",
3
+ "version": "7.7.0",
4
4
  "description": "postMessage bridge contract between gem-web and browser-playable games",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -31,6 +31,10 @@
31
31
  "types": "./dist/server-api.d.ts",
32
32
  "import": "./dist/gem-web-sdk.server-api.js"
33
33
  },
34
+ "./function": {
35
+ "types": "./dist/function.d.ts",
36
+ "import": "./dist/gem-web-sdk.function.js"
37
+ },
34
38
  "./schema": "./schema/bridge.v1.json",
35
39
  "./brand/*": "./brand/*"
36
40
  },
@@ -45,6 +49,7 @@
45
49
  "docs/*.md",
46
50
  "docs/manifest.json",
47
51
  "docs/api/*.md",
48
- "docs/api/reference.json"
52
+ "docs/api/reference.json",
53
+ "CHANGELOG.md"
49
54
  ]
50
55
  }
@@ -894,7 +894,7 @@
894
894
  "AMENDED, DELIBERATELY: this message once carried insets only. It now also",
895
895
  "carries `reserved`, rectangles of the frame covered by the parent's own",
896
896
  "controls floating over the game (a Back tab in a corner, the wallet chips",
897
- "shown beside it). An inset can only describe a full-width or full-height band,",
897
+ "shown in another). An inset can only describe a full-width or full-height band,",
898
898
  "and a corner tab expressed as a top inset would take the whole top strip",
899
899
  "from a full-bleed game to clear a control a few dozen pixels wide. A",
900
900
  "rectangle says exactly which part, and still says nothing about what the",