@wwawing/loader 3.12.9 → 3.12.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TextLoader = void 0;
4
- var infra_1 = require("../../infra");
5
- var TextLoader = (function () {
6
- function TextLoader(wwaData, compressedMapData, startPosition, eventEmitter) {
4
+ const infra_1 = require("../../infra");
5
+ class TextLoader {
6
+ constructor(wwaData, compressedMapData, startPosition, eventEmitter) {
7
7
  this.wwaData = wwaData;
8
8
  this.compressedMapData = compressedMapData;
9
9
  this.startPosition = startPosition;
10
10
  this.eventEmitter = eventEmitter;
11
11
  this.OLDVER_MESSAGE_MAX = 400;
12
12
  }
13
- TextLoader.prototype.load = function () {
14
- var wwaData = this.wwaData;
13
+ load() {
14
+ const wwaData = this.wwaData;
15
15
  this.currentPos = this.startPosition;
16
16
  if (wwaData.version >= 30) {
17
17
  wwaData.worldPassword = this.getMessageFromData();
@@ -20,7 +20,7 @@ var TextLoader = (function () {
20
20
  wwaData.messageNum = this.OLDVER_MESSAGE_MAX;
21
21
  }
22
22
  wwaData.message = new Array(wwaData.messageNum);
23
- for (var i = 0; i < wwaData.message.length; i++) {
23
+ for (let i = 0; i < wwaData.message.length; i++) {
24
24
  wwaData.message[i] = this.getMessageFromData();
25
25
  if (i % 200 === 0) {
26
26
  this.eventEmitter.dispatch("progress", {
@@ -61,7 +61,7 @@ var TextLoader = (function () {
61
61
  wwaData.charCGName = this.getMessageFromData();
62
62
  wwaData.mapCGName = this.getMessageFromData();
63
63
  wwaData.systemMessage = new Array(infra_1.WWAConsts.SYSTEM_MESSAGE_NUM);
64
- for (var i = 0; i < infra_1.WWAConsts.SYSTEM_MESSAGE_NUM; i++) {
64
+ for (let i = 0; i < infra_1.WWAConsts.SYSTEM_MESSAGE_NUM; i++) {
65
65
  if (wwaData.version >= 30) {
66
66
  wwaData.systemMessage[i] = this.getMessageFromData();
67
67
  }
@@ -117,7 +117,7 @@ var TextLoader = (function () {
117
117
  wwaData.gameSpeedIndex = infra_1.WWAConsts.DEFAULT_SPEED_INDEX;
118
118
  wwaData.permitChangeGameSpeed = true;
119
119
  wwaData.userVar = new Array(infra_1.WWAConsts.USER_VAR_NUM);
120
- for (var i = 0; i < infra_1.WWAConsts.USER_VAR_NUM; i++) {
120
+ for (let i = 0; i < infra_1.WWAConsts.USER_VAR_NUM; i++) {
121
121
  wwaData.userVar[i] = 0;
122
122
  }
123
123
  wwaData.playTime = 0;
@@ -128,10 +128,10 @@ var TextLoader = (function () {
128
128
  wwaData.gameOverPolicy = "default";
129
129
  wwaData.bgmDelayDurationMs = 0;
130
130
  return wwaData;
131
- };
132
- TextLoader.prototype.getMessageFromData = function () {
133
- var str = "";
134
- var i = 0;
131
+ }
132
+ getMessageFromData() {
133
+ let str = "";
134
+ let i = 0;
135
135
  for (i = 0; i < 1500; i++) {
136
136
  if (this.compressedMapData[this.currentPos + i * 2] == 0 &&
137
137
  this.compressedMapData[this.currentPos + i * 2 + 1] == 0) {
@@ -142,7 +142,6 @@ var TextLoader = (function () {
142
142
  }
143
143
  this.currentPos += i * 2 + 2;
144
144
  return str;
145
- };
146
- return TextLoader;
147
- }());
145
+ }
146
+ }
148
147
  exports.TextLoader = TextLoader;
@@ -1,73 +1,65 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createDefaultWWAData = exports.LoadStage = exports.PartsType = exports.LoaderProgress = exports.LoaderError = exports.WWAConsts = void 0;
4
- var WWAConsts = exports.WWAConsts = (function () {
5
- function WWAConsts() {
6
- }
7
- WWAConsts.ITEMBOX_SIZE = 12;
8
- WWAConsts.MAP_ATR_MAX = 60;
9
- WWAConsts.OBJ_ATR_MAX = 60;
10
- WWAConsts.OLD_MAP_ATR_MAX = 40;
11
- WWAConsts.OLD_OBJ_ATR_MAX = 40;
12
- WWAConsts.ATR_CROP1 = 1;
13
- WWAConsts.ATR_CROP2 = 2;
14
- WWAConsts.ATR_TYPE = 3;
15
- WWAConsts.ATR_JUMP_X = 16;
16
- WWAConsts.ATR_JUMP_Y = 17;
17
- WWAConsts.MAP_LOCALGATE = 2;
18
- WWAConsts.OBJECT_LOCALGATE = 18;
19
- WWAConsts.SYSTEM_MESSAGE_NUM = 20;
20
- WWAConsts.IMGPOS_DEFAULT_YESNO_X = 3;
21
- WWAConsts.IMGPOS_DEFAULT_YESNO_Y = 1;
22
- WWAConsts.IMGPOS_DEFAULT_PLAYER_X = 2;
23
- WWAConsts.IMGPOS_DEFAULT_PLAYER_Y = 0;
24
- WWAConsts.IMGPOS_DEFAULT_CLICKABLE_ITEM_SIGN_X = 0;
25
- WWAConsts.IMGPOS_DEFAULT_CLICKABLE_ITEM_SIGN_Y = 0;
26
- WWAConsts.IMGPOS_DEFAULT_STATUS_X = 3;
27
- WWAConsts.IMGPOS_DEFAULT_STATUS_Y = 2;
28
- WWAConsts.IMGRELPOS_ENERGY_ICON_X = 0;
29
- WWAConsts.IMGRELPOS_STRENGTH_ICON_X = 1;
30
- WWAConsts.IMGRELPOS_DEFENCE_ICON_X = 2;
31
- WWAConsts.IMGRELPOS_GOLD_ICON_X = 3;
32
- WWAConsts.IMGPOS_DEFAULT_WIDE_CELL_X = 4;
33
- WWAConsts.IMGPOS_DEFAULT_WIDE_CELL_Y = 3;
34
- WWAConsts.IMGPOS_DEFAULT_ITEMBOX_X = 1;
35
- WWAConsts.IMGPOS_DEFAULT_ITEMBOX_Y = 2;
36
- WWAConsts.IMGPOS_DEFAULT_FRAME_X = 0;
37
- WWAConsts.IMGPOS_DEFAULT_FRAME_Y = 1;
38
- WWAConsts.IMGPOS_DEFAULT_BATTLE_EFFECT_X = 3;
39
- WWAConsts.IMGPOS_DEFAULT_BATTLE_EFFECT_Y = 3;
40
- WWAConsts.DEFAULT_DISABLE_SAVE = false;
41
- WWAConsts.DEFAULT_OLDMAP = false;
42
- WWAConsts.DEFAULT_OBJECT_NO_COLLAPSE = false;
43
- WWAConsts.DEFAULT_FRAME_COLOR_R = 0xff;
44
- WWAConsts.DEFAULT_FRAME_COLOR_G = 0xff;
45
- WWAConsts.DEFAULT_FRAME_COLOR_B = 0xff;
46
- WWAConsts.DEFAULT_FRAMEOUT_COLOR_R = 0x60;
47
- WWAConsts.DEFAULT_FRAMEOUT_COLOR_G = 0x60;
48
- WWAConsts.DEFAULT_FRAMEOUT_COLOR_B = 0x60;
49
- WWAConsts.DEFAULT_STR_COLOR_R = 0x0;
50
- WWAConsts.DEFAULT_STR_COLOR_G = 0x0;
51
- WWAConsts.DEFAULT_STR_COLOR_B = 0x0;
52
- WWAConsts.DEFAULT_STATUS_COLOR_R = 0x0;
53
- WWAConsts.DEFAULT_STATUS_COLOR_G = 0x0;
54
- WWAConsts.DEFAULT_STATUS_COLOR_B = 0x0;
55
- WWAConsts.DEFAULT_MOVES = 0;
56
- WWAConsts.DEFAULT_SPEED_INDEX = 3;
57
- WWAConsts.USER_VAR_NUM = 256;
58
- return WWAConsts;
59
- }());
60
- var LoaderError = (function () {
61
- function LoaderError() {
62
- }
63
- return LoaderError;
64
- }());
4
+ class WWAConsts {
5
+ }
6
+ WWAConsts.ITEMBOX_SIZE = 12;
7
+ WWAConsts.MAP_ATR_MAX = 60;
8
+ WWAConsts.OBJ_ATR_MAX = 60;
9
+ WWAConsts.OLD_MAP_ATR_MAX = 40;
10
+ WWAConsts.OLD_OBJ_ATR_MAX = 40;
11
+ WWAConsts.ATR_CROP1 = 1;
12
+ WWAConsts.ATR_CROP2 = 2;
13
+ WWAConsts.ATR_TYPE = 3;
14
+ WWAConsts.ATR_JUMP_X = 16;
15
+ WWAConsts.ATR_JUMP_Y = 17;
16
+ WWAConsts.MAP_LOCALGATE = 2;
17
+ WWAConsts.OBJECT_LOCALGATE = 18;
18
+ WWAConsts.SYSTEM_MESSAGE_NUM = 20;
19
+ WWAConsts.IMGPOS_DEFAULT_YESNO_X = 3;
20
+ WWAConsts.IMGPOS_DEFAULT_YESNO_Y = 1;
21
+ WWAConsts.IMGPOS_DEFAULT_PLAYER_X = 2;
22
+ WWAConsts.IMGPOS_DEFAULT_PLAYER_Y = 0;
23
+ WWAConsts.IMGPOS_DEFAULT_CLICKABLE_ITEM_SIGN_X = 0;
24
+ WWAConsts.IMGPOS_DEFAULT_CLICKABLE_ITEM_SIGN_Y = 0;
25
+ WWAConsts.IMGPOS_DEFAULT_STATUS_X = 3;
26
+ WWAConsts.IMGPOS_DEFAULT_STATUS_Y = 2;
27
+ WWAConsts.IMGRELPOS_ENERGY_ICON_X = 0;
28
+ WWAConsts.IMGRELPOS_STRENGTH_ICON_X = 1;
29
+ WWAConsts.IMGRELPOS_DEFENCE_ICON_X = 2;
30
+ WWAConsts.IMGRELPOS_GOLD_ICON_X = 3;
31
+ WWAConsts.IMGPOS_DEFAULT_WIDE_CELL_X = 4;
32
+ WWAConsts.IMGPOS_DEFAULT_WIDE_CELL_Y = 3;
33
+ WWAConsts.IMGPOS_DEFAULT_ITEMBOX_X = 1;
34
+ WWAConsts.IMGPOS_DEFAULT_ITEMBOX_Y = 2;
35
+ WWAConsts.IMGPOS_DEFAULT_FRAME_X = 0;
36
+ WWAConsts.IMGPOS_DEFAULT_FRAME_Y = 1;
37
+ WWAConsts.IMGPOS_DEFAULT_BATTLE_EFFECT_X = 3;
38
+ WWAConsts.IMGPOS_DEFAULT_BATTLE_EFFECT_Y = 3;
39
+ WWAConsts.DEFAULT_DISABLE_SAVE = false;
40
+ WWAConsts.DEFAULT_OLDMAP = false;
41
+ WWAConsts.DEFAULT_OBJECT_NO_COLLAPSE = false;
42
+ WWAConsts.DEFAULT_FRAME_COLOR_R = 0xff;
43
+ WWAConsts.DEFAULT_FRAME_COLOR_G = 0xff;
44
+ WWAConsts.DEFAULT_FRAME_COLOR_B = 0xff;
45
+ WWAConsts.DEFAULT_FRAMEOUT_COLOR_R = 0x60;
46
+ WWAConsts.DEFAULT_FRAMEOUT_COLOR_G = 0x60;
47
+ WWAConsts.DEFAULT_FRAMEOUT_COLOR_B = 0x60;
48
+ WWAConsts.DEFAULT_STR_COLOR_R = 0x0;
49
+ WWAConsts.DEFAULT_STR_COLOR_G = 0x0;
50
+ WWAConsts.DEFAULT_STR_COLOR_B = 0x0;
51
+ WWAConsts.DEFAULT_STATUS_COLOR_R = 0x0;
52
+ WWAConsts.DEFAULT_STATUS_COLOR_G = 0x0;
53
+ WWAConsts.DEFAULT_STATUS_COLOR_B = 0x0;
54
+ WWAConsts.DEFAULT_MOVES = 0;
55
+ WWAConsts.DEFAULT_SPEED_INDEX = 3;
56
+ WWAConsts.USER_VAR_NUM = 256;
57
+ exports.WWAConsts = WWAConsts;
58
+ class LoaderError {
59
+ }
65
60
  exports.LoaderError = LoaderError;
66
- var LoaderProgress = (function () {
67
- function LoaderProgress() {
68
- }
69
- return LoaderProgress;
70
- }());
61
+ class LoaderProgress {
62
+ }
71
63
  exports.LoaderProgress = LoaderProgress;
72
64
  var PartsType;
73
65
  (function (PartsType) {
package/lib/infra/util.js CHANGED
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.signedByte = exports.new2DArray = void 0;
4
- var new2DArray = function (size1, size2) {
5
- var arr = new Array(size1);
6
- for (var i = 0; i < arr.length; i++) {
4
+ const new2DArray = (size1, size2) => {
5
+ const arr = new Array(size1);
6
+ for (let i = 0; i < arr.length; i++) {
7
7
  arr[i] = new Array(size2);
8
8
  }
9
9
  return arr;
10
10
  };
11
11
  exports.new2DArray = new2DArray;
12
- var signedByte = function (b) {
12
+ const signedByte = (b) => {
13
13
  b = b % 0x100;
14
14
  return b >= 0x80 ? b - 0x100 : b;
15
15
  };
@@ -1,8 +1,8 @@
1
- var MEM_BLOCK = 65000;
2
- var EXT_LAST_PADDING = 3;
1
+ const MEM_BLOCK = 65000;
2
+ const EXT_LAST_PADDING = 3;
3
3
  export function decompressMapData(srcData) {
4
- var destData = new Uint8Array(srcData.length);
5
- var srcCounter, destCounter;
4
+ let destData = new Uint8Array(srcData.length);
5
+ let srcCounter, destCounter;
6
6
  for (srcCounter = 0, destCounter = 0; srcCounter < srcData.length; srcCounter++) {
7
7
  if (srcData[srcCounter] === 0 &&
8
8
  srcData[srcCounter + 1] === 0 &&
@@ -11,8 +11,8 @@ export function decompressMapData(srcData) {
11
11
  }
12
12
  destData[destCounter++] = srcData[srcCounter];
13
13
  if (srcData[srcCounter] === srcData[srcCounter + 1]) {
14
- var maxim = srcData[srcCounter + 2];
15
- for (var i = 0; i < maxim; i++) {
14
+ const maxim = srcData[srcCounter + 2];
15
+ for (let i = 0; i < maxim; i++) {
16
16
  destData[destCounter++] = srcData[srcCounter];
17
17
  }
18
18
  srcCounter += 2;
@@ -4,9 +4,9 @@ function calculateCorrectCheckSum(mapData) {
4
4
  return mapData[BytePosition.CHECK] + mapData[BytePosition.CHECK + 1] * 0x100;
5
5
  }
6
6
  function calculateByteSum(mapData, dataLength) {
7
- var sum = 0;
7
+ let sum = 0;
8
8
  if (mapData[BytePosition.VERSION] >= 29) {
9
- for (var i = 2; i < dataLength; i++) {
9
+ for (let i = 2; i < dataLength; i++) {
10
10
  sum += signedByte(mapData[i]) * (i % 8 + 1);
11
11
  }
12
12
  sum = (sum % 0x10000) & 0xffff;
@@ -14,8 +14,8 @@ function calculateByteSum(mapData, dataLength) {
14
14
  return sum;
15
15
  }
16
16
  export function checkMapDataBroken(mapData, dataLength) {
17
- var correctCheckSum = calculateCorrectCheckSum(mapData);
18
- var sum = calculateByteSum(mapData, dataLength);
17
+ const correctCheckSum = calculateCorrectCheckSum(mapData);
18
+ const sum = calculateByteSum(mapData, dataLength);
19
19
  if (correctCheckSum !== sum) {
20
20
  throw new Error("マップデータが壊れているようです。\n チェックサムの値は" +
21
21
  correctCheckSum +
@@ -2,14 +2,14 @@ import { new2DArray } from "../../infra/util";
2
2
  import { checkMapDataBroken } from "./checksum";
3
3
  import { BytePosition } from "./constants";
4
4
  import { WWAConsts, PartsType, LoadStage, createDefaultWWAData } from "../../infra";
5
- var WWADataExtractor = (function () {
6
- function WWADataExtractor(byteMapData, byteMapLength, eventEmitter) {
5
+ export class WWADataExtractor {
6
+ constructor(byteMapData, byteMapLength, eventEmitter) {
7
7
  this.byteMapData = byteMapData;
8
8
  this.eventEmitter = eventEmitter;
9
9
  checkMapDataBroken(byteMapData, byteMapLength);
10
10
  this.wwaData = createDefaultWWAData();
11
11
  }
12
- WWADataExtractor.prototype.extractAllData = function () {
12
+ extractAllData() {
13
13
  var mapAttrMax, objAttrMax;
14
14
  this.wwaData.version = this.byteMapData[BytePosition.VERSION];
15
15
  this._extractInitialParameters();
@@ -31,8 +31,8 @@ var WWADataExtractor = (function () {
31
31
  }
32
32
  this._replaceAllRandomObjects();
33
33
  return this.wwaData;
34
- };
35
- WWADataExtractor.prototype._convertAttributeV2toV3 = function (partsType) {
34
+ }
35
+ _convertAttributeV2toV3(partsType) {
36
36
  var partsMax;
37
37
  var attributeArray;
38
38
  var localGateIndex;
@@ -81,14 +81,14 @@ var WWADataExtractor = (function () {
81
81
  }
82
82
  }
83
83
  }
84
- };
85
- WWADataExtractor.prototype._get1ByteNumber = function (index) {
84
+ }
85
+ _get1ByteNumber(index) {
86
86
  return this.byteMapData[index];
87
- };
88
- WWADataExtractor.prototype._get2BytesNumber = function (index) {
87
+ }
88
+ _get2BytesNumber(index) {
89
89
  return this.byteMapData[index] + this.byteMapData[index + 1] * 0x100;
90
- };
91
- WWADataExtractor.prototype._extractInitialParameters = function () {
90
+ }
91
+ _extractInitialParameters() {
92
92
  if (this.wwaData.version > 29) {
93
93
  this.wwaData.gameoverX = this._get2BytesNumber(BytePosition.GAMEOVER_X);
94
94
  this.wwaData.gameoverY = this._get2BytesNumber(BytePosition.GAMEOVER_Y);
@@ -119,15 +119,15 @@ var WWADataExtractor = (function () {
119
119
  this.wwaData.mapWidth = 71;
120
120
  else if (this.wwaData.version <= 29)
121
121
  this.wwaData.mapWidth = 101;
122
- };
123
- WWADataExtractor.prototype._extractInitialItemData = function () {
124
- var topIdx = this.wwaData.version > 29 ? BytePosition.ITEMBOX_TOP : BytePosition.OLD_ITEMBOX_TOP;
122
+ }
123
+ _extractInitialItemData() {
124
+ const topIdx = this.wwaData.version > 29 ? BytePosition.ITEMBOX_TOP : BytePosition.OLD_ITEMBOX_TOP;
125
125
  this.wwaData.itemBox = new Array(WWAConsts.ITEMBOX_SIZE);
126
- for (var i = 0; i < WWAConsts.ITEMBOX_SIZE; i++) {
126
+ for (let i = 0; i < WWAConsts.ITEMBOX_SIZE; i++) {
127
127
  this.wwaData.itemBox[i] = this._get1ByteNumber(topIdx + i);
128
128
  }
129
- };
130
- WWADataExtractor.prototype._getFieldDataFromBits = function (partsType, partsMax) {
129
+ }
130
+ _getFieldDataFromBits(partsType, partsMax) {
131
131
  var x, y;
132
132
  var fieldArray;
133
133
  fieldArray = new2DArray(this.wwaData.mapWidth, this.wwaData.mapWidth);
@@ -151,8 +151,8 @@ var WWADataExtractor = (function () {
151
151
  }
152
152
  this.emitProgress(this.wwaData.mapWidth * this.wwaData.mapWidth, this.wwaData.mapWidth * this.wwaData.mapWidth, partsType === PartsType.MAP ? LoadStage.MAP_LOAD : LoadStage.OBJ_LOAD);
153
153
  return fieldArray;
154
- };
155
- WWADataExtractor.prototype._getPartsDataFromBits = function (partsType, partsMax, attrMax) {
154
+ }
155
+ _getPartsDataFromBits(partsType, partsMax, attrMax) {
156
156
  var i, j;
157
157
  var partsData;
158
158
  partsData = new2DArray(partsMax, attrMax);
@@ -172,13 +172,11 @@ var WWADataExtractor = (function () {
172
172
  }
173
173
  this.emitProgress(partsMax * attrMax, partsMax * attrMax, partsType === PartsType.MAP ? LoadStage.MAP_ATTR : LoadStage.OBJ_ATTR);
174
174
  return partsData;
175
- };
176
- WWADataExtractor.prototype._replaceAllRandomObjects = function () {
175
+ }
176
+ _replaceAllRandomObjects() {
177
177
  this.emitProgress(this.wwaData.mapWidth * this.wwaData.mapWidth, this.wwaData.mapWidth * this.wwaData.mapWidth, LoadStage.RAND_PARTS);
178
- };
179
- WWADataExtractor.prototype.emitProgress = function (current, total, stage) {
180
- this.eventEmitter.dispatch("progress", { current: current, total: total, stage: stage });
181
- };
182
- return WWADataExtractor;
183
- }());
184
- export { WWADataExtractor };
178
+ }
179
+ emitProgress(current, total, stage) {
180
+ this.eventEmitter.dispatch("progress", { current, total, stage });
181
+ }
182
+ }
@@ -1,44 +1,8 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
1
  import { WWADataExtractor } from "./extractor";
38
2
  import { decompressMapData } from "./decompressor";
39
3
  import { TextLoader } from "./text-loader";
40
4
  import { BrowserMapDataClient, NodeLocalMapDataClient } from "./map-data-client";
41
- var createMapDataClient = function (fileName) {
5
+ const createMapDataClient = (fileName) => {
42
6
  if (typeof window !== "undefined") {
43
7
  return new BrowserMapDataClient(fileName);
44
8
  }
@@ -46,53 +10,37 @@ var createMapDataClient = function (fileName) {
46
10
  return new NodeLocalMapDataClient(fileName);
47
11
  }
48
12
  };
49
- var WWALoader = (function () {
50
- function WWALoader(fileName, eventEmitter) {
13
+ export class WWALoader {
14
+ constructor(fileName, eventEmitter) {
51
15
  this.fileName = fileName;
52
16
  this.eventEmitter = eventEmitter;
53
17
  }
54
- WWALoader.prototype.requestAndLoadMapData = function () {
55
- return __awaiter(this, void 0, void 0, function () {
56
- var client, responseBuffer, wwaData, error_1, name_1, message;
57
- return __generator(this, function (_a) {
58
- switch (_a.label) {
59
- case 0:
60
- client = createMapDataClient(this.fileName);
61
- _a.label = 1;
62
- case 1:
63
- _a.trys.push([1, 3, , 4]);
64
- return [4, client.request()];
65
- case 2:
66
- responseBuffer = _a.sent();
67
- if (!responseBuffer) {
68
- this.eventEmitter.dispatch("error", { name: "マップデータ取得に失敗しました", message: "mapdata is empty" });
69
- return [2];
70
- }
71
- wwaData = this.loadMapData(responseBuffer);
72
- this.eventEmitter.dispatch("mapData", wwaData);
73
- return [3, 4];
74
- case 3:
75
- error_1 = _a.sent();
76
- name_1 = error_1.name || "";
77
- message = error_1.message || "";
78
- this.eventEmitter.dispatch("error", { name: name_1, message: message });
79
- return [3, 4];
80
- case 4: return [2];
81
- }
82
- });
83
- });
84
- };
85
- WWALoader.prototype.loadMapData = function (data) {
18
+ async requestAndLoadMapData() {
19
+ const client = createMapDataClient(this.fileName);
20
+ try {
21
+ const responseBuffer = await client.request();
22
+ if (!responseBuffer) {
23
+ this.eventEmitter.dispatch("error", { name: "マップデータ取得に失敗しました", message: "mapdata is empty" });
24
+ return;
25
+ }
26
+ const wwaData = this.loadMapData(responseBuffer);
27
+ this.eventEmitter.dispatch("mapData", wwaData);
28
+ }
29
+ catch (error) {
30
+ const name = error.name || "";
31
+ const message = error.message || "";
32
+ this.eventEmitter.dispatch("error", { name, message });
33
+ }
34
+ }
35
+ loadMapData(data) {
86
36
  try {
87
- var compressedByteMapData = new Uint8Array(data);
88
- var _a = decompressMapData(compressedByteMapData), byteMapData = _a.byteMapData, byteMapLength = _a.byteMapLength, compressedEndPosition = _a.compressedEndPosition;
89
- var wwaData = new WWADataExtractor(byteMapData, byteMapLength, this.eventEmitter).extractAllData();
37
+ const compressedByteMapData = new Uint8Array(data);
38
+ const { byteMapData, byteMapLength, compressedEndPosition } = decompressMapData(compressedByteMapData);
39
+ const wwaData = new WWADataExtractor(byteMapData, byteMapLength, this.eventEmitter).extractAllData();
90
40
  return new TextLoader(wwaData, compressedByteMapData, compressedEndPosition, this.eventEmitter).load();
91
41
  }
92
42
  catch (e) {
93
43
  throw e;
94
44
  }
95
- };
96
- return WWALoader;
97
- }());
98
- export { WWALoader };
45
+ }
46
+ }
@@ -1,6 +1,3 @@
1
- var BaseMapDataClient = (function () {
2
- function BaseMapDataClient() {
3
- }
4
- return BaseMapDataClient;
5
- }());
6
- export { BaseMapDataClient };
1
+ export class BaseMapDataClient {
2
+ constructor() { }
3
+ }