diff --git a/docs/architecture.md b/docs/architecture.md index 0eeb8740..54be3f5e 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -99,9 +99,7 @@ reference vectors from that project in `test/cube/notation/orbit64Vectors.json` and `test/cube/notation/orbit64LargeVectors.json`. Only the V2 format exists in the app: [`Orbit64Token.res`](../src/cube/notation/Orbit64Token.res) writes the color framed token of the notation card for sizes 2-15 and reads color tokens -in the typed-input field. V2 reads the V1 tokens of sizes 2, 3, 4, 6 and 7 as -color framed tokens at offset 0; the 43-character V1 token of a 5x5 cube is not -read. +in the typed-input field. A string that is not a V2 color token is rejected. The Orbit64 V2 state codec for 2x2-15x15 cubes ([`Orbit64V2.res`](../src/cube/notation/Orbit64V2.res)) works on orbit diff --git a/src/core/capture/CaptureFlow.res b/src/core/capture/CaptureFlow.res index abb5a102..aaaf1dbe 100644 --- a/src/core/capture/CaptureFlow.res +++ b/src/core/capture/CaptureFlow.res @@ -148,9 +148,7 @@ let parseCubeInput = (input, selectedFormat: NotationOutput.notationFormat) => { | None => Unreadable({ message: isToken - ? String.length(trimmed) == 43 - ? "Orbit64 V1 is no longer supported" - : "Invalid Orbit64 state token. Only Orbit64 V2 color state tokens of 2×2–15×15 cubes are supported." + ? "Invalid Orbit64 state token. Only Orbit64 V2 color state tokens of 2×2–15×15 cubes are supported." : format == Wrg ? "Invalid facelets. Must be 6 space-separated blocks of equal, perfect-square length (9 for 3×3, 25 for 5×5, ...) using colors W, O, G, R, B, Y, in U R F D L B order." : "Invalid facelets. Must be 6 space-separated blocks of equal, perfect-square length (9 for 3×3, 25 for 5×5, ...) using letters U, R, F, D, L, B (the face each sticker matches when solved), in U R F D L B order.", diff --git a/src/cube/notation/Orbit64Token.res b/src/cube/notation/Orbit64Token.res index e15e72e5..a9c23543 100644 --- a/src/cube/notation/Orbit64Token.res +++ b/src/cube/notation/Orbit64Token.res @@ -1,17 +1,14 @@ // The Orbit64 state token of the app: V2, color model, framed pose, for cubes // of size 2..15. A framed color token keeps the whole-cube orientation, so a -// cube read from the facelets round-trips with its orientation. Tokens of the -// V1 format of sizes 2, 3, 4, 6 and 7 are the same strings. Format: +// cube read from the facelets round-trips with its orientation. Framed color +// tokens of sizes 2, 3, 4, 6 and 7 match the strings of the earlier format. +// Format: // FORMAT-V2.md of flix-orbit64 (Apache-2.0); the codec is in Orbit64V2.res and // Orbit64V2Facelets.res. let minSize = 2 let maxSize = 15 -// The V1 token of a 5x5 cube had 43 characters; V2 does not read it. It is -// still recognized as a token so the reader can say why it is refused. -let legacyFiveWidth = 43 - let tokenPattern = RegExp.fromString("^[A-Za-z0-9_-]+$") let sizeOfFacelets = text => { @@ -28,13 +25,12 @@ let framedColorId = n => ->Array.find(entry => entry.n == n && entry.model == Color && entry.pose == Framed) ->Option.map(entry => entry.id) -// True for a token of a registered V2 length, and for the V1 5x5 length. +// True for a token of a registered V2 length. @genType let looksLikeToken = input => { let token = String.trim(input) tokenPattern->RegExp.test(token) && - (String.length(token) == legacyFiveWidth || - Orbit64V2.entries->Array.some(entry => entry.length == String.length(token))) + Orbit64V2.entries->Array.some(entry => entry.length == String.length(token)) } // The token of a cube given as facelets (six blocks in U R F D L B order, diff --git a/test/cube/notation/orbit64Token.test.ts b/test/cube/notation/orbit64Token.test.ts index 148ed1b6..7edce984 100644 --- a/test/cube/notation/orbit64Token.test.ts +++ b/test/cube/notation/orbit64Token.test.ts @@ -73,23 +73,21 @@ describe('Orbit64 token in the UI layer, sizes 2 to 15', () => { expect(parseCubeInput(token, 'urf')).toMatchObject({ ok: true, cube }) }) - it.each( - [...examples, ...largeExamples].filter(([token]) => token.length !== 43), - )('writes the published V1 token %s unchanged', (token, facelets) => { - expect(encodeOrbit64Token(facelets)).toBe(token) - expect(decodeOrbit64Token(token)).toBe(facelets) - }) + it.each([...examples, ...largeExamples])( + 'writes the published token %s unchanged', + (token, facelets) => { + expect(encodeOrbit64Token(facelets)).toBe(token) + expect(decodeOrbit64Token(token)).toBe(facelets) + }, + ) it('refuses a token that is no color cube of the range', () => { - const v1Five = ([...examples, ...largeExamples].find( - ([t]) => t.length === 43, - ) ?? [''])[0] - expect(v1Five).toHaveLength(43) - expect(decodeOrbit64Token(v1Five)).toBeNull() - const refused = parseCubeInput(v1Five, 'urf') + const notV2 = 'A'.repeat(43) + expect(looksLikeOrbit64Token(notV2)).toBe(false) + expect(decodeOrbit64Token(notV2)).toBeNull() + const refused = parseCubeInput(notV2, 'urf') expect(refused.ok).toBe(false) - if (!refused.ok) - expect(refused.message).toBe('Orbit64 V1 is no longer supported') + if (!refused.ok) expect(refused.message).not.toMatch(/V1/) expect(decodeOrbit64Token('A'.repeat(7))).toBeNull() expect(encodeOrbit64Token('UUUU RRRR FFFF DDDD LLLL')).toBeNull() const sixteen = ['U', 'R', 'F', 'D', 'L', 'B'] diff --git a/test/cube/notation/orbit64V2.test.ts b/test/cube/notation/orbit64V2.test.ts index 569fe92a..2ca17c49 100644 --- a/test/cube/notation/orbit64V2.test.ts +++ b/test/cube/notation/orbit64V2.test.ts @@ -334,38 +334,39 @@ const v1Tokens: [number, string][] = [ ...v1LargeExamples.map(([token]): [number, string] => [token.length, token]), ] -describe('Orbit64 V2 reads V1 state tokens', () => { +describe('Orbit64 V2 reads the published color framed tokens', () => { const sizeOfWidth: Record = { 5: 2, 12: 3, 27: 4, + 42: 5, 66: 6, 90: 7, } - it('reads each V1 token as the color framed entry of its size', () => { + it('reads each published token as the color framed entry of its size', () => { const covered = new Set() for (const [width, token] of v1Tokens) { - if (width === 43) continue const n = sizeOfWidth[width] const decoded = ok(decodeOrbit64V2State(token)) expect(decoded.entry.n, token).toBe(n) expect(decoded.entry.model).toBe('Color') expect(decoded.entry.pose).toBe('Framed') expect(decoded.entry.length).toBe(width) - expect(decoded.entry.offset).toBe(0n) + if (n !== 5) expect(decoded.entry.offset).toBe(0n) expect(encodeOrbit64V2State(decoded.entry.id, decoded.cube)).toEqual({ TAG: 'Ok', _0: token, }) covered.add(n) } - expect([...covered].sort()).toEqual([2, 3, 4, 6, 7]) + expect([...covered].sort()).toEqual([2, 3, 4, 5, 6, 7]) }) - it('has the V1 corner digit of the token as its corner state', () => { + it('has the corner digit of a shared-width token as its corner state', () => { for (const [width, token] of v1Tokens) { - if (width === 43) continue + // A 5×5 framed token is 42 characters and does not use that digit layout. + if (width === 42) continue const e = orbit64V2Entries.find( (o) => o.length === width && o.offset === 0n, ) @@ -378,12 +379,8 @@ describe('Orbit64 V2 reads V1 state tokens', () => { } }) - it('rejects the 43-character V1 5x5x5 tokens', () => { - const tokens = v1Tokens.filter(([width]) => width === 43) - expect(tokens.length).toBeGreaterThan(0) - for (const [, token] of tokens) { - expect(decodeOrbit64V2State(token).TAG, token).toBe('Error') - } + it('rejects a length that is not a V2 entry', () => { + expect(v1Tokens.some(([width]) => width === 43)).toBe(false) expect(decodeOrbit64V2State('A'.repeat(43)).TAG).toBe('Error') }) }) diff --git a/test/cube/notation/orbit64Vectors.json b/test/cube/notation/orbit64Vectors.json index ca7867e8..12ec44b0 100644 --- a/test/cube/notation/orbit64Vectors.json +++ b/test/cube/notation/orbit64Vectors.json @@ -260,83 +260,83 @@ "BBBDLFLULLDBUFUL UURBBRDUBFFUFDDB BRFFUUURDBRURDRL FFDDURBBBULLDRLD UFBRRBFRLLDFRLLU RDRLLBRFFDUFLDDF" ], [ - "AvS6-HtG-C7Jh7ScbCTPUW7og3xXOhLInHugqLe5UuH", + "xzBUxQ0Gkz46kK4aNErYR-vb64GB0xcnPugqLe5UuH", "LRLFRLUDLLULFUUBFLFRBDBDD RDRDBLDFRRRDDULFFRUUFRLDR UFRBBBUBBFFULDDRDLBURFFFU FLURLLLUDBBDBFFRUFBFLBLDF DBBDLRDLFLRRUBDBRFLBDFDUU UUUUBDRBRUBBRRFLLRBUDLDUF" ], [ - "AJQoG7cPtMbbwLcCHXD8TQ2RbDT_AfvOaqYVqhmhFuA", + "Lwudk_81uULI0UeGh1YXL5YWGatzzViayYVqhmhFuA", "FFLRBFRFURFRUBUBLBDBBBDDU FURDRUFDDLLB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DDBBUD BBLRUDFLUBURFBDLFDDLFLFLB" ], [ - "AzoDX42ToXBeRf5H6dnqIvKqXQFyw0p7XDDJGaCrKlq", + "2IJuiaAw46NqIxj5oZGMqNxSTMhkIQPXLDJGaCrKlq", "UBUBDULDBRBRDBFFURFLRBLFU LUUFRBBULBDLLDRLFUFFDULFR UDURBDLDURDFFFBFDDRDLRUDB DURLRDRBURFFULDLBFDDDBFDU FBRLBFRULBLRRLFDDRBUFULRB FLBLLRUBDUDLBBBLRUFFFRRUL" ], [ - "ADeE-tVcmzc3-2_fn6SlTWEV9hWVKARgnKCqz8QLlby", + "F-LVW5JvVVnXf37nFEBXRHc4kdD9T30nSCqz8QLlby", "FDBFDRBFRURDUUUBLFUBDUBRU LUFLRBBBUFUFLBUBLRUBBLLBB LRUBBLFBFDDLBDLDRURRBDLLU DBFFRUFLLDBLDRDLDDFULRBFD UFDLFFLBDFFFRRFRRUBFFDRLR FRLRRUURBURUFLRLDDDDLDDUU" ], [ - "AWp8nHaK9il2FqbeCHJ4XjyqVeKKppv3n86Rf42SHAm", + "ZKC9w94GEeleTT6BR7Ube1xQhQ5c9WLoE6Rf42SHAm", "BURBLBURLFFLBBURRUBULLFDF RFLLFDDUDRFDLUBLFBDDLRRFU BDUFDLRDFLUFDDRDUURUDDDLD RRFBFFULBUDBFFUBLBBDRFLFF LULFUUFLLBLLRFBRLDURBRBLB UDDLDBRRDBRRUFBBBRFURRDUU" ], [ - "ABnDtiZokyHmms3p6LtBXgycxjr6osyPInwOohl4M_a", + "EHKEL9VtUAV_VwF5Wedbb1jsmypcAYjIvwOohl4M_a", "UDUDBFLBFFFLUBDFUDBUFFDLF DRFLLBRUFRBDLRLUURBDRRLDF LUBFLURFBDURBFUULLULDRRBD BUBDBRBBRDRFDRUBLBDFBULLD RRRUUBDUFBLURDFFFFDBULDBL ULRLFDLDRRDLFLBFUUDRRBFLR" ], [ - "AYdjc0FLPLj9ln8zqi186p5-p9oCjWBsTm-iV7bXqYl", + "a9pzd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RBLBRFLFDFRBU LUFRFBRDUFFFUUBUUURUUDBLB LLRBRFFDBLFBFRDRUDLRULBRR DRURDUBFDDLLLUDBFFLLFBLUB FBRLLRDRFFDUDLBDLLDLBDUDR" ], [ - "AmLkUIMLuHZGzTN5Wrx9ee5DNn1uAG_HKq0qxQuXApU", + "orqqxv42pR2L8GVV2jZiZ8KIq8czalbKy0qxQuXApU", "DBLDLBLFUFUDRBULURDLLURDU LDLDFUFDFUDDDLFDDUDRRFRUB FRDFBRDURFURFFBURLLRRUBRB FBLBUDUBBLFULBBFBLRLDUURR BDRBDLURLBDBUUFBFRLFRRLRU ULDLLBBDFFRFBFFUBLRDDFBLF" ], [ - "AsYwhJY1cjkL82sdoWKi3lV9eUlNb8a-raM8DHyue_x", + "u423y8ilFc7Vfk5ng7-7gZEZXr8PQBSriM8DHyue_x", "LLDBLUDDBUFUDUBRBDUDFURBU RRUFFFURDDFFFRDFRRLBDLUFD RRBRFRURDLBLRBUUFLLRBBLDF RDULLBRLRFFFUFRUDBUDBURBB DFRFDLBUFDLLBBDLFDFLLRLUU URLUBFRBLBFDLUBLBFLDRDDBU" ], [ - "AXGLnbTKXqKxd_oXf_CAMU1jZIOgs5vfBcSMkdJJrE8", + "ZmR-E23gMDg2ogzfJzcQP4qULVPgNVzBkSMkdJJrE8", "RDRBBRRBUFFRBDLRDUFUDLBBU LFBDDUBLRBDRRFUULFURRRURF LUUDBUFULLLDUBBDDUDFUBRBB RLFLUDBBRDRUFFLLLFRBUFFFD BBUDFBLDFRLRLRDFUDUFLFDLF LUBLDUDLFDRLDLFUBBBLRRDRF" ], [ - "APYf0C4g2trHzzfhD0PyexpL6BjwfwJw4xepbWZc2P3", + "R4mKscN_Pj3McX9C_BOissS1EqfTDwE45epbWZc2P3", "LULBLBRDBRLFBRLFFDRURDBFF RLBDFUUBULRRUBDFBULLFDUUL ULRRDLDUDRFBLFDBUFDDDFDUR RRBFUUFBFBULFLBBLFULLFUDU DRULBFBLFDFDDRDUDLRRDUFFB UDFBBBLDLLLRRURBRUBRBRRDF" ], [ - "A3kv9rOq4LrmEub0WLlGlgPIOn5wGJBYyckrG7H69rb", + "6E2UUyYAtkVdXUQVWWipbSPJrAe5cnsykkrG7H69rb", "UUBDRRLRDLUBUBDUFDFBLRBDB URRBDULUFLDFFFUBDULFRLRUU DFURLDDULRLLLBLLRRBLUFRBF BUFDDLBDRFLLDDBDBBURLFUFL RBLBBUDRFLFFBFBFRLRUDBFDR BRDLFFUUUBRDRLDDBRUDFUFRF" ] ]