@hopple/sdk 1.0.0-next.1 → 1.0.0-next.13

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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/protocol/src/analytics.d.ts
1
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/protocol/src/analytics.d.ts
2
2
  /**
3
3
  * What a game says happened.
4
4
  *
@@ -29,7 +29,7 @@ type AnalyticsValue = string | number | boolean;
29
29
  /** @group Analytics */
30
30
  type AnalyticsProps = Record<string, AnalyticsValue>;
31
31
  //#endregion
32
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/protocol/src/errors.d.ts
32
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/protocol/src/errors.d.ts
33
33
  /**
34
34
  * How a call fails.
35
35
  *
@@ -115,7 +115,7 @@ declare class BridgeError extends Error {
115
115
  constructor(error: ProtocolError);
116
116
  }
117
117
  //#endregion
118
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/protocol/src/input.d.ts
118
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/protocol/src/input.d.ts
119
119
  /**
120
120
  * What the host says about how this game is being played.
121
121
  *
@@ -175,7 +175,7 @@ type InputBinding = {
175
175
  label?: string;
176
176
  };
177
177
  //#endregion
178
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/protocol/src/pause.d.ts
178
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/protocol/src/pause.d.ts
179
179
  /**
180
180
  * Whether the game is holding still, which the host may ask for and only the
181
181
  * game can answer.
@@ -233,7 +233,7 @@ type PauseState =
233
233
  */
234
234
  'unpausable';
235
235
  //#endregion
236
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/protocol/src/save.d.ts
236
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/protocol/src/save.d.ts
237
237
  /**
238
238
  * The one thing a game may keep.
239
239
  *
@@ -255,7 +255,8 @@ type PauseState =
255
255
  * game may assume anywhere, forever, because a game ships and is never updated.
256
256
  */
257
257
  /**
258
- * What a game may write anywhere, in bytes of `state` as UTF-8.
258
+ * What a game may write anywhere, in bytes: of `state` as UTF-8, or of the
259
+ * bytes a game handed over where it handed bytes.
259
260
  *
260
261
  * The floor rather than the cap: a host that will take more says so in the
261
262
  * welcome, and a game that never asks still knows this much is safe. 64 KiB is
@@ -284,7 +285,7 @@ type SaveStored = {
284
285
  bytes: number;
285
286
  };
286
287
  //#endregion
287
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/protocol/src/score.d.ts
288
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/protocol/src/score.d.ts
288
289
  /**
289
290
  * What the host says came of it.
290
291
  *
@@ -322,7 +323,7 @@ type ScoreStanding = {
322
323
  of?: number;
323
324
  };
324
325
  //#endregion
325
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/protocol/src/share.d.ts
326
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/protocol/src/share.d.ts
326
327
  /**
327
328
  * A link to this game, offered to the player by the host.
328
329
  *
@@ -376,7 +377,8 @@ type ScoreStanding = {
376
377
  * its first frame. See `ShareWelcome`.
377
378
  */
378
379
  /**
379
- * What every host carries, in bytes of `data` as UTF-8.
380
+ * What every host carries, in bytes of `data`: as UTF-8, or the bytes a game
381
+ * handed over where it handed bytes.
380
382
  *
381
383
  * The floor rather than the cap: a host may take more and none may take less,
382
384
  * so a game that stays under this is never refused for its size anywhere. It is
@@ -421,7 +423,7 @@ type ShareMeta = {
421
423
  [key: string]: ShareMetaValue;
422
424
  };
423
425
  //#endregion
424
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/protocol/src/methods.d.ts
426
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/protocol/src/methods.d.ts
425
427
  /**
426
428
  * How far a game has got with its own preparation.
427
429
  *
@@ -601,7 +603,7 @@ type DeviceInfo = {
601
603
  tier: DeviceTier;
602
604
  };
603
605
  //#endregion
604
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/protocol/src/listeners.d.ts
606
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/protocol/src/listeners.d.ts
605
607
  /**
606
608
  * The one way anything here is listened to: `on(listener)` hands back the
607
609
  * function that stops it.
@@ -630,7 +632,7 @@ type DeviceInfo = {
630
632
  */
631
633
  type Unsubscribe = () => void;
632
634
  //#endregion
633
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/manifest/src/manifest.d.ts
635
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/manifest/src/manifest.d.ts
634
636
  /**
635
637
  * The API a game is written against: `M.m`, a major and the least minor it
636
638
  * needs, or `next`, the pre-releases of the next stable release.
@@ -849,6 +851,26 @@ type ScoreBoard = {
849
851
  direction: ScoreDirection;
850
852
  /** See `ScoreFormat`. Absent means `integer`. */
851
853
  format?: ScoreFormat;
854
+ /**
855
+ * Which board, of the ones this id has named. Absent is `1`.
856
+ *
857
+ * **Raising it starts the board again from nobody.** The runs under the
858
+ * version before are kept and no longer counted, shown or ranked, so a board
859
+ * whose scores stopped being comparable — new levels, a new rule — begins
860
+ * again under the id the game already submits to.
861
+ *
862
+ * **Only a change to what a stored score means needs it.** The title changes
863
+ * freely, and so does the format between `integer` and `decimal`. Once the
864
+ * board holds scores, turning it around (`direction`) or writing it in
865
+ * another unit (to or from `duration-ms`) is refused at the same version.
866
+ * Going back to a version declared before brings its runs back, so it is
867
+ * held to what that version was.
868
+ *
869
+ * @asType integer
870
+ * @minimum 1
871
+ * @maximum 1000
872
+ */
873
+ version?: number;
852
874
  };
853
875
  /**
854
876
  * The boards this game keeps a score on.
@@ -1012,6 +1034,28 @@ type Achievement = {
1012
1034
  secret?: boolean;
1013
1035
  /** Present makes this measured rather than flagged. See `AchievementProgress`. */
1014
1036
  progress?: AchievementProgress;
1037
+ /**
1038
+ * Which achievement, of the ones this id has named. Absent is `1`.
1039
+ *
1040
+ * **Raising it starts the achievement again for everybody.** What players
1041
+ * reported and unlocked under the version before is kept and no longer
1042
+ * counted, so it is earned afresh under the id the game already reports to.
1043
+ *
1044
+ * **Only a change to what a stored value means needs it.** The words change
1045
+ * freely — title, detail, icon, secret — and so does the target, and a tier
1046
+ * added after the last one: progress is kept as the number reported, which
1047
+ * stays true when the goal moves, and a player who unlocked it keeps it. At
1048
+ * the same version, a published achievement may not turn from a flag into a
1049
+ * measure or back, turn its direction around, write its value in another
1050
+ * unit (to or from `duration-ms`), or move or drop a tier it already has.
1051
+ * Going back to a version declared before brings back what was earned under
1052
+ * it, so it is held to what that version was.
1053
+ *
1054
+ * @asType integer
1055
+ * @minimum 1
1056
+ * @maximum 1000
1057
+ */
1058
+ version?: number;
1015
1059
  };
1016
1060
  /**
1017
1061
  * The achievements this game keeps for a player.
@@ -1077,7 +1121,7 @@ type InputDeviceSet = InputDevice[];
1077
1121
  * doubled. A thumbstick is not one of these; see `InputStick`.
1078
1122
  *
1079
1123
  * @group Input
1080
- * @pattern ^(?:key\.(?!Escape$)(?=.{1,48}$)[A-Za-z][A-Za-z0-9]*|pointer\.(?:primary|secondary)|mouse\.(?:left|middle|right)|touch\.tap|controls\.(?=.{1,48}$)[a-z0-9]+(?:[_-][a-z0-9]+)*|pad\.(?:north|south|east|west|start|select)|pad\.(?:left|right)\.(?:north|south|east|west|bumper|trigger))$
1124
+ * @pattern ^(?:key\.(?!Escape$)(?=.{1,48}$)[A-Za-z][A-Za-z0-9]*|pointer\.(?:primary|secondary)|mouse\.(?:left|middle|right|wheelup|wheeldown)|touch\.tap|controls\.(?=.{1,48}$)[a-z0-9]+(?:[_-][a-z0-9]+)*|pad\.(?:north|south|east|west|start|select)|pad\.(?:left|right)\.(?:north|south|east|west|bumper|trigger))$
1081
1125
  * @errorMessage is not a binding this SDK knows (a thumbstick is read rather than bound, and Escape is the host's key)
1082
1126
  */
1083
1127
  type InputBinding$1 = string;
@@ -1153,7 +1197,7 @@ type PlayerBinding = string;
1153
1197
  * mouse button.
1154
1198
  *
1155
1199
  * @group Input
1156
- * @pattern ^(?:key\.(?!Escape$)(?=.{1,48}$)[A-Za-z][A-Za-z0-9]*|mouse\.(?:left|middle|right))$
1200
+ * @pattern ^(?:key\.(?!Escape$)(?=.{1,48}$)[A-Za-z][A-Za-z0-9]*|mouse\.(?:left|middle|right|wheelup|wheeldown))$
1157
1201
  * @errorMessage must be a key or a mouse button (and Escape is the host's key)
1158
1202
  */
1159
1203
  type KeyboardBinding = string;
@@ -1309,6 +1353,20 @@ type ControlSlot = {
1309
1353
  as?: InputStick | Record<string, InputBinding$1>;
1310
1354
  /** `thumbstick` only. See `ControlAxis`. Absent, the stick moves both ways. */
1311
1355
  axis?: ControlAxis;
1356
+ /**
1357
+ * How big this control is next to the layout's others: `1.25` for a jump
1358
+ * button a thumb lands on without looking, `0.8` for one pressed now and then.
1359
+ * Absent, 1.
1360
+ *
1361
+ * A size in the layout rather than in the game's stylesheet, because whether
1362
+ * the layout fits on a small screen is worked out from it before the
1363
+ * controls are drawn. A game's stylesheet changes how they look, never how
1364
+ * much of the screen they answer in.
1365
+ *
1366
+ * @minimum 0.75
1367
+ * @maximum 1.5
1368
+ */
1369
+ scale?: number;
1312
1370
  };
1313
1371
  /**
1314
1372
  * The one direction an on-screen thumbstick moves in: `x` across, `y` up and
@@ -1459,6 +1517,53 @@ type PreviewsDeclaration = {
1459
1517
  */
1460
1518
  network?: PreviewRevision;
1461
1519
  };
1520
+ /**
1521
+ * What kind of game this is, as one word from a list every game shares.
1522
+ *
1523
+ * A closed list, because a client files games under these and has to name each
1524
+ * one in front of a player: left to free text, one kind of game becomes three
1525
+ * spellings of it with a game each. The list only grows, since a published
1526
+ * manifest has to stay valid. Whoever reads one may be older than the game, and
1527
+ * ignores a word it does not know.
1528
+ *
1529
+ * `local-multiplayer` and `online-multiplayer` say how a game is played rather
1530
+ * than what it is, and only count where the manifest bears them out: see
1531
+ * `declaredGenres`.
1532
+ *
1533
+ * @group Manifest
1534
+ * @category Useful
1535
+ */
1536
+ type GameGenre = 'racing' | 'shooter' | 'platformer' | 'puzzle' | 'arcade' | 'physics' | 'roguelike' | 'strategy' | 'building' | 'idle' | 'sports' | 'horror' | 'stealth' | 'fighting' | 'casual' | 'simulation' | 'adventure' | 'rhythm' | 'rpg' | 'local-multiplayer' | 'online-multiplayer';
1537
+ /**
1538
+ * A few seconds of real play, which Explore shows in place of the still cover,
1539
+ * played muted, over and over. See `GameManifest.clip`.
1540
+ *
1541
+ * @group Manifest
1542
+ * @category Useful
1543
+ */
1544
+ type ClipDeclaration = {
1545
+ /**
1546
+ * The clip: the path of an MP4 file beside the config. H.264 with no sound
1547
+ * track, 2 to 15 seconds long, its longest side at most 1280 and its
1548
+ * shortest at most 720, saved with "fast start", and at most
1549
+ * `CLIP_MAX_BYTES`. `clipProblems` says what is wrong with one.
1550
+ *
1551
+ * @pattern ^(?!/)(?!.*\.\.)[A-Za-z0-9._/-]+\.mp4$
1552
+ * @maxLength 200
1553
+ * @errorMessage must be the path of an .mp4 file beside the config, like "clip.mp4"
1554
+ */
1555
+ video: string;
1556
+ /**
1557
+ * The clip's first frame, as a PNG, JPEG or WebP file beside the config,
1558
+ * shown until the clip plays and wherever it cannot. At most
1559
+ * `POSTER_MAX_BYTES`.
1560
+ *
1561
+ * @pattern ^(?!/)(?!.*\.\.)[A-Za-z0-9._/-]+\.(?:png|jpe?g|webp)$
1562
+ * @maxLength 200
1563
+ * @errorMessage must be the path of a .png, .jpg or .webp file beside the config, like "clip.png"
1564
+ */
1565
+ poster: string;
1566
+ };
1462
1567
  /**
1463
1568
  * Publishing refuses a key the manifest's API does not know; a host reading a
1464
1569
  * published one ignores it (see `validateManifest`).
@@ -1498,8 +1603,19 @@ type GameManifest = {
1498
1603
  * @errorMessage must be a handle: lowercase letters, digits and hyphens
1499
1604
  */
1500
1605
  owner?: string;
1606
+ /**
1607
+ * `false` for a game that is never to be uploaded: an example, a test, a
1608
+ * game kept to one machine. `hopple dev` and `hopple check` still run it;
1609
+ * `hopple upload` and `hopple publish` refuse it, and so does a server it
1610
+ * is sent to another way. Absent, it may be published.
1611
+ *
1612
+ * @category Useful
1613
+ */
1614
+ publishable?: boolean;
1501
1615
  /**
1502
1616
  * The game's own version, `MAJOR.MINOR.PATCH`. Ours to read, never to parse for meaning.
1617
+ * People see it beside the build the server numbers each upload with, and
1618
+ * each published version needs one no other published version of the game has.
1503
1619
  *
1504
1620
  * @category Important
1505
1621
  * @pattern ^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$
@@ -1523,20 +1639,46 @@ type GameManifest = {
1523
1639
  */
1524
1640
  description?: string;
1525
1641
  /**
1526
- * A picture of the game, shown wherever a link to it is pasted — a chat, a
1527
- * post, a message.
1642
+ * What kind of game it is, the main one first. Read by whoever files it in a
1643
+ * catalogue, which never runs it. At most `GENRE_MAX`, not counting
1644
+ * `local-multiplayer` and `online-multiplayer`: a game that is every kind
1645
+ * tells a player nothing. The publisher's claim, taken at its word, except
1646
+ * for those two. See `GameGenre`.
1647
+ *
1648
+ * @category Useful
1649
+ * @minItems 1
1650
+ * @maxItems 5
1651
+ */
1652
+ genres?: GameGenre[];
1653
+ /**
1654
+ * A picture of the game: its cover on Explore's shelves and in a player's
1655
+ * inbox, and what a link to it shows wherever it is pasted — a chat, a post,
1656
+ * a message.
1528
1657
  *
1529
1658
  * The path of a PNG, JPEG or WebP file, relative to the config the manifest
1530
1659
  * is in, and at most `COVER_MAX_BYTES`. `hopple publish` uploads it beside
1531
- * the game. 1200 × 630 is the shape every platform shows whole; without one,
1532
- * a link shows Hopple's own card.
1660
+ * the game, and a server takes no upload without one: only a game that is
1661
+ * never uploaded leaves it out. 1200 × 630 is the shape every platform shows
1662
+ * whole; `hopple smoke --cover` makes one from the game itself.
1533
1663
  *
1534
- * @category Useful
1664
+ * @category Important
1535
1665
  * @pattern ^(?!/)(?!.*\.\.)[A-Za-z0-9._/-]+\.(?:png|jpe?g|webp)$
1536
1666
  * @maxLength 200
1537
1667
  * @errorMessage must be the path of a .png, .jpg or .webp file beside the config, like "cover.png"
1538
1668
  */
1539
1669
  cover?: string;
1670
+ /**
1671
+ * A few seconds of real play, which Explore shows in place of the still
1672
+ * `cover`, played muted. `poster` is the clip's first frame, shown until it
1673
+ * plays. The clip is an H.264 MP4 with no sound track, 2 to 15 seconds long,
1674
+ * no larger than 1280 × 720 either way up, saved with "fast start", and at
1675
+ * most `CLIP_MAX_BYTES`; the poster at most `POSTER_MAX_BYTES`. Both are
1676
+ * paths beside the config, and `hopple publish` uploads them with the game.
1677
+ * See `ClipDeclaration`.
1678
+ *
1679
+ * @category Useful
1680
+ */
1681
+ clip?: ClipDeclaration;
1540
1682
  /** @category Important */
1541
1683
  orientation: Orientation;
1542
1684
  /**
@@ -1596,53 +1738,6 @@ type GameManifest = {
1596
1738
  */
1597
1739
  previews?: PreviewsDeclaration;
1598
1740
  };
1599
- /**
1600
- * A game project's hopple config: `hopple.config.ts`, `hopple.config.js` or
1601
- * `hopple.config.json`, beside the project's `package.json`.
1602
- *
1603
- * Everything the `hopple` command line needs to know about a project, in one
1604
- * place: how to build the game, which built file is the game, and the manifest
1605
- * that says what the game is. Only the manifest leaves the machine, uploaded
1606
- * beside the page as `game.manifest.json`. A TypeScript or JavaScript config
1607
- * default-exports one of these; a JSON config is one.
1608
- *
1609
- * ```ts
1610
- * import type { HoppleConfig } from '@hopple/sdk';
1611
- *
1612
- * export default {
1613
- * build: 'npm run build',
1614
- * page: 'dist/index.html',
1615
- * manifest: { id: 'my-game', version: '0.1.0', title: 'My Game', orientation: 'portrait', audio: null },
1616
- * } satisfies HoppleConfig;
1617
- * ```
1618
- *
1619
- * @group Manifest
1620
- * @category Important
1621
- */
1622
- type HoppleConfig = {
1623
- /** Where an editor finds this file's schema, in a JSON config. Read by nothing else. */
1624
- $schema?: string;
1625
- /**
1626
- * The command that builds the game, run in the config's directory before
1627
- * `hopple dev`, `check` and `publish` use it, so none of them sees a stale
1628
- * build. Leave it out for a game with nothing to build.
1629
- *
1630
- * @pattern \S
1631
- * @errorMessage must be the command that builds the game, like "npm run build"
1632
- */
1633
- build?: string;
1634
- /**
1635
- * The built page, relative to the config. The directory it is in is
1636
- * published, with the page as its `index.html`; a page beside its config is
1637
- * published alone, so it has to hold the whole game.
1638
- *
1639
- * @pattern \.[Hh][Tt][Mm][Ll]?$
1640
- * @errorMessage must be the built .html file, like "dist/index.html"
1641
- */
1642
- page: string;
1643
- /** What the game is. Uploaded beside the page, and read by every host before the game runs. */
1644
- manifest: ProjectManifest;
1645
- };
1646
1741
  /**
1647
1742
  * The manifest as a project's config holds it: `api` may be left out, for the
1648
1743
  * CLI to fill from the installed `@hopple/sdk`.
@@ -1654,7 +1749,7 @@ type ProjectManifest = Omit<GameManifest, 'api'> & {
1654
1749
  api?: ApiVersion;
1655
1750
  };
1656
1751
  //#endregion
1657
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/achievements.d.ts
1752
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/game/src/achievements.d.ts
1658
1753
  /**
1659
1754
  * Where this player stands on one achievement.
1660
1755
  *
@@ -1752,7 +1847,7 @@ type Achievements<Id extends string = string, Measured extends string = Id> = {
1752
1847
  progress(id: Measured, value: number): void;
1753
1848
  };
1754
1849
  //#endregion
1755
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/analytics.d.ts
1850
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/game/src/analytics.d.ts
1756
1851
  /**
1757
1852
  * @group Analytics
1758
1853
  * @category Important
@@ -1769,7 +1864,7 @@ type Analytics<Events extends object = Record<string, AnalyticsProps>> = {
1769
1864
  track<Event extends keyof Events & string>(name: Event, props?: Events[Event]): void;
1770
1865
  };
1771
1866
  //#endregion
1772
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/audio.d.ts
1867
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/game/src/audio.d.ts
1773
1868
  /**
1774
1869
  * Something about the game's sound changed: the host's order, the player's
1775
1870
  * mute, a fader. Read what you need — `volume(channel)`, `allowed` — and apply
@@ -1860,7 +1955,7 @@ type Audio<Channel extends string = string> = {
1860
1955
  media(element: HTMLMediaElement, channel?: Channel): Unsubscribe;
1861
1956
  };
1862
1957
  //#endregion
1863
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/info.d.ts
1958
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/game/src/info.d.ts
1864
1959
  /**
1865
1960
  * What the host said, frozen.
1866
1961
  *
@@ -1878,7 +1973,7 @@ type Info = Readonly<{
1878
1973
  device: Readonly<DeviceInfo>;
1879
1974
  }>;
1880
1975
  //#endregion
1881
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/layout.d.ts
1976
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/game/src/layout.d.ts
1882
1977
  /**
1883
1978
  * How much of each edge belongs to the host. CSS pixels.
1884
1979
  *
@@ -1988,7 +2083,7 @@ type InsetPolicy = {
1988
2083
  */
1989
2084
  declare function insetsFrom(obstructions: readonly Obstruction[], frame: Size, policy?: InsetPolicy): Insets;
1990
2085
  //#endregion
1991
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/names.d.ts
2086
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/game/src/names.d.ts
1992
2087
  /**
1993
2088
  * The keys of a declared map, or `string` where the map is not a literal one —
1994
2089
  * which is what a manifest typed as the wide `GameManifest` gives — and
@@ -2108,7 +2203,7 @@ type EventProps<M> = M extends {
2108
2203
  */
2109
2204
  type StickName = 'pad.left.stick' | 'pad.right.stick' | 'pad.stick' | `controls.${string}`;
2110
2205
  //#endregion
2111
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/input/state.d.ts
2206
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/game/src/input/state.d.ts
2112
2207
  /**
2113
2208
  * Where the pointer is, in the frame's own coordinates.
2114
2209
  *
@@ -2169,7 +2264,7 @@ type InputSnapshot<Action extends string = string> = {
2169
2264
  pointer: PointerState | null;
2170
2265
  };
2171
2266
  //#endregion
2172
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/input/players.d.ts
2267
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/game/src/input/players.d.ts
2173
2268
  /**
2174
2269
  * What one player holds: a pad, one part of the keyboard, or the on-screen
2175
2270
  * controls.
@@ -2191,7 +2286,424 @@ type Controller =
2191
2286
  kind: 'touch';
2192
2287
  };
2193
2288
  //#endregion
2194
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/input/index.d.ts
2289
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/game/src/input/pointers.d.ts
2290
+ /**
2291
+ * Presses and groups of fingers on an element, recognised and meaning nothing:
2292
+ * what a game's tools, or a camera, are built on.
2293
+ *
2294
+ * What a press *is* is the same in every game, and every game that read
2295
+ * pointer events itself got some of it wrong, in the same few ways: a touch
2296
+ * the browser cancelled that counted as a tap, a drag that stuck when the mouse
2297
+ * was let go outside the frame, a view that jumped when a third finger came or
2298
+ * one of two went. What a press *means* is the game's, and differs per press:
2299
+ * one finger paints in an editor and pans in a map, and paints again once the
2300
+ * player picks the brush. So each layer of a game is asked, as a press goes
2301
+ * down, whether it is theirs, and the SDK tells its owner what it does.
2302
+ */
2303
+ /**
2304
+ * A point on an element, in CSS pixels from its top left corner.
2305
+ *
2306
+ * @group Input
2307
+ */
2308
+ type Point = {
2309
+ x: number;
2310
+ y: number;
2311
+ };
2312
+ /**
2313
+ * The modifier keys held.
2314
+ *
2315
+ * @group Input
2316
+ */
2317
+ type Modifiers = {
2318
+ shift: boolean;
2319
+ ctrl: boolean;
2320
+ alt: boolean;
2321
+ meta: boolean;
2322
+ };
2323
+ /**
2324
+ * What a press is made with.
2325
+ *
2326
+ * @group Input
2327
+ */
2328
+ type PointerDevice = 'mouse' | 'touch' | 'pen';
2329
+ /**
2330
+ * A mouse button, by where it is. A pen's barrel button is `'right'`.
2331
+ *
2332
+ * @group Input
2333
+ */
2334
+ type PointerButton = 'left' | 'middle' | 'right';
2335
+ /**
2336
+ * One finger, pen or mouse button on an element, from going down to coming up.
2337
+ * The same object throughout, kept up to date.
2338
+ *
2339
+ * @group Input
2340
+ */
2341
+ type Press = {
2342
+ readonly id: number;
2343
+ readonly device: PointerDevice;
2344
+ /** The mouse button; `null` for a finger or a pen's tip. */
2345
+ readonly button: PointerButton | null;
2346
+ /** The modifier keys held as it went down. */
2347
+ readonly modifiers: Modifiers;
2348
+ readonly start: Point;
2349
+ readonly at: Point;
2350
+ /** Whether it has gone further than the layer's `slop` from `start`. */
2351
+ readonly moved: boolean;
2352
+ /** Whether it stayed still for the layer's `holdMs`. */
2353
+ readonly held: boolean;
2354
+ /** Milliseconds since it went down. */
2355
+ readonly age: number;
2356
+ };
2357
+ /**
2358
+ * What a layer does with a press it took. Exactly one of `tap`, `end` and
2359
+ * `cancel` finishes it.
2360
+ *
2361
+ * @group Input
2362
+ */
2363
+ type PressHandler = {
2364
+ /**
2365
+ * It moved, by this many CSS pixels: once it has gone past `slop`, the first
2366
+ * time from `start` so what was under it stays under it; from the first
2367
+ * pixel with `immediate`.
2368
+ */
2369
+ move?(press: Press, dx: number, dy: number): void;
2370
+ /** Let go without having moved or held. */
2371
+ tap?(press: Press): void;
2372
+ /** Stayed still for `holdMs`. It never taps after that. */
2373
+ hold?(press: Press): void;
2374
+ /** Let go after moving or holding, at this velocity in CSS pixels a second. */
2375
+ end?(press: Press, velocity: Point): void;
2376
+ /**
2377
+ * Taken away: by the browser (a scroll, a system gesture), by a second
2378
+ * finger that another layer made a group, or by the layer going. Undo
2379
+ * whatever it started.
2380
+ */
2381
+ cancel?(press: Press): void;
2382
+ /** Hear moves from the first pixel rather than past `slop`: for drawing, or aiming. */
2383
+ immediate?: boolean;
2384
+ };
2385
+ /**
2386
+ * Two fingers or more on an element, from the second going down to the last
2387
+ * coming up. The same object throughout, kept up to date.
2388
+ *
2389
+ * @group Input
2390
+ */
2391
+ type Group = {
2392
+ /** How many fingers are down now: one, once all but one have lifted. */
2393
+ readonly fingers: number;
2394
+ /** The most that were down at once: 2 for a two-finger tap. */
2395
+ readonly most: number;
2396
+ /** Midway between the first two fingers, or where the one left is; for a tap, where they were together. */
2397
+ readonly centre: Point;
2398
+ /** How far apart the first two fingers are, in CSS pixels; 0 with one. */
2399
+ readonly spread: number;
2400
+ /** The angle from the first finger to the second, in radians. */
2401
+ readonly angle: number;
2402
+ /** Whether any finger has gone further than `slop` from where it went down. */
2403
+ readonly moved: boolean;
2404
+ /** Milliseconds since the second finger went down. */
2405
+ readonly age: number;
2406
+ };
2407
+ /**
2408
+ * How a group moved since it last did: what a pinch, a two-finger drag and a
2409
+ * twist do, at once. A finger coming or going moves nothing.
2410
+ *
2411
+ * @group Input
2412
+ */
2413
+ type GroupChange = {
2414
+ /** How far the centre moved, in CSS pixels. */
2415
+ dx: number;
2416
+ dy: number;
2417
+ /** How much further apart the first two fingers are, as a factor: above 1 is apart. */
2418
+ scale: number;
2419
+ /** How far they turned, in radians, clockwise. */
2420
+ rotate: number;
2421
+ };
2422
+ /**
2423
+ * What a layer does with a group it took. Exactly one of `tap`, `end` and
2424
+ * `cancel` finishes it.
2425
+ *
2426
+ * @group Input
2427
+ */
2428
+ type GroupHandler = {
2429
+ move?(group: Group, change: GroupChange): void;
2430
+ /** Every finger lifted, none having moved, quicker than `holdMs`. */
2431
+ tap?(group: Group): void;
2432
+ /** Every finger lifted otherwise, the centre leaving at this velocity in CSS pixels a second. */
2433
+ end?(group: Group, velocity: Point): void;
2434
+ /** Taken away: the browser took the last finger, or the layer went. */
2435
+ cancel?(group: Group): void;
2436
+ };
2437
+ /**
2438
+ * One layer of a game's on an element: `input.pointers`.
2439
+ *
2440
+ * @group Input
2441
+ */
2442
+ type PointerLayer = {
2443
+ /**
2444
+ * Whether a press going down is this layer's: a handler takes it, for good;
2445
+ * `null` leaves it to the layers below. Asked of the newest layer first, and
2446
+ * of a camera last.
2447
+ */
2448
+ press?(press: Press): PressHandler | null;
2449
+ /**
2450
+ * Whether fingers that make a group are this layer's, asked as the second
2451
+ * goes down. A layer that takes them cancels the press of every finger in
2452
+ * it. Taken by nobody, the new finger is a press of its own.
2453
+ */
2454
+ group?(group: Group): GroupHandler | null;
2455
+ /** A mouse or a pen over the element with nothing pressed; `null` once it leaves. */
2456
+ hover?(at: Point | null, device: PointerDevice): void;
2457
+ /** How far a press may move, in CSS pixels, and still tap. 8 when left out. */
2458
+ slop?: number;
2459
+ /** How long a press stays still to hold, in milliseconds. 450 when left out. */
2460
+ holdMs?: number;
2461
+ };
2462
+ /**
2463
+ * A layer of pointers, being read: `input.pointers`.
2464
+ *
2465
+ * @group Input
2466
+ */
2467
+ type Pointers = {
2468
+ /** Whether a press or a group this layer took is down now. */
2469
+ readonly active: boolean;
2470
+ /** Take the layer off; whatever it holds is cancelled. */
2471
+ dispose(): void;
2472
+ };
2473
+ //#endregion
2474
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/game/src/input/wheel.d.ts
2475
+ /**
2476
+ * One turn of a wheel, swipe of a trackpad, or pinch on one, the same in every
2477
+ * browser: `input.wheel`.
2478
+ *
2479
+ * @group Input
2480
+ */
2481
+ type Wheel = {
2482
+ /** A mouse wheel's notches, a trackpad's scroll, or a trackpad's pinch (Ctrl and a wheel are one too). */
2483
+ kind: 'notch' | 'smooth' | 'pinch';
2484
+ /** How far, in CSS pixels, positive right and down. A notch is 100 in every browser. 0 for a pinch. */
2485
+ x: number;
2486
+ y: number;
2487
+ /**
2488
+ * Whole steps down, negative up: one for each notch, and on a trackpad one
2489
+ * as a swipe starts and another every 200 pixels after. What `mouse.wheelup`
2490
+ * and `mouse.wheeldown` press. 0 for a pinch.
2491
+ */
2492
+ steps: number;
2493
+ /** A pinch's zoom, above 1 closer. 1 for anything else. */
2494
+ scale: number;
2495
+ /** A twist on Safari's trackpad, in radians, clockwise. 0 for anything else. */
2496
+ rotate: number;
2497
+ /** Where the pointer is, in CSS pixels from the element's top left corner. */
2498
+ at: Point;
2499
+ modifiers: Modifiers;
2500
+ };
2501
+ /**
2502
+ * The wheel being taken over an element: `input.wheel`.
2503
+ *
2504
+ * @group Input
2505
+ */
2506
+ type WheelTaker = {
2507
+ /** What was taken since the last read, added up: for a game that reads once a frame. */
2508
+ read(): {
2509
+ x: number;
2510
+ y: number;
2511
+ steps: number;
2512
+ };
2513
+ /** Stop taking it. */
2514
+ dispose(): void;
2515
+ };
2516
+ //#endregion
2517
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/game/src/input/camera.d.ts
2518
+ /**
2519
+ * What the camera should do: one for each move of a finger, a pair of them,
2520
+ * a wheel or a glide, whichever it was.
2521
+ *
2522
+ * @group Input
2523
+ */
2524
+ type CameraChange = {
2525
+ /** Move what is shown by this, in CSS pixels: it follows the finger. */
2526
+ dx: number;
2527
+ dy: number;
2528
+ /** Zoom by this factor around `x`, `y`, above 1 closer; 1 when not zooming. */
2529
+ scale: number;
2530
+ /** Turn by this, in radians clockwise around `x`, `y`: two fingers, or Safari's trackpad. */
2531
+ rotate: number;
2532
+ /** The point zoomed and turned around, in CSS pixels from the element's top left corner. */
2533
+ x: number;
2534
+ y: number;
2535
+ /** What made it: so a game can treat a wheel differently from a finger. */
2536
+ source: 'drag' | 'pinch' | 'wheel' | 'trackpad' | 'glide';
2537
+ };
2538
+ /**
2539
+ * A press or a group of fingers the camera had that never moved.
2540
+ *
2541
+ * @group Input
2542
+ */
2543
+ type Tap = {
2544
+ at: Point;
2545
+ device: PointerDevice;
2546
+ /** The mouse button; `null` for fingers and a pen's tip. */
2547
+ button: PointerButton | null;
2548
+ /** How many fingers: 2 or 3 for a tap of that many. */
2549
+ fingers: number;
2550
+ modifiers: Modifiers;
2551
+ };
2552
+ /**
2553
+ * What a wheel does to a camera.
2554
+ *
2555
+ * @group Input
2556
+ */
2557
+ type WheelMode = 'zoom' | 'pan' | 'none';
2558
+ /**
2559
+ * @group Input
2560
+ */
2561
+ type CameraOptions = {
2562
+ /** A view to move with every change. */
2563
+ view?: View;
2564
+ /** Hear every change, with or without a view: for a camera of the game's own. */
2565
+ move?(change: CameraChange): void;
2566
+ /** A drag or a pinch was let go, at this velocity in CSS pixels a second. */
2567
+ end?(velocity: Point): void;
2568
+ /** A press or a group of fingers the camera had, let go without moving. */
2569
+ tap?(tap: Tap): void;
2570
+ /** A press the camera had, held still. It never taps then. */
2571
+ hold?(tap: Tap): void;
2572
+ /** Which mouse buttons drag. A finger and a pen always do. `['left', 'middle']` when left out. */
2573
+ buttons?: readonly PointerButton[];
2574
+ /**
2575
+ * What the wheel does. Left out, a wheel's notch zooms around the pointer and
2576
+ * a trackpad pans, the way maps do; `'zoom'` or `'pan'` makes both do that,
2577
+ * and `'none'` leaves the wheel alone. A function decides for each turn: a
2578
+ * menu open, Shift held. A pinch on a trackpad zooms unless it says `'none'`.
2579
+ */
2580
+ wheel?: WheelMode | ((wheel: Wheel) => WheelMode);
2581
+ /** Keep moving after a fling, slowing down, until the next press or wheel. */
2582
+ inertia?: boolean;
2583
+ /** How far a press may move, in CSS pixels, and still tap. 8 when left out. */
2584
+ slop?: number;
2585
+ /** How long a press stays still to hold, in milliseconds. 450 when left out. */
2586
+ holdMs?: number;
2587
+ };
2588
+ /**
2589
+ * A camera on an element: `input.camera`.
2590
+ *
2591
+ * @group Input
2592
+ */
2593
+ type Camera = {
2594
+ /** Whether a press or fingers the camera has are down now. */
2595
+ readonly active: boolean;
2596
+ /** Stop: the element's presses and its wheel go back to whoever else wants them. */
2597
+ dispose(): void;
2598
+ };
2599
+ /**
2600
+ * A camera over a flat world: `input.view`.
2601
+ *
2602
+ * The world is in a game's own units, with `y` down; `scale` is CSS pixels to
2603
+ * one of them, and `x`, `y` the world point at the element's top left corner.
2604
+ * A game draws with them, `screen = (world - x) * scale`, and may set any of
2605
+ * them; each move keeps them inside `min`, `max` and `bounds`.
2606
+ *
2607
+ * @group Input
2608
+ */
2609
+ type View = {
2610
+ x: number;
2611
+ y: number;
2612
+ scale: number;
2613
+ /** The one axis it moves along, for a strip; `null` for both. */
2614
+ readonly axis: 'x' | 'y' | null;
2615
+ /** Drag the view by this many CSS pixels, the world following the finger. */
2616
+ pan(dx: number, dy: number): void;
2617
+ /** Zoom by this factor, the world point at `x`, `y` staying where it is. */
2618
+ zoom(factor: number, x: number, y: number): void;
2619
+ /** Put the world point `x`, `y` in the middle of the element, at `scale` if given. */
2620
+ look(x: number, y: number, scale?: number): void;
2621
+ /** The world point at a point on the element. */
2622
+ toWorld(x: number, y: number): Point;
2623
+ /** The point on the element a world point is drawn at. */
2624
+ toScreen(x: number, y: number): Point;
2625
+ /**
2626
+ * Say how big the element is, in CSS pixels: what `look` centres on and
2627
+ * `bounds` keeps filled. Call it whenever the element changes size.
2628
+ */
2629
+ resize(width: number, height: number): void;
2630
+ };
2631
+ /**
2632
+ * @group Input
2633
+ */
2634
+ type ViewOptions = {
2635
+ x?: number;
2636
+ y?: number;
2637
+ scale?: number;
2638
+ /** The least `scale` it zooms out to. */
2639
+ min?: number;
2640
+ /** The most `scale` it zooms in to. */
2641
+ max?: number;
2642
+ /**
2643
+ * Move along this axis only, for a strip: the other never pans nor shifts
2644
+ * as it zooms, and a camera turns a vertical wheel into a pan along it.
2645
+ */
2646
+ axis?: 'x' | 'y';
2647
+ /**
2648
+ * The part of the world the view stays over, in world units: never scrolled
2649
+ * past an edge, and centred on it once all of it fits.
2650
+ */
2651
+ bounds?: {
2652
+ x: number;
2653
+ y: number;
2654
+ width: number;
2655
+ height: number;
2656
+ };
2657
+ /** The element's size in CSS pixels, as `resize` takes it. */
2658
+ width?: number;
2659
+ height?: number;
2660
+ };
2661
+ //#endregion
2662
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/game/src/input/lock.d.ts
2663
+ /**
2664
+ * The mouse held to the game: `input.pointerLock`.
2665
+ *
2666
+ * @group Input
2667
+ */
2668
+ type PointerLock = {
2669
+ /** Whether the mouse is locked to the game now. */
2670
+ readonly locked: boolean;
2671
+ /**
2672
+ * Lock the mouse to an element, the whole page when left out, now if the
2673
+ * browser allows it and on the player's next click or key if not.
2674
+ *
2675
+ * Asked again after the player has just left a lock, the browser makes them
2676
+ * wait about a second; the SDK waits with them. Ask from a press of the
2677
+ * player's where you can, a click on the game or the key that resumes it:
2678
+ * from a frame loop, the browser may not take it until they press something.
2679
+ */
2680
+ request(element?: Element): void;
2681
+ /** Let the mouse go, and stop waiting to take it. */
2682
+ release(): void;
2683
+ /**
2684
+ * Run this when the lock is taken or lost. Lost without `release` is the
2685
+ * player leaving it, with Escape or by switching away: the time to pause.
2686
+ * The SDK does not take it back on its own; `request` again on resuming.
2687
+ */
2688
+ on(listener: (locked: boolean) => void): Unsubscribe;
2689
+ /**
2690
+ * Run this for each move of the mouse while it is locked, in CSS pixels,
2691
+ * or in the mouse's own counts where the browser gives those
2692
+ * (`unadjustedMovement`). The jumps a browser sends as a lock starts are
2693
+ * left out.
2694
+ */
2695
+ onMove(listener: (dx: number, dy: number) => void): Unsubscribe;
2696
+ /**
2697
+ * How far the mouse moved while locked since the last read, added up the way
2698
+ * `onMove` hears it: for a game that reads once a frame.
2699
+ */
2700
+ read(): {
2701
+ x: number;
2702
+ y: number;
2703
+ };
2704
+ };
2705
+ //#endregion
2706
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/game/src/input/index.d.ts
2195
2707
  /**
2196
2708
  * A binding a game can name on its own, for a prompt about a button that is
2197
2709
  * not one of its actions: `pad.start`, `key.Space`.
@@ -2301,6 +2813,22 @@ type Input<Action extends string = string, Layout extends string = string, Playe
2301
2813
  describe(name: Action | ButtonName): string;
2302
2814
  /** The font family `glyph` draws in: name it, last, wherever a glyph is printed. */
2303
2815
  readonly font: string;
2816
+ /**
2817
+ * Draw an icon on an action's on-screen button instead of its label, or
2818
+ * `null` to go back to the label.
2819
+ *
2820
+ * hopple.input.icon('jump', 'M12 3 4 13h5v8h6v-8h5z');
2821
+ *
2822
+ * One SVG path, filled in the buttons' ink, in a 24 by 24 box: what icon
2823
+ * sets draw filled icons in. The label stays the button's name for a screen
2824
+ * reader. `glyph(action)` on a touch screen draws the same icon, so a prompt
2825
+ * matches the button. A path that cannot be read, or that leaves the box, is
2826
+ * reported to `onError` and the label is drawn instead.
2827
+ *
2828
+ * How the controls look otherwise is the game's stylesheet's: see the
2829
+ * skill's input guide.
2830
+ */
2831
+ icon(action: Action, path: string | null): void;
2304
2832
  /**
2305
2833
  * Stop reading input and let go of everything held.
2306
2834
  *
@@ -2312,6 +2840,55 @@ type Input<Action extends string = string, Layout extends string = string, Playe
2312
2840
  suspend(): void;
2313
2841
  resume(): void;
2314
2842
  readonly suspended: boolean;
2843
+ /**
2844
+ * Hear presses on an element, recognised and meaning nothing yet: a layer of
2845
+ * the game's, for its tools, its aim, its brush.
2846
+ *
2847
+ * hopple.input.pointers(canvas, {
2848
+ * press: (p) => tool === 'road' && p.button !== 'right' ? road(p) : null,
2849
+ * });
2850
+ *
2851
+ * Each press is offered to the layers on the element as it goes down, the
2852
+ * newest first and a `camera` last; the first to return a handler has it,
2853
+ * and hears it move, tap, hold, end or be cancelled. Two fingers or more are
2854
+ * offered as a group first: a layer that takes them cancels their presses.
2855
+ * A drag let go outside the frame still ends, a touch the browser took never
2856
+ * taps, and a finger coming or going moves nothing. The element gets
2857
+ * `touch-action: none` until its last layer is disposed.
2858
+ */
2859
+ pointers(element: Element, layer: PointerLayer): Pointers;
2860
+ /**
2861
+ * Take the wheel over an element: a mouse wheel, a trackpad's scroll and its
2862
+ * pinch, the same in every browser, as an amount and as whole steps.
2863
+ *
2864
+ * const wheel = hopple.input.wheel(list, (w) => void (scroll += w.y));
2865
+ *
2866
+ * The page does not scroll under it, and `mouse.wheelup` / `mouse.wheeldown`
2867
+ * do not hear it, unless the listener returns `false` for that turn.
2868
+ * `read()` adds up what was taken since it was last read.
2869
+ */
2870
+ wheel(element: Element, listener?: (wheel: Wheel) => boolean | void): WheelTaker;
2871
+ /**
2872
+ * A camera on an element, moved by whatever presses no other layer took:
2873
+ * one finger or a mouse button drags, two fingers pinch, pan and turn, a
2874
+ * mouse wheel zooms around the pointer and a trackpad pans and pinches, at
2875
+ * one speed in every browser.
2876
+ *
2877
+ * const view = hopple.input.view({ min: 0.5, max: 4, bounds: world });
2878
+ * hopple.input.camera(canvas, { view, tap: ({ at }) => select(view.toWorld(at.x, at.y)) });
2879
+ *
2880
+ * A `view` is moved for it; `move` hears every change, for a camera of the
2881
+ * game's own.
2882
+ */
2883
+ camera(element: Element, options: CameraOptions): Camera;
2884
+ /**
2885
+ * A camera over a flat world that `camera` moves, kept between `min` and
2886
+ * `max` and over `bounds`. Nothing in it is drawn: a game reads `x`, `y`
2887
+ * and `scale` when it draws.
2888
+ */
2889
+ view(options?: ViewOptions): View;
2890
+ /** The mouse held to the game, for a game that turns a camera with it. */
2891
+ readonly pointerLock: PointerLock;
2315
2892
  /**
2316
2893
  * The players on this device, each with their own copy of the actions
2317
2894
  * `input.player` declares, by `slot`. Empty for a game that declares none;
@@ -2412,7 +2989,7 @@ type Controls<Layout extends string = string> = {
2412
2989
  readonly available: boolean;
2413
2990
  };
2414
2991
  //#endregion
2415
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/lifecycle.d.ts
2992
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/game/src/lifecycle.d.ts
2416
2993
  /** @group Lifecycle */
2417
2994
  type LifecycleListener = (phase: Phase, previous: Phase) => void | Promise<void>;
2418
2995
  /**
@@ -2431,7 +3008,7 @@ type Lifecycle = {
2431
3008
  on(listener: LifecycleListener): Unsubscribe;
2432
3009
  };
2433
3010
  //#endregion
2434
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/loop.d.ts
3011
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/game/src/loop.d.ts
2435
3012
  /**
2436
3013
  * The host has let the game run its loop, or stopped it. Return a promise to
2437
3014
  * make the host wait.
@@ -2485,7 +3062,7 @@ type Loop = {
2485
3062
  tick(frame: FrameCallback): Unsubscribe;
2486
3063
  };
2487
3064
  //#endregion
2488
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/panel.d.ts
3065
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/game/src/panel.d.ts
2489
3066
  /**
2490
3067
  * The pages of the host's panel a game has a name for, as the keys of this
2491
3068
  * interface.
@@ -2623,7 +3200,7 @@ type Panel = {
2623
3200
  open(page: PageId): void;
2624
3201
  };
2625
3202
  //#endregion
2626
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/pause.d.ts
3203
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/game/src/pause.d.ts
2627
3204
  /**
2628
3205
  * The host has asked for a pause, or for the game to carry on.
2629
3206
  *
@@ -2684,7 +3261,7 @@ type Pause = {
2684
3261
  on(listener: PauseListener): Unsubscribe;
2685
3262
  };
2686
3263
  //#endregion
2687
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/resources.d.ts
3264
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/game/src/resources.d.ts
2688
3265
  /**
2689
3266
  * The host has let the game hold its resources again, or asked for them back.
2690
3267
  * Return a promise to make the host wait until they have gone, or come back.
@@ -2714,7 +3291,7 @@ type Resources = {
2714
3291
  on(listener: ResourcesListener): Unsubscribe;
2715
3292
  };
2716
3293
  //#endregion
2717
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/save.d.ts
3294
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/game/src/save.d.ts
2718
3295
  /**
2719
3296
  * What a game gets back from a read: its own schema number, and its state.
2720
3297
  *
@@ -2724,7 +3301,10 @@ type Resources = {
2724
3301
  type SaveState = {
2725
3302
  /** Whatever the game passed to `write`, or 1 where it never named one. */
2726
3303
  version: number;
2727
- /** Parsed where it was written as a value, verbatim where it was a string. */
3304
+ /**
3305
+ * Parsed where it was written as a value, verbatim where it was a string, and
3306
+ * a `Uint8Array` where it was one.
3307
+ */
2728
3308
  state: unknown;
2729
3309
  };
2730
3310
  /**
@@ -2764,20 +3344,41 @@ type SaveListener = (now: SaveStatus, previous: SaveStatus) => void;
2764
3344
  *
2765
3345
  * Pure: it is called with two states and must not touch the game's own. Run
2766
3346
  * while the game loads, its answer is what `read()` resolves with; run while
2767
- * the game plays, its answer goes to `onMerge` as well.
3347
+ * the game plays, its answer goes to `onChange` as well.
2768
3348
  *
2769
3349
  * @group Save
2770
3350
  * @category Useful
2771
3351
  */
2772
3352
  type SaveMerger = (mine: SaveState, theirs: SaveState) => SaveState;
2773
3353
  /**
2774
- * Told the merged save, once a merge has run while the game was playing on
2775
- * its own: play on from this, which is both devices' progress.
3354
+ * Why the save a game plays on changed under it.
3355
+ *
3356
+ * - `arrived`: another device's save, built on what the game had — a server
3357
+ * that answered after the game read, or another device that played on. Run
3358
+ * through the game's `merge` with what it last saved, where it has one.
3359
+ * - `merged`: the game's `merge` made one save of this device's and another
3360
+ * that went their own ways.
3361
+ * - `gone`: thrown away on another device, with nothing made here since. The
3362
+ * save is `null`.
2776
3363
  *
2777
3364
  * @group Save
2778
3365
  * @category Useful
2779
3366
  */
2780
- type SaveMergeListener = (merged: SaveState) => void;
3367
+ type SaveChangeReason = 'arrived' | 'merged' | 'gone';
3368
+ /**
3369
+ * Told the save the game now plays on, once it changed under it while it
3370
+ * played, and why: play on from this. `null` is a save thrown away on another
3371
+ * device (`gone`): start again.
3372
+ *
3373
+ * The host now holds what the listener is handed, and the game's next write
3374
+ * continues it. To keep the game's own instead — progress it has not saved
3375
+ * yet, or a New game the player has just chosen over a save that arrived
3376
+ * after — write it from the listener: it takes that save's place.
3377
+ *
3378
+ * @group Save
3379
+ * @category Useful
3380
+ */
3381
+ type SaveChangeListener = (save: SaveState | null, why: SaveChangeReason) => void;
2781
3382
  /**
2782
3383
  * What a game says about its save at `init`, before the host has asked
2783
3384
  * anything.
@@ -2823,10 +3424,12 @@ type Save = {
2823
3424
  /**
2824
3425
  * Keep this. Resolves when the host says the record is durable.
2825
3426
  *
2826
- * A string is stored as it stands and comes back a string; anything else is
2827
- * `JSON.stringify`d and comes back parsed. A value that cannot survive that
2828
- * at all — a cycle, a `BigInt` — rejects with `bad_params` before anything
2829
- * reaches the bridge.
3427
+ * A string is stored as it stands and comes back a string; a `Uint8Array` is
3428
+ * stored as its bytes and comes back a `Uint8Array`, `maxBytes` counting the
3429
+ * bytes themselves; anything else is `JSON.stringify`d and comes back parsed.
3430
+ * A value that cannot survive that at all — a cycle, a `BigInt` — rejects
3431
+ * with `bad_params` before anything reaches the bridge, and bytes on a host
3432
+ * older than keeping them reject with `unsupported`.
2830
3433
  *
2831
3434
  * `version` is the game's own schema number and means whatever the game says
2832
3435
  * it means. There is no migration hook: a hook would be frozen game-side code
@@ -2839,19 +3442,31 @@ type Save = {
2839
3442
  /** Throw the save away — a game resetting its own progress, at a player's asking. */
2840
3443
  clear(): Promise<void>;
2841
3444
  /**
2842
- * Told when the game's `merge` ran while the game was playing: what the
2843
- * host now keeps is the merged save, and the game should play on from it.
3445
+ * Told when the save the game plays on changed under it, and why: play on
3446
+ * from what the listener is handed.
3447
+ *
3448
+ * That is another device's save arriving after the game read — a server
3449
+ * that answered late, a page left open while another device played on —
3450
+ * (`arrived`), or the game's own `merge` run while it played (`merged`), or
3451
+ * the save thrown away on another device with nothing made here since
3452
+ * (`gone`, `null`). Without a merge, an arrival is handed over as it is: it
3453
+ * is built on what the game had.
3454
+ *
3455
+ * Listening is what lets a game start before its save is in hand: draw from
3456
+ * nothing at once, and take the player's save when it comes. Register it
3457
+ * before `read()`. A game that is not listening is never written over —
3458
+ * what it writes next is kept beside what arrived, for its merge or the
3459
+ * player to settle.
2844
3460
  *
2845
- * A merge needed while the game plays waits for its next load unless
2846
- * something is listening here, because a game that went on playing from its
2847
- * own state would save over the merge with its next write.
3461
+ * To keep the game's own over what it is handed, write it from the
3462
+ * listener: that write takes the handed save's place.
2848
3463
  */
2849
- onMerge(listener: SaveMergeListener): Unsubscribe;
3464
+ onChange(listener: SaveChangeListener): Unsubscribe;
2850
3465
  /** The largest save this host will take, in bytes. `SAVE_BYTES` where it said nothing. */
2851
3466
  readonly maxBytes: number;
2852
3467
  };
2853
3468
  //#endregion
2854
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/score.d.ts
3469
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/game/src/score.d.ts
2855
3470
  /**
2856
3471
  * Where this player stands on every board, as far as anybody has said.
2857
3472
  *
@@ -2928,7 +3543,7 @@ type Score<Board extends string = string> = {
2928
3543
  }): Promise<ScoreResult>;
2929
3544
  };
2930
3545
  //#endregion
2931
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/share.d.ts
3546
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/game/src/share.d.ts
2932
3547
  /**
2933
3548
  * @group Share
2934
3549
  * @category Important
@@ -2955,9 +3570,18 @@ type Share = {
2955
3570
  * check it — the same care `save.read` deserves, for a stronger reason.
2956
3571
  *
2957
3572
  * **`null` says nothing about whether a link can be offered.** It means
2958
- * nobody arrived by one; `available` is what says whether one can be made.
3573
+ * nobody arrived by one, or that the link carried bytes, which are `bytes`;
3574
+ * `available` is what says whether one can be made.
2959
3575
  */
2960
3576
  readonly data: string | null;
3577
+ /**
3578
+ * What the link that opened this game carried, where some run of this game
3579
+ * passed `offer` a `Uint8Array`: those bytes. `null` otherwise — a player who
3580
+ * arrived the ordinary way, or a link that carried a string, which is `data`.
3581
+ *
3582
+ * A stranger's input, exactly as `data` is.
3583
+ */
3584
+ readonly bytes: Uint8Array | null;
2961
3585
  /**
2962
3586
  * Ask the host to put a link to this game in front of the player.
2963
3587
  *
@@ -2967,23 +3591,26 @@ type Share = {
2967
3591
  * may keep a sheet open as long as they like, and pressing Share again while
2968
3592
  * one is up does not open a second.
2969
3593
  *
2970
- * `data` is the game's own and travels in the link, opaque to the host, back
2971
- * to whoever opens it. A string, because it has to survive being a URL and
2972
- * because the game reading it back is the game that wrote it: anything
2973
- * structured is the game's to encode and the game's to parse. `SHARE_BYTES`
2974
- * is what every host carries; more than that is a host's own decision, and a
2975
- * host that will not carry it refuses with `too_large`.
3594
+ * `data` is the game's own and travels with the link, opaque to the host,
3595
+ * back to whoever opens it: a string, which arrives as `share.data`, or a
3596
+ * `Uint8Array`, which arrives as `share.bytes`. The game reading it back is
3597
+ * the game that wrote it, so anything structured is the game's to encode and
3598
+ * the game's to parse — bytes pack a board far tighter than text does.
3599
+ * `SHARE_BYTES` is what every host carries, counted in bytes either way; more
3600
+ * than that is a host's own decision, and a host that will not carry it
3601
+ * refuses with `too_large`.
2976
3602
  *
2977
3603
  * `meta` is for the platform rather than for the game: why this link was made
2978
3604
  * — the level, the score, which of the game's buttons — kept beside the
2979
3605
  * host's own record of who made it and how, so a game's makers can learn
2980
3606
  * which of its shares bring people in. Anything JSON can say, and
2981
3607
  * `SHARE_META_BYTES` of it is what every host takes. Nobody who opens the link
2982
- * is handed it.
3608
+ * is handed it; the game's team reads it, with `data`, by `hopple share`.
2983
3609
  *
2984
3610
  * What goes wrong is reported to `onError` and sends nothing: `bad_params`
2985
- * for a `data` that is not a string or a `meta` JSON cannot carry, which are
2986
- * bugs in the game; `too_large` from a host for more than it carries;
3611
+ * for a `data` that is neither a string nor a `Uint8Array`, or a `meta` JSON
3612
+ * cannot carry, which are bugs in the game; `unsupported` for bytes on a host
3613
+ * older than carrying them; `too_large` from a host for more than it carries;
2987
3614
  * `rate_limited` from one that will not offer a link right now. A host with
2988
3615
  * no link to give does nothing, which a game checking `available` never asks
2989
3616
  * of it. Every one of them is a game that carries on: nothing about a share
@@ -2995,12 +3622,12 @@ type Share = {
2995
3622
  * sheet on screen comes from the player's own gesture.
2996
3623
  */
2997
3624
  offer(options?: {
2998
- data?: string;
3625
+ data?: string | Uint8Array;
2999
3626
  meta?: ShareMeta;
3000
3627
  }): void;
3001
3628
  };
3002
3629
  //#endregion
3003
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/init.d.ts
3630
+ //#region ../../../../../../../tmp/hopple-sdk-types-SHySdg/game/src/init.d.ts
3004
3631
  /**
3005
3632
  * What `init` hands back: every namespace a game has, on one object.
3006
3633
  *
@@ -3296,4 +3923,4 @@ type InitOptions = {
3296
3923
  */
3297
3924
  declare function init<M extends object = GameManifest>(options?: InitOptions): Promise<GameSdk<M>>;
3298
3925
  //#endregion
3299
- export { type Achievement, type AchievementDeclaration, type AchievementListener, type AchievementName, type AchievementProgress, type AchievementStanding, type AchievementStatus, type AchievementTier, type Achievements, type ActionListener, type ActionName, type Analytics, type AnalyticsDeclaration, type AnalyticsProps, type AnalyticsShape, type AnalyticsType, type AnalyticsValue, type ApiVersion, type AppInfo, type AppSurface, type Audio, type AudioChannel, type AudioDeclaration, type AudioListener, type BoardName, BridgeError, type ButtonName, type ChannelName, type ControlLayout, type ControlShape, type ControlSlot, type ControlZone, type Controller, type Controls, type DeclaredNames, type DeclaredValue, type DeviceInfo, type DeviceTier, type ErrorCode, type ErrorCodes, type EventName, type EventProps, type FrameCallback, type GameInfo, type GameManifest, type GameSdk, type HoppleConfig, type Info, type InitOptions, type Input, type InputAction, type InputBinding, type InputDeclaration, type InputDevice, type InputListener, type InputScheme, type InputSnapshot, type InputState, type InsetMode, type InsetPolicy, type Insets, type Layout, type LayoutDeclaration, type LayoutListener, type LayoutName, type LayoutState, type Lifecycle, type LifecycleListener, type Loop, type LoopListener, MAX_STEP, type MeasuredName, type Obstruction, type ObstructionKind, type Orientation, type PageId, type Panel, type PanelListener, type PanelPages, type PanelState, type Pause, type PauseListener, type PauseState, type Phase, type Player, type PlayerActionName, type PlayerInfo, type PointerListener, type PointerState, type ProjectManifest, type Rect, type Resources, type ResourcesListener, SAVE_BYTES, SHARE_BYTES, SHARE_META_BYTES, type Save, type SaveDeclaration, type SaveListener, type SaveMergeListener, type SaveMerger, type SaveSetup, type SaveState, type SaveStatus, type SaveStored, type Score, type ScoreBoard, type ScoreDeclaration, type ScoreDirection, type ScoreFormat, type ScoreListener, type ScoreResult, type ScoreStanding, type ScoreStandings, type Share, type ShareMeta, type ShareMetaValue, type Size, type StickListener, type StickName, type StickState, type Unsubscribe, init, insetsFrom };
3926
+ export { type Achievement, type AchievementDeclaration, type AchievementListener, type AchievementName, type AchievementProgress, type AchievementStanding, type AchievementStatus, type AchievementTier, type Achievements, type ActionListener, type ActionName, type Analytics, type AnalyticsDeclaration, type AnalyticsProps, type AnalyticsShape, type AnalyticsType, type AnalyticsValue, type ApiVersion, type AppInfo, type AppSurface, type Audio, type AudioChannel, type AudioDeclaration, type AudioListener, type BoardName, BridgeError, type ButtonName, type Camera, type CameraChange, type CameraOptions, type ChannelName, type ControlLayout, type ControlShape, type ControlSlot, type ControlZone, type Controller, type Controls, type DeclaredNames, type DeclaredValue, type DeviceInfo, type DeviceTier, type ErrorCode, type ErrorCodes, type EventName, type EventProps, type FrameCallback, type GameInfo, type GameManifest, type GameSdk, type Group, type GroupChange, type GroupHandler, type Info, type InitOptions, type Input, type InputAction, type InputBinding, type InputDeclaration, type InputDevice, type InputListener, type InputScheme, type InputSnapshot, type InputState, type InsetMode, type InsetPolicy, type Insets, type Layout, type LayoutDeclaration, type LayoutListener, type LayoutName, type LayoutState, type Lifecycle, type LifecycleListener, type Loop, type LoopListener, MAX_STEP, type MeasuredName, type Modifiers, type Obstruction, type ObstructionKind, type Orientation, type PageId, type Panel, type PanelListener, type PanelPages, type PanelState, type Pause, type PauseListener, type PauseState, type Phase, type Player, type PlayerActionName, type PlayerInfo, type Point, type PointerButton, type PointerDevice, type PointerLayer, type PointerListener, type PointerLock, type PointerState, type Pointers, type Press, type PressHandler, type ProjectManifest, type Rect, type Resources, type ResourcesListener, SAVE_BYTES, SHARE_BYTES, SHARE_META_BYTES, type Save, type SaveChangeListener, type SaveChangeReason, type SaveDeclaration, type SaveListener, type SaveMerger, type SaveSetup, type SaveState, type SaveStatus, type SaveStored, type Score, type ScoreBoard, type ScoreDeclaration, type ScoreDirection, type ScoreFormat, type ScoreListener, type ScoreResult, type ScoreStanding, type ScoreStandings, type Share, type ShareMeta, type ShareMetaValue, type Size, type StickListener, type StickName, type StickState, type Tap, type Unsubscribe, type View, type ViewOptions, type Wheel, type WheelMode, type WheelTaker, init, insetsFrom };