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

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-hbSZtA/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-hbSZtA/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-hbSZtA/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-hbSZtA/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-hbSZtA/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-hbSZtA/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-hbSZtA/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-hbSZtA/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-hbSZtA/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-hbSZtA/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,23 @@ 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';
1462
1537
  /**
1463
1538
  * Publishing refuses a key the manifest's API does not know; a host reading a
1464
1539
  * published one ignores it (see `validateManifest`).
@@ -1498,8 +1573,19 @@ type GameManifest = {
1498
1573
  * @errorMessage must be a handle: lowercase letters, digits and hyphens
1499
1574
  */
1500
1575
  owner?: string;
1576
+ /**
1577
+ * `false` for a game that is never to be uploaded: an example, a test, a
1578
+ * game kept to one machine. `hopple dev` and `hopple check` still run it;
1579
+ * `hopple upload` and `hopple publish` refuse it, and so does a server it
1580
+ * is sent to another way. Absent, it may be published.
1581
+ *
1582
+ * @category Useful
1583
+ */
1584
+ publishable?: boolean;
1501
1585
  /**
1502
1586
  * The game's own version, `MAJOR.MINOR.PATCH`. Ours to read, never to parse for meaning.
1587
+ * People see it beside the build the server numbers each upload with, and
1588
+ * each published version needs one no other published version of the game has.
1503
1589
  *
1504
1590
  * @category Important
1505
1591
  * @pattern ^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$
@@ -1522,6 +1608,18 @@ type GameManifest = {
1522
1608
  * @errorMessage must not be blank
1523
1609
  */
1524
1610
  description?: string;
1611
+ /**
1612
+ * What kind of game it is, the main one first. Read by whoever files it in a
1613
+ * catalogue, which never runs it. At most `GENRE_MAX`, not counting
1614
+ * `local-multiplayer` and `online-multiplayer`: a game that is every kind
1615
+ * tells a player nothing. The publisher's claim, taken at its word, except
1616
+ * for those two. See `GameGenre`.
1617
+ *
1618
+ * @category Useful
1619
+ * @minItems 1
1620
+ * @maxItems 5
1621
+ */
1622
+ genres?: GameGenre[];
1525
1623
  /**
1526
1624
  * A picture of the game, shown wherever a link to it is pasted — a chat, a
1527
1625
  * post, a message.
@@ -1596,53 +1694,6 @@ type GameManifest = {
1596
1694
  */
1597
1695
  previews?: PreviewsDeclaration;
1598
1696
  };
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
1697
  /**
1647
1698
  * The manifest as a project's config holds it: `api` may be left out, for the
1648
1699
  * CLI to fill from the installed `@hopple/sdk`.
@@ -1654,7 +1705,7 @@ type ProjectManifest = Omit<GameManifest, 'api'> & {
1654
1705
  api?: ApiVersion;
1655
1706
  };
1656
1707
  //#endregion
1657
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/achievements.d.ts
1708
+ //#region ../../../../../../../tmp/hopple-sdk-types-hbSZtA/game/src/achievements.d.ts
1658
1709
  /**
1659
1710
  * Where this player stands on one achievement.
1660
1711
  *
@@ -1752,7 +1803,7 @@ type Achievements<Id extends string = string, Measured extends string = Id> = {
1752
1803
  progress(id: Measured, value: number): void;
1753
1804
  };
1754
1805
  //#endregion
1755
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/analytics.d.ts
1806
+ //#region ../../../../../../../tmp/hopple-sdk-types-hbSZtA/game/src/analytics.d.ts
1756
1807
  /**
1757
1808
  * @group Analytics
1758
1809
  * @category Important
@@ -1769,7 +1820,7 @@ type Analytics<Events extends object = Record<string, AnalyticsProps>> = {
1769
1820
  track<Event extends keyof Events & string>(name: Event, props?: Events[Event]): void;
1770
1821
  };
1771
1822
  //#endregion
1772
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/audio.d.ts
1823
+ //#region ../../../../../../../tmp/hopple-sdk-types-hbSZtA/game/src/audio.d.ts
1773
1824
  /**
1774
1825
  * Something about the game's sound changed: the host's order, the player's
1775
1826
  * mute, a fader. Read what you need — `volume(channel)`, `allowed` — and apply
@@ -1860,7 +1911,7 @@ type Audio<Channel extends string = string> = {
1860
1911
  media(element: HTMLMediaElement, channel?: Channel): Unsubscribe;
1861
1912
  };
1862
1913
  //#endregion
1863
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/info.d.ts
1914
+ //#region ../../../../../../../tmp/hopple-sdk-types-hbSZtA/game/src/info.d.ts
1864
1915
  /**
1865
1916
  * What the host said, frozen.
1866
1917
  *
@@ -1878,7 +1929,7 @@ type Info = Readonly<{
1878
1929
  device: Readonly<DeviceInfo>;
1879
1930
  }>;
1880
1931
  //#endregion
1881
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/layout.d.ts
1932
+ //#region ../../../../../../../tmp/hopple-sdk-types-hbSZtA/game/src/layout.d.ts
1882
1933
  /**
1883
1934
  * How much of each edge belongs to the host. CSS pixels.
1884
1935
  *
@@ -1988,7 +2039,7 @@ type InsetPolicy = {
1988
2039
  */
1989
2040
  declare function insetsFrom(obstructions: readonly Obstruction[], frame: Size, policy?: InsetPolicy): Insets;
1990
2041
  //#endregion
1991
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/names.d.ts
2042
+ //#region ../../../../../../../tmp/hopple-sdk-types-hbSZtA/game/src/names.d.ts
1992
2043
  /**
1993
2044
  * The keys of a declared map, or `string` where the map is not a literal one —
1994
2045
  * which is what a manifest typed as the wide `GameManifest` gives — and
@@ -2108,7 +2159,7 @@ type EventProps<M> = M extends {
2108
2159
  */
2109
2160
  type StickName = 'pad.left.stick' | 'pad.right.stick' | 'pad.stick' | `controls.${string}`;
2110
2161
  //#endregion
2111
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/input/state.d.ts
2162
+ //#region ../../../../../../../tmp/hopple-sdk-types-hbSZtA/game/src/input/state.d.ts
2112
2163
  /**
2113
2164
  * Where the pointer is, in the frame's own coordinates.
2114
2165
  *
@@ -2169,7 +2220,7 @@ type InputSnapshot<Action extends string = string> = {
2169
2220
  pointer: PointerState | null;
2170
2221
  };
2171
2222
  //#endregion
2172
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/input/players.d.ts
2223
+ //#region ../../../../../../../tmp/hopple-sdk-types-hbSZtA/game/src/input/players.d.ts
2173
2224
  /**
2174
2225
  * What one player holds: a pad, one part of the keyboard, or the on-screen
2175
2226
  * controls.
@@ -2191,7 +2242,424 @@ type Controller =
2191
2242
  kind: 'touch';
2192
2243
  };
2193
2244
  //#endregion
2194
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/input/index.d.ts
2245
+ //#region ../../../../../../../tmp/hopple-sdk-types-hbSZtA/game/src/input/pointers.d.ts
2246
+ /**
2247
+ * Presses and groups of fingers on an element, recognised and meaning nothing:
2248
+ * what a game's tools, or a camera, are built on.
2249
+ *
2250
+ * What a press *is* is the same in every game, and every game that read
2251
+ * pointer events itself got some of it wrong, in the same few ways: a touch
2252
+ * the browser cancelled that counted as a tap, a drag that stuck when the mouse
2253
+ * was let go outside the frame, a view that jumped when a third finger came or
2254
+ * one of two went. What a press *means* is the game's, and differs per press:
2255
+ * one finger paints in an editor and pans in a map, and paints again once the
2256
+ * player picks the brush. So each layer of a game is asked, as a press goes
2257
+ * down, whether it is theirs, and the SDK tells its owner what it does.
2258
+ */
2259
+ /**
2260
+ * A point on an element, in CSS pixels from its top left corner.
2261
+ *
2262
+ * @group Input
2263
+ */
2264
+ type Point = {
2265
+ x: number;
2266
+ y: number;
2267
+ };
2268
+ /**
2269
+ * The modifier keys held.
2270
+ *
2271
+ * @group Input
2272
+ */
2273
+ type Modifiers = {
2274
+ shift: boolean;
2275
+ ctrl: boolean;
2276
+ alt: boolean;
2277
+ meta: boolean;
2278
+ };
2279
+ /**
2280
+ * What a press is made with.
2281
+ *
2282
+ * @group Input
2283
+ */
2284
+ type PointerDevice = 'mouse' | 'touch' | 'pen';
2285
+ /**
2286
+ * A mouse button, by where it is. A pen's barrel button is `'right'`.
2287
+ *
2288
+ * @group Input
2289
+ */
2290
+ type PointerButton = 'left' | 'middle' | 'right';
2291
+ /**
2292
+ * One finger, pen or mouse button on an element, from going down to coming up.
2293
+ * The same object throughout, kept up to date.
2294
+ *
2295
+ * @group Input
2296
+ */
2297
+ type Press = {
2298
+ readonly id: number;
2299
+ readonly device: PointerDevice;
2300
+ /** The mouse button; `null` for a finger or a pen's tip. */
2301
+ readonly button: PointerButton | null;
2302
+ /** The modifier keys held as it went down. */
2303
+ readonly modifiers: Modifiers;
2304
+ readonly start: Point;
2305
+ readonly at: Point;
2306
+ /** Whether it has gone further than the layer's `slop` from `start`. */
2307
+ readonly moved: boolean;
2308
+ /** Whether it stayed still for the layer's `holdMs`. */
2309
+ readonly held: boolean;
2310
+ /** Milliseconds since it went down. */
2311
+ readonly age: number;
2312
+ };
2313
+ /**
2314
+ * What a layer does with a press it took. Exactly one of `tap`, `end` and
2315
+ * `cancel` finishes it.
2316
+ *
2317
+ * @group Input
2318
+ */
2319
+ type PressHandler = {
2320
+ /**
2321
+ * It moved, by this many CSS pixels: once it has gone past `slop`, the first
2322
+ * time from `start` so what was under it stays under it; from the first
2323
+ * pixel with `immediate`.
2324
+ */
2325
+ move?(press: Press, dx: number, dy: number): void;
2326
+ /** Let go without having moved or held. */
2327
+ tap?(press: Press): void;
2328
+ /** Stayed still for `holdMs`. It never taps after that. */
2329
+ hold?(press: Press): void;
2330
+ /** Let go after moving or holding, at this velocity in CSS pixels a second. */
2331
+ end?(press: Press, velocity: Point): void;
2332
+ /**
2333
+ * Taken away: by the browser (a scroll, a system gesture), by a second
2334
+ * finger that another layer made a group, or by the layer going. Undo
2335
+ * whatever it started.
2336
+ */
2337
+ cancel?(press: Press): void;
2338
+ /** Hear moves from the first pixel rather than past `slop`: for drawing, or aiming. */
2339
+ immediate?: boolean;
2340
+ };
2341
+ /**
2342
+ * Two fingers or more on an element, from the second going down to the last
2343
+ * coming up. The same object throughout, kept up to date.
2344
+ *
2345
+ * @group Input
2346
+ */
2347
+ type Group = {
2348
+ /** How many fingers are down now: one, once all but one have lifted. */
2349
+ readonly fingers: number;
2350
+ /** The most that were down at once: 2 for a two-finger tap. */
2351
+ readonly most: number;
2352
+ /** Midway between the first two fingers, or where the one left is; for a tap, where they were together. */
2353
+ readonly centre: Point;
2354
+ /** How far apart the first two fingers are, in CSS pixels; 0 with one. */
2355
+ readonly spread: number;
2356
+ /** The angle from the first finger to the second, in radians. */
2357
+ readonly angle: number;
2358
+ /** Whether any finger has gone further than `slop` from where it went down. */
2359
+ readonly moved: boolean;
2360
+ /** Milliseconds since the second finger went down. */
2361
+ readonly age: number;
2362
+ };
2363
+ /**
2364
+ * How a group moved since it last did: what a pinch, a two-finger drag and a
2365
+ * twist do, at once. A finger coming or going moves nothing.
2366
+ *
2367
+ * @group Input
2368
+ */
2369
+ type GroupChange = {
2370
+ /** How far the centre moved, in CSS pixels. */
2371
+ dx: number;
2372
+ dy: number;
2373
+ /** How much further apart the first two fingers are, as a factor: above 1 is apart. */
2374
+ scale: number;
2375
+ /** How far they turned, in radians, clockwise. */
2376
+ rotate: number;
2377
+ };
2378
+ /**
2379
+ * What a layer does with a group it took. Exactly one of `tap`, `end` and
2380
+ * `cancel` finishes it.
2381
+ *
2382
+ * @group Input
2383
+ */
2384
+ type GroupHandler = {
2385
+ move?(group: Group, change: GroupChange): void;
2386
+ /** Every finger lifted, none having moved, quicker than `holdMs`. */
2387
+ tap?(group: Group): void;
2388
+ /** Every finger lifted otherwise, the centre leaving at this velocity in CSS pixels a second. */
2389
+ end?(group: Group, velocity: Point): void;
2390
+ /** Taken away: the browser took the last finger, or the layer went. */
2391
+ cancel?(group: Group): void;
2392
+ };
2393
+ /**
2394
+ * One layer of a game's on an element: `input.pointers`.
2395
+ *
2396
+ * @group Input
2397
+ */
2398
+ type PointerLayer = {
2399
+ /**
2400
+ * Whether a press going down is this layer's: a handler takes it, for good;
2401
+ * `null` leaves it to the layers below. Asked of the newest layer first, and
2402
+ * of a camera last.
2403
+ */
2404
+ press?(press: Press): PressHandler | null;
2405
+ /**
2406
+ * Whether fingers that make a group are this layer's, asked as the second
2407
+ * goes down. A layer that takes them cancels the press of every finger in
2408
+ * it. Taken by nobody, the new finger is a press of its own.
2409
+ */
2410
+ group?(group: Group): GroupHandler | null;
2411
+ /** A mouse or a pen over the element with nothing pressed; `null` once it leaves. */
2412
+ hover?(at: Point | null, device: PointerDevice): void;
2413
+ /** How far a press may move, in CSS pixels, and still tap. 8 when left out. */
2414
+ slop?: number;
2415
+ /** How long a press stays still to hold, in milliseconds. 450 when left out. */
2416
+ holdMs?: number;
2417
+ };
2418
+ /**
2419
+ * A layer of pointers, being read: `input.pointers`.
2420
+ *
2421
+ * @group Input
2422
+ */
2423
+ type Pointers = {
2424
+ /** Whether a press or a group this layer took is down now. */
2425
+ readonly active: boolean;
2426
+ /** Take the layer off; whatever it holds is cancelled. */
2427
+ dispose(): void;
2428
+ };
2429
+ //#endregion
2430
+ //#region ../../../../../../../tmp/hopple-sdk-types-hbSZtA/game/src/input/wheel.d.ts
2431
+ /**
2432
+ * One turn of a wheel, swipe of a trackpad, or pinch on one, the same in every
2433
+ * browser: `input.wheel`.
2434
+ *
2435
+ * @group Input
2436
+ */
2437
+ type Wheel = {
2438
+ /** A mouse wheel's notches, a trackpad's scroll, or a trackpad's pinch (Ctrl and a wheel are one too). */
2439
+ kind: 'notch' | 'smooth' | 'pinch';
2440
+ /** How far, in CSS pixels, positive right and down. A notch is 100 in every browser. 0 for a pinch. */
2441
+ x: number;
2442
+ y: number;
2443
+ /**
2444
+ * Whole steps down, negative up: one for each notch, and on a trackpad one
2445
+ * as a swipe starts and another every 200 pixels after. What `mouse.wheelup`
2446
+ * and `mouse.wheeldown` press. 0 for a pinch.
2447
+ */
2448
+ steps: number;
2449
+ /** A pinch's zoom, above 1 closer. 1 for anything else. */
2450
+ scale: number;
2451
+ /** A twist on Safari's trackpad, in radians, clockwise. 0 for anything else. */
2452
+ rotate: number;
2453
+ /** Where the pointer is, in CSS pixels from the element's top left corner. */
2454
+ at: Point;
2455
+ modifiers: Modifiers;
2456
+ };
2457
+ /**
2458
+ * The wheel being taken over an element: `input.wheel`.
2459
+ *
2460
+ * @group Input
2461
+ */
2462
+ type WheelTaker = {
2463
+ /** What was taken since the last read, added up: for a game that reads once a frame. */
2464
+ read(): {
2465
+ x: number;
2466
+ y: number;
2467
+ steps: number;
2468
+ };
2469
+ /** Stop taking it. */
2470
+ dispose(): void;
2471
+ };
2472
+ //#endregion
2473
+ //#region ../../../../../../../tmp/hopple-sdk-types-hbSZtA/game/src/input/camera.d.ts
2474
+ /**
2475
+ * What the camera should do: one for each move of a finger, a pair of them,
2476
+ * a wheel or a glide, whichever it was.
2477
+ *
2478
+ * @group Input
2479
+ */
2480
+ type CameraChange = {
2481
+ /** Move what is shown by this, in CSS pixels: it follows the finger. */
2482
+ dx: number;
2483
+ dy: number;
2484
+ /** Zoom by this factor around `x`, `y`, above 1 closer; 1 when not zooming. */
2485
+ scale: number;
2486
+ /** Turn by this, in radians clockwise around `x`, `y`: two fingers, or Safari's trackpad. */
2487
+ rotate: number;
2488
+ /** The point zoomed and turned around, in CSS pixels from the element's top left corner. */
2489
+ x: number;
2490
+ y: number;
2491
+ /** What made it: so a game can treat a wheel differently from a finger. */
2492
+ source: 'drag' | 'pinch' | 'wheel' | 'trackpad' | 'glide';
2493
+ };
2494
+ /**
2495
+ * A press or a group of fingers the camera had that never moved.
2496
+ *
2497
+ * @group Input
2498
+ */
2499
+ type Tap = {
2500
+ at: Point;
2501
+ device: PointerDevice;
2502
+ /** The mouse button; `null` for fingers and a pen's tip. */
2503
+ button: PointerButton | null;
2504
+ /** How many fingers: 2 or 3 for a tap of that many. */
2505
+ fingers: number;
2506
+ modifiers: Modifiers;
2507
+ };
2508
+ /**
2509
+ * What a wheel does to a camera.
2510
+ *
2511
+ * @group Input
2512
+ */
2513
+ type WheelMode = 'zoom' | 'pan' | 'none';
2514
+ /**
2515
+ * @group Input
2516
+ */
2517
+ type CameraOptions = {
2518
+ /** A view to move with every change. */
2519
+ view?: View;
2520
+ /** Hear every change, with or without a view: for a camera of the game's own. */
2521
+ move?(change: CameraChange): void;
2522
+ /** A drag or a pinch was let go, at this velocity in CSS pixels a second. */
2523
+ end?(velocity: Point): void;
2524
+ /** A press or a group of fingers the camera had, let go without moving. */
2525
+ tap?(tap: Tap): void;
2526
+ /** A press the camera had, held still. It never taps then. */
2527
+ hold?(tap: Tap): void;
2528
+ /** Which mouse buttons drag. A finger and a pen always do. `['left', 'middle']` when left out. */
2529
+ buttons?: readonly PointerButton[];
2530
+ /**
2531
+ * What the wheel does. Left out, a wheel's notch zooms around the pointer and
2532
+ * a trackpad pans, the way maps do; `'zoom'` or `'pan'` makes both do that,
2533
+ * and `'none'` leaves the wheel alone. A function decides for each turn: a
2534
+ * menu open, Shift held. A pinch on a trackpad zooms unless it says `'none'`.
2535
+ */
2536
+ wheel?: WheelMode | ((wheel: Wheel) => WheelMode);
2537
+ /** Keep moving after a fling, slowing down, until the next press or wheel. */
2538
+ inertia?: boolean;
2539
+ /** How far a press may move, in CSS pixels, and still tap. 8 when left out. */
2540
+ slop?: number;
2541
+ /** How long a press stays still to hold, in milliseconds. 450 when left out. */
2542
+ holdMs?: number;
2543
+ };
2544
+ /**
2545
+ * A camera on an element: `input.camera`.
2546
+ *
2547
+ * @group Input
2548
+ */
2549
+ type Camera = {
2550
+ /** Whether a press or fingers the camera has are down now. */
2551
+ readonly active: boolean;
2552
+ /** Stop: the element's presses and its wheel go back to whoever else wants them. */
2553
+ dispose(): void;
2554
+ };
2555
+ /**
2556
+ * A camera over a flat world: `input.view`.
2557
+ *
2558
+ * The world is in a game's own units, with `y` down; `scale` is CSS pixels to
2559
+ * one of them, and `x`, `y` the world point at the element's top left corner.
2560
+ * A game draws with them, `screen = (world - x) * scale`, and may set any of
2561
+ * them; each move keeps them inside `min`, `max` and `bounds`.
2562
+ *
2563
+ * @group Input
2564
+ */
2565
+ type View = {
2566
+ x: number;
2567
+ y: number;
2568
+ scale: number;
2569
+ /** The one axis it moves along, for a strip; `null` for both. */
2570
+ readonly axis: 'x' | 'y' | null;
2571
+ /** Drag the view by this many CSS pixels, the world following the finger. */
2572
+ pan(dx: number, dy: number): void;
2573
+ /** Zoom by this factor, the world point at `x`, `y` staying where it is. */
2574
+ zoom(factor: number, x: number, y: number): void;
2575
+ /** Put the world point `x`, `y` in the middle of the element, at `scale` if given. */
2576
+ look(x: number, y: number, scale?: number): void;
2577
+ /** The world point at a point on the element. */
2578
+ toWorld(x: number, y: number): Point;
2579
+ /** The point on the element a world point is drawn at. */
2580
+ toScreen(x: number, y: number): Point;
2581
+ /**
2582
+ * Say how big the element is, in CSS pixels: what `look` centres on and
2583
+ * `bounds` keeps filled. Call it whenever the element changes size.
2584
+ */
2585
+ resize(width: number, height: number): void;
2586
+ };
2587
+ /**
2588
+ * @group Input
2589
+ */
2590
+ type ViewOptions = {
2591
+ x?: number;
2592
+ y?: number;
2593
+ scale?: number;
2594
+ /** The least `scale` it zooms out to. */
2595
+ min?: number;
2596
+ /** The most `scale` it zooms in to. */
2597
+ max?: number;
2598
+ /**
2599
+ * Move along this axis only, for a strip: the other never pans nor shifts
2600
+ * as it zooms, and a camera turns a vertical wheel into a pan along it.
2601
+ */
2602
+ axis?: 'x' | 'y';
2603
+ /**
2604
+ * The part of the world the view stays over, in world units: never scrolled
2605
+ * past an edge, and centred on it once all of it fits.
2606
+ */
2607
+ bounds?: {
2608
+ x: number;
2609
+ y: number;
2610
+ width: number;
2611
+ height: number;
2612
+ };
2613
+ /** The element's size in CSS pixels, as `resize` takes it. */
2614
+ width?: number;
2615
+ height?: number;
2616
+ };
2617
+ //#endregion
2618
+ //#region ../../../../../../../tmp/hopple-sdk-types-hbSZtA/game/src/input/lock.d.ts
2619
+ /**
2620
+ * The mouse held to the game: `input.pointerLock`.
2621
+ *
2622
+ * @group Input
2623
+ */
2624
+ type PointerLock = {
2625
+ /** Whether the mouse is locked to the game now. */
2626
+ readonly locked: boolean;
2627
+ /**
2628
+ * Lock the mouse to an element, the whole page when left out, now if the
2629
+ * browser allows it and on the player's next click or key if not.
2630
+ *
2631
+ * Asked again after the player has just left a lock, the browser makes them
2632
+ * wait about a second; the SDK waits with them. Ask from a press of the
2633
+ * player's where you can, a click on the game or the key that resumes it:
2634
+ * from a frame loop, the browser may not take it until they press something.
2635
+ */
2636
+ request(element?: Element): void;
2637
+ /** Let the mouse go, and stop waiting to take it. */
2638
+ release(): void;
2639
+ /**
2640
+ * Run this when the lock is taken or lost. Lost without `release` is the
2641
+ * player leaving it, with Escape or by switching away: the time to pause.
2642
+ * The SDK does not take it back on its own; `request` again on resuming.
2643
+ */
2644
+ on(listener: (locked: boolean) => void): Unsubscribe;
2645
+ /**
2646
+ * Run this for each move of the mouse while it is locked, in CSS pixels,
2647
+ * or in the mouse's own counts where the browser gives those
2648
+ * (`unadjustedMovement`). The jumps a browser sends as a lock starts are
2649
+ * left out.
2650
+ */
2651
+ onMove(listener: (dx: number, dy: number) => void): Unsubscribe;
2652
+ /**
2653
+ * How far the mouse moved while locked since the last read, added up the way
2654
+ * `onMove` hears it: for a game that reads once a frame.
2655
+ */
2656
+ read(): {
2657
+ x: number;
2658
+ y: number;
2659
+ };
2660
+ };
2661
+ //#endregion
2662
+ //#region ../../../../../../../tmp/hopple-sdk-types-hbSZtA/game/src/input/index.d.ts
2195
2663
  /**
2196
2664
  * A binding a game can name on its own, for a prompt about a button that is
2197
2665
  * not one of its actions: `pad.start`, `key.Space`.
@@ -2301,6 +2769,22 @@ type Input<Action extends string = string, Layout extends string = string, Playe
2301
2769
  describe(name: Action | ButtonName): string;
2302
2770
  /** The font family `glyph` draws in: name it, last, wherever a glyph is printed. */
2303
2771
  readonly font: string;
2772
+ /**
2773
+ * Draw an icon on an action's on-screen button instead of its label, or
2774
+ * `null` to go back to the label.
2775
+ *
2776
+ * hopple.input.icon('jump', 'M12 3 4 13h5v8h6v-8h5z');
2777
+ *
2778
+ * One SVG path, filled in the buttons' ink, in a 24 by 24 box: what icon
2779
+ * sets draw filled icons in. The label stays the button's name for a screen
2780
+ * reader. `glyph(action)` on a touch screen draws the same icon, so a prompt
2781
+ * matches the button. A path that cannot be read, or that leaves the box, is
2782
+ * reported to `onError` and the label is drawn instead.
2783
+ *
2784
+ * How the controls look otherwise is the game's stylesheet's: see the
2785
+ * skill's input guide.
2786
+ */
2787
+ icon(action: Action, path: string | null): void;
2304
2788
  /**
2305
2789
  * Stop reading input and let go of everything held.
2306
2790
  *
@@ -2312,6 +2796,55 @@ type Input<Action extends string = string, Layout extends string = string, Playe
2312
2796
  suspend(): void;
2313
2797
  resume(): void;
2314
2798
  readonly suspended: boolean;
2799
+ /**
2800
+ * Hear presses on an element, recognised and meaning nothing yet: a layer of
2801
+ * the game's, for its tools, its aim, its brush.
2802
+ *
2803
+ * hopple.input.pointers(canvas, {
2804
+ * press: (p) => tool === 'road' && p.button !== 'right' ? road(p) : null,
2805
+ * });
2806
+ *
2807
+ * Each press is offered to the layers on the element as it goes down, the
2808
+ * newest first and a `camera` last; the first to return a handler has it,
2809
+ * and hears it move, tap, hold, end or be cancelled. Two fingers or more are
2810
+ * offered as a group first: a layer that takes them cancels their presses.
2811
+ * A drag let go outside the frame still ends, a touch the browser took never
2812
+ * taps, and a finger coming or going moves nothing. The element gets
2813
+ * `touch-action: none` until its last layer is disposed.
2814
+ */
2815
+ pointers(element: Element, layer: PointerLayer): Pointers;
2816
+ /**
2817
+ * Take the wheel over an element: a mouse wheel, a trackpad's scroll and its
2818
+ * pinch, the same in every browser, as an amount and as whole steps.
2819
+ *
2820
+ * const wheel = hopple.input.wheel(list, (w) => void (scroll += w.y));
2821
+ *
2822
+ * The page does not scroll under it, and `mouse.wheelup` / `mouse.wheeldown`
2823
+ * do not hear it, unless the listener returns `false` for that turn.
2824
+ * `read()` adds up what was taken since it was last read.
2825
+ */
2826
+ wheel(element: Element, listener?: (wheel: Wheel) => boolean | void): WheelTaker;
2827
+ /**
2828
+ * A camera on an element, moved by whatever presses no other layer took:
2829
+ * one finger or a mouse button drags, two fingers pinch, pan and turn, a
2830
+ * mouse wheel zooms around the pointer and a trackpad pans and pinches, at
2831
+ * one speed in every browser.
2832
+ *
2833
+ * const view = hopple.input.view({ min: 0.5, max: 4, bounds: world });
2834
+ * hopple.input.camera(canvas, { view, tap: ({ at }) => select(view.toWorld(at.x, at.y)) });
2835
+ *
2836
+ * A `view` is moved for it; `move` hears every change, for a camera of the
2837
+ * game's own.
2838
+ */
2839
+ camera(element: Element, options: CameraOptions): Camera;
2840
+ /**
2841
+ * A camera over a flat world that `camera` moves, kept between `min` and
2842
+ * `max` and over `bounds`. Nothing in it is drawn: a game reads `x`, `y`
2843
+ * and `scale` when it draws.
2844
+ */
2845
+ view(options?: ViewOptions): View;
2846
+ /** The mouse held to the game, for a game that turns a camera with it. */
2847
+ readonly pointerLock: PointerLock;
2315
2848
  /**
2316
2849
  * The players on this device, each with their own copy of the actions
2317
2850
  * `input.player` declares, by `slot`. Empty for a game that declares none;
@@ -2412,7 +2945,7 @@ type Controls<Layout extends string = string> = {
2412
2945
  readonly available: boolean;
2413
2946
  };
2414
2947
  //#endregion
2415
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/lifecycle.d.ts
2948
+ //#region ../../../../../../../tmp/hopple-sdk-types-hbSZtA/game/src/lifecycle.d.ts
2416
2949
  /** @group Lifecycle */
2417
2950
  type LifecycleListener = (phase: Phase, previous: Phase) => void | Promise<void>;
2418
2951
  /**
@@ -2431,7 +2964,7 @@ type Lifecycle = {
2431
2964
  on(listener: LifecycleListener): Unsubscribe;
2432
2965
  };
2433
2966
  //#endregion
2434
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/loop.d.ts
2967
+ //#region ../../../../../../../tmp/hopple-sdk-types-hbSZtA/game/src/loop.d.ts
2435
2968
  /**
2436
2969
  * The host has let the game run its loop, or stopped it. Return a promise to
2437
2970
  * make the host wait.
@@ -2485,7 +3018,7 @@ type Loop = {
2485
3018
  tick(frame: FrameCallback): Unsubscribe;
2486
3019
  };
2487
3020
  //#endregion
2488
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/panel.d.ts
3021
+ //#region ../../../../../../../tmp/hopple-sdk-types-hbSZtA/game/src/panel.d.ts
2489
3022
  /**
2490
3023
  * The pages of the host's panel a game has a name for, as the keys of this
2491
3024
  * interface.
@@ -2623,7 +3156,7 @@ type Panel = {
2623
3156
  open(page: PageId): void;
2624
3157
  };
2625
3158
  //#endregion
2626
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/pause.d.ts
3159
+ //#region ../../../../../../../tmp/hopple-sdk-types-hbSZtA/game/src/pause.d.ts
2627
3160
  /**
2628
3161
  * The host has asked for a pause, or for the game to carry on.
2629
3162
  *
@@ -2684,7 +3217,7 @@ type Pause = {
2684
3217
  on(listener: PauseListener): Unsubscribe;
2685
3218
  };
2686
3219
  //#endregion
2687
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/resources.d.ts
3220
+ //#region ../../../../../../../tmp/hopple-sdk-types-hbSZtA/game/src/resources.d.ts
2688
3221
  /**
2689
3222
  * The host has let the game hold its resources again, or asked for them back.
2690
3223
  * Return a promise to make the host wait until they have gone, or come back.
@@ -2714,7 +3247,7 @@ type Resources = {
2714
3247
  on(listener: ResourcesListener): Unsubscribe;
2715
3248
  };
2716
3249
  //#endregion
2717
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/save.d.ts
3250
+ //#region ../../../../../../../tmp/hopple-sdk-types-hbSZtA/game/src/save.d.ts
2718
3251
  /**
2719
3252
  * What a game gets back from a read: its own schema number, and its state.
2720
3253
  *
@@ -2724,7 +3257,10 @@ type Resources = {
2724
3257
  type SaveState = {
2725
3258
  /** Whatever the game passed to `write`, or 1 where it never named one. */
2726
3259
  version: number;
2727
- /** Parsed where it was written as a value, verbatim where it was a string. */
3260
+ /**
3261
+ * Parsed where it was written as a value, verbatim where it was a string, and
3262
+ * a `Uint8Array` where it was one.
3263
+ */
2728
3264
  state: unknown;
2729
3265
  };
2730
3266
  /**
@@ -2764,20 +3300,41 @@ type SaveListener = (now: SaveStatus, previous: SaveStatus) => void;
2764
3300
  *
2765
3301
  * Pure: it is called with two states and must not touch the game's own. Run
2766
3302
  * while the game loads, its answer is what `read()` resolves with; run while
2767
- * the game plays, its answer goes to `onMerge` as well.
3303
+ * the game plays, its answer goes to `onChange` as well.
2768
3304
  *
2769
3305
  * @group Save
2770
3306
  * @category Useful
2771
3307
  */
2772
3308
  type SaveMerger = (mine: SaveState, theirs: SaveState) => SaveState;
2773
3309
  /**
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.
3310
+ * Why the save a game plays on changed under it.
3311
+ *
3312
+ * - `arrived`: another device's save, built on what the game had — a server
3313
+ * that answered after the game read, or another device that played on. Run
3314
+ * through the game's `merge` with what it last saved, where it has one.
3315
+ * - `merged`: the game's `merge` made one save of this device's and another
3316
+ * that went their own ways.
3317
+ * - `gone`: thrown away on another device, with nothing made here since. The
3318
+ * save is `null`.
2776
3319
  *
2777
3320
  * @group Save
2778
3321
  * @category Useful
2779
3322
  */
2780
- type SaveMergeListener = (merged: SaveState) => void;
3323
+ type SaveChangeReason = 'arrived' | 'merged' | 'gone';
3324
+ /**
3325
+ * Told the save the game now plays on, once it changed under it while it
3326
+ * played, and why: play on from this. `null` is a save thrown away on another
3327
+ * device (`gone`): start again.
3328
+ *
3329
+ * The host now holds what the listener is handed, and the game's next write
3330
+ * continues it. To keep the game's own instead — progress it has not saved
3331
+ * yet, or a New game the player has just chosen over a save that arrived
3332
+ * after — write it from the listener: it takes that save's place.
3333
+ *
3334
+ * @group Save
3335
+ * @category Useful
3336
+ */
3337
+ type SaveChangeListener = (save: SaveState | null, why: SaveChangeReason) => void;
2781
3338
  /**
2782
3339
  * What a game says about its save at `init`, before the host has asked
2783
3340
  * anything.
@@ -2823,10 +3380,12 @@ type Save = {
2823
3380
  /**
2824
3381
  * Keep this. Resolves when the host says the record is durable.
2825
3382
  *
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.
3383
+ * A string is stored as it stands and comes back a string; a `Uint8Array` is
3384
+ * stored as its bytes and comes back a `Uint8Array`, `maxBytes` counting the
3385
+ * bytes themselves; anything else is `JSON.stringify`d and comes back parsed.
3386
+ * A value that cannot survive that at all — a cycle, a `BigInt` — rejects
3387
+ * with `bad_params` before anything reaches the bridge, and bytes on a host
3388
+ * older than keeping them reject with `unsupported`.
2830
3389
  *
2831
3390
  * `version` is the game's own schema number and means whatever the game says
2832
3391
  * it means. There is no migration hook: a hook would be frozen game-side code
@@ -2839,19 +3398,31 @@ type Save = {
2839
3398
  /** Throw the save away — a game resetting its own progress, at a player's asking. */
2840
3399
  clear(): Promise<void>;
2841
3400
  /**
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.
3401
+ * Told when the save the game plays on changed under it, and why: play on
3402
+ * from what the listener is handed.
3403
+ *
3404
+ * That is another device's save arriving after the game read — a server
3405
+ * that answered late, a page left open while another device played on —
3406
+ * (`arrived`), or the game's own `merge` run while it played (`merged`), or
3407
+ * the save thrown away on another device with nothing made here since
3408
+ * (`gone`, `null`). Without a merge, an arrival is handed over as it is: it
3409
+ * is built on what the game had.
3410
+ *
3411
+ * Listening is what lets a game start before its save is in hand: draw from
3412
+ * nothing at once, and take the player's save when it comes. Register it
3413
+ * before `read()`. A game that is not listening is never written over —
3414
+ * what it writes next is kept beside what arrived, for its merge or the
3415
+ * player to settle.
2844
3416
  *
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.
3417
+ * To keep the game's own over what it is handed, write it from the
3418
+ * listener: that write takes the handed save's place.
2848
3419
  */
2849
- onMerge(listener: SaveMergeListener): Unsubscribe;
3420
+ onChange(listener: SaveChangeListener): Unsubscribe;
2850
3421
  /** The largest save this host will take, in bytes. `SAVE_BYTES` where it said nothing. */
2851
3422
  readonly maxBytes: number;
2852
3423
  };
2853
3424
  //#endregion
2854
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/score.d.ts
3425
+ //#region ../../../../../../../tmp/hopple-sdk-types-hbSZtA/game/src/score.d.ts
2855
3426
  /**
2856
3427
  * Where this player stands on every board, as far as anybody has said.
2857
3428
  *
@@ -2928,7 +3499,7 @@ type Score<Board extends string = string> = {
2928
3499
  }): Promise<ScoreResult>;
2929
3500
  };
2930
3501
  //#endregion
2931
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/share.d.ts
3502
+ //#region ../../../../../../../tmp/hopple-sdk-types-hbSZtA/game/src/share.d.ts
2932
3503
  /**
2933
3504
  * @group Share
2934
3505
  * @category Important
@@ -2955,9 +3526,18 @@ type Share = {
2955
3526
  * check it — the same care `save.read` deserves, for a stronger reason.
2956
3527
  *
2957
3528
  * **`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.
3529
+ * nobody arrived by one, or that the link carried bytes, which are `bytes`;
3530
+ * `available` is what says whether one can be made.
2959
3531
  */
2960
3532
  readonly data: string | null;
3533
+ /**
3534
+ * What the link that opened this game carried, where some run of this game
3535
+ * passed `offer` a `Uint8Array`: those bytes. `null` otherwise — a player who
3536
+ * arrived the ordinary way, or a link that carried a string, which is `data`.
3537
+ *
3538
+ * A stranger's input, exactly as `data` is.
3539
+ */
3540
+ readonly bytes: Uint8Array | null;
2961
3541
  /**
2962
3542
  * Ask the host to put a link to this game in front of the player.
2963
3543
  *
@@ -2967,23 +3547,26 @@ type Share = {
2967
3547
  * may keep a sheet open as long as they like, and pressing Share again while
2968
3548
  * one is up does not open a second.
2969
3549
  *
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`.
3550
+ * `data` is the game's own and travels with the link, opaque to the host,
3551
+ * back to whoever opens it: a string, which arrives as `share.data`, or a
3552
+ * `Uint8Array`, which arrives as `share.bytes`. The game reading it back is
3553
+ * the game that wrote it, so anything structured is the game's to encode and
3554
+ * the game's to parse — bytes pack a board far tighter than text does.
3555
+ * `SHARE_BYTES` is what every host carries, counted in bytes either way; more
3556
+ * than that is a host's own decision, and a host that will not carry it
3557
+ * refuses with `too_large`.
2976
3558
  *
2977
3559
  * `meta` is for the platform rather than for the game: why this link was made
2978
3560
  * — the level, the score, which of the game's buttons — kept beside the
2979
3561
  * host's own record of who made it and how, so a game's makers can learn
2980
3562
  * which of its shares bring people in. Anything JSON can say, and
2981
3563
  * `SHARE_META_BYTES` of it is what every host takes. Nobody who opens the link
2982
- * is handed it.
3564
+ * is handed it; the game's team reads it, with `data`, by `hopple share`.
2983
3565
  *
2984
3566
  * 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;
3567
+ * for a `data` that is neither a string nor a `Uint8Array`, or a `meta` JSON
3568
+ * cannot carry, which are bugs in the game; `unsupported` for bytes on a host
3569
+ * older than carrying them; `too_large` from a host for more than it carries;
2987
3570
  * `rate_limited` from one that will not offer a link right now. A host with
2988
3571
  * no link to give does nothing, which a game checking `available` never asks
2989
3572
  * of it. Every one of them is a game that carries on: nothing about a share
@@ -2995,12 +3578,12 @@ type Share = {
2995
3578
  * sheet on screen comes from the player's own gesture.
2996
3579
  */
2997
3580
  offer(options?: {
2998
- data?: string;
3581
+ data?: string | Uint8Array;
2999
3582
  meta?: ShareMeta;
3000
3583
  }): void;
3001
3584
  };
3002
3585
  //#endregion
3003
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/init.d.ts
3586
+ //#region ../../../../../../../tmp/hopple-sdk-types-hbSZtA/game/src/init.d.ts
3004
3587
  /**
3005
3588
  * What `init` hands back: every namespace a game has, on one object.
3006
3589
  *
@@ -3296,4 +3879,4 @@ type InitOptions = {
3296
3879
  */
3297
3880
  declare function init<M extends object = GameManifest>(options?: InitOptions): Promise<GameSdk<M>>;
3298
3881
  //#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 };
3882
+ 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 };