@joycostudio/chopper 0.7.1 → 0.8.1

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.
@@ -150,7 +150,28 @@ interface UastcHdrEncoding {
150
150
  zstd?: boolean;
151
151
  }
152
152
  type RasterEncoding = WebpEncoding | AvifEncoding | JpegEncoding | PngEncoding;
153
- type ImageEncoding = RasterEncoding | UastcEncoding | Etc1sEncoding | UastcHdrEncoding;
153
+ /** Standalone, lossless RGBA8 texels. Color-space metadata never transforms samples. */
154
+ type RawKtx2Encoding = {
155
+ /** Store decoded RGBA8 pixels in KTX2. */
156
+ codec: 'ktx2';
157
+ /** Preserve original dimensions and every decoded RGBA8 byte, including transparent RGB. */
158
+ mode: 'raw';
159
+ /** Label unchanged samples; alpha is always linear. @defaultValue `'linear'` */
160
+ colorSpace?: 'linear' | 'srgb';
161
+ /** Raw mode stores exactly one base level. @defaultValue `false` */
162
+ mipmaps?: false;
163
+ } & ({
164
+ /** Compress the texels for delivery; GPU storage remains RGBA8. @defaultValue `true` */
165
+ zstd?: true;
166
+ /** Offline compression effort, integer 1–19; never changes fidelity. @defaultValue `19` */
167
+ zstdLevel?: number;
168
+ } | {
169
+ /** Store texels without supercompression. */
170
+ zstd: false;
171
+ /** Effort is unavailable when Zstandard is disabled. */
172
+ zstdLevel?: never;
173
+ });
174
+ type ImageEncoding = RasterEncoding | UastcEncoding | Etc1sEncoding | UastcHdrEncoding | RawKtx2Encoding;
154
175
  type GlbProperty = 'accessor' | 'animation' | 'buffer' | 'camera' | 'material' | 'mesh' | 'node' | 'primitive' | 'primitiveTarget' | 'skin' | 'texture';
155
176
  type GlbMethodRecipe = {
156
177
  /** Merge equivalent accessors, materials, meshes, skins, or textures. */
@@ -213,8 +234,8 @@ interface EmbeddedTextureRecipe {
213
234
  label: string;
214
235
  /** Textures to encode. A texture cannot be claimed by more than one selector. */
215
236
  select: TextureSelector;
216
- /** Output encoding for the selected textures. UASTC HDR is not supported inside GLBs. */
217
- encode: ImageEncoding;
237
+ /** Output encoding for the selected textures. Raw RGBA8 and UASTC HDR are not supported inside GLBs. */
238
+ encode: Exclude<ImageEncoding, RawKtx2Encoding>;
218
239
  }
219
240
  type GeometryEncoding = {
220
241
  /** Compress geometry with `KHR_draco_mesh_compression` for broad decoder support. */
@@ -240,7 +261,13 @@ interface ImageAssetRecipe {
240
261
  encode: ImageEncoding;
241
262
  }
242
263
  type AssetRecipe = GlbAssetRecipe | ImageAssetRecipe;
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>;
264
+ 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> | (Required<Pick<RawKtx2Encoding, 'codec' | 'mode' | 'colorSpace' | 'mipmaps'>> & ({
265
+ zstd: true;
266
+ zstdLevel: number;
267
+ } | {
268
+ zstd: false;
269
+ zstdLevel?: never;
270
+ }));
244
271
  type NormalizedAssetRecipe = {
245
272
  /** Identifies the normalized recipe as a standalone image recipe. */
246
273
  kind: 'image';
@@ -254,7 +281,7 @@ type NormalizedAssetRecipe = {
254
281
  /** Embedded texture groups with every codec default resolved. */
255
282
  textures: readonly (Omit<EmbeddedTextureRecipe, 'encode'> & {
256
283
  /** Output encoding with every codec default resolved. */
257
- encode: NormalizedImageEncoding;
284
+ encode: Exclude<NormalizedImageEncoding, RawKtx2Encoding>;
258
285
  })[];
259
286
  /** Resolved geometry codec, or `false` when geometry compression is disabled. */
260
287
  geometry: GeometryEncoding | false;
@@ -438,32 +465,36 @@ interface ChopperRule {
438
465
  exclude?: readonly string[];
439
466
  /** Optimization recipe applied to every asset matched by this rule. */
440
467
  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
- */
448
- path?: string;
449
468
  }
450
469
  interface ChopperConfig {
451
470
  /**
452
- * Filesystem root used by Node and the CLI for generated bytes. Relative
453
- * paths are resolved from the project directory, and the resolved directory
454
- * must remain inside the project. This directory is not included in
455
- * {@link PlannedConfigAsset.output}.
471
+ * Physical filesystem root where Node and the CLI write generated bytes.
472
+ * Relative paths are resolved from the project directory, and the resolved
473
+ * directory must remain inside the project. This build directory is never
474
+ * included in the logical paths returned by {@link ConfigAssetPlanner}.
475
+ *
476
+ * For example, a planned output of `assets/compressed/wall.webp` is written
477
+ * to `.chopper/assets/compressed/wall.webp` when this property uses its
478
+ * default. Use {@link outputDirectory} to control the reserved sibling
479
+ * segment in the planned path; use this property only to control where Node
480
+ * and the CLI store the resulting bytes.
456
481
  *
457
482
  * @defaultValue `'.chopper'`
458
483
  */
459
- output?: string;
484
+ buildDirectory?: string;
460
485
  /**
461
- * Reserved sibling directory used for logical generated asset paths.
486
+ * Reserved sibling directory segment used in logical generated asset paths.
462
487
  *
463
488
  * Given `assets/wall.png` and `outputDirectory: 'compressed'`, a WebP
464
489
  * recipe resolves to `assets/compressed/wall.webp`. Inputs already inside
465
490
  * this directory are classified as generated outputs and are never
466
- * processed again.
491
+ * processed again. Rules choose which assets and recipes apply; this
492
+ * config-level property is the sole authority for where their logical
493
+ * outputs go. This logical segment is independent of
494
+ * {@link buildDirectory}, the physical filesystem root used by Node and the
495
+ * CLI.
496
+ *
497
+ * @defaultValue `'compressed'`
467
498
  */
468
499
  outputDirectory?: string;
469
500
  /**
@@ -502,7 +533,8 @@ interface BatchFileReport {
502
533
  }
503
534
  interface BatchReport {
504
535
  mode: BatchMode;
505
- output: string;
536
+ /** Physical filesystem root where this batch reads or writes generated bytes. */
537
+ buildDirectory: string;
506
538
  files: BatchFileReport[];
507
539
  totals: {
508
540
  matched: number;