-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run dev code in worker. This mitigates browsers hanging while loading…
…/debugging the dev page. Uses the workaround from evanw/esbuild#312 (comment) , since evanw/esbuild#2508 has not landed.
- Loading branch information
Showing
4 changed files
with
43 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { workerURL } from "./worker"; | ||
|
||
new Worker(workerURL, { type: "module" }); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// TODO: remove once `esbuild` supports relative URLs: https://github.com/evanw/esbuild/pull/2508 | ||
export const workerURL = import.meta.url; | ||
|
||
if (globalThis.WorkerGlobalScope) { | ||
(async () => { | ||
const [ | ||
{ cube3x3x3 }, | ||
{ setKPuzzleDefString, solveState, serializeDefToTws }, | ||
] = await Promise.all([import("cubing/puzzles"), import("..")]); | ||
|
||
await setKPuzzleDefString( | ||
serializeDefToTws(await cube3x3x3.kpuzzle(), { | ||
moveSubset: ["U", "L", "F", "R", "B", "D"], | ||
startState: `EDGES | ||
0 0 0 0 1 2 3 4 5 6 7 8 | ||
0 0 0 0 0 0 0 0 0 0 0 0 | ||
CORNERS | ||
0 0 0 0 1 2 3 4 | ||
0 0 0 0 0 0 0 0 | ||
CENTERS | ||
0 1 2 3 4 5 | ||
0 0 0 0 0 0`, | ||
}), | ||
); | ||
( | ||
await solveState(`ScrambleState test | ||
EDGES | ||
0 0 0 0 1 2 3 4 5 6 7 8 | ||
1 1 1 1 0 0 0 0 0 0 0 0 | ||
CORNERS | ||
0 0 0 0 1 2 3 4 | ||
0 0 0 0 0 0 0 0 | ||
CENTERS | ||
0 1 2 3 4 5 | ||
0 0 0 0 0 0 | ||
End`) | ||
).log(); | ||
})(); | ||
} |