@flare-engine/cli 0.2.1 → 0.3.1
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/LICENSE +201 -21
- package/NOTICE +2 -0
- package/README.md +5 -4
- package/dist/bin.js +76 -326
- package/dist/bin.js.map +1 -1
- package/dist/bin.mjs +74 -72
- package/dist/bin.mjs.map +1 -1
- package/dist/index.d.mts +86 -80
- package/dist/index.d.mts.map +1 -0
- package/dist/index.d.ts +86 -80
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -272
- package/dist/index.mjs +2 -9
- package/dist/tiled-to-flare-CEdmaHp_.js +273 -0
- package/dist/tiled-to-flare-CEdmaHp_.js.map +1 -0
- package/dist/tiled-to-flare-Cc-ofNer.mjs +239 -0
- package/dist/tiled-to-flare-Cc-ofNer.mjs.map +1 -0
- package/package.json +12 -7
- package/dist/chunk-SUMZ7TVL.mjs +0 -235
- package/dist/chunk-SUMZ7TVL.mjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/bin.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts","../src/bin.ts"],"sourcesContent":["import { spawn } from 'node:child_process';\nimport { Command } from 'commander';\nimport { packAtlas } from './pack-atlas.js';\nimport { convertTiled } from './tiled-to-flare.js';\n\nfunction parseIntArg(value: string, _prev: number): number {\n const n = Number.parseInt(value, 10);\n if (!Number.isFinite(n)) throw new Error(`invalid integer: ${value}`);\n return n;\n}\n\nfunction parseFormatArg(value: string): 'png' | 'webp' {\n if (value !== 'png' && value !== 'webp') {\n throw new Error(`invalid --format: ${value} (expected png|webp)`);\n }\n return value;\n}\n\nfunction parseTemplateArg(value: string): 'blank' | 'topdown' | 'shmup' {\n if (value !== 'blank' && value !== 'topdown' && value !== 'shmup') {\n throw new Error(`invalid --template: ${value} (expected blank|topdown|shmup)`);\n }\n return value;\n}\n\nfunction parsePmArg(value: string): 'bun' | 'npm' | 'pnpm' {\n if (value !== 'bun' && value !== 'npm' && value !== 'pnpm') {\n throw new Error(`invalid --package-manager: ${value} (expected bun|npm|pnpm)`);\n }\n return value;\n}\n\n/** Build the `flare` CLI program. Exposed for tests. */\nexport function buildProgram(): Command {\n const program = new Command();\n program.name('flare').description('Flare engine CLI').version(
|
|
1
|
+
{"version":3,"file":"bin.mjs","names":[],"sources":["../package.json","../src/cli.ts","../src/bin.ts"],"sourcesContent":["","import { spawn } from 'node:child_process';\nimport { Command } from 'commander';\nimport { version } from '../package.json';\nimport { packAtlas } from './pack-atlas.js';\nimport { convertTiled } from './tiled-to-flare.js';\n\nfunction parseIntArg(value: string, _prev: number): number {\n const n = Number.parseInt(value, 10);\n if (!Number.isFinite(n)) throw new Error(`invalid integer: ${value}`);\n return n;\n}\n\nfunction parseFormatArg(value: string): 'png' | 'webp' {\n if (value !== 'png' && value !== 'webp') {\n throw new Error(`invalid --format: ${value} (expected png|webp)`);\n }\n return value;\n}\n\nfunction parseTemplateArg(value: string): 'blank' | 'topdown' | 'shmup' {\n if (value !== 'blank' && value !== 'topdown' && value !== 'shmup') {\n throw new Error(`invalid --template: ${value} (expected blank|topdown|shmup)`);\n }\n return value;\n}\n\nfunction parsePmArg(value: string): 'bun' | 'npm' | 'pnpm' {\n if (value !== 'bun' && value !== 'npm' && value !== 'pnpm') {\n throw new Error(`invalid --package-manager: ${value} (expected bun|npm|pnpm)`);\n }\n return value;\n}\n\nconst VALID_APP_NAME = /^[a-z0-9@/_-]+$/i;\n\n/** Returns true when the name is safe to use as an app name and shell argument. */\nexport function isValidAppName(name: string): boolean {\n return VALID_APP_NAME.test(name);\n}\n\n/** Returns the spawn configuration for `npx create-flare-app` on the given platform. */\nexport function createAppSpawnSpec(platform: NodeJS.Platform): { cmd: string; shell: boolean } {\n return { cmd: 'npx', shell: platform === 'win32' };\n}\n\n/** Build the `flare` CLI program. Exposed for tests. */\nexport function buildProgram(): Command {\n const program = new Command();\n program.name('flare').description('Flare engine CLI').version(version);\n\n program\n .command('pack-atlas <input>')\n .description('Pack a directory of PNG sprites into an atlas JSON + image')\n .option('-o, --out <dir>', 'output directory (defaults to <input>)')\n .option('-n, --name <name>', 'base filename for the atlas pair', 'atlas')\n .option('-p, --padding <n>', 'pixel padding between sprites', parseIntArg, 2)\n .option('-m, --max-size <n>', 'maximum atlas side length in px', parseIntArg, 2048)\n .option('-f, --format <fmt>', 'output image format (png|webp)', parseFormatArg, 'png')\n .action(async (input: string, opts) => {\n const result = await packAtlas({\n input,\n out: opts.out,\n name: opts.name,\n padding: opts.padding,\n maxSize: opts.maxSize,\n format: opts.format,\n });\n process.stdout.write(\n `[pack-atlas] wrote ${result.frames.length} frames → ${result.imagePath} (${result.width}x${result.height})\\n`,\n );\n });\n\n program\n .command('tiled-to-flare <tmj>')\n .description('Convert a Tiled .tmj file to Flare runtime JSON')\n .option('-o, --out <file>', 'output .json path')\n .option('--no-embed-tilesets', 'keep external tileset references rather than inlining')\n .action(async (input: string, opts) => {\n const result = await convertTiled({\n input,\n out: opts.out,\n embedTilesets: opts.embedTilesets,\n });\n process.stdout.write(\n `[tiled-to-flare] wrote ${result.layers.length} layers → ${result.outPath}\\n`,\n );\n });\n\n program\n .command('new <name>')\n .description('Scaffold a new Flare app (alias for create-flare-app)')\n .option('-t, --template <name>', 'template (blank|topdown|shmup)', parseTemplateArg, 'blank')\n .option('-p, --package-manager <pm>', 'package manager (bun|npm|pnpm)', parsePmArg)\n .action(async (name: string, opts) => {\n if (!VALID_APP_NAME.test(name)) throw new Error(`invalid app name: ${name}`);\n const args = [name, '--template', opts.template];\n if (opts.packageManager) args.push('--package-manager', opts.packageManager);\n const code = await runCreateFlareApp(args);\n if (code !== 0) process.exit(code);\n });\n\n return program;\n}\n\nfunction runCreateFlareApp(args: string[]): Promise<number> {\n return new Promise((resolvePromise) => {\n const { cmd, shell } = createAppSpawnSpec(process.platform);\n const child = spawn(cmd, ['create-flare-app', ...args], {\n stdio: 'inherit',\n shell,\n });\n child.on('exit', (code) => resolvePromise(code ?? 1));\n child.on('error', () => resolvePromise(1));\n });\n}\n","#!/usr/bin/env node\nimport { buildProgram } from './cli.js';\n\nbuildProgram()\n .parseAsync(process.argv)\n .catch((err: unknown) => {\n const msg = err instanceof Error ? err.message : String(err);\n process.stderr.write(`[flare] ${msg}\\n`);\n process.exit(1);\n });\n"],"mappings":"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"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,123 +1,129 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
1
2
|
/** Options for `packAtlas` / `flare pack-atlas`. */
|
|
2
3
|
interface AtlasPackerOptions {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
/** Directory containing source `.png` sprites (non-recursive). */
|
|
5
|
+
input: string;
|
|
6
|
+
/** Output directory for atlas JSON + image (default: `input`). */
|
|
7
|
+
out?: string;
|
|
8
|
+
/** Base filename (no extension) for the atlas pair (default: `atlas`). */
|
|
9
|
+
name?: string;
|
|
10
|
+
/** Pixel padding between sprites in the packed atlas (default: 2). */
|
|
11
|
+
padding?: number;
|
|
12
|
+
/** Maximum atlas side length in pixels (default: 2048). */
|
|
13
|
+
maxSize?: number;
|
|
14
|
+
/** Output image format (default: `png`). */
|
|
15
|
+
format?: 'png' | 'webp';
|
|
15
16
|
}
|
|
16
17
|
/** One packed frame in the resulting atlas. */
|
|
17
18
|
interface AtlasFrame {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
/** Frame name — sprite filename without extension. */
|
|
20
|
+
name: string;
|
|
21
|
+
/** X position in atlas (px). */
|
|
22
|
+
x: number;
|
|
23
|
+
/** Y position in atlas (px). */
|
|
24
|
+
y: number;
|
|
25
|
+
/** Source sprite width (px). */
|
|
26
|
+
w: number;
|
|
27
|
+
/** Source sprite height (px). */
|
|
28
|
+
h: number;
|
|
28
29
|
}
|
|
29
30
|
/** Result returned by `packAtlas`. */
|
|
30
31
|
interface AtlasResult {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
/** Absolute path to the written JSON descriptor. */
|
|
33
|
+
jsonPath: string;
|
|
34
|
+
/** Absolute path to the written atlas image. */
|
|
35
|
+
imagePath: string;
|
|
36
|
+
/** Packed frames. */
|
|
37
|
+
frames: readonly AtlasFrame[];
|
|
38
|
+
/** Final atlas width (px). */
|
|
39
|
+
width: number;
|
|
40
|
+
/** Final atlas height (px). */
|
|
41
|
+
height: number;
|
|
41
42
|
}
|
|
42
43
|
/** Options for `convertTiled` / `flare tiled-to-flare`. */
|
|
43
44
|
interface TiledConvertOptions {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
/** Path to a Tiled `.tmj` (JSON) map file. */
|
|
46
|
+
input: string;
|
|
47
|
+
/** Output `.json` path (default: `<input>.flare.json`). */
|
|
48
|
+
out?: string;
|
|
49
|
+
/** Embed external tilesets inline rather than leaving references (default: true). */
|
|
50
|
+
embedTilesets?: boolean;
|
|
50
51
|
}
|
|
51
52
|
/** Normalized Flare tileset descriptor. */
|
|
52
53
|
interface FlareTileset {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
name: string;
|
|
55
|
+
firstgid: number;
|
|
56
|
+
tilewidth: number;
|
|
57
|
+
tileheight: number;
|
|
58
|
+
columns: number;
|
|
59
|
+
tilecount: number;
|
|
60
|
+
image: string;
|
|
61
|
+
imagewidth: number;
|
|
62
|
+
imageheight: number;
|
|
63
|
+
/** External tileset path, preserved when embedTilesets is false. */
|
|
64
|
+
source?: string;
|
|
62
65
|
}
|
|
63
66
|
/** Normalized Flare tile layer. */
|
|
64
67
|
interface FlareTileLayer {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
kind: 'tile';
|
|
69
|
+
name: string;
|
|
70
|
+
width: number;
|
|
71
|
+
height: number;
|
|
72
|
+
data: number[];
|
|
73
|
+
visible: boolean;
|
|
74
|
+
opacity: number;
|
|
72
75
|
}
|
|
73
76
|
/** Normalized Flare object. */
|
|
74
77
|
interface FlareObject {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
id: number;
|
|
79
|
+
name: string;
|
|
80
|
+
type: string;
|
|
81
|
+
x: number;
|
|
82
|
+
y: number;
|
|
83
|
+
width: number;
|
|
84
|
+
height: number;
|
|
85
|
+
properties: Record<string, string | number | boolean>;
|
|
83
86
|
}
|
|
84
87
|
/** Normalized Flare object layer. */
|
|
85
88
|
interface FlareObjectLayer {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
kind: 'object';
|
|
90
|
+
name: string;
|
|
91
|
+
objects: FlareObject[];
|
|
92
|
+
visible: boolean;
|
|
93
|
+
opacity: number;
|
|
91
94
|
}
|
|
92
95
|
type FlareLayer = FlareTileLayer | FlareObjectLayer;
|
|
93
96
|
/** Normalized runtime JSON produced by `convertTiled`. */
|
|
94
97
|
interface FlareMap {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
width: number;
|
|
99
|
+
height: number;
|
|
100
|
+
tilewidth: number;
|
|
101
|
+
tileheight: number;
|
|
102
|
+
tilesets: FlareTileset[];
|
|
103
|
+
layers: FlareLayer[];
|
|
101
104
|
}
|
|
102
105
|
/** Result returned by `convertTiled`. */
|
|
103
106
|
interface TiledResult {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
outPath: string;
|
|
108
|
+
layers: FlareLayer[];
|
|
109
|
+
tilesets: FlareTileset[];
|
|
110
|
+
map: FlareMap;
|
|
108
111
|
}
|
|
109
|
-
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/pack-atlas.d.ts
|
|
110
114
|
/**
|
|
111
115
|
* Pack a directory of PNG sprites into a single TexturePacker-compatible
|
|
112
116
|
* atlas (JSON + image) consumable by `@flare-engine/assets`.
|
|
113
117
|
*/
|
|
114
118
|
declare function packAtlas(opts: AtlasPackerOptions): Promise<AtlasResult>;
|
|
115
|
-
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region src/tiled-to-flare.d.ts
|
|
116
121
|
/**
|
|
117
122
|
* Convert a Tiled `.tmj` JSON map into Flare's normalized runtime format.
|
|
118
123
|
* Flattens group layers, resolves external tilesets (when `embedTilesets`),
|
|
119
124
|
* and drops image/editor-only layers.
|
|
120
125
|
*/
|
|
121
126
|
declare function convertTiled(opts: TiledConvertOptions): Promise<TiledResult>;
|
|
122
|
-
|
|
127
|
+
//#endregion
|
|
123
128
|
export { type AtlasFrame, type AtlasPackerOptions, type AtlasResult, type FlareLayer, type FlareMap, type FlareObject, type FlareObjectLayer, type FlareTileLayer, type FlareTileset, type TiledConvertOptions, type TiledResult, convertTiled, packAtlas };
|
|
129
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/pack-atlas.ts","../src/tiled-to-flare.ts"],"mappings":";;UACiB;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;UAIe;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;;UAIe;;EAEf;;EAEA;;EAEA,iBAAiB;;EAEjB;;EAEA;;;UAIe;;EAEf;;EAEA;;EAEA;;;UAIe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;;;UAIe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;;UAIe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA,YAAY;;;UAIG;EACf;EACA;EACA,SAAS;EACT;EACA;;KAGU,aAAa,iBAAiB;;UAGzB;EACf;EACA;EACA;EACA;EACA,UAAU;EACV,QAAQ;;;UAIO;EACf;EACA,QAAQ;EACR,UAAU;EACV,KAAK;;;;;;;;iBCzEe,UAAU,MAAM,qBAAqB,QAAQ;;;;;;;;iBCsH7C,aAAa,MAAM,sBAAsB,QAAQ"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,123 +1,129 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
1
2
|
/** Options for `packAtlas` / `flare pack-atlas`. */
|
|
2
3
|
interface AtlasPackerOptions {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
/** Directory containing source `.png` sprites (non-recursive). */
|
|
5
|
+
input: string;
|
|
6
|
+
/** Output directory for atlas JSON + image (default: `input`). */
|
|
7
|
+
out?: string;
|
|
8
|
+
/** Base filename (no extension) for the atlas pair (default: `atlas`). */
|
|
9
|
+
name?: string;
|
|
10
|
+
/** Pixel padding between sprites in the packed atlas (default: 2). */
|
|
11
|
+
padding?: number;
|
|
12
|
+
/** Maximum atlas side length in pixels (default: 2048). */
|
|
13
|
+
maxSize?: number;
|
|
14
|
+
/** Output image format (default: `png`). */
|
|
15
|
+
format?: 'png' | 'webp';
|
|
15
16
|
}
|
|
16
17
|
/** One packed frame in the resulting atlas. */
|
|
17
18
|
interface AtlasFrame {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
/** Frame name — sprite filename without extension. */
|
|
20
|
+
name: string;
|
|
21
|
+
/** X position in atlas (px). */
|
|
22
|
+
x: number;
|
|
23
|
+
/** Y position in atlas (px). */
|
|
24
|
+
y: number;
|
|
25
|
+
/** Source sprite width (px). */
|
|
26
|
+
w: number;
|
|
27
|
+
/** Source sprite height (px). */
|
|
28
|
+
h: number;
|
|
28
29
|
}
|
|
29
30
|
/** Result returned by `packAtlas`. */
|
|
30
31
|
interface AtlasResult {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
/** Absolute path to the written JSON descriptor. */
|
|
33
|
+
jsonPath: string;
|
|
34
|
+
/** Absolute path to the written atlas image. */
|
|
35
|
+
imagePath: string;
|
|
36
|
+
/** Packed frames. */
|
|
37
|
+
frames: readonly AtlasFrame[];
|
|
38
|
+
/** Final atlas width (px). */
|
|
39
|
+
width: number;
|
|
40
|
+
/** Final atlas height (px). */
|
|
41
|
+
height: number;
|
|
41
42
|
}
|
|
42
43
|
/** Options for `convertTiled` / `flare tiled-to-flare`. */
|
|
43
44
|
interface TiledConvertOptions {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
/** Path to a Tiled `.tmj` (JSON) map file. */
|
|
46
|
+
input: string;
|
|
47
|
+
/** Output `.json` path (default: `<input>.flare.json`). */
|
|
48
|
+
out?: string;
|
|
49
|
+
/** Embed external tilesets inline rather than leaving references (default: true). */
|
|
50
|
+
embedTilesets?: boolean;
|
|
50
51
|
}
|
|
51
52
|
/** Normalized Flare tileset descriptor. */
|
|
52
53
|
interface FlareTileset {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
name: string;
|
|
55
|
+
firstgid: number;
|
|
56
|
+
tilewidth: number;
|
|
57
|
+
tileheight: number;
|
|
58
|
+
columns: number;
|
|
59
|
+
tilecount: number;
|
|
60
|
+
image: string;
|
|
61
|
+
imagewidth: number;
|
|
62
|
+
imageheight: number;
|
|
63
|
+
/** External tileset path, preserved when embedTilesets is false. */
|
|
64
|
+
source?: string;
|
|
62
65
|
}
|
|
63
66
|
/** Normalized Flare tile layer. */
|
|
64
67
|
interface FlareTileLayer {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
kind: 'tile';
|
|
69
|
+
name: string;
|
|
70
|
+
width: number;
|
|
71
|
+
height: number;
|
|
72
|
+
data: number[];
|
|
73
|
+
visible: boolean;
|
|
74
|
+
opacity: number;
|
|
72
75
|
}
|
|
73
76
|
/** Normalized Flare object. */
|
|
74
77
|
interface FlareObject {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
id: number;
|
|
79
|
+
name: string;
|
|
80
|
+
type: string;
|
|
81
|
+
x: number;
|
|
82
|
+
y: number;
|
|
83
|
+
width: number;
|
|
84
|
+
height: number;
|
|
85
|
+
properties: Record<string, string | number | boolean>;
|
|
83
86
|
}
|
|
84
87
|
/** Normalized Flare object layer. */
|
|
85
88
|
interface FlareObjectLayer {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
kind: 'object';
|
|
90
|
+
name: string;
|
|
91
|
+
objects: FlareObject[];
|
|
92
|
+
visible: boolean;
|
|
93
|
+
opacity: number;
|
|
91
94
|
}
|
|
92
95
|
type FlareLayer = FlareTileLayer | FlareObjectLayer;
|
|
93
96
|
/** Normalized runtime JSON produced by `convertTiled`. */
|
|
94
97
|
interface FlareMap {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
width: number;
|
|
99
|
+
height: number;
|
|
100
|
+
tilewidth: number;
|
|
101
|
+
tileheight: number;
|
|
102
|
+
tilesets: FlareTileset[];
|
|
103
|
+
layers: FlareLayer[];
|
|
101
104
|
}
|
|
102
105
|
/** Result returned by `convertTiled`. */
|
|
103
106
|
interface TiledResult {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
outPath: string;
|
|
108
|
+
layers: FlareLayer[];
|
|
109
|
+
tilesets: FlareTileset[];
|
|
110
|
+
map: FlareMap;
|
|
108
111
|
}
|
|
109
|
-
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/pack-atlas.d.ts
|
|
110
114
|
/**
|
|
111
115
|
* Pack a directory of PNG sprites into a single TexturePacker-compatible
|
|
112
116
|
* atlas (JSON + image) consumable by `@flare-engine/assets`.
|
|
113
117
|
*/
|
|
114
118
|
declare function packAtlas(opts: AtlasPackerOptions): Promise<AtlasResult>;
|
|
115
|
-
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region src/tiled-to-flare.d.ts
|
|
116
121
|
/**
|
|
117
122
|
* Convert a Tiled `.tmj` JSON map into Flare's normalized runtime format.
|
|
118
123
|
* Flattens group layers, resolves external tilesets (when `embedTilesets`),
|
|
119
124
|
* and drops image/editor-only layers.
|
|
120
125
|
*/
|
|
121
126
|
declare function convertTiled(opts: TiledConvertOptions): Promise<TiledResult>;
|
|
122
|
-
|
|
127
|
+
//#endregion
|
|
123
128
|
export { type AtlasFrame, type AtlasPackerOptions, type AtlasResult, type FlareLayer, type FlareMap, type FlareObject, type FlareObjectLayer, type FlareTileLayer, type FlareTileset, type TiledConvertOptions, type TiledResult, convertTiled, packAtlas };
|
|
129
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/pack-atlas.ts","../src/tiled-to-flare.ts"],"mappings":";;UACiB;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;UAIe;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;;UAIe;;EAEf;;EAEA;;EAEA,iBAAiB;;EAEjB;;EAEA;;;UAIe;;EAEf;;EAEA;;EAEA;;;UAIe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;;;UAIe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;;UAIe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA,YAAY;;;UAIG;EACf;EACA;EACA,SAAS;EACT;EACA;;KAGU,aAAa,iBAAiB;;UAGzB;EACf;EACA;EACA;EACA;EACA,UAAU;EACV,QAAQ;;;UAIO;EACf;EACA,QAAQ;EACR,UAAU;EACV,KAAK;;;;;;;;iBCzEe,UAAU,MAAM,qBAAqB,QAAQ;;;;;;;;iBCsH7C,aAAa,MAAM,sBAAsB,QAAQ"}
|