@joycostudio/chopper 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -102,22 +102,17 @@ interface ImageAssetRecipe {
102
102
  type AssetRecipe = GlbAssetRecipe | ImageAssetRecipe;
103
103
  declare const defineRecipe: <const T extends AssetRecipe>(recipe: T) => T;
104
104
 
105
- type ChopperOutput = {
106
- mode: 'replace';
107
- } | {
108
- mode: 'template';
109
- path: string;
110
- };
111
105
  interface ChopperRule {
112
106
  include: readonly string[];
113
107
  exclude?: readonly string[];
114
108
  recipe: AssetRecipe;
115
- output: ChopperOutput;
109
+ path?: string;
116
110
  }
117
111
  interface ChopperConfig {
112
+ output: string;
118
113
  rules: readonly ChopperRule[];
119
114
  concurrency?: number;
120
115
  }
121
116
  declare const defineConfig: <const T extends ChopperConfig>(config: T) => T;
122
117
 
123
- export { type ChopperConfig, type ChopperOutput, type ChopperRule, defineConfig, defineRecipe };
118
+ export { type ChopperConfig, type ChopperRule, defineConfig, defineRecipe };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/recipes.ts","../../src/config/index.ts"],"names":[],"mappings":";AA2NO,IAAM,YAAA,GAAe,CAA8B,MAAA,KAAiB;;;ACzMpE,IAAM,YAAA,GAAe,CAAgC,MAAA,KAAiB","file":"index.js","sourcesContent":["export const RECIPE_SCHEMA_VERSION = 1 as const\n\nexport type TextureSize = readonly [width: number, height: number]\n\ninterface SizedEncoding {\n /** Maximum dimensions. Aspect ratio is preserved and images are not enlarged. */\n maxSize?: TextureSize\n}\n\nexport interface WebpEncoding extends SizedEncoding {\n codec: 'webp'\n quality?: number\n effort?: number\n lossless?: boolean\n /** WebP near-lossless preprocessing strength, from 0 (lossy) to 100. */\n nearLossless?: number\n}\n\nexport interface AvifEncoding extends SizedEncoding {\n codec: 'avif'\n quality?: number\n effort?: number\n lossless?: boolean\n chromaSubsampling?: '4:2:0' | '4:4:4'\n}\n\nexport interface JpegEncoding extends SizedEncoding {\n codec: 'jpeg'\n quality?: number\n chromaSubsampling?: '4:2:0' | '4:4:4'\n}\n\nexport interface PngEncoding extends SizedEncoding {\n codec: 'png'\n}\n\nexport interface UastcEncoding extends SizedEncoding {\n codec: 'ktx2'\n mode: 'uastc'\n colorSpace?: 'srgb' | 'linear'\n normalMap?: boolean\n level?: 0 | 1 | 2 | 3 | 4\n mipmaps?: boolean\n zstd?: boolean\n rdo?: { lambda?: number }\n}\n\nexport interface Etc1sEncoding extends SizedEncoding {\n codec: 'ktx2'\n mode: 'etc1s'\n colorSpace?: 'srgb' | 'linear'\n normalMap?: boolean\n quality?: number\n compression?: 0 | 1 | 2 | 3 | 4 | 5 | 6\n mipmaps?: boolean\n}\n\nexport type RasterEncoding = WebpEncoding | AvifEncoding | JpegEncoding | PngEncoding\n\nexport type ImageEncoding = RasterEncoding | UastcEncoding | Etc1sEncoding\n\nexport type GlbProperty =\n | 'accessor'\n | 'animation'\n | 'buffer'\n | 'camera'\n | 'material'\n | 'mesh'\n | 'node'\n | 'primitive'\n | 'primitiveTarget'\n | 'skin'\n | 'texture'\n\nexport type GlbMethodRecipe =\n | {\n method: 'dedup'\n keepUniqueNames?: boolean\n propertyTypes?: readonly Extract<GlbProperty, 'accessor' | 'material' | 'mesh' | 'skin' | 'texture'>[]\n }\n | {\n method: 'prune'\n keepAttributes?: boolean\n keepExtras?: boolean\n keepLeaves?: boolean\n keepSolidTextures?: boolean\n propertyTypes?: readonly GlbProperty[]\n }\n | {\n method: 'resample'\n tolerance?: number\n cleanup?: boolean\n }\n\nexport type TextureSelector =\n | { by: 'slot'; slots: readonly string[] }\n | { by: 'name'; names: readonly string[] }\n | { by: 'index'; indices: readonly number[] }\n\nexport interface EmbeddedTextureRecipe {\n label: string\n select: TextureSelector\n encode: ImageEncoding\n}\n\nexport type GeometryEncoding = { codec: 'draco' } | { codec: 'meshopt' }\n\nexport interface GlbAssetRecipe {\n schemaVersion: typeof RECIPE_SCHEMA_VERSION\n kind: 'glb'\n methods?: readonly GlbMethodRecipe[]\n textures?: readonly EmbeddedTextureRecipe[]\n geometry?: GeometryEncoding | false\n}\n\nexport interface ImageAssetRecipe {\n schemaVersion: typeof RECIPE_SCHEMA_VERSION\n kind: 'image'\n encode: ImageEncoding\n}\n\nexport type AssetRecipe = GlbAssetRecipe | ImageAssetRecipe\n\nexport type NormalizedImageEncoding =\n | (Required<Omit<WebpEncoding, 'maxSize'>> & Pick<WebpEncoding, 'maxSize'>)\n | (Required<Omit<AvifEncoding, 'maxSize'>> & Pick<AvifEncoding, 'maxSize'>)\n | (Required<Omit<JpegEncoding, 'maxSize'>> & Pick<JpegEncoding, 'maxSize'>)\n | PngEncoding\n | (Required<Omit<UastcEncoding, 'maxSize' | 'rdo'>> & Pick<UastcEncoding, 'maxSize' | 'rdo'>)\n | (Required<Omit<Etc1sEncoding, 'maxSize'>> & Pick<Etc1sEncoding, 'maxSize'>)\n\nexport type NormalizedAssetRecipe =\n | {\n schemaVersion: typeof RECIPE_SCHEMA_VERSION\n kind: 'image'\n encode: NormalizedImageEncoding\n }\n | {\n schemaVersion: typeof RECIPE_SCHEMA_VERSION\n kind: 'glb'\n methods: readonly GlbMethodRecipe[]\n textures: readonly (Omit<EmbeddedTextureRecipe, 'encode'> & {\n encode: NormalizedImageEncoding\n })[]\n geometry: GeometryEncoding | false\n }\n\nexport const COLOR_TEXTURE_SLOTS = [\n 'baseColorTexture',\n 'emissiveTexture',\n 'specularColorTexture',\n 'sheenColorTexture',\n] as const\n\nexport const DIRECTIONAL_TEXTURE_SLOTS = ['normalTexture', 'clearcoatNormalTexture', 'anisotropyTexture'] as const\n\nexport const DATA_TEXTURE_SLOTS = [\n 'occlusionTexture',\n 'metallicRoughnessTexture',\n 'specularTexture',\n 'clearcoatTexture',\n 'clearcoatRoughnessTexture',\n 'sheenRoughnessTexture',\n 'transmissionTexture',\n 'thicknessTexture',\n 'iridescenceTexture',\n 'iridescenceThicknessTexture',\n] as const\n\nexport const DEFAULT_GLB_RECIPE: GlbAssetRecipe = {\n schemaVersion: RECIPE_SCHEMA_VERSION,\n kind: 'glb',\n methods: [],\n textures: [\n {\n label: 'color',\n select: { by: 'slot', slots: COLOR_TEXTURE_SLOTS },\n encode: {\n codec: 'ktx2',\n mode: 'uastc',\n colorSpace: 'srgb',\n level: 3,\n zstd: true,\n },\n },\n {\n label: 'directional',\n select: { by: 'slot', slots: DIRECTIONAL_TEXTURE_SLOTS },\n encode: {\n codec: 'ktx2',\n mode: 'uastc',\n colorSpace: 'linear',\n normalMap: true,\n level: 3,\n zstd: true,\n },\n },\n {\n label: 'data',\n select: { by: 'slot', slots: DATA_TEXTURE_SLOTS },\n encode: {\n codec: 'ktx2',\n mode: 'uastc',\n colorSpace: 'linear',\n level: 3,\n zstd: true,\n rdo: { lambda: 1 },\n },\n },\n ],\n geometry: { codec: 'draco' },\n}\n\nexport const DEFAULT_IMAGE_RECIPE: ImageAssetRecipe = {\n schemaVersion: RECIPE_SCHEMA_VERSION,\n kind: 'image',\n encode: { codec: 'webp', quality: 85, effort: 80 },\n}\n\nexport const defineRecipe = <const T extends AssetRecipe>(recipe: T): T => recipe\n\nexport function outputExtension(encoding: ImageEncoding): string {\n if (encoding.codec === 'ktx2') return '.ktx2'\n if (encoding.codec === 'jpeg') return '.jpg'\n return `.${encoding.codec}`\n}\n\nexport function outputMimeType(encoding: ImageEncoding): string {\n if (encoding.codec === 'ktx2') return 'image/ktx2'\n return `image/${encoding.codec}`\n}\n","import type { AssetRecipe } from '../core/recipes'\n\nexport { defineRecipe } from '../core/recipes'\n\nexport type ChopperOutput = { mode: 'replace' } | { mode: 'template'; path: string }\n\nexport interface ChopperRule {\n include: readonly string[]\n exclude?: readonly string[]\n recipe: AssetRecipe\n output: ChopperOutput\n}\n\nexport interface ChopperConfig {\n rules: readonly ChopperRule[]\n concurrency?: number\n}\n\nexport const defineConfig = <const T extends ChopperConfig>(config: T): T => config\n"]}
1
+ {"version":3,"sources":["../../src/core/recipes.ts","../../src/config/index.ts"],"names":[],"mappings":";AA2NO,IAAM,YAAA,GAAe,CAA8B,MAAA,KAAiB;;;AC1MpE,IAAM,YAAA,GAAe,CAAgC,MAAA,KAAiB","file":"index.js","sourcesContent":["export const RECIPE_SCHEMA_VERSION = 1 as const\n\nexport type TextureSize = readonly [width: number, height: number]\n\ninterface SizedEncoding {\n /** Maximum dimensions. Aspect ratio is preserved and images are not enlarged. */\n maxSize?: TextureSize\n}\n\nexport interface WebpEncoding extends SizedEncoding {\n codec: 'webp'\n quality?: number\n effort?: number\n lossless?: boolean\n /** WebP near-lossless preprocessing strength, from 0 (lossy) to 100. */\n nearLossless?: number\n}\n\nexport interface AvifEncoding extends SizedEncoding {\n codec: 'avif'\n quality?: number\n effort?: number\n lossless?: boolean\n chromaSubsampling?: '4:2:0' | '4:4:4'\n}\n\nexport interface JpegEncoding extends SizedEncoding {\n codec: 'jpeg'\n quality?: number\n chromaSubsampling?: '4:2:0' | '4:4:4'\n}\n\nexport interface PngEncoding extends SizedEncoding {\n codec: 'png'\n}\n\nexport interface UastcEncoding extends SizedEncoding {\n codec: 'ktx2'\n mode: 'uastc'\n colorSpace?: 'srgb' | 'linear'\n normalMap?: boolean\n level?: 0 | 1 | 2 | 3 | 4\n mipmaps?: boolean\n zstd?: boolean\n rdo?: { lambda?: number }\n}\n\nexport interface Etc1sEncoding extends SizedEncoding {\n codec: 'ktx2'\n mode: 'etc1s'\n colorSpace?: 'srgb' | 'linear'\n normalMap?: boolean\n quality?: number\n compression?: 0 | 1 | 2 | 3 | 4 | 5 | 6\n mipmaps?: boolean\n}\n\nexport type RasterEncoding = WebpEncoding | AvifEncoding | JpegEncoding | PngEncoding\n\nexport type ImageEncoding = RasterEncoding | UastcEncoding | Etc1sEncoding\n\nexport type GlbProperty =\n | 'accessor'\n | 'animation'\n | 'buffer'\n | 'camera'\n | 'material'\n | 'mesh'\n | 'node'\n | 'primitive'\n | 'primitiveTarget'\n | 'skin'\n | 'texture'\n\nexport type GlbMethodRecipe =\n | {\n method: 'dedup'\n keepUniqueNames?: boolean\n propertyTypes?: readonly Extract<GlbProperty, 'accessor' | 'material' | 'mesh' | 'skin' | 'texture'>[]\n }\n | {\n method: 'prune'\n keepAttributes?: boolean\n keepExtras?: boolean\n keepLeaves?: boolean\n keepSolidTextures?: boolean\n propertyTypes?: readonly GlbProperty[]\n }\n | {\n method: 'resample'\n tolerance?: number\n cleanup?: boolean\n }\n\nexport type TextureSelector =\n | { by: 'slot'; slots: readonly string[] }\n | { by: 'name'; names: readonly string[] }\n | { by: 'index'; indices: readonly number[] }\n\nexport interface EmbeddedTextureRecipe {\n label: string\n select: TextureSelector\n encode: ImageEncoding\n}\n\nexport type GeometryEncoding = { codec: 'draco' } | { codec: 'meshopt' }\n\nexport interface GlbAssetRecipe {\n schemaVersion: typeof RECIPE_SCHEMA_VERSION\n kind: 'glb'\n methods?: readonly GlbMethodRecipe[]\n textures?: readonly EmbeddedTextureRecipe[]\n geometry?: GeometryEncoding | false\n}\n\nexport interface ImageAssetRecipe {\n schemaVersion: typeof RECIPE_SCHEMA_VERSION\n kind: 'image'\n encode: ImageEncoding\n}\n\nexport type AssetRecipe = GlbAssetRecipe | ImageAssetRecipe\n\nexport type NormalizedImageEncoding =\n | (Required<Omit<WebpEncoding, 'maxSize'>> & Pick<WebpEncoding, 'maxSize'>)\n | (Required<Omit<AvifEncoding, 'maxSize'>> & Pick<AvifEncoding, 'maxSize'>)\n | (Required<Omit<JpegEncoding, 'maxSize'>> & Pick<JpegEncoding, 'maxSize'>)\n | PngEncoding\n | (Required<Omit<UastcEncoding, 'maxSize' | 'rdo'>> & Pick<UastcEncoding, 'maxSize' | 'rdo'>)\n | (Required<Omit<Etc1sEncoding, 'maxSize'>> & Pick<Etc1sEncoding, 'maxSize'>)\n\nexport type NormalizedAssetRecipe =\n | {\n schemaVersion: typeof RECIPE_SCHEMA_VERSION\n kind: 'image'\n encode: NormalizedImageEncoding\n }\n | {\n schemaVersion: typeof RECIPE_SCHEMA_VERSION\n kind: 'glb'\n methods: readonly GlbMethodRecipe[]\n textures: readonly (Omit<EmbeddedTextureRecipe, 'encode'> & {\n encode: NormalizedImageEncoding\n })[]\n geometry: GeometryEncoding | false\n }\n\nexport const COLOR_TEXTURE_SLOTS = [\n 'baseColorTexture',\n 'emissiveTexture',\n 'specularColorTexture',\n 'sheenColorTexture',\n] as const\n\nexport const DIRECTIONAL_TEXTURE_SLOTS = ['normalTexture', 'clearcoatNormalTexture', 'anisotropyTexture'] as const\n\nexport const DATA_TEXTURE_SLOTS = [\n 'occlusionTexture',\n 'metallicRoughnessTexture',\n 'specularTexture',\n 'clearcoatTexture',\n 'clearcoatRoughnessTexture',\n 'sheenRoughnessTexture',\n 'transmissionTexture',\n 'thicknessTexture',\n 'iridescenceTexture',\n 'iridescenceThicknessTexture',\n] as const\n\nexport const DEFAULT_GLB_RECIPE: GlbAssetRecipe = {\n schemaVersion: RECIPE_SCHEMA_VERSION,\n kind: 'glb',\n methods: [],\n textures: [\n {\n label: 'color',\n select: { by: 'slot', slots: COLOR_TEXTURE_SLOTS },\n encode: {\n codec: 'ktx2',\n mode: 'uastc',\n colorSpace: 'srgb',\n level: 3,\n zstd: true,\n },\n },\n {\n label: 'directional',\n select: { by: 'slot', slots: DIRECTIONAL_TEXTURE_SLOTS },\n encode: {\n codec: 'ktx2',\n mode: 'uastc',\n colorSpace: 'linear',\n normalMap: true,\n level: 3,\n zstd: true,\n },\n },\n {\n label: 'data',\n select: { by: 'slot', slots: DATA_TEXTURE_SLOTS },\n encode: {\n codec: 'ktx2',\n mode: 'uastc',\n colorSpace: 'linear',\n level: 3,\n zstd: true,\n rdo: { lambda: 1 },\n },\n },\n ],\n geometry: { codec: 'draco' },\n}\n\nexport const DEFAULT_IMAGE_RECIPE: ImageAssetRecipe = {\n schemaVersion: RECIPE_SCHEMA_VERSION,\n kind: 'image',\n encode: { codec: 'webp', quality: 85, effort: 80 },\n}\n\nexport const defineRecipe = <const T extends AssetRecipe>(recipe: T): T => recipe\n\nexport function outputExtension(encoding: ImageEncoding): string {\n if (encoding.codec === 'ktx2') return '.ktx2'\n if (encoding.codec === 'jpeg') return '.jpg'\n return `.${encoding.codec}`\n}\n\nexport function outputMimeType(encoding: ImageEncoding): string {\n if (encoding.codec === 'ktx2') return 'image/ktx2'\n return `image/${encoding.codec}`\n}\n","import type { AssetRecipe } from '../core/recipes'\n\nexport { defineRecipe } from '../core/recipes'\n\nexport interface ChopperRule {\n include: readonly string[]\n exclude?: readonly string[]\n recipe: AssetRecipe\n path?: string\n}\n\nexport interface ChopperConfig {\n output: string\n rules: readonly ChopperRule[]\n concurrency?: number\n}\n\nexport const defineConfig = <const T extends ChopperConfig>(config: T): T => config\n"]}
package/dist/index.js CHANGED
@@ -298,7 +298,7 @@ function normalizeEncoding(encoding) {
298
298
 
299
299
  // package.json
300
300
  var package_default = {
301
- version: "0.2.0"};
301
+ version: "0.4.0"};
302
302
 
303
303
  // src/codecs/manifest.ts
304
304
  var CODEC_MANIFEST_HASH = "2046d60deb0f9f224743f4404f3c6e8ba5399f81b2811fa50466e93fce3bd322";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/recipes.ts","../src/core/result.ts","../src/core/validation.ts","../package.json","../src/codecs/manifest.ts"],"names":["encodingIssue"],"mappings":";AAAO,IAAM,qBAAA,GAAwB;AAmJ9B,IAAM,mBAAA,GAAsB;AAAA,EACjC,kBAAA;AAAA,EACA,iBAAA;AAAA,EACA,sBAAA;AAAA,EACA;AACF;AAEO,IAAM,yBAAA,GAA4B,CAAC,eAAA,EAAiB,wBAAA,EAA0B,mBAAmB;AAEjG,IAAM,kBAAA,GAAqB;AAAA,EAChC,kBAAA;AAAA,EACA,0BAAA;AAAA,EACA,iBAAA;AAAA,EACA,kBAAA;AAAA,EACA,2BAAA;AAAA,EACA,uBAAA;AAAA,EACA,qBAAA;AAAA,EACA,kBAAA;AAAA,EACA,oBAAA;AAAA,EACA;AACF;AAEO,IAAM,kBAAA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AAAA,EACA,kBAAA,EAAoB;AAAA,IAClB,WAAA,EAAa,aAAA;AAAA,IACb,cAAA,EAAgB,OAAA;AAAA,IAChB,WAAA,EAAa,8BAAA;AAAA,IACb,UAAA,EAAY,uBAAA;AAAA,IACZ,MAAA,EAAQ;AAAA,GACV;AAAA,EACA,gBAAA,EAAkB;AAAA,IAChB,WAAA,EAAa,aAAA;AAAA,IACb,cAAA,EAAgB,OAAA;AAAA,IAChB,WAAA,EAAa,oBAAA;AAAA,IACb,UAAA,EAAY,oBAAA;AAAA,IACZ,MAAA,EAAQ;AAAA;AAEZ,CAAA;AAQO,IAAM,cAAA,GAAiB;AAAA,EAC5B,aAAA,EAAe,CAAA;AAAA,EACf,gBAAgB,eAAA,CAAgB,OAAA;AAAA,EAChC,YAAA,EAAc,mBAAA;AAAA,EACd,oBAAA,EAAsB,OAAA;AAAA,EACtB,oBAAA,EAAsB,OAAA;AAAA,EACtB,SAAA,EAAW;AACb;AAEO,IAAM,SAAA,GAAY,CAAA,QAAA,EAAW,eAAA,CAAgB,OAAO,IAAI,mBAAmB,CAAA","file":"index.js","sourcesContent":["export const RECIPE_SCHEMA_VERSION = 1 as const\n\nexport type TextureSize = readonly [width: number, height: number]\n\ninterface SizedEncoding {\n /** Maximum dimensions. Aspect ratio is preserved and images are not enlarged. */\n maxSize?: TextureSize\n}\n\nexport interface WebpEncoding extends SizedEncoding {\n codec: 'webp'\n quality?: number\n effort?: number\n lossless?: boolean\n /** WebP near-lossless preprocessing strength, from 0 (lossy) to 100. */\n nearLossless?: number\n}\n\nexport interface AvifEncoding extends SizedEncoding {\n codec: 'avif'\n quality?: number\n effort?: number\n lossless?: boolean\n chromaSubsampling?: '4:2:0' | '4:4:4'\n}\n\nexport interface JpegEncoding extends SizedEncoding {\n codec: 'jpeg'\n quality?: number\n chromaSubsampling?: '4:2:0' | '4:4:4'\n}\n\nexport interface PngEncoding extends SizedEncoding {\n codec: 'png'\n}\n\nexport interface UastcEncoding extends SizedEncoding {\n codec: 'ktx2'\n mode: 'uastc'\n colorSpace?: 'srgb' | 'linear'\n normalMap?: boolean\n level?: 0 | 1 | 2 | 3 | 4\n mipmaps?: boolean\n zstd?: boolean\n rdo?: { lambda?: number }\n}\n\nexport interface Etc1sEncoding extends SizedEncoding {\n codec: 'ktx2'\n mode: 'etc1s'\n colorSpace?: 'srgb' | 'linear'\n normalMap?: boolean\n quality?: number\n compression?: 0 | 1 | 2 | 3 | 4 | 5 | 6\n mipmaps?: boolean\n}\n\nexport type RasterEncoding = WebpEncoding | AvifEncoding | JpegEncoding | PngEncoding\n\nexport type ImageEncoding = RasterEncoding | UastcEncoding | Etc1sEncoding\n\nexport type GlbProperty =\n | 'accessor'\n | 'animation'\n | 'buffer'\n | 'camera'\n | 'material'\n | 'mesh'\n | 'node'\n | 'primitive'\n | 'primitiveTarget'\n | 'skin'\n | 'texture'\n\nexport type GlbMethodRecipe =\n | {\n method: 'dedup'\n keepUniqueNames?: boolean\n propertyTypes?: readonly Extract<GlbProperty, 'accessor' | 'material' | 'mesh' | 'skin' | 'texture'>[]\n }\n | {\n method: 'prune'\n keepAttributes?: boolean\n keepExtras?: boolean\n keepLeaves?: boolean\n keepSolidTextures?: boolean\n propertyTypes?: readonly GlbProperty[]\n }\n | {\n method: 'resample'\n tolerance?: number\n cleanup?: boolean\n }\n\nexport type TextureSelector =\n | { by: 'slot'; slots: readonly string[] }\n | { by: 'name'; names: readonly string[] }\n | { by: 'index'; indices: readonly number[] }\n\nexport interface EmbeddedTextureRecipe {\n label: string\n select: TextureSelector\n encode: ImageEncoding\n}\n\nexport type GeometryEncoding = { codec: 'draco' } | { codec: 'meshopt' }\n\nexport interface GlbAssetRecipe {\n schemaVersion: typeof RECIPE_SCHEMA_VERSION\n kind: 'glb'\n methods?: readonly GlbMethodRecipe[]\n textures?: readonly EmbeddedTextureRecipe[]\n geometry?: GeometryEncoding | false\n}\n\nexport interface ImageAssetRecipe {\n schemaVersion: typeof RECIPE_SCHEMA_VERSION\n kind: 'image'\n encode: ImageEncoding\n}\n\nexport type AssetRecipe = GlbAssetRecipe | ImageAssetRecipe\n\nexport type NormalizedImageEncoding =\n | (Required<Omit<WebpEncoding, 'maxSize'>> & Pick<WebpEncoding, 'maxSize'>)\n | (Required<Omit<AvifEncoding, 'maxSize'>> & Pick<AvifEncoding, 'maxSize'>)\n | (Required<Omit<JpegEncoding, 'maxSize'>> & Pick<JpegEncoding, 'maxSize'>)\n | PngEncoding\n | (Required<Omit<UastcEncoding, 'maxSize' | 'rdo'>> & Pick<UastcEncoding, 'maxSize' | 'rdo'>)\n | (Required<Omit<Etc1sEncoding, 'maxSize'>> & Pick<Etc1sEncoding, 'maxSize'>)\n\nexport type NormalizedAssetRecipe =\n | {\n schemaVersion: typeof RECIPE_SCHEMA_VERSION\n kind: 'image'\n encode: NormalizedImageEncoding\n }\n | {\n schemaVersion: typeof RECIPE_SCHEMA_VERSION\n kind: 'glb'\n methods: readonly GlbMethodRecipe[]\n textures: readonly (Omit<EmbeddedTextureRecipe, 'encode'> & {\n encode: NormalizedImageEncoding\n })[]\n geometry: GeometryEncoding | false\n }\n\nexport const COLOR_TEXTURE_SLOTS = [\n 'baseColorTexture',\n 'emissiveTexture',\n 'specularColorTexture',\n 'sheenColorTexture',\n] as const\n\nexport const DIRECTIONAL_TEXTURE_SLOTS = ['normalTexture', 'clearcoatNormalTexture', 'anisotropyTexture'] as const\n\nexport const DATA_TEXTURE_SLOTS = [\n 'occlusionTexture',\n 'metallicRoughnessTexture',\n 'specularTexture',\n 'clearcoatTexture',\n 'clearcoatRoughnessTexture',\n 'sheenRoughnessTexture',\n 'transmissionTexture',\n 'thicknessTexture',\n 'iridescenceTexture',\n 'iridescenceThicknessTexture',\n] as const\n\nexport const DEFAULT_GLB_RECIPE: GlbAssetRecipe = {\n schemaVersion: RECIPE_SCHEMA_VERSION,\n kind: 'glb',\n methods: [],\n textures: [\n {\n label: 'color',\n select: { by: 'slot', slots: COLOR_TEXTURE_SLOTS },\n encode: {\n codec: 'ktx2',\n mode: 'uastc',\n colorSpace: 'srgb',\n level: 3,\n zstd: true,\n },\n },\n {\n label: 'directional',\n select: { by: 'slot', slots: DIRECTIONAL_TEXTURE_SLOTS },\n encode: {\n codec: 'ktx2',\n mode: 'uastc',\n colorSpace: 'linear',\n normalMap: true,\n level: 3,\n zstd: true,\n },\n },\n {\n label: 'data',\n select: { by: 'slot', slots: DATA_TEXTURE_SLOTS },\n encode: {\n codec: 'ktx2',\n mode: 'uastc',\n colorSpace: 'linear',\n level: 3,\n zstd: true,\n rdo: { lambda: 1 },\n },\n },\n ],\n geometry: { codec: 'draco' },\n}\n\nexport const DEFAULT_IMAGE_RECIPE: ImageAssetRecipe = {\n schemaVersion: RECIPE_SCHEMA_VERSION,\n kind: 'image',\n encode: { codec: 'webp', quality: 85, effort: 80 },\n}\n\nexport const defineRecipe = <const T extends AssetRecipe>(recipe: T): T => recipe\n\nexport function outputExtension(encoding: ImageEncoding): string {\n if (encoding.codec === 'ktx2') return '.ktx2'\n if (encoding.codec === 'jpeg') return '.jpg'\n return `.${encoding.codec}`\n}\n\nexport function outputMimeType(encoding: ImageEncoding): string {\n if (encoding.codec === 'ktx2') return 'image/ktx2'\n return `image/${encoding.codec}`\n}\n","export type ChopperErrorCode =\n | 'unsupported_asset'\n | 'invalid_recipe'\n | 'codec_load_failed'\n | 'decode_failed'\n | 'encode_failed'\n | 'validation_failed'\n | 'aborted'\n | 'io_failed'\n\nexport interface ChopperFailure {\n ok: false\n error: {\n code: ChopperErrorCode\n message: string\n cause?: unknown\n }\n}\n\nexport interface ChopperSuccess<T> {\n ok: true\n data: T\n}\n\nexport type ChopperResult<T> = ChopperSuccess<T> | ChopperFailure\n\nexport const success = <T>(data: T): ChopperSuccess<T> => ({ ok: true, data })\n\nexport const failure = (code: ChopperErrorCode, message: string, cause?: unknown): ChopperFailure => ({\n ok: false,\n error: cause === undefined ? { code, message } : { code, message, cause },\n})\n","import { failure, success, type ChopperResult } from './result'\nimport {\n type AssetRecipe,\n type ImageEncoding,\n type NormalizedAssetRecipe,\n type NormalizedImageEncoding,\n RECIPE_SCHEMA_VERSION,\n type TextureSelector,\n} from './recipes'\n\nexport function validateRecipe(recipe: unknown): ChopperResult<AssetRecipe> {\n const shapeIssue = recipeShapeIssue(recipe)\n if (shapeIssue) return failure('invalid_recipe', shapeIssue)\n\n try {\n const typedRecipe = recipe as AssetRecipe\n const issue = recipeIssue(typedRecipe)\n return issue ? failure('invalid_recipe', issue) : success(typedRecipe)\n } catch {\n return failure('invalid_recipe', 'Recipe contains malformed fields')\n }\n}\n\nexport function normalizeRecipe(value: AssetRecipe): ChopperResult<NormalizedAssetRecipe> {\n const validated = validateRecipe(value)\n if (!validated.ok) return validated\n const recipe = validated.data\n\n if (recipe.kind === 'image') {\n return success({\n schemaVersion: RECIPE_SCHEMA_VERSION,\n kind: 'image',\n encode: normalizeEncoding(recipe.encode),\n })\n }\n\n return success({\n schemaVersion: RECIPE_SCHEMA_VERSION,\n kind: 'glb',\n methods: recipe.methods ?? [],\n textures: (recipe.textures ?? []).map((texture) => ({\n ...texture,\n encode: normalizeEncoding(texture.encode),\n })),\n geometry: recipe.geometry ?? false,\n })\n}\n\nfunction recipeShapeIssue(recipe: unknown): string | undefined {\n if (!recipe || typeof recipe !== 'object') return 'Recipe must be an object'\n const candidate = recipe as Record<string, unknown>\n if (candidate.kind !== 'image' && candidate.kind !== 'glb') {\n return `Unsupported recipe kind: ${String(candidate.kind)}`\n }\n\n if (candidate.kind === 'image') {\n return encodingShapeIssue(candidate.encode)\n }\n\n if (candidate.methods !== undefined && !Array.isArray(candidate.methods)) {\n return 'GLB methods must be an array'\n }\n for (const method of (candidate.methods ?? []) as unknown[]) {\n if (\n !method ||\n typeof method !== 'object' ||\n !['dedup', 'prune', 'resample'].includes(String((method as Record<string, unknown>).method))\n ) {\n return 'GLB methods contain an unsupported transform'\n }\n }\n if (candidate.textures !== undefined && !Array.isArray(candidate.textures)) {\n return 'GLB textures must be an array'\n }\n for (const texture of (candidate.textures ?? []) as unknown[]) {\n if (!texture || typeof texture !== 'object') return 'Texture recipes must be objects'\n const entry = texture as Record<string, unknown>\n if (typeof entry.label !== 'string') return 'Texture recipe labels must be strings'\n if (!entry.select || typeof entry.select !== 'object') return 'Texture recipes require a selector'\n const selector = entry.select as Record<string, unknown>\n const values = selector[selector.by === 'slot' ? 'slots' : selector.by === 'name' ? 'names' : 'indices']\n if (!['slot', 'name', 'index'].includes(String(selector.by)) || !Array.isArray(values)) {\n return 'Texture recipe selectors are malformed'\n }\n const encodingIssue = encodingShapeIssue(entry.encode)\n if (encodingIssue) return encodingIssue\n }\n if (\n candidate.geometry !== undefined &&\n candidate.geometry !== false &&\n (!candidate.geometry ||\n typeof candidate.geometry !== 'object' ||\n !['draco', 'meshopt'].includes(String((candidate.geometry as Record<string, unknown>).codec)))\n ) {\n return 'GLB geometry must be false, Draco, or Meshopt'\n }\n return undefined\n}\n\nfunction encodingShapeIssue(encoding: unknown): string | undefined {\n if (!encoding || typeof encoding !== 'object') return 'Image encoding must be an object'\n const candidate = encoding as Record<string, unknown>\n if (!['webp', 'avif', 'jpeg', 'png', 'ktx2'].includes(String(candidate.codec))) {\n return `Unsupported image codec: ${String(candidate.codec)}`\n }\n if (candidate.codec === 'ktx2' && candidate.mode !== 'uastc' && candidate.mode !== 'etc1s') {\n return `Unsupported KTX2 mode: ${String(candidate.mode)}`\n }\n return undefined\n}\n\nfunction recipeIssue(recipe: AssetRecipe): string | undefined {\n if (recipe.schemaVersion !== RECIPE_SCHEMA_VERSION) {\n return `Unsupported recipe schema version: ${String(recipe.schemaVersion)}`\n }\n\n if (recipe.kind === 'image') return encodingIssue(recipe.encode)\n\n const labels = new Set<string>()\n const selectors = new Set<string>()\n for (const texture of recipe.textures ?? []) {\n if (!texture.label) return 'Texture recipe labels cannot be empty'\n if (labels.has(texture.label)) {\n return `Duplicate texture recipe label: ${texture.label}`\n }\n labels.add(texture.label)\n\n const values = selectorValues(texture.select)\n if (!values.ok) return values.error.message\n if (!values.data.length) {\n return `Texture recipe \"${texture.label}\" has an empty selector`\n }\n for (const value of values.data) {\n const key = `${texture.select.by}:${value}`\n if (selectors.has(key)) {\n return `Texture selector appears in more than one recipe: ${key}`\n }\n selectors.add(key)\n }\n\n const issue = encodingIssue(texture.encode)\n if (issue) return issue\n }\n\n for (const method of recipe.methods ?? []) {\n if (method.method === 'resample' && (method.tolerance ?? 1e-4) <= 0) {\n return 'Resample tolerance must be greater than zero'\n }\n }\n\n return undefined\n}\n\nfunction selectorValues(selector: TextureSelector): ChopperResult<readonly (string | number)[]> {\n if (selector.by === 'slot') return success(selector.slots)\n if (selector.by === 'name') return success(selector.names)\n for (const index of selector.indices) {\n if (!Number.isInteger(index) || index < 0) {\n return failure('invalid_recipe', 'Texture indices must be non-negative integers')\n }\n }\n return success(selector.indices)\n}\n\nfunction encodingIssue(encoding: ImageEncoding): string | undefined {\n if (encoding.maxSize) {\n const [width, height] = encoding.maxSize\n if (!Number.isInteger(width) || width < 1 || !Number.isInteger(height) || height < 1) {\n return 'Texture maxSize must contain positive integers'\n }\n }\n\n if ('quality' in encoding && encoding.quality !== undefined) {\n const max = encoding.codec === 'ktx2' ? 255 : 100\n if (encoding.quality < 1 || encoding.quality > max) {\n return `${encoding.codec} quality must be between 1 and ${max}`\n }\n }\n\n if ('effort' in encoding && encoding.effort !== undefined) {\n if (encoding.effort < 0 || encoding.effort > 100) {\n return `${encoding.codec} effort must be between 0 and 100`\n }\n }\n\n if (\n encoding.codec === 'webp' &&\n encoding.nearLossless !== undefined &&\n (encoding.nearLossless < 0 || encoding.nearLossless > 100)\n ) {\n return 'WebP nearLossless must be between 0 and 100'\n }\n\n if (encoding.codec === 'ktx2' && encoding.mode === 'uastc') {\n if (\n encoding.level !== undefined &&\n (!Number.isInteger(encoding.level) || encoding.level < 0 || encoding.level > 4)\n ) {\n return 'UASTC level must be an integer between 0 and 4'\n }\n const lambda = encoding.rdo?.lambda\n if (lambda !== undefined && (lambda < 0.001 || lambda > 10)) {\n return 'UASTC RDO lambda must be between 0.001 and 10'\n }\n }\n\n if (\n encoding.codec === 'ktx2' &&\n encoding.mode === 'etc1s' &&\n encoding.compression !== undefined &&\n (!Number.isInteger(encoding.compression) || encoding.compression < 0 || encoding.compression > 6)\n ) {\n return 'ETC1S compression must be an integer between 0 and 6'\n }\n\n return undefined\n}\n\nfunction normalizeEncoding(encoding: ImageEncoding): NormalizedImageEncoding {\n switch (encoding.codec) {\n case 'webp':\n return {\n ...encoding,\n quality: encoding.quality ?? 75,\n effort: encoding.effort ?? 50,\n lossless: encoding.lossless ?? false,\n nearLossless: encoding.nearLossless ?? 100,\n }\n case 'avif':\n return {\n ...encoding,\n quality: encoding.quality ?? 50,\n effort: encoding.effort ?? 40,\n lossless: encoding.lossless ?? false,\n chromaSubsampling: encoding.chromaSubsampling ?? '4:2:0',\n }\n case 'jpeg':\n return {\n ...encoding,\n quality: encoding.quality ?? 75,\n chromaSubsampling: encoding.chromaSubsampling ?? '4:2:0',\n }\n case 'png':\n return { ...encoding }\n case 'ktx2':\n if (encoding.mode === 'uastc') {\n return {\n ...encoding,\n colorSpace: encoding.colorSpace ?? 'srgb',\n normalMap: encoding.normalMap ?? false,\n level: encoding.level ?? 2,\n mipmaps: encoding.mipmaps ?? true,\n zstd: encoding.zstd ?? true,\n }\n }\n return {\n ...encoding,\n colorSpace: encoding.colorSpace ?? 'srgb',\n normalMap: encoding.normalMap ?? false,\n quality: encoding.quality ?? 128,\n compression: encoding.compression ?? 1,\n mipmaps: encoding.mipmaps ?? true,\n }\n }\n}\n","{\n \"name\": \"@joycostudio/chopper\",\n \"version\": \"0.2.0\",\n \"description\": \"Isomorphic asset optimization pipeline\",\n \"type\": \"module\",\n \"license\": \"ISC\",\n \"author\": \"joyco.studio\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/joyco-studio/chopper.git\",\n \"directory\": \"packages/chopper\"\n },\n \"homepage\": \"https://github.com/joyco-studio/chopper#readme\",\n \"bugs\": \"https://github.com/joyco-studio/chopper/issues\",\n \"publishConfig\": {\n \"registry\": \"https://registry.npmjs.org\",\n \"access\": \"public\"\n },\n \"files\": [\n \"dist\",\n \"codecs\",\n \"README.md\",\n \"THIRD_PARTY_NOTICES.md\"\n ],\n \"bin\": {\n \"chopper\": \"dist/cli/index.js\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\"\n },\n \"./browser\": {\n \"types\": \"./dist/browser/index.d.ts\",\n \"import\": \"./dist/browser/index.js\"\n },\n \"./node\": {\n \"types\": \"./dist/node/index.d.ts\",\n \"import\": \"./dist/node/index.js\"\n },\n \"./config\": {\n \"types\": \"./dist/config/index.d.ts\",\n \"import\": \"./dist/config/index.js\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"scripts\": {\n \"build\": \"pnpm codecs:sync && tsup\",\n \"codecs:sync\": \"tsx ../../scripts/sync-codecs.ts\",\n \"dev\": \"tsup --watch\",\n \"typecheck\": \"tsc --noEmit\"\n },\n \"dependencies\": {\n \"@gltf-transform/core\": \"4.4.2\",\n \"@gltf-transform/extensions\": \"4.4.2\",\n \"@gltf-transform/functions\": \"4.4.2\",\n \"@jsquash/avif\": \"2.1.1\",\n \"@jsquash/jpeg\": \"1.6.0\",\n \"@jsquash/png\": \"3.1.1\",\n \"@jsquash/resize\": \"2.1.1\",\n \"@jsquash/webp\": \"1.5.0\",\n \"draco3dgltf\": \"1.5.7\",\n \"jiti\": \"2.7.0\",\n \"ktx2-encoder\": \"0.6.0\",\n \"meshoptimizer\": \"1.0.1\",\n \"tinyglobby\": \"0.2.17\"\n },\n \"devDependencies\": {\n \"@types/draco3dgltf\": \"1.4.3\"\n }\n}\n","import packageMetadata from '../../package.json'\n\nexport const CODEC_MANIFEST_HASH = '2046d60deb0f9f224743f4404f3c6e8ba5399f81b2811fa50466e93fce3bd322'\n\nexport const CODEC_ARTIFACTS = {\n avifEncoder: {\n packageName: '@jsquash/avif',\n packageVersion: '2.1.1',\n packagePath: 'codec/enc/avif_enc.wasm',\n publicFile: 'avif_enc.wasm',\n sha256: 'd9f2a95164362af48558d176e619becfd49dd97b50b86c679b47100860522b3d',\n },\n jpegDecoder: {\n packageName: '@jsquash/jpeg',\n packageVersion: '1.6.0',\n packagePath: 'codec/dec/mozjpeg_dec.wasm',\n publicFile: 'mozjpeg_dec.wasm',\n sha256: 'a7c4b12169817e779ff4af137981393ae924944e167ad1bd95747c9199162d3e',\n },\n jpegEncoder: {\n packageName: '@jsquash/jpeg',\n packageVersion: '1.6.0',\n packagePath: 'codec/enc/mozjpeg_enc.wasm',\n publicFile: 'mozjpeg_enc.wasm',\n sha256: '24d4177f1c4963e2058b107189249651c61fdef125570e79b1dfb63c8bb49326',\n },\n ktx2Encoder: {\n packageName: 'ktx2-encoder',\n packageVersion: '0.6.0',\n packagePath: 'dist/basis/basis_encoder.wasm',\n publicFile: 'basis_encoder.wasm',\n sha256: '9807719e87cf3d979b0d69ae7112eb88aec6a0e0206c0b2d00dc0bed0d581b80',\n },\n png: {\n packageName: '@jsquash/png',\n packageVersion: '3.1.1',\n packagePath: 'codec/pkg/squoosh_png_bg.wasm',\n publicFile: 'squoosh_png_bg.wasm',\n sha256: '263d6e658808a74b72a1a99c5cc1d619237e70c150db6e41d5d84d3d117ab9be',\n },\n resize: {\n packageName: '@jsquash/resize',\n packageVersion: '2.1.1',\n packagePath: 'lib/resize/pkg/squoosh_resize_bg.wasm',\n publicFile: 'squoosh_resize_bg.wasm',\n sha256: '5b1f702d502c4d0a70b99f78691bd554d566ba95859e4c57af5435955a1d74a5',\n },\n webpEncoder: {\n packageName: '@jsquash/webp',\n packageVersion: '1.5.0',\n packagePath: 'codec/enc/webp_enc.wasm',\n publicFile: 'webp_enc.wasm',\n sha256: 'b6085bb6702f144e9dc6016d58d230b34a84976bf0d080b7390b4b4b137d6ab7',\n },\n dracoDecoderScript: {\n packageName: 'draco3dgltf',\n packageVersion: '1.5.7',\n packagePath: 'draco_decoder_gltf_nodejs.js',\n publicFile: 'draco_decoder_gltf.js',\n sha256: '8bb2952d2ba7d67e1414f8df819410cb0434a666be53f671fff75f68843d76f6',\n },\n dracoDecoderWasm: {\n packageName: 'draco3dgltf',\n packageVersion: '1.5.7',\n packagePath: 'draco_decoder_gltf.wasm',\n publicFile: 'draco_decoder_gltf.wasm',\n sha256: '712db3449ae2041d6e8a224c395bda6cedb49e51322fae38b7db9beb8b381889',\n },\n dracoEncoderScript: {\n packageName: 'draco3dgltf',\n packageVersion: '1.5.7',\n packagePath: 'draco_encoder_gltf_nodejs.js',\n publicFile: 'draco_encoder_gltf.js',\n sha256: '8434adecd1446459601763e499be3697546056bca90b286a538ae0483a00845a',\n },\n dracoEncoderWasm: {\n packageName: 'draco3dgltf',\n packageVersion: '1.5.7',\n packagePath: 'draco_encoder.wasm',\n publicFile: 'draco_encoder.wasm',\n sha256: 'd2a3ac80c91980d5d321c116454834ff36264825c6d1794cc84e42288f158958',\n },\n} as const\n\nexport type CodecArtifactName = keyof typeof CODEC_ARTIFACTS\nexport type ImageWasmModuleName = Extract<\n CodecArtifactName,\n 'avifEncoder' | 'jpegDecoder' | 'jpegEncoder' | 'png' | 'resize' | 'webpEncoder'\n>\n\nexport const CODEC_MANIFEST = {\n schemaVersion: 1,\n chopperVersion: packageMetadata.version,\n manifestHash: CODEC_MANIFEST_HASH,\n gltfTransformVersion: '4.4.2',\n meshoptimizerVersion: '1.0.1',\n artifacts: CODEC_ARTIFACTS,\n} as const\n\nexport const ENGINE_ID = `chopper@${packageMetadata.version}:${CODEC_MANIFEST_HASH}` as const\n"]}
1
+ {"version":3,"sources":["../src/core/recipes.ts","../src/core/result.ts","../src/core/validation.ts","../package.json","../src/codecs/manifest.ts"],"names":["encodingIssue"],"mappings":";AAAO,IAAM,qBAAA,GAAwB;AAmJ9B,IAAM,mBAAA,GAAsB;AAAA,EACjC,kBAAA;AAAA,EACA,iBAAA;AAAA,EACA,sBAAA;AAAA,EACA;AACF;AAEO,IAAM,y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AAAA,IAChB,WAAA,EAAa,8BAAA;AAAA,IACb,UAAA,EAAY,uBAAA;AAAA,IACZ,MAAA,EAAQ;AAAA,GACV;AAAA,EACA,gBAAA,EAAkB;AAAA,IAChB,WAAA,EAAa,aAAA;AAAA,IACb,cAAA,EAAgB,OAAA;AAAA,IAChB,WAAA,EAAa,yBAAA;AAAA,IACb,UAAA,EAAY,yBAAA;AAAA,IACZ,MAAA,EAAQ;AAAA,GACV;AAAA,EACA,kBAAA,EAAoB;AAAA,IAClB,WAAA,EAAa,aAAA;AAAA,IACb,cAAA,EAAgB,OAAA;AAAA,IAChB,WAAA,EAAa,8BAAA;AAAA,IACb,UAAA,EAAY,uBAAA;AAAA,IACZ,MAAA,EAAQ;AAAA,GACV;AAAA,EACA,gBAAA,EAAkB;AAAA,IAChB,WAAA,EAAa,aAAA;AAAA,IACb,cAAA,EAAgB,OAAA;AAAA,IAChB,WAAA,EAAa,oBAAA;AAAA,IACb,UAAA,EAAY,oBAAA;AAAA,IACZ,MAAA,EAAQ;AAAA;AAEZ,CAAA;AAQO,IAAM,cAAA,GAAiB;AAAA,EAC5B,aAAA,EAAe,CAAA;AAAA,EACf,gBAAgB,eAAA,CAAgB,OAAA;AAAA,EAChC,YAAA,EAAc,mBAAA;AAAA,EACd,oBAAA,EAAsB,OAAA;AAAA,EACtB,oBAAA,EAAsB,OAAA;AAAA,EACtB,SAAA,EAAW;AACb;AAEO,IAAM,SAAA,GAAY,CAAA,QAAA,EAAW,eAAA,CAAgB,OAAO,IAAI,mBAAmB,CAAA","file":"index.js","sourcesContent":["export const RECIPE_SCHEMA_VERSION = 1 as const\n\nexport type TextureSize = readonly [width: number, height: number]\n\ninterface SizedEncoding {\n /** Maximum dimensions. Aspect ratio is preserved and images are not enlarged. */\n maxSize?: TextureSize\n}\n\nexport interface WebpEncoding extends SizedEncoding {\n codec: 'webp'\n quality?: number\n effort?: number\n lossless?: boolean\n /** WebP near-lossless preprocessing strength, from 0 (lossy) to 100. */\n nearLossless?: number\n}\n\nexport interface AvifEncoding extends SizedEncoding {\n codec: 'avif'\n quality?: number\n effort?: number\n lossless?: boolean\n chromaSubsampling?: '4:2:0' | '4:4:4'\n}\n\nexport interface JpegEncoding extends SizedEncoding {\n codec: 'jpeg'\n quality?: number\n chromaSubsampling?: '4:2:0' | '4:4:4'\n}\n\nexport interface PngEncoding extends SizedEncoding {\n codec: 'png'\n}\n\nexport interface UastcEncoding extends SizedEncoding {\n codec: 'ktx2'\n mode: 'uastc'\n colorSpace?: 'srgb' | 'linear'\n normalMap?: boolean\n level?: 0 | 1 | 2 | 3 | 4\n mipmaps?: boolean\n zstd?: boolean\n rdo?: { lambda?: number }\n}\n\nexport interface Etc1sEncoding extends SizedEncoding {\n codec: 'ktx2'\n mode: 'etc1s'\n colorSpace?: 'srgb' | 'linear'\n normalMap?: boolean\n quality?: number\n compression?: 0 | 1 | 2 | 3 | 4 | 5 | 6\n mipmaps?: boolean\n}\n\nexport type RasterEncoding = WebpEncoding | AvifEncoding | JpegEncoding | PngEncoding\n\nexport type ImageEncoding = RasterEncoding | UastcEncoding | Etc1sEncoding\n\nexport type GlbProperty =\n | 'accessor'\n | 'animation'\n | 'buffer'\n | 'camera'\n | 'material'\n | 'mesh'\n | 'node'\n | 'primitive'\n | 'primitiveTarget'\n | 'skin'\n | 'texture'\n\nexport type GlbMethodRecipe =\n | {\n method: 'dedup'\n keepUniqueNames?: boolean\n propertyTypes?: readonly Extract<GlbProperty, 'accessor' | 'material' | 'mesh' | 'skin' | 'texture'>[]\n }\n | {\n method: 'prune'\n keepAttributes?: boolean\n keepExtras?: boolean\n keepLeaves?: boolean\n keepSolidTextures?: boolean\n propertyTypes?: readonly GlbProperty[]\n }\n | {\n method: 'resample'\n tolerance?: number\n cleanup?: boolean\n }\n\nexport type TextureSelector =\n | { by: 'slot'; slots: readonly string[] }\n | { by: 'name'; names: readonly string[] }\n | { by: 'index'; indices: readonly number[] }\n\nexport interface EmbeddedTextureRecipe {\n label: string\n select: TextureSelector\n encode: ImageEncoding\n}\n\nexport type GeometryEncoding = { codec: 'draco' } | { codec: 'meshopt' }\n\nexport interface GlbAssetRecipe {\n schemaVersion: typeof RECIPE_SCHEMA_VERSION\n kind: 'glb'\n methods?: readonly GlbMethodRecipe[]\n textures?: readonly EmbeddedTextureRecipe[]\n geometry?: GeometryEncoding | false\n}\n\nexport interface ImageAssetRecipe {\n schemaVersion: typeof RECIPE_SCHEMA_VERSION\n kind: 'image'\n encode: ImageEncoding\n}\n\nexport type AssetRecipe = GlbAssetRecipe | ImageAssetRecipe\n\nexport type NormalizedImageEncoding =\n | (Required<Omit<WebpEncoding, 'maxSize'>> & Pick<WebpEncoding, 'maxSize'>)\n | (Required<Omit<AvifEncoding, 'maxSize'>> & Pick<AvifEncoding, 'maxSize'>)\n | (Required<Omit<JpegEncoding, 'maxSize'>> & Pick<JpegEncoding, 'maxSize'>)\n | PngEncoding\n | (Required<Omit<UastcEncoding, 'maxSize' | 'rdo'>> & Pick<UastcEncoding, 'maxSize' | 'rdo'>)\n | (Required<Omit<Etc1sEncoding, 'maxSize'>> & Pick<Etc1sEncoding, 'maxSize'>)\n\nexport type NormalizedAssetRecipe =\n | {\n schemaVersion: typeof RECIPE_SCHEMA_VERSION\n kind: 'image'\n encode: NormalizedImageEncoding\n }\n | {\n schemaVersion: typeof RECIPE_SCHEMA_VERSION\n kind: 'glb'\n methods: readonly GlbMethodRecipe[]\n textures: readonly (Omit<EmbeddedTextureRecipe, 'encode'> & {\n encode: NormalizedImageEncoding\n })[]\n geometry: GeometryEncoding | false\n }\n\nexport const COLOR_TEXTURE_SLOTS = [\n 'baseColorTexture',\n 'emissiveTexture',\n 'specularColorTexture',\n 'sheenColorTexture',\n] as const\n\nexport const DIRECTIONAL_TEXTURE_SLOTS = ['normalTexture', 'clearcoatNormalTexture', 'anisotropyTexture'] as const\n\nexport const DATA_TEXTURE_SLOTS = [\n 'occlusionTexture',\n 'metallicRoughnessTexture',\n 'specularTexture',\n 'clearcoatTexture',\n 'clearcoatRoughnessTexture',\n 'sheenRoughnessTexture',\n 'transmissionTexture',\n 'thicknessTexture',\n 'iridescenceTexture',\n 'iridescenceThicknessTexture',\n] as const\n\nexport const DEFAULT_GLB_RECIPE: GlbAssetRecipe = {\n schemaVersion: RECIPE_SCHEMA_VERSION,\n kind: 'glb',\n methods: [],\n textures: [\n {\n label: 'color',\n select: { by: 'slot', slots: COLOR_TEXTURE_SLOTS },\n encode: {\n codec: 'ktx2',\n mode: 'uastc',\n colorSpace: 'srgb',\n level: 3,\n zstd: true,\n },\n },\n {\n label: 'directional',\n select: { by: 'slot', slots: DIRECTIONAL_TEXTURE_SLOTS },\n encode: {\n codec: 'ktx2',\n mode: 'uastc',\n colorSpace: 'linear',\n normalMap: true,\n level: 3,\n zstd: true,\n },\n },\n {\n label: 'data',\n select: { by: 'slot', slots: DATA_TEXTURE_SLOTS },\n encode: {\n codec: 'ktx2',\n mode: 'uastc',\n colorSpace: 'linear',\n level: 3,\n zstd: true,\n rdo: { lambda: 1 },\n },\n },\n ],\n geometry: { codec: 'draco' },\n}\n\nexport const DEFAULT_IMAGE_RECIPE: ImageAssetRecipe = {\n schemaVersion: RECIPE_SCHEMA_VERSION,\n kind: 'image',\n encode: { codec: 'webp', quality: 85, effort: 80 },\n}\n\nexport const defineRecipe = <const T extends AssetRecipe>(recipe: T): T => recipe\n\nexport function outputExtension(encoding: ImageEncoding): string {\n if (encoding.codec === 'ktx2') return '.ktx2'\n if (encoding.codec === 'jpeg') return '.jpg'\n return `.${encoding.codec}`\n}\n\nexport function outputMimeType(encoding: ImageEncoding): string {\n if (encoding.codec === 'ktx2') return 'image/ktx2'\n return `image/${encoding.codec}`\n}\n","export type ChopperErrorCode =\n | 'unsupported_asset'\n | 'invalid_recipe'\n | 'codec_load_failed'\n | 'decode_failed'\n | 'encode_failed'\n | 'validation_failed'\n | 'aborted'\n | 'io_failed'\n\nexport interface ChopperFailure {\n ok: false\n error: {\n code: ChopperErrorCode\n message: string\n cause?: unknown\n }\n}\n\nexport interface ChopperSuccess<T> {\n ok: true\n data: T\n}\n\nexport type ChopperResult<T> = ChopperSuccess<T> | ChopperFailure\n\nexport const success = <T>(data: T): ChopperSuccess<T> => ({ ok: true, data })\n\nexport const failure = (code: ChopperErrorCode, message: string, cause?: unknown): ChopperFailure => ({\n ok: false,\n error: cause === undefined ? { code, message } : { code, message, cause },\n})\n","import { failure, success, type ChopperResult } from './result'\nimport {\n type AssetRecipe,\n type ImageEncoding,\n type NormalizedAssetRecipe,\n type NormalizedImageEncoding,\n RECIPE_SCHEMA_VERSION,\n type TextureSelector,\n} from './recipes'\n\nexport function validateRecipe(recipe: unknown): ChopperResult<AssetRecipe> {\n const shapeIssue = recipeShapeIssue(recipe)\n if (shapeIssue) return failure('invalid_recipe', shapeIssue)\n\n try {\n const typedRecipe = recipe as AssetRecipe\n const issue = recipeIssue(typedRecipe)\n return issue ? failure('invalid_recipe', issue) : success(typedRecipe)\n } catch {\n return failure('invalid_recipe', 'Recipe contains malformed fields')\n }\n}\n\nexport function normalizeRecipe(value: AssetRecipe): ChopperResult<NormalizedAssetRecipe> {\n const validated = validateRecipe(value)\n if (!validated.ok) return validated\n const recipe = validated.data\n\n if (recipe.kind === 'image') {\n return success({\n schemaVersion: RECIPE_SCHEMA_VERSION,\n kind: 'image',\n encode: normalizeEncoding(recipe.encode),\n })\n }\n\n return success({\n schemaVersion: RECIPE_SCHEMA_VERSION,\n kind: 'glb',\n methods: recipe.methods ?? [],\n textures: (recipe.textures ?? []).map((texture) => ({\n ...texture,\n encode: normalizeEncoding(texture.encode),\n })),\n geometry: recipe.geometry ?? false,\n })\n}\n\nfunction recipeShapeIssue(recipe: unknown): string | undefined {\n if (!recipe || typeof recipe !== 'object') return 'Recipe must be an object'\n const candidate = recipe as Record<string, unknown>\n if (candidate.kind !== 'image' && candidate.kind !== 'glb') {\n return `Unsupported recipe kind: ${String(candidate.kind)}`\n }\n\n if (candidate.kind === 'image') {\n return encodingShapeIssue(candidate.encode)\n }\n\n if (candidate.methods !== undefined && !Array.isArray(candidate.methods)) {\n return 'GLB methods must be an array'\n }\n for (const method of (candidate.methods ?? []) as unknown[]) {\n if (\n !method ||\n typeof method !== 'object' ||\n !['dedup', 'prune', 'resample'].includes(String((method as Record<string, unknown>).method))\n ) {\n return 'GLB methods contain an unsupported transform'\n }\n }\n if (candidate.textures !== undefined && !Array.isArray(candidate.textures)) {\n return 'GLB textures must be an array'\n }\n for (const texture of (candidate.textures ?? []) as unknown[]) {\n if (!texture || typeof texture !== 'object') return 'Texture recipes must be objects'\n const entry = texture as Record<string, unknown>\n if (typeof entry.label !== 'string') return 'Texture recipe labels must be strings'\n if (!entry.select || typeof entry.select !== 'object') return 'Texture recipes require a selector'\n const selector = entry.select as Record<string, unknown>\n const values = selector[selector.by === 'slot' ? 'slots' : selector.by === 'name' ? 'names' : 'indices']\n if (!['slot', 'name', 'index'].includes(String(selector.by)) || !Array.isArray(values)) {\n return 'Texture recipe selectors are malformed'\n }\n const encodingIssue = encodingShapeIssue(entry.encode)\n if (encodingIssue) return encodingIssue\n }\n if (\n candidate.geometry !== undefined &&\n candidate.geometry !== false &&\n (!candidate.geometry ||\n typeof candidate.geometry !== 'object' ||\n !['draco', 'meshopt'].includes(String((candidate.geometry as Record<string, unknown>).codec)))\n ) {\n return 'GLB geometry must be false, Draco, or Meshopt'\n }\n return undefined\n}\n\nfunction encodingShapeIssue(encoding: unknown): string | undefined {\n if (!encoding || typeof encoding !== 'object') return 'Image encoding must be an object'\n const candidate = encoding as Record<string, unknown>\n if (!['webp', 'avif', 'jpeg', 'png', 'ktx2'].includes(String(candidate.codec))) {\n return `Unsupported image codec: ${String(candidate.codec)}`\n }\n if (candidate.codec === 'ktx2' && candidate.mode !== 'uastc' && candidate.mode !== 'etc1s') {\n return `Unsupported KTX2 mode: ${String(candidate.mode)}`\n }\n return undefined\n}\n\nfunction recipeIssue(recipe: AssetRecipe): string | undefined {\n if (recipe.schemaVersion !== RECIPE_SCHEMA_VERSION) {\n return `Unsupported recipe schema version: ${String(recipe.schemaVersion)}`\n }\n\n if (recipe.kind === 'image') return encodingIssue(recipe.encode)\n\n const labels = new Set<string>()\n const selectors = new Set<string>()\n for (const texture of recipe.textures ?? []) {\n if (!texture.label) return 'Texture recipe labels cannot be empty'\n if (labels.has(texture.label)) {\n return `Duplicate texture recipe label: ${texture.label}`\n }\n labels.add(texture.label)\n\n const values = selectorValues(texture.select)\n if (!values.ok) return values.error.message\n if (!values.data.length) {\n return `Texture recipe \"${texture.label}\" has an empty selector`\n }\n for (const value of values.data) {\n const key = `${texture.select.by}:${value}`\n if (selectors.has(key)) {\n return `Texture selector appears in more than one recipe: ${key}`\n }\n selectors.add(key)\n }\n\n const issue = encodingIssue(texture.encode)\n if (issue) return issue\n }\n\n for (const method of recipe.methods ?? []) {\n if (method.method === 'resample' && (method.tolerance ?? 1e-4) <= 0) {\n return 'Resample tolerance must be greater than zero'\n }\n }\n\n return undefined\n}\n\nfunction selectorValues(selector: TextureSelector): ChopperResult<readonly (string | number)[]> {\n if (selector.by === 'slot') return success(selector.slots)\n if (selector.by === 'name') return success(selector.names)\n for (const index of selector.indices) {\n if (!Number.isInteger(index) || index < 0) {\n return failure('invalid_recipe', 'Texture indices must be non-negative integers')\n }\n }\n return success(selector.indices)\n}\n\nfunction encodingIssue(encoding: ImageEncoding): string | undefined {\n if (encoding.maxSize) {\n const [width, height] = encoding.maxSize\n if (!Number.isInteger(width) || width < 1 || !Number.isInteger(height) || height < 1) {\n return 'Texture maxSize must contain positive integers'\n }\n }\n\n if ('quality' in encoding && encoding.quality !== undefined) {\n const max = encoding.codec === 'ktx2' ? 255 : 100\n if (encoding.quality < 1 || encoding.quality > max) {\n return `${encoding.codec} quality must be between 1 and ${max}`\n }\n }\n\n if ('effort' in encoding && encoding.effort !== undefined) {\n if (encoding.effort < 0 || encoding.effort > 100) {\n return `${encoding.codec} effort must be between 0 and 100`\n }\n }\n\n if (\n encoding.codec === 'webp' &&\n encoding.nearLossless !== undefined &&\n (encoding.nearLossless < 0 || encoding.nearLossless > 100)\n ) {\n return 'WebP nearLossless must be between 0 and 100'\n }\n\n if (encoding.codec === 'ktx2' && encoding.mode === 'uastc') {\n if (\n encoding.level !== undefined &&\n (!Number.isInteger(encoding.level) || encoding.level < 0 || encoding.level > 4)\n ) {\n return 'UASTC level must be an integer between 0 and 4'\n }\n const lambda = encoding.rdo?.lambda\n if (lambda !== undefined && (lambda < 0.001 || lambda > 10)) {\n return 'UASTC RDO lambda must be between 0.001 and 10'\n }\n }\n\n if (\n encoding.codec === 'ktx2' &&\n encoding.mode === 'etc1s' &&\n encoding.compression !== undefined &&\n (!Number.isInteger(encoding.compression) || encoding.compression < 0 || encoding.compression > 6)\n ) {\n return 'ETC1S compression must be an integer between 0 and 6'\n }\n\n return undefined\n}\n\nfunction normalizeEncoding(encoding: ImageEncoding): NormalizedImageEncoding {\n switch (encoding.codec) {\n case 'webp':\n return {\n ...encoding,\n quality: encoding.quality ?? 75,\n effort: encoding.effort ?? 50,\n lossless: encoding.lossless ?? false,\n nearLossless: encoding.nearLossless ?? 100,\n }\n case 'avif':\n return {\n ...encoding,\n quality: encoding.quality ?? 50,\n effort: encoding.effort ?? 40,\n lossless: encoding.lossless ?? false,\n chromaSubsampling: encoding.chromaSubsampling ?? '4:2:0',\n }\n case 'jpeg':\n return {\n ...encoding,\n quality: encoding.quality ?? 75,\n chromaSubsampling: encoding.chromaSubsampling ?? '4:2:0',\n }\n case 'png':\n return { ...encoding }\n case 'ktx2':\n if (encoding.mode === 'uastc') {\n return {\n ...encoding,\n colorSpace: encoding.colorSpace ?? 'srgb',\n normalMap: encoding.normalMap ?? false,\n level: encoding.level ?? 2,\n mipmaps: encoding.mipmaps ?? true,\n zstd: encoding.zstd ?? true,\n }\n }\n return {\n ...encoding,\n colorSpace: encoding.colorSpace ?? 'srgb',\n normalMap: encoding.normalMap ?? false,\n quality: encoding.quality ?? 128,\n compression: encoding.compression ?? 1,\n mipmaps: encoding.mipmaps ?? true,\n }\n }\n}\n","{\n \"name\": \"@joycostudio/chopper\",\n \"version\": \"0.4.0\",\n \"description\": \"Isomorphic asset optimization pipeline\",\n \"type\": \"module\",\n \"license\": \"ISC\",\n \"author\": \"joyco.studio\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/joyco-studio/chopper.git\",\n \"directory\": \"packages/chopper\"\n },\n \"homepage\": \"https://github.com/joyco-studio/chopper#readme\",\n \"bugs\": \"https://github.com/joyco-studio/chopper/issues\",\n \"publishConfig\": {\n \"registry\": \"https://registry.npmjs.org\",\n \"access\": \"public\"\n },\n \"files\": [\n \"dist\",\n \"codecs\",\n \"README.md\",\n \"THIRD_PARTY_NOTICES.md\"\n ],\n \"bin\": {\n \"chopper\": \"dist/cli/index.js\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\"\n },\n \"./browser\": {\n \"types\": \"./dist/browser/index.d.ts\",\n \"import\": \"./dist/browser/index.js\"\n },\n \"./node\": {\n \"types\": \"./dist/node/index.d.ts\",\n \"import\": \"./dist/node/index.js\"\n },\n \"./config\": {\n \"types\": \"./dist/config/index.d.ts\",\n \"import\": \"./dist/config/index.js\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"scripts\": {\n \"build\": \"pnpm codecs:sync && tsup\",\n \"codecs:sync\": \"tsx ../../scripts/sync-codecs.ts\",\n \"dev\": \"tsup --watch\",\n \"typecheck\": \"tsc --noEmit\"\n },\n \"dependencies\": {\n \"@gltf-transform/core\": \"4.4.2\",\n \"@gltf-transform/extensions\": \"4.4.2\",\n \"@gltf-transform/functions\": \"4.4.2\",\n \"@jsquash/avif\": \"2.1.1\",\n \"@jsquash/jpeg\": \"1.6.0\",\n \"@jsquash/png\": \"3.1.1\",\n \"@jsquash/resize\": \"2.1.1\",\n \"@jsquash/webp\": \"1.5.0\",\n \"draco3dgltf\": \"1.5.7\",\n \"jiti\": \"2.7.0\",\n \"ktx2-encoder\": \"0.6.0\",\n \"meshoptimizer\": \"1.0.1\",\n \"tinyglobby\": \"0.2.17\"\n },\n \"devDependencies\": {\n \"@types/draco3dgltf\": \"1.4.3\"\n }\n}\n","import packageMetadata from '../../package.json'\n\nexport const CODEC_MANIFEST_HASH = '2046d60deb0f9f224743f4404f3c6e8ba5399f81b2811fa50466e93fce3bd322'\n\nexport const CODEC_ARTIFACTS = {\n avifEncoder: {\n packageName: '@jsquash/avif',\n packageVersion: '2.1.1',\n packagePath: 'codec/enc/avif_enc.wasm',\n publicFile: 'avif_enc.wasm',\n sha256: 'd9f2a95164362af48558d176e619becfd49dd97b50b86c679b47100860522b3d',\n },\n jpegDecoder: {\n packageName: '@jsquash/jpeg',\n packageVersion: '1.6.0',\n packagePath: 'codec/dec/mozjpeg_dec.wasm',\n publicFile: 'mozjpeg_dec.wasm',\n sha256: 'a7c4b12169817e779ff4af137981393ae924944e167ad1bd95747c9199162d3e',\n },\n jpegEncoder: {\n packageName: '@jsquash/jpeg',\n packageVersion: '1.6.0',\n packagePath: 'codec/enc/mozjpeg_enc.wasm',\n publicFile: 'mozjpeg_enc.wasm',\n sha256: '24d4177f1c4963e2058b107189249651c61fdef125570e79b1dfb63c8bb49326',\n },\n ktx2Encoder: {\n packageName: 'ktx2-encoder',\n packageVersion: '0.6.0',\n packagePath: 'dist/basis/basis_encoder.wasm',\n publicFile: 'basis_encoder.wasm',\n sha256: '9807719e87cf3d979b0d69ae7112eb88aec6a0e0206c0b2d00dc0bed0d581b80',\n },\n png: {\n packageName: '@jsquash/png',\n packageVersion: '3.1.1',\n packagePath: 'codec/pkg/squoosh_png_bg.wasm',\n publicFile: 'squoosh_png_bg.wasm',\n sha256: '263d6e658808a74b72a1a99c5cc1d619237e70c150db6e41d5d84d3d117ab9be',\n },\n resize: {\n packageName: '@jsquash/resize',\n packageVersion: '2.1.1',\n packagePath: 'lib/resize/pkg/squoosh_resize_bg.wasm',\n publicFile: 'squoosh_resize_bg.wasm',\n sha256: '5b1f702d502c4d0a70b99f78691bd554d566ba95859e4c57af5435955a1d74a5',\n },\n webpEncoder: {\n packageName: '@jsquash/webp',\n packageVersion: '1.5.0',\n packagePath: 'codec/enc/webp_enc.wasm',\n publicFile: 'webp_enc.wasm',\n sha256: 'b6085bb6702f144e9dc6016d58d230b34a84976bf0d080b7390b4b4b137d6ab7',\n },\n dracoDecoderScript: {\n packageName: 'draco3dgltf',\n packageVersion: '1.5.7',\n packagePath: 'draco_decoder_gltf_nodejs.js',\n publicFile: 'draco_decoder_gltf.js',\n sha256: '8bb2952d2ba7d67e1414f8df819410cb0434a666be53f671fff75f68843d76f6',\n },\n dracoDecoderWasm: {\n packageName: 'draco3dgltf',\n packageVersion: '1.5.7',\n packagePath: 'draco_decoder_gltf.wasm',\n publicFile: 'draco_decoder_gltf.wasm',\n sha256: '712db3449ae2041d6e8a224c395bda6cedb49e51322fae38b7db9beb8b381889',\n },\n dracoEncoderScript: {\n packageName: 'draco3dgltf',\n packageVersion: '1.5.7',\n packagePath: 'draco_encoder_gltf_nodejs.js',\n publicFile: 'draco_encoder_gltf.js',\n sha256: '8434adecd1446459601763e499be3697546056bca90b286a538ae0483a00845a',\n },\n dracoEncoderWasm: {\n packageName: 'draco3dgltf',\n packageVersion: '1.5.7',\n packagePath: 'draco_encoder.wasm',\n publicFile: 'draco_encoder.wasm',\n sha256: 'd2a3ac80c91980d5d321c116454834ff36264825c6d1794cc84e42288f158958',\n },\n} as const\n\nexport type CodecArtifactName = keyof typeof CODEC_ARTIFACTS\nexport type ImageWasmModuleName = Extract<\n CodecArtifactName,\n 'avifEncoder' | 'jpegDecoder' | 'jpegEncoder' | 'png' | 'resize' | 'webpEncoder'\n>\n\nexport const CODEC_MANIFEST = {\n schemaVersion: 1,\n chopperVersion: packageMetadata.version,\n manifestHash: CODEC_MANIFEST_HASH,\n gltfTransformVersion: '4.4.2',\n meshoptimizerVersion: '1.0.1',\n artifacts: CODEC_ARTIFACTS,\n} as const\n\nexport const ENGINE_ID = `chopper@${packageMetadata.version}:${CODEC_MANIFEST_HASH}` as const\n"]}
@@ -278,19 +278,14 @@ interface OptimizeFileOptions extends OptimizationOptions {
278
278
  }
279
279
  declare function optimizeFile({ input, output, recipe, ...options }: OptimizeFileOptions): Promise<ChopperResult<OptimizationOutput>>;
280
280
 
281
- type ChopperOutput = {
282
- mode: 'replace';
283
- } | {
284
- mode: 'template';
285
- path: string;
286
- };
287
281
  interface ChopperRule {
288
282
  include: readonly string[];
289
283
  exclude?: readonly string[];
290
284
  recipe: AssetRecipe;
291
- output: ChopperOutput;
285
+ path?: string;
292
286
  }
293
287
  interface ChopperConfig {
288
+ output: string;
294
289
  rules: readonly ChopperRule[];
295
290
  concurrency?: number;
296
291
  }
@@ -312,6 +307,7 @@ interface BatchFileReport {
312
307
  }
313
308
  interface BatchReport {
314
309
  mode: BatchMode;
310
+ output: string;
315
311
  files: BatchFileReport[];
316
312
  totals: {
317
313
  matched: number;
@@ -1,6 +1,6 @@
1
1
  import { createHash } from 'crypto';
2
2
  import { readFile, mkdir, mkdtemp, writeFile, rename, rm, readdir, copyFile } from 'fs/promises';
3
- import { join, resolve, dirname, relative, basename, extname } from 'path';
3
+ import { join, resolve, dirname, relative, isAbsolute, sep, basename, extname } from 'path';
4
4
  import avifEncoderFactory from '@jsquash/avif/codec/enc/avif_enc.js';
5
5
  import { defaultOptions as defaultOptions$1 } from '@jsquash/avif/meta.js';
6
6
  import jpegDecoderFactory from '@jsquash/jpeg/codec/dec/mozjpeg_dec.js';
@@ -255,7 +255,7 @@ function normalizeEncoding(encoding) {
255
255
 
256
256
  // package.json
257
257
  var package_default = {
258
- version: "0.2.0"};
258
+ version: "0.4.0"};
259
259
 
260
260
  // src/codecs/manifest.ts
261
261
  var CODEC_MANIFEST_HASH = "2046d60deb0f9f224743f4404f3c6e8ba5399f81b2811fa50466e93fce3bd322";
@@ -1116,10 +1116,18 @@ async function runConfig(options = {}) {
1116
1116
  loaded.data.concurrency ?? 2,
1117
1117
  (asset) => executeAsset(asset, mode, cwd, chopper2)
1118
1118
  );
1119
- return success({ mode, files, totals: summarize(files) });
1119
+ return success({ mode, output: relative(cwd, resolve(cwd, loaded.data.output)), files, totals: summarize(files) });
1120
1120
  }
1121
1121
  async function planAssets(config, cwd) {
1122
1122
  const planned = [];
1123
+ if (typeof config.output !== "string" || !config.output) {
1124
+ return failure("invalid_recipe", "Config output directory is required");
1125
+ }
1126
+ const outputRoot = resolve(cwd, config.output);
1127
+ const relativeRoot = relative(cwd, outputRoot);
1128
+ if (isAbsolute(relativeRoot) || relativeRoot === ".." || relativeRoot.startsWith(`..${sep}`)) {
1129
+ return failure("invalid_recipe", `Output directory must be inside the project: ${config.output}`);
1130
+ }
1123
1131
  for (const rule of config.rules) {
1124
1132
  const valid = validateRecipe(rule.recipe);
1125
1133
  if (!valid.ok) return valid;
@@ -1129,9 +1137,14 @@ async function planAssets(config, cwd) {
1129
1137
  onlyFiles: true
1130
1138
  });
1131
1139
  for (const match of matches.sort()) {
1140
+ const output = resolveOutput(rule, match, outputRoot);
1141
+ const relativeOutput = relative(outputRoot, output);
1142
+ if (isAbsolute(relativeOutput) || relativeOutput === ".." || relativeOutput.startsWith(`..${sep}`)) {
1143
+ return failure("invalid_recipe", `Output path must stay inside ${config.output}: ${rule.path}`);
1144
+ }
1132
1145
  planned.push({
1133
1146
  input: resolve(cwd, match),
1134
- output: resolveOutput(rule, match, cwd),
1147
+ output,
1135
1148
  rule
1136
1149
  });
1137
1150
  }
@@ -1194,14 +1207,13 @@ async function executeAsset(asset, mode, cwd, chopper2) {
1194
1207
  };
1195
1208
  }
1196
1209
  }
1197
- function resolveOutput(rule, input, cwd) {
1198
- if (rule.output.mode === "replace") return resolve(cwd, input);
1210
+ function resolveOutput(rule, input, outputRoot) {
1199
1211
  const extension = rule.recipe.kind === "glb" ? ".glb" : outputExtension(rule.recipe.encode);
1200
1212
  const inputDirectory = dirname(input) === "." ? "" : dirname(input);
1201
1213
  const name = basename(input, extname(input));
1202
1214
  return resolve(
1203
- cwd,
1204
- rule.output.path.replaceAll("{dir}", inputDirectory).replaceAll("{name}", name).replaceAll("{ext}", extension.slice(1))
1215
+ outputRoot,
1216
+ (rule.path ?? "{dir}/{name}.{ext}").replaceAll("{dir}", inputDirectory).replaceAll("{name}", name).replaceAll("{ext}", extension.slice(1))
1205
1217
  );
1206
1218
  }
1207
1219
  async function writeAtomic(path, bytes) {