@dotmon/core 0.1.0

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.
@@ -0,0 +1,42 @@
1
+ import { F as Frame, V as View, G as GenerateOptions, b as Locale } from '../types-kWKrAd-B.js';
2
+
3
+ declare function svgToCanvas(svg: string, size: number, background?: string): Promise<HTMLCanvasElement>;
4
+ interface RasterOptions {
5
+ size?: number;
6
+ background?: string;
7
+ }
8
+ declare function toPng(svg: string, opts?: RasterOptions): Promise<Blob>;
9
+
10
+ declare function lzwEncode(minCodeSize: number, indices: Uint8Array): number[];
11
+ declare function encodeGif(w: number, h: number, palette: number[][], transparentIndex: number, frames: Uint8Array[], delayCs: number): Uint8Array;
12
+ interface GifOptions {
13
+ size?: number;
14
+ background?: string;
15
+ delayMs?: number;
16
+ }
17
+ declare function toGif(frames: [string, string], opts?: GifOptions): Promise<Blob>;
18
+
19
+ declare function crc32(data: Uint8Array): number;
20
+ interface ZipEntry {
21
+ name: string;
22
+ data: Uint8Array;
23
+ }
24
+ declare function buildZip(files: ZipEntry[]): Blob;
25
+
26
+ declare const SHEET_POSES: [string, Frame][];
27
+ declare const SHEET_ROWS: View[];
28
+ interface SpriteSheetResult {
29
+ png: Blob;
30
+ json: Record<string, unknown>;
31
+ }
32
+ declare function toSpriteSheet(seed: string, options?: GenerateOptions): Promise<SpriteSheetResult>;
33
+
34
+ interface AssetZipOptions extends GenerateOptions {
35
+ background?: string;
36
+ locale?: Locale;
37
+ }
38
+ declare function toAssetZip(seed: string, options?: AssetZipOptions): Promise<Blob>;
39
+
40
+ declare function assetReadme(seed: string, locale?: Locale): string;
41
+
42
+ export { type AssetZipOptions, type GifOptions, type RasterOptions, SHEET_POSES, SHEET_ROWS, type SpriteSheetResult, type ZipEntry, assetReadme, buildZip, crc32, encodeGif, lzwEncode, svgToCanvas, toAssetZip, toGif, toPng, toSpriteSheet };
@@ -0,0 +1,348 @@
1
+ import { resolveOptions, SIZE, generateSvg, safeFileName } from '../chunk-QBHMZDDB.js';
2
+
3
+ // src/render/raster.ts
4
+ function svgToCanvas(svg, size, background = "transparent") {
5
+ return new Promise((resolve, reject) => {
6
+ const sized = svg.replace("<svg ", `<svg width="${size}" height="${size}" `);
7
+ const img = new Image();
8
+ img.onload = () => {
9
+ const c = document.createElement("canvas");
10
+ c.width = size;
11
+ c.height = size;
12
+ const ctx = c.getContext("2d");
13
+ ctx.imageSmoothingEnabled = false;
14
+ if (background !== "transparent") {
15
+ ctx.fillStyle = background;
16
+ ctx.fillRect(0, 0, size, size);
17
+ }
18
+ ctx.drawImage(img, 0, 0, size, size);
19
+ resolve(c);
20
+ };
21
+ img.onerror = reject;
22
+ img.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(sized);
23
+ });
24
+ }
25
+ async function toPng(svg, opts = {}) {
26
+ const { size = 512, background = "transparent" } = opts;
27
+ const c = await svgToCanvas(svg, size, background);
28
+ return new Promise((res) => c.toBlob((b) => res(b), "image/png"));
29
+ }
30
+ async function pngBytes(svg, size, background) {
31
+ const blob = await toPng(svg, { size, background });
32
+ return new Uint8Array(await blob.arrayBuffer());
33
+ }
34
+
35
+ // src/render/gif.ts
36
+ function lzwEncode(minCodeSize, indices) {
37
+ const CLEAR = 1 << minCodeSize;
38
+ const EOI = CLEAR + 1;
39
+ let dict;
40
+ let nextCode = 0;
41
+ let codeSize = 0;
42
+ const out = [];
43
+ let bitBuf = 0;
44
+ let bitLen = 0;
45
+ const emit = (code) => {
46
+ bitBuf |= code << bitLen;
47
+ bitLen += codeSize;
48
+ while (bitLen >= 8) {
49
+ out.push(bitBuf & 255);
50
+ bitBuf >>= 8;
51
+ bitLen -= 8;
52
+ }
53
+ };
54
+ const init = () => {
55
+ dict = /* @__PURE__ */ new Map();
56
+ for (let i = 0; i < CLEAR; i++) dict.set(String(i), i);
57
+ nextCode = EOI + 1;
58
+ codeSize = minCodeSize + 1;
59
+ };
60
+ init();
61
+ emit(CLEAR);
62
+ let prefix = String(indices[0]);
63
+ for (let i = 1; i < indices.length; i++) {
64
+ const k = indices[i];
65
+ const key = prefix + "," + k;
66
+ if (dict.has(key)) {
67
+ prefix = key;
68
+ continue;
69
+ }
70
+ emit(dict.get(prefix));
71
+ if (nextCode < 4096) {
72
+ dict.set(key, nextCode);
73
+ if (nextCode === 1 << codeSize && codeSize < 12) codeSize++;
74
+ nextCode++;
75
+ } else {
76
+ emit(CLEAR);
77
+ init();
78
+ }
79
+ prefix = String(k);
80
+ }
81
+ emit(dict.get(prefix));
82
+ emit(EOI);
83
+ if (bitLen > 0) out.push(bitBuf & 255);
84
+ return out;
85
+ }
86
+ function encodeGif(w, h, palette, transparentIndex, frames, delayCs) {
87
+ const bytes = [];
88
+ const put = (b) => bytes.push(b & 255);
89
+ const put16 = (v) => {
90
+ put(v);
91
+ put(v >> 8);
92
+ };
93
+ const putStr = (s) => {
94
+ for (let i = 0; i < s.length; i++) put(s.charCodeAt(i));
95
+ };
96
+ let bits = 1;
97
+ while (1 << bits < palette.length) bits++;
98
+ putStr("GIF89a");
99
+ put16(w);
100
+ put16(h);
101
+ put(128 | 112 | bits - 1);
102
+ put(0);
103
+ put(0);
104
+ for (let i = 0; i < 1 << bits; i++) {
105
+ const c = palette[i] || [0, 0, 0];
106
+ put(c[0]);
107
+ put(c[1]);
108
+ put(c[2]);
109
+ }
110
+ put(33);
111
+ put(255);
112
+ put(11);
113
+ putStr("NETSCAPE2.0");
114
+ put(3);
115
+ put(1);
116
+ put16(0);
117
+ put(0);
118
+ const minCode = Math.max(2, bits);
119
+ for (const indices of frames) {
120
+ put(33);
121
+ put(249);
122
+ put(4);
123
+ put(2 << 2 | (transparentIndex >= 0 ? 1 : 0));
124
+ put16(delayCs);
125
+ put(transparentIndex >= 0 ? transparentIndex : 0);
126
+ put(0);
127
+ put(44);
128
+ put16(0);
129
+ put16(0);
130
+ put16(w);
131
+ put16(h);
132
+ put(0);
133
+ put(minCode);
134
+ const data = lzwEncode(minCode, indices);
135
+ for (let i = 0; i < data.length; i += 255) {
136
+ const n = Math.min(255, data.length - i);
137
+ put(n);
138
+ for (let j = 0; j < n; j++) put(data[i + j]);
139
+ }
140
+ put(0);
141
+ }
142
+ put(59);
143
+ return new Uint8Array(bytes);
144
+ }
145
+ async function toGif(frames, opts = {}) {
146
+ const { size = 256, background = "transparent", delayMs = 400 } = opts;
147
+ const bytes = await gifBytes(frames[0], frames[1], size, background, Math.round(delayMs / 10));
148
+ return new Blob([bytes], { type: "image/gif" });
149
+ }
150
+ async function gifBytes(svgA, svgB, px, bg, delayCs = 40) {
151
+ const canvases = [await svgToCanvas(svgA, px, bg), await svgToCanvas(svgB, px, bg)];
152
+ const palette = [];
153
+ const cmap = /* @__PURE__ */ new Map();
154
+ let transparentIndex = -1;
155
+ if (bg === "transparent") {
156
+ transparentIndex = 0;
157
+ palette.push([0, 0, 0]);
158
+ }
159
+ const frames = canvases.map((c) => {
160
+ const d = c.getContext("2d").getImageData(0, 0, px, px).data;
161
+ const out = new Uint8Array(px * px);
162
+ for (let i = 0; i < px * px; i++) {
163
+ const r = d[i * 4], gr = d[i * 4 + 1], bl = d[i * 4 + 2], a = d[i * 4 + 3];
164
+ if (a < 128 && transparentIndex >= 0) {
165
+ out[i] = transparentIndex;
166
+ continue;
167
+ }
168
+ const key = r << 16 | gr << 8 | bl;
169
+ let idx = cmap.get(key);
170
+ if (idx === void 0) {
171
+ idx = palette.length;
172
+ palette.push([r, gr, bl]);
173
+ cmap.set(key, idx);
174
+ }
175
+ out[i] = idx;
176
+ }
177
+ return out;
178
+ });
179
+ return encodeGif(px, px, palette, transparentIndex, frames, delayCs);
180
+ }
181
+
182
+ // src/render/zip.ts
183
+ var CRC_TABLE = (() => {
184
+ const t = new Uint32Array(256);
185
+ for (let n = 0; n < 256; n++) {
186
+ let c = n;
187
+ for (let k = 0; k < 8; k++) c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
188
+ t[n] = c;
189
+ }
190
+ return t;
191
+ })();
192
+ function crc32(data) {
193
+ let c = 4294967295;
194
+ for (let i = 0; i < data.length; i++) c = CRC_TABLE[(c ^ data[i]) & 255] ^ c >>> 8;
195
+ return (c ^ 4294967295) >>> 0;
196
+ }
197
+ function buildZip(files) {
198
+ const enc = new TextEncoder();
199
+ const u16 = (v) => [v & 255, v >> 8 & 255];
200
+ const u32 = (v) => [v & 255, v >>> 8 & 255, v >>> 16 & 255, v >>> 24 & 255];
201
+ const now = /* @__PURE__ */ new Date();
202
+ const dosTime = (now.getHours() << 11 | now.getMinutes() << 5 | now.getSeconds() >> 1) & 65535;
203
+ const dosDate = (now.getFullYear() - 1980 << 9 | now.getMonth() + 1 << 5 | now.getDate()) & 65535;
204
+ const chunks = [];
205
+ const central = [];
206
+ let offset = 0;
207
+ for (const f of files) {
208
+ const name = enc.encode(f.name);
209
+ const crc = crc32(f.data);
210
+ const head = new Uint8Array([80, 75, 3, 4, ...u16(20), ...u16(2048), ...u16(0), ...u16(dosTime), ...u16(dosDate), ...u32(crc), ...u32(f.data.length), ...u32(f.data.length), ...u16(name.length), ...u16(0)]);
211
+ chunks.push(head, name, f.data);
212
+ central.push({ name, crc, size: f.data.length, offset });
213
+ offset += head.length + name.length + f.data.length;
214
+ }
215
+ const cd = [];
216
+ let cdSize = 0;
217
+ for (const c of central) {
218
+ const rec = new Uint8Array([80, 75, 1, 2, ...u16(20), ...u16(20), ...u16(2048), ...u16(0), ...u16(dosTime), ...u16(dosDate), ...u32(c.crc), ...u32(c.size), ...u32(c.size), ...u16(c.name.length), ...u16(0), ...u16(0), ...u16(0), ...u16(0), ...u32(0), ...u32(c.offset)]);
219
+ cd.push(rec, c.name);
220
+ cdSize += rec.length + c.name.length;
221
+ }
222
+ const eocd = new Uint8Array([80, 75, 5, 6, ...u16(0), ...u16(0), ...u16(files.length), ...u16(files.length), ...u32(cdSize), ...u32(offset), ...u16(0)]);
223
+ const parts = [...chunks, ...cd, eocd].map((p) => p instanceof Uint8Array ? p : new Uint8Array(p));
224
+ return new Blob(parts, { type: "application/zip" });
225
+ }
226
+
227
+ // src/render/sheet.ts
228
+ var SHEET_POSES = [
229
+ ["idle", 0],
230
+ ["walk1", 1],
231
+ ["walk2", 2]
232
+ ];
233
+ var SHEET_ROWS = ["front", "left", "right", "back"];
234
+ async function toSpriteSheet(seed, options = {}) {
235
+ const o = resolveOptions(options);
236
+ const cell = SIZE;
237
+ const sheet = document.createElement("canvas");
238
+ sheet.width = cell * SHEET_POSES.length;
239
+ sheet.height = cell * SHEET_ROWS.length;
240
+ const ctx = sheet.getContext("2d");
241
+ ctx.imageSmoothingEnabled = false;
242
+ const frames = {};
243
+ const animations = {};
244
+ for (let r = 0; r < SHEET_ROWS.length; r++) {
245
+ const view = SHEET_ROWS[r];
246
+ for (let c = 0; c < SHEET_POSES.length; c++) {
247
+ const [pose, frame] = SHEET_POSES[c];
248
+ const cellCanvas = await svgToCanvas(generateSvg(seed, { ...o, view, frame }).svg, cell, "transparent");
249
+ ctx.drawImage(cellCanvas, c * cell, r * cell);
250
+ frames[`${view}_${pose}`] = {
251
+ frame: { x: c * cell, y: r * cell, w: cell, h: cell },
252
+ rotated: false,
253
+ trimmed: false,
254
+ spriteSourceSize: { x: 0, y: 0, w: cell, h: cell },
255
+ sourceSize: { w: cell, h: cell }
256
+ };
257
+ }
258
+ animations[`idle_${view}`] = [`${view}_idle`];
259
+ animations[`walk_${view}`] = [`${view}_walk1`, `${view}_walk2`];
260
+ }
261
+ const json = {
262
+ frames,
263
+ animations,
264
+ meta: {
265
+ app: "dotmon",
266
+ seed,
267
+ image: "sheet.png",
268
+ format: "RGBA8888",
269
+ size: { w: sheet.width, h: sheet.height },
270
+ scale: "1",
271
+ grid: { cols: SHEET_POSES.length, rows: SHEET_ROWS.length, cellW: cell, cellH: cell },
272
+ rowOrder: SHEET_ROWS,
273
+ colOrder: SHEET_POSES.map((p) => p[0]),
274
+ note: "Pixel art: scale with nearest neighbor. Walk = alternate walk1/walk2 (~400ms). Sheet is always transparent."
275
+ }
276
+ };
277
+ const png = await new Promise((res) => sheet.toBlob((b) => res(b), "image/png"));
278
+ return { png, json };
279
+ }
280
+
281
+ // src/render/readme.ts
282
+ function assetReadme(seed, locale = "en") {
283
+ if (locale === "ja") {
284
+ return `${seed} \u306E\u30E2\u30F3\u30B9\u30BF\u30FC\u30BB\u30C3\u30C8
285
+ =========================
286
+ \u3053\u306EZIP\u306B\u306F\u3001\u30B2\u30FC\u30E0\u3084\u30A2\u30A4\u30B3\u30F3\u306B\u305D\u306E\u307E\u307E\u4F7F\u3048\u308B\u753B\u50CF\u304C\u5165\u3063\u3066\u3044\u307E\u3059\u3002
287
+
288
+ \u25A0 \u500B\u5225\u753B\u50CF\uFF08512px / \u4FDD\u5B58\u6642\u306E\u80CC\u666F\u8A2D\u5B9A\u3064\u304D\uFF09
289
+ front_idle.png / front_walk1.png / front_walk2.png \u2026 \u307E\u3048\u5411\u304D\u306E \u7ACB\u3061\u30FB\u6B69\u304D1\u30FB\u6B69\u304D2
290
+ \u540C\u3058\u7D44\u307F\u5408\u308F\u305B\u304C back\uFF08\u3046\u3057\u308D\uFF09/ left\uFF08\u3072\u3060\u308A\uFF09/ right\uFF08\u307F\u304E\uFF09\u306B\u3082\u3042\u308A\u307E\u3059\uFF08\u8A0812\u679A\uFF09
291
+
292
+ \u25A0 \u52D5\u304FGIF\uFF08256px\u30FB2\u30B3\u30DE\u30FB\u7121\u9650\u30EB\u30FC\u30D7\uFF09
293
+ front.gif / back.gif / left.gif / right.gif
294
+
295
+ \u25A0 \u30B2\u30FC\u30E0\u7528\u30B9\u30D7\u30E9\u30A4\u30C8\u30B7\u30FC\u30C8
296
+ sheet.png \u2026 16px\u30C9\u30C3\u30C8\u539F\u5BF8\u30FB3\u5217\xD74\u884C\uFF08\u5217: \u7ACB\u3061/\u6B69\u304D1/\u6B69\u304D2\u3001\u884C: \u307E\u3048/\u3072\u3060\u308A/\u307F\u304E/\u3046\u3057\u308D\uFF09
297
+ sheet.json \u2026 \u5404\u30B3\u30DE\u306E\u5EA7\u6A19\u3068\u30A2\u30CB\u30E1\u5B9A\u7FA9\uFF08TexturePacker\u4E92\u63DB\u3002Phaser / PixiJS \u3067\u305D\u306E\u307E\u307E\u8AAD\u3081\u307E\u3059\uFF09
298
+
299
+ \u203B\u30C9\u30C3\u30C8\u7D75\u306A\u306E\u3067\u3001\u62E1\u5927\u3059\u308B\u3068\u304D\u306F\u300C\u307C\u304B\u3057\u306A\u3057\uFF08nearest neighbor\uFF09\u300D\u3092\u9078\u3076\u3068\u304D\u308C\u3044\u306B\u8868\u793A\u3055\u308C\u307E\u3059\u3002
300
+ `;
301
+ }
302
+ return `Monster asset set for "${seed}"
303
+ =========================
304
+ This ZIP contains images ready to use in games or as icons.
305
+
306
+ - Individual PNGs (512px, with your background setting)
307
+ front_idle.png / front_walk1.png / front_walk2.png = front-facing idle / walk 1 / walk 2
308
+ The same set exists for back / left / right (12 images total)
309
+
310
+ - Animated GIFs (256px, 2 frames, infinite loop)
311
+ front.gif / back.gif / left.gif / right.gif
312
+
313
+ - Game sprite sheet
314
+ sheet.png = native 16px pixels, 3 cols x 4 rows (cols: idle/walk1/walk2, rows: front/left/right/back)
315
+ sheet.json = frame coordinates + animation definitions (TexturePacker compatible; loads directly in Phaser / PixiJS)
316
+
317
+ Tip: this is pixel art \u2014 scale it up with "nearest neighbor" (no smoothing) for crisp results.
318
+ `;
319
+ }
320
+
321
+ // src/render/assetZip.ts
322
+ var VIEWS = ["front", "back", "left", "right"];
323
+ async function toAssetZip(seed, options = {}) {
324
+ const { background = "transparent", locale = "en", ...genOptions } = options;
325
+ const o = resolveOptions(genOptions);
326
+ const dir = safeFileName(seed);
327
+ const files = [];
328
+ files.push({ name: `${dir}/README.txt`, data: new TextEncoder().encode(assetReadme(seed, locale)) });
329
+ for (const view of VIEWS) {
330
+ for (const [pose, frame] of SHEET_POSES) {
331
+ files.push({
332
+ name: `${dir}/${view}_${pose}.png`,
333
+ data: await pngBytes(generateSvg(seed, { ...o, view, frame }).svg, 512, background)
334
+ });
335
+ }
336
+ const gif = await toGif(
337
+ [generateSvg(seed, { ...o, view, frame: 1 }).svg, generateSvg(seed, { ...o, view, frame: 2 }).svg],
338
+ { size: 256, background }
339
+ );
340
+ files.push({ name: `${dir}/${view}.gif`, data: new Uint8Array(await gif.arrayBuffer()) });
341
+ }
342
+ const sheet = await toSpriteSheet(seed, o);
343
+ files.push({ name: `${dir}/sheet.png`, data: new Uint8Array(await sheet.png.arrayBuffer()) });
344
+ files.push({ name: `${dir}/sheet.json`, data: new TextEncoder().encode(JSON.stringify(sheet.json, null, 2)) });
345
+ return buildZip(files);
346
+ }
347
+
348
+ export { SHEET_POSES, SHEET_ROWS, assetReadme, buildZip, crc32, encodeGif, lzwEncode, svgToCanvas, toAssetZip, toGif, toPng, toSpriteSheet };
@@ -0,0 +1,17 @@
1
+ import { G as GenerateOptions } from './types-kWKrAd-B.js';
2
+
3
+ declare const NATURE_IDS: readonly ["cheerful", "easygoing", "timid", "stubborn", "headstrong", "gentle", "playful", "calm", "shy", "hungry", "sleepyhead", "whimsical"];
4
+ type NatureId = (typeof NATURE_IDS)[number];
5
+ interface Stats {
6
+ lv: number;
7
+ nature: NatureId;
8
+ hp: number;
9
+ mp: number;
10
+ atk: number;
11
+ def: number;
12
+ spd: number;
13
+ luck: number;
14
+ }
15
+ declare function getStats(seed: string, options?: GenerateOptions): Stats;
16
+
17
+ export { NATURE_IDS as N, type Stats as S, type NatureId as a, getStats as g };
@@ -0,0 +1,17 @@
1
+ import { G as GenerateOptions } from './types-kWKrAd-B.cjs';
2
+
3
+ declare const NATURE_IDS: readonly ["cheerful", "easygoing", "timid", "stubborn", "headstrong", "gentle", "playful", "calm", "shy", "hungry", "sleepyhead", "whimsical"];
4
+ type NatureId = (typeof NATURE_IDS)[number];
5
+ interface Stats {
6
+ lv: number;
7
+ nature: NatureId;
8
+ hp: number;
9
+ mp: number;
10
+ atk: number;
11
+ def: number;
12
+ spd: number;
13
+ luck: number;
14
+ }
15
+ declare function getStats(seed: string, options?: GenerateOptions): Stats;
16
+
17
+ export { NATURE_IDS as N, type Stats as S, type NatureId as a, getStats as g };
@@ -0,0 +1,12 @@
1
+ import { a as NatureId } from './stats-Cs0yRJTk.cjs';
2
+ import { c as Legs, P as Preset } from './types-kWKrAd-B.cjs';
3
+
4
+ interface LocaleDict {
5
+ natures: Record<NatureId, string>;
6
+ stats: Record<"lv" | "hp" | "mp" | "atk" | "def" | "spd" | "luck", string>;
7
+ legs: Record<Legs, string>;
8
+ presets: Record<Preset, string>;
9
+ presetDescriptions: Record<Preset, string>;
10
+ }
11
+
12
+ export type { LocaleDict as L };
@@ -0,0 +1,12 @@
1
+ import { a as NatureId } from './stats-BMnyxbee.js';
2
+ import { c as Legs, P as Preset } from './types-kWKrAd-B.js';
3
+
4
+ interface LocaleDict {
5
+ natures: Record<NatureId, string>;
6
+ stats: Record<"lv" | "hp" | "mp" | "atk" | "def" | "spd" | "luck", string>;
7
+ legs: Record<Legs, string>;
8
+ presets: Record<Preset, string>;
9
+ presetDescriptions: Record<Preset, string>;
10
+ }
11
+
12
+ export type { LocaleDict as L };
@@ -0,0 +1,27 @@
1
+ type Preset = "mochi" | "retro" | "chaos";
2
+ type Legs = "auto" | "none" | "two" | "many";
3
+ type LegStyle = "none" | "two" | "many";
4
+ type View = "front" | "back" | "left" | "right";
5
+ type Frame = 0 | 1 | 2;
6
+ type Locale = "en" | "ja";
7
+ /** 解決済みの生成オプション(決定論の入力単位) */
8
+ interface ResolvedOpts {
9
+ connected: boolean;
10
+ symmetric: boolean;
11
+ outline: boolean;
12
+ face: boolean;
13
+ legs: Legs;
14
+ }
15
+ /** 公開APIのオプション: preset + 個別上書き + view/frame */
16
+ interface GenerateOptions extends Partial<ResolvedOpts> {
17
+ preset?: Preset;
18
+ view?: View;
19
+ frame?: Frame;
20
+ }
21
+ interface GenerateResult {
22
+ svg: string;
23
+ drawnLegStyle: LegStyle;
24
+ size: 16;
25
+ }
26
+
27
+ export type { Frame as F, GenerateOptions as G, LegStyle as L, Preset as P, ResolvedOpts as R, View as V, GenerateResult as a, Locale as b, Legs as c };
@@ -0,0 +1,27 @@
1
+ type Preset = "mochi" | "retro" | "chaos";
2
+ type Legs = "auto" | "none" | "two" | "many";
3
+ type LegStyle = "none" | "two" | "many";
4
+ type View = "front" | "back" | "left" | "right";
5
+ type Frame = 0 | 1 | 2;
6
+ type Locale = "en" | "ja";
7
+ /** 解決済みの生成オプション(決定論の入力単位) */
8
+ interface ResolvedOpts {
9
+ connected: boolean;
10
+ symmetric: boolean;
11
+ outline: boolean;
12
+ face: boolean;
13
+ legs: Legs;
14
+ }
15
+ /** 公開APIのオプション: preset + 個別上書き + view/frame */
16
+ interface GenerateOptions extends Partial<ResolvedOpts> {
17
+ preset?: Preset;
18
+ view?: View;
19
+ frame?: Frame;
20
+ }
21
+ interface GenerateResult {
22
+ svg: string;
23
+ drawnLegStyle: LegStyle;
24
+ size: 16;
25
+ }
26
+
27
+ export type { Frame as F, GenerateOptions as G, LegStyle as L, Preset as P, ResolvedOpts as R, View as V, GenerateResult as a, Locale as b, Legs as c };
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@dotmon/core",
3
+ "version": "0.1.0",
4
+ "description": "Turn any name into a unique pixel-art monster. Deterministic, animated, zero dependencies.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/dotmon-org/dotmon.git",
8
+ "directory": "packages/core"
9
+ },
10
+ "license": "MIT",
11
+ "type": "module",
12
+ "sideEffects": false,
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "main": "./dist/index.cjs",
17
+ "module": "./dist/index.js",
18
+ "types": "./dist/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "import": "./dist/index.js",
23
+ "require": "./dist/index.cjs"
24
+ },
25
+ "./render": {
26
+ "types": "./dist/render/index.d.ts",
27
+ "import": "./dist/render/index.js",
28
+ "require": "./dist/render/index.cjs"
29
+ },
30
+ "./locales": {
31
+ "types": "./dist/locales/index.d.ts",
32
+ "import": "./dist/locales/index.js",
33
+ "require": "./dist/locales/index.cjs"
34
+ },
35
+ "./locales/en": {
36
+ "types": "./dist/locales/en.d.ts",
37
+ "import": "./dist/locales/en.js",
38
+ "require": "./dist/locales/en.cjs"
39
+ },
40
+ "./locales/ja": {
41
+ "types": "./dist/locales/ja.d.ts",
42
+ "import": "./dist/locales/ja.js",
43
+ "require": "./dist/locales/ja.cjs"
44
+ }
45
+ },
46
+ "keywords": [
47
+ "avatar",
48
+ "pixel-art",
49
+ "monster",
50
+ "generator",
51
+ "deterministic",
52
+ "sprite",
53
+ "svg"
54
+ ],
55
+ "devDependencies": {
56
+ "@types/node": "^22",
57
+ "tsup": "^8.3.5",
58
+ "typescript": "^5.6.3",
59
+ "vitest": "^2.1.8"
60
+ },
61
+ "scripts": {
62
+ "build": "tsup",
63
+ "test": "vitest run",
64
+ "typecheck": "tsc --noEmit",
65
+ "golden:update": "node --experimental-strip-types scripts/update-golden.ts"
66
+ }
67
+ }