@ascii-fx/compiler 0.9.0 → 0.10.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/dist/cli.js CHANGED
@@ -11,25 +11,39 @@ import process from "process";
11
11
  import { decodeProfile, peekFrame } from "@ascii-fx/core";
12
12
 
13
13
  // src/cliArgs.ts
14
+ import { parseArgs as nodeParseArgs } from "util";
15
+ var VALUE_FLAGS = [
16
+ "font",
17
+ "out",
18
+ "charset",
19
+ "characters",
20
+ "id",
21
+ "face",
22
+ "image",
23
+ "profile",
24
+ "columns",
25
+ "rows",
26
+ "color",
27
+ "alpha"
28
+ ];
29
+ var SWITCH_FLAGS = ["shape6", "shape6-lut"];
30
+ var OPTIONS = Object.fromEntries([
31
+ ...VALUE_FLAGS.map((name) => [name, { type: "string" }]),
32
+ ...SWITCH_FLAGS.map((name) => [name, { type: "boolean" }])
33
+ ]);
14
34
  function parseArgs(argv) {
15
- const positional = [];
35
+ const { values, positionals } = nodeParseArgs({
36
+ args: argv,
37
+ options: OPTIONS,
38
+ strict: true,
39
+ allowPositionals: true
40
+ });
16
41
  const flags = /* @__PURE__ */ new Map();
17
- for (let i = 0; i < argv.length; i++) {
18
- const a = argv[i];
19
- if (a.startsWith("--")) {
20
- const key = a.slice(2);
21
- const next = argv[i + 1];
22
- if (next !== void 0 && !next.startsWith("--")) {
23
- flags.set(key, next);
24
- i++;
25
- } else {
26
- flags.set(key, true);
27
- }
28
- } else {
29
- positional.push(a);
30
- }
42
+ for (const [key, value] of Object.entries(values)) {
43
+ if (typeof value === "string") flags.set(key, value);
44
+ else if (value === true) flags.set(key, true);
31
45
  }
32
- return { positional, flags };
46
+ return { positional: positionals, flags };
33
47
  }
34
48
  var str = (args, key) => {
35
49
  const v = args.flags.get(key);
@@ -60,6 +74,9 @@ Usage:
60
74
  ascii-fx frame build --image <file.png> --profile <file.asciip> --out <file.asciif>
61
75
  [--columns N] [--rows N] [--color mono|foreground|full] [--alpha mask|ignore]
62
76
  ascii-fx inspect <file.asciip | file.asciif>
77
+
78
+ Flags take a value as --flag value or --flag=value; use the second form for a value that
79
+ starts with a dash (--characters=-=+#).
63
80
  `;
64
81
  var requireStr = (args, key) => {
65
82
  const v = str(args, key);
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli.ts","../src/cliArgs.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { readFile, writeFile } from 'node:fs/promises'\nimport process from 'node:process'\nimport { decodeProfile, peekFrame } from '@ascii-fx/core'\nimport { type Args, enumFlag, parseArgs, positiveIntFlag, str } from './cliArgs.js'\nimport { buildProfile } from './profile.js'\nimport { buildFrame } from './frameBuild.js'\nimport { decodePng } from './png.js'\n\nconst USAGE = `ascii-fx — ASCII FX build-time compiler\n\nUsage:\n ascii-fx profile build --font <file> --out <file.asciip> [--charset ascii] [--characters \"<chars>\"] [--id default]\n [--face <postscript-name|index>] [--shape6] [--shape6-lut]\n ascii-fx frame build --image <file.png> --profile <file.asciip> --out <file.asciif>\n [--columns N] [--rows N] [--color mono|foreground|full] [--alpha mask|ignore]\n ascii-fx inspect <file.asciip | file.asciif>\n`\n\nconst requireStr = (args: Args, key: string): string => {\n const v = str(args, key)\n if (v === undefined) {\n console.error(`Missing required --${key}\\n\\n${USAGE}`)\n process.exit(1)\n }\n return v\n}\n\nasync function main(): Promise<void> {\n const args = parseArgs(process.argv.slice(2))\n const [cmd, sub] = args.positional\n\n if (cmd === 'profile' && sub === 'build') {\n const fontPath = requireStr(args, 'font')\n const outPath = requireStr(args, 'out')\n const font = new Uint8Array(await readFile(fontPath))\n const characters = str(args, 'characters')\n const face = str(args, 'face')\n const { profile, binary } = buildProfile({\n font,\n face: face !== undefined && /^\\d+$/.test(face) ? Number(face) : face,\n id: str(args, 'id') ?? 'default',\n charset: str(args, 'charset'),\n characters,\n shape6:\n args.flags.get('shape6-lut') === true ? { lut: true } : args.flags.get('shape6') === true,\n })\n await writeFile(outPath, binary)\n console.log(\n `${outPath}: ${profile.glyphCount} glyphs (${profile.metadata.charset}), ` +\n `cell ${profile.atlas.cellWidth}×${profile.atlas.cellHeight}, atlas ${profile.atlas.width}×${profile.atlas.height}, ` +\n `${binary.length} bytes, fingerprint ${profile.fingerprint.slice(0, 12)}…`,\n )\n return\n }\n\n if (cmd === 'frame' && sub === 'build') {\n const imagePath = requireStr(args, 'image')\n const profilePath = requireStr(args, 'profile')\n const outPath = requireStr(args, 'out')\n if (!imagePath.toLowerCase().endsWith('.png')) {\n console.error('frame build currently decodes PNG only.')\n process.exit(1)\n }\n const profile = decodeProfile(new Uint8Array(await readFile(profilePath)))\n const image = decodePng(new Uint8Array(await readFile(imagePath)))\n const { frame, binary } = buildFrame({\n image,\n profile,\n columns: positiveIntFlag('columns', str(args, 'columns')),\n rows: positiveIntFlag('rows', str(args, 'rows')),\n color:\n enumFlag('color', str(args, 'color'), ['mono', 'foreground', 'full'] as const) ?? 'mono',\n alpha: enumFlag('alpha', str(args, 'alpha'), ['mask', 'ignore'] as const),\n })\n await writeFile(outPath, binary)\n console.log(\n `${outPath}: ${frame.columns}×${frame.rows} cells, ${frame.colorMode}, ${binary.length} bytes`,\n )\n return\n }\n\n if (cmd === 'inspect') {\n const file = args.positional[1]\n if (!file) {\n console.error(USAGE)\n process.exit(1)\n }\n const bytes = new Uint8Array(await readFile(file))\n if (bytes[3] === 0x49) {\n const p = decodeProfile(bytes)\n console.log(\n JSON.stringify(\n {\n format: 'asciip/1',\n id: p.id,\n charset: p.metadata.charset,\n fontFamily: p.metadata.fontFamily,\n glyphCount: p.glyphCount,\n cell: `${p.atlas.cellWidth}×${p.atlas.cellHeight}`,\n baseline: p.metrics.baseline,\n atlas: `${p.atlas.width}×${p.atlas.height} (pitch ${p.atlas.pitchWidth}×${p.atlas.pitchHeight})`,\n fingerprint: p.fingerprint,\n fontHash: p.fontHash,\n charsetHash: p.charsetHash,\n compilerVersion: p.metadata.compilerVersion,\n bytes: bytes.length,\n },\n null,\n 2,\n ),\n )\n } else {\n const m = peekFrame(bytes)\n console.log(JSON.stringify({ format: 'asciif/1', ...m, bytes: bytes.length }, null, 2))\n }\n return\n }\n\n console.error(USAGE)\n process.exit(cmd === undefined ? 0 : 1)\n}\n\nmain().catch((err: unknown) => {\n console.error(err instanceof Error ? err.message : err)\n process.exit(1)\n})\n","/**\n * CLI argument parsing and validation, separate from cli.ts so it is testable\n * without spawning the built binary (the node suite runs before `pnpm build`\n * in CI, so dist/cli.js may not exist when tests do).\n *\n * Validators throw plain Errors; cli.ts's top-level catch prints the message\n * and exits 1. They exist because the underlying builders do not reject what\n * they cannot handle: an unknown --color used to encode a silently wrong\n * artifact and a non-numeric --columns an unloadable one, both with exit 0.\n */\n\nexport interface Args {\n positional: string[]\n flags: Map<string, string | true>\n}\n\nexport function parseArgs(argv: string[]): Args {\n const positional: string[] = []\n const flags = new Map<string, string | true>()\n for (let i = 0; i < argv.length; i++) {\n const a = argv[i]\n if (a.startsWith('--')) {\n const key = a.slice(2)\n const next = argv[i + 1]\n if (next !== undefined && !next.startsWith('--')) {\n flags.set(key, next)\n i++\n } else {\n flags.set(key, true)\n }\n } else {\n positional.push(a)\n }\n }\n return { positional, flags }\n}\n\nexport const str = (args: Args, key: string): string | undefined => {\n const v = args.flags.get(key)\n return typeof v === 'string' ? v : undefined\n}\n\n/** An enum-valued flag: anything outside `allowed` is an error, never a guess. */\nexport function enumFlag<T extends string>(\n key: string,\n value: string | undefined,\n allowed: readonly T[],\n): T | undefined {\n if (value === undefined) return undefined\n if ((allowed as readonly string[]).includes(value)) return value as T\n throw new Error(\n `Invalid --${key} ${JSON.stringify(value)}: expected one of ${allowed.join(' | ')}.`,\n )\n}\n\n/** A grid-dimension flag: positive integers only — NaN and fractions reach typed-array sizes otherwise. */\nexport function positiveIntFlag(key: string, value: string | undefined): number | undefined {\n if (value === undefined) return undefined\n const n = Number(value)\n if (!Number.isInteger(n) || n <= 0) {\n throw new Error(`Invalid --${key} ${JSON.stringify(value)}: expected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AAM,IAAM;AACrB,YAAM,IAAI,cAAc,KAAK;AAC7B,cAAQ;AAAA,QACN,KAAK;AAAA,UACH;AAAA,YACE,QAAQ;AAAA,YACR,IAAI,EAAE;AAAA,YACN,SAAS,EAAE,SAAS;AAAA,YACpB,YAAY,EAAE,SAAS;AAAA,YACvB,YAAY,EAAE;AAAA,YACd,MAAM,GAAG,EAAE,MAAM,SAAS,OAAI,EAAE,MAAM,UAAU;AAAA,YAChD,UAAU,EAAE,QAAQ;AAAA,YACpB,OAAO,GAAG,EAAE,MAAM,KAAK,OAAI,EAAE,MAAM,MAAM,WAAW,EAAE,MAAM,UAAU,OAAI,EAAE,MAAM,WAAW;AAAA,YAC7F,aAAa,EAAE;AAAA,YACf,UAAU,EAAE;AAAA,YACZ,aAAa,EAAE;AAAA,YACf,iBAAiB,EAAE,SAAS;AAAA,YAC5B,OAAO,MAAM;AAAA,UACf;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAAA,IACF,OAAO;AACL,YAAM,IAAI,UAAU,KAAK;AACzB,cAAQ,IAAI,KAAK,UAAU,EAAE,QAAQ,YAAY,GAAG,GAAG,OAAO,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC;AAAA,IACxF;AACA;AAAA,EACF;AAEA,UAAQ,MAAM,KAAK;AACnB,UAAQ,KAAK,QAAQ,SAAY,IAAI,CAAC;AACxC;AAEA,KAAK,EAAE,MAAM,CAAC,QAAiB;AAC7B,UAAQ,MAAM,eAAe,QAAQ,IAAI,UAAU,GAAG;AACtD,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
1
+ {"version":3,"sources":["../src/cli.ts","../src/cliArgs.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { readFile, writeFile } from 'node:fs/promises'\nimport process from 'node:process'\nimport { decodeProfile, peekFrame } from '@ascii-fx/core'\nimport { type Args, enumFlag, parseArgs, positiveIntFlag, str } from './cliArgs.js'\nimport { buildProfile } from './profile.js'\nimport { buildFrame } from './frameBuild.js'\nimport { decodePng } from './png.js'\n\nconst USAGE = `ascii-fx — ASCII FX build-time compiler\n\nUsage:\n ascii-fx profile build --font <file> --out <file.asciip> [--charset ascii] [--characters \"<chars>\"] [--id default]\n [--face <postscript-name|index>] [--shape6] [--shape6-lut]\n ascii-fx frame build --image <file.png> --profile <file.asciip> --out <file.asciif>\n [--columns N] [--rows N] [--color mono|foreground|full] [--alpha mask|ignore]\n ascii-fx inspect <file.asciip | file.asciif>\n\nFlags take a value as --flag value or --flag=value; use the second form for a value that\nstarts with a dash (--characters=-=+#).\n`\n\nconst requireStr = (args: Args, key: string): string => {\n const v = str(args, key)\n if (v === undefined) {\n console.error(`Missing required --${key}\\n\\n${USAGE}`)\n process.exit(1)\n }\n return v\n}\n\nasync function main(): Promise<void> {\n const args = parseArgs(process.argv.slice(2))\n const [cmd, sub] = args.positional\n\n if (cmd === 'profile' && sub === 'build') {\n const fontPath = requireStr(args, 'font')\n const outPath = requireStr(args, 'out')\n const font = new Uint8Array(await readFile(fontPath))\n const characters = str(args, 'characters')\n const face = str(args, 'face')\n const { profile, binary } = buildProfile({\n font,\n face: face !== undefined && /^\\d+$/.test(face) ? Number(face) : face,\n id: str(args, 'id') ?? 'default',\n charset: str(args, 'charset'),\n characters,\n shape6:\n args.flags.get('shape6-lut') === true ? { lut: true } : args.flags.get('shape6') === true,\n })\n await writeFile(outPath, binary)\n console.log(\n `${outPath}: ${profile.glyphCount} glyphs (${profile.metadata.charset}), ` +\n `cell ${profile.atlas.cellWidth}×${profile.atlas.cellHeight}, atlas ${profile.atlas.width}×${profile.atlas.height}, ` +\n `${binary.length} bytes, fingerprint ${profile.fingerprint.slice(0, 12)}…`,\n )\n return\n }\n\n if (cmd === 'frame' && sub === 'build') {\n const imagePath = requireStr(args, 'image')\n const profilePath = requireStr(args, 'profile')\n const outPath = requireStr(args, 'out')\n if (!imagePath.toLowerCase().endsWith('.png')) {\n console.error('frame build currently decodes PNG only.')\n process.exit(1)\n }\n const profile = decodeProfile(new Uint8Array(await readFile(profilePath)))\n const image = decodePng(new Uint8Array(await readFile(imagePath)))\n const { frame, binary } = buildFrame({\n image,\n profile,\n columns: positiveIntFlag('columns', str(args, 'columns')),\n rows: positiveIntFlag('rows', str(args, 'rows')),\n color:\n enumFlag('color', str(args, 'color'), ['mono', 'foreground', 'full'] as const) ?? 'mono',\n alpha: enumFlag('alpha', str(args, 'alpha'), ['mask', 'ignore'] as const),\n })\n await writeFile(outPath, binary)\n console.log(\n `${outPath}: ${frame.columns}×${frame.rows} cells, ${frame.colorMode}, ${binary.length} bytes`,\n )\n return\n }\n\n if (cmd === 'inspect') {\n const file = args.positional[1]\n if (!file) {\n console.error(USAGE)\n process.exit(1)\n }\n const bytes = new Uint8Array(await readFile(file))\n if (bytes[3] === 0x49) {\n const p = decodeProfile(bytes)\n console.log(\n JSON.stringify(\n {\n format: 'asciip/1',\n id: p.id,\n charset: p.metadata.charset,\n fontFamily: p.metadata.fontFamily,\n glyphCount: p.glyphCount,\n cell: `${p.atlas.cellWidth}×${p.atlas.cellHeight}`,\n baseline: p.metrics.baseline,\n atlas: `${p.atlas.width}×${p.atlas.height} (pitch ${p.atlas.pitchWidth}×${p.atlas.pitchHeight})`,\n fingerprint: p.fingerprint,\n fontHash: p.fontHash,\n charsetHash: p.charsetHash,\n compilerVersion: p.metadata.compilerVersion,\n bytes: bytes.length,\n },\n null,\n 2,\n ),\n )\n } else {\n const m = peekFrame(bytes)\n console.log(JSON.stringify({ format: 'asciif/1', ...m, bytes: bytes.length }, null, 2))\n }\n return\n }\n\n console.error(USAGE)\n process.exit(cmd === undefined ? 0 : 1)\n}\n\nmain().catch((err: unknown) => {\n console.error(err instanceof Error ? err.message : err)\n process.exit(1)\n})\n","/**\n * CLI argument parsing and validation, separate from cli.ts so it is testable\n * without spawning the built binary (the node suite runs before `pnpm build`\n * in CI, so dist/cli.js may not exist when tests do).\n *\n * Validators throw plain Errors; cli.ts's top-level catch prints the message\n * and exits 1. They exist because the underlying builders do not reject what\n * they cannot handle: an unknown --color used to encode a silently wrong\n * artifact and a non-numeric --columns an unloadable one, both with exit 0.\n */\n\nimport { parseArgs as nodeParseArgs } from 'node:util'\n\nexport interface Args {\n positional: string[]\n flags: Map<string, string | true>\n}\n\n/** Every flag the CLI takes. Anything else is a typo, and is refused as one. */\nconst VALUE_FLAGS = [\n 'font',\n 'out',\n 'charset',\n 'characters',\n 'id',\n 'face',\n 'image',\n 'profile',\n 'columns',\n 'rows',\n 'color',\n 'alpha',\n] as const\nconst SWITCH_FLAGS = ['shape6', 'shape6-lut'] as const\n\nconst OPTIONS: Record<string, { type: 'string' | 'boolean' }> = Object.fromEntries([\n ...VALUE_FLAGS.map((name) => [name, { type: 'string' }] as const),\n ...SWITCH_FLAGS.map((name) => [name, { type: 'boolean' }] as const),\n])\n\n/**\n * Strict, through node's own parser. The hand-rolled one this replaces took any `--word`\n * as a flag: `--columns=160` became a switch named `columns=160`, and `--colums 160` a flag\n * nothing read — both built the default grid and exited 0, the silently wrong artifact the\n * validators below exist to prevent. Now `--flag=value` works, and an unknown flag, or a\n * valued flag with no value, is an error naming the flag.\n */\nexport function parseArgs(argv: string[]): Args {\n const { values, positionals } = nodeParseArgs({\n args: argv,\n options: OPTIONS,\n strict: true,\n allowPositionals: true,\n })\n const flags = new Map<string, string | true>()\n for (const [key, value] of Object.entries(values)) {\n if (typeof value === 'string') flags.set(key, value)\n else if (value === true) flags.set(key, true)\n }\n return { positional: positionals, flags }\n}\n\nexport const str = (args: Args, key: string): string | undefined => {\n const v = args.flags.get(key)\n return typeof v === 'string' ? v : undefined\n}\n\n/** An enum-valued flag: anything outside `allowed` is an error, never a guess. */\nexport function enumFlag<T extends string>(\n key: string,\n value: string | undefined,\n allowed: readonly T[],\n): T | undefined {\n if (value === undefined) return undefined\n if ((allowed as readonly string[]).includes(value)) return value as T\n throw new Error(\n `Invalid --${key} ${JSON.stringify(value)}: expected one of ${allowed.join(' | ')}.`,\n )\n}\n\n/** A grid-dimension flag: positive integers only — NaN and fractions reach typed-array sizes otherwise. */\nexport function positiveIntFlag(key: string, value: string | undefined): number | undefined {\n if (value === undefined) return undefined\n const n = Number(value)\n if (!Number.isInteger(n) || n <= 0) {\n throw new Error(`Invalid --${key} ${JSON.stringify(value)}: expected a positive integer.`)\n }\n return n\n}\n"],"mappings":";;;;;;;;AACA,SAAS,UAAU,iBAAiB;AACpC,OAAO,aAAa;AACpB,SAAS,eAAe,iBAAiB;;;ACQzC,SAAS,aAAa,qBAAqB;AAQ3C,IAAM,cAAc;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACA,IAAM,eAAe,CAAC,UAAU,YAAY;AAE5C,IAAM,UAA0D,OAAO,YAAY;AAAA,EACjF,GAAG,YAAY,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,SAAS,CAAC,CAAU;AAAA,EAChE,GAAG,aAAa,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,UAAU,CAAC,CAAU;AACpE,CAAC;AASM,SAAS,UAAU,MAAsB;AAC9C,QAAM,EAAE,QAAQ,YAAY,IAAI,cAAc;AAAA,IAC5C,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,kBAAkB;AAAA,EACpB,CAAC;AACD,QAAM,QAAQ,oBAAI,IAA2B;AAC7C,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACjD,QAAI,OAAO,UAAU,SAAU,OAAM,IAAI,KAAK,KAAK;AAAA,aAC1C,UAAU,KAAM,OAAM,IAAI,KAAK,IAAI;AAAA,EAC9C;AACA,SAAO,EAAE,YAAY,aAAa,MAAM;AAC1C;AAEO,IAAM,MAAM,CAAC,MAAY,QAAoC;AAClE,QAAM,IAAI,KAAK,MAAM,IAAI,GAAG;AAC5B,SAAO,OAAO,MAAM,WAAW,IA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AAM,CAAC,CAAC;AAAA,IACxF;AACA;AAAA,EACF;AAEA,UAAQ,MAAM,KAAK;AACnB,UAAQ,KAAK,QAAQ,SAAY,IAAI,CAAC;AACxC;AAEA,KAAK,EAAE,MAAM,CAAC,QAAiB;AAC7B,UAAQ,MAAM,eAAe,QAAQ,IAAI,UAAU,GAAG;AACtD,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
package/dist/cliArgs.d.ts CHANGED
@@ -12,6 +12,13 @@ export interface Args {
12
12
  positional: string[];
13
13
  flags: Map<string, string | true>;
14
14
  }
15
+ /**
16
+ * Strict, through node's own parser. The hand-rolled one this replaces took any `--word`
17
+ * as a flag: `--columns=160` became a switch named `columns=160`, and `--colums 160` a flag
18
+ * nothing read — both built the default grid and exited 0, the silently wrong artifact the
19
+ * validators below exist to prevent. Now `--flag=value` works, and an unknown flag, or a
20
+ * valued flag with no value, is an error naming the flag.
21
+ */
15
22
  export declare function parseArgs(argv: string[]): Args;
16
23
  export declare const str: (args: Args, key: string) => string | undefined;
17
24
  /** An enum-valued flag: anything outside `allowed` is an error, never a guess. */
package/dist/config.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import type { AlphaMode, ColorMode } from '@ascii-fx/core';
2
2
  export interface AsciiProfileConfig {
3
- /** Path to the font file, relative to the config file. */
3
+ /**
4
+ * Path to the font file, relative to the config file — or to the Vite root, for a config
5
+ * passed to the plugin inline rather than loaded from a file.
6
+ */
4
7
  font: string;
5
8
  /** Which face of a .ttc/.otc collection: PostScript name or index. */
6
9
  face?: string | number;
@@ -13,7 +16,7 @@ export interface AsciiProfileConfig {
13
16
  }
14
17
  /** Static build-time frame (spec §16). Matching happens at build, not runtime. */
15
18
  export interface AsciiFrameConfig {
16
- /** Path to the source image (PNG in v1), relative to the config file. */
19
+ /** Path to the source image (PNG in v1). Relative to the same place as a profile's `font`. */
17
20
  image: string;
18
21
  /** Profile name from `profiles`. Default 'default'. */
19
22
  profile?: string;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/config.ts","../src/chromatic.ts"],"sourcesContent":["import type { AlphaMode, ColorMode } from '@ascii-fx/core'\n\nexport interface AsciiProfileConfig {\n /** Path to the font file, relative to the config file. */\n font: string\n /** Which face of a .ttc/.otc collection: PostScript name or index. */\n face?: string | number\n charset?: string\n characters?: string | string[]\n /** Compile shape6-v1 data (ALGORITHM.md §18); `{ lut: true }` adds the dense LUT. */\n shape6?: boolean | { lut?: boolean }\n}\n\n/** Static build-time frame (spec §16). Matching happens at build, not runtime. */\nexport interface AsciiFrameConfig {\n /** Path to the source image (PNG in v1), relative to the config file. */\n image: string\n /** Profile name from `profiles`. Default 'default'. */\n profile?: string\n columns?: number\n rows?: number\n color?: ColorMode\n alpha?: AlphaMode\n}\n\nexport interface AsciiConfig {\n profiles: Record<string, AsciiProfileConfig>\n frames?: Record<string, AsciiFrameConfig>\n}\n\nexport function defineAsciiConfig(config: AsciiConfig): AsciiConfig {\n return config\n}\n","// Builds chromatic-v1 profiles (ALGORITHM.md §C) from decoded colour images\n// rather than from a font. There is no rasterization step: colour emoji ship as\n// PNG assets (Noto, Twemoji, Fluent) or as bitmap strikes inside a font, so the\n// deterministic path is decode-then-box-filter, not outline flattening. That\n// makes raster-v1 (§13) inapplicable here by construction, not by omission.\n\nimport type { AsciiProfile, RawImage } from '@ascii-fx/core'\nimport { encodeProfile, idiv, nextPow2, rdiv } from '@ascii-fx/core'\nimport { COMPILER_VERSION, sha256 } from './profile.js'\n\nconst ATLAS_PADDING = 4\n/**\n * Reference cell for chromatic profiles. Square, unlike a text cell, and sized\n * so `cell + 2 * ATLAS_PADDING` is already a power of two: the pow2 pitch rule\n * (§13) exists so padding survives mip levels, and any other cell size rounds\n * up and wastes the difference. 32 would round 40 up to 64 and throw away 61%\n * of the atlas; 24 fits 32 exactly. The efficient sizes are 24, 56, and 120.\n */\nexport const CHROMATIC_CELL = 24\nexport const CHROMATIC_RASTER_VERSION = 'raster-chromatic-v1'\n\nexport interface ChromaticGlyphSource {\n /** The grapheme this glyph draws; may be several code points (ZWJ, VS16, modifiers). */\n char: string\n image: RawImage\n}\n\nexport interface BuildChromaticOptions {\n glyphs: readonly ChromaticGlyphSource[]\n /** Reference cell size in px, square. Default CHROMATIC_CELL (24). */\n cellSize?: number\n id?: string\n}\n\nexport interface BuiltChromaticProfile {\n profile: AsciiProfile\n binary: Uint8Array\n}\n\n/**\n * Alpha-weighted box filter, the same rule as reduce-v1 (§4): colour is\n * weighted by alpha so transparent pixels cannot drag the mean toward whatever\n * RGB happens to sit under them, while alpha itself is a plain mean.\n */\nfunction boxFilter(img: RawImage, tw: number, th: number): Uint8Array {\n const { width: w, height: h, data } = img\n const out = new Uint8Array(tw * th * 4)\n for (let ty = 0; ty < th; ty++) {\n const y0 = idiv(ty * h, th)\n const y1 = Math.max(y0 + 1, idiv((ty + 1) * h, th))\n for (let tx = 0; tx < tw; tx++) {\n const x0 = idiv(tx * w, tw)\n const x1 = Math.max(x0 + 1, idiv((tx + 1) * w, tw))\n let sr = 0\n let sg = 0\n let sb = 0\n let sa = 0\n let count = 0\n for (let y = y0; y < y1; y++) {\n for (let x = x0; x < x1; x++) {\n const p = (y * w + x) * 4\n const a = data[p + 3]\n sr += data[p] * a\n sg += data[p + 1] * a\n sb += data[p + 2] * a\n sa += a\n count++\n }\n }\n const q = (ty * tw + tx) * 4\n if (sa === 0) {\n out[q] = 0\n out[q + 1] = 0\n out[q + 2] = 0\n out[q + 3] = 0\n } else {\n out[q] = rdiv(sr, sa)\n out[q + 1] = rdiv(sg, sa)\n out[q + 2] = rdiv(sb, sa)\n out[q + 3] = rdiv(sa, count)\n }\n }\n }\n return out\n}\n\nexport function buildChromaticProfile(options: BuildChromaticOptions): BuiltChromaticProfile {\n const sources = options.glyphs\n const n = sources.length\n if (n === 0) throw new Error('buildChromaticProfile needs at least one glyph.')\n if (n > 65536)\n throw new Error(`Chromatic profiles hold at most 65536 glyphs (got ${n}); glyph ids are u16.`)\n\n const seen = new Set<string>()\n for (const g of sources) {\n if (g.char.length === 0) throw new Error('A chromatic glyph has an empty character.')\n if (seen.has(g.char)) {\n throw new Error(\n `Duplicate chromatic glyph ${JSON.stringify(g.char)}. Each grapheme may appear once.`,\n )\n }\n seen.add(g.char)\n if (g.image.width < 1 || g.image.height < 1) {\n throw new Error(`Glyph ${JSON.stringify(g.char)} has an empty image.`)\n }\n if (g.image.data.length !== g.image.width * g.image.height * 4) {\n throw new Error(`Glyph ${JSON.stringify(g.char)} image data is not width * height * 4.`)\n }\n }\n\n const cell = options.cellSize ?? CHROMATIC_CELL\n if (!Number.isInteger(cell) || cell < 8)\n throw new Error(`cellSize must be an integer >= 8 (got ${cell}).`)\n\n const pitch = nextPow2(cell + 2 * ATLAS_PADDING)\n let atlasColumns = 1\n while (atlasColumns * atlasColumns < n) atlasColumns++\n const atlasRows = idiv(n + atlasColumns - 1, atlasColumns)\n const atlasW = atlasColumns * pitch\n const atlasH = atlasRows * pitch\n\n const coverageAtlas = new Uint8Array(atlasW * atlasH)\n const rgbaAtlas = new Uint8Array(atlasW * atlasH * 4)\n const samples = new Uint8Array(n * 256)\n const masksLo = new Uint32Array(n)\n const masksHi = new Uint32Array(n)\n const coverage = new Uint16Array(n)\n\n for (let i = 0; i < n; i++) {\n const tile = boxFilter(sources[i].image, cell, cell)\n const tileX = (i % atlasColumns) * pitch + ATLAS_PADDING\n const tileY = idiv(i, atlasColumns) * pitch + ATLAS_PADDING\n let totalAlpha = 0\n for (let y = 0; y < cell; y++) {\n for (let x = 0; x < cell; x++) {\n const src = (y * cell + x) * 4\n const dst = (tileY + y) * atlasW + tileX + x\n rgbaAtlas[dst * 4] = tile[src]\n rgbaAtlas[dst * 4 + 1] = tile[src + 1]\n rgbaAtlas[dst * 4 + 2] = tile[src + 2]\n rgbaAtlas[dst * 4 + 3] = tile[src + 3]\n // The coverage plane is the alpha channel, which keeps blankGlyphId and\n // every structural consumer meaningful on a chromatic profile.\n coverageAtlas[dst] = tile[src + 3]\n totalAlpha += tile[src + 3]\n }\n }\n coverage[i] = rdiv(totalAlpha * 65535, cell * cell * 255)\n\n const small = boxFilter(sources[i].image, 8, 8)\n samples.set(small, i * 256)\n let lo = 0\n let hi = 0\n for (let k = 0; k < 64; k++) {\n // Same 0.5 threshold as raster-v1's mask rule (§13); ties are ink.\n if (small[k * 4 + 3] >= 128) {\n if (k < 32) lo |= 1 << k\n else hi |= 1 << (k - 32)\n }\n }\n masksLo[i] = lo >>> 0\n masksHi[i] = hi >>> 0\n }\n\n const glyphs = sources.map((g) => g.char)\n // There is no font, so the slot carrying a font's identity carries the\n // identity of the source images instead: same role, different provenance.\n let total = 0\n for (const g of sources) total += g.image.data.length\n const imageBytes = new Uint8Array(total)\n let at = 0\n for (const g of sources) {\n imageBytes.set(\n g.image.data instanceof Uint8Array ? g.image.data : new Uint8Array(g.image.data),\n at,\n )\n at += g.image.data.length\n }\n const sourceHash = sha256(imageBytes)\n const charsetHash = sha256(glyphs.join(' '))\n const fingerprint = sha256(\n `asciip/1|chromatic-v1|${CHROMATIC_RASTER_VERSION}|images:${sourceHash}|charset:${charsetHash}` +\n `|cell:${cell}|pad:${ATLAS_PADDING}`,\n )\n\n const profile: AsciiProfile = {\n version: 1,\n id: options.id ?? 'chromatic',\n fingerprint,\n charsetHash,\n fontHash: sourceHash,\n glyphs,\n glyphCount: n,\n // A chromatic cell is square and has no baseline; these describe that box so\n // grid-v1 derives square cells without the matcher special-casing anything.\n metrics: {\n unitsPerEm: cell,\n ascent: cell,\n descent: 0,\n lineGap: 0,\n advanceUnits: cell,\n cellWidth: cell,\n cellHeight: cell,\n baseline: cell,\n },\n atlas: {\n width: atlasW,\n height: atlasH,\n pitchWidth: pitch,\n pitchHeight: pitch,\n cellWidth: cell,\n cellHeight: cell,\n padding: ATLAS_PADDING,\n columns: atlasColumns,\n data: coverageAtlas,\n rgba: rgbaAtlas,\n },\n structural: { masksLo, masksHi, coverage },\n chromatic: { samples },\n metadata: {\n id: options.id ?? 'chromatic',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AO;AAAA,MACL,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,SAASA;AAAA,MACT,SAAS;AAAA,MACT,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA,YAAY,EAAE,SAAS,SAAS,SAAS;AAAA,IACzC,WAAW,EAAE,QAAQ;AAAA,IACrB,UAAU;AAAA,MACR,IAAI,QAAQ,MAAM;AAAA,MAClB,SAAS;AAAA,MACT,iBAAiB;AAAA,IACnB;AAAA,EACF;AAEA,SAAO,EAAE,SAAS,QAAQ,cAAc,OAAO,EAAE;AACnD;","names":["ATLAS_PADDING"]}
1
+ {"version":3,"sources":["../src/config.ts","../src/chromatic.ts"],"sourcesContent":["import type { AlphaMode, ColorMode } from '@ascii-fx/core'\n\nexport interface AsciiProfileConfig {\n /**\n * Path to the font file, relative to the config file — or to the Vite root, for a config\n * passed to the plugin inline rather than loaded from a file.\n */\n font: string\n /** Which face of a .ttc/.otc collection: PostScript name or index. */\n face?: string | number\n charset?: string\n characters?: string | string[]\n /** Compile shape6-v1 data (ALGORITHM.md §18); `{ lut: true }` adds the dense LUT. */\n shape6?: boolean | { lut?: boolean }\n}\n\n/** Static build-time frame (spec §16). Matching happens at build, not runtime. */\nexport interface AsciiFrameConfig {\n /** Path to the source image (PNG in v1). Relative to the same place as a profile's `font`. */\n image: string\n /** Profile name from `profiles`. Default 'default'. */\n profile?: string\n columns?: number\n rows?: number\n color?: ColorMode\n alpha?: AlphaMode\n}\n\nexport interface AsciiConfig {\n profiles: Record<string, AsciiProfileConfig>\n frames?: Record<string, AsciiFrameConfig>\n}\n\nexport function defineAsciiConfig(config: AsciiConfig): AsciiConfig {\n return config\n}\n","// Builds chromatic-v1 profiles (ALGORITHM.md §C) from decoded colour images\n// rather than from a font. There is no rasterization step: colour emoji ship as\n// PNG assets (Noto, Twemoji, Fluent) or as bitmap strikes inside a font, so the\n// deterministic path is decode-then-box-filter, not outline flattening. That\n// makes raster-v1 (§13) inapplicable here by construction, not by omission.\n\nimport type { AsciiProfile, RawImage } from '@ascii-fx/core'\nimport { encodeProfile, idiv, nextPow2, rdiv } from '@ascii-fx/core'\nimport { COMPILER_VERSION, sha256 } from './profile.js'\n\nconst ATLAS_PADDING = 4\n/**\n * Reference cell for chromatic profiles. Square, unlike a text cell, and sized\n * so `cell + 2 * ATLAS_PADDING` is already a power of two: the pow2 pitch rule\n * (§13) exists so padding survives mip levels, and any other cell size rounds\n * up and wastes the difference. 32 would round 40 up to 64 and throw away 61%\n * of the atlas; 24 fits 32 exactly. The efficient sizes are 24, 56, and 120.\n */\nexport const CHROMATIC_CELL = 24\nexport const CHROMATIC_RASTER_VERSION = 'raster-chromatic-v1'\n\nexport interface ChromaticGlyphSource {\n /** The grapheme this glyph draws; may be several code points (ZWJ, VS16, modifiers). */\n char: string\n image: RawImage\n}\n\nexport interface BuildChromaticOptions {\n glyphs: readonly ChromaticGlyphSource[]\n /** Reference cell size in px, square. Default CHROMATIC_CELL (24). */\n cellSize?: number\n id?: string\n}\n\nexport interface BuiltChromaticProfile {\n profile: AsciiProfile\n binary: Uint8Array\n}\n\n/**\n * Alpha-weighted box filter, the same rule as reduce-v1 (§4): colour is\n * weighted by alpha so transparent pixels cannot drag the mean toward whatever\n * RGB happens to sit under them, while alpha itself is a plain mean.\n */\nfunction boxFilter(img: RawImage, tw: number, th: number): Uint8Array {\n const { width: w, height: h, data } = img\n const out = new Uint8Array(tw * th * 4)\n for (let ty = 0; ty < th; ty++) {\n const y0 = idiv(ty * h, th)\n const y1 = Math.max(y0 + 1, idiv((ty + 1) * h, th))\n for (let tx = 0; tx < tw; tx++) {\n const x0 = idiv(tx * w, tw)\n const x1 = Math.max(x0 + 1, idiv((tx + 1) * w, tw))\n let sr = 0\n let sg = 0\n let sb = 0\n let sa = 0\n let count = 0\n for (let y = y0; y < y1; y++) {\n for (let x = x0; x < x1; x++) {\n const p = (y * w + x) * 4\n const a = data[p + 3]\n sr += data[p] * a\n sg += data[p + 1] * a\n sb += data[p + 2] * a\n sa += a\n count++\n }\n }\n const q = (ty * tw + tx) * 4\n if (sa === 0) {\n out[q] = 0\n out[q + 1] = 0\n out[q + 2] = 0\n out[q + 3] = 0\n } else {\n out[q] = rdiv(sr, sa)\n out[q + 1] = rdiv(sg, sa)\n out[q + 2] = rdiv(sb, sa)\n out[q + 3] = rdiv(sa, count)\n }\n }\n }\n return out\n}\n\nexport function buildChromaticProfile(options: BuildChromaticOptions): BuiltChromaticProfile {\n const sources = options.glyphs\n const n = sources.length\n if (n === 0) throw new Error('buildChromaticProfile needs at least one glyph.')\n if (n > 65536)\n throw new Error(`Chromatic profiles hold at most 65536 glyphs (got ${n}); glyph ids are u16.`)\n\n const seen = new Set<string>()\n for (const g of sources) {\n if (g.char.length === 0) throw new Error('A chromatic glyph has an empty character.')\n if (seen.has(g.char)) {\n throw new Error(\n `Duplicate chromatic glyph ${JSON.stringify(g.char)}. Each grapheme may appear once.`,\n )\n }\n seen.add(g.char)\n if (g.image.width < 1 || g.image.height < 1) {\n throw new Error(`Glyph ${JSON.stringify(g.char)} has an empty image.`)\n }\n if (g.image.data.length !== g.image.width * g.image.height * 4) {\n throw new Error(`Glyph ${JSON.stringify(g.char)} image data is not width * height * 4.`)\n }\n }\n\n const cell = options.cellSize ?? CHROMATIC_CELL\n if (!Number.isInteger(cell) || cell < 8)\n throw new Error(`cellSize must be an integer >= 8 (got ${cell}).`)\n\n const pitch = nextPow2(cell + 2 * ATLAS_PADDING)\n let atlasColumns = 1\n while (atlasColumns * atlasColumns < n) atlasColumns++\n const atlasRows = idiv(n + atlasColumns - 1, atlasColumns)\n const atlasW = atlasColumns * pitch\n const atlasH = atlasRows * pitch\n\n const coverageAtlas = new Uint8Array(atlasW * atlasH)\n const rgbaAtlas = new Uint8Array(atlasW * atlasH * 4)\n const samples = new Uint8Array(n * 256)\n const masksLo = new Uint32Array(n)\n const masksHi = new Uint32Array(n)\n const coverage = new Uint16Array(n)\n\n for (let i = 0; i < n; i++) {\n const tile = boxFilter(sources[i].image, cell, cell)\n const tileX = (i % atlasColumns) * pitch + ATLAS_PADDING\n const tileY = idiv(i, atlasColumns) * pitch + ATLAS_PADDING\n let totalAlpha = 0\n for (let y = 0; y < cell; y++) {\n for (let x = 0; x < cell; x++) {\n const src = (y * cell + x) * 4\n const dst = (tileY + y) * atlasW + tileX + x\n rgbaAtlas[dst * 4] = tile[src]\n rgbaAtlas[dst * 4 + 1] = tile[src + 1]\n rgbaAtlas[dst * 4 + 2] = tile[src + 2]\n rgbaAtlas[dst * 4 + 3] = tile[src + 3]\n // The coverage plane is the alpha channel, which keeps blankGlyphId and\n // every structural consumer meaningful on a chromatic profile.\n coverageAtlas[dst] = tile[src + 3]\n totalAlpha += tile[src + 3]\n }\n }\n coverage[i] = rdiv(totalAlpha * 65535, cell * cell * 255)\n\n const small = boxFilter(sources[i].image, 8, 8)\n samples.set(small, i * 256)\n let lo = 0\n let hi = 0\n for (let k = 0; k < 64; k++) {\n // Same 0.5 threshold as raster-v1's mask rule (§13); ties are ink.\n if (small[k * 4 + 3] >= 128) {\n if (k < 32) lo |= 1 << k\n else hi |= 1 << (k - 32)\n }\n }\n masksLo[i] = lo >>> 0\n masksHi[i] = hi >>> 0\n }\n\n const glyphs = sources.map((g) => g.char)\n // There is no font, so the slot carrying a font's identity carries the\n // identity of the source images instead: same role, different provenance.\n let total = 0\n for (const g of sources) total += g.image.data.length\n const imageBytes = new Uint8Array(total)\n let at = 0\n for (const g of sources) {\n imageBytes.set(\n g.image.data instanceof Uint8Array ? g.image.data : new Uint8Array(g.image.data),\n at,\n )\n at += g.image.data.length\n }\n const sourceHash = sha256(imageBytes)\n const charsetHash = sha256(glyphs.join(' '))\n const fingerprint = sha256(\n `asciip/1|chromatic-v1|${CHROMATIC_RASTER_VERSION}|images:${sourceHash}|charset:${charsetHash}` +\n `|cell:${cell}|pad:${ATLAS_PADDING}`,\n )\n\n const profile: AsciiProfile = {\n version: 1,\n id: options.id ?? 'chromatic',\n fingerprint,\n charsetHash,\n fontHash: sourceHash,\n glyphs,\n glyphCount: n,\n // A chromatic cell is square and has no baseline; these describe that box so\n // grid-v1 derives square cells without the matcher special-casing anything.\n metrics: {\n unitsPerEm: cell,\n ascent: cell,\n descent: 0,\n lineGap: 0,\n advanceUnits: cell,\n cellWidth: cell,\n cellHeight: cell,\n baseline: cell,\n },\n atlas: {\n width: atlasW,\n height: atlasH,\n pitchWidth: pitch,\n pitchHeight: pitch,\n cellWidth: cell,\n cellHeight: cell,\n padding: ATLAS_PADDING,\n columns: atlasColumns,\n data: coverageAtlas,\n rgba: rgbaAtlas,\n },\n structural: { masksLo, masksHi, coverage },\n chromatic: { samples },\n metadata: {\n id: options.id ?? 'chromatic',\n charset: 'chromatic',\n compilerVersion: COMPILER_VERSION,\n },\n }\n\n return { profile, binary: encodeProfile(profile) }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiCO,SAAS,kBAAkB,QAAkC;AAClE,SAAO;AACT;;;AC5BA,SAAS,eAAe,MAAM,UAAU,YAAY;AAGpD,IAAMA,iBAAgB;AAQf,IAAM,iBAAiB;AACvB,IAAM,2BAA2B;AAyBxC,SAAS,UAAU,KAAe,IAAY,IAAwB;AACpE,QAAM,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,IAAI;AACtC,QAAM,MAAM,IAAI,WAAW,KAAK,KAAK,CAAC;AACtC,WAAS,KAAK,GAAG,KAAK,IAAI,MAAM;AAC9B,UAAM,KAAK,KAAK,KAAK,GAAG,EAAE;AAC1B,UAAM,KAAK,KAAK,IAAI,KAAK,GAAG,MAAM,KAAK,KAAK,GAAG,EAAE,CAAC;AAClD,aAAS,KAAK,GAAG,KAAK,IAAI,MAAM;AAC9B,YAAM,KAAK,KAAK,KAAK,GAAG,EAAE;AAC1B,YAAM,KAAK,KAAK,IAAI,KAAK,GAAG,MAAM,KAAK,KAAK,GAAG,EAAE,CAAC;AAClD,UAAI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ACpC,QAAM,cAAc,OAAO,OAAO,KAAK,GAAG,CAAC;AAC3C,QAAM,cAAc;AAAA,IAClB,yBAAyB,wBAAwB,WAAW,UAAU,YAAY,WAAW,SAClF,IAAI,QAAQA,cAAa;AAAA,EACtC;AAEA,QAAM,UAAwB;AAAA,IAC5B,SAAS;AAAA,IACT,IAAI,QAAQ,MAAM;AAAA,IAClB;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA,YAAY;AAAA;AAAA;AAAA,IAGZ,SAAS;AAAA,MACP,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,SAAS;AAAA,MACT,cAAc;AAAA,MACd,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,UAAU;AAAA,IACZ;AAAA,IACA,OAAO;AAAA,MACL,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,SAASA;AAAA,MACT,SAAS;AAAA,MACT,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA,YAAY,EAAE,SAAS,SAAS,SAAS;AAAA,IACzC,WAAW,EAAE,QAAQ;AAAA,IACrB,UAAU;AAAA,MACR,IAAI,QAAQ,MAAM;AAAA,MAClB,SAAS;AAAA,MACT,iBAAiB;AAAA,IACnB;AAAA,EACF;AAEA,SAAO,EAAE,SAAS,QAAQ,cAAc,OAAO,EAAE;AACnD;","names":["ATLAS_PADDING"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ascii-fx/compiler",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Build-time compiler for ASCII FX: deterministic font rasterization, glyph atlases, .asciip/.asciif generation.",
5
5
  "keywords": [
6
6
  "ascii",
@@ -41,14 +41,14 @@
41
41
  "access": "public"
42
42
  },
43
43
  "dependencies": {
44
- "@ascii-fx/core": "0.9.0",
44
+ "@ascii-fx/core": "0.10.0",
45
45
  "fontkit": "^2.0.4",
46
46
  "pngjs": "^7.0.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@types/node": "^26.6.5",
49
+ "@types/node": "^26.6.6",
50
50
  "@types/pngjs": "^6.0.5",
51
- "tsup": "^8.5.1",
51
+ "tsup": "^9.0.0",
52
52
  "typescript": "^7.0.2"
53
53
  },
54
54
  "engines": {