Skip to content

Commit

Permalink
[search] Introduce cubing-private exports for search.
Browse files Browse the repository at this point in the history
This allows us to use functions across sub-packages without exporting them publicly. This is generally a sign of bad design, but it allows us to ship certain functionality without exposing an experimental API that we do not intend to support in the future.

In particular, this PR removes `[experimental]randomScrambleForEvent()` from `cubing/search`, since it's only meant to be used from `cubing/scramble`.
  • Loading branch information
lgarron committed May 15, 2022
1 parent ec69843 commit a0e0af5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions script/test/import-restrictions/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const TARGET_INFOS_PATH = resolve(
"./target-infos.js",
);

const CUBING_PRIVATE_SUFFIX = "/cubing-private";

// Note that we have to use an extra `..` to back out of the file name
const PATH_TO_SRC_CUBING = resolve(
new URL(".", import.meta.url).pathname,
Expand Down Expand Up @@ -77,6 +79,11 @@ class Target {
return undefined;
}

// Allow cubing-private cross-package exports.
if (args.path.endsWith(CUBING_PRIVATE_SUFFIX)) {
args.path = args.path.slice(0, -CUBING_PRIVATE_SUFFIX.length);
}

const resolved = resolve(args.resolveDir, args.path);
if (this.dirPath === resolved) {
this.checkImportable(args, forTarget);
Expand Down
2 changes: 1 addition & 1 deletion src/cubing/scramble/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { experimentalRandomScrambleForEvent as randomScrambleForEvent } from "../search";
export { randomScrambleForEvent } from "../search/cubing-private";
1 change: 1 addition & 0 deletions src/cubing/search/cubing-private/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { randomScrambleForEvent } from "../outside";
1 change: 0 additions & 1 deletion src/cubing/search/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export {
randomScrambleForEvent as experimentalRandomScrambleForEvent,
experimentalSolve3x3x3IgnoringCenters,
experimentalSolve2x2x2,
solveSkewb,
Expand Down

0 comments on commit a0e0af5

Please sign in to comment.