@hubol/smooch 1.0.0-beta.19 → 1.0.0-beta.20
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/index.js +24 -26
- package/package.json +1 -1
- package/template-api.d.ts +6 -4
package/index.js
CHANGED
|
@@ -29059,7 +29059,7 @@ TestStream._logger = new logger_1.Logger(TestStream, "green");
|
|
|
29059
29059
|
|
|
29060
29060
|
/***/ }),
|
|
29061
29061
|
|
|
29062
|
-
/***/
|
|
29062
|
+
/***/ 4558:
|
|
29063
29063
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
29064
29064
|
|
|
29065
29065
|
"use strict";
|
|
@@ -29074,15 +29074,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
29074
29074
|
});
|
|
29075
29075
|
};
|
|
29076
29076
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
29077
|
-
exports.
|
|
29077
|
+
exports.readImage = void 0;
|
|
29078
29078
|
const native_module_1 = __webpack_require__(4828);
|
|
29079
|
-
function
|
|
29079
|
+
function readImage(filePath) {
|
|
29080
29080
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29081
|
-
const
|
|
29082
|
-
|
|
29081
|
+
const image = native_module_1.Native.Sharp(filePath);
|
|
29082
|
+
const [buffer, { width, height },] = yield Promise.all([
|
|
29083
|
+
image.raw().ensureAlpha().toBuffer(),
|
|
29084
|
+
image.metadata(),
|
|
29085
|
+
]);
|
|
29086
|
+
return { buffer, width, height };
|
|
29083
29087
|
});
|
|
29084
29088
|
}
|
|
29085
|
-
exports.
|
|
29089
|
+
exports.readImage = readImage;
|
|
29086
29090
|
|
|
29087
29091
|
|
|
29088
29092
|
/***/ }),
|
|
@@ -30702,11 +30706,11 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
30702
30706
|
exports.packTextures = void 0;
|
|
30703
30707
|
const bin_pack_1 = __webpack_require__(3934);
|
|
30704
30708
|
const logger_1 = __webpack_require__(6266);
|
|
30705
|
-
const
|
|
30709
|
+
const read_image_1 = __webpack_require__(4558);
|
|
30706
30710
|
const native_module_1 = __webpack_require__(4828);
|
|
30707
30711
|
const logger = new logger_1.Logger("RawPacker", "magenta");
|
|
30708
30712
|
const filePathToBlocks = (filePath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
30709
|
-
const result = yield (0,
|
|
30713
|
+
const result = yield (0, read_image_1.readImage)(filePath);
|
|
30710
30714
|
if (!result) {
|
|
30711
30715
|
logger.error(`Failed to read dimensions of image file: ${filePath}`);
|
|
30712
30716
|
return [];
|
|
@@ -30715,23 +30719,17 @@ const filePathToBlocks = (filePath) => __awaiter(void 0, void 0, void 0, functio
|
|
|
30715
30719
|
logger.error(`Read malformed dimensions (${result.width}, ${result.height}) for image file: ${filePath}`);
|
|
30716
30720
|
return [];
|
|
30717
30721
|
}
|
|
30718
|
-
const {
|
|
30719
|
-
return [{
|
|
30722
|
+
const { buffer, height, width } = result;
|
|
30723
|
+
return [{ buffer, filePath, height, width }];
|
|
30720
30724
|
});
|
|
30721
|
-
const
|
|
30722
|
-
const
|
|
30723
|
-
|
|
30724
|
-
height
|
|
30725
|
-
|
|
30726
|
-
|
|
30727
|
-
}
|
|
30728
|
-
|
|
30729
|
-
left: block.x,
|
|
30730
|
-
top: block.y,
|
|
30731
|
-
input: block.filePath,
|
|
30732
|
-
}));
|
|
30733
|
-
return yield native_module_1.Native.Sharp({ create })
|
|
30734
|
-
.composite(overlayOptions)
|
|
30725
|
+
const compositeBinImage = (width, height, blocks) => __awaiter(void 0, void 0, void 0, function* () {
|
|
30726
|
+
const binBuffer = new Uint8Array(4 * width * height);
|
|
30727
|
+
for (const block of blocks) {
|
|
30728
|
+
for (let y = 0; y < block.height; y++) {
|
|
30729
|
+
block.buffer.copy(binBuffer, (block.x + ((block.y + y) * width)) * 4, y * block.width * 4, (y + 1) * block.width * 4);
|
|
30730
|
+
}
|
|
30731
|
+
}
|
|
30732
|
+
return yield native_module_1.Native.Sharp(binBuffer, { raw: { channels: 4, width, height, premultiplied: true } })
|
|
30735
30733
|
.png()
|
|
30736
30734
|
.toBuffer();
|
|
30737
30735
|
});
|
|
@@ -30739,7 +30737,7 @@ const packTextures = (filePaths, options) => __awaiter(void 0, void 0, void 0, f
|
|
|
30739
30737
|
const { pack: packOptions } = options;
|
|
30740
30738
|
const blocks = (yield Promise.all(filePaths.map(filePathToBlocks))).flat();
|
|
30741
30739
|
const bins = (0, bin_pack_1.binPack)(blocks, packOptions);
|
|
30742
|
-
yield Promise.all(bins.map((bin) => __awaiter(void 0, void 0, void 0, function* () { return bin.imageBuffer = yield
|
|
30740
|
+
yield Promise.all(bins.map((bin) => __awaiter(void 0, void 0, void 0, function* () { return bin.imageBuffer = yield compositeBinImage(bin.width, bin.height, bin.rects); })));
|
|
30743
30741
|
logger.log(`Created ${bins.length} image buffer(s) for ${filePaths.length} texture(s)`);
|
|
30744
30742
|
return bins;
|
|
30745
30743
|
});
|
|
@@ -52963,7 +52961,7 @@ class MaxRectsPacker {
|
|
|
52963
52961
|
/***/ ((module) => {
|
|
52964
52962
|
|
|
52965
52963
|
"use strict";
|
|
52966
|
-
module.exports = JSON.parse('{"name":"@hubol/smooch","version":"1.0.0-beta.
|
|
52964
|
+
module.exports = JSON.parse('{"name":"@hubol/smooch","version":"1.0.0-beta.20","description":"Generate texture atlases, browser-compatible audio, and source code from directories","scripts":{"build":"npm run build:json-schema && npm run build:template-api-dts && npm run build:bundle && npm run build:distributable-package-json && npm run build:npm-readme && npm run build:npm-pack","build:json-schema":"ts-node ./tools/generate-config-schema.ts","build:template-api-dts":"npx tsup lib/template-api.ts --dts-only --dts-resolve","build:bundle":"webpack","build:distributable-package-json":"ts-node ./tools/generate-distributable-package-json.ts","build:npm-readme":"ts-node ./tools/generate-npm-readme.ts","build:npm-pack":"ts-node ./tools/pack.ts ../smooch.tgz","dev:build-and-test":"npm run build && npm run test","dev:start":"node --nolazy -r ts-node/register ./lib/main/dev.ts","dev:update-readme":"ts-node ./lib/main/dev.ts ../../tools/update-readme-md.ts","test":"ts-node --transpileOnly test/test.ts"},"bin":{"smooch":"index.js"},"author":"Hubol","license":"ISC","repository":{"type":"git","url":"https://github.com/hubol/smooch.git"},"devDependencies":{"@types/archiver":"^5.3.2","@types/fluent-ffmpeg":"^2.1.21","@types/sharp":"^0.31.1","archiver":"^6.0.0","chalk":"^4.1.2","change-case":"^4.1.2","dprint":"^0.47.6","fluent-ffmpeg":"^2.1.2","glob":"^10.3.3","maxrects-packer":"^2.7.3","minimatch":"^9.0.3","superstruct":"^0.15.5","tree-kill":"^1.2.2","ts-loader":"^9.4.4","ts-node":"^10.9.1","tsup":"^7.2.0","typescript":"^5.0.4","typescript-json-schema":"^0.56.0","webpack":"^5.88.2","webpack-cli":"^5.1.4","webpack-shebang-plugin":"^1.1.8"}}');
|
|
52967
52965
|
|
|
52968
52966
|
/***/ })
|
|
52969
52967
|
|
package/package.json
CHANGED
package/template-api.d.ts
CHANGED
|
@@ -466,9 +466,10 @@ type GlobRoot = string & {
|
|
|
466
466
|
};
|
|
467
467
|
|
|
468
468
|
declare function createAtlases(imageFilePaths: Path.File.t[], options: Infer<typeof PackerOptions>): Promise<(Bin<{
|
|
469
|
-
|
|
470
|
-
height: number;
|
|
469
|
+
buffer: Buffer;
|
|
471
470
|
filePath: Path.File.t;
|
|
471
|
+
height: number;
|
|
472
|
+
width: number;
|
|
472
473
|
} & {
|
|
473
474
|
x: number;
|
|
474
475
|
y: number;
|
|
@@ -480,9 +481,10 @@ declare function createAtlases(imageFilePaths: Path.File.t[], options: Infer<typ
|
|
|
480
481
|
type Atlases = AsyncReturnType<typeof createAtlases>;
|
|
481
482
|
declare function createTemplateContext(atlases: Atlases, globRoot: GlobRoot): {
|
|
482
483
|
atlases: (Bin<{
|
|
483
|
-
|
|
484
|
-
height: number;
|
|
484
|
+
buffer: Buffer;
|
|
485
485
|
filePath: Path.File.t;
|
|
486
|
+
height: number;
|
|
487
|
+
width: number;
|
|
486
488
|
} & {
|
|
487
489
|
x: number;
|
|
488
490
|
y: number;
|