arcadible 1.0.40-next.1 → 1.0.40-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,6 +31,39 @@ function warning(path, message, near) {
31
31
  };
32
32
  }
33
33
  // [function]
34
+ // the words of a name, each without a plural's s: `server_origins` is
35
+ // server and origin.
36
+ function words(name) {
37
+ return name
38
+ .toLowerCase()
39
+ .split(/[_\-.\s]+/u)
40
+ .filter((word) => word.length > 2)
41
+ .map((word) => word.replace(/s$/u, ""));
42
+ }
43
+ // [function]
44
+ // the field of that name in another table, such as function.main for a
45
+ // `main` in [game], or null.
46
+ function elsewhere(fields, name, table) {
47
+ const other = Object.keys(fields).find((each) => each !== table && (fields[each] ?? []).includes(name));
48
+ return other ? `${other}.${name}` : null;
49
+ }
50
+ // [function]
51
+ // the known field `name` might mean, when none is spelled near it: one
52
+ // sharing a word with it (`servers`, or a `[server]` table, for
53
+ // client.server_origins), its own table's first; or null.
54
+ function related(fields, name, table) {
55
+ const tables = Object.keys(fields);
56
+ const mine = new Set(words(name));
57
+ const order = table ? [table, ...tables.filter((t) => t !== table)] : tables;
58
+ for (const each of order) {
59
+ const found = (fields[each] ?? []).find((field) => words(field).some((word) => mine.has(word)));
60
+ if (found) {
61
+ return each === table ? found : `${each}.${found}`;
62
+ }
63
+ }
64
+ return null;
65
+ }
66
+ // [function]
34
67
  // a value outside any table, such as a `handle` above `[game]`: the field
35
68
  // it is, in the table that takes it, if any.
36
69
  function untabled(fields, name) {
@@ -49,10 +82,14 @@ export function unknown(root) {
49
82
  return taken ? [] : [untabled(fields, table)];
50
83
  }
51
84
  if (!taken) {
52
- return [warning(table, unknownTable(), closest(table, tables))];
85
+ return [
86
+ warning(table, unknownTable(), closest(table, tables) ?? related(fields, table, null)),
87
+ ];
53
88
  }
54
89
  return Object.keys(values)
55
90
  .filter((field) => !taken.includes(field))
56
- .map((field) => warning(`${table}.${field}`, unknownField(), closest(field, taken)));
91
+ .map((field) => warning(`${table}.${field}`, unknownField(), elsewhere(fields, field, table) ??
92
+ closest(field, taken) ??
93
+ related(fields, field, table)));
57
94
  }));
58
95
  }
@@ -95,21 +95,27 @@ export default defineCommand({
95
95
  "open": {
96
96
  alias: "o",
97
97
  default: false,
98
- describe: "Open the play page in a web browser",
98
+ describe: "Open the play page in a browser",
99
99
  rc: true,
100
100
  type: "boolean",
101
101
  },
102
102
  // run the game for a logged-in player of this name, the same one each
103
- // run; without it, a guest. Left out of the help until tickets ship,
104
- // with the docs.
105
- "player": { hidden: true, rc: true, type: "string" },
103
+ // run; without it, a guest.
104
+ "player": {
105
+ describe: "Play as a logged-in player of this name",
106
+ rc: true,
107
+ type: "string",
108
+ },
106
109
  // serve a play page's host built here, for working on the host itself;
107
110
  // without it, Arcadible's own. Left out of the help.
108
111
  "host": { hidden: true, rc: true, type: "string" },
109
112
  // drop each wire's connection this many seconds after it comes on, to
110
- // try a game's rejoin. Left out of the help until wires ship, with the
111
- // docs.
112
- "wires-drop": { hidden: true, rc: true, type: "number" },
113
+ // try a game's rejoin.
114
+ "wires-drop": {
115
+ describe: "Drop each wire's connection after this many seconds",
116
+ rc: true,
117
+ type: "number",
118
+ },
113
119
  "quiet": QUIET,
114
120
  "cwd": CWD,
115
121
  },
@@ -12,7 +12,7 @@ export function packageFileDev(dir) {
12
12
  }
13
13
  // [function]
14
14
  export function sdkScriptOld(page, old, now) {
15
- return `${page} loads ${old}, the Arcadible SDK before 1.6, which gets no new calls.\nLoad ${now} instead, for the current SDK.`;
15
+ return `${page} loads ${old}, which gets no new calls.\nLoad ${now} instead, for the current SDK.`;
16
16
  }
17
17
  // [function]
18
18
  export function packageFilePrivate(file) {
@@ -125,8 +125,8 @@ export function client() {
125
125
  });
126
126
  }
127
127
  if (clientNames(table).join(" ").length > MAX_NAMES_LENGTH) {
128
- // the servers are named only where the manifest lists them, since
129
- // the docs leave `server_origins` out until it ships (message.ts).
128
+ // the servers are named only where the manifest lists them, so a
129
+ // game with hosts alone reads of its hosts alone.
130
130
  const servers = table.server_origins?.length
131
131
  ? ", with client.server_origins,"
132
132
  : "";
@@ -7,14 +7,8 @@ import { indentLines } from "../util/strs.js";
7
7
  import { MANIFEST } from "../config/url.js";
8
8
  // [declare]
9
9
  // fields the CLI checks but the docs leave out until they ship, so their
10
- // issues have no link: a game's function and its own servers, until they do
11
- // (plan/SERVERS.md).
12
- export const UNDOCUMENTED = new Set([
13
- "function.main",
14
- "function.outbound_hosts",
15
- "function.secrets",
16
- "client.server_origins",
17
- ]);
10
+ // issues have no link: a function's secrets, until they do (doc/TODO.md).
11
+ export const UNDOCUMENTED = new Set(["function.secrets"]);
18
12
  // [function]
19
13
  // the URL of a field's rules in the manifest reference, e.g. #game.title,
20
14
  // or null for an undocumented field.
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "license": "Apache-2.0",
44
44
  "name": "arcadible",
45
- "version": "1.0.40-next.1"
45
+ "version": "1.0.40-next.3"
46
46
  },
47
47
  "node_modules/@cacheable/memory": {
48
48
  "dependencies": {
@@ -2433,5 +2433,5 @@
2433
2433
  }
2434
2434
  },
2435
2435
  "requires": true,
2436
- "version": "1.0.40-next.1"
2436
+ "version": "1.0.40-next.3"
2437
2437
  }
package/package.json CHANGED
@@ -66,5 +66,5 @@
66
66
  "test": "tsc && npm run lint && node --test \"test/**/*.test.js\" \"test/**/*.test.mjs\""
67
67
  },
68
68
  "type": "module",
69
- "version": "1.0.40-next.1"
69
+ "version": "1.0.40-next.3"
70
70
  }