@hopple/sdk 0.1.0-rc.3 → 1.0.0-next.1

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/manifest.md CHANGED
@@ -15,37 +15,40 @@ and the host never asks the game what it is allowed to do.
15
15
 
16
16
  ```json
17
17
  {
18
- "schema": 1,
18
+ "api": "1.0",
19
19
  "id": "ping",
20
20
  "version": "1.0.0",
21
21
  "title": "Ping",
22
22
  "orientation": "portrait",
23
- "sdk": "^0.1.0",
24
23
  "audio": null
25
24
  }
26
25
  ```
27
26
 
28
- These seven keys are required. Everything else is optional.
27
+ These six keys are required. Everything else is optional. A hopple config may
28
+ leave `api` and `previews` out: the CLI fills `api` from the installed
29
+ `@hopple/sdk`, and `previews` from the preview packages the project installs.
29
30
 
30
31
  | Key | Rules | Meaning |
31
32
  |---|---|---|
32
- | `schema` | `1` | The manifest format version. |
33
+ | `api` | `MAJOR.MINOR`, or `next` | The API the game is written against: the major picks what the game is served, the minor is the least it needs. `next` is the pre-releases of the next stable release. Left out of a config, the CLI takes it from the installed `@hopple/sdk` (`1.6.2` is `1.6`, a pre-release is `next`), and refuses one that differs. Publishing is refused until the major has a release of that minor, on `next` until it has a release, and on `next` for users who are neither trusted, admins, nor explicitly granted access. |
33
34
  | `id` | lowercase letters, digits and single hyphens; at most 64 characters | The game's name. On the server, a game is `<owner>/<id>`. |
34
35
  | `version` | `MAJOR.MINOR.PATCH`, optional `-prerelease` | The game's own version. Shown to the game as `sdk.info.game.version`. |
35
36
  | `title` | at most 60 characters | What players see. |
36
37
  | `description` | optional; at most 500 characters | A sentence or two shown beside the title. |
37
38
  | `orientation` | `portrait`, `landscape` or `any` | The shape the game is designed for. Hosts lay the game out to match. |
38
- | `sdk` | a version, optionally with `^` or `~` | The SDK the game was built against. Recorded, not enforced; the protocol handshake is what checks compatibility. |
39
39
  | `audio` | `null`, or an object | Whether the game makes sound, and its volume channels. See [`audio`](#audio). |
40
40
 
41
41
  ## Validating
42
42
 
43
- `hopple check` validates the manifest and names every problem with its field.
44
- The CLI, the dev shell, the server and the clients all use the same function,
45
- so they always agree on whether a manifest is valid.
43
+ `hopple check` validates the manifest and names every problem with its field,
44
+ with the validator of the installed `@hopple/sdk`, which is of the API the
45
+ game declares. The CLI, the dev shell, the server and the clients all use the
46
+ same function, so they agree on whether a manifest is valid.
46
47
 
47
- - **Unknown keys are allowed.** A game built with a newer SDK may declare
48
- things an older host doesn't know about, and must still run there.
48
+ - **Unknown keys are refused.** A misspelt key (such as `"orientaton"`) is an
49
+ error, not silently ignored. A host reading a published manifest ignores
50
+ keys it doesn't know (`validateManifest(value, { lenient: true })`), since
51
+ the game may be written against a newer minor than the host.
49
52
  - **Known keys are checked strictly.** A misspelt value (such as
50
53
  `"draw_under"`) is an error, not silently ignored.
51
54
 
@@ -242,6 +245,36 @@ the host's sheet; a tap of Start is still the game's.
242
245
 
243
246
  Limits: 64 actions, 8 bindings per action, 8 control layouts.
244
247
 
248
+ #### Several players on one device
249
+
250
+ ```json
251
+ "players": { "local": 4, "online": 8 },
252
+ "input": {
253
+ "actions": { "pause": { "bind": ["key.KeyP", "pad.start"] } },
254
+ "player": {
255
+ "actions": {
256
+ "bomb": { "bind": ["pad.south"], "title": "Drop bomb", "join": true }
257
+ },
258
+ "keyboard": [
259
+ { "title": "Left keys", "bind": { "bomb": ["key.Space"] } },
260
+ { "title": "Arrows", "bind": { "bomb": ["key.Enter"] } }
261
+ ]
262
+ }
263
+ }
264
+ ```
265
+
266
+ - **`input.player.actions`**: what each local player does, a copy each. Their
267
+ `bind` holds pad buttons and on-screen controls only, the same for every
268
+ pad. An id is never one `input.actions` declares too. `join: true` marks the
269
+ actions that seat a new player; on none, any does.
270
+ - **`input.player.keyboard`**: the parts of the keyboard players share, one
271
+ player each (at most 4): a `title` and the keys and mouse buttons of each
272
+ player action. A key in two parts is refused.
273
+ - **`players.local`**: the most players on one device, 1 by default; more
274
+ than 1 needs `input.player`.
275
+
276
+ Limits: 32 player actions.
277
+
245
278
  ### audio
246
279
 
247
280
  ```json
@@ -262,6 +295,36 @@ Each channel gets its own labelled volume slider in the host's sound controls.
262
295
  `title` is required: it is the slider's label. `master` is reserved, since
263
296
  every host already has a master volume. At most 8 channels.
264
297
 
298
+ ### previews
299
+
300
+ ```json
301
+ "previews": { "network": 1 }
302
+ ```
303
+
304
+ The parts of the SDK that are not stable yet, each at the revision the game
305
+ is written against. A preview is its own `0.x` package, versioned apart from
306
+ `api`: revision `R` is `@hopple/sdk-preview-network` `0.R.x`. A game is served a runtime
307
+ with the previews it declares, at those revisions, so a change to a preview
308
+ reaches only the games written against it. A breaking change is a new
309
+ revision. A name nobody knows is refused, and a revision is a whole number
310
+ from 1.
311
+
312
+ Left out of a config, the CLI fills each preview from its installed package,
313
+ for a project whose `package.json` lists it, as it fills `api`, and refuses
314
+ one that differs from the installed revision, or that names one with none
315
+ installed. Publishing a game that declares any preview needs what `next`
316
+ needs. Once a newer revision of a preview is out, the older one is retired:
317
+ games whose `latest` is on it are unlisted and lose `beta`, keeping their
318
+ approval and links, and an upload declaring it is refused.
319
+
320
+ - **`network`**: the game plays over the network, in matches: `sdk.match`,
321
+ typed by `@hopple/sdk-preview-network`. It is the permission a reviewer grants, and what
322
+ lets a host offer *Play with friends* before the game has loaded. Nothing
323
+ else is declared: how a match is played, and its size, are chosen when the
324
+ game makes one.
325
+ Without it, a game is never told about a match, and `sdk.match` is not
326
+ there.
327
+
265
328
  ## Changing the manifest in a new version
266
329
 
267
330
  The server refuses a new version whose manifest would corrupt data players
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hopple/sdk",
3
- "version": "0.1.0-rc.3",
3
+ "version": "1.0.0-next.1",
4
4
  "description": "The Hopple SDK: what a game imports to talk to the host that runs it, forwarded to the runtime its page loads.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://hopple.app",
@@ -21,6 +21,10 @@
21
21
  "types": "./index.d.ts",
22
22
  "default": "./index.js"
23
23
  },
24
+ "./manifest": {
25
+ "types": "./manifest.d.ts",
26
+ "default": "./manifest.js"
27
+ },
24
28
  "./config.schema.json": "./config.schema.json",
25
29
  "./package.json": "./package.json"
26
30
  },