@konoui/mjimage 0.0.17 → 0.0.19
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.
- package/dist/mjs/index.d.ts +1 -0
- package/dist/mjs/index.js +1 -0
- package/dist/mjs/lib/calculator/calc.d.ts +1 -1
- package/dist/mjs/lib/controller/controller.d.ts +28 -38
- package/dist/mjs/lib/controller/controller.js +2 -2
- package/dist/mjs/lib/controller/events.js +3 -3
- package/dist/mjs/lib/controller/game.d.ts +3 -3
- package/dist/mjs/lib/controller/managers.d.ts +1 -1
- package/dist/mjs/lib/controller/managers.js +3 -3
- package/dist/mjs/lib/controller/river.d.ts +4 -4
- package/dist/mjs/lib/controller/state-machine.d.ts +2 -2
- package/dist/mjs/lib/controller/state-machine.js +2 -2
- package/dist/mjs/lib/core/index.d.ts +0 -1
- package/dist/mjs/lib/core/index.js +0 -1
- package/dist/mjs/lib/core/parser.d.ts +2 -2
- package/dist/mjs/lib/core/parser.js +2 -2
- package/dist/mjs/lib/{core → image}/image.d.ts +1 -1
- package/dist/mjs/lib/{core → image}/image.js +33 -33
- package/dist/mjs/lib/image/index.d.ts +1 -0
- package/dist/mjs/lib/image/index.js +17 -0
- package/dist/mjs/lib/measure-text/index.js +1 -1
- package/dist/mjs/lib/mjimage.d.ts +1 -1
- package/dist/mjs/lib/mjimage.js +2 -1
- package/dist/mjs/lib/table/table-parser.d.ts +51 -146
- package/dist/mjs/lib/table/table-parser.js +31 -41
- package/dist/mjs/lib/table/table.d.ts +1 -1
- package/dist/mjs/lib/table/table.js +1 -1
- package/package.json +6 -5
package/dist/mjs/index.d.ts
CHANGED
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);
|
|
@@ -17,7 +17,7 @@ export declare class Hand {
|
|
|
17
17
|
private init;
|
|
18
18
|
get hands(): Tile[];
|
|
19
19
|
toString(): string;
|
|
20
|
-
get called(): (
|
|
20
|
+
get called(): (BlockChi | BlockPon | BlockAnKan | BlockDaiKan | BlockShoKan)[];
|
|
21
21
|
get reached(): boolean;
|
|
22
22
|
get drawn(): Tile | null;
|
|
23
23
|
get menzen(): boolean;
|
|
@@ -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:
|
|
32
|
-
oneShotMap: {
|
|
33
|
-
|
|
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: ()
|
|
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:
|
|
43
|
+
iam: Wind;
|
|
54
44
|
} | {
|
|
55
45
|
type: "PON";
|
|
56
46
|
block: BlockPon;
|
|
57
|
-
iam:
|
|
47
|
+
iam: Wind;
|
|
58
48
|
} | {
|
|
59
49
|
type: "RON";
|
|
60
50
|
ret: WinResult;
|
|
61
|
-
iam:
|
|
51
|
+
iam: Wind;
|
|
62
52
|
targetInfo: {
|
|
63
|
-
wind:
|
|
53
|
+
wind: Wind;
|
|
64
54
|
tile: Tile;
|
|
65
55
|
};
|
|
66
|
-
quadWin?: boolean
|
|
56
|
+
quadWin?: boolean;
|
|
67
57
|
} | {
|
|
68
58
|
type: "TSUMO";
|
|
69
59
|
ret: WinResult;
|
|
70
|
-
iam:
|
|
60
|
+
iam: Wind;
|
|
71
61
|
lastTile: Tile;
|
|
72
62
|
} | {
|
|
73
63
|
type: "REACH";
|
|
74
64
|
tile: Tile;
|
|
75
|
-
iam:
|
|
65
|
+
iam: Wind;
|
|
76
66
|
} | {
|
|
77
67
|
type: "DISCARD";
|
|
78
68
|
tile: Tile;
|
|
79
|
-
iam:
|
|
69
|
+
iam: Wind;
|
|
80
70
|
} | {
|
|
81
71
|
type: "AN_KAN";
|
|
82
72
|
block: BlockAnKan;
|
|
83
|
-
iam:
|
|
73
|
+
iam: Wind;
|
|
84
74
|
} | {
|
|
85
75
|
type: "SHO_KAN";
|
|
86
76
|
block: BlockShoKan;
|
|
87
|
-
iam:
|
|
77
|
+
iam: Wind;
|
|
88
78
|
} | {
|
|
89
79
|
type: "DAI_KAN";
|
|
90
80
|
block: BlockDaiKan;
|
|
91
|
-
iam:
|
|
81
|
+
iam: Wind;
|
|
92
82
|
} | {
|
|
93
83
|
type: "DRAWN_GAME_BY_NINE_TILES";
|
|
94
|
-
iam:
|
|
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:
|
|
92
|
+
iam: Wind;
|
|
103
93
|
} | {
|
|
104
94
|
type: "PON";
|
|
105
95
|
block: BlockPon;
|
|
106
|
-
iam:
|
|
96
|
+
iam: Wind;
|
|
107
97
|
} | {
|
|
108
98
|
type: "RON";
|
|
109
99
|
ret: WinResult;
|
|
110
|
-
iam:
|
|
100
|
+
iam: Wind;
|
|
111
101
|
targetInfo: {
|
|
112
|
-
wind:
|
|
102
|
+
wind: Wind;
|
|
113
103
|
tile: Tile;
|
|
114
104
|
};
|
|
115
|
-
quadWin?: boolean
|
|
105
|
+
quadWin?: boolean;
|
|
116
106
|
} | {
|
|
117
107
|
type: "TSUMO";
|
|
118
108
|
ret: WinResult;
|
|
119
|
-
iam:
|
|
109
|
+
iam: Wind;
|
|
120
110
|
lastTile: Tile;
|
|
121
111
|
} | {
|
|
122
112
|
type: "REACH";
|
|
123
113
|
tile: Tile;
|
|
124
|
-
iam:
|
|
114
|
+
iam: Wind;
|
|
125
115
|
} | {
|
|
126
116
|
type: "DISCARD";
|
|
127
117
|
tile: Tile;
|
|
128
|
-
iam:
|
|
118
|
+
iam: Wind;
|
|
129
119
|
} | {
|
|
130
120
|
type: "AN_KAN";
|
|
131
121
|
block: BlockAnKan;
|
|
132
|
-
iam:
|
|
122
|
+
iam: Wind;
|
|
133
123
|
} | {
|
|
134
124
|
type: "SHO_KAN";
|
|
135
125
|
block: BlockShoKan;
|
|
136
|
-
iam:
|
|
126
|
+
iam: Wind;
|
|
137
127
|
} | {
|
|
138
128
|
type: "DAI_KAN";
|
|
139
129
|
block: BlockDaiKan;
|
|
140
|
-
iam:
|
|
130
|
+
iam: Wind;
|
|
141
131
|
} | {
|
|
142
132
|
type: "DRAWN_GAME_BY_NINE_TILES";
|
|
143
|
-
iam:
|
|
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.
|
|
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 =
|
|
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;
|
|
@@ -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) =>
|
|
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.
|
|
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:
|
|
8
|
+
w: Wind;
|
|
9
9
|
t: Tile;
|
|
10
|
-
callMarker?: boolean
|
|
10
|
+
callMarker?: boolean;
|
|
11
11
|
};
|
|
12
12
|
discards(w?: Wind): {
|
|
13
|
-
w:
|
|
13
|
+
w: Wind;
|
|
14
14
|
t: Tile;
|
|
15
|
-
callMarker?: boolean
|
|
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
|
|
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
|
|
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.
|
|
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;
|
|
@@ -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);
|
|
@@ -32,7 +32,7 @@ export declare class Block {
|
|
|
32
32
|
is(type: BLOCK): boolean;
|
|
33
33
|
isCalled(): boolean;
|
|
34
34
|
minTile(): Tile;
|
|
35
|
-
clone(): Block |
|
|
35
|
+
clone(): Block | BlockChi | BlockPon | BlockAnKan | BlockDaiKan | BlockShoKan | BlockPair | BlockSet | BlockIsolated;
|
|
36
36
|
imageSize(scale: number): {
|
|
37
37
|
width: number;
|
|
38
38
|
height: number;
|
|
@@ -74,7 +74,7 @@ export declare class Parser {
|
|
|
74
74
|
readonly input: string;
|
|
75
75
|
readonly maxInputLength = 600;
|
|
76
76
|
constructor(input: string);
|
|
77
|
-
parse(): (Block |
|
|
77
|
+
parse(): (Block | BlockChi | BlockPon | BlockAnKan | BlockDaiKan | BlockShoKan)[];
|
|
78
78
|
tiles(): Tile[];
|
|
79
79
|
tileSeparators(): (Tile | Separator)[];
|
|
80
80
|
private makeBlocks;
|
|
@@ -27,7 +27,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.Parser = exports.blockWrapper = exports.BlockIsolated = exports.BlockRun = exports.BlockThree = exports.BlockPair = exports.BlockShoKan = exports.BlockDaiKan = exports.BlockAnKan = exports.BlockPon = exports.BlockChi = exports.Block = exports.Tile = exports.
|
|
30
|
+
exports.Parser = exports.blockWrapper = exports.BlockIsolated = exports.BlockRun = exports.BlockThree = exports.BlockPair = exports.BlockShoKan = exports.BlockDaiKan = exports.BlockAnKan = exports.BlockPon = exports.BlockChi = exports.Block = exports.Tile = exports.tileSortFunc = void 0;
|
|
31
|
+
exports.isType = isType;
|
|
31
32
|
var lexer_1 = require("./lexer");
|
|
32
33
|
var _1 = require("./");
|
|
33
34
|
var assert_1 = __importDefault(require("assert"));
|
|
@@ -59,7 +60,6 @@ function isType(v) {
|
|
|
59
60
|
}
|
|
60
61
|
return [_1.TYPE.BACK, false];
|
|
61
62
|
}
|
|
62
|
-
exports.isType = isType;
|
|
63
63
|
var Tile = (function () {
|
|
64
64
|
function Tile(t, n, ops) {
|
|
65
65
|
if (ops === void 0) { ops = []; }
|
|
@@ -31,9 +31,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.optimizeSVG = exports.drawBlocks = exports.createHand = exports.ImageHelper = void 0;
|
|
33
33
|
var assert_1 = __importDefault(require("assert"));
|
|
34
|
-
var
|
|
34
|
+
var core_1 = require("../core");
|
|
35
35
|
var svg_js_1 = require("@svgdotjs/svg.js");
|
|
36
|
-
var
|
|
36
|
+
var core_2 = require("../core");
|
|
37
37
|
var BaseHelper = (function () {
|
|
38
38
|
function BaseHelper(props) {
|
|
39
39
|
if (props === void 0) { props = {}; }
|
|
@@ -41,8 +41,8 @@ var BaseHelper = (function () {
|
|
|
41
41
|
this.scale = (_a = props.scale) !== null && _a !== void 0 ? _a : 1;
|
|
42
42
|
this.image_host_path = (_b = props.imageHostPath) !== null && _b !== void 0 ? _b : "";
|
|
43
43
|
this.image_host_url = (_c = props.imageHostUrl) !== null && _c !== void 0 ? _c : "";
|
|
44
|
-
this.tileWidth =
|
|
45
|
-
this.tileHeight =
|
|
44
|
+
this.tileWidth = core_2.TILE_CONTEXT.WIDTH * this.scale;
|
|
45
|
+
this.tileHeight = core_2.TILE_CONTEXT.HEIGHT * this.scale;
|
|
46
46
|
this.svgSprite = (_d = props.svgSprite) !== null && _d !== void 0 ? _d : false;
|
|
47
47
|
}
|
|
48
48
|
BaseHelper.prototype.getDiffTileHeightWidth = function (t) {
|
|
@@ -54,7 +54,7 @@ var BaseHelper = (function () {
|
|
|
54
54
|
if (this.svgSprite) {
|
|
55
55
|
img = new svg_js_1.Use().use(BaseHelper.buildID(tile));
|
|
56
56
|
}
|
|
57
|
-
if (tile instanceof
|
|
57
|
+
if (tile instanceof core_1.Tile && tile.has(core_2.OPERATOR.COLOR_GRAYSCALE)) {
|
|
58
58
|
img.css({ filter: "contrast(65%)" });
|
|
59
59
|
}
|
|
60
60
|
return img;
|
|
@@ -77,7 +77,7 @@ var BaseHelper = (function () {
|
|
|
77
77
|
text
|
|
78
78
|
.size(size.baseWidth, size.baseHeight)
|
|
79
79
|
.font({
|
|
80
|
-
family:
|
|
80
|
+
family: core_2.FONT_FAMILY,
|
|
81
81
|
size: fontSize,
|
|
82
82
|
})
|
|
83
83
|
.dx(textX)
|
|
@@ -107,7 +107,7 @@ var BaseHelper = (function () {
|
|
|
107
107
|
if (tile == 100 || tile == 1000) {
|
|
108
108
|
return tile == 100 ? "stick100" : "stick1000";
|
|
109
109
|
}
|
|
110
|
-
var n = tile.t ==
|
|
110
|
+
var n = tile.t == core_2.TYPE.BACK ? 0 : tile.n;
|
|
111
111
|
return "".concat(tile.t).concat(n);
|
|
112
112
|
};
|
|
113
113
|
BaseHelper.prototype.buildURL = function (tile) {
|
|
@@ -123,7 +123,7 @@ var ImageHelper = (function (_super) {
|
|
|
123
123
|
__extends(ImageHelper, _super);
|
|
124
124
|
function ImageHelper() {
|
|
125
125
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
126
|
-
_this.blockMargin =
|
|
126
|
+
_this.blockMargin = core_2.TILE_CONTEXT.WIDTH * core_2.TILE_CONTEXT.BLOCK_MARGIN_SCALE * _this.scale;
|
|
127
127
|
return _this;
|
|
128
128
|
}
|
|
129
129
|
ImageHelper.prototype.createBlockHandDiscard = function (block) {
|
|
@@ -132,10 +132,10 @@ var ImageHelper = (function (_super) {
|
|
|
132
132
|
for (var _i = 0, _a = block.tiles; _i < _a.length; _i++) {
|
|
133
133
|
var t = _a[_i];
|
|
134
134
|
var size = t.imageSize(this.scale);
|
|
135
|
-
var f = t.has(
|
|
135
|
+
var f = t.has(core_2.OPERATOR.HORIZONTAL)
|
|
136
136
|
? this.createRotate90Image.bind(this)
|
|
137
137
|
: this.createImage.bind(this);
|
|
138
|
-
var y = t.has(
|
|
138
|
+
var y = t.has(core_2.OPERATOR.HORIZONTAL) ? this.getDiffTileHeightWidth(t) : 0;
|
|
139
139
|
var img = f(t, pos, y);
|
|
140
140
|
g.add(img);
|
|
141
141
|
pos += size.width;
|
|
@@ -143,13 +143,13 @@ var ImageHelper = (function (_super) {
|
|
|
143
143
|
return g;
|
|
144
144
|
};
|
|
145
145
|
ImageHelper.prototype.createBlockPonChiKan = function (block) {
|
|
146
|
-
var idx = block.tiles.findIndex(function (d) { return d.has(
|
|
146
|
+
var idx = block.tiles.findIndex(function (d) { return d.has(core_2.OPERATOR.HORIZONTAL); });
|
|
147
147
|
var pos = 0;
|
|
148
148
|
var g = new svg_js_1.G();
|
|
149
|
-
if (block.type ==
|
|
149
|
+
if (block.type == core_2.BLOCK.SHO_KAN) {
|
|
150
150
|
var lastIdx = idx;
|
|
151
151
|
for (var i = 0; i < block.tiles.length; i++)
|
|
152
|
-
if (block.tiles[i].has(
|
|
152
|
+
if (block.tiles[i].has(core_2.OPERATOR.HORIZONTAL))
|
|
153
153
|
lastIdx = i;
|
|
154
154
|
for (var i = 0; i < block.tiles.length; i++) {
|
|
155
155
|
var size = block.tiles[i].imageSize(this.scale);
|
|
@@ -172,7 +172,7 @@ var ImageHelper = (function (_super) {
|
|
|
172
172
|
}
|
|
173
173
|
return g;
|
|
174
174
|
}
|
|
175
|
-
if (block.type ==
|
|
175
|
+
if (block.type == core_2.BLOCK.CHI) {
|
|
176
176
|
var img = this.createRotate90Image(block.tiles[idx], pos, this.getDiffTileHeightWidth(block.tiles[idx]));
|
|
177
177
|
pos += block.tiles[idx].imageSize(this.scale).width;
|
|
178
178
|
g.add(img);
|
|
@@ -205,69 +205,69 @@ var getBlockCreators = function (h) {
|
|
|
205
205
|
var _a;
|
|
206
206
|
var scale = h.scale;
|
|
207
207
|
var lookup = (_a = {},
|
|
208
|
-
_a[
|
|
208
|
+
_a[core_2.BLOCK.CHI] = function (block) {
|
|
209
209
|
var size = block.imageSize(scale);
|
|
210
210
|
var g = h.createBlockPonChiKan(block);
|
|
211
211
|
return __assign(__assign({}, size), { e: g });
|
|
212
212
|
},
|
|
213
|
-
_a[
|
|
213
|
+
_a[core_2.BLOCK.PON] = function (block) {
|
|
214
214
|
var size = block.imageSize(scale);
|
|
215
215
|
var g = h.createBlockPonChiKan(block);
|
|
216
216
|
return __assign(__assign({}, size), { e: g });
|
|
217
217
|
},
|
|
218
|
-
_a[
|
|
218
|
+
_a[core_2.BLOCK.DAI_KAN] = function (block) {
|
|
219
219
|
var size = block.imageSize(scale);
|
|
220
220
|
var g = h.createBlockPonChiKan(block);
|
|
221
221
|
return __assign(__assign({}, size), { e: g });
|
|
222
222
|
},
|
|
223
|
-
_a[
|
|
223
|
+
_a[core_2.BLOCK.SHO_KAN] = function (block) {
|
|
224
224
|
var size = block.imageSize(scale);
|
|
225
225
|
var g = h.createBlockPonChiKan(block);
|
|
226
226
|
return __assign(__assign({}, size), { e: g });
|
|
227
227
|
},
|
|
228
|
-
_a[
|
|
228
|
+
_a[core_2.BLOCK.AN_KAN] = function (block) {
|
|
229
229
|
var size = block.imageSize(scale);
|
|
230
230
|
var zp = block.tiles.filter(function (v) {
|
|
231
|
-
return v.t !==
|
|
231
|
+
return v.t !== core_2.TYPE.BACK;
|
|
232
232
|
});
|
|
233
233
|
(0, assert_1.default)(zp != null && zp.length == 2);
|
|
234
|
-
var g = h.createBlockHandDiscard(new
|
|
234
|
+
var g = h.createBlockHandDiscard(new core_1.BlockAnKan([zp[0], zp[1], zp[0], zp[1]]));
|
|
235
235
|
return __assign(__assign({}, size), { e: g });
|
|
236
236
|
},
|
|
237
|
-
_a[
|
|
237
|
+
_a[core_2.BLOCK.DORA] = function (block) {
|
|
238
238
|
var size = block.imageSize(scale);
|
|
239
239
|
var g = new svg_js_1.G();
|
|
240
240
|
var img = h.createTextImage(block.tiles[0], 0, 0, "(ドラ)");
|
|
241
241
|
g.add(img);
|
|
242
242
|
return __assign(__assign({}, size), { e: g });
|
|
243
243
|
},
|
|
244
|
-
_a[
|
|
244
|
+
_a[core_2.BLOCK.TSUMO] = function (block) {
|
|
245
245
|
var size = block.imageSize(scale);
|
|
246
246
|
var g = new svg_js_1.G();
|
|
247
247
|
var img = h.createTextImage(block.tiles[0], 0, 0, "(ツモ)");
|
|
248
248
|
g.add(img);
|
|
249
249
|
return __assign(__assign({}, size), { e: g });
|
|
250
250
|
},
|
|
251
|
-
_a[
|
|
251
|
+
_a[core_2.BLOCK.HAND] = function (block) {
|
|
252
252
|
var size = block.imageSize(scale);
|
|
253
253
|
var g = h.createBlockHandDiscard(block);
|
|
254
254
|
return __assign(__assign({}, size), { e: g });
|
|
255
255
|
},
|
|
256
|
-
_a[
|
|
256
|
+
_a[core_2.BLOCK.DISCARD] = function (block) {
|
|
257
257
|
var size = block.imageSize(scale);
|
|
258
258
|
var g = h.createBlockHandDiscard(block);
|
|
259
259
|
return __assign(__assign({}, size), { e: g });
|
|
260
260
|
},
|
|
261
|
-
_a[
|
|
261
|
+
_a[core_2.BLOCK.UNKNOWN] = function (block) {
|
|
262
262
|
throw new Error("found unknown block");
|
|
263
263
|
},
|
|
264
|
-
_a[
|
|
264
|
+
_a[core_2.BLOCK.PAIR] = function (block) {
|
|
265
265
|
throw new Error("unsupported");
|
|
266
266
|
},
|
|
267
|
-
_a[
|
|
267
|
+
_a[core_2.BLOCK.SET] = function (block) {
|
|
268
268
|
throw new Error("unsupported");
|
|
269
269
|
},
|
|
270
|
-
_a[
|
|
270
|
+
_a[core_2.BLOCK.ISOLATED] = function (block) {
|
|
271
271
|
throw new Error("unsupported");
|
|
272
272
|
},
|
|
273
273
|
_a);
|
|
@@ -321,13 +321,13 @@ var getValidIDs = function () {
|
|
|
321
321
|
var values = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
|
322
322
|
var ids = [];
|
|
323
323
|
var _loop_1 = function (kind) {
|
|
324
|
-
if (kind ==
|
|
325
|
-
ids.push(BaseHelper.buildID(new
|
|
324
|
+
if (kind == core_2.TYPE.BACK) {
|
|
325
|
+
ids.push(BaseHelper.buildID(new core_1.Tile(kind, 0)));
|
|
326
326
|
return "continue";
|
|
327
327
|
}
|
|
328
|
-
ids.push.apply(ids, values.map(function (v) { return BaseHelper.buildID(new
|
|
328
|
+
ids.push.apply(ids, values.map(function (v) { return BaseHelper.buildID(new core_1.Tile(kind, v)); }).flat());
|
|
329
329
|
};
|
|
330
|
-
for (var _i = 0, _a = Object.values(
|
|
330
|
+
for (var _i = 0, _a = Object.values(core_2.TYPE); _i < _a.length; _i++) {
|
|
331
331
|
var kind = _a[_i];
|
|
332
332
|
_loop_1(kind);
|
|
333
333
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./image";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./image"), exports);
|
|
@@ -8,9 +8,9 @@ var assert_1 = __importDefault(require("assert"));
|
|
|
8
8
|
var constants_1 = require("../core/constants");
|
|
9
9
|
var MeasureText = (function () {
|
|
10
10
|
function MeasureText(strText, numText) {
|
|
11
|
-
var _this = this;
|
|
12
11
|
if (strText === void 0) { strText = "東"; }
|
|
13
12
|
if (numText === void 0) { numText = "2"; }
|
|
13
|
+
var _this = this;
|
|
14
14
|
this.ctx = null;
|
|
15
15
|
this.measure = function (str, fontStr) {
|
|
16
16
|
if (_this.ctx == null) {
|
package/dist/mjs/lib/mjimage.js
CHANGED
|
@@ -13,6 +13,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.mjimage = void 0;
|
|
15
15
|
var core_1 = require("./core");
|
|
16
|
+
var image_1 = require("./image");
|
|
16
17
|
var measure_text_1 = require("./measure-text");
|
|
17
18
|
var table_1 = require("./table");
|
|
18
19
|
var svg_js_1 = require("@svgdotjs/svg.js");
|
|
@@ -65,7 +66,7 @@ var mjimage = (function () {
|
|
|
65
66
|
else {
|
|
66
67
|
var scale = calculateScale(handScale, textHeight);
|
|
67
68
|
var blocks = new core_1.Parser(input).parse();
|
|
68
|
-
(0,
|
|
69
|
+
(0, image_1.drawBlocks)(svg, blocks, __assign(__assign({}, props), { svgSprite: svgSprite, scale: scale }), { responsive: responsive });
|
|
69
70
|
}
|
|
70
71
|
svg.addTo(target);
|
|
71
72
|
}
|
|
@@ -1,152 +1,57 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InferOutput } from "valibot";
|
|
2
2
|
import { Tile, Block } from "../core/parser";
|
|
3
3
|
import { WIND_MAP, ROUND_MAP } from "../core/constants";
|
|
4
|
-
declare const tableInputSchema:
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
score: number;
|
|
26
|
-
}, {
|
|
27
|
-
discard?: string | undefined;
|
|
28
|
-
hand?: string | undefined;
|
|
29
|
-
score?: number | undefined;
|
|
30
|
-
}>>>;
|
|
31
|
-
"3w": z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
32
|
-
discard: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
33
|
-
hand: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
34
|
-
score: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
35
|
-
}, "strict", z.ZodTypeAny, {
|
|
36
|
-
discard: string;
|
|
37
|
-
hand: string;
|
|
38
|
-
score: number;
|
|
39
|
-
}, {
|
|
40
|
-
discard?: string | undefined;
|
|
41
|
-
hand?: string | undefined;
|
|
42
|
-
score?: number | undefined;
|
|
43
|
-
}>>>;
|
|
44
|
-
"4w": z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
45
|
-
discard: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
46
|
-
hand: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
47
|
-
score: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
48
|
-
}, "strict", z.ZodTypeAny, {
|
|
49
|
-
discard: string;
|
|
50
|
-
hand: string;
|
|
51
|
-
score: number;
|
|
52
|
-
}, {
|
|
53
|
-
discard?: string | undefined;
|
|
54
|
-
hand?: string | undefined;
|
|
55
|
-
score?: number | undefined;
|
|
56
|
-
}>>>;
|
|
57
|
-
board: z.ZodObject<{
|
|
58
|
-
round: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"1w1" | "1w2" | "1w3" | "1w4" | "2w1" | "2w2" | "2w3" | "2w4" | "3w1" | "3w2" | "3w3" | "3w4" | "4w1" | "4w2" | "4w3" | "4w4">, z.ZodLiteral<"1w1" | "1w2" | "1w3" | "1w4" | "2w1" | "2w2" | "2w3" | "2w4" | "3w1" | "3w2" | "3w3" | "3w4" | "4w1" | "4w2" | "4w3" | "4w4">, ...z.ZodLiteral<"1w1" | "1w2" | "1w3" | "1w4" | "2w1" | "2w2" | "2w3" | "2w4" | "3w1" | "3w2" | "3w3" | "3w4" | "4w1" | "4w2" | "4w3" | "4w4">[]]>>>;
|
|
59
|
-
sticks: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
60
|
-
reach: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
61
|
-
dead: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
62
|
-
}, "strip", z.ZodTypeAny, {
|
|
63
|
-
reach: number;
|
|
64
|
-
dead: number;
|
|
65
|
-
}, {
|
|
66
|
-
reach?: number | undefined;
|
|
67
|
-
dead?: number | undefined;
|
|
68
|
-
}>>>;
|
|
69
|
-
doras: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
70
|
-
front: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"1w" | "2w" | "3w" | "4w">, z.ZodLiteral<"1w" | "2w" | "3w" | "4w">, ...z.ZodLiteral<"1w" | "2w" | "3w" | "4w">[]]>>>;
|
|
71
|
-
}, "strict", z.ZodTypeAny, {
|
|
72
|
-
round: "1w1" | "1w2" | "1w3" | "1w4" | "2w1" | "2w2" | "2w3" | "2w4" | "3w1" | "3w2" | "3w3" | "3w4" | "4w1" | "4w2" | "4w3" | "4w4";
|
|
73
|
-
front: "1w" | "2w" | "3w" | "4w";
|
|
74
|
-
sticks: {
|
|
75
|
-
reach: number;
|
|
76
|
-
dead: number;
|
|
77
|
-
};
|
|
78
|
-
doras: string[];
|
|
79
|
-
}, {
|
|
80
|
-
round?: "1w1" | "1w2" | "1w3" | "1w4" | "2w1" | "2w2" | "2w3" | "2w4" | "3w1" | "3w2" | "3w3" | "3w4" | "4w1" | "4w2" | "4w3" | "4w4" | undefined;
|
|
81
|
-
sticks?: {
|
|
82
|
-
reach?: number | undefined;
|
|
83
|
-
dead?: number | undefined;
|
|
84
|
-
} | undefined;
|
|
85
|
-
doras?: string[] | undefined;
|
|
86
|
-
front?: "1w" | "2w" | "3w" | "4w" | undefined;
|
|
4
|
+
declare const tableInputSchema: import("valibot").StrictObjectSchema<{
|
|
5
|
+
readonly board: import("valibot").StrictObjectSchema<{
|
|
6
|
+
readonly round: import("valibot").OptionalSchema<import("valibot").PicklistSchema<("1w1" | "1w2" | "1w3" | "1w4" | "2w1" | "2w2" | "2w3" | "2w4" | "3w1" | "3w2" | "3w3" | "3w4" | "4w1" | "4w2" | "4w3" | "4w4")[], undefined>, "1w1">;
|
|
7
|
+
readonly sticks: import("valibot").OptionalSchema<import("valibot").StrictObjectSchema<{
|
|
8
|
+
readonly reach: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").NumberSchema<undefined>, import("valibot").MinValueAction<number, 0, "">, import("valibot").MaxValueAction<number, 9, "">]>, 0>;
|
|
9
|
+
readonly dead: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").NumberSchema<undefined>, import("valibot").MinValueAction<number, 0, "">, import("valibot").MaxValueAction<number, 9, "">]>, 0>;
|
|
10
|
+
}, undefined>, {
|
|
11
|
+
readonly reach: 0;
|
|
12
|
+
readonly dead: 0;
|
|
13
|
+
}>;
|
|
14
|
+
readonly doras: import("valibot").OptionalSchema<import("valibot").ArraySchema<import("valibot").StringSchema<undefined>, undefined>, readonly ["3w"]>;
|
|
15
|
+
readonly front: import("valibot").OptionalSchema<import("valibot").PicklistSchema<("1w" | "2w" | "3w" | "4w")[], undefined>, "1w">;
|
|
16
|
+
}, undefined>;
|
|
17
|
+
readonly "1w": import("valibot").OptionalSchema<import("valibot").StrictObjectSchema<{
|
|
18
|
+
readonly discard: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, "">;
|
|
19
|
+
readonly hand: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, "">;
|
|
20
|
+
readonly score: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, 25000>;
|
|
21
|
+
}, undefined>, {
|
|
22
|
+
readonly discard: "";
|
|
23
|
+
readonly hand: "";
|
|
24
|
+
readonly score: 25000;
|
|
87
25
|
}>;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
};
|
|
118
|
-
}, {
|
|
119
|
-
board: {
|
|
120
|
-
round?: "1w1" | "1w2" | "1w3" | "1w4" | "2w1" | "2w2" | "2w3" | "2w4" | "3w1" | "3w2" | "3w3" | "3w4" | "4w1" | "4w2" | "4w3" | "4w4" | undefined;
|
|
121
|
-
sticks?: {
|
|
122
|
-
reach?: number | undefined;
|
|
123
|
-
dead?: number | undefined;
|
|
124
|
-
} | undefined;
|
|
125
|
-
doras?: string[] | undefined;
|
|
126
|
-
front?: "1w" | "2w" | "3w" | "4w" | undefined;
|
|
127
|
-
};
|
|
128
|
-
"1w"?: {
|
|
129
|
-
discard?: string | undefined;
|
|
130
|
-
hand?: string | undefined;
|
|
131
|
-
score?: number | undefined;
|
|
132
|
-
} | undefined;
|
|
133
|
-
"2w"?: {
|
|
134
|
-
discard?: string | undefined;
|
|
135
|
-
hand?: string | undefined;
|
|
136
|
-
score?: number | undefined;
|
|
137
|
-
} | undefined;
|
|
138
|
-
"3w"?: {
|
|
139
|
-
discard?: string | undefined;
|
|
140
|
-
hand?: string | undefined;
|
|
141
|
-
score?: number | undefined;
|
|
142
|
-
} | undefined;
|
|
143
|
-
"4w"?: {
|
|
144
|
-
discard?: string | undefined;
|
|
145
|
-
hand?: string | undefined;
|
|
146
|
-
score?: number | undefined;
|
|
147
|
-
} | undefined;
|
|
148
|
-
}>;
|
|
149
|
-
export type TableInput = z.infer<typeof tableInputSchema>;
|
|
26
|
+
readonly "2w": import("valibot").OptionalSchema<import("valibot").StrictObjectSchema<{
|
|
27
|
+
readonly discard: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, "">;
|
|
28
|
+
readonly hand: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, "">;
|
|
29
|
+
readonly score: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, 25000>;
|
|
30
|
+
}, undefined>, {
|
|
31
|
+
readonly discard: "";
|
|
32
|
+
readonly hand: "";
|
|
33
|
+
readonly score: 25000;
|
|
34
|
+
}>;
|
|
35
|
+
readonly "3w": import("valibot").OptionalSchema<import("valibot").StrictObjectSchema<{
|
|
36
|
+
readonly discard: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, "">;
|
|
37
|
+
readonly hand: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, "">;
|
|
38
|
+
readonly score: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, 25000>;
|
|
39
|
+
}, undefined>, {
|
|
40
|
+
readonly discard: "";
|
|
41
|
+
readonly hand: "";
|
|
42
|
+
readonly score: 25000;
|
|
43
|
+
}>;
|
|
44
|
+
readonly "4w": import("valibot").OptionalSchema<import("valibot").StrictObjectSchema<{
|
|
45
|
+
readonly discard: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, "">;
|
|
46
|
+
readonly hand: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, "">;
|
|
47
|
+
readonly score: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, 25000>;
|
|
48
|
+
}, undefined>, {
|
|
49
|
+
readonly discard: "";
|
|
50
|
+
readonly hand: "";
|
|
51
|
+
readonly score: 25000;
|
|
52
|
+
}>;
|
|
53
|
+
}, undefined>;
|
|
54
|
+
export type TableInput = InferOutput<typeof tableInputSchema>;
|
|
150
55
|
export interface DiscardsInput {
|
|
151
56
|
front: Tile[];
|
|
152
57
|
right: Tile[];
|
|
@@ -1,53 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var _a;
|
|
3
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
15
|
exports.convertInput = exports.parseTableInput = exports.parse = void 0;
|
|
5
16
|
var js_yaml_1 = require("js-yaml");
|
|
6
|
-
var
|
|
17
|
+
var valibot_1 = require("valibot");
|
|
7
18
|
var parser_1 = require("../core/parser");
|
|
8
19
|
var constants_1 = require("../core/constants");
|
|
9
|
-
var windInputSchema =
|
|
10
|
-
.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
.strict()
|
|
16
|
-
.optional()
|
|
17
|
-
.default({ discard: "", hand: "", score: 25000 });
|
|
18
|
-
var windInputsSchema = zod_1.z
|
|
19
|
-
.object((_a = {},
|
|
20
|
+
var windInputSchema = (0, valibot_1.optional)((0, valibot_1.strictObject)({
|
|
21
|
+
discard: (0, valibot_1.optional)((0, valibot_1.string)(), ""),
|
|
22
|
+
hand: (0, valibot_1.optional)((0, valibot_1.string)(), ""),
|
|
23
|
+
score: (0, valibot_1.optional)((0, valibot_1.number)(), 25000),
|
|
24
|
+
}), { discard: "", hand: "", score: 25000 });
|
|
25
|
+
var windInputsSchema = (0, valibot_1.strictObject)((_a = {},
|
|
20
26
|
_a[constants_1.WIND.EAST] = windInputSchema,
|
|
21
27
|
_a[constants_1.WIND.SOUTH] = windInputSchema,
|
|
22
28
|
_a[constants_1.WIND.WEST] = windInputSchema,
|
|
23
29
|
_a[constants_1.WIND.NORTH] = windInputSchema,
|
|
24
|
-
_a))
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
.
|
|
32
|
-
|
|
33
|
-
.optional()
|
|
34
|
-
.default("1w1"),
|
|
35
|
-
sticks: zod_1.z
|
|
36
|
-
.object({
|
|
37
|
-
reach: zod_1.z.number().max(9).gte(0).optional().default(0),
|
|
38
|
-
dead: zod_1.z.number().max(9).gte(0).optional().default(0),
|
|
39
|
-
})
|
|
40
|
-
.optional()
|
|
41
|
-
.default({ reach: 0, dead: 0 }),
|
|
42
|
-
doras: zod_1.z.array(zod_1.z.string()).max(4).optional().default(["3w"]),
|
|
43
|
-
front: unionOfLiterals(Object.keys(constants_1.WIND_MAP))
|
|
44
|
-
.optional()
|
|
45
|
-
.default("1w"),
|
|
46
|
-
})
|
|
47
|
-
.strict();
|
|
48
|
-
var tableInputSchema = windInputsSchema.extend({
|
|
49
|
-
board: boardInputSchema,
|
|
30
|
+
_a));
|
|
31
|
+
var boardInputSchema = (0, valibot_1.strictObject)({
|
|
32
|
+
round: (0, valibot_1.optional)((0, valibot_1.picklist)(Object.keys(constants_1.ROUND_MAP)), "1w1"),
|
|
33
|
+
sticks: (0, valibot_1.optional)((0, valibot_1.strictObject)({
|
|
34
|
+
reach: (0, valibot_1.optional)((0, valibot_1.pipe)((0, valibot_1.number)(), (0, valibot_1.minValue)(0, ""), (0, valibot_1.maxValue)(9, "")), 0),
|
|
35
|
+
dead: (0, valibot_1.optional)((0, valibot_1.pipe)((0, valibot_1.number)(), (0, valibot_1.minValue)(0, ""), (0, valibot_1.maxValue)(9, "")), 0),
|
|
36
|
+
}), { reach: 0, dead: 0 }),
|
|
37
|
+
doras: (0, valibot_1.optional)((0, valibot_1.array)((0, valibot_1.string)()), ["3w"]),
|
|
38
|
+
front: (0, valibot_1.optional)((0, valibot_1.picklist)(Object.keys(constants_1.WIND_MAP)), "1w"),
|
|
50
39
|
});
|
|
40
|
+
var tableInputSchema = (0, valibot_1.strictObject)(__assign(__assign({}, windInputsSchema.entries), { board: boardInputSchema }));
|
|
51
41
|
var parse = function (s) {
|
|
52
42
|
var d = (0, exports.parseTableInput)(s);
|
|
53
43
|
return (0, exports.convertInput)(d);
|
|
@@ -55,11 +45,11 @@ var parse = function (s) {
|
|
|
55
45
|
exports.parse = parse;
|
|
56
46
|
var parseTableInput = function (s) {
|
|
57
47
|
var rawInput = (0, js_yaml_1.load)(s);
|
|
58
|
-
var ret =
|
|
48
|
+
var ret = (0, valibot_1.safeParse)(tableInputSchema, rawInput.table);
|
|
59
49
|
if (!ret.success) {
|
|
60
|
-
throw ret.
|
|
50
|
+
throw ret.issues;
|
|
61
51
|
}
|
|
62
|
-
return ret.
|
|
52
|
+
return ret.output;
|
|
63
53
|
};
|
|
64
54
|
exports.parseTableInput = parseTableInput;
|
|
65
55
|
var convertInput = function (i) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ImageHelper, ImageHelperConfig } from "../
|
|
1
|
+
import { ImageHelper, ImageHelperConfig } from "../image/image";
|
|
2
2
|
import { Svg, G } from "@svgdotjs/svg.js";
|
|
3
3
|
import { FontContext } from "../measure-text/";
|
|
4
4
|
import { ScoreBoardInput, DiscardsInput, HandsInput } from "./";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.drawTable = exports.createTable = void 0;
|
|
4
4
|
var core_1 = require("../core/");
|
|
5
|
-
var image_1 = require("../
|
|
5
|
+
var image_1 = require("../image/image");
|
|
6
6
|
var svg_js_1 = require("@svgdotjs/svg.js");
|
|
7
7
|
var _1 = require("./");
|
|
8
8
|
var splitTiles = function (input) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@konoui/mjimage",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"description": "Generates Mahjong tiles in SVG format.",
|
|
5
5
|
"author": "konoui",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"exports": {
|
|
33
33
|
".": "./dist/mjs/index.js",
|
|
34
34
|
"./core": "./dist/mjs/lib/core/index.js",
|
|
35
|
+
"./image": "./dist/mjs/lib/image/index.js",
|
|
35
36
|
"./table": "./dist/mjs/lib/table/index.js",
|
|
36
37
|
"./calculator": "./dist/mjs/lib/calculator/index.js"
|
|
37
38
|
},
|
|
@@ -65,20 +66,20 @@
|
|
|
65
66
|
"assert": "^2.1.0",
|
|
66
67
|
"buffer": "^6.0.3",
|
|
67
68
|
"jest": "^29.7.0",
|
|
68
|
-
"parcel": "^2.
|
|
69
|
+
"parcel": "^2.12.0",
|
|
69
70
|
"parcel-reporter-static-files-copy": "^1.5.2",
|
|
70
71
|
"process": "^0.11.10",
|
|
71
72
|
"svg-sprite": "^2.0.2",
|
|
72
73
|
"svgdom": "0.1.14",
|
|
73
74
|
"svgo": "^3.0.2",
|
|
74
75
|
"ts-jest": "^29.1.1",
|
|
75
|
-
"typescript": "^5.
|
|
76
|
+
"typescript": "^5.5.4"
|
|
76
77
|
},
|
|
77
78
|
"dependencies": {
|
|
78
79
|
"@svgdotjs/svg.js": "^3.2.4",
|
|
79
80
|
"eventmit": "^2.0.4",
|
|
80
81
|
"js-yaml": "^4.1.0",
|
|
81
|
-
"
|
|
82
|
-
"
|
|
82
|
+
"valibot": "^0.40.0",
|
|
83
|
+
"xstate": "^5.7.0"
|
|
83
84
|
}
|
|
84
85
|
}
|