@konoui/mjimage 0.0.20 → 0.0.22

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.
@@ -23,15 +23,11 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
23
23
  }
24
24
  return to.concat(ar || Array.prototype.slice.call(from));
25
25
  };
26
- var __importDefault = (this && this.__importDefault) || function (mod) {
27
- return (mod && mod.__esModule) ? mod : { "default": mod };
28
- };
29
26
  Object.defineProperty(exports, "__esModule", { value: true });
30
27
  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
28
  exports.isType = isType;
32
29
  var lexer_1 = require("./lexer");
33
30
  var _1 = require("./");
34
- var assert_1 = __importDefault(require("assert"));
35
31
  var tileSortFunc = function (i, j) {
36
32
  var _a;
37
33
  if (i.t == j.t) {
@@ -165,7 +161,8 @@ var Block = (function () {
165
161
  Block.prototype.minTile = function () {
166
162
  if (this.is(_1.BLOCK.CHI))
167
163
  return this.clone().tiles.sort(exports.tileSortFunc)[0];
168
- (0, assert_1.default)(!this.is(_1.BLOCK.HAND), "mintile() is called with ".concat(this.toString()));
164
+ if (this.is(_1.BLOCK.HAND))
165
+ throw new Error("[debug] mintile() is called with ".concat(this.toString()));
169
166
  return this.tiles[0];
170
167
  };
171
168
  Block.prototype.clone = function () {
@@ -4,13 +4,15 @@ export interface ImageHelperConfig {
4
4
  scale?: number;
5
5
  imageHostPath?: string;
6
6
  imageHostUrl?: string;
7
+ imageExt?: "svg" | "webp";
7
8
  svgSprite?: boolean;
8
9
  }
9
10
  declare class BaseHelper {
10
11
  readonly tileWidth: number;
11
12
  readonly tileHeight: number;
12
- readonly image_host_path: string;
13
- readonly image_host_url: string;
13
+ readonly imageHostPath: string;
14
+ readonly imageHostUrl: string;
15
+ readonly imageExt: string;
14
16
  readonly scale: number;
15
17
  readonly svgSprite: boolean;
16
18
  constructor(props?: ImageHelperConfig);
@@ -33,13 +33,14 @@ var core_2 = require("../core");
33
33
  var BaseHelper = (function () {
34
34
  function BaseHelper(props) {
35
35
  if (props === void 0) { props = {}; }
36
- var _a, _b, _c, _d;
36
+ var _a, _b, _c, _d, _e;
37
37
  this.scale = (_a = props.scale) !== null && _a !== void 0 ? _a : 1;
38
- this.image_host_path = (_b = props.imageHostPath) !== null && _b !== void 0 ? _b : "";
39
- this.image_host_url = (_c = props.imageHostUrl) !== null && _c !== void 0 ? _c : "";
38
+ this.imageHostPath = (_b = props.imageHostPath) !== null && _b !== void 0 ? _b : "";
39
+ this.imageHostUrl = (_c = props.imageHostUrl) !== null && _c !== void 0 ? _c : "";
40
+ this.imageExt = (_d = props.imageExt) !== null && _d !== void 0 ? _d : "svg";
40
41
  this.tileWidth = core_2.TILE_CONTEXT.WIDTH * this.scale;
41
42
  this.tileHeight = core_2.TILE_CONTEXT.HEIGHT * this.scale;
42
- this.svgSprite = (_d = props.svgSprite) !== null && _d !== void 0 ? _d : false;
43
+ this.svgSprite = (_e = props.svgSprite) !== null && _e !== void 0 ? _e : false;
43
44
  }
44
45
  BaseHelper.prototype.getDiffTileHeightWidth = function (t) {
45
46
  var size = t.imageSize(this.scale);
@@ -107,11 +108,11 @@ var BaseHelper = (function () {
107
108
  return "".concat(tile.t).concat(n);
108
109
  };
109
110
  BaseHelper.prototype.buildURL = function (tile) {
110
- var filename = "".concat(BaseHelper.buildID(tile), ".svg");
111
- if (this.image_host_url != "") {
112
- return "".concat(this.image_host_url).concat(filename);
111
+ var filename = "".concat(BaseHelper.buildID(tile), ".").concat(this.imageExt);
112
+ if (this.imageHostUrl != "") {
113
+ return "".concat(this.imageHostUrl).concat(filename);
113
114
  }
114
- return "".concat(this.image_host_path).concat(filename);
115
+ return "".concat(this.imageHostPath).concat(filename);
115
116
  };
116
117
  return BaseHelper;
117
118
  }());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konoui/mjimage",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "description": "Generates Mahjong tiles in SVG format.",
5
5
  "author": "konoui",
6
6
  "license": "MIT",
@@ -53,10 +53,16 @@
53
53
  "module": {}
54
54
  },
55
55
  "alias": {},
56
- "staticFiles": {
57
- "staticPath": "static/svg",
58
- "staticOutPath": "svg"
59
- },
56
+ "staticFiles": [
57
+ {
58
+ "staticPath": "static/svg",
59
+ "staticOutPath": "svg"
60
+ },
61
+ {
62
+ "staticPath": "static/webp",
63
+ "staticOutPath": "webp"
64
+ }
65
+ ],
60
66
  "devDependencies": {
61
67
  "@parcel/reporter-bundle-analyzer": "^2.12.0",
62
68
  "@parcel/transformer-inline-string": "^2.9.3",
@@ -65,6 +71,7 @@
65
71
  "@types/jest": "^29.5.5",
66
72
  "@types/js-yaml": "^4.0.9",
67
73
  "@types/svgdom": "^0.1.0",
74
+ "assert": "^2.1.0",
68
75
  "buffer": "^6.0.3",
69
76
  "parcel": "^2.12.0",
70
77
  "parcel-reporter-static-files-copy": "^1.5.2",