@joycostudio/chopper 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/codecs/manifest.json +1 -1
- package/dist/browser/{chunk-MIIFUV4R.js → chunk-CC6UVN2A.js} +3 -3
- package/dist/browser/{chunk-MIIFUV4R.js.map → chunk-CC6UVN2A.js.map} +1 -1
- package/dist/browser/{in-process-W4MAY3WM.js → in-process-ELNZ7M7W.js} +3 -3
- package/dist/browser/{in-process-W4MAY3WM.js.map → in-process-ELNZ7M7W.js.map} +1 -1
- 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 +11 -11
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/node/index.d.ts +2 -2
- package/dist/node/index.js +11 -11
- package/dist/node/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readFile, readdir, mkdir, copyFile, mkdtemp, writeFile, rename, rm } from 'fs/promises';
|
|
3
|
-
import { extname, parse, join, dirname, resolve, relative, basename } from 'path';
|
|
3
|
+
import { extname, parse, join, dirname, resolve, relative, isAbsolute, sep, basename } from 'path';
|
|
4
4
|
import { PropertyType, NodeIO } from '@gltf-transform/core';
|
|
5
5
|
import { ALL_EXTENSIONS, EXTTextureWebP, EXTTextureAVIF, KHRTextureBasisu } from '@gltf-transform/extensions';
|
|
6
6
|
import draco3d from 'draco3dgltf';
|
|
@@ -103,7 +103,7 @@ function outputMimeType(encoding) {
|
|
|
103
103
|
|
|
104
104
|
// package.json
|
|
105
105
|
var package_default = {
|
|
106
|
-
version: "0.
|
|
106
|
+
version: "0.3.0"};
|
|
107
107
|
|
|
108
108
|
// src/codecs/manifest.ts
|
|
109
109
|
var CODEC_MANIFEST_HASH = "2046d60deb0f9f224743f4404f3c6e8ba5399f81b2811fa50466e93fce3bd322";
|
|
@@ -1148,7 +1148,7 @@ async function runConfig(options = {}) {
|
|
|
1148
1148
|
const mode = options.mode ?? "write";
|
|
1149
1149
|
const loaded = options.config ? success(options.config) : await loadConfig(resolve(cwd, options.configPath ?? "chopper.config.ts"));
|
|
1150
1150
|
if (!loaded.ok) return loaded;
|
|
1151
|
-
const planned = await planAssets(loaded.data, cwd, options.
|
|
1151
|
+
const planned = await planAssets(loaded.data, cwd, options.outputDirectory);
|
|
1152
1152
|
if (!planned.ok) return planned;
|
|
1153
1153
|
const chopper2 = options.chopper ?? createNodeChopper();
|
|
1154
1154
|
const files = await mapConcurrent(
|
|
@@ -1158,9 +1158,9 @@ async function runConfig(options = {}) {
|
|
|
1158
1158
|
);
|
|
1159
1159
|
return success({ mode, files, totals: summarize(files) });
|
|
1160
1160
|
}
|
|
1161
|
-
async function planAssets(config, cwd,
|
|
1162
|
-
const changed = changedPaths ? new Set(changedPaths.map((path) => normalizePath(path))) : void 0;
|
|
1161
|
+
async function planAssets(config, cwd, outputDirectory) {
|
|
1163
1162
|
const planned = [];
|
|
1163
|
+
const outputRoot = outputDirectory ? resolve(cwd, outputDirectory) : void 0;
|
|
1164
1164
|
for (const rule of config.rules) {
|
|
1165
1165
|
const valid = validateRecipe(rule.recipe);
|
|
1166
1166
|
if (!valid.ok) return valid;
|
|
@@ -1170,11 +1170,14 @@ async function planAssets(config, cwd, changedPaths) {
|
|
|
1170
1170
|
onlyFiles: true
|
|
1171
1171
|
});
|
|
1172
1172
|
for (const match of matches.sort()) {
|
|
1173
|
-
const
|
|
1174
|
-
|
|
1173
|
+
const configuredOutput = resolveOutput(rule, match, cwd);
|
|
1174
|
+
const relativeOutput = relative(cwd, configuredOutput);
|
|
1175
|
+
if (outputRoot && (isAbsolute(relativeOutput) || relativeOutput === ".." || relativeOutput.startsWith(`..${sep}`))) {
|
|
1176
|
+
return failure("invalid_recipe", `Cannot stage output outside the project: ${configuredOutput}`);
|
|
1177
|
+
}
|
|
1175
1178
|
planned.push({
|
|
1176
1179
|
input: resolve(cwd, match),
|
|
1177
|
-
output:
|
|
1180
|
+
output: outputRoot ? resolve(outputRoot, relativeOutput) : configuredOutput,
|
|
1178
1181
|
rule
|
|
1179
1182
|
});
|
|
1180
1183
|
}
|
|
@@ -1262,9 +1265,6 @@ function bytesEqual(left, right) {
|
|
|
1262
1265
|
if (left.byteLength !== right.byteLength) return false;
|
|
1263
1266
|
return left.every((value, index) => value === right[index]);
|
|
1264
1267
|
}
|
|
1265
|
-
function normalizePath(path) {
|
|
1266
|
-
return path.replaceAll("\\", "/");
|
|
1267
|
-
}
|
|
1268
1268
|
async function mapConcurrent(values, concurrency, operation) {
|
|
1269
1269
|
const results = new Array(values.length);
|
|
1270
1270
|
let next = 0;
|