@konoui/mjimage 0.0.16 → 0.0.18

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.
@@ -2,5 +2,6 @@ export * from "./lib/mjimage";
2
2
  export * from "./lib/measure-text/";
3
3
  export * from "./lib/core/";
4
4
  export * from "./lib/table/";
5
+ export * from "./lib/image/";
5
6
  export * from "./lib/calculator/";
6
7
  export * from "./lib/controller/";
package/dist/mjs/index.js CHANGED
@@ -18,5 +18,6 @@ __exportStar(require("./lib/mjimage"), exports);
18
18
  __exportStar(require("./lib/measure-text/"), exports);
19
19
  __exportStar(require("./lib/core/"), exports);
20
20
  __exportStar(require("./lib/table/"), exports);
21
+ __exportStar(require("./lib/image/"), exports);
21
22
  __exportStar(require("./lib/calculator/"), exports);
22
23
  __exportStar(require("./lib/controller/"), exports);
@@ -1,4 +1,4 @@
1
- import { Tile } from "../core/parser";
1
+ import { Tile } from "../core";
2
2
  import { Hand } from "../calculator";
3
3
  export interface Candidate {
4
4
  tile: Tile;
@@ -5,8 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Efficiency = void 0;
7
7
  var assert_1 = __importDefault(require("assert"));
8
- var constants_1 = require("../core/constants");
9
- var parser_1 = require("../core/parser");
8
+ var core_1 = require("../core");
10
9
  var calculator_1 = require("../calculator");
11
10
  var Efficiency = (function () {
12
11
  function Efficiency() {
@@ -42,14 +41,14 @@ var Efficiency = (function () {
42
41
  var r = Number.POSITIVE_INFINITY;
43
42
  var candidates = [];
44
43
  var sc = new calculator_1.ShantenCalculator(hand);
45
- for (var _i = 0, _a = Object.values(constants_1.TYPE); _i < _a.length; _i++) {
44
+ for (var _i = 0, _a = Object.values(core_1.TYPE); _i < _a.length; _i++) {
46
45
  var t = _a[_i];
47
- if (t == constants_1.TYPE.BACK)
46
+ if (t == core_1.TYPE.BACK)
48
47
  continue;
49
48
  for (var n = 1; n < hand.getArrayLen(t); n++) {
50
49
  if (hand.get(t, n) >= 4)
51
50
  continue;
52
- var tile = new parser_1.Tile(t, n);
51
+ var tile = new core_1.Tile(t, n);
53
52
  var tiles = hand.inc([tile]);
54
53
  var s = sc.calc();
55
54
  hand.dec(tiles);
@@ -70,14 +69,14 @@ var Efficiency = (function () {
70
69
  var h = new calculator_1.Hand(input, true);
71
70
  Array(13 - h.hands.length)
72
71
  .fill(undefined)
73
- .map(function () { return h.inc([new parser_1.Tile(constants_1.TYPE.BACK, 0)]); });
72
+ .map(function () { return h.inc([new core_1.Tile(core_1.TYPE.BACK, 0)]); });
74
73
  return Efficiency.candidateTiles(h);
75
74
  };
76
75
  Efficiency.partialShanten = function (input) {
77
76
  var h = new calculator_1.Hand(input, true);
78
77
  Array(13 - h.hands.length)
79
78
  .fill(undefined)
80
- .map(function () { return h.inc([new parser_1.Tile(constants_1.TYPE.BACK, 0)]); });
79
+ .map(function () { return h.inc([new core_1.Tile(core_1.TYPE.BACK, 0)]); });
81
80
  var sc = new calculator_1.ShantenCalculator(h);
82
81
  return sc.calc();
83
82
  };
@@ -28,21 +28,11 @@ export declare class Controller {
28
28
  wall: Wall;
29
29
  playerIDs: string[];
30
30
  actor: import("xstate").Actor<import("xstate").StateMachine<{
31
- currentWind: "1w" | "2w" | "3w" | "4w";
32
- oneShotMap: {
33
- "1w": boolean;
34
- "2w": boolean;
35
- "3w": boolean;
36
- "4w": boolean;
37
- };
38
- missingMap: {
39
- "1w": boolean;
40
- "2w": boolean;
41
- "3w": boolean;
42
- "4w": boolean;
43
- };
31
+ currentWind: Wind;
32
+ oneShotMap: { [key in Wind]: boolean; };
33
+ missingMap: { [key in Wind]: boolean; };
44
34
  controller: Controller;
45
- genEventID: () => string;
35
+ genEventID: ReturnType<typeof import("./state-machine").incrementalIDGenerator>;
46
36
  }, {
47
37
  type: "";
48
38
  } | {
@@ -50,48 +40,48 @@ export declare class Controller {
50
40
  } | {
51
41
  type: "CHI";
52
42
  block: BlockChi;
53
- iam: "1w" | "2w" | "3w" | "4w";
43
+ iam: Wind;
54
44
  } | {
55
45
  type: "PON";
56
46
  block: BlockPon;
57
- iam: "1w" | "2w" | "3w" | "4w";
47
+ iam: Wind;
58
48
  } | {
59
49
  type: "RON";
60
50
  ret: WinResult;
61
- iam: "1w" | "2w" | "3w" | "4w";
51
+ iam: Wind;
62
52
  targetInfo: {
63
- wind: "1w" | "2w" | "3w" | "4w";
53
+ wind: Wind;
64
54
  tile: Tile;
65
55
  };
66
- quadWin?: boolean | undefined;
56
+ quadWin?: boolean;
67
57
  } | {
68
58
  type: "TSUMO";
69
59
  ret: WinResult;
70
- iam: "1w" | "2w" | "3w" | "4w";
60
+ iam: Wind;
71
61
  lastTile: Tile;
72
62
  } | {
73
63
  type: "REACH";
74
64
  tile: Tile;
75
- iam: "1w" | "2w" | "3w" | "4w";
65
+ iam: Wind;
76
66
  } | {
77
67
  type: "DISCARD";
78
68
  tile: Tile;
79
- iam: "1w" | "2w" | "3w" | "4w";
69
+ iam: Wind;
80
70
  } | {
81
71
  type: "AN_KAN";
82
72
  block: BlockAnKan;
83
- iam: "1w" | "2w" | "3w" | "4w";
73
+ iam: Wind;
84
74
  } | {
85
75
  type: "SHO_KAN";
86
76
  block: BlockShoKan;
87
- iam: "1w" | "2w" | "3w" | "4w";
77
+ iam: Wind;
88
78
  } | {
89
79
  type: "DAI_KAN";
90
80
  block: BlockDaiKan;
91
- iam: "1w" | "2w" | "3w" | "4w";
81
+ iam: Wind;
92
82
  } | {
93
83
  type: "DRAWN_GAME_BY_NINE_TILES";
94
- iam: "1w" | "2w" | "3w" | "4w";
84
+ iam: Wind;
95
85
  }, Record<string, import("xstate").AnyActorRef>, import("xstate").ProvidedActor, import("xstate").ParameterizedObject, import("xstate").ParameterizedObject, string, import("xstate").StateValue, string, unknown, import("xstate").NonReducibleUnknown, import("xstate").ResolveTypegenMeta<import("xstate").TypegenDisabled, {
96
86
  type: "";
97
87
  } | {
@@ -99,48 +89,48 @@ export declare class Controller {
99
89
  } | {
100
90
  type: "CHI";
101
91
  block: BlockChi;
102
- iam: "1w" | "2w" | "3w" | "4w";
92
+ iam: Wind;
103
93
  } | {
104
94
  type: "PON";
105
95
  block: BlockPon;
106
- iam: "1w" | "2w" | "3w" | "4w";
96
+ iam: Wind;
107
97
  } | {
108
98
  type: "RON";
109
99
  ret: WinResult;
110
- iam: "1w" | "2w" | "3w" | "4w";
100
+ iam: Wind;
111
101
  targetInfo: {
112
- wind: "1w" | "2w" | "3w" | "4w";
102
+ wind: Wind;
113
103
  tile: Tile;
114
104
  };
115
- quadWin?: boolean | undefined;
105
+ quadWin?: boolean;
116
106
  } | {
117
107
  type: "TSUMO";
118
108
  ret: WinResult;
119
- iam: "1w" | "2w" | "3w" | "4w";
109
+ iam: Wind;
120
110
  lastTile: Tile;
121
111
  } | {
122
112
  type: "REACH";
123
113
  tile: Tile;
124
- iam: "1w" | "2w" | "3w" | "4w";
114
+ iam: Wind;
125
115
  } | {
126
116
  type: "DISCARD";
127
117
  tile: Tile;
128
- iam: "1w" | "2w" | "3w" | "4w";
118
+ iam: Wind;
129
119
  } | {
130
120
  type: "AN_KAN";
131
121
  block: BlockAnKan;
132
- iam: "1w" | "2w" | "3w" | "4w";
122
+ iam: Wind;
133
123
  } | {
134
124
  type: "SHO_KAN";
135
125
  block: BlockShoKan;
136
- iam: "1w" | "2w" | "3w" | "4w";
126
+ iam: Wind;
137
127
  } | {
138
128
  type: "DAI_KAN";
139
129
  block: BlockDaiKan;
140
- iam: "1w" | "2w" | "3w" | "4w";
130
+ iam: Wind;
141
131
  } | {
142
132
  type: "DRAWN_GAME_BY_NINE_TILES";
143
- iam: "1w" | "2w" | "3w" | "4w";
133
+ iam: Wind;
144
134
  }, import("xstate").ProvidedActor, import("xstate").ParameterizedObject, import("xstate").ParameterizedObject, string, string>>>;
145
135
  observer: Observer;
146
136
  handlers: {
@@ -29,7 +29,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
29
  return (mod && mod.__esModule) ? mod : { "default": mod };
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.replaceTileBlock = exports.Observer = exports.BaseActor = exports.Controller = void 0;
32
+ exports.Observer = exports.BaseActor = exports.Controller = void 0;
33
+ exports.replaceTileBlock = replaceTileBlock;
33
34
  var assert_1 = __importDefault(require("assert"));
34
35
  var xstate_1 = require("xstate");
35
36
  var core_1 = require("../core/");
@@ -859,4 +860,3 @@ function replaceTileBlock(obj) {
859
860
  }
860
861
  }
861
862
  }
862
- exports.replaceTileBlock = replaceTileBlock;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createEventEmitter = exports.createEventPipe = exports.prioritizeDrawnEvents = exports.prioritizeDiscardedEvents = void 0;
3
+ exports.createEventEmitter = exports.createEventPipe = void 0;
4
+ exports.prioritizeDiscardedEvents = prioritizeDiscardedEvents;
5
+ exports.prioritizeDrawnEvents = prioritizeDrawnEvents;
4
6
  var eventmit_1 = require("eventmit");
5
7
  function prioritizeDiscardedEvents(events) {
6
8
  var _a;
@@ -13,7 +15,6 @@ function prioritizeDiscardedEvents(events) {
13
15
  type: priorityIndex(order, (_a = selected[0]) === null || _a === void 0 ? void 0 : _a.choices),
14
16
  };
15
17
  }
16
- exports.prioritizeDiscardedEvents = prioritizeDiscardedEvents;
17
18
  function prioritizeDrawnEvents(events) {
18
19
  var _a;
19
20
  var order = [
@@ -32,7 +33,6 @@ function prioritizeDrawnEvents(events) {
32
33
  type: priorityIndex(order, (_a = selected[0]) === null || _a === void 0 ? void 0 : _a.choices),
33
34
  };
34
35
  }
35
- exports.prioritizeDrawnEvents = prioritizeDrawnEvents;
36
36
  function prioritizeEvents(choices, order) {
37
37
  var highestPriorityIndices = [];
38
38
  var highestPriority = Number.POSITIVE_INFINITY;
@@ -1,5 +1,5 @@
1
1
  import { Controller } from "../controller";
2
2
  export declare const createLocalGame: (params?: {
3
- playerIDs?: string[] | undefined;
4
- debug?: boolean | undefined;
5
- } | undefined) => Controller;
3
+ playerIDs?: string[];
4
+ debug?: boolean;
5
+ }) => Controller;
@@ -51,7 +51,7 @@ export declare class PlaceManager {
51
51
  [key: string]: "1w" | "2w" | "3w" | "4w";
52
52
  };
53
53
  }
54
- export declare const nextRound: (r: Round) => "1w1" | "1w2" | "1w3" | "1w4" | "2w1" | "2w2" | "2w3" | "2w4" | "3w1" | "3w2" | "3w3" | "3w4" | "4w1" | "4w2" | "4w3" | "4w4";
54
+ export declare const nextRound: (r: Round) => Round;
55
55
  export declare const prevRound: (r: Round) => "1w1" | "1w2" | "1w3" | "1w4" | "2w1" | "2w2" | "2w3" | "2w4" | "3w1" | "3w2" | "3w3" | "3w4" | "4w1" | "4w2" | "4w3" | "4w4";
56
56
  export declare const nextWind: (w: Wind) => Wind;
57
57
  export declare const prevWind: (w: Wind) => Wind;
@@ -3,7 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Counter = exports.shuffle = exports.createWindMap = exports.prevWind = exports.nextWind = exports.prevRound = exports.nextRound = exports.PlaceManager = exports.ScoreManager = void 0;
6
+ exports.Counter = exports.prevWind = exports.nextWind = exports.prevRound = exports.nextRound = exports.PlaceManager = exports.ScoreManager = void 0;
7
+ exports.createWindMap = createWindMap;
8
+ exports.shuffle = shuffle;
7
9
  var assert_1 = __importDefault(require("assert"));
8
10
  var constants_1 = require("../core/constants");
9
11
  var ScoreManager = (function () {
@@ -137,7 +139,6 @@ function createWindMap(initial, clone) {
137
139
  }
138
140
  return m;
139
141
  }
140
- exports.createWindMap = createWindMap;
141
142
  function shuffle(array) {
142
143
  var _a;
143
144
  for (var i = array.length - 1; i > 0; i--) {
@@ -146,7 +147,6 @@ function shuffle(array) {
146
147
  }
147
148
  return array;
148
149
  }
149
- exports.shuffle = shuffle;
150
150
  var Counter = (function () {
151
151
  function Counter(disable) {
152
152
  var _a;
@@ -5,14 +5,14 @@ export declare class River {
5
5
  constructor();
6
6
  discard(t: Tile, w: Wind): void;
7
7
  get lastTile(): {
8
- w: "1w" | "2w" | "3w" | "4w";
8
+ w: Wind;
9
9
  t: Tile;
10
- callMarker?: boolean | undefined;
10
+ callMarker?: boolean;
11
11
  };
12
12
  discards(w?: Wind): {
13
- w: "1w" | "2w" | "3w" | "4w";
13
+ w: Wind;
14
14
  t: Tile;
15
- callMarker?: boolean | undefined;
15
+ callMarker?: boolean;
16
16
  }[];
17
17
  markCalled(): void;
18
18
  cannotContinue(): boolean;
@@ -33,7 +33,7 @@ export declare const createControllerMachine: (c: Controller) => import("xstate"
33
33
  wind: Wind;
34
34
  tile: Tile;
35
35
  };
36
- quadWin?: boolean | undefined;
36
+ quadWin?: boolean;
37
37
  } | {
38
38
  type: "TSUMO";
39
39
  ret: WinResult;
@@ -82,7 +82,7 @@ export declare const createControllerMachine: (c: Controller) => import("xstate"
82
82
  wind: Wind;
83
83
  tile: Tile;
84
84
  };
85
- quadWin?: boolean | undefined;
85
+ quadWin?: boolean;
86
86
  } | {
87
87
  type: "TSUMO";
88
88
  ret: WinResult;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.incrementalIDGenerator = exports.createControllerMachine = void 0;
3
+ exports.createControllerMachine = void 0;
4
+ exports.incrementalIDGenerator = incrementalIDGenerator;
4
5
  var constants_1 = require("../core/constants");
5
6
  var parser_1 = require("../core/parser");
6
7
  var calculator_1 = require("./../calculator");
@@ -730,4 +731,3 @@ function incrementalIDGenerator(start) {
730
731
  return (idx++).toString();
731
732
  };
732
733
  }
733
- exports.incrementalIDGenerator = incrementalIDGenerator;
@@ -1,3 +1,2 @@
1
1
  export * from "./constants";
2
- export * from "./image";
3
2
  export * from "./parser";
@@ -15,5 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./constants"), exports);
18
- __exportStar(require("./image"), exports);
19
18
  __exportStar(require("./parser"), exports);
@@ -1,4 +1,4 @@
1
- import { BLOCK, OPERATOR, TYPE, INPUT_SEPARATOR } from "./constants";
1
+ import { BLOCK, OPERATOR, TYPE, INPUT_SEPARATOR } from "./";
2
2
  type Separator = typeof INPUT_SEPARATOR;
3
3
  export declare const tileSortFunc: (i: Tile, j: Tile) => number;
4
4
  export type Type = (typeof TYPE)[keyof typeof TYPE];