hopple 0.1.0-rc.1 → 0.1.0-rc.3

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/README.md CHANGED
@@ -9,6 +9,7 @@ The command-line tool for game developers:
9
9
  uploads it to a Hopple server.
10
10
  - `hopple list`, `login`, `logout` and `whoami` manage what you've published
11
11
  and who you publish as.
12
+ - `hopple collaborators` chooses who else may publish a game.
12
13
 
13
14
  It is a dev dependency of the game (`npm install --save-dev hopple`, which
14
15
  `hopple create` sets up), run with `npx hopple`. It is one compiled file with
@@ -19,7 +20,7 @@ whatever tool the game uses.
19
20
 
20
21
  ## The project's config
21
22
 
22
- `dev`, `check` and `publish` work on a **project**: a directory with a hopple
23
+ `dev`, `check`, `publish` and `collaborators` work on a **project**: a directory with a hopple
23
24
  config in it. They find it in the current directory, or the nearest one above
24
25
  it (like `tsconfig.json`). The config says everything they need to know:
25
26
 
@@ -45,9 +46,10 @@ export default {
45
46
  - **`build`** (optional) is the command that builds the game. It runs first, in
46
47
  the config's directory, and a failed build stops the command. So
47
48
  `npx hopple publish` can't upload a stale build. `--no-build` skips it.
48
- - **`page`** is the built HTML file, relative to the config. It is the one file
49
- that is played in the dev shell and published, so it must contain the whole
50
- game.
49
+ - **`page`** is the built HTML file, relative to the config: the `index.html`
50
+ of the build's output directory, which is played in the dev shell and
51
+ published whole. A page beside the config has no output directory, and is
52
+ published alone.
51
53
  - **`manifest`** is what the game is: its id, title, description, and what it
52
54
  declares. See [the manifest's reference](https://docs.hopple.app/manifest.md).
53
55
 
@@ -67,10 +69,11 @@ and errors in an editor, the manifest's included.
67
69
 
68
70
  ```
69
71
  hopple create <dir>
70
- hopple dev [project] [--port <n>] [--no-build]
72
+ hopple dev [project] [--port <n>] [--server <url>] [--no-build]
71
73
  hopple check [project] [--no-build]
72
74
  hopple publish [project] [--server <url>] [--no-build]
73
75
  hopple list [--server <url>]
76
+ hopple collaborators [add <handle> | remove <handle>] [project] [--server <url>]
74
77
  hopple login [--server <url>]
75
78
  hopple logout [--server <url>]
76
79
  hopple whoami [--server <url>]
@@ -98,8 +101,13 @@ Writes a new project into `<dir>`, which must be new or empty. The directory's
98
101
  name becomes the game's id (lowercase letters, digits and hyphens). It is the
99
102
  recommended setup, not a requirement:
100
103
 
101
- - **Vite** builds it, with `vite-plugin-singlefile` inlining every script,
102
- style and imported asset into `dist/index.html`.
104
+ - **Vite** builds it into `dist/`, with `base: './'` so every address in it
105
+ is relative, and `dist/index.html` as its page.
106
+ - **`index.html` loads the runtime as its first script**,
107
+ `<script src="_rt/1/hopple.js"></script>`. The runtime is the SDK, served
108
+ beside the game by whatever runs it; the `@hopple/sdk` package the game
109
+ imports is its types and a stub that forwards to it. So a fix to the SDK
110
+ reaches the game without a rebuild. Keep the tag first.
103
111
  - **`hopple.config.ts`** builds with `npm run build` (typecheck with `tsc`,
104
112
  then bundle), names `dist/index.html` as the page, and holds the manifest.
105
113
  Being TypeScript, a mistake in the manifest is a type error.
@@ -122,8 +130,13 @@ The dev server serves:
122
130
 
123
131
  - `/`: the dev shell.
124
132
  - `/game/`: the config's `page`, and `/game/…` the other files in its
125
- directory, with CORS enabled and caching disabled. Nothing outside that
126
- directory is served.
133
+ directory, with caching disabled. Nothing outside that directory is
134
+ served.
135
+ - `/game/_rt/1/hopple.js`: the runtime, beside the game as it is beside every
136
+ published version. It is the release the server's players get, fetched
137
+ from the server (`--server`, as for the other commands) when `hopple dev`
138
+ starts, or the copy this CLI carries when the server can't be reached; the
139
+ terminal says which.
127
140
 
128
141
  A valid manifest is shown in the shell. An invalid or missing one is reported
129
142
  in the terminal and on the page, naming the bad fields, and the game still
@@ -150,14 +163,31 @@ npx hopple check --no-build # as it was last built
150
163
  Everything `publish` checks before it uploads, without uploading:
151
164
 
152
165
  1. The manifest validates.
153
- 2. The **page** exists, and loads nothing from outside itself: no
154
- `<script src>`, stylesheet `<link>`, `<img>` or CSS `url()` that isn't a
155
- `data:` URL. Only that one file is published, so it must contain the whole
156
- game, with every script and asset inlined. (Files the game's code fetches
157
- can't be seen this way; they fail the same way.)
166
+ 2. The **page** exists and is its output directory's `index.html`, and loads
167
+ nothing the directory doesn't hold: every `<script src>`, stylesheet
168
+ `<link>`, `<img>` and CSS `url()` is a `data:` URL or a file in the
169
+ directory, referred to relatively. That directory is what is published, at
170
+ the root of the version's own address, and a game reaches nothing else.
171
+ (Files the game's code fetches can't be seen this way; they fail the same
172
+ way.) A page beside its config is published alone, so it must contain the
173
+ whole game. The runtime, `_rt/`, is not the game's: it is served beside
174
+ every game, and the directory may hold nothing there.
175
+ 3. The page loads the runtime as its first script,
176
+ `<script src="_rt/1/hopple.js"></script>`, as it is, and no page or
177
+ script carries a copy of the SDK. Games published before the runtime keep
178
+ the SDK they bundled, but a new upload built that way is refused.
179
+ 4. Nothing is addressed from the root (`/assets/x.png` names the root of
180
+ whatever serves the game, not the game), no page has a `<base>`, and every
181
+ page is UTF-8.
182
+ 5. No script uses `localStorage`, `sessionStorage`, IndexedDB, Cache
183
+ Storage or `document.cookie`: a game's origin keeps nothing past a reload,
184
+ and the runtime makes them throw. Use `save` instead.
185
+
186
+ The server checks the same, in the same words.
158
187
 
159
188
  It exits with 1 and says what is wrong, or prints the game's id, version and
160
- size.
189
+ size. Over 2 MB compressed it warns that a player on a phone waits for the
190
+ game, and over 10 MB `publish` refuses it.
161
191
 
162
192
  ### `hopple publish`
163
193
 
@@ -169,20 +199,28 @@ npx hopple publish path/to/project
169
199
  1. Makes every check `hopple check` makes, so mistakes are caught before
170
200
  anything is uploaded.
171
201
  2. Uploads the manifest and the page, and publishes them as
172
- `<your username>/<manifest id>`, as a new version. The game is listed with
202
+ `<owner>/<manifest id>`, as a new version. The owner is the manifest's
203
+ `owner`, or you when it names none; only the owner and the game's
204
+ collaborators may publish it. The game is listed with
173
205
  the manifest's `title` and `description`: to change them, change the
174
206
  manifest.
175
207
  3. Prints the version's address, whether it is live, and a link that opens that
176
208
  exact version.
177
209
 
178
- If you are a trusted user or an admin, the version goes live immediately.
210
+ If you are a trusted user or an admin, the version goes live immediately,
211
+ whoever owns the game.
179
212
  Otherwise it waits for an admin to review it, and the previous live version
180
213
  (if any) stays in the feed meanwhile.
181
214
 
215
+ Nothing is published for an anonymous account. Without `hopple login`, the
216
+ upload is kept and its link works, but it stays out of the feed, and `publish`
217
+ prints a warning saying so. Sign in before or after: either way the game ends
218
+ up in your account.
219
+
182
220
  ### `hopple login`, `logout`, `whoami`, `list`
183
221
 
184
222
  - The first command that talks to a server starts an **anonymous session**,
185
- so you can publish without an account.
223
+ named `anon-` and three words, so you can upload without an account.
186
224
  - `hopple login` signs that same session in. It prints a link and a short
187
225
  code, and waits: open the link in a browser where you are signed in to the
188
226
  site (or sign in there, any way the site offers), check that the page shows
@@ -191,7 +229,7 @@ Otherwise it waits for an admin to review it, and the previous live version
191
229
  Anything you published anonymously from this machine moves into your account.
192
230
  - `hopple whoami` shows who you are on that server and how you signed in.
193
231
  - `hopple logout` ends the session and forgets it.
194
- - `hopple list` shows each game you've published, its live version, its
232
+ - `hopple list` shows each game you own or collaborate on, its live version, its
195
233
  newest version if different (and whether it is waiting for review), and a
196
234
  link to each.
197
235
 
@@ -205,6 +243,23 @@ the CLI, under your Hopple player in our usage analytics. Nothing else is
205
243
  collected, and nothing is collected on your machine. Set `DO_NOT_TRACK=1` to
206
244
  leave your publishes and sign-ins out of those counts.
207
245
 
246
+ ### `hopple collaborators`
247
+
248
+ ```bash
249
+ npx hopple collaborators # who else may publish this project's game
250
+ npx hopple collaborators add ada # let ada publish it too
251
+ npx hopple collaborators remove ada
252
+ ```
253
+
254
+ A collaborator may publish new versions of the game. Nothing else: deleting
255
+ it and choosing who publishes it stay with its owner. The game is the one
256
+ `publish` would upload to, `<owner>/<manifest id>`. Only accounts can be added,
257
+ and each is told in their inbox.
258
+
259
+ To publish a game you collaborate on, set the manifest's `owner` to the
260
+ owner's handle. Without it, `publish` makes a game of your own instead. Its
261
+ versions go live or wait for review by your own trust, not the owner's.
262
+
208
263
  ## The dev shell
209
264
 
210
265
  The dev shell runs the game the way real hosts do (same sandbox, same bridge),
@@ -8,6 +8,32 @@ Licensed under MIT. The package ships no license text.
8
8
 
9
9
  --------------------------------------------------------------------------------
10
10
 
11
+ fflate 0.8.2 (MIT)
12
+
13
+ MIT License
14
+
15
+ Copyright (c) 2023 Arjun Barrett
16
+
17
+ Permission is hereby granted, free of charge, to any person obtaining a copy
18
+ of this software and associated documentation files (the "Software"), to deal
19
+ in the Software without restriction, including without limitation the rights
20
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21
+ copies of the Software, and to permit persons to whom the Software is
22
+ furnished to do so, subject to the following conditions:
23
+
24
+ The above copyright notice and this permission notice shall be included in all
25
+ copies or substantial portions of the Software.
26
+
27
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33
+ SOFTWARE.
34
+
35
+ --------------------------------------------------------------------------------
36
+
11
37
  react-dom 19.2.3 (MIT)
12
38
 
13
39
  MIT License