@joycostudio/chopper 0.5.2 → 0.5.4
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-G4APMK7P.js} +3 -3
- package/dist/browser/{chunk-C47JCVDL.js.map → chunk-G4APMK7P.js.map} +1 -1
- package/dist/browser/{in-process-Y2RGECEF.js → in-process-5DUPLJNY.js} +3 -3
- package/dist/browser/{in-process-Y2RGECEF.js.map → in-process-5DUPLJNY.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 +161 -5
- package/dist/config/index.js.map +1 -1
- package/dist/index.d.ts +139 -5
- 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/browser/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
|
|
package/dist/browser/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { failure, CODEC_MANIFEST_HASH, CODEC_MANIFEST, ENGINE_ID } from './chunk-
|
|
1
|
+
import { failure, CODEC_MANIFEST_HASH, CODEC_MANIFEST, ENGINE_ID } from './chunk-G4APMK7P.js';
|
|
2
2
|
import './chunk-5WRI5ZAA.js';
|
|
3
3
|
|
|
4
4
|
// src/browser/chopper.ts
|
|
@@ -6,7 +6,7 @@ async function createBrowserChopper(options = {}) {
|
|
|
6
6
|
if ((options.execution ?? "worker") === "worker") {
|
|
7
7
|
return createWorkerChopper(options);
|
|
8
8
|
}
|
|
9
|
-
const { createInProcessChopper } = await import('./in-process-
|
|
9
|
+
const { createInProcessChopper } = await import('./in-process-5DUPLJNY.js');
|
|
10
10
|
return createInProcessChopper(options);
|
|
11
11
|
}
|
|
12
12
|
function createWorkerChopper(options) {
|
package/dist/browser/worker.js
CHANGED