@three-flatland/bake 0.1.0-alpha.1 → 0.1.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,104 @@
1
+ import __tsdown_shims_path from 'node:path';
2
+ import __tsdown_shims_url from 'node:url';
3
+ //#region src/types.d.ts
4
+ /**
5
+ * Contract every baker must satisfy.
6
+ *
7
+ * Bakers are registered by package.json via a `flatland.bake` field:
8
+ *
9
+ * ```json
10
+ * {
11
+ * "flatland": {
12
+ * "bake": [
13
+ * { "name": "font", "description": "Bake SlugFont", "entry": "./dist/cli.js" }
14
+ * ]
15
+ * }
16
+ * }
17
+ * ```
18
+ *
19
+ * Entry modules must default-export a `Baker`. The legacy `flatland.bakers`
20
+ * shape is still accepted for one release with a deprecation warning.
21
+ */
22
+ interface Baker {
23
+ /** Subcommand name used on the CLI: `flatland-bake <name> ...` */
24
+ name: string;
25
+ /** One-line description shown by `flatland-bake --list`. */
26
+ description: string;
27
+ /**
28
+ * Run the baker with the CLI args that follow the subcommand.
29
+ * Resolves to an exit code (0 = success).
30
+ */
31
+ run(args: string[]): Promise<number>;
32
+ /** Optional multiline usage string for `flatland-bake <name> --help`. */
33
+ usage?(): string;
34
+ }
35
+ interface BakerRegistration {
36
+ name: string;
37
+ description: string;
38
+ entry: string;
39
+ /** Package that declared the baker — used in diagnostics. */
40
+ packageName: string;
41
+ /** Absolute path on disk the `entry` resolves to. */
42
+ resolvedEntry: string;
43
+ }
44
+ interface FlatlandManifestEntry {
45
+ name: string;
46
+ description: string;
47
+ entry: string;
48
+ }
49
+ interface FlatlandManifest {
50
+ /** Current registration shape. */
51
+ bake?: FlatlandManifestEntry[];
52
+ /** @deprecated Legacy shape; use `bake` instead. Accepted for one release. */
53
+ bakers?: FlatlandManifestEntry[];
54
+ }
55
+ /**
56
+ * Shared option interface for every loader that speaks the
57
+ * "try baked sibling first → fall back to in-memory generation" pattern.
58
+ *
59
+ * Loaders extend this with their asset-specific options:
60
+ *
61
+ * ```ts
62
+ * interface MyLoaderOptions extends BakedAssetLoaderOptions {
63
+ * // asset-specific fields
64
+ * }
65
+ * ```
66
+ */
67
+ interface BakedAssetLoaderOptions {
68
+ /**
69
+ * Generate this asset's derived data in the browser on every load
70
+ * instead of loading a pre-baked sidecar. The runtime generator
71
+ * becomes the canonical source — no sidecar probe, no devtime "no
72
+ * baked sibling" warning, just a fresh generate on every load.
73
+ *
74
+ * If you ask for the data (e.g. `normals: true`), you always get it.
75
+ * `forceRuntime` chooses *where* the generation happens — browser vs
76
+ * CI — it does not choose whether you get the data. The default path
77
+ * still produces the data on every miss; this flag just commits to
78
+ * "the browser is always where it's produced for this asset."
79
+ *
80
+ * Use when runtime really is the right home for the generation:
81
+ * procedurally varied content, throwaway prototypes, asset bundles
82
+ * where shipping the sidecar isn't worth the bytes. Not a dev-
83
+ * iteration knob — the default path (probe → generate on miss + warn
84
+ * pointing at `flatland-bake`) already handles iteration.
85
+ *
86
+ * Default `false`. Mirrors `SlugFontLoader.forceRuntime` — one flag
87
+ * across every baked-asset loader in the codebase.
88
+ */
89
+ forceRuntime?: boolean;
90
+ }
91
+ /**
92
+ * Metadata stamped into a baked PNG's `tEXt` chunk under the key
93
+ * `flatland`. Read back by `probeBakedSibling` to validate the baked
94
+ * file still matches the descriptor a consumer is about to use.
95
+ */
96
+ interface BakedSidecarMetadata {
97
+ /** Content hash of the descriptor that produced this file. */
98
+ hash: string;
99
+ /** Schema version of the metadata format itself. */
100
+ v: 1;
101
+ }
102
+ //#endregion
103
+ export { BakedAssetLoaderOptions, BakedSidecarMetadata, Baker, BakerRegistration, FlatlandManifest, FlatlandManifestEntry };
104
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;UAkBiB;;EAEf;;EAEA;;;;;EAKA,IAAI,iBAAiB;;EAErB;;UAGe;EACf;EACA;EACA;;EAEA;;EAEA;;UAGe;EACf;EACA;EACA;;UAGe;;EAEf,OAAO;;EAEP,SAAS;;;;;;;;;;;;;;UAeM;;;;;;;;;;;;;;;;;;;;;;EAsBf;;;;;;;UAQe;;EAEf;;EAEA"}
package/dist/types.js CHANGED
@@ -1 +1,4 @@
1
- //# sourceMappingURL=types.js.map
1
+ import "node:path";
2
+ import "node:url";
3
+ import.meta.url;
4
+ export {};
@@ -0,0 +1,22 @@
1
+ import __tsdown_shims_path from 'node:path';
2
+ import __tsdown_shims_url from 'node:url';
3
+ import { BakedSidecarMetadata } from "./types.js";
4
+ //#region src/writeSidecar.d.ts
5
+ /**
6
+ * Write a PNG with a flatland metadata `tEXt` chunk stamped in.
7
+ *
8
+ * The stamp lives under keyword `flatland` and carries the descriptor
9
+ * hash so downstream `probeBakedSibling` calls can invalidate the
10
+ * baked file when the descriptor changes.
11
+ */
12
+ declare function writeSidecarPng(outputPath: string, pixels: Uint8Array, width: number, height: number, metadata: BakedSidecarMetadata): void;
13
+ /**
14
+ * Write a sidecar descriptor JSON file adjacent to the source asset.
15
+ *
16
+ * Same file format `flatland-bake <subcommand> --descriptor` consumes,
17
+ * so the runtime and CLI agree on one shape.
18
+ */
19
+ declare function writeSidecarJson(outputPath: string, descriptor: unknown): void;
20
+ //#endregion
21
+ export { writeSidecarJson, writeSidecarPng };
22
+ //# sourceMappingURL=writeSidecar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeSidecar.d.ts","names":[],"sources":["../src/writeSidecar.ts"],"mappings":";;;;;;;;;;;iBAYgB,gBACd,oBACA,QAAQ,YACR,eACA,gBACA,UAAU;;;;;;;iBAeI,iBAAiB,oBAAoB"}
@@ -1,60 +1,84 @@
1
+ import "node:path";
2
+ import "node:url";
3
+ import.meta.url;
1
4
  import { writeFileSync } from "node:fs";
2
5
  import { Buffer } from "node:buffer";
3
6
  import { PNG } from "pngjs";
7
+ //#region src/writeSidecar.ts
8
+ /**
9
+ * Write a PNG with a flatland metadata `tEXt` chunk stamped in.
10
+ *
11
+ * The stamp lives under keyword `flatland` and carries the descriptor
12
+ * hash so downstream `probeBakedSibling` calls can invalidate the
13
+ * baked file when the descriptor changes.
14
+ */
4
15
  function writeSidecarPng(outputPath, pixels, width, height, metadata) {
5
- const png = new PNG({ width, height });
6
- png.data = Buffer.from(pixels.buffer, pixels.byteOffset, pixels.byteLength);
7
- const buffer = PNG.sync.write(png);
8
- const stamped = injectTextChunk(buffer, "flatland", JSON.stringify(metadata));
9
- writeFileSync(outputPath, stamped);
16
+ const png = new PNG({
17
+ width,
18
+ height
19
+ });
20
+ png.data = Buffer.from(pixels.buffer, pixels.byteOffset, pixels.byteLength);
21
+ writeFileSync(outputPath, injectTextChunk(PNG.sync.write(png), "flatland", JSON.stringify(metadata)));
10
22
  }
23
+ /**
24
+ * Write a sidecar descriptor JSON file adjacent to the source asset.
25
+ *
26
+ * Same file format `flatland-bake <subcommand> --descriptor` consumes,
27
+ * so the runtime and CLI agree on one shape.
28
+ */
11
29
  function writeSidecarJson(outputPath, descriptor) {
12
- writeFileSync(outputPath, JSON.stringify(descriptor, null, 2) + "\n");
30
+ writeFileSync(outputPath, JSON.stringify(descriptor, null, 2) + "\n");
13
31
  }
32
+ /**
33
+ * Inject a `tEXt` chunk immediately after the IHDR so the metadata is
34
+ * near the head of the file — `probeBakedSibling` range-fetches ~4 KB
35
+ * to read the stamp, so placement matters.
36
+ */
14
37
  function injectTextChunk(pngBuffer, keyword, value) {
15
- const sigLen = 8;
16
- if (pngBuffer[sigLen + 4] !== 73 || pngBuffer[sigLen + 5] !== 72 || pngBuffer[sigLen + 6] !== 68 || pngBuffer[sigLen + 7] !== 82) {
17
- return pngBuffer;
18
- }
19
- const ihdrLength = pngBuffer.readUInt32BE(sigLen);
20
- const ihdrEnd = sigLen + 8 + ihdrLength + 4;
21
- const textData = Buffer.concat([
22
- Buffer.from(keyword, "latin1"),
23
- Buffer.from([0]),
24
- Buffer.from(value, "latin1")
25
- ]);
26
- const textType = Buffer.from("tEXt", "latin1");
27
- const textLen = Buffer.alloc(4);
28
- textLen.writeUInt32BE(textData.length, 0);
29
- const textCrc = Buffer.alloc(4);
30
- textCrc.writeUInt32BE(crc32(Buffer.concat([textType, textData])), 0);
31
- const textChunk = Buffer.concat([textLen, textType, textData, textCrc]);
32
- return Buffer.concat([pngBuffer.subarray(0, ihdrEnd), textChunk, pngBuffer.subarray(ihdrEnd)]);
38
+ const sigLen = 8;
39
+ if (pngBuffer[12] !== 73 || pngBuffer[13] !== 72 || pngBuffer[14] !== 68 || pngBuffer[15] !== 82) return pngBuffer;
40
+ const ihdrEnd = 16 + pngBuffer.readUInt32BE(sigLen) + 4;
41
+ const textData = Buffer.concat([
42
+ Buffer.from(keyword, "latin1"),
43
+ Buffer.from([0]),
44
+ Buffer.from(value, "latin1")
45
+ ]);
46
+ const textType = Buffer.from("tEXt", "latin1");
47
+ const textLen = Buffer.alloc(4);
48
+ textLen.writeUInt32BE(textData.length, 0);
49
+ const textCrc = Buffer.alloc(4);
50
+ textCrc.writeUInt32BE(crc32(Buffer.concat([textType, textData])), 0);
51
+ const textChunk = Buffer.concat([
52
+ textLen,
53
+ textType,
54
+ textData,
55
+ textCrc
56
+ ]);
57
+ return Buffer.concat([
58
+ pngBuffer.subarray(0, ihdrEnd),
59
+ textChunk,
60
+ pngBuffer.subarray(ihdrEnd)
61
+ ]);
33
62
  }
34
63
  let _crcTable = null;
35
64
  function crcTable() {
36
- if (_crcTable) return _crcTable;
37
- const table = new Uint32Array(256);
38
- for (let n = 0; n < 256; n++) {
39
- let c = n;
40
- for (let k = 0; k < 8; k++) {
41
- c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
42
- }
43
- table[n] = c >>> 0;
44
- }
45
- _crcTable = table;
46
- return table;
65
+ if (_crcTable) return _crcTable;
66
+ const table = /* @__PURE__ */ new Uint32Array(256);
67
+ for (let n = 0; n < 256; n++) {
68
+ let c = n;
69
+ for (let k = 0; k < 8; k++) c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
70
+ table[n] = c >>> 0;
71
+ }
72
+ _crcTable = table;
73
+ return table;
47
74
  }
48
75
  function crc32(buffer) {
49
- const table = crcTable();
50
- let crc = 4294967295;
51
- for (let i = 0; i < buffer.length; i++) {
52
- crc = (table[(crc ^ buffer[i]) & 255] ^ crc >>> 8) >>> 0;
53
- }
54
- return (crc ^ 4294967295) >>> 0;
76
+ const table = crcTable();
77
+ let crc = 4294967295;
78
+ for (let i = 0; i < buffer.length; i++) crc = (table[(crc ^ buffer[i]) & 255] ^ crc >>> 8) >>> 0;
79
+ return (crc ^ 4294967295) >>> 0;
55
80
  }
56
- export {
57
- writeSidecarJson,
58
- writeSidecarPng
59
- };
81
+ //#endregion
82
+ export { writeSidecarJson, writeSidecarPng };
83
+
60
84
  //# sourceMappingURL=writeSidecar.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/writeSidecar.ts"],"sourcesContent":["import { writeFileSync } from 'node:fs'\nimport { Buffer } from 'node:buffer'\nimport { PNG } from 'pngjs'\nimport type { BakedSidecarMetadata } from './types.js'\n\n/**\n * Write a PNG with a flatland metadata `tEXt` chunk stamped in.\n *\n * The stamp lives under keyword `flatland` and carries the descriptor\n * hash so downstream `probeBakedSibling` calls can invalidate the\n * baked file when the descriptor changes.\n */\nexport function writeSidecarPng(\n outputPath: string,\n pixels: Uint8Array,\n width: number,\n height: number,\n metadata: BakedSidecarMetadata\n): void {\n const png = new PNG({ width, height })\n png.data = Buffer.from(pixels.buffer, pixels.byteOffset, pixels.byteLength)\n const buffer = PNG.sync.write(png)\n const stamped = injectTextChunk(buffer, 'flatland', JSON.stringify(metadata))\n writeFileSync(outputPath, stamped)\n}\n\n/**\n * Write a sidecar descriptor JSON file adjacent to the source asset.\n *\n * Same file format `flatland-bake <subcommand> --descriptor` consumes,\n * so the runtime and CLI agree on one shape.\n */\nexport function writeSidecarJson(outputPath: string, descriptor: unknown): void {\n writeFileSync(outputPath, JSON.stringify(descriptor, null, 2) + '\\n')\n}\n\n/**\n * Inject a `tEXt` chunk immediately after the IHDR so the metadata is\n * near the head of the file — `probeBakedSibling` range-fetches ~4 KB\n * to read the stamp, so placement matters.\n */\nfunction injectTextChunk(pngBuffer: Buffer, keyword: string, value: string): Buffer {\n const sigLen = 8\n // IHDR type starts 4 bytes after the length prefix: [len][I][H][D][R]...\n if (\n pngBuffer[sigLen + 4] !== 0x49 ||\n pngBuffer[sigLen + 5] !== 0x48 ||\n pngBuffer[sigLen + 6] !== 0x44 ||\n pngBuffer[sigLen + 7] !== 0x52\n ) {\n return pngBuffer\n }\n const ihdrLength = pngBuffer.readUInt32BE(sigLen)\n const ihdrEnd = sigLen + 8 + ihdrLength + 4 // length(4) + type(4) + data + CRC(4)\n\n const textData = Buffer.concat([\n Buffer.from(keyword, 'latin1'),\n Buffer.from([0]),\n Buffer.from(value, 'latin1'),\n ])\n const textType = Buffer.from('tEXt', 'latin1')\n const textLen = Buffer.alloc(4)\n textLen.writeUInt32BE(textData.length, 0)\n const textCrc = Buffer.alloc(4)\n textCrc.writeUInt32BE(crc32(Buffer.concat([textType, textData])), 0)\n const textChunk = Buffer.concat([textLen, textType, textData, textCrc])\n\n return Buffer.concat([pngBuffer.subarray(0, ihdrEnd), textChunk, pngBuffer.subarray(ihdrEnd)])\n}\n\nlet _crcTable: Uint32Array | null = null\nfunction crcTable(): Uint32Array {\n if (_crcTable) return _crcTable\n const table = new Uint32Array(256)\n for (let n = 0; n < 256; n++) {\n let c = n\n for (let k = 0; k < 8; k++) {\n c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1\n }\n table[n] = c >>> 0\n }\n _crcTable = table\n return table\n}\n\nfunction crc32(buffer: Buffer): number {\n const table = crcTable()\n let crc = 0xffffffff\n for (let i = 0; i < buffer.length; i++) {\n crc = (table[(crc ^ buffer[i]!) & 0xff]! ^ (crc >>> 8)) >>> 0\n }\n return (crc ^ 0xffffffff) >>> 0\n}\n"],"mappings":"AAA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AO,OAAO,OAAO,CAAC,UAAU,SAAS,GAAG,OAAO,GAAG,WAAW,UAAU,SAAS,OAAO,CAAC,CAAC;AAC/F;AAEA,IAAI,YAAgC;AACpC,SAAS,WAAwB;AAC/B,MAAI,UAAW,QAAO;AACtB,QAAM,QAAQ,IAAI,YAAY,GAAG;AACjC,WAAS,IAAI,GAAG,IAAI,KAAK,KAAK;AAC5B,QAAI,IAAI;AACR,aAAS,IAAI,GAAG,IAAI,GAAG,KAAK;AAC1B,UAAI,IAAI,IAAI,aAAc,MAAM,IAAK,MAAM;AAAA,IAC7C;AACA,UAAM,CAAC,IAAI,MAAM;AAAA,EACnB;AACA,cAAY;AACZ,SAAO;AACT;AAEA,SAAS,MAAM,QAAwB;AACrC,QAAM,QAAQ,SAAS;AACvB,MAAI,MAAM;AACV,WAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACtC,WAAO,OAAO,MAAM,OAAO,CAAC,KAAM,GAAI,IAAM,QAAQ,OAAQ;AAAA,EAC9D;AACA,UAAQ,MAAM,gBAAgB;AAChC;","names":[]}
1
+ {"version":3,"file":"writeSidecar.js","names":[],"sources":["../src/writeSidecar.ts"],"sourcesContent":["import { writeFileSync } from 'node:fs'\nimport { Buffer } from 'node:buffer'\nimport { PNG } from 'pngjs'\nimport type { BakedSidecarMetadata } from './types.js'\n\n/**\n * Write a PNG with a flatland metadata `tEXt` chunk stamped in.\n *\n * The stamp lives under keyword `flatland` and carries the descriptor\n * hash so downstream `probeBakedSibling` calls can invalidate the\n * baked file when the descriptor changes.\n */\nexport function writeSidecarPng(\n outputPath: string,\n pixels: Uint8Array,\n width: number,\n height: number,\n metadata: BakedSidecarMetadata\n): void {\n const png = new PNG({ width, height })\n png.data = Buffer.from(pixels.buffer, pixels.byteOffset, pixels.byteLength)\n const buffer = PNG.sync.write(png)\n const stamped = injectTextChunk(buffer, 'flatland', JSON.stringify(metadata))\n writeFileSync(outputPath, stamped)\n}\n\n/**\n * Write a sidecar descriptor JSON file adjacent to the source asset.\n *\n * Same file format `flatland-bake <subcommand> --descriptor` consumes,\n * so the runtime and CLI agree on one shape.\n */\nexport function writeSidecarJson(outputPath: string, descriptor: unknown): void {\n writeFileSync(outputPath, JSON.stringify(descriptor, null, 2) + '\\n')\n}\n\n/**\n * Inject a `tEXt` chunk immediately after the IHDR so the metadata is\n * near the head of the file — `probeBakedSibling` range-fetches ~4 KB\n * to read the stamp, so placement matters.\n */\nfunction injectTextChunk(pngBuffer: Buffer, keyword: string, value: string): Buffer {\n const sigLen = 8\n // IHDR type starts 4 bytes after the length prefix: [len][I][H][D][R]...\n if (\n pngBuffer[sigLen + 4] !== 0x49 ||\n pngBuffer[sigLen + 5] !== 0x48 ||\n pngBuffer[sigLen + 6] !== 0x44 ||\n pngBuffer[sigLen + 7] !== 0x52\n ) {\n return pngBuffer\n }\n const ihdrLength = pngBuffer.readUInt32BE(sigLen)\n const ihdrEnd = sigLen + 8 + ihdrLength + 4 // length(4) + type(4) + data + CRC(4)\n\n const textData = Buffer.concat([Buffer.from(keyword, 'latin1'), Buffer.from([0]), Buffer.from(value, 'latin1')])\n const textType = Buffer.from('tEXt', 'latin1')\n const textLen = Buffer.alloc(4)\n textLen.writeUInt32BE(textData.length, 0)\n const textCrc = Buffer.alloc(4)\n textCrc.writeUInt32BE(crc32(Buffer.concat([textType, textData])), 0)\n const textChunk = Buffer.concat([textLen, textType, textData, textCrc])\n\n return Buffer.concat([pngBuffer.subarray(0, ihdrEnd), textChunk, pngBuffer.subarray(ihdrEnd)])\n}\n\nlet _crcTable: Uint32Array | null = null\nfunction crcTable(): Uint32Array {\n if (_crcTable) return _crcTable\n const table = new Uint32Array(256)\n for (let n = 0; n < 256; n++) {\n let c = n\n for (let k = 0; k < 8; k++) {\n c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1\n }\n table[n] = c >>> 0\n }\n _crcTable = table\n return table\n}\n\nfunction crc32(buffer: Buffer): number {\n const table = crcTable()\n let crc = 0xffffffff\n for (let i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AAW,UAAU,SAAS,OAAO;CAAC,CAAC;AAC/F;AAEA,IAAI,YAAgC;AACpC,SAAS,WAAwB;CAC/B,IAAI,WAAW,OAAO;CACtB,MAAM,wBAAQ,IAAI,YAAY,GAAG;CACjC,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,KAAK;EAC5B,IAAI,IAAI;EACR,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KACrB,IAAI,IAAI,IAAI,aAAc,MAAM,IAAK,MAAM;EAE7C,MAAM,KAAK,MAAM;CACnB;CACA,YAAY;CACZ,OAAO;AACT;AAEA,SAAS,MAAM,QAAwB;CACrC,MAAM,QAAQ,SAAS;CACvB,IAAI,MAAM;CACV,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KACjC,OAAO,OAAO,MAAM,OAAO,MAAO,OAAU,QAAQ,OAAQ;CAE9D,QAAQ,MAAM,gBAAgB;AAChC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@three-flatland/bake",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.1.0-alpha.2",
4
4
  "description": "Shared bake pipeline infrastructure — CLI, discovery, and browser-safe loader utilities for assets with offline-baked siblings",
5
5
  "type": "module",
6
6
  "bin": {
@@ -8,7 +8,6 @@
8
8
  },
9
9
  "exports": {
10
10
  ".": {
11
- "source": "./src/index.ts",
12
11
  "node": {
13
12
  "types": "./dist/node.d.ts",
14
13
  "import": "./dist/node.js"
@@ -23,7 +22,6 @@
23
22
  }
24
23
  },
25
24
  "./node": {
26
- "source": "./src/node.ts",
27
25
  "types": "./dist/node.d.ts",
28
26
  "import": "./dist/node.js"
29
27
  }
@@ -34,6 +32,27 @@
34
32
  "dist"
35
33
  ],
36
34
  "sideEffects": false,
35
+ "nx": {
36
+ "tags": [
37
+ "scope:foundation"
38
+ ],
39
+ "targets": {
40
+ "test": {
41
+ "executor": "nx:run-commands",
42
+ "options": {
43
+ "command": "vitest run",
44
+ "cwd": "{projectRoot}"
45
+ }
46
+ },
47
+ "lint": {
48
+ "executor": "nx:run-commands",
49
+ "options": {
50
+ "command": "oxlint --type-aware .",
51
+ "cwd": "{projectRoot}"
52
+ }
53
+ }
54
+ }
55
+ },
37
56
  "dependencies": {
38
57
  "pngjs": "^7.0.0"
39
58
  },
@@ -52,8 +71,8 @@
52
71
  "directory": "packages/bake"
53
72
  },
54
73
  "scripts": {
55
- "build": "tsup",
56
- "dev": "tsup --watch",
74
+ "build": "tsdown",
75
+ "dev": "tsdown --watch",
57
76
  "typecheck": "tsc --noEmit",
58
77
  "clean": "rm -rf dist"
59
78
  }
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Browser-safe surface of @three-flatland/bake.\n//\n// Types + runtime helpers usable from any environment (browser, node,\n// workers, deno). No `node:*` imports, no filesystem access.\n//\n// Consumers running in node that need the CLI, discovery, or sidecar\n// emission should import from '@three-flatland/bake/node' instead.\nexport type {\n Baker,\n BakerRegistration,\n FlatlandManifest,\n FlatlandManifestEntry,\n BakedAssetLoaderOptions,\n BakedSidecarMetadata,\n} from './types.js'\n\nexport {\n bakedSiblingURL,\n probeBakedSibling,\n readPngTextChunk,\n hashDescriptor,\n} from './sidecar.js'\n\nexport { devtimeWarn, _resetDevtimeWarnings } from './devtimeWarn.js'\n"],"mappings":"AAgBA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,aAAa,6BAA6B;","names":[]}
package/dist/node.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/node.ts"],"sourcesContent":["// Node-only surface of @three-flatland/bake.\n//\n// Re-exports the browser-safe surface plus filesystem helpers and the\n// manifest discovery used by the `flatland-bake` CLI. Importing this\n// entry pulls in `node:fs`, `node:path`, and `pngjs` — avoid it from\n// bundles targeting the browser.\n\nexport * from './index.js'\nexport { discoverBakers } from './discovery.js'\nexport { writeSidecarPng, writeSidecarJson } from './writeSidecar.js'\n"],"mappings":"AAOA,cAAc;AACd,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB,wBAAwB;","names":[]}
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}