@flare-engine/cli 0.4.6 → 0.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.js CHANGED
@@ -1,11 +1,10 @@
1
1
  #!/usr/bin/env node
2
- const require_tiled_to_flare = require("./tiled-to-flare-cer90bv-.js");
2
+ const require_tiled_to_flare = require("./tiled-to-flare-wePXqHGg.js");
3
3
  let node_child_process = require("node:child_process");
4
4
  let commander = require("commander");
5
- //#region package.json
6
- var version = "0.4.6";
7
- //#endregion
8
- //#region src/cli.ts
5
+ // package.json
6
+ var version = "0.4.7";
7
+ // src/cli.ts
9
8
  function parseIntArg(value, _prev) {
10
9
  const n = Number.parseInt(value, 10);
11
10
  if (!Number.isFinite(n)) throw new Error(`invalid integer: ${value}`);
@@ -87,13 +86,11 @@ function runCreateApp(args) {
87
86
  child.on("error", () => resolvePromise(1));
88
87
  });
89
88
  }
90
- //#endregion
91
- //#region src/bin.ts
89
+ // src/bin.ts
92
90
  buildProgram().parseAsync(process.argv).catch((err) => {
93
91
  const msg = err instanceof Error ? err.message : String(err);
94
92
  process.stderr.write(`[flare] ${msg}\n`);
95
93
  process.exit(1);
96
94
  });
97
- //#endregion
98
95
 
99
96
  //# sourceMappingURL=bin.js.map
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 @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,MAA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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"}
1
+ {"version":3,"file":"bin.js","names":["Command","packAtlas","convertTiled","spawn"],"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,OA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,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,aAAa,IAAI;EACpC,IAAI,SAAS,GAAG,QAAQ,KAAK,IAAI;CACnC,CAAC;CAEH,OAAO;AACT;AAEA,SAAS,aAAa,MAAiC;CACrD,OAAO,IAAI,SAAS,mBAAmB;EACrC,MAAM,EAAE,KAAK,UAAU,mBAAmB,QAAQ,QAAQ;EAC1D,MAAM,SAAA,GAAQC,mBAAAA,MAAAA,CAAM,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,11 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import { n as packAtlas, t as convertTiled } from "./tiled-to-flare-CB70UDDG.mjs";
2
+ import { n as packAtlas, t as convertTiled } from "./tiled-to-flare-H2mTRm-p.mjs";
3
3
  import { spawn } from "node:child_process";
4
4
  import { Command } from "commander";
5
- //#region package.json
6
- var version = "0.4.6";
7
- //#endregion
8
- //#region src/cli.ts
5
+ // package.json
6
+ var version = "0.4.7";
7
+ // src/cli.ts
9
8
  function parseIntArg(value, _prev) {
10
9
  const n = Number.parseInt(value, 10);
11
10
  if (!Number.isFinite(n)) throw new Error(`invalid integer: ${value}`);
@@ -87,14 +86,12 @@ function runCreateApp(args) {
87
86
  child.on("error", () => resolvePromise(1));
88
87
  });
89
88
  }
90
- //#endregion
91
- //#region src/bin.ts
89
+ // src/bin.ts
92
90
  buildProgram().parseAsync(process.argv).catch((err) => {
93
91
  const msg = err instanceof Error ? err.message : String(err);
94
92
  process.stderr.write(`[flare] ${msg}\n`);
95
93
  process.exit(1);
96
94
  });
97
- //#endregion
98
95
  export {};
99
96
 
100
97
  //# sourceMappingURL=bin.mjs.map
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 @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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AY,CAAC,CACrB,YAAY,+DAA+D,CAAC,CAC5E,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,aAAa,IAAI;EACpC,IAAI,SAAS,GAAG,QAAQ,KAAK,IAAI;CACnC,CAAC;CAEH,OAAO;AACT;AAEA,SAAS,aAAa,MAAiC;CACrD,OAAO,IAAI,SAAS,mBAAmB;EACrC,MAAM,EAAE,KAAK,UAAU,mBAAmB,QAAQ,QAAQ;EAC1D,MAAM,QAAQ,MAAM,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"}
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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AM,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/index.d.mts CHANGED
@@ -1,4 +1,3 @@
1
- //#region src/types.d.ts
2
1
  /** Options for `packAtlas` / `flare pack-atlas`. */
3
2
  interface AtlasPackerOptions {
4
3
  /** Directory containing source `.png` sprites (non-recursive). */
@@ -152,15 +151,11 @@ interface TiledResult {
152
151
  tilesets: TiledTileset[];
153
152
  map: TiledMap;
154
153
  }
155
- //#endregion
156
- //#region src/pack-atlas.d.ts
157
154
  /**
158
155
  * Pack a directory of PNG sprites into a single TexturePacker-compatible
159
156
  * atlas (JSON + image) consumable by `@flare-engine/assets`.
160
157
  */
161
- declare function packAtlas(opts: AtlasPackerOptions): Promise<AtlasResult>;
162
- //#endregion
163
- //#region src/tiled-to-flare.d.ts
158
+ export declare function packAtlas(opts: AtlasPackerOptions): Promise<AtlasResult>;
164
159
  /**
165
160
  * Convert a Tiled `.tmj` JSON map into Tiled-shaped runtime JSON, accepted
166
161
  * directly by `@flare-engine/tilemap`'s `parseTiled` — this is a pass-through of
@@ -169,7 +164,6 @@ declare function packAtlas(opts: AtlasPackerOptions): Promise<AtlasResult>;
169
164
  * all survive. Flattens group layers, resolves external tilesets (when
170
165
  * `embedTilesets`), and drops image/editor-only layers.
171
166
  */
172
- declare function convertTiled(opts: TiledConvertOptions): Promise<TiledResult>;
173
- //#endregion
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 };
167
+ export declare function convertTiled(opts: TiledConvertOptions): Promise<TiledResult>;
168
+ export type { AtlasFrame, AtlasPackerOptions, AtlasResult, TiledConvertOptions, TiledLayer, TiledMap, TiledObject, TiledObjectLayer, TiledProperty, TiledResult, TiledTile, TiledTileLayer, TiledTileset };
175
169
  //# 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;;;;;;;;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"}
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;;;;;;wBCtHe,UAAU,MAAM,qBAAqB,QAAQ;;;;;;;;;wBCgH7C,aAAa,MAAM,sBAAsB,QAAQ"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- //#region src/types.d.ts
2
1
  /** Options for `packAtlas` / `flare pack-atlas`. */
3
2
  interface AtlasPackerOptions {
4
3
  /** Directory containing source `.png` sprites (non-recursive). */
@@ -152,15 +151,11 @@ interface TiledResult {
152
151
  tilesets: TiledTileset[];
153
152
  map: TiledMap;
154
153
  }
155
- //#endregion
156
- //#region src/pack-atlas.d.ts
157
154
  /**
158
155
  * Pack a directory of PNG sprites into a single TexturePacker-compatible
159
156
  * atlas (JSON + image) consumable by `@flare-engine/assets`.
160
157
  */
161
- declare function packAtlas(opts: AtlasPackerOptions): Promise<AtlasResult>;
162
- //#endregion
163
- //#region src/tiled-to-flare.d.ts
158
+ export declare function packAtlas(opts: AtlasPackerOptions): Promise<AtlasResult>;
164
159
  /**
165
160
  * Convert a Tiled `.tmj` JSON map into Tiled-shaped runtime JSON, accepted
166
161
  * directly by `@flare-engine/tilemap`'s `parseTiled` — this is a pass-through of
@@ -169,7 +164,6 @@ declare function packAtlas(opts: AtlasPackerOptions): Promise<AtlasResult>;
169
164
  * all survive. Flattens group layers, resolves external tilesets (when
170
165
  * `embedTilesets`), and drops image/editor-only layers.
171
166
  */
172
- declare function convertTiled(opts: TiledConvertOptions): Promise<TiledResult>;
173
- //#endregion
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 };
167
+ export declare function convertTiled(opts: TiledConvertOptions): Promise<TiledResult>;
168
+ export type { AtlasFrame, AtlasPackerOptions, AtlasResult, TiledConvertOptions, TiledLayer, TiledMap, TiledObject, TiledObjectLayer, TiledProperty, TiledResult, TiledTile, TiledTileLayer, TiledTileset };
175
169
  //# 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;;;;;;;;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"}
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;;;;;;wBCtHe,UAAU,MAAM,qBAAqB,QAAQ;;;;;;;;;wBCgH7C,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-cer90bv-.js");
2
+ const require_tiled_to_flare = require("./tiled-to-flare-wePXqHGg.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 @@
1
- import { n as packAtlas, t as convertTiled } from "./tiled-to-flare-CB70UDDG.mjs";
2
- export { convertTiled, packAtlas };
1
+ export { t as convertTiled, n as packAtlas } from "./tiled-to-flare-H2mTRm-p.mjs";
@@ -2,7 +2,7 @@ import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
2
2
  import { basename, dirname, extname, isAbsolute, join, resolve } from "node:path";
3
3
  import { MaxRectsPacker } from "maxrects-packer";
4
4
  import sharp from "sharp";
5
- //#region src/pack-atlas.ts
5
+ // src/pack-atlas.ts
6
6
  function absPath$1(p) {
7
7
  return isAbsolute(p) ? p : resolve(process.cwd(), p);
8
8
  }
@@ -121,15 +121,23 @@ async function packAtlas(opts) {
121
121
  height: atlasHeight
122
122
  };
123
123
  }
124
- //#endregion
125
- //#region src/tiled-to-flare.ts
124
+ // src/tiled-to-flare.ts
126
125
  function absPath(p, base) {
127
126
  return isAbsolute(p) ? p : resolve(base, p);
128
127
  }
128
+ /**
129
+ * Tiled takes the format from "Save as type", not the extension, so a `.tmj`
130
+ * may hold TMX (XML). JSON can never start with `<`, so a leading one (after an
131
+ * optional BOM and whitespace) is the whole check — no XML parsing.
132
+ */
133
+ function looksLikeXml(raw) {
134
+ return /^?\s*</.test(raw);
135
+ }
129
136
  async function resolveTileset(ref, mapDir, embed) {
130
137
  let data = ref;
131
138
  if (ref.source && embed) {
132
- const raw = await readFile(absPath(ref.source, mapDir), "utf8");
139
+ const srcPath = absPath(ref.source, mapDir);
140
+ const raw = await readFile(srcPath, "utf8");
133
141
  data = {
134
142
  ...JSON.parse(raw),
135
143
  firstgid: ref.firstgid
@@ -210,6 +218,7 @@ async function convertTiled(opts) {
210
218
  const outPath = opts.out ? absPath(opts.out, process.cwd()) : join(dirname(inputPath), `${basename(inputPath).replace(/\.(tmj|json)$/i, "")}.flare.json`);
211
219
  const embed = opts.embedTilesets !== false;
212
220
  const raw = await readFile(inputPath, "utf8");
221
+ if (looksLikeXml(raw)) throw new Error(`[tiled-to-flare] ${inputPath} is a TMX (XML) map, not JSON. Re-save it in Tiled with "Save as type" set to "JSON map files (*.tmj *.json)" and run again.`);
213
222
  const parsed = JSON.parse(raw);
214
223
  const mapDir = dirname(inputPath);
215
224
  const tilesets = [];
@@ -235,7 +244,6 @@ async function convertTiled(opts) {
235
244
  map
236
245
  };
237
246
  }
238
- //#endregion
239
247
  export { packAtlas as n, convertTiled as t };
240
248
 
241
- //# sourceMappingURL=tiled-to-flare-CB70UDDG.mjs.map
249
+ //# sourceMappingURL=tiled-to-flare-H2mTRm-p.mjs.map
@@ -1 +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,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A,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"}
1
+ {"version":3,"file":"tiled-to-flare-H2mTRm-p.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\n/**\n * Tiled takes the format from \"Save as type\", not the extension, so a `.tmj`\n * may hold TMX (XML). JSON can never start with `<`, so a leading one (after an\n * optional BOM and whitespace) is the whole check — no XML parsing.\n */\nfunction looksLikeXml(raw: string): boolean {\n return /^?\\s*</.test(raw);\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 if (looksLikeXml(raw)) {\n throw new Error(\n `[tiled-to-flare] ${inputPath} is a TMX (XML) map, not JSON. ` +\n 'Re-save it in Tiled with \"Save as type\" set to \"JSON map files (*.tmj *.json)\" and run again.',\n );\n }\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;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B,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"}
@@ -1,4 +1,4 @@
1
- //#region \0rolldown/runtime.js
1
+ // \0rolldown/runtime.js
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -15,17 +15,16 @@ var __copyProps = (to, from, except, desc) => {
15
15
  }
16
16
  return to;
17
17
  };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
19
19
  value: mod,
20
20
  enumerable: true
21
21
  }) : target, mod));
22
- //#endregion
23
22
  let node_fs_promises = require("node:fs/promises");
24
23
  let node_path = require("node:path");
25
24
  let maxrects_packer = require("maxrects-packer");
26
25
  let sharp = require("sharp");
27
26
  sharp = __toESM(sharp);
28
- //#region src/pack-atlas.ts
27
+ // src/pack-atlas.ts
29
28
  function absPath$1(p) {
30
29
  return (0, node_path.isAbsolute)(p) ? p : (0, node_path.resolve)(process.cwd(), p);
31
30
  }
@@ -144,15 +143,23 @@ async function packAtlas(opts) {
144
143
  height: atlasHeight
145
144
  };
146
145
  }
147
- //#endregion
148
- //#region src/tiled-to-flare.ts
146
+ // src/tiled-to-flare.ts
149
147
  function absPath(p, base) {
150
148
  return (0, node_path.isAbsolute)(p) ? p : (0, node_path.resolve)(base, p);
151
149
  }
150
+ /**
151
+ * Tiled takes the format from "Save as type", not the extension, so a `.tmj`
152
+ * may hold TMX (XML). JSON can never start with `<`, so a leading one (after an
153
+ * optional BOM and whitespace) is the whole check — no XML parsing.
154
+ */
155
+ function looksLikeXml(raw) {
156
+ return /^?\s*</.test(raw);
157
+ }
152
158
  async function resolveTileset(ref, mapDir, embed) {
153
159
  let data = ref;
154
160
  if (ref.source && embed) {
155
- const raw = await (0, node_fs_promises.readFile)(absPath(ref.source, mapDir), "utf8");
161
+ const srcPath = absPath(ref.source, mapDir);
162
+ const raw = await (0, node_fs_promises.readFile)(srcPath, "utf8");
156
163
  data = {
157
164
  ...JSON.parse(raw),
158
165
  firstgid: ref.firstgid
@@ -233,6 +240,7 @@ async function convertTiled(opts) {
233
240
  const outPath = opts.out ? absPath(opts.out, process.cwd()) : (0, node_path.join)((0, node_path.dirname)(inputPath), `${(0, node_path.basename)(inputPath).replace(/\.(tmj|json)$/i, "")}.flare.json`);
234
241
  const embed = opts.embedTilesets !== false;
235
242
  const raw = await (0, node_fs_promises.readFile)(inputPath, "utf8");
243
+ if (looksLikeXml(raw)) throw new Error(`[tiled-to-flare] ${inputPath} is a TMX (XML) map, not JSON. Re-save it in Tiled with "Save as type" set to "JSON map files (*.tmj *.json)" and run again.`);
236
244
  const parsed = JSON.parse(raw);
237
245
  const mapDir = (0, node_path.dirname)(inputPath);
238
246
  const tilesets = [];
@@ -258,7 +266,6 @@ async function convertTiled(opts) {
258
266
  map
259
267
  };
260
268
  }
261
- //#endregion
262
269
  Object.defineProperty(exports, "convertTiled", {
263
270
  enumerable: true,
264
271
  get: function() {
@@ -272,4 +279,4 @@ Object.defineProperty(exports, "packAtlas", {
272
279
  }
273
280
  });
274
281
 
275
- //# sourceMappingURL=tiled-to-flare-cer90bv-.js.map
282
+ //# sourceMappingURL=tiled-to-flare-wePXqHGg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tiled-to-flare-wePXqHGg.js","names":["absPath","isAbsolute","resolve","readdir","extname","join","basename","mkdir","MaxRectsPacker","readFile","writeFile","isAbsolute","resolve","readFile","join","dirname","basename","writeFile"],"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\n/**\n * Tiled takes the format from \"Save as type\", not the extension, so a `.tmj`\n * may hold TMX (XML). JSON can never start with `<`, so a leading one (after an\n * optional BOM and whitespace) is the whole check — no XML parsing.\n */\nfunction looksLikeXml(raw: string): boolean {\n return /^?\\s*</.test(raw);\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 if (looksLikeXml(raw)) {\n throw new Error(\n `[tiled-to-flare] ${inputPath} is a TMX (XML) map, not JSON. ` +\n 'Re-save it in Tiled with \"Save as type\" set to \"JSON map files (*.tmj *.json)\" and run again.',\n );\n }\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,GAAOC,UAAAA,WAAAA,CAAW,CAAC,IAAI,KAAA,GAAIC,UAAAA,QAAAA,CAAQ,QAAQ,IAAI,GAAG,CAAC;AACrD;AAEA,e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AY,QAAQ,KAAK,OAAO,QAAQ,IAAI,CAAC;CACnD,MAAM,UAAU,KAAK,MACjB,QAAQ,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAA,GAC/BC,UAAAA,KAAAA,EAAAA,GAAKC,UAAAA,QAAAA,CAAQ,SAAS,GAAG,IAAA,GAAGC,UAAAA,SAAAA,CAAS,SAAS,CAAC,CAAC,QAAQ,kBAAkB,EAAE,EAAE,YAAY;CAC9F,MAAM,QAAQ,KAAK,kBAAkB;CAErC,MAAM,MAAM,OAAA,GAAMH,iBAAAA,SAAAA,CAAS,WAAW,MAAM;CAC5C,IAAI,aAAa,GAAG,GAClB,MAAM,IAAI,MACR,oBAAoB,UAAU,6HAEhC;CAEF,MAAM,SAAS,KAAK,MAAM,GAAG;CAC7B,MAAM,UAAA,GAASE,UAAAA,QAAAA,CAAQ,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,GAAME,iBAAAA,UAAAA,CAAU,SAAS,GAAG,KAAK,UAAU,KAAK,MAAM,CAAC,EAAE,KAAK,MAAM;CACpE,OAAO;EAAE;EAAS;EAAQ;EAAU;CAAI;AAC1C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flare-engine/cli",
3
- "version": "0.4.6",
3
+ "version": "0.4.7",
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",
@@ -40,11 +40,11 @@
40
40
  "typecheck": "tsc --noEmit"
41
41
  },
42
42
  "devDependencies": {
43
- "@flare-engine/tilemap": "^0.4.6"
43
+ "@flare-engine/tilemap": "^0.4.7"
44
44
  },
45
45
  "dependencies": {
46
- "commander": "^13.1.0",
47
- "maxrects-packer": "^2.7.3",
46
+ "commander": "^14.0.3",
47
+ "maxrects-packer": "^3.0.0",
48
48
  "sharp": "^0.35.5"
49
49
  },
50
50
  "engines": {
@@ -1 +0,0 @@
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,KA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