draught/index_js.bootstrap.js
2021-06-26 20:15:29 +00:00

44 lines
15 KiB
JavaScript

/*
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
* This devtool is neither made for production nor for readable output files.
* It uses "eval()" calls to create a separate source file in the browser devtools.
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
* or disable the default devtool with "devtool: false".
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
*/
(self["webpackChunkdraught"] = self["webpackChunkdraught"] || []).push([["index_js"],{
/***/ "../pkg/draught_bg.js":
/*!****************************!*\
!*** ../pkg/draught_bg.js ***!
\****************************/
/***/ ((module, __webpack_exports__, __webpack_require__) => {
"use strict";
eval("__webpack_require__.a(module, async (__webpack_handle_async_dependencies__) => {\n__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"init_game\": () => (/* binding */ init_game),\n/* harmony export */ \"Team\": () => (/* binding */ Team),\n/* harmony export */ \"Strength\": () => (/* binding */ Strength),\n/* harmony export */ \"SquareState\": () => (/* binding */ SquareState),\n/* harmony export */ \"Moveable\": () => (/* binding */ Moveable),\n/* harmony export */ \"Board\": () => (/* binding */ Board),\n/* harmony export */ \"BrdIdx\": () => (/* binding */ BrdIdx),\n/* harmony export */ \"Game\": () => (/* binding */ Game),\n/* harmony export */ \"Piece\": () => (/* binding */ Piece),\n/* harmony export */ \"Square\": () => (/* binding */ Square),\n/* harmony export */ \"__wbindgen_string_new\": () => (/* binding */ __wbindgen_string_new),\n/* harmony export */ \"__wbindgen_object_drop_ref\": () => (/* binding */ __wbindgen_object_drop_ref),\n/* harmony export */ \"__wbg_log_9a99fb1af846153b\": () => (/* binding */ __wbg_log_9a99fb1af846153b),\n/* harmony export */ \"__wbg_new_59cb74e423758ede\": () => (/* binding */ __wbg_new_59cb74e423758ede),\n/* harmony export */ \"__wbg_stack_558ba5917b466edd\": () => (/* binding */ __wbg_stack_558ba5917b466edd),\n/* harmony export */ \"__wbg_error_4bb6c2a97407129a\": () => (/* binding */ __wbg_error_4bb6c2a97407129a),\n/* harmony export */ \"__wbindgen_throw\": () => (/* binding */ __wbindgen_throw)\n/* harmony export */ });\n/* harmony import */ var _draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./draught_bg.wasm */ \"../pkg/draught_bg.wasm\");\n/* module decorator */ module = __webpack_require__.hmd(module);\nvar __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__]);\n_draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? await __webpack_async_dependencies__ : __webpack_async_dependencies__)[0];\n\n\nconst lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;\n\nlet cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });\n\ncachedTextDecoder.decode();\n\nlet cachegetUint8Memory0 = null;\nfunction getUint8Memory0() {\n if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== _draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__.memory.buffer) {\n cachegetUint8Memory0 = new Uint8Array(_draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__.memory.buffer);\n }\n return cachegetUint8Memory0;\n}\n\nfunction getStringFromWasm0(ptr, len) {\n return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));\n}\n\nconst heap = new Array(32).fill(undefined);\n\nheap.push(undefined, null, true, false);\n\nlet heap_next = heap.length;\n\nfunction addHeapObject(obj) {\n if (heap_next === heap.length) heap.push(heap.length + 1);\n const idx = heap_next;\n heap_next = heap[idx];\n\n heap[idx] = obj;\n return idx;\n}\n\nfunction getObject(idx) { return heap[idx]; }\n\nfunction dropObject(idx) {\n if (idx < 36) return;\n heap[idx] = heap_next;\n heap_next = idx;\n}\n\nfunction takeObject(idx) {\n const ret = getObject(idx);\n dropObject(idx);\n return ret;\n}\n\nfunction _assertClass(instance, klass) {\n if (!(instance instanceof klass)) {\n throw new Error(`expected instance of ${klass.name}`);\n }\n return instance.ptr;\n}\n/**\n*/\nfunction init_game() {\n _draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__.init_game();\n}\n\nlet WASM_VECTOR_LEN = 0;\n\nconst lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;\n\nlet cachedTextEncoder = new lTextEncoder('utf-8');\n\nconst encodeString = (typeof cachedTextEncoder.encodeInto === 'function'\n ? function (arg, view) {\n return cachedTextEncoder.encodeInto(arg, view);\n}\n : function (arg, view) {\n const buf = cachedTextEncoder.encode(arg);\n view.set(buf);\n return {\n read: arg.length,\n written: buf.length\n };\n});\n\nfunction passStringToWasm0(arg, malloc, realloc) {\n\n if (realloc === undefined) {\n const buf = cachedTextEncoder.encode(arg);\n const ptr = malloc(buf.length);\n getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);\n WASM_VECTOR_LEN = buf.length;\n return ptr;\n }\n\n let len = arg.length;\n let ptr = malloc(len);\n\n const mem = getUint8Memory0();\n\n let offset = 0;\n\n for (; offset < len; offset++) {\n const code = arg.charCodeAt(offset);\n if (code > 0x7F) break;\n mem[ptr + offset] = code;\n }\n\n if (offset !== len) {\n if (offset !== 0) {\n arg = arg.slice(offset);\n }\n ptr = realloc(ptr, len, len = offset + arg.length * 3);\n const view = getUint8Memory0().subarray(ptr + offset, ptr + len);\n const ret = encodeString(arg, view);\n\n offset += ret.written;\n }\n\n WASM_VECTOR_LEN = offset;\n return ptr;\n}\n\nlet cachegetInt32Memory0 = null;\nfunction getInt32Memory0() {\n if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== _draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__.memory.buffer) {\n cachegetInt32Memory0 = new Int32Array(_draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__.memory.buffer);\n }\n return cachegetInt32Memory0;\n}\n/**\n*/\nconst Team = Object.freeze({ Black:0,\"0\":\"Black\",White:1,\"1\":\"White\", });\n/**\n*/\nconst Strength = Object.freeze({ Man:0,\"0\":\"Man\",King:1,\"1\":\"King\", });\n/**\n*/\nconst SquareState = Object.freeze({ Empty:0,\"0\":\"Empty\",Occupied:1,\"1\":\"Occupied\",Unplayable:2,\"2\":\"Unplayable\", });\n/**\n*/\nconst Moveable = Object.freeze({ Allowed:0,\"0\":\"Allowed\",Occupied:1,\"1\":\"Occupied\",OutOfBounds:2,\"2\":\"OutOfBounds\", });\n/**\n* Models a single state for a checkers board\n*/\nclass Board {\n\n static __wrap(ptr) {\n const obj = Object.create(Board.prototype);\n obj.ptr = ptr;\n\n return obj;\n }\n\n __destroy_into_raw() {\n const ptr = this.ptr;\n this.ptr = 0;\n\n return ptr;\n }\n\n free() {\n const ptr = this.__destroy_into_raw();\n _draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__.__wbg_board_free(ptr);\n }\n /**\n * @param {number} idx\n * @returns {Square}\n */\n cell(idx) {\n var ret = _draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__.board_cell(this.ptr, idx);\n return Square.__wrap(ret);\n }\n /**\n * @param {BrdIdx} idx\n * @returns {Square}\n */\n grid_cell(idx) {\n _assertClass(idx, BrdIdx);\n var ptr0 = idx.ptr;\n idx.ptr = 0;\n var ret = _draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__.board_grid_cell(this.ptr, ptr0);\n return Square.__wrap(ret);\n }\n /**\n * @param {number} row\n * @param {number} col\n * @returns {number}\n */\n cell_index(row, col) {\n var ret = _draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__.board_cell_index(this.ptr, row, col);\n return ret >>> 0;\n }\n /**\n * @param {BrdIdx} idx\n * @returns {number}\n */\n cell_idx(idx) {\n _assertClass(idx, BrdIdx);\n var ptr0 = idx.ptr;\n idx.ptr = 0;\n var ret = _draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__.board_cell_idx(this.ptr, ptr0);\n return ret >>> 0;\n }\n /**\n * @param {number} idx\n * @returns {BrdIdx}\n */\n board_index(idx) {\n var ret = _draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__.board_board_index(this.ptr, idx);\n return BrdIdx.__wrap(ret);\n }\n /**\n * @param {number} width\n * @param {number} height\n * @returns {Board}\n */\n static new(width, height) {\n var ret = _draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__.board_new(width, height);\n return Board.__wrap(ret);\n }\n /**\n * @param {Board} board\n * @returns {Board}\n */\n static init_game(board) {\n _assertClass(board, Board);\n var ptr0 = board.ptr;\n board.ptr = 0;\n var ret = _draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__.board_init_game(ptr0);\n return Board.__wrap(ret);\n }\n /**\n * @returns {number}\n */\n current_turn() {\n var ret = _draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__.board_current_turn(this.ptr);\n return ret >>> 0;\n }\n /**\n * @returns {number}\n */\n cells() {\n var ret = _draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__.board_cells(this.ptr);\n return ret;\n }\n /**\n * @returns {number}\n */\n num_cells() {\n var ret = _draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__.board_num_cells(this.ptr);\n return ret >>> 0;\n }\n /**\n * @param {number} idx\n * @returns {number}\n */\n cell_state(idx) {\n var ret = _draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__.board_cell_state(this.ptr, idx);\n return ret >>> 0;\n }\n}\n/**\n*/\nclass BrdIdx {\n\n static __wrap(ptr) {\n const obj = Object.create(BrdIdx.prototype);\n obj.ptr = ptr;\n\n return obj;\n }\n\n __destroy_into_raw() {\n const ptr = this.ptr;\n this.ptr = 0;\n\n return ptr;\n }\n\n free() {\n const ptr = this.__destroy_into_raw();\n _draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__.__wbg_brdidx_free(ptr);\n }\n /**\n * @param {number} row\n * @param {number} col\n * @returns {BrdIdx}\n */\n static from(row, col) {\n var ret = _draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__.brdidx_from(row, col);\n return BrdIdx.__wrap(ret);\n }\n}\n/**\n*/\nclass Game {\n\n __destroy_into_raw() {\n const ptr = this.ptr;\n this.ptr = 0;\n\n return ptr;\n }\n\n free() {\n const ptr = this.__destroy_into_raw();\n _draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__.__wbg_game_free(ptr);\n }\n}\n/**\n*/\nclass Piece {\n\n __destroy_into_raw() {\n const ptr = this.ptr;\n this.ptr = 0;\n\n return ptr;\n }\n\n free() {\n const ptr = this.__destroy_into_raw();\n _draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__.__wbg_piece_free(ptr);\n }\n}\n/**\n*/\nclass Square {\n\n static __wrap(ptr) {\n const obj = Object.create(Square.prototype);\n obj.ptr = ptr;\n\n return obj;\n }\n\n __destroy_into_raw() {\n const ptr = this.ptr;\n this.ptr = 0;\n\n return ptr;\n }\n\n free() {\n const ptr = this.__destroy_into_raw();\n _draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__.__wbg_square_free(ptr);\n }\n}\n\nfunction __wbindgen_string_new(arg0, arg1) {\n var ret = getStringFromWasm0(arg0, arg1);\n return addHeapObject(ret);\n};\n\nfunction __wbindgen_object_drop_ref(arg0) {\n takeObject(arg0);\n};\n\nfunction __wbg_log_9a99fb1af846153b(arg0) {\n console.log(getObject(arg0));\n};\n\nfunction __wbg_new_59cb74e423758ede() {\n var ret = new Error();\n return addHeapObject(ret);\n};\n\nfunction __wbg_stack_558ba5917b466edd(arg0, arg1) {\n var ret = getObject(arg1).stack;\n var ptr0 = passStringToWasm0(ret, _draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__.__wbindgen_malloc, _draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__.__wbindgen_realloc);\n var len0 = WASM_VECTOR_LEN;\n getInt32Memory0()[arg0 / 4 + 1] = len0;\n getInt32Memory0()[arg0 / 4 + 0] = ptr0;\n};\n\nfunction __wbg_error_4bb6c2a97407129a(arg0, arg1) {\n try {\n console.error(getStringFromWasm0(arg0, arg1));\n } finally {\n _draught_bg_wasm__WEBPACK_IMPORTED_MODULE_0__.__wbindgen_free(arg0, arg1);\n }\n};\n\nfunction __wbindgen_throw(arg0, arg1) {\n throw new Error(getStringFromWasm0(arg0, arg1));\n};\n\n\n});\n\n//# sourceURL=webpack://draught/../pkg/draught_bg.js?");
/***/ }),
/***/ "../pkg/draught_bg.wasm":
/*!******************************!*\
!*** ../pkg/draught_bg.wasm ***!
\******************************/
/***/ ((module, exports, __webpack_require__) => {
"use strict";
eval("var __webpack_instantiate__ = ([WEBPACK_IMPORTED_MODULE_0]) => {\n\treturn __webpack_require__.v(exports, module.id, \"4d68ea94c77e642d94c7\", {\n\t\t\"./draught_bg.js\": {\n\t\t\t\"__wbindgen_string_new\": WEBPACK_IMPORTED_MODULE_0.__wbindgen_string_new,\n\t\t\t\"__wbindgen_object_drop_ref\": WEBPACK_IMPORTED_MODULE_0.__wbindgen_object_drop_ref,\n\t\t\t\"__wbg_log_9a99fb1af846153b\": WEBPACK_IMPORTED_MODULE_0.__wbg_log_9a99fb1af846153b,\n\t\t\t\"__wbg_new_59cb74e423758ede\": WEBPACK_IMPORTED_MODULE_0.__wbg_new_59cb74e423758ede,\n\t\t\t\"__wbg_stack_558ba5917b466edd\": WEBPACK_IMPORTED_MODULE_0.__wbg_stack_558ba5917b466edd,\n\t\t\t\"__wbg_error_4bb6c2a97407129a\": WEBPACK_IMPORTED_MODULE_0.__wbg_error_4bb6c2a97407129a,\n\t\t\t\"__wbindgen_throw\": WEBPACK_IMPORTED_MODULE_0.__wbindgen_throw\n\t\t}\n\t});\n}\n__webpack_require__.a(module, (__webpack_handle_async_dependencies__) => {\n\t/* harmony import */ var WEBPACK_IMPORTED_MODULE_0 = __webpack_require__(/*! ./draught_bg.js */ \"../pkg/draught_bg.js\");\n\tvar __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([WEBPACK_IMPORTED_MODULE_0]);\n\treturn __webpack_async_dependencies__.then ? __webpack_async_dependencies__.then(__webpack_instantiate__) : __webpack_instantiate__(__webpack_async_dependencies__);\n}, 1);\n\n//# sourceURL=webpack://draught/../pkg/draught_bg.wasm?");
/***/ }),
/***/ "./index.js":
/*!******************!*\
!*** ./index.js ***!
\******************/
/***/ ((module, __webpack_exports__, __webpack_require__) => {
"use strict";
eval("__webpack_require__.a(module, async (__webpack_handle_async_dependencies__) => {\n__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var draught__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! draught */ \"../pkg/draught_bg.js\");\nvar __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([draught__WEBPACK_IMPORTED_MODULE_0__]);\ndraught__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? await __webpack_async_dependencies__ : __webpack_async_dependencies__)[0];\n\n\n\n// let PLAY = true;\n// let PLAY = false;\n(0,draught__WEBPACK_IMPORTED_MODULE_0__.init_game)();\n\nconst canvas = document.getElementById(\"game-canvas\");\nconst ctx = canvas.getContext('2d');\n\n});\n\n//# sourceURL=webpack://draught/./index.js?");
/***/ })
}]);