cubing 0.52.4 → 0.53.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/dist/bin/order.js +43 -15
- package/dist/bin/order.js.map +2 -2
- package/dist/bin/scramble.js +143 -124
- package/dist/bin/scramble.js.map +3 -3
- package/dist/lib/cubing/{index-BieP5oS7.d.ts → KPattern.d-BYanty6A.d.ts} +104 -104
- package/dist/lib/cubing/{PuzzleLoader-Cas0EZPp.d.ts → PuzzleLoader-Bxh01zKY.d.ts} +5 -5
- package/dist/lib/cubing/{TwizzleLink.d-_BQNFBIO.d.ts → TwizzleLink.d-Dde7gyeR.d.ts} +8 -8
- package/dist/lib/cubing/alg/index.d.ts +3 -3
- package/dist/lib/cubing/bluetooth/index.d.ts +6 -6
- package/dist/lib/cubing/{bluetooth-puzzle.d-BciBNcQQ.d.ts → bluetooth-puzzle.d-CmjQOGXN.d.ts} +2 -2
- package/dist/lib/cubing/{index-C0J1JuZs.d.ts → index-SnpOfUNy.d.ts} +2 -2
- package/dist/lib/cubing/kpuzzle/index.d.ts +2 -2
- package/dist/lib/cubing/notation/index.d.ts +4 -4
- package/dist/lib/cubing/{parseAlg.d-BaJ_OjeN.d.ts → parseAlg.d-CCV6A24s.d.ts} +1 -1
- package/dist/lib/cubing/protocol/index.d.ts +2 -2
- package/dist/lib/cubing/puzzle-geometry/index.d.ts +3 -3
- package/dist/lib/cubing/puzzles/index.d.ts +4 -4
- package/dist/lib/cubing/scramble/index.d.ts +3 -3
- package/dist/lib/cubing/search/index.d.ts +3 -3
- package/dist/lib/cubing/stream/index.d.ts +5 -5
- package/dist/lib/cubing/twisty/index.d.ts +5 -5
- package/dist/lib/cubing/twisty/index.js.map +1 -1
- package/package.json +4 -5
package/dist/bin/order.js
CHANGED
|
@@ -1,22 +1,50 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/bin/order.ts
|
|
4
|
+
import {
|
|
5
|
+
binary,
|
|
6
|
+
string as cmdString,
|
|
7
|
+
command,
|
|
8
|
+
positional,
|
|
9
|
+
run
|
|
10
|
+
} from "cmd-ts";
|
|
11
|
+
import { Alg } from "cubing/alg";
|
|
4
12
|
import { KPuzzle } from "cubing/kpuzzle";
|
|
5
13
|
import { getPuzzleGeometryByName } from "cubing/puzzle-geometry";
|
|
6
14
|
import { puzzles } from "cubing/puzzles";
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
var ReadAlg = {
|
|
16
|
+
async from(str) {
|
|
17
|
+
return Alg.fromString(str);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
var app = command({
|
|
21
|
+
name: "order",
|
|
22
|
+
description: `Example: order 3x3x3 "R U R' U R U2' R'"`,
|
|
23
|
+
args: {
|
|
24
|
+
puzzleGeometryID: positional({
|
|
25
|
+
type: cmdString,
|
|
26
|
+
displayName: "Puzzle geometry ID"
|
|
27
|
+
}),
|
|
28
|
+
alg: positional({
|
|
29
|
+
type: ReadAlg,
|
|
30
|
+
displayName: "Alg"
|
|
31
|
+
})
|
|
32
|
+
},
|
|
33
|
+
handler: async ({ puzzleGeometryID, alg }) => {
|
|
34
|
+
const puzzleLoader = puzzles[puzzleGeometryID];
|
|
35
|
+
const kpuzzle = await (async () => {
|
|
36
|
+
if (puzzleLoader) {
|
|
37
|
+
return await puzzles[puzzleGeometryID].kpuzzle();
|
|
38
|
+
} else {
|
|
39
|
+
const pg = getPuzzleGeometryByName(puzzleGeometryID, {
|
|
40
|
+
allMoves: true
|
|
41
|
+
});
|
|
42
|
+
return new KPuzzle(pg.getKPuzzleDefinition(true));
|
|
43
|
+
}
|
|
44
|
+
})();
|
|
45
|
+
const order = kpuzzle.algToTransformation(alg).repetitionOrder();
|
|
46
|
+
console.log(order);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
await run(binary(app), process.argv);
|
|
22
50
|
//# sourceMappingURL=order.js.map
|
package/dist/bin/order.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/bin/order.ts"],
|
|
4
|
-
"sourcesContent": ["// To run this file directly:\n// bun run src/bin/order.ts --
|
|
5
|
-
"mappings": ";;;AAGA,SAAS,eAAe;AACxB,SAAS,+BAA+B;AACxC,SAAS,eAAe;
|
|
4
|
+
"sourcesContent": ["// To run this file directly:\n// bun run src/bin/order.ts -- 3x3x3 \"R U R' U R U2' R'\"\n\nimport {\n binary,\n string as cmdString,\n command,\n positional,\n run,\n type Type,\n} from \"cmd-ts\";\nimport { Alg } from \"cubing/alg\";\nimport { KPuzzle } from \"cubing/kpuzzle\";\nimport { getPuzzleGeometryByName } from \"cubing/puzzle-geometry\";\nimport { puzzles } from \"cubing/puzzles\";\n\n// TODO: dedup with `screenshot` implementation.\nconst ReadAlg: Type<string, Alg> = {\n async from(str) {\n return Alg.fromString(str);\n },\n};\n\nconst app = command({\n name: \"order\",\n description: \"Example: order 3x3x3 \\\"R U R' U R U2' R'\\\"\",\n args: {\n puzzleGeometryID: positional({\n type: cmdString,\n displayName: \"Puzzle geometry ID\",\n }),\n alg: positional({\n type: ReadAlg,\n displayName: \"Alg\",\n }),\n },\n handler: async ({ puzzleGeometryID, alg }) => {\n /*\n * Turn a name into a geometry.\n */\n\n const puzzleLoader = puzzles[puzzleGeometryID];\n const kpuzzle = await (async () => {\n if (puzzleLoader) {\n return await puzzles[puzzleGeometryID].kpuzzle();\n } else {\n const pg = getPuzzleGeometryByName(puzzleGeometryID, {\n allMoves: true,\n });\n return new KPuzzle(pg.getKPuzzleDefinition(true));\n }\n })();\n const order = kpuzzle.algToTransformation(alg).repetitionOrder();\n console.log(order);\n },\n});\n\nawait run(binary(app), process.argv);\n"],
|
|
5
|
+
"mappings": ";;;AAGA;AAAA,EACE;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,WAAW;AACpB,SAAS,eAAe;AACxB,SAAS,+BAA+B;AACxC,SAAS,eAAe;AAGxB,IAAM,UAA6B;AAAA,EACjC,MAAM,KAAK,KAAK;AACd,WAAO,IAAI,WAAW,GAAG;AAAA,EAC3B;AACF;AAEA,IAAM,MAAM,QAAQ;AAAA,EAClB,MAAM;AAAA,EACN,aAAa;AAAA,EACb,MAAM;AAAA,IACJ,kBAAkB,WAAW;AAAA,MAC3B,MAAM;AAAA,MACN,aAAa;AAAA,IACf,CAAC;AAAA,IACD,KAAK,WAAW;AAAA,MACd,MAAM;AAAA,MACN,aAAa;AAAA,IACf,CAAC;AAAA,EACH;AAAA,EACA,SAAS,OAAO,EAAE,kBAAkB,IAAI,MAAM;AAK5C,UAAM,eAAe,QAAQ,gBAAgB;AAC7C,UAAM,UAAU,OAAO,YAAY;AACjC,UAAI,cAAc;AAChB,eAAO,MAAM,QAAQ,gBAAgB,EAAE,QAAQ;AAAA,MACjD,OAAO;AACL,cAAM,KAAK,wBAAwB,kBAAkB;AAAA,UACnD,UAAU;AAAA,QACZ,CAAC;AACD,eAAO,IAAI,QAAQ,GAAG,qBAAqB,IAAI,CAAC;AAAA,MAClD;AAAA,IACF,GAAG;AACH,UAAM,QAAQ,QAAQ,oBAAoB,GAAG,EAAE,gBAAgB;AAC/D,YAAQ,IAAI,KAAK;AAAA,EACnB;AACF,CAAC;AAED,MAAM,IAAI,OAAO,GAAG,GAAG,QAAQ,IAAI;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/bin/scramble.js
CHANGED
|
@@ -1,146 +1,165 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/bin/scramble.ts
|
|
4
|
+
import {
|
|
5
|
+
binary,
|
|
6
|
+
number as cmdNumber,
|
|
7
|
+
string as cmdString,
|
|
8
|
+
command,
|
|
9
|
+
flag,
|
|
10
|
+
oneOf,
|
|
11
|
+
option,
|
|
12
|
+
optional,
|
|
13
|
+
positional,
|
|
14
|
+
run
|
|
15
|
+
} from "cmd-ts";
|
|
4
16
|
import { eventInfo } from "cubing/puzzles";
|
|
5
17
|
import { randomScrambleForEvent } from "cubing/scramble";
|
|
6
18
|
import { setSearchDebug } from "cubing/search";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
throw new Error(
|
|
14
|
-
"Could not import `yargs`, which is not automatically installed as a regular dependency of `cubing`. Please run `npm install yargs` (or the equivalent) separately."
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
})();
|
|
18
|
-
var argv = await yargs(
|
|
19
|
-
// TODO: `hideBin` just shows `bun` in `bun`.
|
|
20
|
-
hideBin(process.argv)
|
|
21
|
-
).option("amount", {
|
|
22
|
-
describe: "Amount of scrambles.",
|
|
23
|
-
default: 1,
|
|
24
|
-
type: "number",
|
|
25
|
-
alias: "n"
|
|
26
|
-
}).option("format", {
|
|
27
|
-
describe: "Output format.",
|
|
28
|
-
choices: ["text", "link", "json-text"],
|
|
29
|
-
alias: "f"
|
|
30
|
-
}).option("notation", {
|
|
31
|
-
describe: "Notation type.",
|
|
32
|
-
default: "auto",
|
|
33
|
-
choices: ["auto", "LGN"]
|
|
34
|
-
}).option("text", {
|
|
35
|
-
type: "boolean",
|
|
36
|
-
describe: "Convenient shorthand for `--format text`.",
|
|
37
|
-
alias: "t"
|
|
38
|
-
}).usage(
|
|
39
|
-
"$0 eventID",
|
|
40
|
-
"Generate cubing scrambles.",
|
|
41
|
-
(yargs2) => yargs2.positional("eventID", {
|
|
42
|
-
describe: "WCA or unofficial event ID",
|
|
43
|
-
type: "string"
|
|
44
|
-
})
|
|
45
|
-
).version(false).strictOptions().argv;
|
|
46
|
-
var eventID = argv.eventID;
|
|
47
|
-
var { format } = argv;
|
|
48
|
-
format ??= argv.text || !process.stdout.isTTY ? "text" : "auto";
|
|
49
|
-
setSearchDebug({ logPerf: false, showWorkerInstantiationWarnings: false });
|
|
50
|
-
function scrambleText(scramble) {
|
|
51
|
-
return scramble.toString({
|
|
52
|
-
// TODO: any
|
|
53
|
-
notation: argv.notation
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
function scrambleLink(scramble) {
|
|
57
|
-
const url = new URL("https://alpha.twizzle.net/edit/");
|
|
58
|
-
const puzzleID = eventInfo(eventID)?.puzzleID;
|
|
59
|
-
puzzleID && url.searchParams.set("puzzle", puzzleID);
|
|
60
|
-
url.searchParams.set("alg", scrambleText(scramble));
|
|
61
|
-
return url.toString();
|
|
19
|
+
try {
|
|
20
|
+
await import("cmd-ts");
|
|
21
|
+
} catch (e) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
"Could not import `cmd-ts`, which is not automatically installed as a regular dependency of `cubing`. Please run `npm install cmd-ts` (or the equivalent) separately."
|
|
24
|
+
);
|
|
62
25
|
}
|
|
63
|
-
var
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
26
|
+
var outputFormats = ["text", "link", "json-text"];
|
|
27
|
+
var notationTypes = ["auto", "LGN"];
|
|
28
|
+
var app = command({
|
|
29
|
+
name: "scramble",
|
|
30
|
+
args: {
|
|
31
|
+
amount: option({
|
|
32
|
+
description: "Amount of scrambles",
|
|
33
|
+
type: cmdNumber,
|
|
34
|
+
long: "amount",
|
|
35
|
+
short: "n",
|
|
36
|
+
defaultValue: () => 1,
|
|
37
|
+
defaultValueIsSerializable: true
|
|
38
|
+
}),
|
|
39
|
+
format: option({
|
|
40
|
+
description: `Output format. One of: ${outputFormats.join(", ")}`,
|
|
41
|
+
type: optional(oneOf(outputFormats)),
|
|
42
|
+
long: "format",
|
|
43
|
+
short: "f"
|
|
44
|
+
}),
|
|
45
|
+
notation: option({
|
|
46
|
+
description: `Notation type. One of: ${notationTypes.join(", ")}`,
|
|
47
|
+
type: optional(oneOf(["auto", "LGN"])),
|
|
48
|
+
long: "notation"
|
|
49
|
+
}),
|
|
50
|
+
text: flag({
|
|
51
|
+
description: "Convenient shorthand for `--format text`.",
|
|
52
|
+
long: "t",
|
|
53
|
+
// TODO: https://github.com/Schniz/cmd-ts/issues/221
|
|
54
|
+
short: "t"
|
|
55
|
+
}),
|
|
56
|
+
eventID: positional({
|
|
57
|
+
type: cmdString,
|
|
58
|
+
displayName: "WCA or unofficial event ID"
|
|
59
|
+
})
|
|
60
|
+
},
|
|
61
|
+
handler: async ({ amount, format: argsFormat, notation, text, eventID }) => {
|
|
62
|
+
const format = argsFormat ?? (text || !process.stdout.isTTY ? "text" : "auto");
|
|
63
|
+
setSearchDebug({ logPerf: false, showWorkerInstantiationWarnings: false });
|
|
64
|
+
function scrambleText(scramble) {
|
|
65
|
+
return scramble.toString({
|
|
66
|
+
// TODO: any
|
|
67
|
+
notation
|
|
68
|
+
// TODO: handle type conversion at arg parse time.
|
|
69
|
+
});
|
|
79
70
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
switch (format) {
|
|
87
|
-
case "text": {
|
|
88
|
-
console.log(scrambleText(scramble));
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
case "link": {
|
|
92
|
-
console.log(scrambleLink(scramble));
|
|
93
|
-
break;
|
|
71
|
+
function scrambleLink(scramble) {
|
|
72
|
+
const url = new URL("https://alpha.twizzle.net/edit/");
|
|
73
|
+
const puzzleID = eventInfo(eventID)?.puzzleID;
|
|
74
|
+
puzzleID && url.searchParams.set("puzzle", puzzleID);
|
|
75
|
+
url.searchParams.set("alg", scrambleText(scramble));
|
|
76
|
+
return url.toString();
|
|
94
77
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
)
|
|
78
|
+
class JSONListPrinter {
|
|
79
|
+
#finished = false;
|
|
80
|
+
#firstValuePrintedAlready = false;
|
|
81
|
+
constructor() {
|
|
82
|
+
process.stdout.write("[\n ");
|
|
83
|
+
}
|
|
84
|
+
push(value) {
|
|
85
|
+
if (this.#firstValuePrintedAlready) {
|
|
86
|
+
process.stdout.write(",\n ");
|
|
87
|
+
}
|
|
88
|
+
this.#firstValuePrintedAlready = true;
|
|
89
|
+
process.stdout.write(JSON.stringify(value));
|
|
90
|
+
}
|
|
91
|
+
finish() {
|
|
92
|
+
if (this.#finished) {
|
|
93
|
+
throw new Error("Tried to finish JSON list printing multiple times.");
|
|
94
|
+
}
|
|
95
|
+
this.#finished = true;
|
|
96
|
+
console.log("\n]");
|
|
97
|
+
}
|
|
99
98
|
}
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
if (format !== "json-text" && amount === 1) {
|
|
100
|
+
const scramble = await randomScrambleForEvent(eventID);
|
|
101
|
+
switch (format) {
|
|
102
|
+
case "text": {
|
|
103
|
+
console.log(scrambleText(scramble));
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
case "link": {
|
|
107
|
+
console.log(scrambleLink(scramble));
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
// @ts-ignore This is a code guard for future refactoring.
|
|
111
|
+
case "json-text": {
|
|
112
|
+
throw new Error(
|
|
113
|
+
"Encountered `json` format in code that is not expected to handle it."
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
case "auto": {
|
|
117
|
+
console.log(`${scrambleText(scramble)}
|
|
102
118
|
|
|
103
119
|
\u{1F517} ${scrambleLink(scramble)}`);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
} else {
|
|
111
|
-
const jsonListPrinter = format === "json-text" ? new JSONListPrinter() : void 0;
|
|
112
|
-
for (let i = 0; i < argv.amount; i++) {
|
|
113
|
-
const scramble = await randomScrambleForEvent(eventID);
|
|
114
|
-
switch (format) {
|
|
115
|
-
case "text": {
|
|
116
|
-
console.log(`// Scramble #${i + 1}`);
|
|
117
|
-
console.log(`${scrambleText(scramble)}
|
|
118
|
-
`);
|
|
119
|
-
break;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
default: {
|
|
123
|
+
throw new Error("Unknown format!");
|
|
124
|
+
}
|
|
120
125
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
126
|
+
} else {
|
|
127
|
+
const jsonListPrinter = format === "json-text" ? new JSONListPrinter() : void 0;
|
|
128
|
+
for (let i = 0; i < amount; i++) {
|
|
129
|
+
const scramble = await randomScrambleForEvent(eventID);
|
|
130
|
+
switch (format) {
|
|
131
|
+
case "text": {
|
|
132
|
+
console.log(`// Scramble #${i + 1}`);
|
|
133
|
+
console.log(`${scrambleText(scramble)}
|
|
124
134
|
`);
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
case "link": {
|
|
138
|
+
console.log(`// Scramble #${i + 1}`);
|
|
139
|
+
console.log(`${scrambleLink(scramble)}
|
|
140
|
+
`);
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
case "json-text": {
|
|
144
|
+
jsonListPrinter?.push(scramble.toString());
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
case "auto": {
|
|
148
|
+
console.log(`// Scramble #${i + 1}
|
|
133
149
|
${scrambleText(scramble)}
|
|
134
150
|
|
|
135
151
|
\u{1F517} ${scrambleLink(scramble)}
|
|
136
152
|
`);
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
default: {
|
|
156
|
+
throw new Error("Unknown format!");
|
|
157
|
+
}
|
|
158
|
+
}
|
|
141
159
|
}
|
|
160
|
+
jsonListPrinter?.finish();
|
|
142
161
|
}
|
|
143
162
|
}
|
|
144
|
-
|
|
145
|
-
|
|
163
|
+
});
|
|
164
|
+
await run(binary(app), process.argv);
|
|
146
165
|
//# sourceMappingURL=scramble.js.map
|
package/dist/bin/scramble.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/bin/scramble.ts"],
|
|
4
|
-
"sourcesContent": ["// To run this file directly:\n// bun run src/bin/scramble.ts -- 333\n\
|
|
5
|
-
"mappings": ";;;
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["// To run this file directly:\n// bun run src/bin/scramble.ts -- 333\n\n// TODO: completions for `bash`, `zsh`, and `fish`: https://github.com/loilo/completarr\ntry {\n await import(\"cmd-ts\");\n} catch (e) {\n throw new Error(\n \"Could not import `cmd-ts`, which is not automatically installed as a regular dependency of `cubing`. Please run `npm install cmd-ts` (or the equivalent) separately.\",\n );\n}\n\nimport {\n binary,\n number as cmdNumber,\n string as cmdString,\n command,\n flag,\n oneOf,\n option,\n optional,\n positional,\n run,\n} from \"cmd-ts\";\nimport type { Alg } from \"cubing/alg\";\nimport { eventInfo } from \"cubing/puzzles\";\nimport { randomScrambleForEvent } from \"cubing/scramble\";\nimport { setSearchDebug } from \"cubing/search\";\n\n// TODO: file an issue about printing these values.\nconst outputFormats = [\"text\", \"link\", \"json-text\"] as const;\nconst notationTypes = [\"auto\", \"LGN\"] as const;\n\nconst app = command({\n name: \"scramble\",\n args: {\n amount: option({\n description: \"Amount of scrambles\",\n type: cmdNumber,\n long: \"amount\",\n short: \"n\",\n defaultValue: () => 1,\n defaultValueIsSerializable: true,\n }),\n format: option({\n description: `Output format. One of: ${outputFormats.join(\", \")}`,\n type: optional(oneOf(outputFormats)),\n long: \"format\",\n short: \"f\",\n }),\n notation: option({\n description: `Notation type. One of: ${notationTypes.join(\", \")}`,\n type: optional(oneOf([\"auto\", \"LGN\"])),\n long: \"notation\",\n }),\n text: flag({\n description: \"Convenient shorthand for `--format text`.\",\n long: \"t\", // TODO: https://github.com/Schniz/cmd-ts/issues/221\n short: \"t\",\n }),\n eventID: positional({\n type: cmdString,\n displayName: \"WCA or unofficial event ID\",\n }),\n },\n handler: async ({ amount, format: argsFormat, notation, text, eventID }) => {\n const format =\n argsFormat ?? (text || !process.stdout.isTTY ? \"text\" : \"auto\");\n\n setSearchDebug({ logPerf: false, showWorkerInstantiationWarnings: false });\n\n function scrambleText(scramble: Alg): string {\n return scramble.toString({\n // TODO: any\n notation: notation as (typeof notationTypes)[number], // TODO: handle type conversion at arg parse time.\n });\n }\n\n function scrambleLink(scramble: Alg): string {\n const url = new URL(\"https://alpha.twizzle.net/edit/\");\n const puzzleID = eventInfo(eventID)?.puzzleID;\n puzzleID && url.searchParams.set(\"puzzle\", puzzleID);\n url.searchParams.set(\"alg\", scrambleText(scramble));\n return url.toString();\n }\n\n class JSONListPrinter<T> {\n #finished = false;\n #firstValuePrintedAlready = false;\n constructor() {\n process.stdout.write(\"[\\n \");\n }\n\n push(value: T) {\n if (this.#firstValuePrintedAlready) {\n process.stdout.write(\",\\n \");\n }\n this.#firstValuePrintedAlready = true;\n process.stdout.write(JSON.stringify(value));\n }\n\n finish() {\n if (this.#finished) {\n throw new Error(\"Tried to finish JSON list printing multiple times.\");\n }\n this.#finished = true;\n console.log(\"\\n]\");\n }\n }\n\n if (format !== \"json-text\" && amount === 1) {\n const scramble = await randomScrambleForEvent(eventID);\n\n switch (format) {\n case \"text\": {\n console.log(scrambleText(scramble));\n break;\n }\n case \"link\": {\n console.log(scrambleLink(scramble));\n break;\n }\n // @ts-ignore This is a code guard for future refactoring.\n case \"json-text\": {\n throw new Error(\n \"Encountered `json` format in code that is not expected to handle it.\",\n );\n }\n case \"auto\": {\n console.log(`${scrambleText(scramble)}\n\n\uD83D\uDD17 ${scrambleLink(scramble)}`);\n break;\n }\n default: {\n throw new Error(\"Unknown format!\");\n }\n }\n } else {\n const jsonListPrinter: JSONListPrinter<string> | undefined =\n format === \"json-text\" ? new JSONListPrinter() : undefined;\n for (let i = 0; i < amount; i++) {\n // @ts-ignore: Top-level await is okay because this is not part of the main library.\n const scramble = await randomScrambleForEvent(eventID);\n switch (format) {\n case \"text\": {\n console.log(`// Scramble #${i + 1}`);\n console.log(`${scrambleText(scramble)}\\n`);\n break;\n }\n case \"link\": {\n console.log(`// Scramble #${i + 1}`);\n console.log(`${scrambleLink(scramble)}\\n`);\n break;\n }\n case \"json-text\": {\n jsonListPrinter?.push(scramble.toString());\n break;\n }\n case \"auto\": {\n console.log(`// Scramble #${i + 1}\n${scrambleText(scramble)}\n\n\uD83D\uDD17 ${scrambleLink(scramble)}\n`);\n break;\n }\n default: {\n throw new Error(\"Unknown format!\");\n }\n }\n }\n jsonListPrinter?.finish();\n }\n },\n});\n\nawait run(binary(app), process.argv);\n"],
|
|
5
|
+
"mappings": ";;;AAYA;AAAA,EACE;AAAA,EACA,UAAU;AAAA,EACV,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,iBAAiB;AAC1B,SAAS,8BAA8B;AACvC,SAAS,sBAAsB;AAvB/B,IAAI;AACF,QAAM,OAAO,QAAQ;AACvB,SAAS,GAAG;AACV,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACF;AAoBA,IAAM,gBAAgB,CAAC,QAAQ,QAAQ,WAAW;AAClD,IAAM,gBAAgB,CAAC,QAAQ,KAAK;AAEpC,IAAM,MAAM,QAAQ;AAAA,EAClB,MAAM;AAAA,EACN,MAAM;AAAA,IACJ,QAAQ,OAAO;AAAA,MACb,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO;AAAA,MACP,cAAc,MAAM;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AC,EAAE;AACnC,oBAAQ,IAAI,GAAG,aAAa,QAAQ,CAAC;AAAA,CAAI;AACzC;AAAA,UACF;AAAA,UACA,KAAK,aAAa;AAChB,6BAAiB,KAAK,SAAS,SAAS,CAAC;AACzC;AAAA,UACF;AAAA,UACA,KAAK,QAAQ;AACX,oBAAQ,IAAI,gBAAgB,IAAI,CAAC;AAAA,EAC3C,aAAa,QAAQ,CAAC;AAAA;AAAA,YAEnB,aAAa,QAAQ,CAAC;AAAA,CAC1B;AACW;AAAA,UACF;AAAA,UACA,SAAS;AACP,kBAAM,IAAI,MAAM,iBAAiB;AAAA,UACnC;AAAA,QACF;AAAA,MACF;AACA,uBAAiB,OAAO;AAAA,IAC1B;AAAA,EACF;AACF,CAAC;AAED,MAAM,IAAI,OAAO,GAAG,GAAG,QAAQ,IAAI;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,107 +1,4 @@
|
|
|
1
|
-
import { M as Move, A as Alg } from './PuzzleLoader-
|
|
2
|
-
|
|
3
|
-
interface NotationMapper {
|
|
4
|
-
notationToInternal(move: Move): Move | null;
|
|
5
|
-
notationToExternal(move: Move): Move | null;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
declare function parseOptions(argv: string[]): {
|
|
9
|
-
puzzleDescription: PuzzleDescription | null;
|
|
10
|
-
options: PuzzleGeometryOptions;
|
|
11
|
-
};
|
|
12
|
-
type FaceName = string;
|
|
13
|
-
type OrientationDirection = [number, number, number];
|
|
14
|
-
type FaceBasedOrientationDescription = [
|
|
15
|
-
[
|
|
16
|
-
FaceName,
|
|
17
|
-
OrientationDirection
|
|
18
|
-
],
|
|
19
|
-
[
|
|
20
|
-
FaceName,
|
|
21
|
-
OrientationDirection
|
|
22
|
-
]
|
|
23
|
-
];
|
|
24
|
-
type BaseFaceCount = 4 | 6 | 8 | 12 | 20;
|
|
25
|
-
type FaceBasedOrientationDescriptionLookup = Record<BaseFaceCount, FaceBasedOrientationDescription>;
|
|
26
|
-
declare class PuzzleGeometryFullOptions {
|
|
27
|
-
verbosity: number;
|
|
28
|
-
allMoves: boolean;
|
|
29
|
-
outerBlockMoves: boolean;
|
|
30
|
-
vertexMoves: boolean;
|
|
31
|
-
addRotations: boolean;
|
|
32
|
-
moveList: string[] | null;
|
|
33
|
-
fixedOrientation: boolean;
|
|
34
|
-
fixedPieceType: null | "e" | "v" | "f";
|
|
35
|
-
orientCenters: boolean;
|
|
36
|
-
includeCornerOrbits: boolean;
|
|
37
|
-
includeCenterOrbits: boolean;
|
|
38
|
-
includeEdgeOrbits: boolean;
|
|
39
|
-
excludeOrbits: string[];
|
|
40
|
-
optimizeOrbits: boolean;
|
|
41
|
-
grayCorners: boolean;
|
|
42
|
-
grayCenters: boolean;
|
|
43
|
-
grayEdges: boolean;
|
|
44
|
-
puzzleOrientation: FaceBasedOrientationDescription | null;
|
|
45
|
-
puzzleOrientations: FaceBasedOrientationDescriptionLookup | null;
|
|
46
|
-
scrambleAmount: number;
|
|
47
|
-
constructor(options?: PuzzleGeometryOptions);
|
|
48
|
-
}
|
|
49
|
-
type PuzzleGeometryOptions = Partial<PuzzleGeometryFullOptions>;
|
|
50
|
-
|
|
51
|
-
declare class Perm {
|
|
52
|
-
n: number;
|
|
53
|
-
p: number[];
|
|
54
|
-
constructor(a: number[]);
|
|
55
|
-
toString(): string;
|
|
56
|
-
mul(p2: Perm): Perm;
|
|
57
|
-
rmul(p2: Perm): Perm;
|
|
58
|
-
inv(): Perm;
|
|
59
|
-
compareTo(p2: Perm): number;
|
|
60
|
-
toGap(): string;
|
|
61
|
-
toMathematica(): string;
|
|
62
|
-
order(): number;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
declare class KTransformation {
|
|
66
|
-
#private;
|
|
67
|
-
readonly kpuzzle: KPuzzle;
|
|
68
|
-
readonly transformationData: KTransformationData;
|
|
69
|
-
constructor(kpuzzle: KPuzzle, transformationData: KTransformationData);
|
|
70
|
-
toJSON(): any;
|
|
71
|
-
invert(): KTransformation;
|
|
72
|
-
isIdentityTransformation(): boolean;
|
|
73
|
-
/** @deprecated */
|
|
74
|
-
static experimentalConstructIdentity(kpuzzle: KPuzzle): KTransformation;
|
|
75
|
-
isIdentical(t2: KTransformation): boolean;
|
|
76
|
-
/** @deprecated */
|
|
77
|
-
apply(source: KTransformationSource): KTransformation;
|
|
78
|
-
applyTransformation(t2: KTransformation): KTransformation;
|
|
79
|
-
applyMove(move: Move | string): KTransformation;
|
|
80
|
-
applyAlg(alg: Alg | string): KTransformation;
|
|
81
|
-
toKPattern(): KPattern;
|
|
82
|
-
repetitionOrder(): number;
|
|
83
|
-
selfMultiply(amount: number): KTransformation;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
declare class KPattern {
|
|
87
|
-
readonly kpuzzle: KPuzzle;
|
|
88
|
-
readonly patternData: KPatternData;
|
|
89
|
-
constructor(kpuzzle: KPuzzle, patternData: KPatternData);
|
|
90
|
-
toJSON(): any;
|
|
91
|
-
static fromTransformation(transformation: KTransformation): KPattern;
|
|
92
|
-
/** @deprecated */
|
|
93
|
-
apply(source: KTransformationSource): KPattern;
|
|
94
|
-
applyTransformation(transformation: KTransformation): KPattern;
|
|
95
|
-
applyMove(move: Move | string): KPattern;
|
|
96
|
-
applyAlg(alg: Alg | string): KPattern;
|
|
97
|
-
isIdentical(other: KPattern): boolean;
|
|
98
|
-
/** @deprecated */
|
|
99
|
-
experimentalToTransformation(): KTransformation | null;
|
|
100
|
-
experimentalIsSolved(options: {
|
|
101
|
-
ignorePuzzleOrientation: boolean;
|
|
102
|
-
ignoreCenterOrientation: boolean;
|
|
103
|
-
}): boolean;
|
|
104
|
-
}
|
|
1
|
+
import { M as Move, A as Alg } from './PuzzleLoader-Bxh01zKY.js';
|
|
105
2
|
|
|
106
3
|
type KPatternData = Record<string, KPatternOrbitData>;
|
|
107
4
|
interface KPatternOrbitData {
|
|
@@ -254,6 +151,89 @@ interface KPuzzleDefinition {
|
|
|
254
151
|
}) => boolean;
|
|
255
152
|
}
|
|
256
153
|
|
|
154
|
+
declare class KTransformation {
|
|
155
|
+
#private;
|
|
156
|
+
readonly kpuzzle: KPuzzle;
|
|
157
|
+
readonly transformationData: KTransformationData;
|
|
158
|
+
constructor(kpuzzle: KPuzzle, transformationData: KTransformationData);
|
|
159
|
+
toJSON(): any;
|
|
160
|
+
invert(): KTransformation;
|
|
161
|
+
isIdentityTransformation(): boolean;
|
|
162
|
+
/** @deprecated */
|
|
163
|
+
static experimentalConstructIdentity(kpuzzle: KPuzzle): KTransformation;
|
|
164
|
+
isIdentical(t2: KTransformation): boolean;
|
|
165
|
+
/** @deprecated */
|
|
166
|
+
apply(source: KTransformationSource): KTransformation;
|
|
167
|
+
applyTransformation(t2: KTransformation): KTransformation;
|
|
168
|
+
applyMove(move: Move | string): KTransformation;
|
|
169
|
+
applyAlg(alg: Alg | string): KTransformation;
|
|
170
|
+
toKPattern(): KPattern;
|
|
171
|
+
repetitionOrder(): number;
|
|
172
|
+
selfMultiply(amount: number): KTransformation;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
interface NotationMapper {
|
|
176
|
+
notationToInternal(move: Move): Move | null;
|
|
177
|
+
notationToExternal(move: Move): Move | null;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
declare function parseOptions(argv: string[]): {
|
|
181
|
+
puzzleDescription: PuzzleDescription | null;
|
|
182
|
+
options: PuzzleGeometryOptions;
|
|
183
|
+
};
|
|
184
|
+
type FaceName = string;
|
|
185
|
+
type OrientationDirection = [number, number, number];
|
|
186
|
+
type FaceBasedOrientationDescription = [
|
|
187
|
+
[
|
|
188
|
+
FaceName,
|
|
189
|
+
OrientationDirection
|
|
190
|
+
],
|
|
191
|
+
[
|
|
192
|
+
FaceName,
|
|
193
|
+
OrientationDirection
|
|
194
|
+
]
|
|
195
|
+
];
|
|
196
|
+
type BaseFaceCount = 4 | 6 | 8 | 12 | 20;
|
|
197
|
+
type FaceBasedOrientationDescriptionLookup = Record<BaseFaceCount, FaceBasedOrientationDescription>;
|
|
198
|
+
declare class PuzzleGeometryFullOptions {
|
|
199
|
+
verbosity: number;
|
|
200
|
+
allMoves: boolean;
|
|
201
|
+
outerBlockMoves: boolean;
|
|
202
|
+
vertexMoves: boolean;
|
|
203
|
+
addRotations: boolean;
|
|
204
|
+
moveList: string[] | null;
|
|
205
|
+
fixedOrientation: boolean;
|
|
206
|
+
fixedPieceType: null | "e" | "v" | "f";
|
|
207
|
+
orientCenters: boolean;
|
|
208
|
+
includeCornerOrbits: boolean;
|
|
209
|
+
includeCenterOrbits: boolean;
|
|
210
|
+
includeEdgeOrbits: boolean;
|
|
211
|
+
excludeOrbits: string[];
|
|
212
|
+
optimizeOrbits: boolean;
|
|
213
|
+
grayCorners: boolean;
|
|
214
|
+
grayCenters: boolean;
|
|
215
|
+
grayEdges: boolean;
|
|
216
|
+
puzzleOrientation: FaceBasedOrientationDescription | null;
|
|
217
|
+
puzzleOrientations: FaceBasedOrientationDescriptionLookup | null;
|
|
218
|
+
scrambleAmount: number;
|
|
219
|
+
constructor(options?: PuzzleGeometryOptions);
|
|
220
|
+
}
|
|
221
|
+
type PuzzleGeometryOptions = Partial<PuzzleGeometryFullOptions>;
|
|
222
|
+
|
|
223
|
+
declare class Perm {
|
|
224
|
+
n: number;
|
|
225
|
+
p: number[];
|
|
226
|
+
constructor(a: number[]);
|
|
227
|
+
toString(): string;
|
|
228
|
+
mul(p2: Perm): Perm;
|
|
229
|
+
rmul(p2: Perm): Perm;
|
|
230
|
+
inv(): Perm;
|
|
231
|
+
compareTo(p2: Perm): number;
|
|
232
|
+
toGap(): string;
|
|
233
|
+
toMathematica(): string;
|
|
234
|
+
order(): number;
|
|
235
|
+
}
|
|
236
|
+
|
|
257
237
|
declare class PGOrbitDef {
|
|
258
238
|
size: number;
|
|
259
239
|
mod: number;
|
|
@@ -547,4 +527,24 @@ declare class KPuzzle {
|
|
|
547
527
|
canConvertDefaultPatternToUniqueTransformation(): boolean;
|
|
548
528
|
}
|
|
549
529
|
|
|
530
|
+
declare class KPattern {
|
|
531
|
+
readonly kpuzzle: KPuzzle;
|
|
532
|
+
readonly patternData: KPatternData;
|
|
533
|
+
constructor(kpuzzle: KPuzzle, patternData: KPatternData);
|
|
534
|
+
toJSON(): any;
|
|
535
|
+
static fromTransformation(transformation: KTransformation): KPattern;
|
|
536
|
+
/** @deprecated */
|
|
537
|
+
apply(source: KTransformationSource): KPattern;
|
|
538
|
+
applyTransformation(transformation: KTransformation): KPattern;
|
|
539
|
+
applyMove(move: Move | string): KPattern;
|
|
540
|
+
applyAlg(alg: Alg | string): KPattern;
|
|
541
|
+
isIdentical(other: KPattern): boolean;
|
|
542
|
+
/** @deprecated */
|
|
543
|
+
experimentalToTransformation(): KTransformation | null;
|
|
544
|
+
experimentalIsSolved(options: {
|
|
545
|
+
ignorePuzzleOrientation: boolean;
|
|
546
|
+
ignoreCenterOrientation: boolean;
|
|
547
|
+
}): boolean;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
550
|
export { KPattern as K, Perm as P, Quat as Q, type StickerDat as S, getPuzzleGeometryByDesc as a, getPuzzleGeometryByName as b, getPG3DNamedPuzzles as c, PuzzleGeometry as d, type StickerDatAxis as e, type StickerDatFace as f, getPuzzleDescriptionString as g, type StickerDatSticker as h, parseOptions as i, type PuzzleGeometryOptions as j, PGNotation as k, type PuzzleCutDescription as l, type PuzzleDescription as m, PUZZLE_CUT_TYPES as n, type PuzzleCutType as o, parsePuzzleDescription as p, PUZZLE_BASE_SHAPES as q, type PuzzleBaseShape as r, KPuzzle as s, KTransformation as t, type PuzzleDescriptionString as u, type KPuzzleDefinition as v, type KPatternData as w, type KPatternOrbitData as x, type KTransformationData as y, type KTransformationOrbitData as z };
|