arcadible 1.0.36 → 1.0.38
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 +1 -1
- package/dist/action/build/tool.js +57 -8
- package/dist/action/function/logs.js +1 -1
- package/dist/action/login/flow.js +8 -1
- package/dist/action/pack/limits.js +28 -4
- package/dist/action/pack/tool.js +2 -1
- package/dist/action/secret/tool.js +3 -5
- package/dist/action/serve/tool.js +28 -21
- package/dist/action/value/tool.js +18 -12
- package/dist/action/wire/tool.js +1 -1
- package/dist/api.js +1 -1
- package/dist/arc.js +6 -2
- package/dist/cli/argv.js +3 -1
- package/dist/cli/command.js +12 -2
- package/dist/command/function/index.js +4 -5
- package/dist/command/function/logs.js +8 -1
- package/dist/command/function/pause.js +1 -1
- package/dist/command/function/resume.js +1 -1
- package/dist/command/function/run.js +1 -1
- package/dist/command/function/secret/index.js +1 -1
- package/dist/command/function/secret/remove.js +2 -2
- package/dist/command/function/secret/run.js +1 -1
- package/dist/command/function/secret/set.js +1 -1
- package/dist/command/{delete.js → game/delete.js} +14 -13
- package/dist/command/game/index.js +12 -0
- package/dist/command/login.js +1 -2
- package/dist/command/serve.js +9 -3
- package/dist/command/server/index.js +3 -4
- package/dist/command/server/key/create.js +1 -1
- package/dist/command/server/key/index.js +1 -1
- package/dist/command/server/key/revoke.js +1 -1
- package/dist/command/server/key/run.js +1 -1
- package/dist/command/unstable/index.js +23 -0
- package/dist/command/value/get.js +1 -1
- package/dist/command/value/index.js +6 -6
- package/dist/command/value/list.js +1 -1
- package/dist/command/value/remove.js +2 -2
- package/dist/command/value/set.js +1 -1
- package/dist/command/value/usage.js +5 -16
- package/dist/command/wire/index.js +4 -5
- package/dist/commands.js +3 -29
- package/dist/config/code.js +7 -3
- package/dist/config/limit.js +13 -0
- package/dist/phrase/deploy.js +1 -1
- package/dist/phrase/function.js +7 -7
- package/dist/phrase/game.js +1 -1
- package/dist/phrase/index.js +1 -0
- package/dist/phrase/pack.js +17 -0
- package/dist/phrase/serve.js +8 -3
- package/dist/phrase/server.js +5 -5
- package/dist/phrase/unstable.js +6 -0
- package/dist/phrase/value.js +30 -5
- package/dist/runner/bundle.js +13 -4
- package/dist/runner/entry.js +113 -17
- package/dist/runner/outbound.js +21 -5
- package/dist/schema/check/workflow.js +0 -21
- package/dist/schema/game.js +0 -32
- package/dist/schema/message.js +2 -3
- package/dist/schema/runner.js +8 -6
- package/dist/schema/workflow.js +6 -28
- package/dist/serve/page.js +1 -1
- package/dist/serve/remote.js +14 -6
- package/dist/serve/runner.js +89 -6
- package/dist/serve/server.js +8 -6
- package/dist/util/term.js +8 -0
- package/dist/util/zip.js +5 -0
- package/dist/wires/room.js +3 -3
- package/npm-shrinkwrap.json +33 -33
- package/package.json +1 -1
package/dist/serve/runner.js
CHANGED
|
@@ -6,18 +6,27 @@
|
|
|
6
6
|
// read only when a project has a [function] table.
|
|
7
7
|
// [import]
|
|
8
8
|
import cp, {} from "node:child_process";
|
|
9
|
+
import fs from "node:fs";
|
|
9
10
|
import { copyFile, mkdir, mkdtemp, readFile, rm, writeFile, } from "node:fs/promises";
|
|
10
11
|
import http from "node:http";
|
|
11
12
|
import net from "node:net";
|
|
12
13
|
import os from "node:os";
|
|
13
|
-
import { join } from "node:path";
|
|
14
|
+
import { dirname, join } from "node:path";
|
|
14
15
|
// [import]
|
|
15
16
|
import { bundle } from "../runner/bundle.js";
|
|
16
17
|
import { ENTRY, ENTRY_MODULE, FUNCTION_MODULE } from "../runner/entry.js";
|
|
17
18
|
// [declare]
|
|
18
19
|
// where a runner answers on the game's origin, as on Arcadible, where the
|
|
19
|
-
// folder is Arcadible's own on every build's site
|
|
20
|
-
|
|
20
|
+
// folder is Arcadible's own on every build's site: the path itself, and
|
|
21
|
+
// anything under it.
|
|
22
|
+
export const PREFIX = "/arcadible/function";
|
|
23
|
+
// the function's own path for a request under PREFIX, as the dispatcher
|
|
24
|
+
// passes it on: `/arcadible/function/move` is `/move`, and the path itself
|
|
25
|
+
// is `/`, its query kept.
|
|
26
|
+
export function innerPath(url) {
|
|
27
|
+
const rest = url.slice(PREFIX.length);
|
|
28
|
+
return rest.startsWith("/") ? rest : `/${rest}`;
|
|
29
|
+
}
|
|
21
30
|
// the header a runner reads who's asking from (the Server SDK's
|
|
22
31
|
// players.primary): the player's id, or empty for a guest. Whatever a request
|
|
23
32
|
// brings by that name is dropped.
|
|
@@ -268,8 +277,66 @@ async function bodyOf(req) {
|
|
|
268
277
|
}
|
|
269
278
|
return Buffer.concat(parts);
|
|
270
279
|
}
|
|
280
|
+
// [declare]
|
|
281
|
+
// how long the code's files must stop changing before it's run again, as
|
|
282
|
+
// deploy_dir's reload waits (./reload.ts).
|
|
283
|
+
const SETTLE = 100;
|
|
271
284
|
// [function]
|
|
272
|
-
// a
|
|
285
|
+
// watches the files a function's bundle was made from, wherever they are
|
|
286
|
+
// (`main`'s folder and beyond: a game's rules its function imports), and
|
|
287
|
+
// calls `onChange` once they've stopped changing. `files(paths)` sets what's
|
|
288
|
+
// watched, after each bundle; until the first, `main` alone. Each folder
|
|
289
|
+
// holding one is watched, not recursively, and only its own files count.
|
|
290
|
+
export function watchInputs(main, onChange) {
|
|
291
|
+
let inputs = new Set([main]);
|
|
292
|
+
let timer;
|
|
293
|
+
const watchers = new Map();
|
|
294
|
+
const sync = function () {
|
|
295
|
+
const dirs = new Set([...inputs].map((path) => dirname(path)));
|
|
296
|
+
for (const [dir, watcher] of watchers) {
|
|
297
|
+
if (!dirs.has(dir)) {
|
|
298
|
+
watcher.close();
|
|
299
|
+
watchers.delete(dir);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
for (const dir of dirs) {
|
|
303
|
+
if (watchers.has(dir))
|
|
304
|
+
continue;
|
|
305
|
+
try {
|
|
306
|
+
const watcher = fs.watch(dir, (_event, name) => {
|
|
307
|
+
if (name !== null && !inputs.has(join(dir, name)))
|
|
308
|
+
return;
|
|
309
|
+
clearTimeout(timer);
|
|
310
|
+
timer = setTimeout(onChange, SETTLE);
|
|
311
|
+
});
|
|
312
|
+
// a folder removed while it's watched: stop watching it
|
|
313
|
+
watcher.on("error", () => {
|
|
314
|
+
watcher.close();
|
|
315
|
+
watchers.delete(dir);
|
|
316
|
+
});
|
|
317
|
+
watchers.set(dir, watcher);
|
|
318
|
+
}
|
|
319
|
+
catch {
|
|
320
|
+
// a folder that isn't there (yet) isn't watched
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
sync();
|
|
325
|
+
return {
|
|
326
|
+
close() {
|
|
327
|
+
clearTimeout(timer);
|
|
328
|
+
for (const watcher of watchers.values())
|
|
329
|
+
watcher.close();
|
|
330
|
+
watchers.clear();
|
|
331
|
+
},
|
|
332
|
+
files(paths) {
|
|
333
|
+
inputs = new Set([main, ...paths]);
|
|
334
|
+
sync();
|
|
335
|
+
},
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
// [function]
|
|
339
|
+
// a game's function, running. `main` is its code's path, `dir` where the
|
|
273
340
|
// runtime is kept, `origin` the game's own origin (a ticket for the runner
|
|
274
341
|
// is for it), `serve` arc serve's page (where Arcadible is, here), `hosts`
|
|
275
342
|
// the hosts its manifest declares, the only ones it may call, `secrets` the
|
|
@@ -282,6 +349,12 @@ export async function runner({ dir, handler, hosts = [], main, origin, secrets =
|
|
|
282
349
|
let child = null;
|
|
283
350
|
let port = null;
|
|
284
351
|
let failed = null;
|
|
352
|
+
// what the bundle was made from, watched: a change to any of it runs the
|
|
353
|
+
// new code, set after each bundle that builds (one that doesn't keeps
|
|
354
|
+
// what was watched, so fixing it runs it)
|
|
355
|
+
const watched = watchInputs(main, () => {
|
|
356
|
+
void start();
|
|
357
|
+
});
|
|
285
358
|
const stop = function () {
|
|
286
359
|
if (child) {
|
|
287
360
|
child.kill();
|
|
@@ -296,7 +369,13 @@ export async function runner({ dir, handler, hosts = [], main, origin, secrets =
|
|
|
296
369
|
const began = Date.now();
|
|
297
370
|
// the developer's code, and Arcadible's entry beside it, where the
|
|
298
371
|
// script starts, as the pipeline uploads a build's
|
|
299
|
-
await bundle({
|
|
372
|
+
await bundle({
|
|
373
|
+
main,
|
|
374
|
+
onInputs: (paths) => {
|
|
375
|
+
watched.files(paths);
|
|
376
|
+
},
|
|
377
|
+
outfile: join(work, FUNCTION_MODULE),
|
|
378
|
+
});
|
|
300
379
|
await writeFile(join(work, ENTRY_MODULE), ENTRY);
|
|
301
380
|
const free = await freePort();
|
|
302
381
|
port = free;
|
|
@@ -372,6 +451,9 @@ export async function runner({ dir, handler, hosts = [], main, origin, secrets =
|
|
|
372
451
|
...Object.fromEntries(Object.entries(req.headers).filter(([name]) => !dropped.includes(name))),
|
|
373
452
|
[PLAYER]: typeof player === "string" ? player : "",
|
|
374
453
|
[GUEST]: typeof guest === "string" ? guest : "",
|
|
454
|
+
// the game's origin, as on Arcadible, where the code's request.url is
|
|
455
|
+
// its site's: never the runtime's own port
|
|
456
|
+
host: new URL(origin).host,
|
|
375
457
|
};
|
|
376
458
|
if (body !== true) {
|
|
377
459
|
delete headers["transfer-encoding"];
|
|
@@ -382,7 +464,7 @@ export async function runner({ dir, handler, hosts = [], main, origin, secrets =
|
|
|
382
464
|
headers,
|
|
383
465
|
host: "127.0.0.1",
|
|
384
466
|
method: req.method,
|
|
385
|
-
path: (req.url ?? "")
|
|
467
|
+
path: innerPath(req.url ?? ""),
|
|
386
468
|
port,
|
|
387
469
|
}, (answer) => {
|
|
388
470
|
res.writeHead(answer.statusCode ?? 502, { ...answer.headers, ...CORS });
|
|
@@ -397,6 +479,7 @@ export async function runner({ dir, handler, hosts = [], main, origin, secrets =
|
|
|
397
479
|
await start();
|
|
398
480
|
return {
|
|
399
481
|
close() {
|
|
482
|
+
watched.close();
|
|
400
483
|
stop();
|
|
401
484
|
rm(work, { force: true, recursive: true }).catch(() => null);
|
|
402
485
|
},
|
package/dist/serve/server.js
CHANGED
|
@@ -15,7 +15,7 @@ import { PREFIX as WIRES, wires as wiresFor } from "./wires.js";
|
|
|
15
15
|
// [declare]
|
|
16
16
|
// the hostnames a browser may use for the page, on IPv4 and IPv6. `localhost`
|
|
17
17
|
// is IPv6's ::1 on some systems, so both are listened on.
|
|
18
|
-
const LOOPBACK = ["127.0.0.1", "::1"];
|
|
18
|
+
export const LOOPBACK = ["127.0.0.1", "::1"];
|
|
19
19
|
// [function]
|
|
20
20
|
// listens on `port` at `address`, resolving with the server, or rejecting with
|
|
21
21
|
// the listen error, such as EADDRINUSE.
|
|
@@ -64,7 +64,7 @@ export async function serve({ art, files, hostFile = null, icon, info, keyFile,
|
|
|
64
64
|
if (tickets) {
|
|
65
65
|
tickets.remember(player);
|
|
66
66
|
}
|
|
67
|
-
// the game's
|
|
67
|
+
// the game's function, when the project has one: on the game's own origin,
|
|
68
68
|
// behind a ticket check, as on Arcadible
|
|
69
69
|
const runner = runs && tickets
|
|
70
70
|
? await startRunner({
|
|
@@ -120,12 +120,14 @@ export async function serve({ art, files, hostFile = null, icon, info, keyFile,
|
|
|
120
120
|
const host = req.headers.host;
|
|
121
121
|
const onGame = host === `127.0.0.1:${port}`;
|
|
122
122
|
const pathname = pathOf(req);
|
|
123
|
-
//
|
|
124
|
-
//
|
|
125
|
-
//
|
|
123
|
+
// the function's path, and what's under it, as Arcadible's edge sends
|
|
124
|
+
// them on: /arcadible/functionx is a file of Arcadible's, like any
|
|
125
|
+
// other there, and isn't found.
|
|
126
126
|
// A project with no function is answered as Arcadible answers a build
|
|
127
127
|
// with none.
|
|
128
|
-
const forRunner = onGame &&
|
|
128
|
+
const forRunner = onGame &&
|
|
129
|
+
pathname !== null &&
|
|
130
|
+
(pathname === RUNNER || pathname.startsWith(`${RUNNER}/`))
|
|
129
131
|
? (runner?.handle ?? noFunction)
|
|
130
132
|
: null;
|
|
131
133
|
// a game opens a wire at Arcadible's path on its own origin, whether
|
package/dist/util/term.js
CHANGED
|
@@ -19,3 +19,11 @@ export function configureColor() {
|
|
|
19
19
|
chalkStderr.level = 0;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
+
// [function]
|
|
23
|
+
// a Ctrl+C in a terminal leaves `^C` with the cursor after it, so whatever
|
|
24
|
+
// comes next, the shell's prompt included, starts on a new line.
|
|
25
|
+
export function interrupted() {
|
|
26
|
+
if (interactive()) {
|
|
27
|
+
process.stderr.write("\n");
|
|
28
|
+
}
|
|
29
|
+
}
|
package/dist/util/zip.js
CHANGED
package/dist/wires/room.js
CHANGED
|
@@ -157,10 +157,10 @@ export function createRoom(options) {
|
|
|
157
157
|
left(member) {
|
|
158
158
|
// their last connection: the rest hear they went
|
|
159
159
|
const still = options.list().some((each) => each.member.id === member.id);
|
|
160
|
-
|
|
161
|
-
|
|
160
|
+
// their rate is kept, so leaving and coming back never starts it full
|
|
161
|
+
// (servers:21a)
|
|
162
|
+
if (!still)
|
|
162
163
|
all({ leave: member });
|
|
163
|
-
}
|
|
164
164
|
},
|
|
165
165
|
said(key, text) {
|
|
166
166
|
const mine = options.list().find((each) => each.key === key);
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"license": "Apache-2.0",
|
|
46
46
|
"name": "arcadible",
|
|
47
|
-
"version": "1.0.
|
|
47
|
+
"version": "1.0.38"
|
|
48
48
|
},
|
|
49
49
|
"node_modules/@asamuzakjp/css-color": {
|
|
50
50
|
"dependencies": {
|
|
@@ -884,20 +884,6 @@
|
|
|
884
884
|
"resolved": "https://registry.npmjs.org/@inquirer/core/-/core-10.3.2.tgz",
|
|
885
885
|
"version": "10.3.2"
|
|
886
886
|
},
|
|
887
|
-
"node_modules/@inquirer/core/node_modules/wrap-ansi": {
|
|
888
|
-
"dependencies": {
|
|
889
|
-
"ansi-styles": "^4.0.0",
|
|
890
|
-
"string-width": "^4.1.0",
|
|
891
|
-
"strip-ansi": "^6.0.0"
|
|
892
|
-
},
|
|
893
|
-
"engines": {
|
|
894
|
-
"node": ">=8"
|
|
895
|
-
},
|
|
896
|
-
"integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==",
|
|
897
|
-
"license": "MIT",
|
|
898
|
-
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
|
|
899
|
-
"version": "6.2.0"
|
|
900
|
-
},
|
|
901
887
|
"node_modules/@inquirer/editor": {
|
|
902
888
|
"dependencies": {
|
|
903
889
|
"@inquirer/core": "^10.3.2",
|
|
@@ -1247,10 +1233,10 @@
|
|
|
1247
1233
|
"engines": {
|
|
1248
1234
|
"node": ">= 4"
|
|
1249
1235
|
},
|
|
1250
|
-
"integrity": "sha512-
|
|
1236
|
+
"integrity": "sha512-52N+Y4HRMOJmbLmr+DqO4iSRyyB7N52gm7PWCT6h0p978+oKbqHCB7gIJIwZvBUsjlSdWbrBFqUSmIFNZMpn0A==",
|
|
1251
1237
|
"license": "MIT",
|
|
1252
|
-
"resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.
|
|
1253
|
-
"version": "7.0.
|
|
1238
|
+
"resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.16.tgz",
|
|
1239
|
+
"version": "7.0.16"
|
|
1254
1240
|
},
|
|
1255
1241
|
"node_modules/@typescript-eslint/parser": {
|
|
1256
1242
|
"dependencies": {
|
|
@@ -1645,6 +1631,23 @@
|
|
|
1645
1631
|
"resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz",
|
|
1646
1632
|
"version": "8.0.1"
|
|
1647
1633
|
},
|
|
1634
|
+
"node_modules/cliui/node_modules/wrap-ansi": {
|
|
1635
|
+
"dependencies": {
|
|
1636
|
+
"ansi-styles": "^4.0.0",
|
|
1637
|
+
"string-width": "^4.1.0",
|
|
1638
|
+
"strip-ansi": "^6.0.0"
|
|
1639
|
+
},
|
|
1640
|
+
"engines": {
|
|
1641
|
+
"node": ">=10"
|
|
1642
|
+
},
|
|
1643
|
+
"funding": {
|
|
1644
|
+
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
|
|
1645
|
+
},
|
|
1646
|
+
"integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
|
|
1647
|
+
"license": "MIT",
|
|
1648
|
+
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
|
|
1649
|
+
"version": "7.0.0"
|
|
1650
|
+
},
|
|
1648
1651
|
"node_modules/color-convert": {
|
|
1649
1652
|
"dependencies": {
|
|
1650
1653
|
"color-name": "~1.1.4"
|
|
@@ -2158,10 +2161,10 @@
|
|
|
2158
2161
|
"version": "6.0.2"
|
|
2159
2162
|
},
|
|
2160
2163
|
"node_modules/graceful-fs": {
|
|
2161
|
-
"integrity": "sha512-
|
|
2162
|
-
"license": "
|
|
2163
|
-
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.
|
|
2164
|
-
"version": "4.2.
|
|
2164
|
+
"integrity": "sha512-iuyGF2E4oafQfPsRrG2wtY2ILupMhvtdrhzrxB+0VcjsPpSPttpfYdjnGFGsTi5MaJFjI1jOKHPQ6UTbTj9TAw==",
|
|
2165
|
+
"license": "BlueOak-1.0.0",
|
|
2166
|
+
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.12.tgz",
|
|
2167
|
+
"version": "4.2.12"
|
|
2165
2168
|
},
|
|
2166
2169
|
"node_modules/hashery": {
|
|
2167
2170
|
"dependencies": {
|
|
@@ -2540,10 +2543,10 @@
|
|
|
2540
2543
|
"funding": {
|
|
2541
2544
|
"url": "https://github.com/sponsors/isaacs"
|
|
2542
2545
|
},
|
|
2543
|
-
"integrity": "sha512-
|
|
2546
|
+
"integrity": "sha512-KCFkfyjqerNlSstjlhIGNXIKZGA/6O4V4RlhZ+Dsr621SPPw0mzlypE9D9ZOoPiVefHID+j7/XuMMlqfD/F60Q==",
|
|
2544
2547
|
"license": "BlueOak-1.0.0",
|
|
2545
|
-
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.
|
|
2546
|
-
"version": "11.0.
|
|
2548
|
+
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.9.tgz",
|
|
2549
|
+
"version": "11.0.9"
|
|
2547
2550
|
},
|
|
2548
2551
|
"node_modules/mp4box": {
|
|
2549
2552
|
"engines": {
|
|
@@ -3134,15 +3137,12 @@
|
|
|
3134
3137
|
"strip-ansi": "^6.0.0"
|
|
3135
3138
|
},
|
|
3136
3139
|
"engines": {
|
|
3137
|
-
"node": ">=
|
|
3138
|
-
},
|
|
3139
|
-
"funding": {
|
|
3140
|
-
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
|
|
3140
|
+
"node": ">=8"
|
|
3141
3141
|
},
|
|
3142
|
-
"integrity": "sha512-
|
|
3142
|
+
"integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==",
|
|
3143
3143
|
"license": "MIT",
|
|
3144
|
-
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-
|
|
3145
|
-
"version": "
|
|
3144
|
+
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
|
|
3145
|
+
"version": "6.2.0"
|
|
3146
3146
|
},
|
|
3147
3147
|
"node_modules/ws": {
|
|
3148
3148
|
"engines": {
|
|
@@ -3267,5 +3267,5 @@
|
|
|
3267
3267
|
}
|
|
3268
3268
|
},
|
|
3269
3269
|
"requires": true,
|
|
3270
|
-
"version": "1.0.
|
|
3270
|
+
"version": "1.0.38"
|
|
3271
3271
|
}
|
package/package.json
CHANGED