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

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-ky983p/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-ky983p/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-ky983p/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-ky983p/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-ky983p/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-ky983p/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-ky983p/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-ky983p/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-ky983p/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-ky983p/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.
@@ -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-ky983p/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-ky983p/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-ky983p/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-ky983p/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-ky983p/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-ky983p/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-ky983p/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-ky983p/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,7 @@ 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-ky983p/game/src/input/index.d.ts
2195
2246
  /**
2196
2247
  * A binding a game can name on its own, for a prompt about a button that is
2197
2248
  * not one of its actions: `pad.start`, `key.Space`.
@@ -2301,6 +2352,22 @@ type Input<Action extends string = string, Layout extends string = string, Playe
2301
2352
  describe(name: Action | ButtonName): string;
2302
2353
  /** The font family `glyph` draws in: name it, last, wherever a glyph is printed. */
2303
2354
  readonly font: string;
2355
+ /**
2356
+ * Draw an icon on an action's on-screen button instead of its label, or
2357
+ * `null` to go back to the label.
2358
+ *
2359
+ * hopple.input.icon('jump', 'M12 3 4 13h5v8h6v-8h5z');
2360
+ *
2361
+ * One SVG path, filled in the buttons' ink, in a 24 by 24 box: what icon
2362
+ * sets draw filled icons in. The label stays the button's name for a screen
2363
+ * reader. `glyph(action)` on a touch screen draws the same icon, so a prompt
2364
+ * matches the button. A path that cannot be read, or that leaves the box, is
2365
+ * reported to `onError` and the label is drawn instead.
2366
+ *
2367
+ * How the controls look otherwise is the game's stylesheet's: see the
2368
+ * skill's input guide.
2369
+ */
2370
+ icon(action: Action, path: string | null): void;
2304
2371
  /**
2305
2372
  * Stop reading input and let go of everything held.
2306
2373
  *
@@ -2412,7 +2479,7 @@ type Controls<Layout extends string = string> = {
2412
2479
  readonly available: boolean;
2413
2480
  };
2414
2481
  //#endregion
2415
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/lifecycle.d.ts
2482
+ //#region ../../../../../../../tmp/hopple-sdk-types-ky983p/game/src/lifecycle.d.ts
2416
2483
  /** @group Lifecycle */
2417
2484
  type LifecycleListener = (phase: Phase, previous: Phase) => void | Promise<void>;
2418
2485
  /**
@@ -2431,7 +2498,7 @@ type Lifecycle = {
2431
2498
  on(listener: LifecycleListener): Unsubscribe;
2432
2499
  };
2433
2500
  //#endregion
2434
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/loop.d.ts
2501
+ //#region ../../../../../../../tmp/hopple-sdk-types-ky983p/game/src/loop.d.ts
2435
2502
  /**
2436
2503
  * The host has let the game run its loop, or stopped it. Return a promise to
2437
2504
  * make the host wait.
@@ -2485,7 +2552,7 @@ type Loop = {
2485
2552
  tick(frame: FrameCallback): Unsubscribe;
2486
2553
  };
2487
2554
  //#endregion
2488
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/panel.d.ts
2555
+ //#region ../../../../../../../tmp/hopple-sdk-types-ky983p/game/src/panel.d.ts
2489
2556
  /**
2490
2557
  * The pages of the host's panel a game has a name for, as the keys of this
2491
2558
  * interface.
@@ -2623,7 +2690,7 @@ type Panel = {
2623
2690
  open(page: PageId): void;
2624
2691
  };
2625
2692
  //#endregion
2626
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/pause.d.ts
2693
+ //#region ../../../../../../../tmp/hopple-sdk-types-ky983p/game/src/pause.d.ts
2627
2694
  /**
2628
2695
  * The host has asked for a pause, or for the game to carry on.
2629
2696
  *
@@ -2684,7 +2751,7 @@ type Pause = {
2684
2751
  on(listener: PauseListener): Unsubscribe;
2685
2752
  };
2686
2753
  //#endregion
2687
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/resources.d.ts
2754
+ //#region ../../../../../../../tmp/hopple-sdk-types-ky983p/game/src/resources.d.ts
2688
2755
  /**
2689
2756
  * The host has let the game hold its resources again, or asked for them back.
2690
2757
  * Return a promise to make the host wait until they have gone, or come back.
@@ -2714,7 +2781,7 @@ type Resources = {
2714
2781
  on(listener: ResourcesListener): Unsubscribe;
2715
2782
  };
2716
2783
  //#endregion
2717
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/save.d.ts
2784
+ //#region ../../../../../../../tmp/hopple-sdk-types-ky983p/game/src/save.d.ts
2718
2785
  /**
2719
2786
  * What a game gets back from a read: its own schema number, and its state.
2720
2787
  *
@@ -2724,7 +2791,10 @@ type Resources = {
2724
2791
  type SaveState = {
2725
2792
  /** Whatever the game passed to `write`, or 1 where it never named one. */
2726
2793
  version: number;
2727
- /** Parsed where it was written as a value, verbatim where it was a string. */
2794
+ /**
2795
+ * Parsed where it was written as a value, verbatim where it was a string, and
2796
+ * a `Uint8Array` where it was one.
2797
+ */
2728
2798
  state: unknown;
2729
2799
  };
2730
2800
  /**
@@ -2764,20 +2834,41 @@ type SaveListener = (now: SaveStatus, previous: SaveStatus) => void;
2764
2834
  *
2765
2835
  * Pure: it is called with two states and must not touch the game's own. Run
2766
2836
  * while the game loads, its answer is what `read()` resolves with; run while
2767
- * the game plays, its answer goes to `onMerge` as well.
2837
+ * the game plays, its answer goes to `onChange` as well.
2768
2838
  *
2769
2839
  * @group Save
2770
2840
  * @category Useful
2771
2841
  */
2772
2842
  type SaveMerger = (mine: SaveState, theirs: SaveState) => SaveState;
2773
2843
  /**
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.
2844
+ * Why the save a game plays on changed under it.
2845
+ *
2846
+ * - `arrived`: another device's save, built on what the game had — a server
2847
+ * that answered after the game read, or another device that played on. Run
2848
+ * through the game's `merge` with what it last saved, where it has one.
2849
+ * - `merged`: the game's `merge` made one save of this device's and another
2850
+ * that went their own ways.
2851
+ * - `gone`: thrown away on another device, with nothing made here since. The
2852
+ * save is `null`.
2776
2853
  *
2777
2854
  * @group Save
2778
2855
  * @category Useful
2779
2856
  */
2780
- type SaveMergeListener = (merged: SaveState) => void;
2857
+ type SaveChangeReason = 'arrived' | 'merged' | 'gone';
2858
+ /**
2859
+ * Told the save the game now plays on, once it changed under it while it
2860
+ * played, and why: play on from this. `null` is a save thrown away on another
2861
+ * device (`gone`): start again.
2862
+ *
2863
+ * The host now holds what the listener is handed, and the game's next write
2864
+ * continues it. To keep the game's own instead — progress it has not saved
2865
+ * yet, or a New game the player has just chosen over a save that arrived
2866
+ * after — write it from the listener: it takes that save's place.
2867
+ *
2868
+ * @group Save
2869
+ * @category Useful
2870
+ */
2871
+ type SaveChangeListener = (save: SaveState | null, why: SaveChangeReason) => void;
2781
2872
  /**
2782
2873
  * What a game says about its save at `init`, before the host has asked
2783
2874
  * anything.
@@ -2823,10 +2914,12 @@ type Save = {
2823
2914
  /**
2824
2915
  * Keep this. Resolves when the host says the record is durable.
2825
2916
  *
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.
2917
+ * A string is stored as it stands and comes back a string; a `Uint8Array` is
2918
+ * stored as its bytes and comes back a `Uint8Array`, `maxBytes` counting the
2919
+ * bytes themselves; anything else is `JSON.stringify`d and comes back parsed.
2920
+ * A value that cannot survive that at all — a cycle, a `BigInt` — rejects
2921
+ * with `bad_params` before anything reaches the bridge, and bytes on a host
2922
+ * older than keeping them reject with `unsupported`.
2830
2923
  *
2831
2924
  * `version` is the game's own schema number and means whatever the game says
2832
2925
  * it means. There is no migration hook: a hook would be frozen game-side code
@@ -2839,19 +2932,31 @@ type Save = {
2839
2932
  /** Throw the save away — a game resetting its own progress, at a player's asking. */
2840
2933
  clear(): Promise<void>;
2841
2934
  /**
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.
2935
+ * Told when the save the game plays on changed under it, and why: play on
2936
+ * from what the listener is handed.
2937
+ *
2938
+ * That is another device's save arriving after the game read — a server
2939
+ * that answered late, a page left open while another device played on —
2940
+ * (`arrived`), or the game's own `merge` run while it played (`merged`), or
2941
+ * the save thrown away on another device with nothing made here since
2942
+ * (`gone`, `null`). Without a merge, an arrival is handed over as it is: it
2943
+ * is built on what the game had.
2844
2944
  *
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.
2945
+ * Listening is what lets a game start before its save is in hand: draw from
2946
+ * nothing at once, and take the player's save when it comes. Register it
2947
+ * before `read()`. A game that is not listening is never written over —
2948
+ * what it writes next is kept beside what arrived, for its merge or the
2949
+ * player to settle.
2950
+ *
2951
+ * To keep the game's own over what it is handed, write it from the
2952
+ * listener: that write takes the handed save's place.
2848
2953
  */
2849
- onMerge(listener: SaveMergeListener): Unsubscribe;
2954
+ onChange(listener: SaveChangeListener): Unsubscribe;
2850
2955
  /** The largest save this host will take, in bytes. `SAVE_BYTES` where it said nothing. */
2851
2956
  readonly maxBytes: number;
2852
2957
  };
2853
2958
  //#endregion
2854
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/score.d.ts
2959
+ //#region ../../../../../../../tmp/hopple-sdk-types-ky983p/game/src/score.d.ts
2855
2960
  /**
2856
2961
  * Where this player stands on every board, as far as anybody has said.
2857
2962
  *
@@ -2928,7 +3033,7 @@ type Score<Board extends string = string> = {
2928
3033
  }): Promise<ScoreResult>;
2929
3034
  };
2930
3035
  //#endregion
2931
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/share.d.ts
3036
+ //#region ../../../../../../../tmp/hopple-sdk-types-ky983p/game/src/share.d.ts
2932
3037
  /**
2933
3038
  * @group Share
2934
3039
  * @category Important
@@ -2955,9 +3060,18 @@ type Share = {
2955
3060
  * check it — the same care `save.read` deserves, for a stronger reason.
2956
3061
  *
2957
3062
  * **`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.
3063
+ * nobody arrived by one, or that the link carried bytes, which are `bytes`;
3064
+ * `available` is what says whether one can be made.
2959
3065
  */
2960
3066
  readonly data: string | null;
3067
+ /**
3068
+ * What the link that opened this game carried, where some run of this game
3069
+ * passed `offer` a `Uint8Array`: those bytes. `null` otherwise — a player who
3070
+ * arrived the ordinary way, or a link that carried a string, which is `data`.
3071
+ *
3072
+ * A stranger's input, exactly as `data` is.
3073
+ */
3074
+ readonly bytes: Uint8Array | null;
2961
3075
  /**
2962
3076
  * Ask the host to put a link to this game in front of the player.
2963
3077
  *
@@ -2967,23 +3081,26 @@ type Share = {
2967
3081
  * may keep a sheet open as long as they like, and pressing Share again while
2968
3082
  * one is up does not open a second.
2969
3083
  *
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`.
3084
+ * `data` is the game's own and travels with the link, opaque to the host,
3085
+ * back to whoever opens it: a string, which arrives as `share.data`, or a
3086
+ * `Uint8Array`, which arrives as `share.bytes`. The game reading it back is
3087
+ * the game that wrote it, so anything structured is the game's to encode and
3088
+ * the game's to parse — bytes pack a board far tighter than text does.
3089
+ * `SHARE_BYTES` is what every host carries, counted in bytes either way; more
3090
+ * than that is a host's own decision, and a host that will not carry it
3091
+ * refuses with `too_large`.
2976
3092
  *
2977
3093
  * `meta` is for the platform rather than for the game: why this link was made
2978
3094
  * — the level, the score, which of the game's buttons — kept beside the
2979
3095
  * host's own record of who made it and how, so a game's makers can learn
2980
3096
  * which of its shares bring people in. Anything JSON can say, and
2981
3097
  * `SHARE_META_BYTES` of it is what every host takes. Nobody who opens the link
2982
- * is handed it.
3098
+ * is handed it; the game's team reads it, with `data`, by `hopple share`.
2983
3099
  *
2984
3100
  * 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;
3101
+ * for a `data` that is neither a string nor a `Uint8Array`, or a `meta` JSON
3102
+ * cannot carry, which are bugs in the game; `unsupported` for bytes on a host
3103
+ * older than carrying them; `too_large` from a host for more than it carries;
2987
3104
  * `rate_limited` from one that will not offer a link right now. A host with
2988
3105
  * no link to give does nothing, which a game checking `available` never asks
2989
3106
  * of it. Every one of them is a game that carries on: nothing about a share
@@ -2995,12 +3112,12 @@ type Share = {
2995
3112
  * sheet on screen comes from the player's own gesture.
2996
3113
  */
2997
3114
  offer(options?: {
2998
- data?: string;
3115
+ data?: string | Uint8Array;
2999
3116
  meta?: ShareMeta;
3000
3117
  }): void;
3001
3118
  };
3002
3119
  //#endregion
3003
- //#region ../../../../../../../tmp/hopple-sdk-types-SLrqDf/game/src/init.d.ts
3120
+ //#region ../../../../../../../tmp/hopple-sdk-types-ky983p/game/src/init.d.ts
3004
3121
  /**
3005
3122
  * What `init` hands back: every namespace a game has, on one object.
3006
3123
  *
@@ -3296,4 +3413,4 @@ type InitOptions = {
3296
3413
  */
3297
3414
  declare function init<M extends object = GameManifest>(options?: InitOptions): Promise<GameSdk<M>>;
3298
3415
  //#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 };
3416
+ 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 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 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 Unsubscribe, init, insetsFrom };
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hopple/sdk 1.0.0-next.1 | Copyright (c) 2026 The Hopple authors | MIT License */
1
+ /*! @hopple/sdk 1.0.0-next.5 | Copyright (c) 2026 The Hopple authors | MIT License */
2
2
  // The SDK runs from the runtime the page loads as its first script, which
3
3
  // defines the global `Hopple`; this forwards each export to it.
4
4
  const runtime = globalThis.Hopple;