dewctl 0.10.0 → 0.12.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,14 +108,16 @@ 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).
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). Give each light its real brightness: a sun in lux, a sky light and a glow in nits, a lamp in candela.
113
114
  Default: the recipe's ([lights and materials](https://alpha.dewdrop.world/docs/lighting)).
114
115
  - **How dark.** For a night or an indoor look: "can the player see the whole room, or only what the light
115
- reaches?" Night is dim lights over everyday colors, with a fixed exposure so it stays dark; only what the light
116
- reaches means `localShadows` at 1 and lights placed where the player should look
117
- ([a fixed exposure](https://alpha.dewdrop.world/docs/lighting#a-fixed-exposure)). Default: Dewdrop's own
118
- exposure for day, a fixed one for night.
116
+ reaches?" Night is a night's dim lights over everyday colors, which Dewdrop's own exposure keeps darker than a
117
+ day; a fixed exposure (`ev`) chooses exactly how dark. Only what the light reaches means `localShadowsEv` at 0
118
+ and lights placed where the player should look
119
+ ([exposure and tone](https://alpha.dewdrop.world/docs/lighting#exposure-and-tone)). Default: Dewdrop's own
120
+ exposure.
119
121
  - **Palette.** Three or four colors by their roles: the ground, the sky, the main built thing, the player or hero.
120
122
  Ask in color names and choose the hex yourself. They are the things' everyday colors: the light makes them warm
121
123
  or cold, bright or dim. Default: the recipe's colors.
@@ -165,9 +167,9 @@ Two or three per medium, each changing shapes, light or colors. Skip what the us
165
167
  is a glowing mesh that lights the wet ground below it.
166
168
  - **Noir:** black and white, or a tint? One hard light per scene, so the shadows agree?
167
169
  - **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.
170
+ A carried candle is a glowing flame that moves with the player and lights what's around it. Flames about
171
+ 5 × 11 cm; smaller ones read as unlit.
172
+ - **Winter:** overcast, or sunny? Snowfall in the prompt's words, or none?
171
173
  - **Golden hour:** where is the sun, and so which faces are gold and which blue-green? Does it set while playing?
172
174
  The view toward the sun reads most golden.
173
175
  - **Underwater:** how murky, and how far can the player see? Does the light come from the surface, or from
@@ -193,17 +195,18 @@ nothing that has a description of its own.)
193
195
 
194
196
  ## Sky
195
197
 
196
- `scene.background`: `#8fd0f5`. `renderer.backgroundDescription`: "plain pale blue studio backdrop".
198
+ `scene.background`: `#8fd0f5` at 8,000 nits. `renderer.backgroundDescription`: "plain pale blue studio backdrop".
197
199
 
198
200
  ## Light
199
201
 
200
202
  | Light | three.js | Color | Intensity | Where |
201
203
  | --- | --- | --- | --- | --- |
202
- | key | `DirectionalLight`, `userData.angle` 0.05 | `#fff1dc` | 3 | high, from the left |
203
- | sky | `HemisphereLight` | `#cfe8ff` / `#7a6a50` | 1 | |
204
+ | key | `DirectionalLight`, `userData.angle` 0.05 | `#fff1dc` | 30,000 lux | high, from the left |
205
+ | sky | `HemisphereLight` | `#cfe8ff` / `#7a6a50` | 3,000 nits | |
204
206
  | ... | | | | |
205
207
 
206
- Exposure: Dewdrop's own (`renderer.exposure = null`), or the fixed settings and why.
208
+ Exposure: Dewdrop's own (`renderer.exposure = null`), or the settings and why (a fixed `ev`, a
209
+ `compensationCurve`, `localShadowsEv`).
207
210
 
208
211
  ## Palette
209
212
 
@@ -250,19 +253,21 @@ and [lights and materials](https://alpha.dewdrop.world/docs/lighting) each light
250
253
  | The user says | You change |
251
254
  | --- | --- |
252
255
  | 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
- | 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 |
256
+ | darker, moodier | dimmer lights, the colors kept, and a fixed exposure for an exact darkness; the light words in the style phrase ("dim candlelight", "hard low-key lighting") |
257
+ | a carried candle or torch | a glowing flame mesh moving with the player, which lights what's around it |
255
258
  | 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
259
  | warmer, colder | the lights' colors: a warm sun and a cool sky, or the other way round |
257
260
  | more detail, more realistic | more meshes and truer shapes, the biggest where the camera goes; textures on the large surfaces |
258
261
  | 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 |
262
+ | smoke, steam, dust | words in the prompt. Sparks and embers are small transparent glowing meshes |
260
263
  | wood grain, fabric, rust, any texture | a texture of it as the material's `map`, and the material in the words |
261
- | glow, neon, fire, a lit window | a mesh with an `emissive` color and `emissiveIntensity`, which lights what's near it |
264
+ | glow, neon, fire, a lit window | a mesh with an `emissive` color and `emissiveIntensity` in nits (a flame about 10,000, a lit screen 100), which lights what's near it |
265
+ | 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
266
  | shiny, polished, metal | low `roughness`; `metalness` 1 with the metal's own color for metal |
263
267
  | glass, water, ice | a transparent material with `userData.modelLayer = 'surface'`, described as the surface |
264
268
  | wet ground, reflections | the ground at low `roughness`, which shows the lights in it, and "wet" in its words |
265
269
  | leaves, grass, a fence, lace | cards with a cut-out texture and an `alphaTest` |
270
+ | grass in the wind, a waving flag, a swell on the water | a `VertexMaterial` whose WGSL program moves the vertices every frame ([moving vertices](https://alpha.dewdrop.world/docs/vertex)) |
266
271
  | shadows | every light casts them; a softer edge from a larger `userData.angle` on the sun |
267
272
  | a sign you can read | the letters built as meshes or in the sign's texture; a sign only described shows no word |
268
273
  | big clouds | white spheres stacked into towers about 1 km or more away, described as a cloud |
@@ -38,7 +38,7 @@ Dewdrop lights the three.js scene, then draws every frame in the game's style
38
38
  ([prompt and descriptions](https://alpha.dewdrop.world/docs/prompting)).
39
39
 
40
40
  `scene.fog`, lines (`Line`, `LineSegments`, `LineLoop`), render targets and post-processing don't show. A
41
- `ShaderMaterial`'s shaders don't run, and `RectAreaLight` and `scene.environment` light nothing. Sprites, points and
41
+ `ShaderMaterial`'s shaders don't run (to move vertices, use a `VertexMaterial`, below), and `RectAreaLight` and `scene.environment` light nothing. Sprites, points and
42
42
  transparent materials draw as glows. The prompt is at most 4 KiB, the background description and each description
43
43
  at most 1 KiB. A scene draws at most 65,536 objects (each mesh counts once, and so does each instance), and holds
44
44
  up to 4,096 lights and 4,096 textures ([what works](https://alpha.dewdrop.world/docs/limits#the-look)).
@@ -55,15 +55,30 @@ 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.
59
- - **Brightness is relative.** The exposure adapts, so what matters is each light next to the others. A sun's
60
- `userData.angle` softens its shadows: 0.02 to 0.05 gives a hazy sun.
61
- - **Night is dim light, not dark colors.** Keep the materials' everyday colors, turn the lights down, and fix the
62
- exposure so the night stays dark: `renderer.exposure = { ev: 2, strength: 0 }`, its `ev` chosen on Dewdrop
63
- ([a fixed exposure](https://alpha.dewdrop.world/docs/lighting#a-fixed-exposure)).
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.
60
+ - **Light is in real units.** A sun's `color` times its `intensity` is lux (the noon sun about 100,000, an
61
+ overcast day 10,000, the full moon 0.1); a sky light's is nits (a clear day's sky a few thousand, a night sky
62
+ under 0.01); a lamp's is candela (a candle about 1, a 60 W bulb about 70), falling off with the square of the
63
+ distance, its `distance` and `decay` not read. Set each light as bright as its real counterpart: the exposure
64
+ adapts as a camera does, and keeps a night darker than a day. A sun's `userData.angle` softens its shadows:
65
+ 0.02 to 0.05 gives a hazy sun.
66
+ - **The sky's color is a brightness too:** `scene.background` in nits, such as
67
+ `new THREE.Color('#8ec5ff').multiplyScalar(12000)` for a clear day's sky, about 6,000 nits. A plain hex color is
68
+ at most 1 nit, a black sky by day. A frame that is mostly sky or backdrop is exposed for it, so a backdrop that must
69
+ stay darker than middle grey wants a fixed exposure, as a studio's camera has.
70
+ - **Night is dim light, not dark colors.** Keep the materials' everyday colors and turn the lights down to a
71
+ night's. To choose exactly how dark, fix the exposure: `renderer.exposure = { ev: 2 }`, in EV100, each step up
72
+ halving the brightness (a street at night about 2, a lit room 7), chosen on Dewdrop. Its other settings are
73
+ `compensationCurve`, `up`, `down`, `shadowContrast`, `highlightContrast`, `localShadowsEv` and
74
+ `localHighlightsEv` ([exposure and tone](https://alpha.dewdrop.world/docs/lighting#exposure-and-tone)).
64
75
  - **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)).
76
+ `emissive` times its `emissiveIntensity`, its brightness in nits (a candle flame about 10,000, a lit screen
77
+ 100), and it lights what's around it, so a candle can light a dark room by itself. Only an opaque mesh with a
78
+ lit material (`MeshStandardMaterial` and the like) lights its surroundings; a transparent one, sprites and
79
+ points glow but light nothing. A light inside a closed shade, such as a paper lantern, is hidden by it: make the
80
+ shade or the lantern's windows glow instead
81
+ ([glowing things](https://alpha.dewdrop.world/docs/lighting#glowing-things)).
67
82
  - **Give every mesh a material with a color.** `MeshStandardMaterial` takes highlights by its `roughness` (0
68
83
  polished to 1 matte) and `metalness`; `MeshBasicMaterial` is unlit. A geometry needs normals to be lit.
69
84
  - **Textures show** (`map`, `emissiveMap`, `alphaMap`, `normalMap`) from PNG, JPEG or WebP, glTF models and
@@ -85,10 +100,14 @@ Shapes ([shapes](https://alpha.dewdrop.world/docs/renderer#shapes)):
85
100
  parts a few meters from anywhere the camera goes, and characters 2.5 m or more. In first person, hold items 0.6
86
101
  to 0.7 m from the camera, as its children ([camera](https://alpha.dewdrop.world/docs/camera)).
87
102
  - **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
103
+ about 0.6 m long or more, 8 m or more from the camera
89
104
  ([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.
105
+ - **Moving vertices is a `VertexMaterial`:** grass in the wind, a waving flag, a swell on the water. Write
106
+ `fn vertex(v: Vertex) -> Moved` in a `.wgsl` file in `src/`, import it, and give it as the `program` of a
107
+ `VertexMaterial` from `dewdrop-sdk/vertex`, shaded as a standard material; set `renderer.programTime` from the
108
+ game's clock every frame for its `time()`. `vite build` names the line of a program Dewdrop can't run
109
+ ([moving vertices](https://alpha.dewdrop.world/docs/vertex)).
110
+ - **Atmosphere is words.** Haze, mist, rain and god rays go in the prompt's scene sentence.
92
111
 
93
112
  Words ([prompt and descriptions](https://alpha.dewdrop.world/docs/prompting)):
94
113
  - **The prompt has exactly this form:** `style: <style phrase>. <scene sentence>`, 15 to 35 words in all.
@@ -118,7 +137,7 @@ Words ([prompt and descriptions](https://alpha.dewdrop.world/docs/prompting)):
118
137
  part's name, `of the` and the character's own description
119
138
  ([characters and their parts](https://alpha.dewdrop.world/docs/prompting#characters-and-their-parts)).
120
139
  - **The sky is the background.** Describe it in `renderer.backgroundDescription`, with a matching `scene.background`
121
- color. Big clouds are stacked white spheres about 1 km or more away.
140
+ color at the sky's brightness in nits. Big clouds are stacked white spheres about 1 km or more away.
122
141
  - **A change of look is a cut**, 0.15 to 0.3 s later, with no blend. Change the prompt, lights, colors and
123
142
  descriptions in the same frame ([a change of look](https://alpha.dewdrop.world/docs/renderer#a-change-of-look-is-a-cut)).
124
143
 
@@ -7,15 +7,17 @@ camera.position.set(0,0,5);
7
7
  const renderer=new THREE.WebGLRenderer();
8
8
  // On Dewdrop, the style of your whole game: a medium with its light, then the scene…
9
9
  renderer.prompt='style: Clean stylized 3D game render with soft studio lighting. A minimal studio scene, eye-level view, centered framing.';
10
- // …the sky, in color and in words…
11
- scene.background=new THREE.Color('#142232');
10
+ // …the sky, its color and brightness in nits, and in words…
11
+ scene.background=new THREE.Color('#142232').multiplyScalar(10000);
12
12
  renderer.backgroundDescription='plain dark blue studio backdrop';
13
+ // …a fixed exposure, as a studio's camera has…
14
+ renderer.exposure={ev:13};
13
15
  renderer.setSize(innerWidth,innerHeight);
14
16
  document.body.appendChild(renderer.domElement);
15
- // …the light: a key light and a soft sky…
16
- const key=new THREE.DirectionalLight('#fff4e6',3);
17
+ // …the light, in real units: a key light in lux and a soft sky in nits…
18
+ const key=new THREE.DirectionalLight('#fff4e6',30000);
17
19
  key.position.set(3,5,4);
18
- scene.add(key,new THREE.HemisphereLight('#cfe2ff','#1c2838',0.8));
20
+ scene.add(key,new THREE.HemisphereLight('#cfe2ff','#1c2838',3000));
19
21
  // …and what each thing is.
20
22
  const cube=new THREE.Mesh(new THREE.BoxGeometry(1.5,1.5,1.5),new THREE.MeshStandardMaterial({color:'#4edbb1',roughness:0.35}));
21
23
  cube.userData.description='turquoise cube';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dewctl",
3
- "version": "0.10.0",
3
+ "version": "0.12.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/project.js CHANGED
@@ -180,11 +180,11 @@ export async function build(project, signal) {
180
180
  const STARTER_FILES=['package.json','src','index.html','vite.config.js'];
181
181
  // The SDK a new game depends on — the range moves with the SDK's minor, since a caret on 0.x stays within one —
182
182
  // and this CLI, at its own version.
183
- const SDK_RANGE='^0.10.0';
183
+ const SDK_RANGE='^0.11.0';
184
184
  const CLI_RANGE=`^${JSON.parse(readFileSync(new URL('../package.json',import.meta.url),'utf8')).version}`;
185
185
  // The games a new one can start from: Blank, which ships with this CLI, and the starter games in the public
186
186
  // starter-templates repository, a folder each, at the commit this release pins.
187
- const STARTERS={repo:'DewdropLabs/starter-templates',commit:'fcffe9dcc6dae96c59d6d6699883dbd88eaa89ad'};
187
+ const STARTERS={repo:'DewdropLabs/starter-templates',commit:'81bb3cca05bbd547503591539b101bf0e10eba3b'};
188
188
  const TEMPLATES={
189
189
  blank:['Blank','a cube and a style prompt, the smallest game'],
190
190
  'golden-glide':['Golden Glide','flight over golden-hour countryside, in gouache'],
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();