diff --git a/.gitignore b/.gitignore index 7be0d7764d..47582e6f98 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ public/trans public/compiled public/vendor/stockfish public/vendor/stockfish.wasm +public/vendor/stockfish-mv.wasm target bin/.translate_version data/ diff --git a/ui/ceval/src/ctrl.ts b/ui/ceval/src/ctrl.ts index 54eb227e5e..d019312cda 100644 --- a/ui/ceval/src/ctrl.ts +++ b/ui/ceval/src/ctrl.ts @@ -16,7 +16,7 @@ function sanIrreversible(variant: VariantKey, san: string): boolean { } function officialStockfish(variant: VariantKey): boolean { - return variant === 'standard' || variant === 'chess960' || variant === 'fromPosition'; + return variant === 'standard' || variant === 'chess960'; } export default function(opts: CevalOpts): CevalCtrl { @@ -27,7 +27,7 @@ export default function(opts: CevalOpts): CevalCtrl { const pnaclSupported: boolean = !opts.failsafe && 'application/x-pnacl' in navigator.mimeTypes; const wasmSupported = typeof WebAssembly === 'object' && WebAssembly.validate(Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00)); - const wasmThreadsSupported = officialStockfish(opts.variant.key) && wasmSupported && typeof SharedArrayBuffer === 'function' && new WebAssembly!.Memory({shared: true, initial: 8, maximum: 8}).buffer instanceof SharedArrayBuffer; + const wasmThreadsSupported = wasmSupported && typeof SharedArrayBuffer === 'function' && new WebAssembly!.Memory({shared: true, initial: 8, maximum: 8}).buffer instanceof SharedArrayBuffer; const minDepth = 6; const maxDepth = storedProp(storageKey('ceval.max-depth'), 18); const multiPv = storedProp(storageKey('ceval.multipv'), opts.multiPvDefault || 1); @@ -48,7 +48,7 @@ export default function(opts: CevalOpts): CevalCtrl { asmjs: li.assetUrl(sfPath + '.js', {sameDomain: true}), pnacl: pnaclSupported && li.assetUrl(sfPath + '.nmf'), wasm: wasmSupported && li.assetUrl(sfPath + '.wasm.js', {sameDomain: true}), - wasmThreaded: wasmThreadsSupported && 'vendor/stockfish.wasm/stockfish.js', + wasmThreaded: wasmThreadsSupported && (officialStockfish(opts.variant.key) ? 'vendor/stockfish.wasm/stockfish.js' : 'vendor/stockfish-mv.wasm/stockfish.js'), onCrash: opts.onCrash }, { minDepth, diff --git a/ui/site/gulpfile.js b/ui/site/gulpfile.js index 09010c9e49..582393bcb7 100644 --- a/ui/site/gulpfile.js +++ b/ui/site/gulpfile.js @@ -74,6 +74,15 @@ gulp.task('stockfish.wasm', function() { ]).pipe(gulp.dest('../../public/vendor/stockfish.wasm/')); }); +gulp.task('stockfish-mv.wasm', function() { + gulp.src([ + require.resolve('stockfish-mv.wasm/stockfish.js'), + require.resolve('stockfish-mv.wasm/stockfish.js.mem'), + require.resolve('stockfish-mv.wasm/stockfish.wasm'), + require.resolve('stockfish-mv.wasm/pthread-main.js') + ]).pipe(gulp.dest('../../public/vendor/stockfish-mv.wasm/')); +}); + gulp.task('prod-source', function() { return browserify('src/index.ts', { standalone: standalone @@ -147,7 +156,7 @@ gulp.task('user-mod', function() { .pipe(gulp.dest(destination)); }); -const tasks = ['git-sha', 'jquery-fill', 'ab', 'standalones', 'user-mod', 'stockfish.wasm']; +const tasks = ['git-sha', 'jquery-fill', 'ab', 'standalones', 'user-mod', 'stockfish.wasm', 'stockfish-mv.wasm']; if (!process.env.TRAVIS || process.env.GITHUB_API_TOKEN) { if (!process.env.NO_SF) { // to skip SF download tasks.push('stockfish.pexe'); diff --git a/ui/site/package.json b/ui/site/package.json index 28feac06f7..cdecd84504 100644 --- a/ui/site/package.json +++ b/ui/site/package.json @@ -22,6 +22,7 @@ "vinyl-source-stream": "^1" }, "dependencies": { + "stockfish-mv.wasm": "^0.2.0", "stockfish.wasm": "^0.2.0", "tablesort": "^5.0.0" } diff --git a/yarn.lock b/yarn.lock index 751a6cb67f..04bd9dc481 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4425,6 +4425,11 @@ static-extend@^0.1.1: define-property "^0.2.5" object-copy "^0.1.0" +stockfish-mv.wasm@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/stockfish-mv.wasm/-/stockfish-mv.wasm-0.2.0.tgz#b402050ccca5455ed4419ffe2ad96d52a19c5f34" + integrity sha512-a2E/J0kBJIfoKdC8KPNy+xGQ4hvT/E10THMxjqmy1aHCgoV0pvOY+lgcLqvm6Q4c5IyFX5iDiY59ZrrtHedbEg== + stockfish.wasm@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/stockfish.wasm/-/stockfish.wasm-0.2.0.tgz#f92ee6a35c0ca3dacbd704adfec2df5101116503"