@joycostudio/chopper 0.5.2 → 0.5.3
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/codecs/manifest.json +1 -1
- package/dist/browser/{chunk-C47JCVDL.js → chunk-AQRTPT4W.js} +3 -3
- package/dist/browser/{chunk-C47JCVDL.js.map → chunk-AQRTPT4W.js.map} +1 -1
- package/dist/browser/{in-process-Y2RGECEF.js → in-process-E2XKKSPY.js} +3 -3
- package/dist/browser/{in-process-Y2RGECEF.js.map → in-process-E2XKKSPY.js.map} +1 -1
- package/dist/browser/index.d.ts +136 -3
- package/dist/browser/index.js +2 -2
- package/dist/browser/worker.js +1 -1
- package/dist/browser/worker.js.map +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/config/index.d.ts +159 -3
- package/dist/config/index.js.map +1 -1
- package/dist/index.d.ts +137 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/node/index.d.ts +164 -3
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/recipes.ts","../src/core/result.ts","../src/core/object-validation.ts","../src/core/validation.ts","../src/codecs/hdr-source.ts","../package.json","../src/codecs/manifest.ts"],"names":["unknownField","encodingIssue"],"mappings":";AAkKO,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,E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B;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,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":["import type { NoUnknownFields } from './exact'\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\n/**\n * UASTC HDR 4x4. Encodes half-float EXR source into blocks the runtime\n * transcodes to BC6H on desktop, or uploads as ASTC 4x4 SFLOAT where the HDR\n * profile exists. Fixed 8 bits per texel on the GPU regardless of source.\n *\n * Deliberately not a `SizedEncoding`: resizing runs on decoded 8-bit RGBA, and\n * there is no half-float resampler in the pipeline, so HDR sources must already\n * be authored at their target resolution.\n */\nexport interface UastcHdrEncoding {\n codec: 'ktx2'\n mode: 'uastc-hdr'\n /** Encoder effort. Higher is slower; rarely helps on low-frequency lightmaps. */\n level?: 0 | 1 | 2 | 3 | 4\n mipmaps?: boolean\n zstd?: boolean\n}\n\nexport type RasterEncoding = WebpEncoding | AvifEncoding | JpegEncoding | PngEncoding\n\nexport type ImageEncoding = RasterEncoding | UastcEncoding | Etc1sEncoding | UastcHdrEncoding\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 kind: 'glb'\n methods?: readonly GlbMethodRecipe[]\n textures?: readonly EmbeddedTextureRecipe[]\n geometry?: GeometryEncoding | false\n}\n\nexport interface ImageAssetRecipe {\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 | Required<UastcHdrEncoding>\n\nexport type NormalizedAssetRecipe =\n | {\n kind: 'image'\n encode: NormalizedImageEncoding\n }\n | {\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 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 kind: 'image',\n encode: { codec: 'webp', quality: 85, effort: 80 },\n}\n\nexport const defineRecipe = <const T extends AssetRecipe>(recipe: T & NoUnknownFields<T, AssetRecipe>): 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","export function unknownFieldIssue(\n value: Record<string, unknown>,\n allowedFields: readonly string[],\n subject: string\n): string | undefined {\n const field = Object.keys(value).find((key) => !allowedFields.includes(key))\n return field ? `Unknown ${subject} field: ${field}` : undefined\n}\n","import { failure, success, type ChopperResult } from './result'\nimport { unknownFieldIssue } from './object-validation'\nimport {\n type AssetRecipe,\n type ImageEncoding,\n type NormalizedAssetRecipe,\n type NormalizedImageEncoding,\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 kind: 'image',\n encode: normalizeEncoding(recipe.encode),\n })\n }\n\n return success({\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 const unknownField = unknownFieldIssue(candidate, ['kind', 'encode'], 'image recipe')\n if (unknownField) return unknownField\n return encodingShapeIssue(candidate.encode)\n }\n\n const unknownField = unknownFieldIssue(candidate, ['kind', 'methods', 'textures', 'geometry'], 'GLB recipe')\n if (unknownField) return unknownField\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 (!method || typeof method !== 'object') {\n return 'GLB methods contain an unsupported transform'\n }\n const entry = method as Record<string, unknown>\n if (!['dedup', 'prune', 'resample'].includes(String(entry.method))) {\n return 'GLB methods contain an unsupported transform'\n }\n const allowedFields =\n entry.method === 'dedup'\n ? ['method', 'keepUniqueNames', 'propertyTypes']\n : entry.method === 'prune'\n ? ['method', 'keepAttributes', 'keepExtras', 'keepLeaves', 'keepSolidTextures', 'propertyTypes']\n : ['method', 'tolerance', 'cleanup']\n const unknownField = unknownFieldIssue(entry, allowedFields, 'GLB method')\n if (unknownField) return unknownField\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 const unknownField = unknownFieldIssue(entry, ['label', 'select', 'encode'], 'texture recipe')\n if (unknownField) return unknownField\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 if (!['slot', 'name', 'index'].includes(String(selector.by))) {\n return 'Texture recipe selectors are malformed'\n }\n const valueField = selector.by === 'slot' ? 'slots' : selector.by === 'name' ? 'names' : 'indices'\n const selectorUnknownField = unknownFieldIssue(selector, ['by', valueField], 'texture selector')\n if (selectorUnknownField) return selectorUnknownField\n if (!Array.isArray(selector[valueField])) return 'Texture recipe selectors are malformed'\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 if (candidate.geometry && typeof candidate.geometry === 'object') {\n const geometryUnknownField = unknownFieldIssue(\n candidate.geometry as Record<string, unknown>,\n ['codec'],\n 'GLB geometry'\n )\n if (geometryUnknownField) return geometryUnknownField\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 (\n candidate.codec === 'ktx2' &&\n candidate.mode !== 'uastc' &&\n candidate.mode !== 'etc1s' &&\n candidate.mode !== 'uastc-hdr'\n ) {\n return `Unsupported KTX2 mode: ${String(candidate.mode)}`\n }\n if (candidate.codec === 'ktx2' && candidate.mode === 'uastc-hdr' && candidate.maxSize !== undefined) {\n return 'UASTC HDR does not support maxSize; resizing requires a decoded 8-bit image. Author the source at its target resolution.'\n }\n const allowedFields =\n candidate.codec === 'webp'\n ? ['codec', 'maxSize', 'quality', 'effort', 'lossless', 'nearLossless']\n : candidate.codec === 'avif'\n ? ['codec', 'maxSize', 'quality', 'effort', 'lossless', 'chromaSubsampling']\n : candidate.codec === 'jpeg'\n ? ['codec', 'maxSize', 'quality', 'chromaSubsampling']\n : candidate.codec === 'png'\n ? ['codec', 'maxSize']\n : candidate.mode === 'uastc'\n ? ['codec', 'mode', 'maxSize', 'colorSpace', 'normalMap', 'level', 'mipmaps', 'zstd', 'rdo']\n : candidate.mode === 'etc1s'\n ? ['codec', 'mode', 'maxSize', 'colorSpace', 'normalMap', 'quality', 'compression', 'mipmaps']\n : ['codec', 'mode', 'level', 'mipmaps', 'zstd']\n const unknownField = unknownFieldIssue(candidate, allowedFields, 'image encoding')\n if (unknownField) return unknownField\n if (candidate.codec === 'ktx2' && candidate.mode === 'uastc' && candidate.rdo !== undefined) {\n if (!candidate.rdo || typeof candidate.rdo !== 'object' || Array.isArray(candidate.rdo)) {\n return 'UASTC RDO must be an object'\n }\n const rdoUnknownField = unknownFieldIssue(candidate.rdo as Record<string, unknown>, ['lambda'], 'UASTC RDO')\n if (rdoUnknownField) return rdoUnknownField\n }\n return undefined\n}\n\nfunction recipeIssue(recipe: AssetRecipe): string | undefined {\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 if (texture.encode.codec === 'ktx2' && texture.encode.mode === 'uastc-hdr') {\n return `Texture recipe \"${texture.label}\" uses UASTC HDR, which KHR_texture_basisu does not cover; HDR is only supported for standalone image recipes`\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 ('maxSize' in encoding && 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 === 'uastc-hdr' &&\n encoding.level !== undefined &&\n (!Number.isInteger(encoding.level) || encoding.level < 0 || encoding.level > 4)\n ) {\n return 'UASTC HDR level must be an integer between 0 and 4'\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-hdr') {\n return {\n ...encoding,\n level: encoding.level ?? 1,\n mipmaps: encoding.mipmaps ?? true,\n zstd: encoding.zstd ?? true,\n }\n }\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 * Minimal readers for the two HDR containers Chopper accepts.\n *\n * Chopper never decodes HDR pixels: the Basis encoder parses the container\n * itself (see `encodeKtx2Hdr`). All we need locally is the image size, so\n * `inspect` can report dimensions and so oversized inputs fail with a message\n * that names the real limit instead of the encoder's output-buffer wall.\n */\n\nexport type HdrContainer = 'exr' | 'hdr'\n\nexport type HdrSourceMimeType = 'image/x-exr' | 'image/vnd.radiance'\n\n/** The source mime types the Basis HDR encoder parses directly. */\nexport const HDR_SOURCE_MIME_TYPES: Record<HdrContainer, HdrSourceMimeType> = {\n exr: 'image/x-exr',\n hdr: 'image/vnd.radiance',\n}\n\nexport function isHdrSourceMimeType(mimeType: string): boolean {\n return mimeType === 'image/x-exr' || mimeType === 'image/vnd.radiance'\n}\n\n/** `0x01312f76` little-endian. */\nconst EXR_MAGIC = [0x76, 0x2f, 0x31, 0x01] as const\n\n// ImfVersion.h\nconst VERSION_NUMBER_FIELD = 0x000000ff\nconst NON_IMAGE_FLAG = 0x00000800\nconst MULTI_PART_FILE_FLAG = 0x00001000\n\n/**\n * EXR compression codecs, and whether the Basis encoder's bundled TinyEXR can\n * read them. TinyEXR decodes NONE, RLE, ZIPS, ZIP and PIZ; everything else hits\n * its \"Unknown compression type\" branch and fails inside the WASM with no\n * mention of which codec was at fault.\n */\nconst EXR_COMPRESSION = [\n { name: 'NO_COMPRESSION', supported: true },\n { name: 'RLE', supported: true },\n { name: 'ZIPS', supported: true },\n { name: 'ZIP', supported: true },\n { name: 'PIZ', supported: true },\n { name: 'PXR24', supported: false },\n { name: 'B44', supported: false },\n { name: 'B44A', supported: false },\n { name: 'DWAA', supported: false },\n { name: 'DWAB', supported: false },\n] as const\n\n/** Radiance files open with `#?`, usually followed by RADIANCE or RGBE. */\nconst RADIANCE_MAGIC = [0x23, 0x3f] as const\n\n/** Radiance headers are small; never scan more than this looking for one. */\nconst RADIANCE_HEADER_LIMIT = 8192\n\n/**\n * Basis v2.5 caps total source texels to guard 32-bit WASM against OOM. The\n * wrapper only pre-checks this for LDR input, so HDR inputs that exceed it fail\n * deep inside the encoder with an output-buffer message that says nothing about\n * resolution. Chopper checks it up front instead.\n */\nexport const MAX_HDR_SOURCE_TEXELS = 12 * 1024 * 1024\n\nexport function detectHdrContainer(bytes: Uint8Array): HdrContainer | undefined {\n if (bytes.length >= 8 && EXR_MAGIC.every((byte, index) => bytes[index] === byte)) return 'exr'\n if (bytes.length >= 8 && RADIANCE_MAGIC.every((byte, index) => bytes[index] === byte)) return 'hdr'\n return undefined\n}\n\nexport interface HdrSource {\n container: HdrContainer\n width: number\n height: number\n}\n\nexport function readHdrSource(bytes: Uint8Array): HdrSource | { error: string } {\n const container = detectHdrContainer(bytes)\n if (!container) return { error: 'Not an OpenEXR or Radiance HDR file' }\n return container === 'exr' ? readExr(bytes) : readRadiance(bytes)\n}\n\n/** Reads the data window from an EXR header. */\nfunction readExr(bytes: Uint8Array): HdrSource | { error: string } {\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength)\n const version = view.getInt32(4, true)\n if ((version & VERSION_NUMBER_FIELD) !== 2) {\n return { error: `Unsupported EXR version: ${version & VERSION_NUMBER_FIELD}` }\n }\n if (version & MULTI_PART_FILE_FLAG) return { error: 'Multi-part EXR files are not supported' }\n if (version & NON_IMAGE_FLAG) return { error: 'Deep EXR files are not supported' }\n\n // name\\0 type\\0 int32 size, value[size] — repeated until a zero-length name.\n // dataWindow and compression can appear in either order, so collect both.\n let size: HdrSource | undefined\n let compressionIssue: string | undefined\n\n let offset = 8\n while (offset < bytes.length) {\n const name = readNullTerminated(bytes, offset)\n if (name === undefined) return { error: 'Malformed EXR header' }\n // A zero-length name closes the header.\n if (name.value === '') break\n offset = name.next\n\n const type = readNullTerminated(bytes, offset)\n if (type === undefined) return { error: 'Malformed EXR header' }\n offset = type.next\n\n if (offset + 4 > bytes.length) return { error: 'Malformed EXR header' }\n const length = view.getInt32(offset, true)\n offset += 4\n if (length < 0 || offset + length > bytes.length) return { error: 'Malformed EXR header' }\n\n if (name.value === 'dataWindow') {\n if (type.value !== 'box2i' || length !== 16) return { error: 'Malformed EXR dataWindow' }\n const xMin = view.getInt32(offset, true)\n const yMin = view.getInt32(offset + 4, true)\n const xMax = view.getInt32(offset + 8, true)\n const yMax = view.getInt32(offset + 12, true)\n const width = xMax - xMin + 1\n const height = yMax - yMin + 1\n if (width < 1 || height < 1) return { error: 'EXR dataWindow is empty' }\n size = { container: 'exr', width, height }\n }\n\n if (name.value === 'compression') {\n if (length !== 1) return { error: 'Malformed EXR compression attribute' }\n compressionIssue = exrCompressionIssue(bytes[offset]!)\n }\n\n offset += length\n }\n\n // Compression first: an unreadable codec matters more than the dimensions.\n if (compressionIssue) return { error: compressionIssue }\n return size ?? { error: 'EXR header has no dataWindow attribute' }\n}\n\nfunction exrCompressionIssue(code: number): string | undefined {\n const codec = EXR_COMPRESSION[code]\n if (!codec) return `Unsupported EXR compression: unknown codec ${code}`\n if (codec.supported) return undefined\n\n const readable = EXR_COMPRESSION.filter((entry) => entry.supported)\n .map((entry) => entry.name)\n .join(', ')\n return (\n `EXR uses ${codec.name} compression, which the HDR encoder cannot read. ` +\n `Re-export with one of: ${readable}. EXR compression only affects the file on ` +\n `disk — it does not change the encoded KTX2.`\n )\n}\n\n/**\n * Reads the resolution line of a Radiance file: variable header lines, a blank\n * line, then a line pairing an X and a Y axis with their extents.\n */\nfunction readRadiance(bytes: Uint8Array): HdrSource | { error: string } {\n const text = latin1(bytes.subarray(0, RADIANCE_HEADER_LIMIT))\n const lines = text.split('\\n')\n\n let index = 0\n while (index < lines.length && lines[index] !== '' && lines[index] !== '\\r') index++\n // Skip the blank line that closes the header.\n index++\n while (index < lines.length && (lines[index] === '' || lines[index] === '\\r')) index++\n if (index >= lines.length) return { error: 'Radiance file has no resolution line' }\n\n const resolution = /^([+-][XY])\\s+(\\d+)\\s+([+-][XY])\\s+(\\d+)\\s*$/.exec(lines[index]!.replace(/\\r$/, ''))\n if (!resolution) return { error: `Malformed Radiance resolution line: ${lines[index]!.slice(0, 40)}` }\n\n const extents = new Map([\n [resolution[1]![1], Number(resolution[2])],\n [resolution[3]![1], Number(resolution[4])],\n ])\n const width = extents.get('X')\n const height = extents.get('Y')\n if (width === undefined || height === undefined) {\n return { error: 'Radiance resolution line must pair an X and a Y axis' }\n }\n if (width < 1 || height < 1) return { error: 'Radiance image is empty' }\n\n return { container: 'hdr', width, height }\n}\n\nfunction readNullTerminated(bytes: Uint8Array, start: number): { value: string; next: number } | undefined {\n // Attribute names and types are capped at 255 bytes even with LONG_NAMES_FLAG.\n const limit = Math.min(bytes.length, start + 256)\n for (let index = start; index < limit; index++) {\n if (bytes[index] === 0) {\n return { value: latin1(bytes.subarray(start, index)), next: index + 1 }\n }\n }\n return undefined\n}\n\nfunction latin1(bytes: Uint8Array): string {\n let value = ''\n for (const byte of bytes) value += String.fromCharCode(byte)\n return value\n}\n","{\n \"name\": \"@joycostudio/chopper\",\n \"version\": \"0.5.2\",\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 \"default\": \"./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 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/object-validation.ts","../src/core/validation.ts","../src/codecs/hdr-source.ts","../package.json","../src/codecs/manifest.ts"],"names":["unknownField","encodingIssue"],"mappings":";AAwTO,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,GAAqC;AAAA,EAChD,IAAA,EAAM,KAAA;AAAA,EACN,SAAS,EAAC;AAAA,EACV,QAAA,EAAU;AAAA,IACR;AAAA,MACE,KAAA,EAAO,OAAA;AAAA,MACP,MAAA,EAAQ,EAAE,EAAA,EAAI,MAAA,EAAQ,OAAO,mBAAA,EAAoB;AAAA,MACjD,MAAA,EAAQ;AAAA,QACN,KAAA,EAAO,MAAA;AAAA,QACP,IAAA,EAAM,OAAA;AAAA,QACN,UAAA,EAAY,MAAA;AAAA,QACZ,KAAA,EAAO,CAAA;AAAA,QACP,IAAA,EAAM;AAAA;AACR,KACF;AAAA,IACA;AAAA,MACE,KAAA,EAAO,aAAA;AAAA,MACP,MAAA,EAAQ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A;AAAA,IACZ,MAAA,EAAQ;AAAA;AAEZ,CAAA;AAQO,IAAM,cAAA,GAAiB;AAAA,EAC5B,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":["import type { NoUnknownFields } from './exact'\n\n/** Maximum image dimensions in pixels: `[width, height]`. Both values must be positive integers. */\nexport type TextureSize = readonly [width: number, height: number]\n\ninterface SizedEncoding {\n /**\n * Maximum output dimensions in pixels. Aspect ratio is preserved, and an\n * image smaller than both limits is not enlarged. Omit this property to keep\n * the source dimensions.\n */\n maxSize?: TextureSize\n}\n\nexport interface WebpEncoding extends SizedEncoding {\n /** Encode the image as WebP. */\n codec: 'webp'\n /** Lossy quality from 1 (smallest, lowest fidelity) to 100. @defaultValue `75` */\n quality?: number\n /** Encoder effort from 0 (fastest) to 100 (slowest). @defaultValue `50` */\n effort?: number\n /** Use lossless WebP instead of lossy encoding. Lossy `quality` is then ignored. @defaultValue `false` */\n lossless?: boolean\n /**\n * Near-lossless preprocessing quality for lossless encoding, from 0\n * (strongest pixel changes and smallest output) to 100 (no preprocessing).\n *\n * @defaultValue `100`\n */\n nearLossless?: number\n}\n\nexport interface AvifEncoding extends SizedEncoding {\n /** Encode the image as AVIF. */\n codec: 'avif'\n /** Lossy quality from 1 (smallest, lowest fidelity) to 100. @defaultValue `50` */\n quality?: number\n /** Encoder effort from 0 (fastest) to 100 (slowest). @defaultValue `40` */\n effort?: number\n /** Use lossless AVIF instead of lossy encoding, overriding `quality` and chroma subsampling. @defaultValue `false` */\n lossless?: boolean\n /**\n * Chroma resolution: `4:2:0` reduces color detail for smaller files, while\n * `4:4:4` preserves full color resolution. Lossless encoding always uses\n * full color resolution.\n *\n * @defaultValue `'4:2:0'`\n */\n chromaSubsampling?: '4:2:0' | '4:4:4'\n}\n\nexport interface JpegEncoding extends SizedEncoding {\n /** Encode the image as JPEG. Alpha is not preserved. */\n codec: 'jpeg'\n /** Lossy quality from 1 (smallest, lowest fidelity) to 100. @defaultValue `75` */\n quality?: number\n /**\n * Chroma resolution: `4:2:0` reduces color detail for smaller files, while\n * `4:4:4` preserves full color resolution.\n *\n * @defaultValue `'4:2:0'`\n */\n chromaSubsampling?: '4:2:0' | '4:4:4'\n}\n\nexport interface PngEncoding extends SizedEncoding {\n /** Encode the image as lossless PNG. */\n codec: 'png'\n}\n\nexport interface UastcEncoding extends SizedEncoding {\n /** Encode the image in a GPU-ready KTX2 container. */\n codec: 'ktx2'\n /** Use high-quality UASTC block compression for LDR pixels. */\n mode: 'uastc'\n /**\n * How the texture is sampled: `srgb` for color data such as albedo and\n * emissive maps, or `linear` for data and normal maps.\n *\n * @defaultValue `'srgb'`\n */\n colorSpace?: 'srgb' | 'linear'\n /** Tune the encoder for tangent-space normal-map data. @defaultValue `false` */\n normalMap?: boolean\n /** Encoder effort from 0 (fastest) to 4 (slowest, highest quality). @defaultValue `2` */\n level?: 0 | 1 | 2 | 3 | 4\n /** Generate a complete mip chain for minified rendering. @defaultValue `true` */\n mipmaps?: boolean\n /** Apply Zstandard supercompression to reduce download size. @defaultValue `true` */\n zstd?: boolean\n /**\n * Enable rate-distortion optimization. This can substantially reduce files\n * at the cost of image fidelity; omit it to disable RDO.\n */\n rdo?: {\n /**\n * Compression-to-quality tradeoff from 0.001 to 10. Larger values usually\n * produce smaller files with more distortion.\n *\n * @defaultValue `1`\n */\n lambda?: number\n }\n}\n\nexport interface Etc1sEncoding extends SizedEncoding {\n /** Encode the image in a GPU-ready KTX2 container. */\n codec: 'ktx2'\n /** Use ETC1S compression for the smallest download size at lower fidelity than UASTC. */\n mode: 'etc1s'\n /**\n * How the texture is sampled: `srgb` for color data such as albedo and\n * emissive maps, or `linear` for data and normal maps.\n *\n * @defaultValue `'srgb'`\n */\n colorSpace?: 'srgb' | 'linear'\n /** Tune the encoder for tangent-space normal-map data. @defaultValue `false` */\n normalMap?: boolean\n /** Quality from 1 (smallest, lowest fidelity) to 255. @defaultValue `128` */\n quality?: number\n /**\n * Encoder effort from 0 (fastest) to 6 (slowest). Higher values search\n * harder for a smaller file at the requested quality.\n *\n * @defaultValue `1`\n */\n compression?: 0 | 1 | 2 | 3 | 4 | 5 | 6\n /** Generate a complete mip chain for minified rendering. @defaultValue `true` */\n mipmaps?: boolean\n}\n\n/**\n * UASTC HDR 4x4. Encodes half-float EXR source into blocks the runtime\n * transcodes to BC6H on desktop, or uploads as ASTC 4x4 SFLOAT where the HDR\n * profile exists. Fixed 8 bits per texel on the GPU regardless of source.\n *\n * Deliberately not a `SizedEncoding`: resizing runs on decoded 8-bit RGBA, and\n * there is no half-float resampler in the pipeline, so HDR sources must already\n * be authored at their target resolution.\n */\nexport interface UastcHdrEncoding {\n /** Encode the image in a GPU-ready KTX2 container. */\n codec: 'ktx2'\n /**\n * Use UASTC HDR for half-float EXR or Radiance HDR input. This mode does not\n * support resizing or alpha and is only available to standalone image recipes.\n */\n mode: 'uastc-hdr'\n /**\n * Encoder effort from 0 (fastest) to 4 (slowest). Higher levels rarely help\n * low-frequency content such as diffuse lightmaps.\n *\n * @defaultValue `1`\n */\n level?: 0 | 1 | 2 | 3 | 4\n /** Generate a complete mip chain for minified rendering. @defaultValue `true` */\n mipmaps?: boolean\n /** Apply Zstandard supercompression to reduce download size. @defaultValue `true` */\n zstd?: boolean\n}\n\nexport type RasterEncoding = WebpEncoding | AvifEncoding | JpegEncoding | PngEncoding\n\nexport type ImageEncoding = RasterEncoding | UastcEncoding | Etc1sEncoding | UastcHdrEncoding\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 /** Merge equivalent accessors, materials, meshes, skins, or textures. */\n method: 'dedup'\n /** Keep otherwise-identical properties separate when their names differ. @defaultValue `false` */\n keepUniqueNames?: boolean\n /**\n * Property kinds to merge.\n *\n * @defaultValue `['accessor', 'material', 'mesh', 'skin', 'texture']`\n */\n propertyTypes?: readonly Extract<GlbProperty, 'accessor' | 'material' | 'mesh' | 'skin' | 'texture'>[]\n }\n | {\n /** Remove unused GLB properties and optionally simplify redundant data. */\n method: 'prune'\n /** Keep unused vertex attributes, such as UVs without an assigned texture. @defaultValue `false` */\n keepAttributes?: boolean\n /** Prevent a property with custom `extras` data from being removed. @defaultValue `false` */\n keepExtras?: boolean\n /** Keep empty leaf nodes that would otherwise be removed. @defaultValue `false` */\n keepLeaves?: boolean\n /** Keep single-color textures instead of replacing them with material factors. @defaultValue `false` */\n keepSolidTextures?: boolean\n /** Property kinds eligible for pruning. By default, every supported kind is eligible. */\n propertyTypes?: readonly GlbProperty[]\n }\n | {\n /** Remove redundant animation keyframes while keeping motion within a tolerance. */\n method: 'resample'\n /** Maximum permitted animation-value error. Must be greater than zero. @defaultValue `0.0001` */\n tolerance?: number\n /**\n * Deduplicate and prune temporary or unused resources after resampling.\n * Disable this when those resources must be preserved for a later step.\n *\n * @defaultValue `true`\n */\n cleanup?: boolean\n }\n\nexport type TextureSelector =\n | {\n /** Select textures by the material slots that reference them. */\n by: 'slot'\n /** glTF material texture-slot names, such as `baseColorTexture` or `normalTexture`. */\n slots: readonly string[]\n }\n | {\n /** Select textures by their authored GLB names. */\n by: 'name'\n /** Exact, case-sensitive texture names. Names should be unique within the GLB. */\n names: readonly string[]\n }\n | {\n /** Select textures by their zero-based order in the GLB. */\n by: 'index'\n /** Non-negative texture indices. Indices can change when a source GLB is re-exported. */\n indices: readonly number[]\n }\n\nexport interface EmbeddedTextureRecipe {\n /**\n * Unique, non-empty name for this texture group in progress events and\n * optimization reports. It does not rename textures in the GLB.\n */\n label: string\n /** Textures to encode. A texture cannot be claimed by more than one selector. */\n select: TextureSelector\n /** Output encoding for the selected textures. UASTC HDR is not supported inside GLBs. */\n encode: ImageEncoding\n}\n\nexport type GeometryEncoding =\n | {\n /** Compress geometry with `KHR_draco_mesh_compression` for broad decoder support. */\n codec: 'draco'\n }\n | {\n /** Compress geometry with `EXT_meshopt_compression` for fast runtime decoding. */\n codec: 'meshopt'\n }\n\nexport interface GlbAssetRecipe {\n /** Optimize a binary glTF (`.glb`) asset. */\n kind: 'glb'\n /** Structural transforms to run in array order before texture and geometry encoding. @defaultValue `[]` */\n methods?: readonly GlbMethodRecipe[]\n /** Embedded texture groups to encode. Unselected textures keep their source encoding. @defaultValue `[]` */\n textures?: readonly EmbeddedTextureRecipe[]\n /** Geometry codec to apply, or `false` to leave geometry uncompressed. @defaultValue `false` */\n geometry?: GeometryEncoding | false\n}\n\nexport interface ImageAssetRecipe {\n /** Optimize a standalone raster or HDR image. */\n kind: 'image'\n /** Output codec and its quality, size, and performance tradeoffs. */\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 | Required<UastcHdrEncoding>\n\nexport type NormalizedAssetRecipe =\n | {\n /** Identifies the normalized recipe as a standalone image recipe. */\n kind: 'image'\n /** Image encoding with every codec default resolved. */\n encode: NormalizedImageEncoding\n }\n | {\n /** Identifies the normalized recipe as a binary glTF recipe. */\n kind: 'glb'\n /** Structural transforms to run, with an omitted value resolved to an empty array. */\n methods: readonly GlbMethodRecipe[]\n /** Embedded texture groups with every codec default resolved. */\n textures: readonly (Omit<EmbeddedTextureRecipe, 'encode'> & {\n /** Output encoding with every codec default resolved. */\n encode: NormalizedImageEncoding\n })[]\n /** Resolved geometry codec, or `false` when geometry compression is disabled. */\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 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 kind: 'image',\n encode: { codec: 'webp', quality: 85, effort: 80 },\n}\n\n/** Defines a type-checked optimization recipe while preserving its inferred literal types. */\nexport const defineRecipe = <const T extends AssetRecipe>(recipe: T & NoUnknownFields<T, AssetRecipe>): 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","export function unknownFieldIssue(\n value: Record<string, unknown>,\n allowedFields: readonly string[],\n subject: string\n): string | undefined {\n const field = Object.keys(value).find((key) => !allowedFields.includes(key))\n return field ? `Unknown ${subject} field: ${field}` : undefined\n}\n","import { failure, success, type ChopperResult } from './result'\nimport { unknownFieldIssue } from './object-validation'\nimport {\n type AssetRecipe,\n type ImageEncoding,\n type NormalizedAssetRecipe,\n type NormalizedImageEncoding,\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 kind: 'image',\n encode: normalizeEncoding(recipe.encode),\n })\n }\n\n return success({\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 const unknownField = unknownFieldIssue(candidate, ['kind', 'encode'], 'image recipe')\n if (unknownField) return unknownField\n return encodingShapeIssue(candidate.encode)\n }\n\n const unknownField = unknownFieldIssue(candidate, ['kind', 'methods', 'textures', 'geometry'], 'GLB recipe')\n if (unknownField) return unknownField\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 (!method || typeof method !== 'object') {\n return 'GLB methods contain an unsupported transform'\n }\n const entry = method as Record<string, unknown>\n if (!['dedup', 'prune', 'resample'].includes(String(entry.method))) {\n return 'GLB methods contain an unsupported transform'\n }\n const allowedFields =\n entry.method === 'dedup'\n ? ['method', 'keepUniqueNames', 'propertyTypes']\n : entry.method === 'prune'\n ? ['method', 'keepAttributes', 'keepExtras', 'keepLeaves', 'keepSolidTextures', 'propertyTypes']\n : ['method', 'tolerance', 'cleanup']\n const unknownField = unknownFieldIssue(entry, allowedFields, 'GLB method')\n if (unknownField) return unknownField\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 const unknownField = unknownFieldIssue(entry, ['label', 'select', 'encode'], 'texture recipe')\n if (unknownField) return unknownField\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 if (!['slot', 'name', 'index'].includes(String(selector.by))) {\n return 'Texture recipe selectors are malformed'\n }\n const valueField = selector.by === 'slot' ? 'slots' : selector.by === 'name' ? 'names' : 'indices'\n const selectorUnknownField = unknownFieldIssue(selector, ['by', valueField], 'texture selector')\n if (selectorUnknownField) return selectorUnknownField\n if (!Array.isArray(selector[valueField])) return 'Texture recipe selectors are malformed'\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 if (candidate.geometry && typeof candidate.geometry === 'object') {\n const geometryUnknownField = unknownFieldIssue(\n candidate.geometry as Record<string, unknown>,\n ['codec'],\n 'GLB geometry'\n )\n if (geometryUnknownField) return geometryUnknownField\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 (\n candidate.codec === 'ktx2' &&\n candidate.mode !== 'uastc' &&\n candidate.mode !== 'etc1s' &&\n candidate.mode !== 'uastc-hdr'\n ) {\n return `Unsupported KTX2 mode: ${String(candidate.mode)}`\n }\n if (candidate.codec === 'ktx2' && candidate.mode === 'uastc-hdr' && candidate.maxSize !== undefined) {\n return 'UASTC HDR does not support maxSize; resizing requires a decoded 8-bit image. Author the source at its target resolution.'\n }\n const allowedFields =\n candidate.codec === 'webp'\n ? ['codec', 'maxSize', 'quality', 'effort', 'lossless', 'nearLossless']\n : candidate.codec === 'avif'\n ? ['codec', 'maxSize', 'quality', 'effort', 'lossless', 'chromaSubsampling']\n : candidate.codec === 'jpeg'\n ? ['codec', 'maxSize', 'quality', 'chromaSubsampling']\n : candidate.codec === 'png'\n ? ['codec', 'maxSize']\n : candidate.mode === 'uastc'\n ? ['codec', 'mode', 'maxSize', 'colorSpace', 'normalMap', 'level', 'mipmaps', 'zstd', 'rdo']\n : candidate.mode === 'etc1s'\n ? ['codec', 'mode', 'maxSize', 'colorSpace', 'normalMap', 'quality', 'compression', 'mipmaps']\n : ['codec', 'mode', 'level', 'mipmaps', 'zstd']\n const unknownField = unknownFieldIssue(candidate, allowedFields, 'image encoding')\n if (unknownField) return unknownField\n if (candidate.codec === 'ktx2' && candidate.mode === 'uastc' && candidate.rdo !== undefined) {\n if (!candidate.rdo || typeof candidate.rdo !== 'object' || Array.isArray(candidate.rdo)) {\n return 'UASTC RDO must be an object'\n }\n const rdoUnknownField = unknownFieldIssue(candidate.rdo as Record<string, unknown>, ['lambda'], 'UASTC RDO')\n if (rdoUnknownField) return rdoUnknownField\n }\n return undefined\n}\n\nfunction recipeIssue(recipe: AssetRecipe): string | undefined {\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 if (texture.encode.codec === 'ktx2' && texture.encode.mode === 'uastc-hdr') {\n return `Texture recipe \"${texture.label}\" uses UASTC HDR, which KHR_texture_basisu does not cover; HDR is only supported for standalone image recipes`\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 ('maxSize' in encoding && 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 === 'uastc-hdr' &&\n encoding.level !== undefined &&\n (!Number.isInteger(encoding.level) || encoding.level < 0 || encoding.level > 4)\n ) {\n return 'UASTC HDR level must be an integer between 0 and 4'\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-hdr') {\n return {\n ...encoding,\n level: encoding.level ?? 1,\n mipmaps: encoding.mipmaps ?? true,\n zstd: encoding.zstd ?? true,\n }\n }\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 * Minimal readers for the two HDR containers Chopper accepts.\n *\n * Chopper never decodes HDR pixels: the Basis encoder parses the container\n * itself (see `encodeKtx2Hdr`). All we need locally is the image size, so\n * `inspect` can report dimensions and so oversized inputs fail with a message\n * that names the real limit instead of the encoder's output-buffer wall.\n */\n\nexport type HdrContainer = 'exr' | 'hdr'\n\nexport type HdrSourceMimeType = 'image/x-exr' | 'image/vnd.radiance'\n\n/** The source mime types the Basis HDR encoder parses directly. */\nexport const HDR_SOURCE_MIME_TYPES: Record<HdrContainer, HdrSourceMimeType> = {\n exr: 'image/x-exr',\n hdr: 'image/vnd.radiance',\n}\n\nexport function isHdrSourceMimeType(mimeType: string): boolean {\n return mimeType === 'image/x-exr' || mimeType === 'image/vnd.radiance'\n}\n\n/** `0x01312f76` little-endian. */\nconst EXR_MAGIC = [0x76, 0x2f, 0x31, 0x01] as const\n\n// ImfVersion.h\nconst VERSION_NUMBER_FIELD = 0x000000ff\nconst NON_IMAGE_FLAG = 0x00000800\nconst MULTI_PART_FILE_FLAG = 0x00001000\n\n/**\n * EXR compression codecs, and whether the Basis encoder's bundled TinyEXR can\n * read them. TinyEXR decodes NONE, RLE, ZIPS, ZIP and PIZ; everything else hits\n * its \"Unknown compression type\" branch and fails inside the WASM with no\n * mention of which codec was at fault.\n */\nconst EXR_COMPRESSION = [\n { name: 'NO_COMPRESSION', supported: true },\n { name: 'RLE', supported: true },\n { name: 'ZIPS', supported: true },\n { name: 'ZIP', supported: true },\n { name: 'PIZ', supported: true },\n { name: 'PXR24', supported: false },\n { name: 'B44', supported: false },\n { name: 'B44A', supported: false },\n { name: 'DWAA', supported: false },\n { name: 'DWAB', supported: false },\n] as const\n\n/** Radiance files open with `#?`, usually followed by RADIANCE or RGBE. */\nconst RADIANCE_MAGIC = [0x23, 0x3f] as const\n\n/** Radiance headers are small; never scan more than this looking for one. */\nconst RADIANCE_HEADER_LIMIT = 8192\n\n/**\n * Basis v2.5 caps total source texels to guard 32-bit WASM against OOM. The\n * wrapper only pre-checks this for LDR input, so HDR inputs that exceed it fail\n * deep inside the encoder with an output-buffer message that says nothing about\n * resolution. Chopper checks it up front instead.\n */\nexport const MAX_HDR_SOURCE_TEXELS = 12 * 1024 * 1024\n\nexport function detectHdrContainer(bytes: Uint8Array): HdrContainer | undefined {\n if (bytes.length >= 8 && EXR_MAGIC.every((byte, index) => bytes[index] === byte)) return 'exr'\n if (bytes.length >= 8 && RADIANCE_MAGIC.every((byte, index) => bytes[index] === byte)) return 'hdr'\n return undefined\n}\n\nexport interface HdrSource {\n container: HdrContainer\n width: number\n height: number\n}\n\nexport function readHdrSource(bytes: Uint8Array): HdrSource | { error: string } {\n const container = detectHdrContainer(bytes)\n if (!container) return { error: 'Not an OpenEXR or Radiance HDR file' }\n return container === 'exr' ? readExr(bytes) : readRadiance(bytes)\n}\n\n/** Reads the data window from an EXR header. */\nfunction readExr(bytes: Uint8Array): HdrSource | { error: string } {\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength)\n const version = view.getInt32(4, true)\n if ((version & VERSION_NUMBER_FIELD) !== 2) {\n return { error: `Unsupported EXR version: ${version & VERSION_NUMBER_FIELD}` }\n }\n if (version & MULTI_PART_FILE_FLAG) return { error: 'Multi-part EXR files are not supported' }\n if (version & NON_IMAGE_FLAG) return { error: 'Deep EXR files are not supported' }\n\n // name\\0 type\\0 int32 size, value[size] — repeated until a zero-length name.\n // dataWindow and compression can appear in either order, so collect both.\n let size: HdrSource | undefined\n let compressionIssue: string | undefined\n\n let offset = 8\n while (offset < bytes.length) {\n const name = readNullTerminated(bytes, offset)\n if (name === undefined) return { error: 'Malformed EXR header' }\n // A zero-length name closes the header.\n if (name.value === '') break\n offset = name.next\n\n const type = readNullTerminated(bytes, offset)\n if (type === undefined) return { error: 'Malformed EXR header' }\n offset = type.next\n\n if (offset + 4 > bytes.length) return { error: 'Malformed EXR header' }\n const length = view.getInt32(offset, true)\n offset += 4\n if (length < 0 || offset + length > bytes.length) return { error: 'Malformed EXR header' }\n\n if (name.value === 'dataWindow') {\n if (type.value !== 'box2i' || length !== 16) return { error: 'Malformed EXR dataWindow' }\n const xMin = view.getInt32(offset, true)\n const yMin = view.getInt32(offset + 4, true)\n const xMax = view.getInt32(offset + 8, true)\n const yMax = view.getInt32(offset + 12, true)\n const width = xMax - xMin + 1\n const height = yMax - yMin + 1\n if (width < 1 || height < 1) return { error: 'EXR dataWindow is empty' }\n size = { container: 'exr', width, height }\n }\n\n if (name.value === 'compression') {\n if (length !== 1) return { error: 'Malformed EXR compression attribute' }\n compressionIssue = exrCompressionIssue(bytes[offset]!)\n }\n\n offset += length\n }\n\n // Compression first: an unreadable codec matters more than the dimensions.\n if (compressionIssue) return { error: compressionIssue }\n return size ?? { error: 'EXR header has no dataWindow attribute' }\n}\n\nfunction exrCompressionIssue(code: number): string | undefined {\n const codec = EXR_COMPRESSION[code]\n if (!codec) return `Unsupported EXR compression: unknown codec ${code}`\n if (codec.supported) return undefined\n\n const readable = EXR_COMPRESSION.filter((entry) => entry.supported)\n .map((entry) => entry.name)\n .join(', ')\n return (\n `EXR uses ${codec.name} compression, which the HDR encoder cannot read. ` +\n `Re-export with one of: ${readable}. EXR compression only affects the file on ` +\n `disk — it does not change the encoded KTX2.`\n )\n}\n\n/**\n * Reads the resolution line of a Radiance file: variable header lines, a blank\n * line, then a line pairing an X and a Y axis with their extents.\n */\nfunction readRadiance(bytes: Uint8Array): HdrSource | { error: string } {\n const text = latin1(bytes.subarray(0, RADIANCE_HEADER_LIMIT))\n const lines = text.split('\\n')\n\n let index = 0\n while (index < lines.length && lines[index] !== '' && lines[index] !== '\\r') index++\n // Skip the blank line that closes the header.\n index++\n while (index < lines.length && (lines[index] === '' || lines[index] === '\\r')) index++\n if (index >= lines.length) return { error: 'Radiance file has no resolution line' }\n\n const resolution = /^([+-][XY])\\s+(\\d+)\\s+([+-][XY])\\s+(\\d+)\\s*$/.exec(lines[index]!.replace(/\\r$/, ''))\n if (!resolution) return { error: `Malformed Radiance resolution line: ${lines[index]!.slice(0, 40)}` }\n\n const extents = new Map([\n [resolution[1]![1], Number(resolution[2])],\n [resolution[3]![1], Number(resolution[4])],\n ])\n const width = extents.get('X')\n const height = extents.get('Y')\n if (width === undefined || height === undefined) {\n return { error: 'Radiance resolution line must pair an X and a Y axis' }\n }\n if (width < 1 || height < 1) return { error: 'Radiance image is empty' }\n\n return { container: 'hdr', width, height }\n}\n\nfunction readNullTerminated(bytes: Uint8Array, start: number): { value: string; next: number } | undefined {\n // Attribute names and types are capped at 255 bytes even with LONG_NAMES_FLAG.\n const limit = Math.min(bytes.length, start + 256)\n for (let index = start; index < limit; index++) {\n if (bytes[index] === 0) {\n return { value: latin1(bytes.subarray(start, index)), next: index + 1 }\n }\n }\n return undefined\n}\n\nfunction latin1(bytes: Uint8Array): string {\n let value = ''\n for (const byte of bytes) value += String.fromCharCode(byte)\n return value\n}\n","{\n \"name\": \"@joycostudio/chopper\",\n \"version\": \"0.5.3\",\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 \"default\": \"./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 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"]}
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,50 +1,123 @@
|
|
|
1
|
+
/** Maximum image dimensions in pixels: `[width, height]`. Both values must be positive integers. */
|
|
1
2
|
type TextureSize = readonly [width: number, height: number];
|
|
2
3
|
interface SizedEncoding {
|
|
3
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Maximum output dimensions in pixels. Aspect ratio is preserved, and an
|
|
6
|
+
* image smaller than both limits is not enlarged. Omit this property to keep
|
|
7
|
+
* the source dimensions.
|
|
8
|
+
*/
|
|
4
9
|
maxSize?: TextureSize;
|
|
5
10
|
}
|
|
6
11
|
interface WebpEncoding extends SizedEncoding {
|
|
12
|
+
/** Encode the image as WebP. */
|
|
7
13
|
codec: 'webp';
|
|
14
|
+
/** Lossy quality from 1 (smallest, lowest fidelity) to 100. @defaultValue `75` */
|
|
8
15
|
quality?: number;
|
|
16
|
+
/** Encoder effort from 0 (fastest) to 100 (slowest). @defaultValue `50` */
|
|
9
17
|
effort?: number;
|
|
18
|
+
/** Use lossless WebP instead of lossy encoding. Lossy `quality` is then ignored. @defaultValue `false` */
|
|
10
19
|
lossless?: boolean;
|
|
11
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Near-lossless preprocessing quality for lossless encoding, from 0
|
|
22
|
+
* (strongest pixel changes and smallest output) to 100 (no preprocessing).
|
|
23
|
+
*
|
|
24
|
+
* @defaultValue `100`
|
|
25
|
+
*/
|
|
12
26
|
nearLossless?: number;
|
|
13
27
|
}
|
|
14
28
|
interface AvifEncoding extends SizedEncoding {
|
|
29
|
+
/** Encode the image as AVIF. */
|
|
15
30
|
codec: 'avif';
|
|
31
|
+
/** Lossy quality from 1 (smallest, lowest fidelity) to 100. @defaultValue `50` */
|
|
16
32
|
quality?: number;
|
|
33
|
+
/** Encoder effort from 0 (fastest) to 100 (slowest). @defaultValue `40` */
|
|
17
34
|
effort?: number;
|
|
35
|
+
/** Use lossless AVIF instead of lossy encoding, overriding `quality` and chroma subsampling. @defaultValue `false` */
|
|
18
36
|
lossless?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Chroma resolution: `4:2:0` reduces color detail for smaller files, while
|
|
39
|
+
* `4:4:4` preserves full color resolution. Lossless encoding always uses
|
|
40
|
+
* full color resolution.
|
|
41
|
+
*
|
|
42
|
+
* @defaultValue `'4:2:0'`
|
|
43
|
+
*/
|
|
19
44
|
chromaSubsampling?: '4:2:0' | '4:4:4';
|
|
20
45
|
}
|
|
21
46
|
interface JpegEncoding extends SizedEncoding {
|
|
47
|
+
/** Encode the image as JPEG. Alpha is not preserved. */
|
|
22
48
|
codec: 'jpeg';
|
|
49
|
+
/** Lossy quality from 1 (smallest, lowest fidelity) to 100. @defaultValue `75` */
|
|
23
50
|
quality?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Chroma resolution: `4:2:0` reduces color detail for smaller files, while
|
|
53
|
+
* `4:4:4` preserves full color resolution.
|
|
54
|
+
*
|
|
55
|
+
* @defaultValue `'4:2:0'`
|
|
56
|
+
*/
|
|
24
57
|
chromaSubsampling?: '4:2:0' | '4:4:4';
|
|
25
58
|
}
|
|
26
59
|
interface PngEncoding extends SizedEncoding {
|
|
60
|
+
/** Encode the image as lossless PNG. */
|
|
27
61
|
codec: 'png';
|
|
28
62
|
}
|
|
29
63
|
interface UastcEncoding extends SizedEncoding {
|
|
64
|
+
/** Encode the image in a GPU-ready KTX2 container. */
|
|
30
65
|
codec: 'ktx2';
|
|
66
|
+
/** Use high-quality UASTC block compression for LDR pixels. */
|
|
31
67
|
mode: 'uastc';
|
|
68
|
+
/**
|
|
69
|
+
* How the texture is sampled: `srgb` for color data such as albedo and
|
|
70
|
+
* emissive maps, or `linear` for data and normal maps.
|
|
71
|
+
*
|
|
72
|
+
* @defaultValue `'srgb'`
|
|
73
|
+
*/
|
|
32
74
|
colorSpace?: 'srgb' | 'linear';
|
|
75
|
+
/** Tune the encoder for tangent-space normal-map data. @defaultValue `false` */
|
|
33
76
|
normalMap?: boolean;
|
|
77
|
+
/** Encoder effort from 0 (fastest) to 4 (slowest, highest quality). @defaultValue `2` */
|
|
34
78
|
level?: 0 | 1 | 2 | 3 | 4;
|
|
79
|
+
/** Generate a complete mip chain for minified rendering. @defaultValue `true` */
|
|
35
80
|
mipmaps?: boolean;
|
|
81
|
+
/** Apply Zstandard supercompression to reduce download size. @defaultValue `true` */
|
|
36
82
|
zstd?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Enable rate-distortion optimization. This can substantially reduce files
|
|
85
|
+
* at the cost of image fidelity; omit it to disable RDO.
|
|
86
|
+
*/
|
|
37
87
|
rdo?: {
|
|
88
|
+
/**
|
|
89
|
+
* Compression-to-quality tradeoff from 0.001 to 10. Larger values usually
|
|
90
|
+
* produce smaller files with more distortion.
|
|
91
|
+
*
|
|
92
|
+
* @defaultValue `1`
|
|
93
|
+
*/
|
|
38
94
|
lambda?: number;
|
|
39
95
|
};
|
|
40
96
|
}
|
|
41
97
|
interface Etc1sEncoding extends SizedEncoding {
|
|
98
|
+
/** Encode the image in a GPU-ready KTX2 container. */
|
|
42
99
|
codec: 'ktx2';
|
|
100
|
+
/** Use ETC1S compression for the smallest download size at lower fidelity than UASTC. */
|
|
43
101
|
mode: 'etc1s';
|
|
102
|
+
/**
|
|
103
|
+
* How the texture is sampled: `srgb` for color data such as albedo and
|
|
104
|
+
* emissive maps, or `linear` for data and normal maps.
|
|
105
|
+
*
|
|
106
|
+
* @defaultValue `'srgb'`
|
|
107
|
+
*/
|
|
44
108
|
colorSpace?: 'srgb' | 'linear';
|
|
109
|
+
/** Tune the encoder for tangent-space normal-map data. @defaultValue `false` */
|
|
45
110
|
normalMap?: boolean;
|
|
111
|
+
/** Quality from 1 (smallest, lowest fidelity) to 255. @defaultValue `128` */
|
|
46
112
|
quality?: number;
|
|
113
|
+
/**
|
|
114
|
+
* Encoder effort from 0 (fastest) to 6 (slowest). Higher values search
|
|
115
|
+
* harder for a smaller file at the requested quality.
|
|
116
|
+
*
|
|
117
|
+
* @defaultValue `1`
|
|
118
|
+
*/
|
|
47
119
|
compression?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
120
|
+
/** Generate a complete mip chain for minified rendering. @defaultValue `true` */
|
|
48
121
|
mipmaps?: boolean;
|
|
49
122
|
}
|
|
50
123
|
/**
|
|
@@ -57,73 +130,133 @@ interface Etc1sEncoding extends SizedEncoding {
|
|
|
57
130
|
* be authored at their target resolution.
|
|
58
131
|
*/
|
|
59
132
|
interface UastcHdrEncoding {
|
|
133
|
+
/** Encode the image in a GPU-ready KTX2 container. */
|
|
60
134
|
codec: 'ktx2';
|
|
135
|
+
/**
|
|
136
|
+
* Use UASTC HDR for half-float EXR or Radiance HDR input. This mode does not
|
|
137
|
+
* support resizing or alpha and is only available to standalone image recipes.
|
|
138
|
+
*/
|
|
61
139
|
mode: 'uastc-hdr';
|
|
62
|
-
/**
|
|
140
|
+
/**
|
|
141
|
+
* Encoder effort from 0 (fastest) to 4 (slowest). Higher levels rarely help
|
|
142
|
+
* low-frequency content such as diffuse lightmaps.
|
|
143
|
+
*
|
|
144
|
+
* @defaultValue `1`
|
|
145
|
+
*/
|
|
63
146
|
level?: 0 | 1 | 2 | 3 | 4;
|
|
147
|
+
/** Generate a complete mip chain for minified rendering. @defaultValue `true` */
|
|
64
148
|
mipmaps?: boolean;
|
|
149
|
+
/** Apply Zstandard supercompression to reduce download size. @defaultValue `true` */
|
|
65
150
|
zstd?: boolean;
|
|
66
151
|
}
|
|
67
152
|
type RasterEncoding = WebpEncoding | AvifEncoding | JpegEncoding | PngEncoding;
|
|
68
153
|
type ImageEncoding = RasterEncoding | UastcEncoding | Etc1sEncoding | UastcHdrEncoding;
|
|
69
154
|
type GlbProperty = 'accessor' | 'animation' | 'buffer' | 'camera' | 'material' | 'mesh' | 'node' | 'primitive' | 'primitiveTarget' | 'skin' | 'texture';
|
|
70
155
|
type GlbMethodRecipe = {
|
|
156
|
+
/** Merge equivalent accessors, materials, meshes, skins, or textures. */
|
|
71
157
|
method: 'dedup';
|
|
158
|
+
/** Keep otherwise-identical properties separate when their names differ. @defaultValue `false` */
|
|
72
159
|
keepUniqueNames?: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Property kinds to merge.
|
|
162
|
+
*
|
|
163
|
+
* @defaultValue `['accessor', 'material', 'mesh', 'skin', 'texture']`
|
|
164
|
+
*/
|
|
73
165
|
propertyTypes?: readonly Extract<GlbProperty, 'accessor' | 'material' | 'mesh' | 'skin' | 'texture'>[];
|
|
74
166
|
} | {
|
|
167
|
+
/** Remove unused GLB properties and optionally simplify redundant data. */
|
|
75
168
|
method: 'prune';
|
|
169
|
+
/** Keep unused vertex attributes, such as UVs without an assigned texture. @defaultValue `false` */
|
|
76
170
|
keepAttributes?: boolean;
|
|
171
|
+
/** Prevent a property with custom `extras` data from being removed. @defaultValue `false` */
|
|
77
172
|
keepExtras?: boolean;
|
|
173
|
+
/** Keep empty leaf nodes that would otherwise be removed. @defaultValue `false` */
|
|
78
174
|
keepLeaves?: boolean;
|
|
175
|
+
/** Keep single-color textures instead of replacing them with material factors. @defaultValue `false` */
|
|
79
176
|
keepSolidTextures?: boolean;
|
|
177
|
+
/** Property kinds eligible for pruning. By default, every supported kind is eligible. */
|
|
80
178
|
propertyTypes?: readonly GlbProperty[];
|
|
81
179
|
} | {
|
|
180
|
+
/** Remove redundant animation keyframes while keeping motion within a tolerance. */
|
|
82
181
|
method: 'resample';
|
|
182
|
+
/** Maximum permitted animation-value error. Must be greater than zero. @defaultValue `0.0001` */
|
|
83
183
|
tolerance?: number;
|
|
184
|
+
/**
|
|
185
|
+
* Deduplicate and prune temporary or unused resources after resampling.
|
|
186
|
+
* Disable this when those resources must be preserved for a later step.
|
|
187
|
+
*
|
|
188
|
+
* @defaultValue `true`
|
|
189
|
+
*/
|
|
84
190
|
cleanup?: boolean;
|
|
85
191
|
};
|
|
86
192
|
type TextureSelector = {
|
|
193
|
+
/** Select textures by the material slots that reference them. */
|
|
87
194
|
by: 'slot';
|
|
195
|
+
/** glTF material texture-slot names, such as `baseColorTexture` or `normalTexture`. */
|
|
88
196
|
slots: readonly string[];
|
|
89
197
|
} | {
|
|
198
|
+
/** Select textures by their authored GLB names. */
|
|
90
199
|
by: 'name';
|
|
200
|
+
/** Exact, case-sensitive texture names. Names should be unique within the GLB. */
|
|
91
201
|
names: readonly string[];
|
|
92
202
|
} | {
|
|
203
|
+
/** Select textures by their zero-based order in the GLB. */
|
|
93
204
|
by: 'index';
|
|
205
|
+
/** Non-negative texture indices. Indices can change when a source GLB is re-exported. */
|
|
94
206
|
indices: readonly number[];
|
|
95
207
|
};
|
|
96
208
|
interface EmbeddedTextureRecipe {
|
|
209
|
+
/**
|
|
210
|
+
* Unique, non-empty name for this texture group in progress events and
|
|
211
|
+
* optimization reports. It does not rename textures in the GLB.
|
|
212
|
+
*/
|
|
97
213
|
label: string;
|
|
214
|
+
/** Textures to encode. A texture cannot be claimed by more than one selector. */
|
|
98
215
|
select: TextureSelector;
|
|
216
|
+
/** Output encoding for the selected textures. UASTC HDR is not supported inside GLBs. */
|
|
99
217
|
encode: ImageEncoding;
|
|
100
218
|
}
|
|
101
219
|
type GeometryEncoding = {
|
|
220
|
+
/** Compress geometry with `KHR_draco_mesh_compression` for broad decoder support. */
|
|
102
221
|
codec: 'draco';
|
|
103
222
|
} | {
|
|
223
|
+
/** Compress geometry with `EXT_meshopt_compression` for fast runtime decoding. */
|
|
104
224
|
codec: 'meshopt';
|
|
105
225
|
};
|
|
106
226
|
interface GlbAssetRecipe {
|
|
227
|
+
/** Optimize a binary glTF (`.glb`) asset. */
|
|
107
228
|
kind: 'glb';
|
|
229
|
+
/** Structural transforms to run in array order before texture and geometry encoding. @defaultValue `[]` */
|
|
108
230
|
methods?: readonly GlbMethodRecipe[];
|
|
231
|
+
/** Embedded texture groups to encode. Unselected textures keep their source encoding. @defaultValue `[]` */
|
|
109
232
|
textures?: readonly EmbeddedTextureRecipe[];
|
|
233
|
+
/** Geometry codec to apply, or `false` to leave geometry uncompressed. @defaultValue `false` */
|
|
110
234
|
geometry?: GeometryEncoding | false;
|
|
111
235
|
}
|
|
112
236
|
interface ImageAssetRecipe {
|
|
237
|
+
/** Optimize a standalone raster or HDR image. */
|
|
113
238
|
kind: 'image';
|
|
239
|
+
/** Output codec and its quality, size, and performance tradeoffs. */
|
|
114
240
|
encode: ImageEncoding;
|
|
115
241
|
}
|
|
116
242
|
type AssetRecipe = GlbAssetRecipe | ImageAssetRecipe;
|
|
117
243
|
type NormalizedImageEncoding = (Required<Omit<WebpEncoding, 'maxSize'>> & Pick<WebpEncoding, 'maxSize'>) | (Required<Omit<AvifEncoding, 'maxSize'>> & Pick<AvifEncoding, 'maxSize'>) | (Required<Omit<JpegEncoding, 'maxSize'>> & Pick<JpegEncoding, 'maxSize'>) | PngEncoding | (Required<Omit<UastcEncoding, 'maxSize' | 'rdo'>> & Pick<UastcEncoding, 'maxSize' | 'rdo'>) | (Required<Omit<Etc1sEncoding, 'maxSize'>> & Pick<Etc1sEncoding, 'maxSize'>) | Required<UastcHdrEncoding>;
|
|
118
244
|
type NormalizedAssetRecipe = {
|
|
245
|
+
/** Identifies the normalized recipe as a standalone image recipe. */
|
|
119
246
|
kind: 'image';
|
|
247
|
+
/** Image encoding with every codec default resolved. */
|
|
120
248
|
encode: NormalizedImageEncoding;
|
|
121
249
|
} | {
|
|
250
|
+
/** Identifies the normalized recipe as a binary glTF recipe. */
|
|
122
251
|
kind: 'glb';
|
|
252
|
+
/** Structural transforms to run, with an omitted value resolved to an empty array. */
|
|
123
253
|
methods: readonly GlbMethodRecipe[];
|
|
254
|
+
/** Embedded texture groups with every codec default resolved. */
|
|
124
255
|
textures: readonly (Omit<EmbeddedTextureRecipe, 'encode'> & {
|
|
256
|
+
/** Output encoding with every codec default resolved. */
|
|
125
257
|
encode: NormalizedImageEncoding;
|
|
126
258
|
})[];
|
|
259
|
+
/** Resolved geometry codec, or `false` when geometry compression is disabled. */
|
|
127
260
|
geometry: GeometryEncoding | false;
|
|
128
261
|
};
|
|
129
262
|
|
|
@@ -293,12 +426,33 @@ interface OptimizeFileOptions extends OptimizationOptions {
|
|
|
293
426
|
declare function optimizeFile({ input, output, recipe, ...options }: OptimizeFileOptions): Promise<ChopperResult<OptimizationOutput>>;
|
|
294
427
|
|
|
295
428
|
interface ChopperRule {
|
|
429
|
+
/**
|
|
430
|
+
* Glob patterns for source assets, evaluated relative to the project directory.
|
|
431
|
+
* A rule runs once for every file matched by at least one pattern.
|
|
432
|
+
*/
|
|
296
433
|
include: readonly string[];
|
|
434
|
+
/**
|
|
435
|
+
* Glob patterns removed from `include` matches, evaluated relative to the
|
|
436
|
+
* project directory. Omit this property to exclude nothing.
|
|
437
|
+
*/
|
|
297
438
|
exclude?: readonly string[];
|
|
439
|
+
/** Optimization recipe applied to every asset matched by this rule. */
|
|
298
440
|
recipe: AssetRecipe;
|
|
441
|
+
/**
|
|
442
|
+
* Output path template relative to {@link ChopperConfig.output}. Supports
|
|
443
|
+
* `{dir}` (source directory), `{name}` (source basename), and `{ext}`
|
|
444
|
+
* (recipe output extension).
|
|
445
|
+
*
|
|
446
|
+
* @defaultValue `'{dir}/{name}.{ext}'`
|
|
447
|
+
*/
|
|
299
448
|
path?: string;
|
|
300
449
|
}
|
|
301
450
|
interface ChopperConfig {
|
|
451
|
+
/**
|
|
452
|
+
* Directory where optimized assets are written. Relative paths are resolved
|
|
453
|
+
* from the project directory, and the resolved directory must remain inside
|
|
454
|
+
* the project.
|
|
455
|
+
*/
|
|
302
456
|
output: string;
|
|
303
457
|
/**
|
|
304
458
|
* Every rule matches independently, so one file can be claimed by several of
|
|
@@ -308,6 +462,13 @@ interface ChopperConfig {
|
|
|
308
462
|
* one input can still fan out to several encodings.
|
|
309
463
|
*/
|
|
310
464
|
rules: readonly ChopperRule[];
|
|
465
|
+
/**
|
|
466
|
+
* Maximum number of assets optimized at the same time. Must be a positive
|
|
467
|
+
* integer; lower values reduce peak CPU and memory use, while higher values
|
|
468
|
+
* may finish a batch sooner.
|
|
469
|
+
*
|
|
470
|
+
* @defaultValue `2`
|
|
471
|
+
*/
|
|
311
472
|
concurrency?: number;
|
|
312
473
|
}
|
|
313
474
|
|
package/dist/node/index.js
CHANGED
|
@@ -430,7 +430,7 @@ function latin1(bytes) {
|
|
|
430
430
|
|
|
431
431
|
// package.json
|
|
432
432
|
var package_default = {
|
|
433
|
-
version: "0.5.
|
|
433
|
+
version: "0.5.3"};
|
|
434
434
|
|
|
435
435
|
// src/codecs/manifest.ts
|
|
436
436
|
var CODEC_MANIFEST_HASH = "2046d60deb0f9f224743f4404f3c6e8ba5399f81b2811fa50466e93fce3bd322";
|