dewctl 0.8.0 → 0.8.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/package.json +1 -1
- package/src/client.js +8 -8
- package/src/main.js +2 -3
- package/src/watch.js +1 -1
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -22,7 +22,7 @@ export const PART_BYTES=32*1024*1024;
|
|
|
22
22
|
// files go in one round trip, while a run's first push — the whole game, which Dewdrop mostly has from the last run —
|
|
23
23
|
// sends the manifest alone and lets the answer name what is missing.
|
|
24
24
|
export const PROBE_BYTES=1024*1024;
|
|
25
|
-
// How long a poll asks
|
|
25
|
+
// How long a poll asks Dewdrop to hold it for news (`Prefer: wait`), within how long a request may stay open.
|
|
26
26
|
const WAIT_S=25;
|
|
27
27
|
// `chunks` cut into runs of exactly `bytes`, but the last, which is what remains and never empty: a file given as a
|
|
28
28
|
// run of buffers of any lengths is sent in parts of one size, holding about one part at a time.
|
|
@@ -39,7 +39,7 @@ export function* parts(chunks,bytes=PART_BYTES) {
|
|
|
39
39
|
}
|
|
40
40
|
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
|
-
// `pollMs` is the least a wait on
|
|
42
|
+
// `pollMs` is the least a wait on Dewdrop takes a round: a Dewdrop that holds the request answers when there
|
|
43
43
|
// is news, within WAIT_S; one that answers at once instead is asked again after that long.
|
|
44
44
|
// `confirmed` holds the hashes of the files Dewdrop has been seen to have, for this run.
|
|
45
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();}
|
|
@@ -89,9 +89,9 @@ export class Client {
|
|
|
89
89
|
// or which of the manifest's files it still lacks for this game, sent in further requests of PART_BYTES of files —
|
|
90
90
|
// only those, never a file it did not ask for — until it records the release, which must carry the same id. A file
|
|
91
91
|
// over PART_BYTES goes up on its own first, in parts. The files Dewdrop confirms, by recording the release or by not
|
|
92
|
-
// asking for them again, are remembered for the run, so the next push's first request carries only what changed.
|
|
93
|
-
//
|
|
94
|
-
//
|
|
92
|
+
// asking for them again, are remembered for the run, so the next push's first request carries only what changed.
|
|
93
|
+
// `progress` is told what is being sent or checked, what Dewdrop turned out to lack, and each phase of a file stored
|
|
94
|
+
// over minutes.
|
|
95
95
|
async push(game,bundle,signal,progress) {
|
|
96
96
|
const path=`/v1/games/${game}/releases/${bundle.id}`;
|
|
97
97
|
// `.manifest` sorts before every path a manifest allows, so the writer puts it first.
|
|
@@ -153,7 +153,7 @@ export class Client {
|
|
|
153
153
|
while(result.bytes===undefined) {
|
|
154
154
|
if(Date.now()>=deadline)throw new Error(`Dewdrop is taking longer than fifteen minutes to store the upload. Run ${RUN} releases to see whether it arrived.`);
|
|
155
155
|
if(result.phase!==undefined&&result.phase!==phase){phase=result.phase;progress?.(phase);}
|
|
156
|
-
// Held by
|
|
156
|
+
// Held by Dewdrop until the completion ends, or answered at once by one that does not hold a poll.
|
|
157
157
|
const asked=Date.now();
|
|
158
158
|
result=await this.api(path,{signal,prefer:`wait=${WAIT_S}`});
|
|
159
159
|
if(result.bytes===undefined)await this.#rest(asked,signal);
|
|
@@ -183,7 +183,7 @@ export class Client {
|
|
|
183
183
|
if(seen.release===release&&!seen.ready&&!seen.error)await this.#rest(asked,signal);
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
|
-
// The game as
|
|
186
|
+
// The game as Dewdrop answers it once `version` is ready or refused, holding the request for it; a Dewdrop from
|
|
187
187
|
// before that route answers the game as it stands, and is asked that way from then on.
|
|
188
188
|
async held(game,version,signal) {
|
|
189
189
|
if(!this.holds)return this.game(game,signal);
|
|
@@ -194,7 +194,7 @@ export class Client {
|
|
|
194
194
|
return this.game(game,signal);
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
|
-
// The rest of a round that came back at once: a
|
|
197
|
+
// The rest of a round that came back at once: a Dewdrop holding the request has answered with news, one that
|
|
198
198
|
// answered at once is asked again `pollMs` after it was asked.
|
|
199
199
|
async #rest(asked,signal) {
|
|
200
200
|
const left=this.pollMs-(Date.now()-asked);
|
package/src/main.js
CHANGED
|
@@ -29,8 +29,7 @@ const HELP=`${RUN} — make three.js games on Dewdrop
|
|
|
29
29
|
share EMAIL Let another developer play and update the dev version
|
|
30
30
|
unshare EMAIL Take that back
|
|
31
31
|
status Show the dev and published versions and where to play them
|
|
32
|
-
releases List
|
|
33
|
-
each member's latest upload, and every other dev build for two weeks;
|
|
32
|
+
releases List every upload Dewdrop keeps, which is all of them until deleted;
|
|
34
33
|
any id, or its first 8 characters, feeds --release and delete
|
|
35
34
|
delete ID Delete an upload nothing runs, freeing its space (owner only)
|
|
36
35
|
delete-game NAME Delete this game, its name typed again to confirm: both versions stop
|
|
@@ -152,7 +151,7 @@ async function main() {
|
|
|
152
151
|
const [{releases},state]=await Promise.all([client.releases(game),client.game(game)]);
|
|
153
152
|
if(!releases.length){console.log(`No uploads of ${game} yet. Run ${RUN} dev to make one.`);return;}
|
|
154
153
|
// What each release is to the game, the reason Dewdrop keeps it, and for an old dev build when it goes.
|
|
155
|
-
const status=release=>[release.sha256===state.dev.release&&'dev',release.sha256===state.live.release&&'published'].filter(Boolean).join(', ')||(release.published?'published before':release.
|
|
154
|
+
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');
|
|
156
155
|
console.log(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])]));
|
|
157
156
|
return;
|
|
158
157
|
}
|
package/src/watch.js
CHANGED
|
@@ -11,7 +11,7 @@ export function size(bytes) {
|
|
|
11
11
|
return `${value<10?value.toFixed(1):Math.round(value)} ${unit}`;
|
|
12
12
|
}
|
|
13
13
|
// What Dewdrop is doing with an upload that takes a while, by the phase the client sees it in.
|
|
14
|
-
const PHASES={waiting:'Waiting for Dewdrop to take the upload…',
|
|
14
|
+
const PHASES={waiting:'Waiting for Dewdrop to take the upload…',checking:'Dewdrop is checking the upload…',storing:'Dewdrop is storing the upload…'};
|
|
15
15
|
const count=(n,noun)=>`${n} ${noun}${n===1?'':'s'}`;
|
|
16
16
|
// What a push says as it goes, in the developer's terms: the files going up, or checked with Dewdrop first, the ones
|
|
17
17
|
// Dewdrop turned out to lack, and each phase of a file stored over minutes.
|