@flare-engine/cli 0.3.0 → 0.4.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @flare-engine/cli
2
2
 
3
- Node-only dev tool. Three commands: `flare pack-atlas` (sprite folder → TexturePacker-compatible JSON + atlas PNG), `flare tiled-to-flare` (Tiled `.tmj` → normalized runtime JSON for `@flare-engine/tilemap`), and `flare new` (alias for `create-flare-app`). Programmatic equivalents (`packAtlas`, `convertTiled`) are exported so CI and integration tests can call them without shelling out.
3
+ Node-only dev tool. Three commands: `flare pack-atlas` (sprite folder → TexturePacker-compatible JSON + atlas PNG), `flare tiled-to-flare` (Tiled `.tmj` → normalized runtime JSON for `@flare-engine/tilemap`), and `flare new` (runs `@flare-engine/create` at this CLI's own version). Programmatic equivalents (`packAtlas`, `convertTiled`) are exported so CI and integration tests can call them without shelling out.
4
4
 
5
5
  ## Install
6
6
 
@@ -15,7 +15,7 @@ Requires Node 20+; uses `sharp` for image work and `commander` for arg parsing.
15
15
  ```sh
16
16
  flare pack-atlas ./sprites --out ./assets --padding 2 --max-size 2048 --format png
17
17
  flare tiled-to-flare ./maps/zone1.tmj --out ./assets/zone1.json # embeds tilesets (default)
18
- flare tiled-to-flare ./maps/zone1.tmj --out ./assets/zone1.json --no-embed-tilesets # keep external refs
18
+ flare tiled-to-flare ./maps/zone1.tmj --out ./assets/zone1.json --no-embed-tilesets # keep external refs (not consumable by parseTiled)
19
19
  flare new my-game --template shmup --package-manager bun
20
20
  ```
21
21
 
package/dist/bin.js CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- const require_tiled_to_flare = require("./tiled-to-flare-CEdmaHp_.js");
2
+ const require_tiled_to_flare = require("./tiled-to-flare-cer90bv-.js");
3
3
  let node_child_process = require("node:child_process");
4
4
  let commander = require("commander");
5
5
  //#region package.json
6
- var version = "0.3.0";
6
+ var version = "0.4.0";
7
7
  //#endregion
8
8
  //#region src/cli.ts
9
9
  function parseIntArg(value, _prev) {
@@ -24,13 +24,22 @@ function parsePmArg(value) {
24
24
  return value;
25
25
  }
26
26
  const VALID_APP_NAME = /^[a-z0-9@/_-]+$/i;
27
- /** Returns the spawn configuration for `npx create-flare-app` on the given platform. */
27
+ /** Returns the spawn configuration for `npx @flare-engine/create` on the given platform. */
28
28
  function createAppSpawnSpec(platform) {
29
29
  return {
30
30
  cmd: "npx",
31
31
  shell: platform === "win32"
32
32
  };
33
33
  }
34
+ /**
35
+ * The npx arguments for `flare new`: the scaffolder pinned to this CLI's own
36
+ * version. Lockstep versioning guarantees `@flare-engine/create` exists at that
37
+ * version, and a scoped, exact spec can never resolve to a package someone else
38
+ * published under an unscoped name.
39
+ */
40
+ function createAppSpawnArgs(cliVersion, args) {
41
+ return [`@flare-engine/create@${cliVersion}`, ...args];
42
+ }
34
43
  /** Build the `flare` CLI program. Exposed for tests. */
35
44
  function buildProgram() {
36
45
  const program = new commander.Command();
@@ -46,7 +55,7 @@ function buildProgram() {
46
55
  });
47
56
  process.stdout.write(`[pack-atlas] wrote ${result.frames.length} frames → ${result.imagePath} (${result.width}x${result.height})\n`);
48
57
  });
49
- program.command("tiled-to-flare <tmj>").description("Convert a Tiled .tmj file to Flare runtime JSON").option("-o, --out <file>", "output .json path").option("--no-embed-tilesets", "keep external tileset references rather than inlining").action(async (input, opts) => {
58
+ program.command("tiled-to-flare <tmj>").description("Convert a Tiled .tmj file to Flare runtime JSON").option("-o, --out <file>", "output .json path").option("--no-embed-tilesets", "keep external tileset references instead of inlining (parseTiled rejects the result)").action(async (input, opts) => {
50
59
  const result = await require_tiled_to_flare.convertTiled({
51
60
  input,
52
61
  out: opts.out,
@@ -54,7 +63,7 @@ function buildProgram() {
54
63
  });
55
64
  process.stdout.write(`[tiled-to-flare] wrote ${result.layers.length} layers → ${result.outPath}\n`);
56
65
  });
57
- program.command("new <name>").description("Scaffold a new Flare app (alias for create-flare-app)").option("-t, --template <name>", "template (blank|topdown|shmup)", parseTemplateArg, "blank").option("-p, --package-manager <pm>", "package manager (bun|npm|pnpm)", parsePmArg).action(async (name, opts) => {
66
+ program.command("new <name>").description("Scaffold a new Flare app (alias for npm create @flare-engine)").option("-t, --template <name>", "template (blank|topdown|shmup)", parseTemplateArg, "blank").option("-p, --package-manager <pm>", "package manager (bun|npm|pnpm)", parsePmArg).action(async (name, opts) => {
58
67
  if (!VALID_APP_NAME.test(name)) throw new Error(`invalid app name: ${name}`);
59
68
  const args = [
60
69
  name,
@@ -62,15 +71,15 @@ function buildProgram() {
62
71
  opts.template
63
72
  ];
64
73
  if (opts.packageManager) args.push("--package-manager", opts.packageManager);
65
- const code = await runCreateFlareApp(args);
74
+ const code = await runCreateApp(args);
66
75
  if (code !== 0) process.exit(code);
67
76
  });
68
77
  return program;
69
78
  }
70
- function runCreateFlareApp(args) {
79
+ function runCreateApp(args) {
71
80
  return new Promise((resolvePromise) => {
72
81
  const { cmd, shell } = createAppSpawnSpec(process.platform);
73
- const child = (0, node_child_process.spawn)(cmd, ["create-flare-app", ...args], {
82
+ const child = (0, node_child_process.spawn)(cmd, createAppSpawnArgs(version, args), {
74
83
  stdio: "inherit",
75
84
  shell
76
85
  });
package/dist/bin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bin.js","names":["Command","packAtlas","convertTiled"],"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":";;;;;;;;ACMA,SAAS,YAAY,OAAe,OAAuB;CACzD,MAAM,IAAI,OAAO,SAAS,OAAO,EAAE;CACnC,IAAI,CAAC,OAAO,SAAS,CAAC,GAAG,MAAM,IAAI,MAAM,oBAAoB,OAAO;CACpE,OAAO;AACT;AAEA,SAAS,eAAe,OAA+B;CACrD,IAAI,UAAU,SAAS,UAAU,QAC/B,MAAM,IAAI,MAAM,qBAAqB,MAAM,qBAAqB;CAElE,OAAO;AACT;AAEA,SAAS,iBAAiB,OAA8C;CACtE,IAAI,UAAU,WAAW,UAAU,aAAa,UAAU,SACxD,MAAM,IAAI,MAAM,uBAAuB,MA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,CAAC;EACD,QAAQ,OAAO,MACb,0BAA0B,OAAO,OAAO,OAAO,YAAY,OAAO,QAAQ,GAC5E;CACF,CAAC;CAEH,QACG,QAAQ,YAAY,CAAC,CACrB,YAAY,uDAAuD,CAAC,CACpE,OAAO,yBAAyB,kCAAkC,kBAAkB,OAAO,CAAC,CAC5F,OAAO,8BAA8B,kCAAkC,UAAU,CAAC,CAClF,OAAO,OAAO,MAAc,SAAS;EACpC,IAAI,CAAC,eAAe,KAAK,IAAI,GAAG,MAAM,IAAI,MAAM,qBAAqB,MAAM;EAC3E,MAAM,OAAO;GAAC;GAAM;GAAc,KAAK;EAAQ;EAC/C,IAAI,KAAK,gBAAgB,KAAK,KAAK,qBAAqB,KAAK,cAAc;EAC3E,MAAM,OAAO,MAAM,kBAAkB,IAAI;EACzC,IAAI,SAAS,GAAG,QAAQ,KAAK,IAAI;CACnC,CAAC;CAEH,OAAO;AACT;AAEA,SAAS,kBAAkB,MAAiC;CAC1D,OAAO,IAAI,SAAS,mBAAmB;EACrC,MAAM,EAAE,KAAK,UAAU,mBAAmB,QAAQ,QAAQ;EAC1D,MAAM,SAAA,GAAA,mBAAA,MAAA,CAAc,KAAK,CAAC,oBAAoB,GAAG,IAAI,GAAG;GACtD,OAAO;GACP;EACF,CAAC;EACD,MAAM,GAAG,SAAS,SAAS,eAAe,QAAQ,CAAC,CAAC;EACpD,MAAM,GAAG,eAAe,eAAe,CAAC,CAAC;CAC3C,CAAC;AACH;;;AC/GA,aAAa,CAAC,CACX,WAAW,QAAQ,IAAI,CAAC,CACxB,OAAO,QAAiB;CACvB,MAAM,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;CAC3D,QAAQ,OAAO,MAAM,WAAW,IAAI,GAAG;CACvC,QAAQ,KAAK,CAAC;AAChB,CAAC"}
1
+ {"version":3,"file":"bin.js","names":["Command","packAtlas","convertTiled"],"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 @flare-engine/create` on the given platform. */\nexport function createAppSpawnSpec(platform: NodeJS.Platform): { cmd: string; shell: boolean } {\n return { cmd: 'npx', shell: platform === 'win32' };\n}\n\n/**\n * The npx arguments for `flare new`: the scaffolder pinned to this CLI's own\n * version. Lockstep versioning guarantees `@flare-engine/create` exists at that\n * version, and a scoped, exact spec can never resolve to a package someone else\n * published under an unscoped name.\n */\nexport function createAppSpawnArgs(cliVersion: string, args: readonly string[]): string[] {\n return [`@flare-engine/create@${cliVersion}`, ...args];\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(\n '--no-embed-tilesets',\n 'keep external tileset references instead of inlining (parseTiled rejects the result)',\n )\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 npm create @flare-engine)')\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 runCreateApp(args);\n if (code !== 0) process.exit(code);\n });\n\n return program;\n}\n\nfunction runCreateApp(args: string[]): Promise<number> {\n return new Promise((resolvePromise) => {\n const { cmd, shell } = createAppSpawnSpec(process.platform);\n const child = spawn(cmd, createAppSpawnArgs(version, 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":";;;;;;;;ACMA,SAAS,YAAY,OAAe,OAAuB;CACzD,MAAM,IAAI,OAAO,SAAS,OAAO,EAAE;CACnC,IAAI,CAAC,OAAO,SAAS,CAAC,GAAG,MAAM,IAAI,MAAM,oBAAoB,OAAO;CACpE,OAAO;AACT;AAEA,SAAS,eAAe,OAA+B;CACrD,IAAI,UAAU,SAAS,UAAU,QAC/B,MAAM,IAAI,MAAM,qBAAqB,MAAM,qBAAqB;CAElE,OAAO;AACT;AAEA,SAAS,iBAAiB,OAA8C;CACtE,IAAI,UAAU,WAAW,UAAU,aAAa,UAAU,SACxD,MAAM,IAAI,MAAM,uBAAuB,MAAM,gCAAgC;CAE/E,OAAO;AACT;AAEA,SAAS,WAAW,OAAuC;CACzD,IAAI,UAAU,SAAS,UAAU,SAAS,UAAU,QAClD,MAAM,IAAI,MAAM,8BAA8B,MAAM,yBAAyB;CAE/E,OAAO;AACT;AAEA,MAAM,iBAAiB;;AAQvB,SAAgB,mBAAmB,UAA4D;CAC7F,OAAO;EAAE,KAAK;EAAO,OAAO,aAAa;CAAQ;AACnD;;;;;;;AAQA,SAAgB,mBAAmB,YAAoB,MAAmC;CACxF,OAAO,CAAC,wBAAwB,cAAc,GAAG,IAAI;AACvD;;AAGA,SAAgB,eAAwB;CACtC,MAAM,UAAU,IAAIA,UAAAA,QAAQ;CAC5B,QAAQ,KAAK,OAAO,CAAC,CAAC,YAAY,kBAAkB,CAAC,CAAC,QAAQ,OAAO;CAErE,QACG,QAAQ,oBAAoB,CAAC,CAC7B,YAAY,4DAA4D,CAAC,CACzE,OAAO,mBAAmB,wCAAwC,CAAC,CACnE,OAAO,qBAAqB,oCAAoC,OAAO,CAAC,CACxE,OAAO,qBAAqB,iCAAiC,aAAa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AAiC;CACrD,OAAO,IAAI,SAAS,mBAAmB;EACrC,MAAM,EAAE,KAAK,UAAU,mBAAmB,QAAQ,QAAQ;EAC1D,MAAM,SAAA,GAAA,mBAAA,MAAA,CAAc,KAAK,mBAAmB,SAAS,IAAI,GAAG;GAC1D,OAAO;GACP;EACF,CAAC;EACD,MAAM,GAAG,SAAS,SAAS,eAAe,QAAQ,CAAC,CAAC;EACpD,MAAM,GAAG,eAAe,eAAe,CAAC,CAAC;CAC3C,CAAC;AACH;;;AC5HA,aAAa,CAAC,CACX,WAAW,QAAQ,IAAI,CAAC,CACxB,OAAO,QAAiB;CACvB,MAAM,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;CAC3D,QAAQ,OAAO,MAAM,WAAW,IAAI,GAAG;CACvC,QAAQ,KAAK,CAAC;AAChB,CAAC"}
package/dist/bin.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import { n as packAtlas, t as convertTiled } from "./tiled-to-flare-Cc-ofNer.mjs";
2
+ import { n as packAtlas, t as convertTiled } from "./tiled-to-flare-CB70UDDG.mjs";
3
3
  import { spawn } from "node:child_process";
4
4
  import { Command } from "commander";
5
5
  //#region package.json
6
- var version = "0.3.0";
6
+ var version = "0.4.0";
7
7
  //#endregion
8
8
  //#region src/cli.ts
9
9
  function parseIntArg(value, _prev) {
@@ -24,13 +24,22 @@ function parsePmArg(value) {
24
24
  return value;
25
25
  }
26
26
  const VALID_APP_NAME = /^[a-z0-9@/_-]+$/i;
27
- /** Returns the spawn configuration for `npx create-flare-app` on the given platform. */
27
+ /** Returns the spawn configuration for `npx @flare-engine/create` on the given platform. */
28
28
  function createAppSpawnSpec(platform) {
29
29
  return {
30
30
  cmd: "npx",
31
31
  shell: platform === "win32"
32
32
  };
33
33
  }
34
+ /**
35
+ * The npx arguments for `flare new`: the scaffolder pinned to this CLI's own
36
+ * version. Lockstep versioning guarantees `@flare-engine/create` exists at that
37
+ * version, and a scoped, exact spec can never resolve to a package someone else
38
+ * published under an unscoped name.
39
+ */
40
+ function createAppSpawnArgs(cliVersion, args) {
41
+ return [`@flare-engine/create@${cliVersion}`, ...args];
42
+ }
34
43
  /** Build the `flare` CLI program. Exposed for tests. */
35
44
  function buildProgram() {
36
45
  const program = new Command();
@@ -46,7 +55,7 @@ function buildProgram() {
46
55
  });
47
56
  process.stdout.write(`[pack-atlas] wrote ${result.frames.length} frames → ${result.imagePath} (${result.width}x${result.height})\n`);
48
57
  });
49
- program.command("tiled-to-flare <tmj>").description("Convert a Tiled .tmj file to Flare runtime JSON").option("-o, --out <file>", "output .json path").option("--no-embed-tilesets", "keep external tileset references rather than inlining").action(async (input, opts) => {
58
+ program.command("tiled-to-flare <tmj>").description("Convert a Tiled .tmj file to Flare runtime JSON").option("-o, --out <file>", "output .json path").option("--no-embed-tilesets", "keep external tileset references instead of inlining (parseTiled rejects the result)").action(async (input, opts) => {
50
59
  const result = await convertTiled({
51
60
  input,
52
61
  out: opts.out,
@@ -54,7 +63,7 @@ function buildProgram() {
54
63
  });
55
64
  process.stdout.write(`[tiled-to-flare] wrote ${result.layers.length} layers → ${result.outPath}\n`);
56
65
  });
57
- program.command("new <name>").description("Scaffold a new Flare app (alias for create-flare-app)").option("-t, --template <name>", "template (blank|topdown|shmup)", parseTemplateArg, "blank").option("-p, --package-manager <pm>", "package manager (bun|npm|pnpm)", parsePmArg).action(async (name, opts) => {
66
+ program.command("new <name>").description("Scaffold a new Flare app (alias for npm create @flare-engine)").option("-t, --template <name>", "template (blank|topdown|shmup)", parseTemplateArg, "blank").option("-p, --package-manager <pm>", "package manager (bun|npm|pnpm)", parsePmArg).action(async (name, opts) => {
58
67
  if (!VALID_APP_NAME.test(name)) throw new Error(`invalid app name: ${name}`);
59
68
  const args = [
60
69
  name,
@@ -62,15 +71,15 @@ function buildProgram() {
62
71
  opts.template
63
72
  ];
64
73
  if (opts.packageManager) args.push("--package-manager", opts.packageManager);
65
- const code = await runCreateFlareApp(args);
74
+ const code = await runCreateApp(args);
66
75
  if (code !== 0) process.exit(code);
67
76
  });
68
77
  return program;
69
78
  }
70
- function runCreateFlareApp(args) {
79
+ function runCreateApp(args) {
71
80
  return new Promise((resolvePromise) => {
72
81
  const { cmd, shell } = createAppSpawnSpec(process.platform);
73
- const child = spawn(cmd, ["create-flare-app", ...args], {
82
+ const child = spawn(cmd, createAppSpawnArgs(version, args), {
74
83
  stdio: "inherit",
75
84
  shell
76
85
  });
package/dist/bin.mjs.map CHANGED
@@ -1 +1 @@
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":";;;;;;;;ACMA,SAAS,YAAY,OAAe,OAAuB;CACzD,MAAM,IAAI,OAAO,SAAS,OAAO,EAAE;CACnC,IAAI,CAAC,OAAO,SAAS,CAAC,GAAG,MAAM,IAAI,MAAM,oBAAoB,OAAO;CACpE,OAAO;AACT;AAEA,SAAS,eAAe,OAA+B;CACrD,IAAI,UAAU,SAAS,UAAU,QAC/B,MAAM,IAAI,MAAM,qBAAqB,MAAM,qBAAqB;CAElE,OAAO;AACT;AAEA,SAAS,iBAAiB,OAA8C;CACtE,IAAI,UAAU,WAAW,UAAU,aAAa,UAAU,SACxD,MAAM,IAAI,MAAM,uBAAuB,MAAM,gCAAgC;CAE/E,OAAO;AACT;AAEA,SAAS,WAAW,OAAuC;CACzD,IAAI,UAAU,SAAS,UAAU,SAAS,UAAU,QAClD,MAAM,IAAI,MAAM,8BAA8B,MAAM,yBAAyB;CAE/E,OAAO;AACT;AAEA,MAAM,iBAAiB;;AAQvB,SAAgB,mBAAmB,UAA4D;CAC7F,OAAO;EAAE,KAAK;EAAO,OAAO,aAAa;CAAQ;AACnD;;AAGA,SAAgB,eAAwB;CACtC,MAAM,UAAU,IAAI,QAAQ;CAC5B,QAAQ,KAAK,OAAO,CAAC,CAAC,YAAY,kBAAkB,CAAC,CAAC,QAAQ,OAAO;CAErE,QACG,QAAQ,oBAAoB,CAAC,CAC7B,YAAY,4DAA4D,CAAC,CACzE,OAAO,mBAAmB,wCAAwC,CAAC,C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,KAAK,IAAI;CACnC,CAAC;CAEH,OAAO;AACT;AAEA,SAAS,kBAAkB,MAAiC;CAC1D,OAAO,IAAI,SAAS,mBAAmB;EACrC,MAAM,EAAE,KAAK,UAAU,mBAAmB,QAAQ,QAAQ;EAC1D,MAAM,QAAQ,MAAM,KAAK,CAAC,oBAAoB,GAAG,IAAI,GAAG;GACtD,OAAO;GACP;EACF,CAAC;EACD,MAAM,GAAG,SAAS,SAAS,eAAe,QAAQ,CAAC,CAAC;EACpD,MAAM,GAAG,eAAe,eAAe,CAAC,CAAC;CAC3C,CAAC;AACH;;;AC/GA,aAAa,CAAC,CACX,WAAW,QAAQ,IAAI,CAAC,CACxB,OAAO,QAAiB;CACvB,MAAM,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;CAC3D,QAAQ,OAAO,MAAM,WAAW,IAAI,GAAG;CACvC,QAAQ,KAAK,CAAC;AAChB,CAAC"}
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 @flare-engine/create` on the given platform. */\nexport function createAppSpawnSpec(platform: NodeJS.Platform): { cmd: string; shell: boolean } {\n return { cmd: 'npx', shell: platform === 'win32' };\n}\n\n/**\n * The npx arguments for `flare new`: the scaffolder pinned to this CLI's own\n * version. Lockstep versioning guarantees `@flare-engine/create` exists at that\n * version, and a scoped, exact spec can never resolve to a package someone else\n * published under an unscoped name.\n */\nexport function createAppSpawnArgs(cliVersion: string, args: readonly string[]): string[] {\n return [`@flare-engine/create@${cliVersion}`, ...args];\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(\n '--no-embed-tilesets',\n 'keep external tileset references instead of inlining (parseTiled rejects the result)',\n )\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 npm create @flare-engine)')\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 runCreateApp(args);\n if (code !== 0) process.exit(code);\n });\n\n return program;\n}\n\nfunction runCreateApp(args: string[]): Promise<number> {\n return new Promise((resolvePromise) => {\n const { cmd, shell } = createAppSpawnSpec(process.platform);\n const child = spawn(cmd, createAppSpawnArgs(version, 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":";;;;;;;;ACMA,SAAS,YAAY,OAAe,OAAuB;CACzD,MAAM,IAAI,OAAO,SAAS,OAAO,EAAE;CACnC,IAAI,CAAC,OAAO,SAAS,CAAC,GAAG,MAAM,IAAI,MAAM,oBAAoB,OAAO;CACpE,OAAO;AACT;AAEA,SAAS,eAAe,OAA+B;CACrD,IAAI,UAAU,SAAS,UAAU,QAC/B,MAAM,IAAI,MAAM,qBAAqB,MAAM,qBAAqB;CAElE,OAAO;AACT;AAEA,SAAS,iBAAiB,OAA8C;CACtE,IAAI,UAAU,WAAW,UAAU,aAAa,UAAU,SACxD,MAAM,IAAI,MAAM,uBAAuB,MAA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path (default: `<input>.flare.json`). */
48
48
  out?: string;
49
- /** Embed external tilesets inline rather than leaving references (default: true). */
49
+ /**
50
+ * Embed external tilesets inline rather than leaving references (default: true).
51
+ * With `false`, the emitted tileset keeps its Tiled `source` path instead of being
52
+ * resolved — `@flare-engine/tilemap`'s `parseTiled` rejects a tileset with `source`
53
+ * set, so that output is not directly engine-consumable; it exists for pipelines
54
+ * that resolve external tilesets themselves before calling `parseTiled`.
55
+ */
50
56
  embedTilesets?: boolean;
51
57
  }
52
- /** Normalized Flare tileset descriptor. */
53
- interface FlareTileset {
58
+ /** A Tiled custom property, as Tiled's JSON export represents it. */
59
+ interface TiledProperty {
54
60
  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;
61
+ type?: string;
62
+ value: string | number | boolean;
65
63
  }
66
- /** Normalized Flare tile layer. */
67
- interface FlareTileLayer {
68
- kind: 'tile';
69
- name: string;
70
- width: number;
71
- height: number;
72
- data: number[];
73
- visible: boolean;
74
- opacity: number;
64
+ /**
65
+ * A tile definition inside a tileset's `tiles[]` — the only place per-tile
66
+ * `properties` and `solid`/`collision` flags live. `parseTiled` reads this shape
67
+ * directly to populate `TilesetRef.solidTiles` / `tileProperties`.
68
+ */
69
+ interface TiledTile {
70
+ id: number;
71
+ type?: string;
72
+ class?: string;
73
+ properties?: TiledProperty[];
75
74
  }
76
- /** Normalized Flare object. */
77
- interface FlareObject {
75
+ /** An object inside an object layer — Tiled-shaped, unchanged by `convertTiled`. */
76
+ interface TiledObject {
78
77
  id: number;
79
- name: string;
80
- type: string;
78
+ name?: string;
79
+ type?: string;
80
+ class?: string;
81
81
  x: number;
82
82
  y: number;
83
83
  width: number;
84
84
  height: number;
85
- properties: Record<string, string | number | boolean>;
85
+ rotation?: number;
86
+ visible?: boolean;
87
+ properties?: TiledProperty[];
88
+ }
89
+ /** A tile layer, Tiled-shaped — accepted directly by `@flare-engine/tilemap`'s `parseTiled`. */
90
+ interface TiledTileLayer {
91
+ type: 'tilelayer';
92
+ name: string;
93
+ width: number;
94
+ height: number;
95
+ data: number[];
96
+ visible: boolean;
97
+ opacity: number;
98
+ offsetx?: number;
99
+ offsety?: number;
100
+ properties?: TiledProperty[];
86
101
  }
87
- /** Normalized Flare object layer. */
88
- interface FlareObjectLayer {
89
- kind: 'object';
102
+ /** An object layer, Tiled-shaped — accepted directly by `@flare-engine/tilemap`'s `parseTiled`. */
103
+ interface TiledObjectLayer {
104
+ type: 'objectgroup';
90
105
  name: string;
91
- objects: FlareObject[];
106
+ objects: TiledObject[];
92
107
  visible: boolean;
93
108
  opacity: number;
109
+ properties?: TiledProperty[];
94
110
  }
95
- type FlareLayer = FlareTileLayer | FlareObjectLayer;
96
- /** Normalized runtime JSON produced by `convertTiled`. */
97
- interface FlareMap {
111
+ type TiledLayer = TiledTileLayer | TiledObjectLayer;
112
+ /**
113
+ * A tileset entry, Tiled-shaped. External tilesets are resolved and inlined here
114
+ * when `embedTilesets` (the default) — `tiles` and `properties` carry through so
115
+ * `parseTiled` can populate collision flags and custom data.
116
+ */
117
+ interface TiledTileset {
118
+ name: string;
119
+ firstgid: number;
120
+ tilewidth: number;
121
+ tileheight: number;
122
+ columns: number;
123
+ tilecount: number;
124
+ image: string;
125
+ imagewidth: number;
126
+ imageheight: number;
127
+ tiles?: TiledTile[];
128
+ properties?: TiledProperty[];
129
+ /**
130
+ * External tileset path — present only when `embedTilesets` is false.
131
+ * `parseTiled` rejects a tileset with `source` set; see `TiledConvertOptions.embedTilesets`.
132
+ */
133
+ source?: string;
134
+ }
135
+ /**
136
+ * Tiled-shaped runtime JSON written by `convertTiled` — a pass-through of the
137
+ * original map's layers and tilesets (group/image layers flattened/dropped,
138
+ * external tilesets inlined), accepted directly by `parseTiled`.
139
+ */
140
+ interface TiledMap {
98
141
  width: number;
99
142
  height: number;
100
143
  tilewidth: number;
101
144
  tileheight: number;
102
- tilesets: FlareTileset[];
103
- layers: FlareLayer[];
145
+ tilesets: TiledTileset[];
146
+ layers: TiledLayer[];
104
147
  }
105
148
  /** Result returned by `convertTiled`. */
106
149
  interface TiledResult {
107
150
  outPath: string;
108
- layers: FlareLayer[];
109
- tilesets: FlareTileset[];
110
- map: FlareMap;
151
+ layers: TiledLayer[];
152
+ tilesets: TiledTileset[];
153
+ map: TiledMap;
111
154
  }
112
155
  //#endregion
113
156
  //#region src/pack-atlas.d.ts
@@ -119,11 +162,14 @@ declare function packAtlas(opts: AtlasPackerOptions): Promise<AtlasResult>;
119
162
  //#endregion
120
163
  //#region src/tiled-to-flare.d.ts
121
164
  /**
122
- * Convert a Tiled `.tmj` JSON map into Flare's normalized runtime format.
123
- * Flattens group layers, resolves external tilesets (when `embedTilesets`),
124
- * and drops image/editor-only layers.
165
+ * Convert a Tiled `.tmj` JSON map into Tiled-shaped runtime JSON, accepted
166
+ * directly by `@flare-engine/tilemap`'s `parseTiled` — this is a pass-through of
167
+ * the original layer/tileset objects (not a re-projection), so `type`,
168
+ * `properties`, tileset `tiles[]`, object `rotation` and layer `offsetx`/`offsety`
169
+ * all survive. Flattens group layers, resolves external tilesets (when
170
+ * `embedTilesets`), and drops image/editor-only layers.
125
171
  */
126
172
  declare function convertTiled(opts: TiledConvertOptions): Promise<TiledResult>;
127
173
  //#endregion
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 };
174
+ export { type AtlasFrame, type AtlasPackerOptions, type AtlasResult, type TiledConvertOptions, type TiledLayer, type TiledMap, type TiledObject, type TiledObjectLayer, type TiledProperty, type TiledResult, type TiledTile, type TiledTileLayer, type TiledTileset, convertTiled, packAtlas };
129
175
  //# sourceMappingURL=index.d.mts.map
@@ -1 +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"}
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;;;;;;;;EAQA;;;UAIe;EACf;EACA;EACA;;;;;;;UAQe;EACf;EACA;EACA;EACA,aAAa;;;UAIE;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,aAAa;;;UAIE;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,aAAa;;;UAIE;EACf;EACA;EACA,SAAS;EACT;EACA;EACA,aAAa;;KAGH,aAAa,iBAAiB;;;;;;UAOzB;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,QAAQ;EACR,aAAa;;;;;EAKb;;;;;;;UAQe;EACf;EACA;EACA;EACA;EACA,UAAU;EACV,QAAQ;;;UAIO;EACf;EACA,QAAQ;EACR,UAAU;EACV,KAAK;;;;;;;;iBCtHe,UAAU,MAAM,qBAAqB,QAAQ;;;;;;;;;;;iBCuG7C,aAAa,MAAM,sBAAsB,QAAQ"}
package/dist/index.d.ts CHANGED
@@ -46,68 +46,111 @@ interface TiledConvertOptions {
46
46
  input: string;
47
47
  /** Output `.json` path (default: `<input>.flare.json`). */
48
48
  out?: string;
49
- /** Embed external tilesets inline rather than leaving references (default: true). */
49
+ /**
50
+ * Embed external tilesets inline rather than leaving references (default: true).
51
+ * With `false`, the emitted tileset keeps its Tiled `source` path instead of being
52
+ * resolved — `@flare-engine/tilemap`'s `parseTiled` rejects a tileset with `source`
53
+ * set, so that output is not directly engine-consumable; it exists for pipelines
54
+ * that resolve external tilesets themselves before calling `parseTiled`.
55
+ */
50
56
  embedTilesets?: boolean;
51
57
  }
52
- /** Normalized Flare tileset descriptor. */
53
- interface FlareTileset {
58
+ /** A Tiled custom property, as Tiled's JSON export represents it. */
59
+ interface TiledProperty {
54
60
  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;
61
+ type?: string;
62
+ value: string | number | boolean;
65
63
  }
66
- /** Normalized Flare tile layer. */
67
- interface FlareTileLayer {
68
- kind: 'tile';
69
- name: string;
70
- width: number;
71
- height: number;
72
- data: number[];
73
- visible: boolean;
74
- opacity: number;
64
+ /**
65
+ * A tile definition inside a tileset's `tiles[]` — the only place per-tile
66
+ * `properties` and `solid`/`collision` flags live. `parseTiled` reads this shape
67
+ * directly to populate `TilesetRef.solidTiles` / `tileProperties`.
68
+ */
69
+ interface TiledTile {
70
+ id: number;
71
+ type?: string;
72
+ class?: string;
73
+ properties?: TiledProperty[];
75
74
  }
76
- /** Normalized Flare object. */
77
- interface FlareObject {
75
+ /** An object inside an object layer — Tiled-shaped, unchanged by `convertTiled`. */
76
+ interface TiledObject {
78
77
  id: number;
79
- name: string;
80
- type: string;
78
+ name?: string;
79
+ type?: string;
80
+ class?: string;
81
81
  x: number;
82
82
  y: number;
83
83
  width: number;
84
84
  height: number;
85
- properties: Record<string, string | number | boolean>;
85
+ rotation?: number;
86
+ visible?: boolean;
87
+ properties?: TiledProperty[];
88
+ }
89
+ /** A tile layer, Tiled-shaped — accepted directly by `@flare-engine/tilemap`'s `parseTiled`. */
90
+ interface TiledTileLayer {
91
+ type: 'tilelayer';
92
+ name: string;
93
+ width: number;
94
+ height: number;
95
+ data: number[];
96
+ visible: boolean;
97
+ opacity: number;
98
+ offsetx?: number;
99
+ offsety?: number;
100
+ properties?: TiledProperty[];
86
101
  }
87
- /** Normalized Flare object layer. */
88
- interface FlareObjectLayer {
89
- kind: 'object';
102
+ /** An object layer, Tiled-shaped — accepted directly by `@flare-engine/tilemap`'s `parseTiled`. */
103
+ interface TiledObjectLayer {
104
+ type: 'objectgroup';
90
105
  name: string;
91
- objects: FlareObject[];
106
+ objects: TiledObject[];
92
107
  visible: boolean;
93
108
  opacity: number;
109
+ properties?: TiledProperty[];
94
110
  }
95
- type FlareLayer = FlareTileLayer | FlareObjectLayer;
96
- /** Normalized runtime JSON produced by `convertTiled`. */
97
- interface FlareMap {
111
+ type TiledLayer = TiledTileLayer | TiledObjectLayer;
112
+ /**
113
+ * A tileset entry, Tiled-shaped. External tilesets are resolved and inlined here
114
+ * when `embedTilesets` (the default) — `tiles` and `properties` carry through so
115
+ * `parseTiled` can populate collision flags and custom data.
116
+ */
117
+ interface TiledTileset {
118
+ name: string;
119
+ firstgid: number;
120
+ tilewidth: number;
121
+ tileheight: number;
122
+ columns: number;
123
+ tilecount: number;
124
+ image: string;
125
+ imagewidth: number;
126
+ imageheight: number;
127
+ tiles?: TiledTile[];
128
+ properties?: TiledProperty[];
129
+ /**
130
+ * External tileset path — present only when `embedTilesets` is false.
131
+ * `parseTiled` rejects a tileset with `source` set; see `TiledConvertOptions.embedTilesets`.
132
+ */
133
+ source?: string;
134
+ }
135
+ /**
136
+ * Tiled-shaped runtime JSON written by `convertTiled` — a pass-through of the
137
+ * original map's layers and tilesets (group/image layers flattened/dropped,
138
+ * external tilesets inlined), accepted directly by `parseTiled`.
139
+ */
140
+ interface TiledMap {
98
141
  width: number;
99
142
  height: number;
100
143
  tilewidth: number;
101
144
  tileheight: number;
102
- tilesets: FlareTileset[];
103
- layers: FlareLayer[];
145
+ tilesets: TiledTileset[];
146
+ layers: TiledLayer[];
104
147
  }
105
148
  /** Result returned by `convertTiled`. */
106
149
  interface TiledResult {
107
150
  outPath: string;
108
- layers: FlareLayer[];
109
- tilesets: FlareTileset[];
110
- map: FlareMap;
151
+ layers: TiledLayer[];
152
+ tilesets: TiledTileset[];
153
+ map: TiledMap;
111
154
  }
112
155
  //#endregion
113
156
  //#region src/pack-atlas.d.ts
@@ -119,11 +162,14 @@ declare function packAtlas(opts: AtlasPackerOptions): Promise<AtlasResult>;
119
162
  //#endregion
120
163
  //#region src/tiled-to-flare.d.ts
121
164
  /**
122
- * Convert a Tiled `.tmj` JSON map into Flare's normalized runtime format.
123
- * Flattens group layers, resolves external tilesets (when `embedTilesets`),
124
- * and drops image/editor-only layers.
165
+ * Convert a Tiled `.tmj` JSON map into Tiled-shaped runtime JSON, accepted
166
+ * directly by `@flare-engine/tilemap`'s `parseTiled` — this is a pass-through of
167
+ * the original layer/tileset objects (not a re-projection), so `type`,
168
+ * `properties`, tileset `tiles[]`, object `rotation` and layer `offsetx`/`offsety`
169
+ * all survive. Flattens group layers, resolves external tilesets (when
170
+ * `embedTilesets`), and drops image/editor-only layers.
125
171
  */
126
172
  declare function convertTiled(opts: TiledConvertOptions): Promise<TiledResult>;
127
173
  //#endregion
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 };
174
+ export { type AtlasFrame, type AtlasPackerOptions, type AtlasResult, type TiledConvertOptions, type TiledLayer, type TiledMap, type TiledObject, type TiledObjectLayer, type TiledProperty, type TiledResult, type TiledTile, type TiledTileLayer, type TiledTileset, convertTiled, packAtlas };
129
175
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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"}
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;;;;;;;;EAQA;;;UAIe;EACf;EACA;EACA;;;;;;;UAQe;EACf;EACA;EACA;EACA,aAAa;;;UAIE;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,aAAa;;;UAIE;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,aAAa;;;UAIE;EACf;EACA;EACA,SAAS;EACT;EACA;EACA,aAAa;;KAGH,aAAa,iBAAiB;;;;;;UAOzB;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,QAAQ;EACR,aAAa;;;;;EAKb;;;;;;;UAQe;EACf;EACA;EACA;EACA;EACA,UAAU;EACV,QAAQ;;;UAIO;EACf;EACA,QAAQ;EACR,UAAU;EACV,KAAK;;;;;;;;iBCtHe,UAAU,MAAM,qBAAqB,QAAQ;;;;;;;;;;;iBCuG7C,aAAa,MAAM,sBAAsB,QAAQ"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_tiled_to_flare = require("./tiled-to-flare-CEdmaHp_.js");
2
+ const require_tiled_to_flare = require("./tiled-to-flare-cer90bv-.js");
3
3
  exports.convertTiled = require_tiled_to_flare.convertTiled;
4
4
  exports.packAtlas = require_tiled_to_flare.packAtlas;
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as packAtlas, t as convertTiled } from "./tiled-to-flare-Cc-ofNer.mjs";
1
+ import { n as packAtlas, t as convertTiled } from "./tiled-to-flare-CB70UDDG.mjs";
2
2
  export { convertTiled, packAtlas };
@@ -126,12 +126,6 @@ async function packAtlas(opts) {
126
126
  function absPath(p, base) {
127
127
  return isAbsolute(p) ? p : resolve(base, p);
128
128
  }
129
- function propsToRecord(props) {
130
- const out = {};
131
- if (!props) return out;
132
- for (const p of props) out[p.name] = p.value;
133
- return out;
134
- }
135
129
  async function resolveTileset(ref, mapDir, embed) {
136
130
  let data = ref;
137
131
  if (ref.source && embed) {
@@ -141,7 +135,7 @@ async function resolveTileset(ref, mapDir, embed) {
141
135
  firstgid: ref.firstgid
142
136
  };
143
137
  }
144
- return {
138
+ const tileset = {
145
139
  name: data.name ?? "tileset",
146
140
  firstgid: data.firstgid,
147
141
  tilewidth: data.tilewidth ?? 0,
@@ -150,58 +144,66 @@ async function resolveTileset(ref, mapDir, embed) {
150
144
  tilecount: data.tilecount ?? 0,
151
145
  image: data.image ?? "",
152
146
  imagewidth: data.imagewidth ?? 0,
153
- imageheight: data.imageheight ?? 0,
154
- ...ref.source && !embed ? { source: ref.source } : {}
147
+ imageheight: data.imageheight ?? 0
155
148
  };
149
+ if (data.tiles) tileset.tiles = data.tiles;
150
+ if (data.properties) tileset.properties = data.properties;
151
+ if (ref.source && !embed) tileset.source = ref.source;
152
+ return tileset;
156
153
  }
157
154
  function flattenLayers(layers) {
158
155
  const out = [];
159
156
  const walk = (ls) => {
160
157
  for (const l of ls) if (l.type === "group") {
161
- const inner = l.layers;
162
- if (inner) walk(inner);
158
+ if (l.layers) walk(l.layers);
163
159
  } else out.push(l);
164
160
  };
165
161
  walk(layers);
166
162
  return out;
167
163
  }
164
+ /**
165
+ * Route a layer through as Tiled-shaped `TiledLayer`, keeping every field
166
+ * `parseTiled` reads (offsets, properties, and — for objects — rotation, which
167
+ * passes through untouched since `objects` is not re-mapped).
168
+ */
168
169
  function convertLayer(layer) {
169
170
  const visible = layer.visible !== false;
170
171
  const opacity = typeof layer.opacity === "number" ? layer.opacity : 1;
171
- if (layer.type === "tilelayer") return {
172
- kind: "tile",
173
- name: layer.name,
174
- width: layer.width ?? 0,
175
- height: layer.height ?? 0,
176
- data: layer.data ?? [],
177
- visible,
178
- opacity
179
- };
172
+ if (layer.type === "tilelayer") {
173
+ const tile = {
174
+ type: "tilelayer",
175
+ name: layer.name,
176
+ width: layer.width ?? 0,
177
+ height: layer.height ?? 0,
178
+ data: layer.data ?? [],
179
+ visible,
180
+ opacity
181
+ };
182
+ if (layer.offsetx !== void 0) tile.offsetx = layer.offsetx;
183
+ if (layer.offsety !== void 0) tile.offsety = layer.offsety;
184
+ if (layer.properties) tile.properties = layer.properties;
185
+ return tile;
186
+ }
180
187
  if (layer.type === "objectgroup") {
181
- const objects = (layer.objects ?? []).map((o) => ({
182
- id: o.id,
183
- name: o.name ?? "",
184
- type: o.type ?? o.class ?? "",
185
- x: o.x,
186
- y: o.y,
187
- width: o.width,
188
- height: o.height,
189
- properties: propsToRecord(o.properties)
190
- }));
191
- return {
192
- kind: "object",
188
+ const obj = {
189
+ type: "objectgroup",
193
190
  name: layer.name,
194
- objects,
191
+ objects: layer.objects ?? [],
195
192
  visible,
196
193
  opacity
197
194
  };
195
+ if (layer.properties) obj.properties = layer.properties;
196
+ return obj;
198
197
  }
199
198
  return null;
200
199
  }
201
200
  /**
202
- * Convert a Tiled `.tmj` JSON map into Flare's normalized runtime format.
203
- * Flattens group layers, resolves external tilesets (when `embedTilesets`),
204
- * and drops image/editor-only layers.
201
+ * Convert a Tiled `.tmj` JSON map into Tiled-shaped runtime JSON, accepted
202
+ * directly by `@flare-engine/tilemap`'s `parseTiled` — this is a pass-through of
203
+ * the original layer/tileset objects (not a re-projection), so `type`,
204
+ * `properties`, tileset `tiles[]`, object `rotation` and layer `offsetx`/`offsety`
205
+ * all survive. Flattens group layers, resolves external tilesets (when
206
+ * `embedTilesets`), and drops image/editor-only layers.
205
207
  */
206
208
  async function convertTiled(opts) {
207
209
  const inputPath = absPath(opts.input, process.cwd());
@@ -236,4 +238,4 @@ async function convertTiled(opts) {
236
238
  //#endregion
237
239
  export { packAtlas as n, convertTiled as t };
238
240
 
239
- //# sourceMappingURL=tiled-to-flare-Cc-ofNer.mjs.map
241
+ //# sourceMappingURL=tiled-to-flare-CB70UDDG.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tiled-to-flare-CB70UDDG.mjs","names":["absPath"],"sources":["../src/pack-atlas.ts","../src/tiled-to-flare.ts"],"sourcesContent":["import { mkdir, readdir, readFile, writeFile } from 'node:fs/promises';\nimport { basename, extname, isAbsolute, join, resolve } from 'node:path';\nimport { MaxRectsPacker } from 'maxrects-packer';\nimport sharp from 'sharp';\nimport type { AtlasFrame, AtlasPackerOptions, AtlasResult } from './types.js';\n\ninterface SpriteInput {\n name: string;\n path: string;\n width: number;\n height: number;\n}\n\nfunction absPath(p: string): string {\n return isAbsolute(p) ? p : resolve(process.cwd(), p);\n}\n\nasync function listPngs(dir: string): Promise<string[]> {\n const entries = await readdir(dir, { withFileTypes: true });\n const result: string[] = [];\n for (const e of entries) {\n if (!e.isFile()) continue;\n if (extname(e.name).toLowerCase() === '.png') result.push(join(dir, e.name));\n }\n result.sort();\n return result;\n}\n\nasync function readSprite(path: string): Promise<SpriteInput> {\n const meta = await sharp(path).metadata();\n if (!meta.width || !meta.height) {\n throw new Error(`[pack-atlas] unable to read dimensions for ${path}`);\n }\n return {\n name: basename(path, extname(path)),\n path,\n width: meta.width,\n height: meta.height,\n };\n}\n\n/**\n * Pack a directory of PNG sprites into a single TexturePacker-compatible\n * atlas (JSON + image) consumable by `@flare-engine/assets`.\n */\nexport async function packAtlas(opts: AtlasPackerOptions): Promise<AtlasResult> {\n const inputDir = absPath(opts.input);\n const outDir = absPath(opts.out ?? opts.input);\n const name = opts.name ?? 'atlas';\n const padding = opts.padding ?? 2;\n const maxSize = opts.maxSize ?? 2048;\n const format = opts.format ?? 'png';\n\n await mkdir(outDir, { recursive: true });\n\n const files = await listPngs(inputDir);\n if (files.length === 0) {\n throw new Error(`[pack-atlas] no .png files found in ${inputDir}`);\n }\n\n const sprites: SpriteInput[] = [];\n for (const f of files) sprites.push(await readSprite(f));\n\n const packer = new MaxRectsPacker(maxSize, maxSize, padding, {\n smart: true,\n pot: false,\n square: false,\n allowRotation: false,\n tag: false,\n border: 0,\n });\n for (const s of sprites) packer.add(s.width, s.height, s);\n\n if (packer.bins.length !== 1) {\n throw new Error(\n `[pack-atlas] sprites do not fit in a single ${maxSize}x${maxSize} atlas (got ${packer.bins.length} bins)`,\n );\n }\n const bin = packer.bins[0];\n if (!bin) throw new Error('[pack-atlas] packing produced no bin');\n\n const atlasWidth = bin.width;\n const atlasHeight = bin.height;\n\n const frames: AtlasFrame[] = [];\n const composites: { input: Buffer; left: number; top: number }[] = [];\n\n for (const rect of bin.rects) {\n const sprite = rect.data as SpriteInput;\n const buf = await readFile(sprite.path);\n composites.push({ input: buf, left: rect.x, top: rect.y });\n frames.push({\n name: sprite.name,\n x: rect.x,\n y: rect.y,\n w: sprite.width,\n h: sprite.height,\n });\n }\n frames.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));\n\n const imageName = `${name}.${format}`;\n const jsonName = `${name}.json`;\n const imagePath = join(outDir, imageName);\n const jsonPath = join(outDir, jsonName);\n\n let pipeline = sharp({\n create: {\n width: atlasWidth,\n height: atlasHeight,\n channels: 4,\n background: { r: 0, g: 0, b: 0, alpha: 0 },\n },\n }).composite(composites);\n pipeline = format === 'webp' ? pipeline.webp() : pipeline.png();\n await pipeline.toFile(imagePath);\n\n // TexturePacker-compatible JSON (hash format).\n const jsonFrames: Record<string, { frame: { x: number; y: number; w: number; h: number } }> = {};\n for (const f of frames) {\n jsonFrames[f.name] = { frame: { x: f.x, y: f.y, w: f.w, h: f.h } };\n }\n const jsonDoc = {\n frames: jsonFrames,\n meta: {\n app: '@flare-engine/cli',\n version: '1.0',\n image: imageName,\n format: 'RGBA8888',\n size: { w: atlasWidth, h: atlasHeight },\n scale: '1',\n },\n };\n await writeFile(jsonPath, `${JSON.stringify(jsonDoc, null, 2)}\\n`, 'utf8');\n\n return {\n jsonPath,\n imagePath,\n frames,\n width: atlasWidth,\n height: atlasHeight,\n };\n}\n","import { readFile, writeFile } from 'node:fs/promises';\nimport { basename, dirname, isAbsolute, join, resolve } from 'node:path';\nimport type {\n TiledConvertOptions,\n TiledLayer,\n TiledMap,\n TiledObject,\n TiledObjectLayer,\n TiledProperty,\n TiledResult,\n TiledTile,\n TiledTileLayer,\n TiledTileset,\n} from './types.js';\n\n/** Raw layer shape as Tiled writes it — a superset covering group/image layers, which are dropped. */\ninterface RawTiledLayer {\n type: 'tilelayer' | 'objectgroup' | 'imagelayer' | 'group';\n name: string;\n visible?: boolean;\n opacity?: number;\n width?: number;\n height?: number;\n data?: number[];\n objects?: TiledObject[];\n offsetx?: number;\n offsety?: number;\n properties?: TiledProperty[];\n layers?: RawTiledLayer[];\n}\n\ninterface RawTiledTilesetRef {\n firstgid: number;\n source?: string;\n name?: string;\n tilewidth?: number;\n tileheight?: number;\n columns?: number;\n tilecount?: number;\n image?: string;\n imagewidth?: number;\n imageheight?: number;\n tiles?: TiledTile[];\n properties?: TiledProperty[];\n}\n\ninterface RawTiledMap {\n width: number;\n height: number;\n tilewidth: number;\n tileheight: number;\n layers: RawTiledLayer[];\n tilesets: RawTiledTilesetRef[];\n}\n\nfunction absPath(p: string, base: string): string {\n return isAbsolute(p) ? p : resolve(base, p);\n}\n\nasync function resolveTileset(\n ref: RawTiledTilesetRef,\n mapDir: string,\n embed: boolean,\n): Promise<TiledTileset> {\n let data: RawTiledTilesetRef = ref;\n if (ref.source && embed) {\n const srcPath = absPath(ref.source, mapDir);\n const raw = await readFile(srcPath, 'utf8');\n const external = JSON.parse(raw) as RawTiledTilesetRef;\n data = { ...external, firstgid: ref.firstgid };\n }\n const tileset: TiledTileset = {\n name: data.name ?? 'tileset',\n firstgid: data.firstgid,\n tilewidth: data.tilewidth ?? 0,\n tileheight: data.tileheight ?? 0,\n columns: data.columns ?? 0,\n tilecount: data.tilecount ?? 0,\n image: data.image ?? '',\n imagewidth: data.imagewidth ?? 0,\n imageheight: data.imageheight ?? 0,\n };\n if (data.tiles) tileset.tiles = data.tiles;\n if (data.properties) tileset.properties = data.properties;\n if (ref.source && !embed) tileset.source = ref.source;\n return tileset;\n}\n\nfunction flattenLayers(layers: RawTiledLayer[]): RawTiledLayer[] {\n const out: RawTiledLayer[] = [];\n const walk = (ls: RawTiledLayer[]): void => {\n for (const l of ls) {\n if (l.type === 'group') {\n if (l.layers) walk(l.layers);\n } else {\n out.push(l);\n }\n }\n };\n walk(layers);\n return out;\n}\n\n/**\n * Route a layer through as Tiled-shaped `TiledLayer`, keeping every field\n * `parseTiled` reads (offsets, properties, and — for objects — rotation, which\n * passes through untouched since `objects` is not re-mapped).\n */\nfunction convertLayer(layer: RawTiledLayer): TiledLayer | null {\n const visible = layer.visible !== false;\n const opacity = typeof layer.opacity === 'number' ? layer.opacity : 1;\n if (layer.type === 'tilelayer') {\n const tile: TiledTileLayer = {\n type: 'tilelayer',\n name: layer.name,\n width: layer.width ?? 0,\n height: layer.height ?? 0,\n data: layer.data ?? [],\n visible,\n opacity,\n };\n if (layer.offsetx !== undefined) tile.offsetx = layer.offsetx;\n if (layer.offsety !== undefined) tile.offsety = layer.offsety;\n if (layer.properties) tile.properties = layer.properties;\n return tile;\n }\n if (layer.type === 'objectgroup') {\n const obj: TiledObjectLayer = {\n type: 'objectgroup',\n name: layer.name,\n objects: layer.objects ?? [],\n visible,\n opacity,\n };\n if (layer.properties) obj.properties = layer.properties;\n return obj;\n }\n return null;\n}\n\n/**\n * Convert a Tiled `.tmj` JSON map into Tiled-shaped runtime JSON, accepted\n * directly by `@flare-engine/tilemap`'s `parseTiled` — this is a pass-through of\n * the original layer/tileset objects (not a re-projection), so `type`,\n * `properties`, tileset `tiles[]`, object `rotation` and layer `offsetx`/`offsety`\n * all survive. Flattens group layers, resolves external tilesets (when\n * `embedTilesets`), and drops image/editor-only layers.\n */\nexport async function convertTiled(opts: TiledConvertOptions): Promise<TiledResult> {\n const inputPath = absPath(opts.input, process.cwd());\n const outPath = opts.out\n ? absPath(opts.out, process.cwd())\n : join(dirname(inputPath), `${basename(inputPath).replace(/\\.(tmj|json)$/i, '')}.flare.json`);\n const embed = opts.embedTilesets !== false;\n\n const raw = await readFile(inputPath, 'utf8');\n const parsed = JSON.parse(raw) as RawTiledMap;\n const mapDir = dirname(inputPath);\n\n const tilesets: TiledTileset[] = [];\n for (const ref of parsed.tilesets ?? []) {\n tilesets.push(await resolveTileset(ref, mapDir, embed));\n }\n\n const layers: TiledLayer[] = [];\n for (const l of flattenLayers(parsed.layers ?? [])) {\n const converted = convertLayer(l);\n if (converted) layers.push(converted);\n }\n\n const map: TiledMap = {\n width: parsed.width,\n height: parsed.height,\n tilewidth: parsed.tilewidth,\n tileheight: parsed.tileheight,\n tilesets,\n layers,\n };\n\n await writeFile(outPath, `${JSON.stringify(map, null, 2)}\\n`, 'utf8');\n return { outPath, layers, tilesets, map };\n}\n"],"mappings":";;;;;AAaA,SAASA,UAAQ,GAAmB;CAClC,OAAO,WAAW,CAAC,IAAI,IAAI,QAAQ,QAAQ,IAAI,GAAG,CAAC;AACrD;AAEA,eAAe,SAAS,KAAgC;CACtD,MAAM,UAAU,MAAM,QAAQ,KAAK,EAAE,eAAe,KAAK,CAAC;CAC1D,MAAM,SAAmB,CAAC;CAC1B,KAAK,MAAM,KAAK,SAAS;EACvB,IAAI,CAAC,EAAE,OAAO,GAAG;EACjB,IAAI,QAAQ,EAAE,IAAI,CAAC,CAAC,YAAY,MAAM,QAAQ,OAAO,KAAK,KAAK,KAAK,EAAE,IAAI,CAAC;CAC7E;CACA,OAAO,KAAK;CACZ,OAAO;AACT;AAEA,eAAe,WAAW,MAAoC;CAC5D,MAAM,OAAO,MAAM,MAAM,IAAI,CAAC,CAAC,SAAS;CACxC,IAAI,CAAC,KAAK,SAAS,CAAC,KAAK,QACvB,MAAM,IAAI,MAAM,8CAA8C,MAAM;CAEtE,OAAO;EACL,MAAM,SAAS,MAAM,QAAQ,IAAI,CAAC;EAClC;EACA,OAAO,KAAK;EACZ,QAAQ,KAAK;CACf;AACF;;;;;AAMA,eAAsB,UAAU,MAAgD;CAC9E,MAAM,WAAWA,UAAQ,KAAK,KAAK;CACnC,MAAM,SAASA,UAAQ,KAAK,OAAO,KAAK,KAAK;CAC7C,MAAM,OAAO,KAAK,QAAQ;CAC1B,MAAM,UAAU,KAAK,WAAW;CAChC,MAA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AAiD;CAClF,MAAM,YAAY,QAAQ,KAAK,OAAO,QAAQ,IAAI,CAAC;CACnD,MAAM,UAAU,KAAK,MACjB,QAAQ,KAAK,KAAK,QAAQ,IAAI,CAAC,IAC/B,KAAK,QAAQ,SAAS,GAAG,GAAG,SAAS,SAAS,CAAC,CAAC,QAAQ,kBAAkB,EAAE,EAAE,YAAY;CAC9F,MAAM,QAAQ,KAAK,kBAAkB;CAErC,MAAM,MAAM,MAAM,SAAS,WAAW,MAAM;CAC5C,MAAM,SAAS,KAAK,MAAM,GAAG;CAC7B,MAAM,SAAS,QAAQ,SAAS;CAEhC,MAAM,WAA2B,CAAC;CAClC,KAAK,MAAM,OAAO,OAAO,YAAY,CAAC,GACpC,SAAS,KAAK,MAAM,eAAe,KAAK,QAAQ,KAAK,CAAC;CAGxD,MAAM,SAAuB,CAAC;CAC9B,KAAK,MAAM,KAAK,cAAc,OAAO,UAAU,CAAC,CAAC,GAAG;EAClD,MAAM,YAAY,aAAa,CAAC;EAChC,IAAI,WAAW,OAAO,KAAK,SAAS;CACtC;CAEA,MAAM,MAAgB;EACpB,OAAO,OAAO;EACd,QAAQ,OAAO;EACf,WAAW,OAAO;EAClB,YAAY,OAAO;EACnB;EACA;CACF;CAEA,MAAM,UAAU,SAAS,GAAG,KAAK,UAAU,KAAK,MAAM,CAAC,EAAE,KAAK,MAAM;CACpE,OAAO;EAAE;EAAS;EAAQ;EAAU;CAAI;AAC1C"}
@@ -149,12 +149,6 @@ async function packAtlas(opts) {
149
149
  function absPath(p, base) {
150
150
  return (0, node_path.isAbsolute)(p) ? p : (0, node_path.resolve)(base, p);
151
151
  }
152
- function propsToRecord(props) {
153
- const out = {};
154
- if (!props) return out;
155
- for (const p of props) out[p.name] = p.value;
156
- return out;
157
- }
158
152
  async function resolveTileset(ref, mapDir, embed) {
159
153
  let data = ref;
160
154
  if (ref.source && embed) {
@@ -164,7 +158,7 @@ async function resolveTileset(ref, mapDir, embed) {
164
158
  firstgid: ref.firstgid
165
159
  };
166
160
  }
167
- return {
161
+ const tileset = {
168
162
  name: data.name ?? "tileset",
169
163
  firstgid: data.firstgid,
170
164
  tilewidth: data.tilewidth ?? 0,
@@ -173,58 +167,66 @@ async function resolveTileset(ref, mapDir, embed) {
173
167
  tilecount: data.tilecount ?? 0,
174
168
  image: data.image ?? "",
175
169
  imagewidth: data.imagewidth ?? 0,
176
- imageheight: data.imageheight ?? 0,
177
- ...ref.source && !embed ? { source: ref.source } : {}
170
+ imageheight: data.imageheight ?? 0
178
171
  };
172
+ if (data.tiles) tileset.tiles = data.tiles;
173
+ if (data.properties) tileset.properties = data.properties;
174
+ if (ref.source && !embed) tileset.source = ref.source;
175
+ return tileset;
179
176
  }
180
177
  function flattenLayers(layers) {
181
178
  const out = [];
182
179
  const walk = (ls) => {
183
180
  for (const l of ls) if (l.type === "group") {
184
- const inner = l.layers;
185
- if (inner) walk(inner);
181
+ if (l.layers) walk(l.layers);
186
182
  } else out.push(l);
187
183
  };
188
184
  walk(layers);
189
185
  return out;
190
186
  }
187
+ /**
188
+ * Route a layer through as Tiled-shaped `TiledLayer`, keeping every field
189
+ * `parseTiled` reads (offsets, properties, and — for objects — rotation, which
190
+ * passes through untouched since `objects` is not re-mapped).
191
+ */
191
192
  function convertLayer(layer) {
192
193
  const visible = layer.visible !== false;
193
194
  const opacity = typeof layer.opacity === "number" ? layer.opacity : 1;
194
- if (layer.type === "tilelayer") return {
195
- kind: "tile",
196
- name: layer.name,
197
- width: layer.width ?? 0,
198
- height: layer.height ?? 0,
199
- data: layer.data ?? [],
200
- visible,
201
- opacity
202
- };
195
+ if (layer.type === "tilelayer") {
196
+ const tile = {
197
+ type: "tilelayer",
198
+ name: layer.name,
199
+ width: layer.width ?? 0,
200
+ height: layer.height ?? 0,
201
+ data: layer.data ?? [],
202
+ visible,
203
+ opacity
204
+ };
205
+ if (layer.offsetx !== void 0) tile.offsetx = layer.offsetx;
206
+ if (layer.offsety !== void 0) tile.offsety = layer.offsety;
207
+ if (layer.properties) tile.properties = layer.properties;
208
+ return tile;
209
+ }
203
210
  if (layer.type === "objectgroup") {
204
- const objects = (layer.objects ?? []).map((o) => ({
205
- id: o.id,
206
- name: o.name ?? "",
207
- type: o.type ?? o.class ?? "",
208
- x: o.x,
209
- y: o.y,
210
- width: o.width,
211
- height: o.height,
212
- properties: propsToRecord(o.properties)
213
- }));
214
- return {
215
- kind: "object",
211
+ const obj = {
212
+ type: "objectgroup",
216
213
  name: layer.name,
217
- objects,
214
+ objects: layer.objects ?? [],
218
215
  visible,
219
216
  opacity
220
217
  };
218
+ if (layer.properties) obj.properties = layer.properties;
219
+ return obj;
221
220
  }
222
221
  return null;
223
222
  }
224
223
  /**
225
- * Convert a Tiled `.tmj` JSON map into Flare's normalized runtime format.
226
- * Flattens group layers, resolves external tilesets (when `embedTilesets`),
227
- * and drops image/editor-only layers.
224
+ * Convert a Tiled `.tmj` JSON map into Tiled-shaped runtime JSON, accepted
225
+ * directly by `@flare-engine/tilemap`'s `parseTiled` — this is a pass-through of
226
+ * the original layer/tileset objects (not a re-projection), so `type`,
227
+ * `properties`, tileset `tiles[]`, object `rotation` and layer `offsetx`/`offsety`
228
+ * all survive. Flattens group layers, resolves external tilesets (when
229
+ * `embedTilesets`), and drops image/editor-only layers.
228
230
  */
229
231
  async function convertTiled(opts) {
230
232
  const inputPath = absPath(opts.input, process.cwd());
@@ -270,4 +272,4 @@ Object.defineProperty(exports, "packAtlas", {
270
272
  }
271
273
  });
272
274
 
273
- //# sourceMappingURL=tiled-to-flare-CEdmaHp_.js.map
275
+ //# sourceMappingURL=tiled-to-flare-cer90bv-.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tiled-to-flare-cer90bv-.js","names":["absPath","MaxRectsPacker"],"sources":["../src/pack-atlas.ts","../src/tiled-to-flare.ts"],"sourcesContent":["import { mkdir, readdir, readFile, writeFile } from 'node:fs/promises';\nimport { basename, extname, isAbsolute, join, resolve } from 'node:path';\nimport { MaxRectsPacker } from 'maxrects-packer';\nimport sharp from 'sharp';\nimport type { AtlasFrame, AtlasPackerOptions, AtlasResult } from './types.js';\n\ninterface SpriteInput {\n name: string;\n path: string;\n width: number;\n height: number;\n}\n\nfunction absPath(p: string): string {\n return isAbsolute(p) ? p : resolve(process.cwd(), p);\n}\n\nasync function listPngs(dir: string): Promise<string[]> {\n const entries = await readdir(dir, { withFileTypes: true });\n const result: string[] = [];\n for (const e of entries) {\n if (!e.isFile()) continue;\n if (extname(e.name).toLowerCase() === '.png') result.push(join(dir, e.name));\n }\n result.sort();\n return result;\n}\n\nasync function readSprite(path: string): Promise<SpriteInput> {\n const meta = await sharp(path).metadata();\n if (!meta.width || !meta.height) {\n throw new Error(`[pack-atlas] unable to read dimensions for ${path}`);\n }\n return {\n name: basename(path, extname(path)),\n path,\n width: meta.width,\n height: meta.height,\n };\n}\n\n/**\n * Pack a directory of PNG sprites into a single TexturePacker-compatible\n * atlas (JSON + image) consumable by `@flare-engine/assets`.\n */\nexport async function packAtlas(opts: AtlasPackerOptions): Promise<AtlasResult> {\n const inputDir = absPath(opts.input);\n const outDir = absPath(opts.out ?? opts.input);\n const name = opts.name ?? 'atlas';\n const padding = opts.padding ?? 2;\n const maxSize = opts.maxSize ?? 2048;\n const format = opts.format ?? 'png';\n\n await mkdir(outDir, { recursive: true });\n\n const files = await listPngs(inputDir);\n if (files.length === 0) {\n throw new Error(`[pack-atlas] no .png files found in ${inputDir}`);\n }\n\n const sprites: SpriteInput[] = [];\n for (const f of files) sprites.push(await readSprite(f));\n\n const packer = new MaxRectsPacker(maxSize, maxSize, padding, {\n smart: true,\n pot: false,\n square: false,\n allowRotation: false,\n tag: false,\n border: 0,\n });\n for (const s of sprites) packer.add(s.width, s.height, s);\n\n if (packer.bins.length !== 1) {\n throw new Error(\n `[pack-atlas] sprites do not fit in a single ${maxSize}x${maxSize} atlas (got ${packer.bins.length} bins)`,\n );\n }\n const bin = packer.bins[0];\n if (!bin) throw new Error('[pack-atlas] packing produced no bin');\n\n const atlasWidth = bin.width;\n const atlasHeight = bin.height;\n\n const frames: AtlasFrame[] = [];\n const composites: { input: Buffer; left: number; top: number }[] = [];\n\n for (const rect of bin.rects) {\n const sprite = rect.data as SpriteInput;\n const buf = await readFile(sprite.path);\n composites.push({ input: buf, left: rect.x, top: rect.y });\n frames.push({\n name: sprite.name,\n x: rect.x,\n y: rect.y,\n w: sprite.width,\n h: sprite.height,\n });\n }\n frames.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));\n\n const imageName = `${name}.${format}`;\n const jsonName = `${name}.json`;\n const imagePath = join(outDir, imageName);\n const jsonPath = join(outDir, jsonName);\n\n let pipeline = sharp({\n create: {\n width: atlasWidth,\n height: atlasHeight,\n channels: 4,\n background: { r: 0, g: 0, b: 0, alpha: 0 },\n },\n }).composite(composites);\n pipeline = format === 'webp' ? pipeline.webp() : pipeline.png();\n await pipeline.toFile(imagePath);\n\n // TexturePacker-compatible JSON (hash format).\n const jsonFrames: Record<string, { frame: { x: number; y: number; w: number; h: number } }> = {};\n for (const f of frames) {\n jsonFrames[f.name] = { frame: { x: f.x, y: f.y, w: f.w, h: f.h } };\n }\n const jsonDoc = {\n frames: jsonFrames,\n meta: {\n app: '@flare-engine/cli',\n version: '1.0',\n image: imageName,\n format: 'RGBA8888',\n size: { w: atlasWidth, h: atlasHeight },\n scale: '1',\n },\n };\n await writeFile(jsonPath, `${JSON.stringify(jsonDoc, null, 2)}\\n`, 'utf8');\n\n return {\n jsonPath,\n imagePath,\n frames,\n width: atlasWidth,\n height: atlasHeight,\n };\n}\n","import { readFile, writeFile } from 'node:fs/promises';\nimport { basename, dirname, isAbsolute, join, resolve } from 'node:path';\nimport type {\n TiledConvertOptions,\n TiledLayer,\n TiledMap,\n TiledObject,\n TiledObjectLayer,\n TiledProperty,\n TiledResult,\n TiledTile,\n TiledTileLayer,\n TiledTileset,\n} from './types.js';\n\n/** Raw layer shape as Tiled writes it — a superset covering group/image layers, which are dropped. */\ninterface RawTiledLayer {\n type: 'tilelayer' | 'objectgroup' | 'imagelayer' | 'group';\n name: string;\n visible?: boolean;\n opacity?: number;\n width?: number;\n height?: number;\n data?: number[];\n objects?: TiledObject[];\n offsetx?: number;\n offsety?: number;\n properties?: TiledProperty[];\n layers?: RawTiledLayer[];\n}\n\ninterface RawTiledTilesetRef {\n firstgid: number;\n source?: string;\n name?: string;\n tilewidth?: number;\n tileheight?: number;\n columns?: number;\n tilecount?: number;\n image?: string;\n imagewidth?: number;\n imageheight?: number;\n tiles?: TiledTile[];\n properties?: TiledProperty[];\n}\n\ninterface RawTiledMap {\n width: number;\n height: number;\n tilewidth: number;\n tileheight: number;\n layers: RawTiledLayer[];\n tilesets: RawTiledTilesetRef[];\n}\n\nfunction absPath(p: string, base: string): string {\n return isAbsolute(p) ? p : resolve(base, p);\n}\n\nasync function resolveTileset(\n ref: RawTiledTilesetRef,\n mapDir: string,\n embed: boolean,\n): Promise<TiledTileset> {\n let data: RawTiledTilesetRef = ref;\n if (ref.source && embed) {\n const srcPath = absPath(ref.source, mapDir);\n const raw = await readFile(srcPath, 'utf8');\n const external = JSON.parse(raw) as RawTiledTilesetRef;\n data = { ...external, firstgid: ref.firstgid };\n }\n const tileset: TiledTileset = {\n name: data.name ?? 'tileset',\n firstgid: data.firstgid,\n tilewidth: data.tilewidth ?? 0,\n tileheight: data.tileheight ?? 0,\n columns: data.columns ?? 0,\n tilecount: data.tilecount ?? 0,\n image: data.image ?? '',\n imagewidth: data.imagewidth ?? 0,\n imageheight: data.imageheight ?? 0,\n };\n if (data.tiles) tileset.tiles = data.tiles;\n if (data.properties) tileset.properties = data.properties;\n if (ref.source && !embed) tileset.source = ref.source;\n return tileset;\n}\n\nfunction flattenLayers(layers: RawTiledLayer[]): RawTiledLayer[] {\n const out: RawTiledLayer[] = [];\n const walk = (ls: RawTiledLayer[]): void => {\n for (const l of ls) {\n if (l.type === 'group') {\n if (l.layers) walk(l.layers);\n } else {\n out.push(l);\n }\n }\n };\n walk(layers);\n return out;\n}\n\n/**\n * Route a layer through as Tiled-shaped `TiledLayer`, keeping every field\n * `parseTiled` reads (offsets, properties, and — for objects — rotation, which\n * passes through untouched since `objects` is not re-mapped).\n */\nfunction convertLayer(layer: RawTiledLayer): TiledLayer | null {\n const visible = layer.visible !== false;\n const opacity = typeof layer.opacity === 'number' ? layer.opacity : 1;\n if (layer.type === 'tilelayer') {\n const tile: TiledTileLayer = {\n type: 'tilelayer',\n name: layer.name,\n width: layer.width ?? 0,\n height: layer.height ?? 0,\n data: layer.data ?? [],\n visible,\n opacity,\n };\n if (layer.offsetx !== undefined) tile.offsetx = layer.offsetx;\n if (layer.offsety !== undefined) tile.offsety = layer.offsety;\n if (layer.properties) tile.properties = layer.properties;\n return tile;\n }\n if (layer.type === 'objectgroup') {\n const obj: TiledObjectLayer = {\n type: 'objectgroup',\n name: layer.name,\n objects: layer.objects ?? [],\n visible,\n opacity,\n };\n if (layer.properties) obj.properties = layer.properties;\n return obj;\n }\n return null;\n}\n\n/**\n * Convert a Tiled `.tmj` JSON map into Tiled-shaped runtime JSON, accepted\n * directly by `@flare-engine/tilemap`'s `parseTiled` — this is a pass-through of\n * the original layer/tileset objects (not a re-projection), so `type`,\n * `properties`, tileset `tiles[]`, object `rotation` and layer `offsetx`/`offsety`\n * all survive. Flattens group layers, resolves external tilesets (when\n * `embedTilesets`), and drops image/editor-only layers.\n */\nexport async function convertTiled(opts: TiledConvertOptions): Promise<TiledResult> {\n const inputPath = absPath(opts.input, process.cwd());\n const outPath = opts.out\n ? absPath(opts.out, process.cwd())\n : join(dirname(inputPath), `${basename(inputPath).replace(/\\.(tmj|json)$/i, '')}.flare.json`);\n const embed = opts.embedTilesets !== false;\n\n const raw = await readFile(inputPath, 'utf8');\n const parsed = JSON.parse(raw) as RawTiledMap;\n const mapDir = dirname(inputPath);\n\n const tilesets: TiledTileset[] = [];\n for (const ref of parsed.tilesets ?? []) {\n tilesets.push(await resolveTileset(ref, mapDir, embed));\n }\n\n const layers: TiledLayer[] = [];\n for (const l of flattenLayers(parsed.layers ?? [])) {\n const converted = convertLayer(l);\n if (converted) layers.push(converted);\n }\n\n const map: TiledMap = {\n width: parsed.width,\n height: parsed.height,\n tilewidth: parsed.tilewidth,\n tileheight: parsed.tileheight,\n tilesets,\n layers,\n };\n\n await writeFile(outPath, `${JSON.stringify(map, null, 2)}\\n`, 'utf8');\n return { outPath, layers, tilesets, map };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,SAASA,UAAQ,GAAmB;CAClC,QAAA,GAAA,UAAA,WAAA,CAAkB,CAAC,IAAI,KAAA,GAAA,UAAA,QAAA,CAAY,QAAQ,IAAI,GAAG,CAAC;AACrD;AAEA,eAAe,SAAS,KAAgC;CACtD,MAAM,UAAU,OAAA,GAAA,iBAAA,QAAA,CAAc,KAAK,EAAE,eAAe,KAAK,CAAC;CAC1D,MAAM,SAAmB,CAAC;CAC1B,KAAK,MAAM,KAAK,SAAS;EACvB,IAAI,CAAC,EAAE,OAAO,GAAG;EACjB,KAAA,GAAA,UAAA,QAAA,CAAY,EAAE,IAAI,CAAC,CAAC,YAAY,MAAM,QAAQ,OAAO,MAAA,GAAA,UAAA,KAAA,CAAU,KAAK,EAAE,IAAI,CAAC;CAC7E;CACA,OAAO,KAAK;CACZ,OAAO;AACT;AAEA,eAAe,WAAW,MAAoC;CAC5D,MAAM,OAAO,OAAA,GAAA,MAAA,QAAA,CAAY,IAAI,CAAC,CAAC,SAAS;CACxC,IAAI,CAAC,KAAK,SAAS,CAAC,KAAK,QACvB,MAAM,IAAI,MAAM,8CAA8C,MAAM;CAEtE,OAAO;EACL,OAAA,GAAA,UAAA,SAAA,CAAe,OAAA,GAAA,UAAA,QAAA,CAAc,IAAI,CAAC;EAClC;EACA,OAAO,KAAK;EACZ,QAAQ,KAAK;CACf;AACF;;;;;AAMA,eAAsB,UAAU,MAAgD;CAC9E,MAAM,WAAWA,UAAQ,KAAK,KAAK;CACnC,MAAM,SAASA,UAAQ,KAAK,OAAO,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AAE;EAAS;EAAQ;EAAU;CAAI;AAC1C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flare-engine/cli",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Flare engine CLI — pack-atlas, tiled-to-flare, new app scaffolder",
5
5
  "keywords": ["flare-engine", "cli", "atlas", "tiled", "sprite-sheet", "scaffold"],
6
6
  "license": "Apache-2.0",
@@ -39,6 +39,9 @@
39
39
  "lint": "biome check src/",
40
40
  "typecheck": "tsc --noEmit"
41
41
  },
42
+ "devDependencies": {
43
+ "@flare-engine/tilemap": "^0.4.0"
44
+ },
42
45
  "dependencies": {
43
46
  "commander": "^13.1.0",
44
47
  "maxrects-packer": "^2.7.3",
@@ -1 +0,0 @@
1
- {"version":3,"file":"tiled-to-flare-CEdmaHp_.js","names":["absPath","MaxRectsPacker"],"sources":["../src/pack-atlas.ts","../src/tiled-to-flare.ts"],"sourcesContent":["import { mkdir, readdir, readFile, writeFile } from 'node:fs/promises';\nimport { basename, extname, isAbsolute, join, resolve } from 'node:path';\nimport { MaxRectsPacker } from 'maxrects-packer';\nimport sharp from 'sharp';\nimport type { AtlasFrame, AtlasPackerOptions, AtlasResult } from './types.js';\n\ninterface SpriteInput {\n name: string;\n path: string;\n width: number;\n height: number;\n}\n\nfunction absPath(p: string): string {\n return isAbsolute(p) ? p : resolve(process.cwd(), p);\n}\n\nasync function listPngs(dir: string): Promise<string[]> {\n const entries = await readdir(dir, { withFileTypes: true });\n const result: string[] = [];\n for (const e of entries) {\n if (!e.isFile()) continue;\n if (extname(e.name).toLowerCase() === '.png') result.push(join(dir, e.name));\n }\n result.sort();\n return result;\n}\n\nasync function readSprite(path: string): Promise<SpriteInput> {\n const meta = await sharp(path).metadata();\n if (!meta.width || !meta.height) {\n throw new Error(`[pack-atlas] unable to read dimensions for ${path}`);\n }\n return {\n name: basename(path, extname(path)),\n path,\n width: meta.width,\n height: meta.height,\n };\n}\n\n/**\n * Pack a directory of PNG sprites into a single TexturePacker-compatible\n * atlas (JSON + image) consumable by `@flare-engine/assets`.\n */\nexport async function packAtlas(opts: AtlasPackerOptions): Promise<AtlasResult> {\n const inputDir = absPath(opts.input);\n const outDir = absPath(opts.out ?? opts.input);\n const name = opts.name ?? 'atlas';\n const padding = opts.padding ?? 2;\n const maxSize = opts.maxSize ?? 2048;\n const format = opts.format ?? 'png';\n\n await mkdir(outDir, { recursive: true });\n\n const files = await listPngs(inputDir);\n if (files.length === 0) {\n throw new Error(`[pack-atlas] no .png files found in ${inputDir}`);\n }\n\n const sprites: SpriteInput[] = [];\n for (const f of files) sprites.push(await readSprite(f));\n\n const packer = new MaxRectsPacker(maxSize, maxSize, padding, {\n smart: true,\n pot: false,\n square: false,\n allowRotation: false,\n tag: false,\n border: 0,\n });\n for (const s of sprites) packer.add(s.width, s.height, s);\n\n if (packer.bins.length !== 1) {\n throw new Error(\n `[pack-atlas] sprites do not fit in a single ${maxSize}x${maxSize} atlas (got ${packer.bins.length} bins)`,\n );\n }\n const bin = packer.bins[0];\n if (!bin) throw new Error('[pack-atlas] packing produced no bin');\n\n const atlasWidth = bin.width;\n const atlasHeight = bin.height;\n\n const frames: AtlasFrame[] = [];\n const composites: { input: Buffer; left: number; top: number }[] = [];\n\n for (const rect of bin.rects) {\n const sprite = rect.data as SpriteInput;\n const buf = await readFile(sprite.path);\n composites.push({ input: buf, left: rect.x, top: rect.y });\n frames.push({\n name: sprite.name,\n x: rect.x,\n y: rect.y,\n w: sprite.width,\n h: sprite.height,\n });\n }\n frames.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));\n\n const imageName = `${name}.${format}`;\n const jsonName = `${name}.json`;\n const imagePath = join(outDir, imageName);\n const jsonPath = join(outDir, jsonName);\n\n let pipeline = sharp({\n create: {\n width: atlasWidth,\n height: atlasHeight,\n channels: 4,\n background: { r: 0, g: 0, b: 0, alpha: 0 },\n },\n }).composite(composites);\n pipeline = format === 'webp' ? pipeline.webp() : pipeline.png();\n await pipeline.toFile(imagePath);\n\n // TexturePacker-compatible JSON (hash format).\n const jsonFrames: Record<string, { frame: { x: number; y: number; w: number; h: number } }> = {};\n for (const f of frames) {\n jsonFrames[f.name] = { frame: { x: f.x, y: f.y, w: f.w, h: f.h } };\n }\n const jsonDoc = {\n frames: jsonFrames,\n meta: {\n app: '@flare-engine/cli',\n version: '1.0',\n image: imageName,\n format: 'RGBA8888',\n size: { w: atlasWidth, h: atlasHeight },\n scale: '1',\n },\n };\n await writeFile(jsonPath, `${JSON.stringify(jsonDoc, null, 2)}\\n`, 'utf8');\n\n return {\n jsonPath,\n imagePath,\n frames,\n width: atlasWidth,\n height: atlasHeight,\n };\n}\n","import { readFile, writeFile } from 'node:fs/promises';\nimport { basename, dirname, isAbsolute, join, resolve } from 'node:path';\nimport type {\n FlareLayer,\n FlareMap,\n FlareObject,\n FlareObjectLayer,\n FlareTileLayer,\n FlareTileset,\n TiledConvertOptions,\n TiledResult,\n} from './types.js';\n\ninterface TiledProperty {\n name: string;\n type?: string;\n value: string | number | boolean;\n}\n\ninterface TiledObject {\n id: number;\n name?: string;\n type?: string;\n class?: string;\n x: number;\n y: number;\n width: number;\n height: number;\n visible?: boolean;\n properties?: TiledProperty[];\n}\n\ninterface TiledLayer {\n type: 'tilelayer' | 'objectgroup' | 'imagelayer' | 'group';\n name: string;\n visible?: boolean;\n opacity?: number;\n width?: number;\n height?: number;\n data?: number[];\n objects?: TiledObject[];\n}\n\ninterface TiledTilesetRef {\n firstgid: number;\n source?: string;\n name?: string;\n tilewidth?: number;\n tileheight?: number;\n columns?: number;\n tilecount?: number;\n image?: string;\n imagewidth?: number;\n imageheight?: number;\n}\n\ninterface TiledMap {\n width: number;\n height: number;\n tilewidth: number;\n tileheight: number;\n layers: TiledLayer[];\n tilesets: TiledTilesetRef[];\n}\n\nfunction absPath(p: string, base: string): string {\n return isAbsolute(p) ? p : resolve(base, p);\n}\n\nfunction propsToRecord(\n props: TiledProperty[] | undefined,\n): Record<string, string | number | boolean> {\n const out: Record<string, string | number | boolean> = {};\n if (!props) return out;\n for (const p of props) out[p.name] = p.value;\n return out;\n}\n\nasync function resolveTileset(\n ref: TiledTilesetRef,\n mapDir: string,\n embed: boolean,\n): Promise<FlareTileset> {\n let data: TiledTilesetRef = ref;\n if (ref.source && embed) {\n const srcPath = absPath(ref.source, mapDir);\n const raw = await readFile(srcPath, 'utf8');\n const external = JSON.parse(raw) as TiledTilesetRef;\n data = { ...external, firstgid: ref.firstgid };\n }\n return {\n name: data.name ?? 'tileset',\n firstgid: data.firstgid,\n tilewidth: data.tilewidth ?? 0,\n tileheight: data.tileheight ?? 0,\n columns: data.columns ?? 0,\n tilecount: data.tilecount ?? 0,\n image: data.image ?? '',\n imagewidth: data.imagewidth ?? 0,\n imageheight: data.imageheight ?? 0,\n ...(ref.source && !embed ? { source: ref.source } : {}),\n };\n}\n\nfunction flattenLayers(layers: TiledLayer[]): TiledLayer[] {\n const out: TiledLayer[] = [];\n const walk = (ls: TiledLayer[]): void => {\n for (const l of ls) {\n if (l.type === 'group') {\n const inner = (l as unknown as { layers?: TiledLayer[] }).layers;\n if (inner) walk(inner);\n } else {\n out.push(l);\n }\n }\n };\n walk(layers);\n return out;\n}\n\nfunction convertLayer(layer: TiledLayer): FlareLayer | null {\n const visible = layer.visible !== false;\n const opacity = typeof layer.opacity === 'number' ? layer.opacity : 1;\n if (layer.type === 'tilelayer') {\n const tile: FlareTileLayer = {\n kind: 'tile',\n name: layer.name,\n width: layer.width ?? 0,\n height: layer.height ?? 0,\n data: layer.data ?? [],\n visible,\n opacity,\n };\n return tile;\n }\n if (layer.type === 'objectgroup') {\n const objects: FlareObject[] = (layer.objects ?? []).map((o) => ({\n id: o.id,\n name: o.name ?? '',\n type: o.type ?? o.class ?? '',\n x: o.x,\n y: o.y,\n width: o.width,\n height: o.height,\n properties: propsToRecord(o.properties),\n }));\n const obj: FlareObjectLayer = {\n kind: 'object',\n name: layer.name,\n objects,\n visible,\n opacity,\n };\n return obj;\n }\n return null;\n}\n\n/**\n * Convert a Tiled `.tmj` JSON map into Flare's normalized runtime format.\n * Flattens group layers, resolves external tilesets (when `embedTilesets`),\n * and drops image/editor-only layers.\n */\nexport async function convertTiled(opts: TiledConvertOptions): Promise<TiledResult> {\n const inputPath = absPath(opts.input, process.cwd());\n const outPath = opts.out\n ? absPath(opts.out, process.cwd())\n : join(dirname(inputPath), `${basename(inputPath).replace(/\\.(tmj|json)$/i, '')}.flare.json`);\n const embed = opts.embedTilesets !== false;\n\n const raw = await readFile(inputPath, 'utf8');\n const parsed = JSON.parse(raw) as TiledMap;\n const mapDir = dirname(inputPath);\n\n const tilesets: FlareTileset[] = [];\n for (const ref of parsed.tilesets ?? []) {\n tilesets.push(await resolveTileset(ref, mapDir, embed));\n }\n\n const layers: FlareLayer[] = [];\n for (const l of flattenLayers(parsed.layers ?? [])) {\n const converted = convertLayer(l);\n if (converted) layers.push(converted);\n }\n\n const map: FlareMap = {\n width: parsed.width,\n height: parsed.height,\n tilewidth: parsed.tilewidth,\n tileheight: parsed.tileheight,\n tilesets,\n layers,\n };\n\n await writeFile(outPath, `${JSON.stringify(map, null, 2)}\\n`, 'utf8');\n return { outPath, layers, tilesets, map };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,SAASA,UAAQ,GAAmB;CAClC,QAAA,GAAA,UAAA,WAAA,CAAkB,CAAC,IAAI,KAAA,GAAA,UAAA,QAAA,CAAY,QAAQ,IAAI,GAAG,CAAC;AACrD;AAEA,eAAe,SAAS,KAAgC;CACtD,MAAM,UAAU,OAAA,GAAA,iBAAA,QAAA,CAAc,KAAK,EAAE,eAAe,KAAK,CAAC;CAC1D,MAAM,SAAmB,CAAC;CAC1B,KAAK,MAAM,KAAK,SAAS;EACvB,IAAI,CAAC,EAAE,OAAO,GAAG;EACjB,KAAA,GAAA,UAAA,QAAA,CAAY,EAAE,IAAI,CAAC,CAAC,YAAY,MAAM,QAAQ,OAAO,MAAA,GAAA,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S,KAAK,MAAM,GAAG;CAC7B,MAAM,UAAA,GAAA,UAAA,QAAA,CAAiB,SAAS;CAEhC,MAAM,WAA2B,CAAC;CAClC,KAAK,MAAM,OAAO,OAAO,YAAY,CAAC,GACpC,SAAS,KAAK,MAAM,eAAe,KAAK,QAAQ,KAAK,CAAC;CAGxD,MAAM,SAAuB,CAAC;CAC9B,KAAK,MAAM,KAAK,cAAc,OAAO,UAAU,CAAC,CAAC,GAAG;EAClD,MAAM,YAAY,aAAa,CAAC;EAChC,IAAI,WAAW,OAAO,KAAK,SAAS;CACtC;CAEA,MAAM,MAAgB;EACpB,OAAO,OAAO;EACd,QAAQ,OAAO;EACf,WAAW,OAAO;EAClB,YAAY,OAAO;EACnB;EACA;CACF;CAEA,OAAA,GAAA,iBAAA,UAAA,CAAgB,SAAS,GAAG,KAAK,UAAU,KAAK,MAAM,CAAC,EAAE,KAAK,MAAM;CACpE,OAAO;EAAE;EAAS;EAAQ;EAAU;CAAI;AAC1C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"tiled-to-flare-Cc-ofNer.mjs","names":["absPath"],"sources":["../src/pack-atlas.ts","../src/tiled-to-flare.ts"],"sourcesContent":["import { mkdir, readdir, readFile, writeFile } from 'node:fs/promises';\nimport { basename, extname, isAbsolute, join, resolve } from 'node:path';\nimport { MaxRectsPacker } from 'maxrects-packer';\nimport sharp from 'sharp';\nimport type { AtlasFrame, AtlasPackerOptions, AtlasResult } from './types.js';\n\ninterface SpriteInput {\n name: string;\n path: string;\n width: number;\n height: number;\n}\n\nfunction absPath(p: string): string {\n return isAbsolute(p) ? p : resolve(process.cwd(), p);\n}\n\nasync function listPngs(dir: string): Promise<string[]> {\n const entries = await readdir(dir, { withFileTypes: true });\n const result: string[] = [];\n for (const e of entries) {\n if (!e.isFile()) continue;\n if (extname(e.name).toLowerCase() === '.png') result.push(join(dir, e.name));\n }\n result.sort();\n return result;\n}\n\nasync function readSprite(path: string): Promise<SpriteInput> {\n const meta = await sharp(path).metadata();\n if (!meta.width || !meta.height) {\n throw new Error(`[pack-atlas] unable to read dimensions for ${path}`);\n }\n return {\n name: basename(path, extname(path)),\n path,\n width: meta.width,\n height: meta.height,\n };\n}\n\n/**\n * Pack a directory of PNG sprites into a single TexturePacker-compatible\n * atlas (JSON + image) consumable by `@flare-engine/assets`.\n */\nexport async function packAtlas(opts: AtlasPackerOptions): Promise<AtlasResult> {\n const inputDir = absPath(opts.input);\n const outDir = absPath(opts.out ?? opts.input);\n const name = opts.name ?? 'atlas';\n const padding = opts.padding ?? 2;\n const maxSize = opts.maxSize ?? 2048;\n const format = opts.format ?? 'png';\n\n await mkdir(outDir, { recursive: true });\n\n const files = await listPngs(inputDir);\n if (files.length === 0) {\n throw new Error(`[pack-atlas] no .png files found in ${inputDir}`);\n }\n\n const sprites: SpriteInput[] = [];\n for (const f of files) sprites.push(await readSprite(f));\n\n const packer = new MaxRectsPacker(maxSize, maxSize, padding, {\n smart: true,\n pot: false,\n square: false,\n allowRotation: false,\n tag: false,\n border: 0,\n });\n for (const s of sprites) packer.add(s.width, s.height, s);\n\n if (packer.bins.length !== 1) {\n throw new Error(\n `[pack-atlas] sprites do not fit in a single ${maxSize}x${maxSize} atlas (got ${packer.bins.length} bins)`,\n );\n }\n const bin = packer.bins[0];\n if (!bin) throw new Error('[pack-atlas] packing produced no bin');\n\n const atlasWidth = bin.width;\n const atlasHeight = bin.height;\n\n const frames: AtlasFrame[] = [];\n const composites: { input: Buffer; left: number; top: number }[] = [];\n\n for (const rect of bin.rects) {\n const sprite = rect.data as SpriteInput;\n const buf = await readFile(sprite.path);\n composites.push({ input: buf, left: rect.x, top: rect.y });\n frames.push({\n name: sprite.name,\n x: rect.x,\n y: rect.y,\n w: sprite.width,\n h: sprite.height,\n });\n }\n frames.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));\n\n const imageName = `${name}.${format}`;\n const jsonName = `${name}.json`;\n const imagePath = join(outDir, imageName);\n const jsonPath = join(outDir, jsonName);\n\n let pipeline = sharp({\n create: {\n width: atlasWidth,\n height: atlasHeight,\n channels: 4,\n background: { r: 0, g: 0, b: 0, alpha: 0 },\n },\n }).composite(composites);\n pipeline = format === 'webp' ? pipeline.webp() : pipeline.png();\n await pipeline.toFile(imagePath);\n\n // TexturePacker-compatible JSON (hash format).\n const jsonFrames: Record<string, { frame: { x: number; y: number; w: number; h: number } }> = {};\n for (const f of frames) {\n jsonFrames[f.name] = { frame: { x: f.x, y: f.y, w: f.w, h: f.h } };\n }\n const jsonDoc = {\n frames: jsonFrames,\n meta: {\n app: '@flare-engine/cli',\n version: '1.0',\n image: imageName,\n format: 'RGBA8888',\n size: { w: atlasWidth, h: atlasHeight },\n scale: '1',\n },\n };\n await writeFile(jsonPath, `${JSON.stringify(jsonDoc, null, 2)}\\n`, 'utf8');\n\n return {\n jsonPath,\n imagePath,\n frames,\n width: atlasWidth,\n height: atlasHeight,\n };\n}\n","import { readFile, writeFile } from 'node:fs/promises';\nimport { basename, dirname, isAbsolute, join, resolve } from 'node:path';\nimport type {\n FlareLayer,\n FlareMap,\n FlareObject,\n FlareObjectLayer,\n FlareTileLayer,\n FlareTileset,\n TiledConvertOptions,\n TiledResult,\n} from './types.js';\n\ninterface TiledProperty {\n name: string;\n type?: string;\n value: string | number | boolean;\n}\n\ninterface TiledObject {\n id: number;\n name?: string;\n type?: string;\n class?: string;\n x: number;\n y: number;\n width: number;\n height: number;\n visible?: boolean;\n properties?: TiledProperty[];\n}\n\ninterface TiledLayer {\n type: 'tilelayer' | 'objectgroup' | 'imagelayer' | 'group';\n name: string;\n visible?: boolean;\n opacity?: number;\n width?: number;\n height?: number;\n data?: number[];\n objects?: TiledObject[];\n}\n\ninterface TiledTilesetRef {\n firstgid: number;\n source?: string;\n name?: string;\n tilewidth?: number;\n tileheight?: number;\n columns?: number;\n tilecount?: number;\n image?: string;\n imagewidth?: number;\n imageheight?: number;\n}\n\ninterface TiledMap {\n width: number;\n height: number;\n tilewidth: number;\n tileheight: number;\n layers: TiledLayer[];\n tilesets: TiledTilesetRef[];\n}\n\nfunction absPath(p: string, base: string): string {\n return isAbsolute(p) ? p : resolve(base, p);\n}\n\nfunction propsToRecord(\n props: TiledProperty[] | undefined,\n): Record<string, string | number | boolean> {\n const out: Record<string, string | number | boolean> = {};\n if (!props) return out;\n for (const p of props) out[p.name] = p.value;\n return out;\n}\n\nasync function resolveTileset(\n ref: TiledTilesetRef,\n mapDir: string,\n embed: boolean,\n): Promise<FlareTileset> {\n let data: TiledTilesetRef = ref;\n if (ref.source && embed) {\n const srcPath = absPath(ref.source, mapDir);\n const raw = await readFile(srcPath, 'utf8');\n const external = JSON.parse(raw) as TiledTilesetRef;\n data = { ...external, firstgid: ref.firstgid };\n }\n return {\n name: data.name ?? 'tileset',\n firstgid: data.firstgid,\n tilewidth: data.tilewidth ?? 0,\n tileheight: data.tileheight ?? 0,\n columns: data.columns ?? 0,\n tilecount: data.tilecount ?? 0,\n image: data.image ?? '',\n imagewidth: data.imagewidth ?? 0,\n imageheight: data.imageheight ?? 0,\n ...(ref.source && !embed ? { source: ref.source } : {}),\n };\n}\n\nfunction flattenLayers(layers: TiledLayer[]): TiledLayer[] {\n const out: TiledLayer[] = [];\n const walk = (ls: TiledLayer[]): void => {\n for (const l of ls) {\n if (l.type === 'group') {\n const inner = (l as unknown as { layers?: TiledLayer[] }).layers;\n if (inner) walk(inner);\n } else {\n out.push(l);\n }\n }\n };\n walk(layers);\n return out;\n}\n\nfunction convertLayer(layer: TiledLayer): FlareLayer | null {\n const visible = layer.visible !== false;\n const opacity = typeof layer.opacity === 'number' ? layer.opacity : 1;\n if (layer.type === 'tilelayer') {\n const tile: FlareTileLayer = {\n kind: 'tile',\n name: layer.name,\n width: layer.width ?? 0,\n height: layer.height ?? 0,\n data: layer.data ?? [],\n visible,\n opacity,\n };\n return tile;\n }\n if (layer.type === 'objectgroup') {\n const objects: FlareObject[] = (layer.objects ?? []).map((o) => ({\n id: o.id,\n name: o.name ?? '',\n type: o.type ?? o.class ?? '',\n x: o.x,\n y: o.y,\n width: o.width,\n height: o.height,\n properties: propsToRecord(o.properties),\n }));\n const obj: FlareObjectLayer = {\n kind: 'object',\n name: layer.name,\n objects,\n visible,\n opacity,\n };\n return obj;\n }\n return null;\n}\n\n/**\n * Convert a Tiled `.tmj` JSON map into Flare's normalized runtime format.\n * Flattens group layers, resolves external tilesets (when `embedTilesets`),\n * and drops image/editor-only layers.\n */\nexport async function convertTiled(opts: TiledConvertOptions): Promise<TiledResult> {\n const inputPath = absPath(opts.input, process.cwd());\n const outPath = opts.out\n ? absPath(opts.out, process.cwd())\n : join(dirname(inputPath), `${basename(inputPath).replace(/\\.(tmj|json)$/i, '')}.flare.json`);\n const embed = opts.embedTilesets !== false;\n\n const raw = await readFile(inputPath, 'utf8');\n const parsed = JSON.parse(raw) as TiledMap;\n const mapDir = dirname(inputPath);\n\n const tilesets: FlareTileset[] = [];\n for (const ref of parsed.tilesets ?? []) {\n tilesets.push(await resolveTileset(ref, mapDir, embed));\n }\n\n const layers: FlareLayer[] = [];\n for (const l of flattenLayers(parsed.layers ?? [])) {\n const converted = convertLayer(l);\n if (converted) layers.push(converted);\n }\n\n const map: FlareMap = {\n width: parsed.width,\n height: parsed.height,\n tilewidth: parsed.tilewidth,\n tileheight: parsed.tileheight,\n tilesets,\n layers,\n };\n\n await writeFile(outPath, `${JSON.stringify(map, null, 2)}\\n`, 'utf8');\n return { outPath, layers, tilesets, map };\n}\n"],"mappings":";;;;;AAaA,SAASA,UAAQ,GAAmB;CAClC,OAAO,WAAW,CAAC,IAAI,IAAI,QAAQ,QAAQ,IAAI,GAAG,CAAC;AACrD;AAEA,eAAe,SAAS,KAAgC;CACtD,MAAM,UAAU,MAAM,QAAQ,KAAK,EAAE,eAAe,KAAK,CAAC;CAC1D,MAAM,SAAmB,CAAC;CAC1B,KAAK,MAAM,KAAK,SAAS;EACvB,IAAI,CAAC,EAAE,OAAO,GAAG;EACjB,IAAI,QAAQ,EAAE,IAAI,CAAC,CAAC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