dewctl 0.10.0 → 0.11.0

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
@@ -88,6 +88,24 @@ dewctl eval 'game.player.position'
88
88
  dewctl resume
89
89
  ```
90
90
 
91
+ ## Named dev versions
92
+
93
+ A game runs up to eight dev versions beside its first, each at a link of its
94
+ own, so several agents working on different parts of a game can each show
95
+ their own. `dewctl dev --new terrain` starts the dev version `terrain`, and is
96
+ refused while one of that name runs, so pick another name; `dewctl status`
97
+ lists the ones running. After that, `--name terrain` reaches it from `dev`,
98
+ `stop`, `publish`, `status`, `logs`, `seat`, `sessions`, `eval`, `pause`,
99
+ `resume`, `step`, `speed` and `repl`. A name is 1 to 10 lowercase letters,
100
+ digits or dashes, and every dev version shares the game's dev saves.
101
+
102
+ ```sh
103
+ dewctl dev --new terrain # starts it; refused if terrain runs
104
+ dewctl dev --name terrain --watch # uploads to it on every save
105
+ dewctl seat --name terrain --out .dewdrop-seat.json
106
+ dewctl stop --name terrain # frees the name
107
+ ```
108
+
91
109
  ## License
92
110
 
93
111
  MIT
@@ -108,9 +108,9 @@ For each: what to ask, why it changes the build, and what to take when the user
108
108
  change it at a moment the player won't mind. Default: the recipe's.
109
109
  - **Light.** Where the light comes from: the sun and the sky, lamps, candles, neon, a moon, glowing windows. A
110
110
  sun is a `DirectionalLight`, the sky a `HemisphereLight`, a lamp a `PointLight` or `SpotLight`, and a candle,
111
- a lit window or a neon tube a mesh that glows, which lights what's near it. Every light casts shadows by
112
- itself; ask whether they're soft (a hazy sun, `userData.angle` about 0.03) or hard and long (a low, small sun).
113
- Default: the recipe's ([lights and materials](https://alpha.dewdrop.world/docs/lighting)).
111
+ a lit window, a neon tube or a lantern's shade a mesh that glows, which lights what's near it. Every light casts
112
+ shadows by itself; ask whether they're soft (a hazy sun, `userData.angle` about 0.03) or hard and long (a low,
113
+ small sun). Default: the recipe's ([lights and materials](https://alpha.dewdrop.world/docs/lighting)).
114
114
  - **How dark.** For a night or an indoor look: "can the player see the whole room, or only what the light
115
115
  reaches?" Night is dim lights over everyday colors, with a fixed exposure so it stays dark; only what the light
116
116
  reaches means `localShadows` at 1 and lights placed where the player should look
@@ -165,9 +165,9 @@ Two or three per medium, each changing shapes, light or colors. Skip what the us
165
165
  is a glowing mesh that lights the wet ground below it.
166
166
  - **Noir:** black and white, or a tint? One hard light per scene, so the shadows agree?
167
167
  - **Horror:** a carried candle, fixed candles, or moonlight through the windows? How far can the player see?
168
- A carried candle is a glowing flame with a `PointLight` that moves with the player. Flames about 5 × 11 cm;
169
- smaller ones read as unlit.
170
- - **Winter:** overcast, or sunny? Snowfall in the prompt's words, or none: falling flakes can't be built.
168
+ A carried candle is a glowing flame that moves with the player and lights what's around it. Flames about
169
+ 5 × 11 cm; smaller ones read as unlit.
170
+ - **Winter:** overcast, or sunny? Snowfall in the prompt's words, or none?
171
171
  - **Golden hour:** where is the sun, and so which faces are gold and which blue-green? Does it set while playing?
172
172
  The view toward the sun reads most golden.
173
173
  - **Underwater:** how murky, and how far can the player see? Does the light come from the surface, or from
@@ -251,14 +251,15 @@ and [lights and materials](https://alpha.dewdrop.world/docs/lighting) each light
251
251
  | --- | --- |
252
252
  | softer, dreamier | a hazier sun (`userData.angle` 0.02 to 0.05) and a brighter sky light; paler colors; "soft, diffused" light in the style phrase; fewer small meshes far away |
253
253
  | darker, moodier | dimmer lights and a fixed exposure, the colors kept; the light words in the style phrase ("dim candlelight", "hard low-key lighting") |
254
- | a carried candle or torch | a glowing flame mesh with a `PointLight` at it, moving with the player |
254
+ | a carried candle or torch | a glowing flame mesh moving with the player, which lights what's around it |
255
255
  | a lit side and a dark side, long shadows | a low `DirectionalLight` sun with a weaker sky light; a smaller `userData.angle` for harder edges |
256
256
  | warmer, colder | the lights' colors: a warm sun and a cool sky, or the other way round |
257
257
  | more detail, more realistic | more meshes and truer shapes, the biggest where the camera goes; textures on the large surfaces |
258
258
  | fog, mist, rain, god rays | words in the prompt's scene sentence |
259
- | smoke, steam, dust | words in the prompt; no mesh works for a plume. Sparks and embers are small transparent glowing meshes |
259
+ | smoke, steam, dust | words in the prompt. Sparks and embers are small transparent glowing meshes |
260
260
  | wood grain, fabric, rust, any texture | a texture of it as the material's `map`, and the material in the words |
261
261
  | glow, neon, fire, a lit window | a mesh with an `emissive` color and `emissiveIntensity`, which lights what's near it |
262
+ | a lantern, a frosted globe | the shade or the lantern's windows glow: a light inside a closed shade is hidden by it, but still shines through an open bottom or cut-out holes |
262
263
  | shiny, polished, metal | low `roughness`; `metalness` 1 with the metal's own color for metal |
263
264
  | glass, water, ice | a transparent material with `userData.modelLayer = 'surface'`, described as the surface |
264
265
  | wet ground, reflections | the ground at low `roughness`, which shows the lights in it, and "wet" in its words |
@@ -55,15 +55,19 @@ Light and color ([lights and materials](https://alpha.dewdrop.world/docs/lightin
55
55
  - **Light the scene as for three.js's own renderer:** a sun (`DirectionalLight`) and a sky (`HemisphereLight`)
56
56
  for daylight, lamps (`PointLight`, `SpotLight`) and glowing meshes at night. Every light casts shadows, with no
57
57
  `castShadow` needed, and light bounces. A scene with no light shows every surface evenly at its own color; once
58
- the game adds one, only its lights light it, so give it a sky as well as a sun.
58
+ the game adds a light or a glowing mesh, only its lights and glowing meshes light it, so give it a sky as well
59
+ as a sun.
59
60
  - **Brightness is relative.** The exposure adapts, so what matters is each light next to the others. A sun's
60
61
  `userData.angle` softens its shadows: 0.02 to 0.05 gives a hazy sun.
61
62
  - **Night is dim light, not dark colors.** Keep the materials' everyday colors, turn the lights down, and fix the
62
63
  exposure so the night stays dark: `renderer.exposure = { ev: 2, strength: 0 }`, its `ev` chosen on Dewdrop
63
64
  ([a fixed exposure](https://alpha.dewdrop.world/docs/lighting#a-fixed-exposure)).
64
65
  - **A glowing thing is a mesh that glows:** a lamp, a candle flame, a lit window or neon is a material's
65
- `emissive` times its `emissiveIntensity`, and it lights what's around it. For a light carried by a character,
66
- add a `PointLight` at the flame ([glowing things](https://alpha.dewdrop.world/docs/lighting#glowing-things)).
66
+ `emissive` times its `emissiveIntensity`, and it lights what's around it, so a candle can light a dark room by
67
+ itself. Only an opaque mesh with a lit material (`MeshStandardMaterial` and the like) lights its surroundings;
68
+ a transparent one, sprites and points glow but light nothing. A light inside a closed shade, such as a paper
69
+ lantern, is hidden by it: make the shade or the lantern's windows glow instead
70
+ ([glowing things](https://alpha.dewdrop.world/docs/lighting#glowing-things)).
67
71
  - **Give every mesh a material with a color.** `MeshStandardMaterial` takes highlights by its `roughness` (0
68
72
  polished to 1 matte) and `metalness`; `MeshBasicMaterial` is unlit. A geometry needs normals to be lit.
69
73
  - **Textures show** (`map`, `emissiveMap`, `alphaMap`, `normalMap`) from PNG, JPEG or WebP, glTF models and
@@ -85,10 +89,9 @@ Shapes ([shapes](https://alpha.dewdrop.world/docs/renderer#shapes)):
85
89
  parts a few meters from anywhere the camera goes, and characters 2.5 m or more. In first person, hold items 0.6
86
90
  to 0.7 m from the camera, as its children ([camera](https://alpha.dewdrop.world/docs/camera)).
87
91
  - **Small moving things lose their shape.** Make what matters large in frame. Fish, flocks and sparks: muted,
88
- about 0.6 m long or more, 8 m or more from the camera. Turn flat things to face the camera
92
+ about 0.6 m long or more, 8 m or more from the camera
89
93
  ([what to watch for](https://alpha.dewdrop.world/docs/renderer#what-to-watch-for)).
90
- - **Atmosphere is words.** Mist, rain, god rays, smoke and steam go in the prompt's scene sentence: no mesh works
91
- for a plume of smoke.
94
+ - **Atmosphere is words.** Haze, mist, rain and god rays go in the prompt's scene sentence.
92
95
 
93
96
  Words ([prompt and descriptions](https://alpha.dewdrop.world/docs/prompting)):
94
97
  - **The prompt has exactly this form:** `style: <style phrase>. <scene sentence>`, 15 to 35 words in all.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dewctl",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Build and publish three.js games on Dewdrop.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/client.js CHANGED
@@ -41,8 +41,13 @@ export class Client {
41
41
  // `partBytes` is for the tests, which cut at a few bytes; a push's requests and a file's parts are PART_BYTES.
42
42
  // `pollMs` is the least a wait on Dewdrop takes a round: a request Dewdrop holds is answered when there is news,
43
43
  // within WAIT_S, and an answer without news that comes at once is asked again after that long.
44
- // `confirmed` holds the hashes of the files Dewdrop has been seen to have, for this run.
45
- constructor(origin,credentials,{fetcher=fetch,pollMs=1000,timeoutMs=180000,storeMs=15*60*1000,partBytes=PART_BYTES}={}){this.origin=origin;this.credentials=credentials;this.fetcher=fetcher;this.pollMs=pollMs;this.timeoutMs=timeoutMs;this.storeMs=storeMs;this.partBytes=partBytes;this.holds=true;this.confirmed=new Set();}
44
+ // `confirmed` holds the hashes of the files Dewdrop has been seen to have, for this run. `devName` names the dev
45
+ // version every request of the game's dev version reaches, '' the game's first; with `fresh`, each game's first upload
46
+ // starts it, refused while it runs, so two developers or agents never share a name unknowingly, and later ones update
47
+ // it: `started` holds the games it was started in, a watcher moving to another game starting it there afresh.
48
+ constructor(origin,credentials,{fetcher=fetch,pollMs=1000,timeoutMs=180000,storeMs=15*60*1000,partBytes=PART_BYTES,devName='',fresh=false}={}){this.origin=origin;this.credentials=credentials;this.fetcher=fetcher;this.pollMs=pollMs;this.timeoutMs=timeoutMs;this.storeMs=storeMs;this.partBytes=partBytes;this.holds=true;this.confirmed=new Set();this.devName=devName;this.fresh=fresh;this.started=new Set();}
49
+ // `path` of the game or its dev version, reaching the dev version `devName` names.
50
+ #named(path){return this.devName?`${path}${path.includes('?')?'&':'?'}name=${this.devName}`:path;}
46
51
  // A request signed in with `token`. When Dewdrop can't be reached the failure is marked transient, which a watcher
47
52
  // or a sign-in waits out; a refused token asks for a new sign-in, whatever Dewdrop's words.
48
53
  async request(path,{method='GET',body,token,signal,type,prefer}={}) {
@@ -74,7 +79,7 @@ export class Client {
74
79
  return current;
75
80
  }
76
81
  async api(path,options={}){return this.request(path,{...options,token:this.session().token});}
77
- game(game,signal){return this.api(`/v1/games/${game}`,{signal});}
82
+ game(game,signal){return this.api(this.#named(`/v1/games/${game}`),{signal});}
78
83
  releases(game){return this.api(`/v1/games/${game}/releases`);}
79
84
  deleteRelease(game,release){return this.api(`/v1/games/${game}/releases/${release}`,{method:'DELETE'});}
80
85
  deleteGame(game){return this.api(`/v1/games/${game}`,{method:'DELETE'});}
@@ -170,7 +175,9 @@ export class Client {
170
175
  // Points a version at a release, then follows the game until that version is ready, fails, or somebody points it
171
176
  // elsewhere. The PUT answers with the game, so it is the first look, handed to `started` before the wait.
172
177
  async point(game,version,release,signal,started) {
173
- let state=await this.api(`/v1/games/${game}/${version}`,{method:'PUT',body:{release},signal});
178
+ const fresh=version==='dev'&&release!==null&&this.fresh&&!this.started.has(game);
179
+ let state=await this.api(version==='dev'?this.#named(`/v1/games/${game}/dev`):`/v1/games/${game}/live`,{method:'PUT',body:fresh?{release,new:true}:{release},signal});
180
+ if(fresh)this.started.add(game);
174
181
  started?.(state);
175
182
  if(release===null&&version==='live')return state;
176
183
  const doing=release===null?'Stopping the dev version':version==='dev'?'Starting the dev version':'Publishing',deadline=Date.now()+this.timeoutMs;
@@ -191,7 +198,7 @@ export class Client {
191
198
  // refuse that wait, the game is read as it stands instead, then and from then on.
192
199
  async held(game,version,signal) {
193
200
  if(!this.holds)return this.game(game,signal);
194
- try{return await this.api(`/v1/games/${game}/${version}`,{signal,prefer:`wait=${WAIT_S}`});}
201
+ try{return await this.api(version==='dev'?this.#named(`/v1/games/${game}/dev`):`/v1/games/${game}/live`,{signal,prefer:`wait=${WAIT_S}`});}
195
202
  catch(error){
196
203
  if(error.status!==405&&error.status!==404)throw error;
197
204
  this.holds=false;
@@ -213,13 +220,13 @@ export class Client {
213
220
  // A seat pass for the dev version: one use, within minutes, by whatever the developer's own tools are.
214
221
  seat(game,signal){return this.#dev(game,'seat',{method:'POST',body:{},signal});}
215
222
  async #dev(game,path,options) {
216
- try { return await this.api(`/v1/games/${game}/dev/${path}`,options); }
223
+ try { return await this.api(this.#named(`/v1/games/${game}/dev/${path}`),options); }
217
224
  catch(error) {
218
225
  const said={
219
226
  403:`Only ${game}'s owner and the developers it's shared with can use its dev version.`,
220
227
  404:`${game} isn't on Dewdrop yet. Run ${RUN} dev to create it.`,
221
228
  429:path==='seat'?'You\'ve reached your account\'s limit on seat passes and the seats they open. Try again later.':'Dewdrop is asked for the console too often. Try again in a moment.',
222
- 503:`${game} has no dev version running. Run ${RUN} dev to start it.`,
229
+ 503:this.devName?`${game} has no dev version named ${this.devName} running. Run ${RUN} dev --new ${this.devName} to start it.`:`${game} has no dev version running. Run ${RUN} dev to start it.`,
223
230
  }[error.status];
224
231
  if(said===undefined||error.status===401)throw error;
225
232
  throw new ApiError(error.status,said,error.body);
@@ -235,7 +242,7 @@ export class Client {
235
242
  // A control of the developer's own seats. Dewdrop's own words say what was wrong — which seat or room, what to run —
236
243
  // but for a route Dewdrop doesn't take, and a refusal to someone not on the game.
237
244
  async #control(game,path,options) {
238
- try { return await this.api(`/v1/games/${game}/dev/${path}`,options); }
245
+ try { return await this.api(this.#named(`/v1/games/${game}/dev/${path}`),options); }
239
246
  catch(error) {
240
247
  if(error.status===405||(error.status===404&&error.message==='Route not found'))throw new ApiError(error.status,'Dewdrop can\'t control dev sessions from the CLI right now. Try again later.',error.body);
241
248
  if(error.status===403)throw new ApiError(403,`Only ${game}'s owner and the developers it's shared with can use its dev version.`,error.body);
package/src/main.js CHANGED
@@ -24,12 +24,15 @@ const HELP=`${RUN} — make three.js games on Dewdrop
24
24
  after the folder unless --game names it
25
25
  login Sign in: prints a link to open in your browser and approve
26
26
  logout Sign this computer out
27
- dev [--watch] [--release ID] Build, upload and play the dev version; --watch repeats this on every
27
+ dev [--watch] [--release ID] [--new NAME | --name NAME]
28
+ Build, upload and play the dev version; --watch repeats this on every
28
29
  save, --release plays a kept upload without building. Without --release,
29
30
  dev then prints the dev version's console as logs --follow does, at a
30
31
  terminal and with --watch, until Ctrl-C; in a script it returns once the
31
32
  upload is ready to play. The build's source maps (.map files) are never
32
- uploaded: they stay on this computer
33
+ uploaded: they stay on this computer. --new NAME starts a dev version of
34
+ its own beside the first, refused while one of that name runs; --name
35
+ NAME uploads to it once it runs
33
36
  logs [GAME] [--follow] Print the dev version's recent console: the game's page and backend lines,
34
37
  and how each seat's session ended. Positions in the built code are shown
35
38
  in your source, by the last build's source maps. --follow keeps printing
@@ -59,17 +62,18 @@ const HELP=`${RUN} — make three.js games on Dewdrop
59
62
  to 1/2, 1/3, 1/4 and so on, no slower than 1/300
60
63
  repl [GAME] [--seat S] [--backend] Evaluate each line you type in your seat. .pause, .resume, .step N,
61
64
  .speed K, .seat S, .backend, .page, .help and .exit do what they say
62
- stop Stop the dev version and disconnect its players
65
+ stop [--name NAME] Stop the dev version and disconnect its players
63
66
  publish [--release ID] Publish the dev version, or an earlier upload, for players; uploads
64
67
  the thumbnail dewdrop.json names when it has changed
65
68
  unpublish Take the game down for players
66
69
  share EMAIL Let another developer play and update the dev version
67
70
  unshare EMAIL Take that back
68
- status Show the dev and published versions and where to play them
71
+ status Show the dev and published versions, every named dev version running,
72
+ and where to play them
69
73
  releases List every upload Dewdrop keeps, which is all of them until deleted;
70
74
  any id, or its first 8 characters, feeds --release and delete
71
75
  delete ID Delete an upload nothing runs, freeing its space (owner only)
72
- delete-game NAME Delete this game, its name typed again to confirm: both versions stop
76
+ delete-game NAME Delete this game, its name typed again to confirm: every version stops
73
77
  now, and it is removed with its uploads and its players' saves. This
74
78
  can't be undone (owner only)
75
79
  --version Show this CLI's version
@@ -78,6 +82,12 @@ const HELP=`${RUN} — make three.js games on Dewdrop
78
82
  eval, pause, resume, step, speed and repl also take the name of a game you develop. Those that reach your
79
83
  seats reach only your own, in the dev version, and none starts one: open one in a browser first.
80
84
 
85
+ Named dev versions: a game runs up to eight beside its first, each at a link of its own, so that several
86
+ agents each show their own work. A name is 1 to 10 lowercase letters, digits or dashes. dev --new NAME
87
+ starts one, and is refused while one of that name runs: pick another, as status lists them. After that,
88
+ --name NAME on dev, stop, publish, status, logs, seat, sessions, eval, pause, resume, step, speed and repl
89
+ reaches it in place of the first. Every dev version shares the game's dev saves.
90
+
81
91
  A coding agent driving the game, for example (${DEWDROP}/docs/coding-agents):
82
92
  ${RUN} dev && ${RUN} seat --out .dewdrop-seat.json # upload, and get a pass for its browser tool
83
93
  # the browser tool sets the pass's cookie for its url, opens the url and awaits dewdrop.ready()
@@ -88,8 +98,10 @@ const HELP=`${RUN} — make three.js games on Dewdrop
88
98
  // Each command's flags; share and unshare also take one address, delete one release, delete-game the game's name,
89
99
  // logs, seat and the seat commands (SEATED) a game's name, eval its code, step its frames and speed its factor. Anything
90
100
  // else on the line is refused.
91
- const COMMANDS={init:['--game','--template'],login:[],logout:[],dev:['--watch','--release'],stop:[],publish:['--release'],unpublish:[],share:[],unshare:[],status:[],releases:[],delete:[],'delete-game':[],logs:['--follow'],seat:['--out'],sessions:['--json'],eval:['--seat','--backend','--json'],pause:['--seat','--json'],resume:['--seat','--json'],step:['--seat','--json'],speed:['--seat','--json'],repl:['--seat','--backend']};
92
- const VALUED=['--game','--template','--release','--out','--seat'];
101
+ const COMMANDS={init:['--game','--template'],login:[],logout:[],dev:['--watch','--release','--new','--name'],stop:['--name'],publish:['--release','--name'],unpublish:[],share:[],unshare:[],status:['--name'],releases:[],delete:[],'delete-game':[],logs:['--follow','--name'],seat:['--out','--name'],sessions:['--json','--name'],eval:['--seat','--backend','--json','--name'],pause:['--seat','--json','--name'],resume:['--seat','--json','--name'],step:['--seat','--json','--name'],speed:['--seat','--json','--name'],repl:['--seat','--backend','--name']};
102
+ const VALUED=['--game','--template','--release','--out','--seat','--new','--name'];
103
+ // A dev version's name beside the game's first, as Dewdrop takes one.
104
+ const DEV_NAME=/^[a-z0-9][a-z0-9-]{0,9}$/;
93
105
  // The commands that reach the developer's own seats, and the one value each takes after the game's name.
94
106
  const SEATED={sessions:null,eval:'code',pause:null,resume:null,step:'frames',speed:'k',repl:null};
95
107
  function options(command,args) {
@@ -107,7 +119,7 @@ function options(command,args) {
107
119
  else out[key.slice(2)]=args[++i];
108
120
  } else if(['share','unshare'].includes(command)&&!key.startsWith('-')&&out.email===undefined)out.email=key;
109
121
  else if(command==='delete'&&!key.startsWith('-')&&out.release===undefined)out.release=key;
110
- else if(command==='delete-game'&&!key.startsWith('-')&&out.name===undefined)out.name=key;
122
+ else if(command==='delete-game'&&!key.startsWith('-')&&out.confirm===undefined)out.confirm=key;
111
123
  else if(['logs','seat'].includes(command)&&!key.startsWith('-')&&out.game===undefined)out.game=key;
112
124
  // A seat command's words: its game's name, then its value — a lone word is the value for a command that takes one.
113
125
  else if(Object.hasOwn(SEATED,command)&&(!key.startsWith('-')||key==='-')&&(out.words??=[]).length<(SEATED[command]?2:1))out.words.push(key);
@@ -115,6 +127,9 @@ function options(command,args) {
115
127
  }
116
128
  if(out.release!==undefined&&!/^[a-f0-9]{8,64}$/.test(out.release))throw new Error(`${command==='delete'?'delete':'--release'} takes a release id, or its first 8 or more characters, from ${RUN} releases.`);
117
129
  if(out.watch&&out.release)throw new Error('Choose --watch or --release, not both.');
130
+ if(out.new!==undefined&&out.name!==undefined)throw new Error('Choose --new to start a dev version or --name to reach one running, not both.');
131
+ const devName=out.new??out.name;
132
+ if(devName!==undefined&&!DEV_NAME.test(devName))throw new Error(`${devName} isn't a dev version's name: a name is 1–10 lowercase letters, digits or dashes, starting with a letter or digit.`);
118
133
  if(Object.hasOwn(SEATED,command)) {
119
134
  const words=out.words??[],value=SEATED[command];
120
135
  delete out.words;
@@ -181,7 +196,7 @@ async function main() {
181
196
  try { project=readProject(process.cwd()); }
182
197
  catch(error) { if(flags.game===undefined)throw error; }
183
198
  const origin=dewdropOrigin();
184
- const credentials=new Credentials(origin),client=new Client(origin,credentials);
199
+ const credentials=new Credentials(origin),client=new Client(origin,credentials,{devName:flags.new??flags.name??'',fresh:flags.new!==undefined});
185
200
  // The commands that wait on Dewdrop stop waiting at Ctrl-C; the rest end the ordinary way. Every signal is taken,
186
201
  // not the first alone: under `npm run dev`, npm passes the terminal's Ctrl-C on to the CLI, which has had it already,
187
202
  // and a second signal must not end the CLI before it has said what it stopped.
@@ -236,7 +251,7 @@ async function main() {
236
251
  }
237
252
  if(command==='sessions') {
238
253
  const answer=await client.sessions(game,signal);
239
- console.log(flags.json?json(answer):seatTable(answer.sessions,game));
254
+ console.log(flags.json?json(answer):seatTable(answer.sessions,game,flags.name));
240
255
  return;
241
256
  }
242
257
  if(command==='eval') {
@@ -266,8 +281,9 @@ async function main() {
266
281
  let state;
267
282
  try { state=await client.game(game); }
268
283
  catch(error) { if(error.status===404)throw new Error(`${game} isn't on Dewdrop yet. Run ${RUN} dev to create it.`); throw error; }
269
- const url=devPlayUrl(state);
270
- console.log(printable(`${game}\n Dev version: ${describe(state.dev,'stopped')}${state.dev.release?` — ${url}`:''}\n Published: ${describe(state.live,'not published')}${state.live.release?` — ${state.urls.play}`:''}\n Thumbnail: ${state.urls.thumbnail??'none'}`));
284
+ const url=devPlayUrl(state),named=(state.named??[]).filter(each=>each.name!==flags.name);
285
+ const others=named.length?`\n Named: ${named.map(each=>`${each.name} ${describe(each,'stopped')} — ${each.url}/dev`).join('\n ')}`:'';
286
+ console.log(printable(`${game}\n ${flags.name?`Dev ${flags.name}:`.padEnd(13):'Dev version: '} ${describe(state.dev,'stopped')}${state.dev.release?` — ${url}`:''}${others}\n Published: ${describe(state.live,'not published')}${state.live.release?` — ${state.urls.play}`:''}\n Thumbnail: ${state.urls.thumbnail??'none'}`));
271
287
  return;
272
288
  }
273
289
  if(command==='releases'){
@@ -275,7 +291,7 @@ async function main() {
275
291
  if(!releases.length){console.log(`No uploads of ${game} yet. Run ${RUN} dev to make one.`);return;}
276
292
  // What each release is to the game: the versions running it, else whether it was published before, is an older
277
293
  // dev build, or is the latest upload.
278
- const status=release=>[release.sha256===state.dev.release&&'dev',release.sha256===state.live.release&&'published'].filter(Boolean).join(', ')||(release.published?'published before':release.devBuild?'dev build':'latest upload');
294
+ const status=release=>[release.sha256===state.dev.release&&'dev',...(state.named??[]).filter(each=>each.release===release.sha256).map(each=>`dev ${each.name}`),release.sha256===state.live.release&&'published'].filter(Boolean).join(', ')||(release.published?'published before':release.devBuild?'dev build':'latest upload');
279
295
  console.log(printable(columns([['RELEASE','UPLOADED (UTC)','SIZE','STATUS','BY'],...releases.map(release=>[release.sha256.slice(0,12),new Date(release.created).toISOString().slice(0,16).replace('T',' '),size(release.bytes),status(release),release.email])])));
280
296
  return;
281
297
  }
@@ -286,9 +302,9 @@ async function main() {
286
302
  console.log(printable(`Deleted ${release.slice(0,12)} from ${game}.`));return;
287
303
  }
288
304
  if(command==='delete-game'){
289
- if(flags.name!==game)throw new Error(`delete-game takes the game's name to confirm. Run ${RUN} delete-game ${game} to delete ${game}.`);
305
+ if(flags.confirm!==game)throw new Error(`delete-game takes the game's name to confirm. Run ${RUN} delete-game ${game} to delete ${game}.`);
290
306
  await client.deleteGame(game);
291
- console.log(`Deleted ${game}. Both versions are stopped, players can no longer open it, and it is removed with its uploads and its players' saves.`);return;
307
+ console.log(`Deleted ${game}. Every version is stopped, players can no longer open it, and it is removed with its uploads and its players' saves.`);return;
292
308
  }
293
309
  if(['share','unshare'].includes(command)) {
294
310
  if(!flags.email)throw new Error(`${command} needs the developer's email address.`);
@@ -298,12 +314,13 @@ async function main() {
298
314
  }
299
315
  if(command==='stop'){
300
316
  await client.stop(game,signal);
301
- console.log(`Stopped ${game}'s dev version. Run ${RUN} dev to start it again.`);return;
317
+ console.log(flags.name?`Stopped ${game}'s dev version ${flags.name}. Run ${RUN} dev --new ${flags.name} to start it again.`:`Stopped ${game}'s dev version. Run ${RUN} dev to start it again.`);return;
302
318
  }
303
319
  if(command==='unpublish'){await client.publish(game,null,signal);console.log(`Unpublished ${game}. Players can no longer open it.`);return;}
304
320
  if(command==='publish') {
305
321
  const current=await client.game(game,signal);
306
322
  const release=flags.release?await releaseId(client,game,flags.release):current.dev.release;
323
+ if(!release&&flags.name)throw new Error(`${game} has no dev version named ${flags.name} running. Run ${RUN} dev --new ${flags.name} first, or publish a kept upload with --release (see ${RUN} releases).`);
307
324
  if(!release)throw new Error(`${game} has no dev version to publish. Run ${RUN} dev first, or publish a kept upload with --release (see ${RUN} releases).`);
308
325
  // The thumbnail goes first, so an image Dewdrop refuses stops the publish before anything changes for players.
309
326
  if(project.thumbnail&&await syncThumbnail(project,client,current,signal))console.log(`Uploaded the thumbnail, ${project.thumbnail}.`);
@@ -321,7 +338,11 @@ async function main() {
321
338
  else {
322
339
  // Claimed before the build, so a name someone else has or an ended sign-in is known at once.
323
340
  await client.claim(game,signal);
324
- if((await deploy(project,client,{signal,maps})).changed)throw new Error(`Files changed during the build, so nothing was uploaded. Run ${RUN} dev again, or ${RUN} dev --watch to rebuild on every save.`);
341
+ if((await deploy(project,client,{signal,maps})).changed){
342
+ // Run again as this run was: the version it names was neither started nor updated.
343
+ const again=flags.new?` --new ${flags.new}`:flags.name?` --name ${flags.name}`:'';
344
+ throw new Error(`Files changed during the build, so nothing was uploaded. Run ${RUN} dev${again} again, or ${RUN} dev${again} --watch to rebuild on every save.`);
345
+ }
325
346
  // At a terminal the console follows, for the developer to watch; a script or an agent gets the upload alone, and
326
347
  // reads the console with logs.
327
348
  if(process.stdout.isTTY) {
package/src/session.js CHANGED
@@ -7,21 +7,23 @@ import {readFileSync} from 'node:fs';
7
7
  import {RUN} from './command.js';
8
8
  import {printable,json} from './logs.js';
9
9
 
10
+ // A command as the developer runs it for dev version `devName`, '' the game's first.
11
+ const named=(command,devName)=>`${RUN} ${command}${devName?` --name ${devName}`:''}`;
10
12
  // No seat of the developer's playing, in their words: how to get one.
11
- const noSeat=game=>`No dev seat of yours is playing ${game}: open one in a browser (${RUN} seat) first.`;
13
+ const noSeat=(game,devName)=>`No dev seat of yours is playing ${game}: open one in a browser (${named('seat',devName)}) first.`;
12
14
  // The seat named `seat`, or the developer's newest when it names none, as `{seat, room}`.
13
15
  export async function findSeat(client,game,seat,signal) {
14
16
  const {sessions}=await client.sessions(game,signal);
15
- if(!sessions.length)throw new Error(noSeat(game));
17
+ if(!sessions.length)throw new Error(noSeat(game,client.devName));
16
18
  if(seat===undefined)return sessions[0];
17
19
  const found=sessions.find(each=>each.seat===seat);
18
- if(!found)throw new Error(`No dev seat of yours named ${seat} is playing ${game}. Run ${RUN} sessions to list yours.`);
20
+ if(!found)throw new Error(`No dev seat of yours named ${seat} is playing ${game}. Run ${named('sessions',client.devName)} to list yours.`);
19
21
  return found;
20
22
  }
21
23
  // The seats as `sessions` prints them: a column each for the seat and its room, the newest — the one the other commands
22
24
  // use when no --seat is given — first.
23
- export function seatTable(sessions,game) {
24
- if(!sessions.length)return noSeat(game);
25
+ export function seatTable(sessions,game,devName='') {
26
+ if(!sessions.length)return noSeat(game,devName);
25
27
  const width=Math.max(4,...sessions.map(each=>each.seat.length));
26
28
  return printable([`${'SEAT'.padEnd(width)} ROOM`,...sessions.map((each,i)=>`${each.seat.padEnd(width)} ${each.room}${i===0?' (default)':''}`)].join('\n'));
27
29
  }
@@ -77,12 +79,12 @@ export function factor(value) {
77
79
  if(!/^(0|1)?(\.[0-9]+)?$/.test(value??'')||!(k>0&&k<=1)||Math.ceil(1/k)>300)throw new Error('speed takes a factor above 0 and at most 1, no slower than 1/300, such as 0.25.');
78
80
  return k;
79
81
  }
80
- const HELP=`Each line is evaluated in the seat (or, after .backend, in its room's backend) and its value printed.
82
+ const help=devName=>`Each line is evaluated in the seat (or, after .backend, in its room's backend) and its value printed.
81
83
  .pause Pause the seat's room
82
84
  .resume Resume it
83
85
  .step N Run the room N frames (1 to 600), then pause it
84
86
  .speed K Run the room at K times its speed (above 0, at most 1, no slower than 1/300)
85
- .seat S Evaluate in your seat S from now on (${RUN} sessions lists them)
87
+ .seat S Evaluate in your seat S from now on (${named('sessions',devName)} lists them)
86
88
  .backend Evaluate in the room's backend from now on
87
89
  .page Evaluate in the seat's page again
88
90
  .help Show this
@@ -119,7 +121,7 @@ export async function repl(client,game,{seat,backend=false,maps,input=process.st
119
121
  },
120
122
  '.backend':()=>{backend=true;say(`Evaluating in ${current}'s room's backend.`);},
121
123
  '.page':()=>{backend=false;say(`Evaluating in ${current}'s page.`);},
122
- '.help':()=>say(HELP),
124
+ '.help':()=>say(help(client.devName)),
123
125
  };
124
126
  for await(const line of lines) {
125
127
  const text=line.trim();