cubing 0.27.0 → 0.28.2
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 +3 -1
- package/dist/esm/.DS_Store +0 -0
- package/dist/esm/alg/index.js +4 -4
- package/dist/esm/bluetooth/index.js +228 -92
- package/dist/esm/bluetooth/index.js.map +3 -3
- package/dist/esm/{chunk-WQK6XWML.js → chunk-2IZUSAXQ.js} +2 -2
- package/dist/esm/{chunk-WQK6XWML.js.map → chunk-2IZUSAXQ.js.map} +1 -1
- package/dist/esm/{chunk-VY7VF4MA.js → chunk-5744RHHG.js} +145 -58
- package/dist/esm/chunk-5744RHHG.js.map +7 -0
- package/dist/esm/{chunk-KJYODR27.js → chunk-76H7SSCY.js} +28 -12
- package/dist/esm/{chunk-KJYODR27.js.map → chunk-76H7SSCY.js.map} +1 -1
- package/dist/esm/chunk-76UZ2QTB.js +1137 -0
- package/dist/esm/chunk-76UZ2QTB.js.map +7 -0
- package/dist/esm/{chunk-LNUPGLIU.js → chunk-D4YYXJDB.js} +175 -72
- package/dist/esm/{chunk-LNUPGLIU.js.map → chunk-D4YYXJDB.js.map} +3 -3
- package/dist/esm/{chunk-3Y4PK4XI.js → chunk-FEIKQ7FV.js} +6 -6
- package/dist/esm/chunk-FEIKQ7FV.js.map +7 -0
- package/dist/esm/{chunk-HIMSRIID.js → chunk-LOTZ7ZO7.js} +8 -4
- package/dist/esm/{chunk-HIMSRIID.js.map → chunk-LOTZ7ZO7.js.map} +1 -1
- package/dist/esm/{chunk-YBDBUTYE.js → chunk-OX6O2ZO5.js} +1 -1
- package/dist/esm/{chunk-YBDBUTYE.js.map → chunk-OX6O2ZO5.js.map} +1 -1
- package/dist/esm/{chunk-NQORDEXF.js → chunk-PCR6JT2W.js} +466 -322
- package/dist/esm/chunk-PCR6JT2W.js.map +7 -0
- package/dist/esm/{chunk-AU3UW5N4.js → chunk-PTUPP5AW.js} +22 -8
- package/dist/esm/{chunk-AU3UW5N4.js.map → chunk-PTUPP5AW.js.map} +1 -1
- package/dist/esm/{chunk-BEXHMXCT.js → chunk-RHC3DIN3.js} +1 -1
- package/dist/esm/{chunk-BEXHMXCT.js.map → chunk-RHC3DIN3.js.map} +1 -1
- package/dist/esm/{chunk-DSAZCGT2.js → chunk-RTFKKZPH.js} +22 -13
- package/dist/esm/{chunk-DSAZCGT2.js.map → chunk-RTFKKZPH.js.map} +2 -2
- package/dist/esm/{chunk-MGJA5U5O.js → chunk-SBZRVSPK.js} +1 -12
- package/dist/esm/{chunk-MGJA5U5O.js.map → chunk-SBZRVSPK.js.map} +0 -0
- package/dist/esm/{chunk-VYMKSHDI.js → chunk-TX2AQ4XW.js} +35 -13
- package/dist/esm/{chunk-VYMKSHDI.js.map → chunk-TX2AQ4XW.js.map} +2 -2
- package/dist/esm/{chunk-NYAPGKCW.js → chunk-WXCNEGW3.js} +10 -4
- package/dist/esm/{chunk-NYAPGKCW.js.map → chunk-WXCNEGW3.js.map} +1 -1
- package/dist/esm/{chunk-GBMX6FHY.js → chunk-ZB3P5AZN.js} +1 -1
- package/dist/esm/{chunk-GBMX6FHY.js.map → chunk-ZB3P5AZN.js.map} +1 -1
- package/dist/esm/kpuzzle/index.js +3 -3
- package/dist/esm/notation/index.js +3 -3
- package/dist/esm/protocol/index.js +5 -5
- package/dist/esm/puzzle-geometry/index.js +4570 -15
- package/dist/esm/puzzle-geometry/index.js.map +4 -4
- package/dist/esm/puzzles/index.js +5 -5
- package/dist/esm/{puzzles-dynamic-3x3x3-NB2PEZTV.js → puzzles-dynamic-3x3x3-KIG5A6QR.js} +2 -2
- package/dist/esm/{puzzles-dynamic-3x3x3-NB2PEZTV.js.map → puzzles-dynamic-3x3x3-KIG5A6QR.js.map} +0 -0
- package/dist/esm/puzzles-dynamic-4x4x4-PEDAPUZK.js +126 -0
- package/dist/esm/puzzles-dynamic-4x4x4-PEDAPUZK.js.map +7 -0
- package/dist/esm/{puzzles-dynamic-side-events-HOXBZYWI.js → puzzles-dynamic-side-events-5C7LMBWX.js} +2 -2
- package/dist/esm/{puzzles-dynamic-side-events-HOXBZYWI.js.map → puzzles-dynamic-side-events-5C7LMBWX.js.map} +1 -1
- package/dist/esm/{puzzles-dynamic-unofficial-MGVOFUDR.js → puzzles-dynamic-unofficial-WWJ4NJMX.js} +2 -2
- package/dist/esm/{puzzles-dynamic-unofficial-MGVOFUDR.js.map → puzzles-dynamic-unofficial-WWJ4NJMX.js.map} +1 -1
- package/dist/esm/scramble/index.js +6 -6
- package/dist/esm/search/index.js +11 -11
- package/dist/esm/{search-dynamic-sgs-side-events-4UF3XJRB.js → search-dynamic-sgs-side-events-X62KI7ZV.js} +37 -21
- package/dist/esm/search-dynamic-sgs-side-events-X62KI7ZV.js.map +7 -0
- package/dist/esm/{search-dynamic-sgs-unofficial-ZEUVDMBT.js → search-dynamic-sgs-unofficial-YAPJYTMF.js} +35 -14
- package/dist/esm/{search-dynamic-sgs-unofficial-ZEUVDMBT.js.map → search-dynamic-sgs-unofficial-YAPJYTMF.js.map} +2 -2
- package/dist/esm/{search-dynamic-solve-3x3x3-K4TG7P3X.js → search-dynamic-solve-3x3x3-7XZTYQMO.js} +795 -142
- package/dist/esm/{search-dynamic-solve-3x3x3-K4TG7P3X.js.map → search-dynamic-solve-3x3x3-7XZTYQMO.js.map} +1 -1
- package/dist/esm/{search-dynamic-solve-4x4x4-FKEWH5MW.js → search-dynamic-solve-4x4x4-5HST67LZ.js} +135 -29
- package/dist/esm/{search-dynamic-solve-4x4x4-FKEWH5MW.js.map → search-dynamic-solve-4x4x4-5HST67LZ.js.map} +1 -1
- package/dist/esm/{search-dynamic-solve-fto-WROONLZS.js → search-dynamic-solve-fto-4LI23P6K.js} +253 -69
- package/dist/esm/{search-dynamic-solve-fto-WROONLZS.js.map → search-dynamic-solve-fto-4LI23P6K.js.map} +2 -2
- package/dist/esm/{search-dynamic-solve-kilominx-JVBOIWI2.js → search-dynamic-solve-kilominx-PIS3T2P4.js} +32 -8
- package/dist/esm/{search-dynamic-solve-kilominx-JVBOIWI2.js.map → search-dynamic-solve-kilominx-PIS3T2P4.js.map} +2 -2
- package/dist/esm/{search-dynamic-solve-master_tetraminx-3R2CJUKW.js → search-dynamic-solve-master_tetraminx-UB32C7MM.js} +111 -42
- package/dist/esm/{search-dynamic-solve-master_tetraminx-3R2CJUKW.js.map → search-dynamic-solve-master_tetraminx-UB32C7MM.js.map} +2 -2
- package/dist/esm/{search-dynamic-solve-sq1-RS5HN6AH.js → search-dynamic-solve-sq1-HA72TYF2.js} +54 -9
- package/dist/esm/{search-dynamic-solve-sq1-RS5HN6AH.js.map → search-dynamic-solve-sq1-HA72TYF2.js.map} +2 -2
- package/dist/esm/search-worker-inside-generated-string-HMA547DJ.js +3886 -0
- package/dist/esm/search-worker-inside-generated-string-HMA547DJ.js.map +7 -0
- package/dist/esm/{search-worker-js-entry-NTV7KFZ5.js → search-worker-js-entry-3QMPUE4B.js} +149 -55
- package/dist/esm/search-worker-js-entry-3QMPUE4B.js.map +7 -0
- package/dist/esm/{search-worker-ts-entry-EUKJTYA6.js → search-worker-ts-entry-3RHWJNVQ.js} +6 -6
- package/dist/esm/{search-worker-ts-entry-EUKJTYA6.js.map → search-worker-ts-entry-3RHWJNVQ.js.map} +1 -1
- package/dist/esm/stream/index.js +12 -8
- package/dist/esm/stream/index.js.map +1 -1
- package/dist/esm/twisty/index.js +1186 -1533
- package/dist/esm/twisty/index.js.map +4 -4
- package/dist/esm/{twisty-dynamic-3d-UJR5FP6R.js → twisty-dynamic-3d-2KRJEHAN.js} +358 -146
- package/dist/esm/twisty-dynamic-3d-2KRJEHAN.js.map +7 -0
- package/dist/types/{Alg-1b229e63.d.ts → Alg-137fb0d5.d.ts} +53 -46
- package/dist/types/{KState-7a536c23.d.ts → KState-d5f04c9a.d.ts} +1 -1
- package/dist/types/{TwizzleLink-0fbaf9bd.d.ts → TwizzleLink-43d94aca.d.ts} +57 -21
- package/dist/types/alg/index.d.ts +12 -8
- package/dist/types/bluetooth/index.d.ts +4 -4
- package/dist/types/{bluetooth-puzzle-7065b808.d.ts → bluetooth-puzzle-7e1a2576.d.ts} +9 -9
- package/dist/types/kpuzzle/index.d.ts +2 -2
- package/dist/types/notation/index.d.ts +1 -1
- package/dist/types/{outside-f12ca41a.d.ts → outside-f83e819a.d.ts} +2 -2
- package/dist/types/parseAlg-a28f7568.d.ts +9 -0
- package/dist/types/protocol/index.d.ts +2 -2
- package/dist/types/puzzle-geometry/index.d.ts +3 -3
- package/dist/types/puzzles/index.d.ts +5 -5
- package/dist/types/scramble/index.d.ts +3 -3
- package/dist/types/search/index.d.ts +3 -3
- package/dist/types/stream/index.d.ts +5 -5
- package/dist/types/twisty/index.d.ts +13 -6
- package/package.json +32 -28
- package/dist/esm/chunk-3Y4PK4XI.js.map +0 -7
- package/dist/esm/chunk-NQORDEXF.js.map +0 -7
- package/dist/esm/chunk-NS5XT5ZV.js +0 -4386
- package/dist/esm/chunk-NS5XT5ZV.js.map +0 -7
- package/dist/esm/chunk-RECTK3R2.js +0 -342
- package/dist/esm/chunk-RECTK3R2.js.map +0 -7
- package/dist/esm/chunk-VY7VF4MA.js.map +0 -7
- package/dist/esm/search-dynamic-sgs-side-events-4UF3XJRB.js.map +0 -7
- package/dist/esm/search-worker-inside-generated-string-KTF5N656.js +0 -3768
- package/dist/esm/search-worker-inside-generated-string-KTF5N656.js.map +0 -7
- package/dist/esm/search-worker-js-entry-NTV7KFZ5.js.map +0 -7
- package/dist/esm/twisty-dynamic-3d-UJR5FP6R.js.map +0 -7
- package/dist/types/parse-7cf1a92b.d.ts +0 -9
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ Twizzle</a> is the spiritual successor to [alg.cubing.net](https://alg.cubing.ne
|
|
|
15
15
|
|
|
16
16
|
## Getting started
|
|
17
17
|
|
|
18
|
-
If you're just getting started, the easiest way to use `cubing.js` is
|
|
18
|
+
If you're just getting started, the easiest way to use `cubing.js` is through `cdn.cubing.net`:
|
|
19
19
|
|
|
20
20
|
```html
|
|
21
21
|
<script src="https://cdn.cubing.net/js/cubing/twisty" type="module"></script>
|
|
@@ -39,6 +39,8 @@ import { Alg } from "cubing/alg";
|
|
|
39
39
|
import { TwistyPlayer } from "cubing/twisty";
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
+
Please note that `cubing.js` requires ES2020 module compatibility. See [here](https://js.cubing.net/cubing/#javascript).
|
|
43
|
+
|
|
42
44
|
## Contributing
|
|
43
45
|
|
|
44
46
|
If you would like to contribute to the development of `cubing.js`, please refer to our [contribution guidelines](./CONTRIBUTING.md).
|
|
Binary file
|
package/dist/esm/alg/index.js
CHANGED
|
@@ -12,13 +12,13 @@ import {
|
|
|
12
12
|
QuantumMove,
|
|
13
13
|
TraversalDownUp,
|
|
14
14
|
TraversalUp,
|
|
15
|
-
|
|
15
|
+
experimentalAlgCubingNetLink,
|
|
16
16
|
experimentalAppendMove,
|
|
17
17
|
experimentalIs,
|
|
18
18
|
keyToMove,
|
|
19
19
|
setAlgDebug
|
|
20
|
-
} from "../chunk-
|
|
21
|
-
import "../chunk-
|
|
20
|
+
} from "../chunk-PCR6JT2W.js";
|
|
21
|
+
import "../chunk-SBZRVSPK.js";
|
|
22
22
|
export {
|
|
23
23
|
Alg,
|
|
24
24
|
AlgBuilder,
|
|
@@ -33,7 +33,7 @@ export {
|
|
|
33
33
|
QuantumMove,
|
|
34
34
|
TraversalDownUp,
|
|
35
35
|
TraversalUp,
|
|
36
|
-
|
|
36
|
+
experimentalAlgCubingNetLink,
|
|
37
37
|
experimentalAppendMove,
|
|
38
38
|
experimentalIs,
|
|
39
39
|
keyToMove,
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
binaryComponentsToReid3x3x3,
|
|
3
3
|
twizzleBinaryToBinaryComponents
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-PTUPP5AW.js";
|
|
5
5
|
import {
|
|
6
6
|
puzzles
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-D4YYXJDB.js";
|
|
8
8
|
import {
|
|
9
9
|
experimental3x3x3KPuzzle
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-TX2AQ4XW.js";
|
|
11
11
|
import {
|
|
12
12
|
KState
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-5744RHHG.js";
|
|
14
14
|
import {
|
|
15
15
|
Alg,
|
|
16
16
|
Move,
|
|
17
17
|
experimentalAppendMove,
|
|
18
18
|
keyToMove
|
|
19
|
-
} from "../chunk-
|
|
20
|
-
import "../chunk-
|
|
19
|
+
} from "../chunk-PCR6JT2W.js";
|
|
20
|
+
import "../chunk-SBZRVSPK.js";
|
|
21
21
|
|
|
22
22
|
// src/cubing/bluetooth/debug.ts
|
|
23
23
|
var DEBUG_LOGGING_ENABLED = false;
|
|
@@ -64,7 +64,7 @@ var m = {
|
|
|
64
64
|
"-x z": new Quaternion(0, 0, s2, s2)
|
|
65
65
|
};
|
|
66
66
|
var BasicRotationTransformer = class {
|
|
67
|
-
|
|
67
|
+
transformAlgLeaf(_algLeafEvent) {
|
|
68
68
|
}
|
|
69
69
|
transformOrientation(orientationEvent) {
|
|
70
70
|
const { x, y, z, w } = orientationEvent.quaternion;
|
|
@@ -94,7 +94,7 @@ var BluetoothPuzzle = class extends EventTarget {
|
|
|
94
94
|
async getState() {
|
|
95
95
|
throw new Error("cannot get state");
|
|
96
96
|
}
|
|
97
|
-
|
|
97
|
+
addAlgLeafListener(listener) {
|
|
98
98
|
this.listeners.push(listener);
|
|
99
99
|
}
|
|
100
100
|
addOrientationListener(listener) {
|
|
@@ -103,12 +103,12 @@ var BluetoothPuzzle = class extends EventTarget {
|
|
|
103
103
|
experimentalAddBasicRotationTransformer() {
|
|
104
104
|
this.transformers.push(new BasicRotationTransformer());
|
|
105
105
|
}
|
|
106
|
-
|
|
106
|
+
dispatchAlgLeaf(algLeaf) {
|
|
107
107
|
for (const transformer of this.transformers) {
|
|
108
|
-
transformer.
|
|
108
|
+
transformer.transformAlgLeaf(algLeaf);
|
|
109
109
|
}
|
|
110
110
|
for (const l of this.listeners) {
|
|
111
|
-
l(
|
|
111
|
+
l(algLeaf);
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
dispatchOrientation(orientationEvent) {
|
|
@@ -151,12 +151,12 @@ var KeyboardPuzzle = class extends BluetoothPuzzle {
|
|
|
151
151
|
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) {
|
|
152
152
|
return;
|
|
153
153
|
}
|
|
154
|
-
const
|
|
155
|
-
if (
|
|
156
|
-
const newState = (await this.state).
|
|
154
|
+
const algLeaf = keyToMove(e);
|
|
155
|
+
if (algLeaf) {
|
|
156
|
+
const newState = (await this.state).applyAlg(new Alg([algLeaf]));
|
|
157
157
|
this.state = Promise.resolve(newState);
|
|
158
|
-
this.
|
|
159
|
-
|
|
158
|
+
this.dispatchAlgLeaf({
|
|
159
|
+
latestAlgLeaf: algLeaf,
|
|
160
160
|
timeStamp: e.timeStamp,
|
|
161
161
|
state: newState
|
|
162
162
|
});
|
|
@@ -181,7 +181,9 @@ function requestOptions(configs, acceptAllDevices = false) {
|
|
|
181
181
|
if (!acceptAllDevices) {
|
|
182
182
|
options.filters = options.filters.concat(config.filters);
|
|
183
183
|
}
|
|
184
|
-
options.optionalServices = options.optionalServices.concat(
|
|
184
|
+
options.optionalServices = options.optionalServices.concat(
|
|
185
|
+
config.optionalServices
|
|
186
|
+
);
|
|
185
187
|
}
|
|
186
188
|
debugLog({ requestOptions: options });
|
|
187
189
|
return options;
|
|
@@ -194,10 +196,14 @@ async function bluetoothConnect(configs, options = {}) {
|
|
|
194
196
|
try {
|
|
195
197
|
let acceptAllDevices = options.acceptAllDevices;
|
|
196
198
|
if (!acceptAllDevices && consecutiveFailures >= MAX_FAILURES_BEFORE_ACCEPT_ALL_FALLBACK) {
|
|
197
|
-
console.info(
|
|
199
|
+
console.info(
|
|
200
|
+
`The last ${MAX_FAILURES_BEFORE_ACCEPT_ALL_FALLBACK} Bluetooth puzzle connection attempts failed. This time, the Bluetooth prompt will show all possible devices.`
|
|
201
|
+
);
|
|
198
202
|
acceptAllDevices = true;
|
|
199
203
|
}
|
|
200
|
-
device = await navigator.bluetooth.requestDevice(
|
|
204
|
+
device = await navigator.bluetooth.requestDevice(
|
|
205
|
+
requestOptions(configs, acceptAllDevices)
|
|
206
|
+
);
|
|
201
207
|
consecutiveFailures = 0;
|
|
202
208
|
} catch (e) {
|
|
203
209
|
consecutiveFailures++;
|
|
@@ -226,7 +232,9 @@ import { Quaternion as Quaternion2 } from "three";
|
|
|
226
232
|
// src/cubing/vendor/unsafe-raw-aes/unsafe-raw-aes.ts
|
|
227
233
|
var blockSize = 16;
|
|
228
234
|
var zeros = new Uint8Array(blockSize);
|
|
229
|
-
var paddingBlockPlaintext = new Uint8Array(
|
|
235
|
+
var paddingBlockPlaintext = new Uint8Array(
|
|
236
|
+
new Array(blockSize).fill(blockSize)
|
|
237
|
+
);
|
|
230
238
|
var AES_CBC = "AES-CBC";
|
|
231
239
|
async function importKey(keyBytes) {
|
|
232
240
|
return await crypto.subtle.importKey("raw", keyBytes, AES_CBC, true, [
|
|
@@ -235,21 +243,33 @@ async function importKey(keyBytes) {
|
|
|
235
243
|
]);
|
|
236
244
|
}
|
|
237
245
|
async function unsafeEncryptBlockWithIV(key, plaintextBlock, iv) {
|
|
238
|
-
const cryptoResult = await window.crypto.subtle.encrypt(
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
246
|
+
const cryptoResult = await window.crypto.subtle.encrypt(
|
|
247
|
+
{
|
|
248
|
+
name: AES_CBC,
|
|
249
|
+
iv
|
|
250
|
+
},
|
|
251
|
+
key,
|
|
252
|
+
plaintextBlock
|
|
253
|
+
);
|
|
242
254
|
return cryptoResult.slice(0, blockSize);
|
|
243
255
|
}
|
|
244
256
|
async function unsafeDecryptBlock(key, ciphertextBlock) {
|
|
245
|
-
const paddingBlock = await unsafeEncryptBlockWithIV(
|
|
257
|
+
const paddingBlock = await unsafeEncryptBlockWithIV(
|
|
258
|
+
key,
|
|
259
|
+
paddingBlockPlaintext,
|
|
260
|
+
ciphertextBlock
|
|
261
|
+
);
|
|
246
262
|
const cbcCiphertext = new Uint8Array(2 * blockSize);
|
|
247
263
|
cbcCiphertext.set(new Uint8Array(ciphertextBlock), 0);
|
|
248
264
|
cbcCiphertext.set(new Uint8Array(paddingBlock), blockSize);
|
|
249
|
-
const cryptoResult = await window.crypto.subtle.decrypt(
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
265
|
+
const cryptoResult = await window.crypto.subtle.decrypt(
|
|
266
|
+
{
|
|
267
|
+
name: AES_CBC,
|
|
268
|
+
iv: zeros
|
|
269
|
+
},
|
|
270
|
+
key,
|
|
271
|
+
cbcCiphertext
|
|
272
|
+
);
|
|
253
273
|
return cryptoResult.slice(0, blockSize);
|
|
254
274
|
}
|
|
255
275
|
|
|
@@ -316,7 +336,10 @@ async function decryptState(data, aesKey) {
|
|
|
316
336
|
}
|
|
317
337
|
const copy = new Uint8Array(data);
|
|
318
338
|
copy.set(new Uint8Array(await unsafeDecryptBlock(aesKey, copy.slice(3))), 3);
|
|
319
|
-
copy.set(
|
|
339
|
+
copy.set(
|
|
340
|
+
new Uint8Array(await unsafeDecryptBlock(aesKey, copy.slice(0, 16))),
|
|
341
|
+
0
|
|
342
|
+
);
|
|
320
343
|
if (probablyDecodedCorrectly(copy)) {
|
|
321
344
|
return copy;
|
|
322
345
|
}
|
|
@@ -333,7 +356,10 @@ var PhysicalState = class {
|
|
|
333
356
|
}
|
|
334
357
|
}
|
|
335
358
|
static async read(characteristic, aesKey) {
|
|
336
|
-
const value = await decryptState(
|
|
359
|
+
const value = await decryptState(
|
|
360
|
+
new Uint8Array((await characteristic.readValue()).buffer),
|
|
361
|
+
aesKey
|
|
362
|
+
);
|
|
337
363
|
const timeStamp = Date.now();
|
|
338
364
|
return new PhysicalState(new DataView(value.buffer), timeStamp);
|
|
339
365
|
}
|
|
@@ -360,7 +386,9 @@ var PhysicalState = class {
|
|
|
360
386
|
if (n < 0 || n > MAX_LATEST_MOVES) {
|
|
361
387
|
throw new Error(`Must ask for 0 to 6 latest moves. (Asked for ${n})`);
|
|
362
388
|
}
|
|
363
|
-
return Array.from(this.arr.slice(19 - n, 19)).map(
|
|
389
|
+
return Array.from(this.arr.slice(19 - n, 19)).map(
|
|
390
|
+
(i) => ganMoveToBlockMove[i]
|
|
391
|
+
);
|
|
364
392
|
}
|
|
365
393
|
debugInfo() {
|
|
366
394
|
return {
|
|
@@ -401,7 +429,10 @@ var commands = {
|
|
|
401
429
|
])
|
|
402
430
|
};
|
|
403
431
|
function buf2hex(buffer) {
|
|
404
|
-
return Array.prototype.map.call(
|
|
432
|
+
return Array.prototype.map.call(
|
|
433
|
+
new Uint8Array(buffer),
|
|
434
|
+
(x) => ("00" + x.toString(16)).slice(-2)
|
|
435
|
+
).join(" ");
|
|
405
436
|
}
|
|
406
437
|
var reidEdgeOrder = "UF UR UB UL DF DR DB DL FR FL BR BL".split(" ");
|
|
407
438
|
var reidCornerOrder = "UFR URB UBL ULF DRF DFL DLB DBR".split(" ");
|
|
@@ -446,15 +477,23 @@ var gan356iEdgeMappings = [
|
|
|
446
477
|
var faceOrder = "URFDLB";
|
|
447
478
|
async function getKey(server) {
|
|
448
479
|
const infoService = await server.getPrimaryService(UUIDs.infoService);
|
|
449
|
-
const versionCharacteristic = await infoService.getCharacteristic(
|
|
450
|
-
|
|
480
|
+
const versionCharacteristic = await infoService.getCharacteristic(
|
|
481
|
+
UUIDs.versionCharacteristic
|
|
482
|
+
);
|
|
483
|
+
const versionBuffer = new Uint8Array(
|
|
484
|
+
(await versionCharacteristic.readValue()).buffer
|
|
485
|
+
);
|
|
451
486
|
const versionValue = ((versionBuffer[0] << 8) + versionBuffer[1] << 8) + versionBuffer[2];
|
|
452
487
|
if (versionValue < 65544) {
|
|
453
488
|
return null;
|
|
454
489
|
}
|
|
455
490
|
const keyXor = versionValue < 65792 ? key10 : key11;
|
|
456
|
-
const systemIDCharacteristic = await infoService.getCharacteristic(
|
|
457
|
-
|
|
491
|
+
const systemIDCharacteristic = await infoService.getCharacteristic(
|
|
492
|
+
UUIDs.systemIDCharacteristic
|
|
493
|
+
);
|
|
494
|
+
const systemID = new Uint8Array(
|
|
495
|
+
(await systemIDCharacteristic.readValue()).buffer
|
|
496
|
+
).reverse();
|
|
458
497
|
const key = new Uint8Array(keyXor);
|
|
459
498
|
for (let i = 0; i < systemID.length; i++) {
|
|
460
499
|
key[i] = (key[i] + systemID[i]) % 256;
|
|
@@ -478,12 +517,21 @@ var GanCube = class extends BluetoothPuzzle {
|
|
|
478
517
|
static async connect(server) {
|
|
479
518
|
const ganCubeService = await server.getPrimaryService(UUIDs.ganCubeService);
|
|
480
519
|
debugLog("Service:", ganCubeService);
|
|
481
|
-
const physicalStateCharacteristic = await ganCubeService.getCharacteristic(
|
|
520
|
+
const physicalStateCharacteristic = await ganCubeService.getCharacteristic(
|
|
521
|
+
UUIDs.physicalStateCharacteristic
|
|
522
|
+
);
|
|
482
523
|
debugLog("Characteristic:", physicalStateCharacteristic);
|
|
483
524
|
const aesKey = await getKey(server);
|
|
484
525
|
const initialMoveCounter = (await PhysicalState.read(physicalStateCharacteristic, aesKey)).moveCounter();
|
|
485
526
|
debugLog("Initial Move Counter:", initialMoveCounter);
|
|
486
|
-
const cube = new GanCube(
|
|
527
|
+
const cube = new GanCube(
|
|
528
|
+
await puzzles["3x3x3"].kpuzzle(),
|
|
529
|
+
ganCubeService,
|
|
530
|
+
server,
|
|
531
|
+
physicalStateCharacteristic,
|
|
532
|
+
initialMoveCounter,
|
|
533
|
+
aesKey
|
|
534
|
+
);
|
|
487
535
|
return cube;
|
|
488
536
|
}
|
|
489
537
|
name() {
|
|
@@ -493,7 +541,10 @@ var GanCube = class extends BluetoothPuzzle {
|
|
|
493
541
|
this.server.disconnect();
|
|
494
542
|
}
|
|
495
543
|
startTrackingMoves() {
|
|
496
|
-
this.intervalHandle = window.setInterval(
|
|
544
|
+
this.intervalHandle = window.setInterval(
|
|
545
|
+
this.intervalHandler.bind(this),
|
|
546
|
+
this.INTERVAL_MS
|
|
547
|
+
);
|
|
497
548
|
}
|
|
498
549
|
stopTrackingMoves() {
|
|
499
550
|
if (!this.intervalHandle) {
|
|
@@ -503,16 +554,21 @@ var GanCube = class extends BluetoothPuzzle {
|
|
|
503
554
|
this.intervalHandle = null;
|
|
504
555
|
}
|
|
505
556
|
async intervalHandler() {
|
|
506
|
-
const physicalState = await PhysicalState.read(
|
|
557
|
+
const physicalState = await PhysicalState.read(
|
|
558
|
+
this.physicalStateCharacteristic,
|
|
559
|
+
this.aesKey
|
|
560
|
+
);
|
|
507
561
|
let numInterveningMoves = physicalState.numMovesSince(this.lastMoveCounter);
|
|
508
562
|
if (numInterveningMoves > MAX_LATEST_MOVES) {
|
|
509
|
-
debugLog(
|
|
563
|
+
debugLog(
|
|
564
|
+
`Too many moves! Dropping ${numInterveningMoves - MAX_LATEST_MOVES} moves`
|
|
565
|
+
);
|
|
510
566
|
numInterveningMoves = MAX_LATEST_MOVES;
|
|
511
567
|
}
|
|
512
568
|
for (const move of physicalState.latestMoves(numInterveningMoves)) {
|
|
513
569
|
this.state = this.state.applyMove(move);
|
|
514
|
-
this.
|
|
515
|
-
|
|
570
|
+
this.dispatchAlgLeaf({
|
|
571
|
+
latestAlgLeaf: move,
|
|
516
572
|
timeStamp: physicalState.timeStamp,
|
|
517
573
|
debug: physicalState.debugInfo(),
|
|
518
574
|
state: this.state
|
|
@@ -525,10 +581,15 @@ var GanCube = class extends BluetoothPuzzle {
|
|
|
525
581
|
this.lastMoveCounter = physicalState.moveCounter();
|
|
526
582
|
}
|
|
527
583
|
async getBattery() {
|
|
528
|
-
return new Uint8Array(
|
|
584
|
+
return new Uint8Array(
|
|
585
|
+
await this.readActualAngleAndBatteryCharacteristic()
|
|
586
|
+
)[7];
|
|
529
587
|
}
|
|
530
588
|
async getState() {
|
|
531
|
-
const arr = await decryptState(
|
|
589
|
+
const arr = await decryptState(
|
|
590
|
+
new Uint8Array(await this.readFaceletStatus1Characteristic()),
|
|
591
|
+
this.aesKey
|
|
592
|
+
);
|
|
532
593
|
const stickers = [];
|
|
533
594
|
for (let i = 0; i < 18; i += 3) {
|
|
534
595
|
let v = ((arr[i ^ 1] << 8) + arr[i + 1 ^ 1] << 8) + arr[i + 2 ^ 1];
|
|
@@ -716,13 +777,20 @@ var GiiKERCube = class extends BluetoothPuzzle {
|
|
|
716
777
|
static async connect(server) {
|
|
717
778
|
const cubeService = await server.getPrimaryService(UUIDs2.cubeService);
|
|
718
779
|
debugLog("Service:", cubeService);
|
|
719
|
-
const cubeCharacteristic = await cubeService.getCharacteristic(
|
|
780
|
+
const cubeCharacteristic = await cubeService.getCharacteristic(
|
|
781
|
+
UUIDs2.cubeCharacteristic
|
|
782
|
+
);
|
|
720
783
|
debugLog("Characteristic:", cubeCharacteristic);
|
|
721
|
-
const originalValue = await decodeState(
|
|
784
|
+
const originalValue = await decodeState(
|
|
785
|
+
new Uint8Array((await cubeCharacteristic.readValue()).buffer)
|
|
786
|
+
);
|
|
722
787
|
debugLog("Original value:", originalValue);
|
|
723
788
|
const cube = new GiiKERCube(server, cubeCharacteristic, originalValue);
|
|
724
789
|
await cubeCharacteristic.startNotifications();
|
|
725
|
-
cubeCharacteristic.addEventListener(
|
|
790
|
+
cubeCharacteristic.addEventListener(
|
|
791
|
+
"characteristicvaluechanged",
|
|
792
|
+
cube.onCubeCharacteristicChanged.bind(cube)
|
|
793
|
+
);
|
|
726
794
|
return cube;
|
|
727
795
|
}
|
|
728
796
|
name() {
|
|
@@ -732,7 +800,9 @@ var GiiKERCube = class extends BluetoothPuzzle {
|
|
|
732
800
|
this.server.disconnect();
|
|
733
801
|
}
|
|
734
802
|
async getState() {
|
|
735
|
-
return this.toReid333(
|
|
803
|
+
return this.toReid333(
|
|
804
|
+
new Uint8Array((await this.cubeCharacteristic.readValue()).buffer)
|
|
805
|
+
);
|
|
736
806
|
}
|
|
737
807
|
getBit(val, i) {
|
|
738
808
|
const n = i / 8 | 0;
|
|
@@ -779,8 +849,8 @@ var GiiKERCube = class extends BluetoothPuzzle {
|
|
|
779
849
|
debugLog(giikerState);
|
|
780
850
|
const str = giikerStateStr(giikerState);
|
|
781
851
|
debugLog(str);
|
|
782
|
-
this.
|
|
783
|
-
|
|
852
|
+
this.dispatchAlgLeaf({
|
|
853
|
+
latestAlgLeaf: giikerMoveToAlgMove(giikerState[32], giikerState[33]),
|
|
784
854
|
timeStamp: event.timeStamp,
|
|
785
855
|
debug: {
|
|
786
856
|
stateStr: str
|
|
@@ -828,7 +898,10 @@ var UUIDs3 = {
|
|
|
828
898
|
goCubeStateCharacteristic: "6e400003-b5a3-f393-e0a9-e50e24dcca9e"
|
|
829
899
|
};
|
|
830
900
|
function buf2hex2(buffer) {
|
|
831
|
-
return Array.prototype.map.call(
|
|
901
|
+
return Array.prototype.map.call(
|
|
902
|
+
new Uint8Array(buffer),
|
|
903
|
+
(x) => ("00" + x.toString(16)).slice(-2)
|
|
904
|
+
).join(" ");
|
|
832
905
|
}
|
|
833
906
|
function bufferToString(buffer) {
|
|
834
907
|
const byteView = new Uint8Array(buffer);
|
|
@@ -867,11 +940,16 @@ var GoCube = class extends BluetoothPuzzle {
|
|
|
867
940
|
static async connect(server) {
|
|
868
941
|
const service = await server.getPrimaryService(UUIDs3.goCubeService);
|
|
869
942
|
debugLog({ service });
|
|
870
|
-
const goCubeStateCharacteristic = await service.getCharacteristic(
|
|
943
|
+
const goCubeStateCharacteristic = await service.getCharacteristic(
|
|
944
|
+
UUIDs3.goCubeStateCharacteristic
|
|
945
|
+
);
|
|
871
946
|
debugLog({ goCubeStateCharacteristic });
|
|
872
947
|
const cube = new GoCube(server, goCubeStateCharacteristic);
|
|
873
948
|
await goCubeStateCharacteristic.startNotifications();
|
|
874
|
-
goCubeStateCharacteristic.addEventListener(
|
|
949
|
+
goCubeStateCharacteristic.addEventListener(
|
|
950
|
+
"characteristicvaluechanged",
|
|
951
|
+
cube.onCubeCharacteristicChanged.bind(cube)
|
|
952
|
+
);
|
|
875
953
|
return cube;
|
|
876
954
|
}
|
|
877
955
|
disconnect() {
|
|
@@ -899,8 +977,8 @@ var GoCube = class extends BluetoothPuzzle {
|
|
|
899
977
|
for (let i = 3; i < buffer.byteLength - 4; i += 2) {
|
|
900
978
|
const move = moveMap[buffer.getUint8(i)];
|
|
901
979
|
this.alg = experimentalAppendMove(this.alg, move);
|
|
902
|
-
this.
|
|
903
|
-
|
|
980
|
+
this.dispatchAlgLeaf({
|
|
981
|
+
latestAlgLeaf: moveMap[buffer.getUint8(i)],
|
|
904
982
|
timeStamp: event.timeStamp,
|
|
905
983
|
debug: {
|
|
906
984
|
stateStr: buf2hex2(buffer.buffer)
|
|
@@ -908,7 +986,9 @@ var GoCube = class extends BluetoothPuzzle {
|
|
|
908
986
|
});
|
|
909
987
|
}
|
|
910
988
|
} else {
|
|
911
|
-
const coords = bufferToString(
|
|
989
|
+
const coords = bufferToString(
|
|
990
|
+
buffer.buffer.slice(3, buffer.byteLength - 3)
|
|
991
|
+
).split("#").map((s) => parseInt(s, 10) / 16384);
|
|
912
992
|
const quat = new Quaternion3(coords[0], coords[1], coords[2], coords[3]);
|
|
913
993
|
this.lastRawQuat = quat.clone();
|
|
914
994
|
if (!this.homeQuatInverse) {
|
|
@@ -955,16 +1035,27 @@ var HeykubeCube = class extends BluetoothPuzzle {
|
|
|
955
1035
|
super();
|
|
956
1036
|
this.server = server;
|
|
957
1037
|
this.stateCharacteristic = stateCharacteristic;
|
|
958
|
-
device.addEventListener(
|
|
1038
|
+
device.addEventListener(
|
|
1039
|
+
"gattserverdisconnected",
|
|
1040
|
+
this.onDisconnect.bind(this)
|
|
1041
|
+
);
|
|
959
1042
|
this.stateCharacteristic.startNotifications();
|
|
960
1043
|
this.startTrackingMoves();
|
|
961
1044
|
}
|
|
962
1045
|
static async connect(server, device) {
|
|
963
1046
|
const service = await server.getPrimaryService(UUIDs4.heykubeService);
|
|
964
1047
|
debugLog("Service:", service);
|
|
965
|
-
const stateCharacteristic = await service.getCharacteristic(
|
|
1048
|
+
const stateCharacteristic = await service.getCharacteristic(
|
|
1049
|
+
UUIDs4.stateCharacteristic
|
|
1050
|
+
);
|
|
966
1051
|
debugLog("Characteristic:", stateCharacteristic);
|
|
967
|
-
const cube = new HeykubeCube(
|
|
1052
|
+
const cube = new HeykubeCube(
|
|
1053
|
+
await puzzles["3x3x3"].kpuzzle(),
|
|
1054
|
+
service,
|
|
1055
|
+
device,
|
|
1056
|
+
server,
|
|
1057
|
+
stateCharacteristic
|
|
1058
|
+
);
|
|
968
1059
|
return cube;
|
|
969
1060
|
}
|
|
970
1061
|
name() {
|
|
@@ -977,12 +1068,15 @@ var HeykubeCube = class extends BluetoothPuzzle {
|
|
|
977
1068
|
this.dispatchEvent(new CustomEvent("disconnect"));
|
|
978
1069
|
}
|
|
979
1070
|
startTrackingMoves() {
|
|
980
|
-
this.stateCharacteristic.addEventListener(
|
|
1071
|
+
this.stateCharacteristic.addEventListener(
|
|
1072
|
+
"characteristicvaluechanged",
|
|
1073
|
+
(e) => this.onStateCharacteristic(e)
|
|
1074
|
+
);
|
|
981
1075
|
}
|
|
982
1076
|
onStateCharacteristic(event) {
|
|
983
1077
|
const state = this.decodeState(event.target.value);
|
|
984
|
-
this.
|
|
985
|
-
|
|
1078
|
+
this.dispatchAlgLeaf({
|
|
1079
|
+
latestAlgLeaf: state.latestMove,
|
|
986
1080
|
timeStamp: event.timeStamp,
|
|
987
1081
|
state: state.state
|
|
988
1082
|
});
|
|
@@ -1008,7 +1102,9 @@ var HeykubeCube = class extends BluetoothPuzzle {
|
|
|
1008
1102
|
for (let i = 0; i < dv.byteLength; i++) {
|
|
1009
1103
|
b2[i] = flipBitOrder(dv.getUint8(i), 8);
|
|
1010
1104
|
}
|
|
1011
|
-
const components1 = twizzleBinaryToBinaryComponents(
|
|
1105
|
+
const components1 = twizzleBinaryToBinaryComponents(
|
|
1106
|
+
b2.slice(0, 11)
|
|
1107
|
+
);
|
|
1012
1108
|
const components2 = {
|
|
1013
1109
|
epLex: flipBitOrder(components1.epLex, 29),
|
|
1014
1110
|
eoMask: flipBitOrder(components1.eoMask, 12),
|
|
@@ -1049,7 +1145,10 @@ async function connectSmartPuzzle(options) {
|
|
|
1049
1145
|
|
|
1050
1146
|
// src/cubing/bluetooth/smart-robot/GanRobot.ts
|
|
1051
1147
|
function buf2hex3(buffer) {
|
|
1052
|
-
return Array.prototype.map.call(
|
|
1148
|
+
return Array.prototype.map.call(
|
|
1149
|
+
new Uint8Array(buffer),
|
|
1150
|
+
(x) => ("00" + x.toString(16)).slice(-2)
|
|
1151
|
+
).join(" ");
|
|
1053
1152
|
}
|
|
1054
1153
|
var MAX_NIBBLES_PER_WRITE = 18 * 2;
|
|
1055
1154
|
var QUANTUM_TURN_DURATION_MS = 150;
|
|
@@ -1137,13 +1236,28 @@ var GanRobot = class extends EventTarget {
|
|
|
1137
1236
|
};
|
|
1138
1237
|
this.locked = false;
|
|
1139
1238
|
this.moveQueue = new Alg();
|
|
1140
|
-
device.addEventListener(
|
|
1239
|
+
device.addEventListener(
|
|
1240
|
+
"gattserverdisconnected",
|
|
1241
|
+
this.onDisconnect.bind(this)
|
|
1242
|
+
);
|
|
1141
1243
|
}
|
|
1142
1244
|
static async connect(server, device) {
|
|
1143
|
-
const ganTimerService = await server.getPrimaryService(
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
const
|
|
1245
|
+
const ganTimerService = await server.getPrimaryService(
|
|
1246
|
+
UUIDs5.ganRobotService
|
|
1247
|
+
);
|
|
1248
|
+
const statusCharacteristic = await ganTimerService.getCharacteristic(
|
|
1249
|
+
UUIDs5.statusCharacteristic
|
|
1250
|
+
);
|
|
1251
|
+
const moveCharacteristic = await ganTimerService.getCharacteristic(
|
|
1252
|
+
UUIDs5.moveCharacteristic
|
|
1253
|
+
);
|
|
1254
|
+
const timer = new GanRobot(
|
|
1255
|
+
ganTimerService,
|
|
1256
|
+
server,
|
|
1257
|
+
device,
|
|
1258
|
+
statusCharacteristic,
|
|
1259
|
+
moveCharacteristic
|
|
1260
|
+
);
|
|
1147
1261
|
return timer;
|
|
1148
1262
|
}
|
|
1149
1263
|
name() {
|
|
@@ -1164,7 +1278,9 @@ var GanRobot = class extends EventTarget {
|
|
|
1164
1278
|
}
|
|
1165
1279
|
async writeNibbles(nibbles) {
|
|
1166
1280
|
if (nibbles.length > MAX_NIBBLES_PER_WRITE) {
|
|
1167
|
-
throw new Error(
|
|
1281
|
+
throw new Error(
|
|
1282
|
+
`Can only write ${MAX_NIBBLES_PER_WRITE} nibbles at a time!`
|
|
1283
|
+
);
|
|
1168
1284
|
}
|
|
1169
1285
|
const bytes = new Uint8Array(18);
|
|
1170
1286
|
let i;
|
|
@@ -1193,7 +1309,9 @@ var GanRobot = class extends EventTarget {
|
|
|
1193
1309
|
await sleep(this.experimentalOptions.postSleep);
|
|
1194
1310
|
}
|
|
1195
1311
|
async getStatus() {
|
|
1196
|
-
const statusBytes = new Uint8Array(
|
|
1312
|
+
const statusBytes = new Uint8Array(
|
|
1313
|
+
(await this.statusCharacteristic.readValue()).buffer
|
|
1314
|
+
);
|
|
1197
1315
|
this.experimentalDebugLog("moves remaining:", statusBytes[0]);
|
|
1198
1316
|
return {
|
|
1199
1317
|
movesRemaining: statusBytes[0]
|
|
@@ -1206,26 +1324,26 @@ var GanRobot = class extends EventTarget {
|
|
|
1206
1324
|
if (!this.locked) {
|
|
1207
1325
|
try {
|
|
1208
1326
|
this.locked = true;
|
|
1209
|
-
if (this.moveQueue.
|
|
1327
|
+
if (this.moveQueue.experimentalNumChildAlgNodes() === 1) {
|
|
1210
1328
|
await sleep(this.experimentalOptions.bufferQueue);
|
|
1211
1329
|
}
|
|
1212
|
-
while (this.moveQueue.
|
|
1213
|
-
let
|
|
1214
|
-
if (this.experimentalOptions.singleMoveFixHack &&
|
|
1215
|
-
const move =
|
|
1330
|
+
while (this.moveQueue.experimentalNumChildAlgNodes() > 0) {
|
|
1331
|
+
let algNodes = Array.from(this.moveQueue.childAlgNodes());
|
|
1332
|
+
if (this.experimentalOptions.singleMoveFixHack && algNodes.length === 1) {
|
|
1333
|
+
const move = algNodes[0];
|
|
1216
1334
|
if (move.amount === 2) {
|
|
1217
|
-
|
|
1335
|
+
algNodes = [
|
|
1218
1336
|
move.modified({ amount: 1 }),
|
|
1219
1337
|
move.modified({ amount: 1 })
|
|
1220
1338
|
];
|
|
1221
1339
|
} else {
|
|
1222
|
-
|
|
1340
|
+
algNodes = [
|
|
1223
1341
|
move.modified({ amount: -move.amount }),
|
|
1224
1342
|
move.modified({ amount: 2 })
|
|
1225
1343
|
];
|
|
1226
1344
|
}
|
|
1227
1345
|
}
|
|
1228
|
-
const moves2 =
|
|
1346
|
+
const moves2 = algNodes.splice(0, MAX_NIBBLES_PER_WRITE);
|
|
1229
1347
|
const nibbles = moves2.map(this.moveToNibble.bind(this));
|
|
1230
1348
|
const sending = new Alg(moves2);
|
|
1231
1349
|
this.experimentalDebugLog("SENDING", sending.toString());
|
|
@@ -1233,7 +1351,7 @@ var GanRobot = class extends EventTarget {
|
|
|
1233
1351
|
this.experimentalDebugOnSend(sending);
|
|
1234
1352
|
}
|
|
1235
1353
|
const write = this.writeNibbles(nibbles);
|
|
1236
|
-
this.moveQueue = new Alg(
|
|
1354
|
+
this.moveQueue = new Alg(algNodes);
|
|
1237
1355
|
await write;
|
|
1238
1356
|
}
|
|
1239
1357
|
} finally {
|
|
@@ -1248,12 +1366,18 @@ var GanRobot = class extends EventTarget {
|
|
|
1248
1366
|
await this.queueMoves(new Alg([move]));
|
|
1249
1367
|
} else if (move.family === (this.experimentalOptions.xAngle ? "B" : "U")) {
|
|
1250
1368
|
await Promise.all([
|
|
1251
|
-
this.queueMoves(
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1369
|
+
this.queueMoves(
|
|
1370
|
+
this.experimentalOptions.xAngle ? F_B_SWAP : U_D_SWAP
|
|
1371
|
+
),
|
|
1372
|
+
this.queueMoves(
|
|
1373
|
+
new Alg([
|
|
1374
|
+
move.modified({
|
|
1375
|
+
family: this.experimentalOptions.xAngle ? "F" : "D"
|
|
1376
|
+
})
|
|
1377
|
+
]).concat(
|
|
1378
|
+
this.experimentalOptions.xAngle ? F_B_UNSWAP : U_D_UNSWAP
|
|
1379
|
+
)
|
|
1380
|
+
)
|
|
1257
1381
|
]);
|
|
1258
1382
|
}
|
|
1259
1383
|
}
|
|
@@ -1286,14 +1410,26 @@ var GanTimer = class extends EventTarget {
|
|
|
1286
1410
|
this.previousDetail = null;
|
|
1287
1411
|
this.startPolling();
|
|
1288
1412
|
console.log(server);
|
|
1289
|
-
device.addEventListener(
|
|
1413
|
+
device.addEventListener(
|
|
1414
|
+
"gattserverdisconnected",
|
|
1415
|
+
this.onDisconnect.bind(this)
|
|
1416
|
+
);
|
|
1290
1417
|
}
|
|
1291
1418
|
static async connect(server, device) {
|
|
1292
|
-
const ganTimerService = await server.getPrimaryService(
|
|
1419
|
+
const ganTimerService = await server.getPrimaryService(
|
|
1420
|
+
UUIDs6.ganTimerService
|
|
1421
|
+
);
|
|
1293
1422
|
console.log("Service:", ganTimerService);
|
|
1294
|
-
const timeCharacteristic = await ganTimerService.getCharacteristic(
|
|
1423
|
+
const timeCharacteristic = await ganTimerService.getCharacteristic(
|
|
1424
|
+
UUIDs6.timeCharacteristic
|
|
1425
|
+
);
|
|
1295
1426
|
console.log("Characteristic:", timeCharacteristic);
|
|
1296
|
-
const timer = new GanTimer(
|
|
1427
|
+
const timer = new GanTimer(
|
|
1428
|
+
ganTimerService,
|
|
1429
|
+
server,
|
|
1430
|
+
device,
|
|
1431
|
+
timeCharacteristic
|
|
1432
|
+
);
|
|
1297
1433
|
return timer;
|
|
1298
1434
|
}
|
|
1299
1435
|
disconnect() {
|