@pixzle/node 0.0.19 → 0.0.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/dist/file.js ADDED
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createDir = createDir;
7
+ exports.writeFile = writeFile;
8
+ exports.readJsonFile = readJsonFile;
9
+ exports.readFileBuffer = readFileBuffer;
10
+ exports.fileNameWithoutExtension = fileNameWithoutExtension;
11
+ const node_fs_1 = require("node:fs");
12
+ const node_path_1 = __importDefault(require("node:path"));
13
+ /**
14
+ * Create a directory
15
+ * @param dir Directory path
16
+ * @param recursive Create parent directories if they don't exist
17
+ */
18
+ async function createDir(dir, recursive = false) {
19
+ await node_fs_1.promises.mkdir(dir, { recursive });
20
+ }
21
+ /**
22
+ * Write a file
23
+ * @param dir Directory path
24
+ * @param filename Filename
25
+ * @param data Data to write
26
+ * @returns Path to the file
27
+ */
28
+ async function writeFile(dir, filename, data) {
29
+ const filePath = node_path_1.default.join(dir, filename);
30
+ await node_fs_1.promises.writeFile(filePath, data);
31
+ return filePath;
32
+ }
33
+ /**
34
+ * Read a JSON file and return its content
35
+ * @param filePath Path to the JSON file
36
+ * @returns Content of the JSON file
37
+ */
38
+ async function readJsonFile(filePath) {
39
+ return JSON.parse(await node_fs_1.promises.readFile(filePath, "utf8"));
40
+ }
41
+ /**
42
+ * Read a file and return its content
43
+ * @param filePath Path to the file
44
+ * @returns Content of the file
45
+ */
46
+ async function readFileBuffer(filePath) {
47
+ return await node_fs_1.promises.readFile(filePath);
48
+ }
49
+ /**
50
+ * Get the filename without the extension
51
+ * @param filePath Path to the file
52
+ * @returns Filename without the extension
53
+ */
54
+ function fileNameWithoutExtension(filePath) {
55
+ return node_path_1.default.basename(filePath, node_path_1.default.extname(filePath));
56
+ }
57
+ //# sourceMappingURL=file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.js","sourceRoot":"","sources":["../src/file.ts"],"names":[],"mappings":";;;;;AAQA,8BAEC;AASD,8BAQC;AAOD,oCAEC;AAOD,wCAEC;AAOD,4DAEC;AAtDD,qCAAyC;AACzC,0DAA6B;AAE7B;;;;GAIG;AACI,KAAK,UAAU,SAAS,CAAC,GAAW,EAAE,SAAS,GAAG,KAAK;IAC5D,MAAM,kBAAE,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,SAAS,CAC7B,GAAW,EACX,QAAgB,EAChB,IAAqB;IAErB,MAAM,QAAQ,GAAG,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC1C,MAAM,kBAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACnC,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,YAAY,CAAI,QAAgB;IACpD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,kBAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AACzD,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,cAAc,CAAC,QAAgB;IACnD,OAAO,MAAM,kBAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACrC,CAAC;AAED;;;;GAIG;AACH,SAAgB,wBAAwB,CAAC,QAAgB;IACvD,OAAO,mBAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,mBAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;AACzD,CAAC"}
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImageFragmenter = void 0;
4
+ const core_1 = require("@pixzle/core");
5
+ const seeded_shuffle_1 = require("@tuki0918/seeded-shuffle");
6
+ const block_1 = require("./block");
7
+ const constants_1 = require("./constants");
8
+ const file_1 = require("./file");
9
+ const utils_1 = require("./utils");
10
+ class ImageFragmenter {
11
+ config;
12
+ constructor(config) {
13
+ this.config = this._initializeConfig(config);
14
+ }
15
+ _initializeConfig(config) {
16
+ return {
17
+ blockSize: config.blockSize ?? core_1.DEFAULT_FRAGMENTATION_CONFIG.BLOCK_SIZE,
18
+ prefix: config.prefix ?? core_1.DEFAULT_FRAGMENTATION_CONFIG.PREFIX,
19
+ seed: config.seed || seeded_shuffle_1.SeededRandom.generateSeed(),
20
+ preserveName: config.preserveName ?? core_1.DEFAULT_FRAGMENTATION_CONFIG.PRESERVE_NAME,
21
+ crossImageShuffle: config.crossImageShuffle ??
22
+ core_1.DEFAULT_FRAGMENTATION_CONFIG.CROSS_IMAGE_SHUFFLE,
23
+ };
24
+ }
25
+ async fragmentImages(paths) {
26
+ const { manifest, blocks, blockCountsForCrossImages, blockCountsPerImage } = await this._prepareData(paths);
27
+ const shuffled = this.config.crossImageShuffle
28
+ ? (0, seeded_shuffle_1.shuffle)(blocks, manifest.config.seed)
29
+ : (0, block_1.blocksPerImage)(blocks, blockCountsPerImage, manifest.config.seed, seeded_shuffle_1.shuffle);
30
+ const blockCounts = this.config.crossImageShuffle
31
+ ? blockCountsForCrossImages
32
+ : blockCountsPerImage;
33
+ const fragmentedImages = await this._createImages(shuffled, blockCounts, manifest);
34
+ return {
35
+ manifest,
36
+ fragmentedImages,
37
+ };
38
+ }
39
+ async _createImages(blocks, blockCounts, manifest) {
40
+ return await Promise.all(manifest.images.map(async (_, index) => {
41
+ const { start, end } = (0, core_1.calculateBlockRange)(blockCounts, index);
42
+ const imageBlocks = blocks.slice(start, end);
43
+ return await this._createImage(imageBlocks, manifest.config.blockSize);
44
+ }));
45
+ }
46
+ _createManifest(manifestId, imageInfos) {
47
+ return {
48
+ id: manifestId,
49
+ version: constants_1.VERSION,
50
+ timestamp: new Date().toISOString(),
51
+ config: this.config,
52
+ images: imageInfos,
53
+ };
54
+ }
55
+ async _prepareData(paths) {
56
+ const manifestId = (0, utils_1.generateManifestId)();
57
+ const { imageInfos, blocks } = await this._processImages(paths);
58
+ (0, core_1.validateFileNames)(imageInfos, this.config.preserveName);
59
+ const manifest = this._createManifest(manifestId, imageInfos);
60
+ const blockCountsForCrossImages = (0, core_1.calculateBlockCountsForCrossImages)(blocks.length, paths.length);
61
+ // Calculate actual block counts per image for per-image shuffle
62
+ const blockCountsPerImage = (0, core_1.calculateBlockCountsPerImage)(imageInfos);
63
+ return { manifest, blocks, blockCountsForCrossImages, blockCountsPerImage };
64
+ }
65
+ async _processImages(paths) {
66
+ const results = await Promise.all(paths.map((path) => this._processImage(path)));
67
+ const imageInfos = results.map((r) => r.imageInfo);
68
+ const blocks = results.flatMap((r) => r.blocks);
69
+ return { imageInfos, blocks };
70
+ }
71
+ async _processImage(path) {
72
+ const buffer = await (0, file_1.readFileBuffer)(path);
73
+ const { blocks, width, height, blockCountX, blockCountY } = await (0, block_1.imageFileToBlocks)(buffer, this.config.blockSize);
74
+ const imageInfo = {
75
+ w: width,
76
+ h: height,
77
+ c: 4, // Always use 4 channels (RGBA) for generated PNG
78
+ x: blockCountX,
79
+ y: blockCountY,
80
+ name: this.config.preserveName
81
+ ? (0, core_1.encodeFileName)((0, file_1.fileNameWithoutExtension)(path))
82
+ : undefined,
83
+ };
84
+ return { imageInfo, blocks };
85
+ }
86
+ async _createImage(blocks, blockSize) {
87
+ const blockCount = blocks.length;
88
+ const blocksPerRow = Math.ceil(Math.sqrt(blockCount));
89
+ const imageWidth = blocksPerRow * blockSize;
90
+ const imageHeight = Math.ceil(blockCount / blocksPerRow) * blockSize;
91
+ return await (0, block_1.blocksToPngImage)(blocks, imageWidth, imageHeight, blockSize);
92
+ }
93
+ }
94
+ exports.ImageFragmenter = ImageFragmenter;
95
+ //# sourceMappingURL=fragmenter.js.map
@@ -0,0 +1,14 @@
1
+ import { type FragmentationConfig, type FragmentationResult } from "@pixzle/core";
2
+ export declare class ImageFragmenter {
3
+ private config;
4
+ constructor(config: FragmentationConfig);
5
+ private _initializeConfig;
6
+ fragmentImages(paths: string[]): Promise<FragmentationResult>;
7
+ private _createImages;
8
+ private _createManifest;
9
+ private _prepareData;
10
+ private _processImages;
11
+ private _processImage;
12
+ private _createImage;
13
+ }
14
+ //# sourceMappingURL=fragmenter.d.ts.map
@@ -0,0 +1,13 @@
1
+ import { type FragmentationConfig, type FragmentationResult } from "@pixzle/core";
2
+ export declare class ImageFragmenter {
3
+ private config;
4
+ constructor(config: FragmentationConfig);
5
+ private _initializeConfig;
6
+ fragmentImages(paths: string[]): Promise<FragmentationResult>;
7
+ private _createImages;
8
+ private _createManifest;
9
+ private _prepareData;
10
+ private _processImages;
11
+ private _processImage;
12
+ private _createImage;
13
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fragmenter.d.ts","sourceRoot":"","sources":["../src/fragmenter.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EAQzB,MAAM,cAAc,CAAC;AAOtB,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAgC;gBAElC,MAAM,EAAE,mBAAmB;IAIvC,OAAO,CAAC,iBAAiB;IAenB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC;YA6BrD,aAAa;IAc3B,OAAO,CAAC,eAAe;YAaT,YAAY;YAyBZ,cAAc;YAcd,aAAa;YAuBb,YAAY;CAW3B"}
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImageFragmenter = void 0;
4
+ const core_1 = require("@pixzle/core");
5
+ const seeded_shuffle_1 = require("@tuki0918/seeded-shuffle");
6
+ const block_1 = require("./block");
7
+ const constants_1 = require("./constants");
8
+ const file_1 = require("./file");
9
+ const utils_1 = require("./utils");
10
+ class ImageFragmenter {
11
+ config;
12
+ constructor(config) {
13
+ this.config = this._initializeConfig(config);
14
+ }
15
+ _initializeConfig(config) {
16
+ return {
17
+ blockSize: config.blockSize ?? core_1.DEFAULT_FRAGMENTATION_CONFIG.BLOCK_SIZE,
18
+ prefix: config.prefix ?? core_1.DEFAULT_FRAGMENTATION_CONFIG.PREFIX,
19
+ seed: config.seed || seeded_shuffle_1.SeededRandom.generateSeed(),
20
+ preserveName: config.preserveName ?? core_1.DEFAULT_FRAGMENTATION_CONFIG.PRESERVE_NAME,
21
+ crossImageShuffle: config.crossImageShuffle ??
22
+ core_1.DEFAULT_FRAGMENTATION_CONFIG.CROSS_IMAGE_SHUFFLE,
23
+ };
24
+ }
25
+ async fragmentImages(paths) {
26
+ const { manifest, blocks, blockCountsForCrossImages, blockCountsPerImage } = await this._prepareData(paths);
27
+ const shuffled = this.config.crossImageShuffle
28
+ ? (0, seeded_shuffle_1.shuffle)(blocks, manifest.config.seed)
29
+ : (0, block_1.blocksPerImage)(blocks, blockCountsPerImage, manifest.config.seed, seeded_shuffle_1.shuffle);
30
+ const blockCounts = this.config.crossImageShuffle
31
+ ? blockCountsForCrossImages
32
+ : blockCountsPerImage;
33
+ const fragmentedImages = await this._createImages(shuffled, blockCounts, manifest);
34
+ return {
35
+ manifest,
36
+ fragmentedImages,
37
+ };
38
+ }
39
+ async _createImages(blocks, blockCounts, manifest) {
40
+ return await Promise.all(manifest.images.map(async (_, index) => {
41
+ const { start, end } = (0, core_1.calculateBlockRange)(blockCounts, index);
42
+ const imageBlocks = blocks.slice(start, end);
43
+ return await this._createImage(imageBlocks, manifest.config.blockSize);
44
+ }));
45
+ }
46
+ _createManifest(manifestId, imageInfos) {
47
+ return {
48
+ id: manifestId,
49
+ version: constants_1.VERSION,
50
+ timestamp: new Date().toISOString(),
51
+ config: this.config,
52
+ images: imageInfos,
53
+ };
54
+ }
55
+ async _prepareData(paths) {
56
+ const manifestId = (0, utils_1.generateManifestId)();
57
+ const { imageInfos, blocks } = await this._processImages(paths);
58
+ (0, core_1.validateFileNames)(imageInfos, this.config.preserveName);
59
+ const manifest = this._createManifest(manifestId, imageInfos);
60
+ const blockCountsForCrossImages = (0, core_1.calculateBlockCountsForCrossImages)(blocks.length, paths.length);
61
+ // Calculate actual block counts per image for per-image shuffle
62
+ const blockCountsPerImage = (0, core_1.calculateBlockCountsPerImage)(imageInfos);
63
+ return { manifest, blocks, blockCountsForCrossImages, blockCountsPerImage };
64
+ }
65
+ async _processImages(paths) {
66
+ const results = await Promise.all(paths.map((path) => this._processImage(path)));
67
+ const imageInfos = results.map((r) => r.imageInfo);
68
+ const blocks = results.flatMap((r) => r.blocks);
69
+ return { imageInfos, blocks };
70
+ }
71
+ async _processImage(path) {
72
+ const buffer = await (0, file_1.readFileBuffer)(path);
73
+ const { blocks, width, height, blockCountX, blockCountY } = await (0, block_1.imageFileToBlocks)(buffer, this.config.blockSize);
74
+ const imageInfo = {
75
+ w: width,
76
+ h: height,
77
+ c: 4, // Always use 4 channels (RGBA) for generated PNG
78
+ x: blockCountX,
79
+ y: blockCountY,
80
+ name: this.config.preserveName
81
+ ? (0, core_1.encodeFileName)((0, file_1.fileNameWithoutExtension)(path))
82
+ : undefined,
83
+ };
84
+ return { imageInfo, blocks };
85
+ }
86
+ async _createImage(blocks, blockSize) {
87
+ const blockCount = blocks.length;
88
+ const blocksPerRow = Math.ceil(Math.sqrt(blockCount));
89
+ const imageWidth = blocksPerRow * blockSize;
90
+ const imageHeight = Math.ceil(blockCount / blocksPerRow) * blockSize;
91
+ return await (0, block_1.blocksToPngImage)(blocks, imageWidth, imageHeight, blockSize);
92
+ }
93
+ }
94
+ exports.ImageFragmenter = ImageFragmenter;
95
+ //# sourceMappingURL=fragmenter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fragmenter.js","sourceRoot":"","sources":["../src/fragmenter.ts"],"names":[],"mappings":";;;AAAA,uCAWsB;AACtB,6DAAiE;AACjE,mCAA8E;AAC9E,2CAAsC;AACtC,iC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,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IAC/B,CAAC;IAEO,KAAK,CAAC,YAAY,CACxB,MAAgB,EAChB,SAAiB;QAEjB,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC;QACjC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QACtD,MAAM,UAAU,GAAG,YAAY,GAAG,SAAS,CAAC;QAC5C,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,YAAY,CAAC,GAAG,SAAS,CAAC;QAErE,OAAO,MAAM,IAAA,wBAAgB,EAAC,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IAC5E,CAAC;CACF;AAvJD,0CAuJC"}
package/dist/index.cjs ADDED
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImageRestorer = exports.ImageFragmenter = void 0;
4
+ const core_1 = require("@pixzle/core");
5
+ const file_1 = require("./file");
6
+ const fragmenter_1 = require("./fragmenter");
7
+ Object.defineProperty(exports, "ImageFragmenter", { enumerable: true, get: function () { return fragmenter_1.ImageFragmenter; } });
8
+ const restorer_1 = require("./restorer");
9
+ Object.defineProperty(exports, "ImageRestorer", { enumerable: true, get: function () { return restorer_1.ImageRestorer; } });
10
+ async function shuffle(options) {
11
+ const { imagePaths, config, outputDir } = validateShuffleOptions(options);
12
+ const fragmenter = new fragmenter_1.ImageFragmenter(config ?? {});
13
+ const { manifest, fragmentedImages } = await fragmenter.fragmentImages(imagePaths);
14
+ await (0, file_1.createDir)(outputDir, true);
15
+ await (0, file_1.writeFile)(outputDir, core_1.MANIFEST_FILE_NAME, JSON.stringify(manifest, null, 2));
16
+ await Promise.all(fragmentedImages.map((img, i) => {
17
+ const filename = (0, core_1.generateFragmentFileName)(manifest, i);
18
+ return (0, file_1.writeFile)(outputDir, filename, img);
19
+ }));
20
+ }
21
+ async function restore(options) {
22
+ const { imagePaths, manifestPath, outputDir } = validateRestoreOptions(options);
23
+ const manifest = await (0, file_1.readJsonFile)(manifestPath);
24
+ (0, core_1.validateFragmentImageCount)(imagePaths, manifest);
25
+ const restorer = new restorer_1.ImageRestorer();
26
+ const restoredImages = await restorer.restoreImages(imagePaths, manifest);
27
+ await (0, file_1.createDir)(outputDir, true);
28
+ const imageInfos = manifest.images;
29
+ await Promise.all(restoredImages.map((img, i) => {
30
+ const filename = (0, core_1.generateRestoredOriginalFileName)(imageInfos[i]) ??
31
+ (0, core_1.generateRestoredFileName)(manifest, i);
32
+ return (0, file_1.writeFile)(outputDir, filename, img);
33
+ }));
34
+ }
35
+ const pixzle = {
36
+ shuffle,
37
+ restore,
38
+ };
39
+ exports.default = pixzle;
40
+ function validateCommonOptions(options, context) {
41
+ if (!options)
42
+ throw new Error(`[${context}] Options object is required.`);
43
+ const { imagePaths, outputDir } = options;
44
+ if (!imagePaths || !Array.isArray(imagePaths) || imagePaths.length === 0)
45
+ throw new Error(`[${context}] imagePaths must be a non-empty array.`);
46
+ if (!outputDir || typeof outputDir !== "string")
47
+ throw new Error(`[${context}] outputDir is required and must be a string.`);
48
+ return options;
49
+ }
50
+ function validateShuffleOptions(options) {
51
+ return validateCommonOptions(options, "shuffle");
52
+ }
53
+ function validateRestoreOptions(options) {
54
+ const { manifestPath } = options;
55
+ if (!manifestPath || typeof manifestPath !== "string")
56
+ throw new Error("[restore] manifestPath is required and must be a string.");
57
+ return validateCommonOptions(options, "restore");
58
+ }
59
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,12 @@
1
+ import { type FragmentationConfig, type ManifestData, type RestoreOptions, type ShuffleOptions } from "@pixzle/core";
2
+ import { ImageFragmenter } from "./fragmenter";
3
+ import { ImageRestorer } from "./restorer";
4
+ export { ImageFragmenter, ImageRestorer, type FragmentationConfig, type ManifestData, };
5
+ declare function shuffle(options: ShuffleOptions): Promise<void>;
6
+ declare function restore(options: RestoreOptions): Promise<void>;
7
+ declare const pixzle: {
8
+ shuffle: typeof shuffle;
9
+ restore: typeof restore;
10
+ };
11
+ export default pixzle;
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { type FragmentationConfig, type ManifestData, type RestoreOptions, type ShuffleOptions } from "@pixzle/core";
2
+ import { ImageFragmenter } from "./fragmenter";
3
+ import { ImageRestorer } from "./restorer";
4
+ export { ImageFragmenter, ImageRestorer, type FragmentationConfig, type ManifestData, };
5
+ declare function shuffle(options: ShuffleOptions): Promise<void>;
6
+ declare function restore(options: RestoreOptions): Promise<void>;
7
+ declare const pixzle: {
8
+ shuffle: typeof shuffle;
9
+ restore: typeof restore;
10
+ };
11
+ export default pixzle;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EAExB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,cAAc,EAKpB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EACL,eAAe,EACf,aAAa,EACb,KAAK,mBAAmB,EACxB,KAAK,YAAY,GAClB,CAAC;AAEF,iBAAe,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAoB7D;AAED,iBAAe,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAsB7D;AAED,QAAA,MAAM,MAAM;;;CAGX,CAAC;AAEF,eAAe,MAAM,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImageRestorer = exports.ImageFragmenter = void 0;
4
+ const core_1 = require("@pixzle/core");
5
+ const file_1 = require("./file");
6
+ const fragmenter_1 = require("./fragmenter");
7
+ Object.defineProperty(exports, "ImageFragmenter", { enumerable: true, get: function () { return fragmenter_1.ImageFragmenter; } });
8
+ const restorer_1 = require("./restorer");
9
+ Object.defineProperty(exports, "ImageRestorer", { enumerable: true, get: function () { return restorer_1.ImageRestorer; } });
10
+ async function shuffle(options) {
11
+ const { imagePaths, config, outputDir } = validateShuffleOptions(options);
12
+ const fragmenter = new fragmenter_1.ImageFragmenter(config ?? {});
13
+ const { manifest, fragmentedImages } = await fragmenter.fragmentImages(imagePaths);
14
+ await (0, file_1.createDir)(outputDir, true);
15
+ await (0, file_1.writeFile)(outputDir, core_1.MANIFEST_FILE_NAME, JSON.stringify(manifest, null, 2));
16
+ await Promise.all(fragmentedImages.map((img, i) => {
17
+ const filename = (0, core_1.generateFragmentFileName)(manifest, i);
18
+ return (0, file_1.writeFile)(outputDir, filename, img);
19
+ }));
20
+ }
21
+ async function restore(options) {
22
+ const { imagePaths, manifestPath, outputDir } = validateRestoreOptions(options);
23
+ const manifest = await (0, file_1.readJsonFile)(manifestPath);
24
+ (0, core_1.validateFragmentImageCount)(imagePaths, manifest);
25
+ const restorer = new restorer_1.ImageRestorer();
26
+ const restoredImages = await restorer.restoreImages(imagePaths, manifest);
27
+ await (0, file_1.createDir)(outputDir, true);
28
+ const imageInfos = manifest.images;
29
+ await Promise.all(restoredImages.map((img, i) => {
30
+ const filename = (0, core_1.generateRestoredOriginalFileName)(imageInfos[i]) ??
31
+ (0, core_1.generateRestoredFileName)(manifest, i);
32
+ return (0, file_1.writeFile)(outputDir, filename, img);
33
+ }));
34
+ }
35
+ const pixzle = {
36
+ shuffle,
37
+ restore,
38
+ };
39
+ exports.default = pixzle;
40
+ function validateCommonOptions(options, context) {
41
+ if (!options)
42
+ throw new Error(`[${context}] Options object is required.`);
43
+ const { imagePaths, outputDir } = options;
44
+ if (!imagePaths || !Array.isArray(imagePaths) || imagePaths.length === 0)
45
+ throw new Error(`[${context}] imagePaths must be a non-empty array.`);
46
+ if (!outputDir || typeof outputDir !== "string")
47
+ throw new Error(`[${context}] outputDir is required and must be a string.`);
48
+ return options;
49
+ }
50
+ function validateShuffleOptions(options) {
51
+ return validateCommonOptions(options, "shuffle");
52
+ }
53
+ function validateRestoreOptions(options) {
54
+ const { manifestPath } = options;
55
+ if (!manifestPath || typeof manifestPath !== "string")
56
+ throw new Error("[restore] manifestPath is required and must be a string.");
57
+ return validateCommonOptions(options, "restore");
58
+ }
59
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uCAUsB;AACtB,iCAA4D;AAC5D,6CAA+C;AAI7C,gGAJO,4BAAe,OAIP;AAHjB,yCAA2C;AAIzC,8FAJO,wBAAa,OAIP;AAKf,KAAK,UAAU,OAAO,CAAC,OAAuB;IAC5C,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAE1E,MAAM,UAAU,GAAG,IAAI,4BAAe,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;IACrD,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,GAClC,MAAM,UAAU,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAE9C,MAAM,IAAA,gBAAS,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACjC,MAAM,IAAA,gBAAS,EACb,SAAS,EACT,yBAAkB,EAClB,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAClC,CAAC;IAEF,MAAM,OAAO,CAAC,GAAG,CACf,gBAAgB,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;QAC9B,MAAM,QAAQ,GAAG,IAAA,+BAAwB,EAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QACvD,OAAO,IAAA,gBAAS,EAAC,SAAS,EAAE,QAAQ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CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QACtE,MAAM,IAAI,KAAK,CAAC,IAAI,OAAO,yCAAyC,CAAC,CAAC;IACxE,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ;QAC7C,MAAM,IAAI,KAAK,CAAC,IAAI,OAAO,+CAA+C,CAAC,CAAC;IAC9E,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,sBAAsB,CAAC,OAAuB;IACrD,OAAO,qBAAqB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AACnD,CAAC;AAED,SAAS,sBAAsB,CAAC,OAAuB;IACrD,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IACjC,IAAI,CAAC,YAAY,IAAI,OAAO,YAAY,KAAK,QAAQ;QACnD,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,OAAO,qBAAqB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AACnD,CAAC"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImageRestorer = void 0;
4
+ const core_1 = require("@pixzle/core");
5
+ const seeded_shuffle_1 = require("@tuki0918/seeded-shuffle");
6
+ const block_1 = require("./block");
7
+ const file_1 = require("./file");
8
+ class ImageRestorer {
9
+ async restoreImages(fragments, manifest) {
10
+ const { blocks, blockCountsPerImage } = await this._prepareData(fragments, manifest);
11
+ const restored = manifest.config.crossImageShuffle
12
+ ? (0, seeded_shuffle_1.unshuffle)(blocks, manifest.config.seed)
13
+ : (0, block_1.blocksPerImage)(blocks, blockCountsPerImage, manifest.config.seed, seeded_shuffle_1.unshuffle);
14
+ return await this._reconstructImages(restored, manifest);
15
+ }
16
+ async _reconstructImages(blocks, manifest) {
17
+ const blockCountsPerImage = (0, core_1.calculateBlockCountsPerImage)(manifest.images);
18
+ return await Promise.all(manifest.images.map(async (imageInfo, index) => {
19
+ const { start, end } = (0, core_1.calculateBlockRange)(blockCountsPerImage, index);
20
+ const imageBlocks = blocks.slice(start, end);
21
+ return await this._createImage(imageBlocks, manifest.config.blockSize, imageInfo);
22
+ }));
23
+ }
24
+ async _prepareData(fragments, manifest) {
25
+ const totalBlocks = (0, core_1.calculateTotalBlocks)(manifest.images);
26
+ const blockCountsForCrossImages = (0, core_1.calculateBlockCountsForCrossImages)(totalBlocks, fragments.length);
27
+ // Calculate actual block counts per image for per-image unshuffle
28
+ const blockCountsPerImage = (0, core_1.calculateBlockCountsPerImage)(manifest.images);
29
+ // Use blockCountsPerImage when crossImageShuffle is false
30
+ const blockCounts = manifest.config.crossImageShuffle
31
+ ? blockCountsForCrossImages
32
+ : blockCountsPerImage;
33
+ const blocks = await this._readBlocks(fragments, manifest, blockCounts);
34
+ return { blocks, blockCountsPerImage };
35
+ }
36
+ // Extract an array of blocks (Buffer) from a fragment image
37
+ async _readBlocksFromFragment(fragment, manifest, expectedCount) {
38
+ const buffer = Buffer.isBuffer(fragment)
39
+ ? fragment
40
+ : await (0, file_1.readFileBuffer)(fragment);
41
+ const { blocks } = await (0, block_1.imageFileToBlocks)(buffer, manifest.config.blockSize);
42
+ return blocks.slice(0, expectedCount);
43
+ }
44
+ async _readBlocks(fragments, manifest, blockCounts) {
45
+ const blockGroups = await Promise.all(fragments.map((fragment, i) => this._readBlocksFromFragment(fragment, manifest, blockCounts[i])));
46
+ return blockGroups.flat();
47
+ }
48
+ async _createImage(blocks, blockSize, imageInfo) {
49
+ const { w, h } = imageInfo;
50
+ return await (0, block_1.blocksToPngImage)(blocks, w, h, blockSize);
51
+ }
52
+ }
53
+ exports.ImageRestorer = ImageRestorer;
54
+ //# sourceMappingURL=restorer.js.map
@@ -0,0 +1,10 @@
1
+ import { type ManifestData } from "@pixzle/core";
2
+ export declare class ImageRestorer {
3
+ restoreImages(fragments: (string | Buffer)[], manifest: ManifestData): Promise<Buffer[]>;
4
+ private _reconstructImages;
5
+ private _prepareData;
6
+ private _readBlocksFromFragment;
7
+ private _readBlocks;
8
+ private _createImage;
9
+ }
10
+ //# sourceMappingURL=restorer.d.ts.map
@@ -0,0 +1,9 @@
1
+ import { type ManifestData } from "@pixzle/core";
2
+ export declare class ImageRestorer {
3
+ restoreImages(fragments: (string | Buffer)[], manifest: ManifestData): Promise<Buffer[]>;
4
+ private _reconstructImages;
5
+ private _prepareData;
6
+ private _readBlocksFromFragment;
7
+ private _readBlocks;
8
+ private _createImage;
9
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restorer.d.ts","sourceRoot":"","sources":["../src/restorer.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EAKlB,MAAM,cAAc,CAAC;AAKtB,qBAAa,aAAa;IAClB,aAAa,CACjB,SAAS,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAC9B,QAAQ,EAAE,YAAY,GACrB,OAAO,CAAC,MAAM,EAAE,CAAC;YAkBN,kBAAkB;YAkBlB,YAAY;YA2BZ,uBAAuB;YAgBvB,WAAW;YAaX,YAAY;CAQ3B"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImageRestorer = void 0;
4
+ const core_1 = require("@pixzle/core");
5
+ const seeded_shuffle_1 = require("@tuki0918/seeded-shuffle");
6
+ const block_1 = require("./block");
7
+ const file_1 = require("./file");
8
+ class ImageRestorer {
9
+ async restoreImages(fragments, manifest) {
10
+ const { blocks, blockCountsPerImage } = await this._prepareData(fragments, manifest);
11
+ const restored = manifest.config.crossImageShuffle
12
+ ? (0, seeded_shuffle_1.unshuffle)(blocks, manifest.config.seed)
13
+ : (0, block_1.blocksPerImage)(blocks, blockCountsPerImage, manifest.config.seed, seeded_shuffle_1.unshuffle);
14
+ return await this._reconstructImages(restored, manifest);
15
+ }
16
+ async _reconstructImages(blocks, manifest) {
17
+ const blockCountsPerImage = (0, core_1.calculateBlockCountsPerImage)(manifest.images);
18
+ return await Promise.all(manifest.images.map(async (imageInfo, index) => {
19
+ const { start, end } = (0, core_1.calculateBlockRange)(blockCountsPerImage, index);
20
+ const imageBlocks = blocks.slice(start, end);
21
+ return await this._createImage(imageBlocks, manifest.config.blockSize, imageInfo);
22
+ }));
23
+ }
24
+ async _prepareData(fragments, manifest) {
25
+ const totalBlocks = (0, core_1.calculateTotalBlocks)(manifest.images);
26
+ const blockCountsForCrossImages = (0, core_1.calculateBlockCountsForCrossImages)(totalBlocks, fragments.length);
27
+ // Calculate actual block counts per image for per-image unshuffle
28
+ const blockCountsPerImage = (0, core_1.calculateBlockCountsPerImage)(manifest.images);
29
+ // Use blockCountsPerImage when crossImageShuffle is false
30
+ const blockCounts = manifest.config.crossImageShuffle
31
+ ? blockCountsForCrossImages
32
+ : blockCountsPerImage;
33
+ const blocks = await this._readBlocks(fragments, manifest, blockCounts);
34
+ return { blocks, blockCountsPerImage };
35
+ }
36
+ // Extract an array of blocks (Buffer) from a fragment image
37
+ async _readBlocksFromFragment(fragment, manifest, expectedCount) {
38
+ const buffer = Buffer.isBuffer(fragment)
39
+ ? fragment
40
+ : await (0, file_1.readFileBuffer)(fragment);
41
+ const { blocks } = await (0, block_1.imageFileToBlocks)(buffer, manifest.config.blockSize);
42
+ return blocks.slice(0, expectedCount);
43
+ }
44
+ async _readBlocks(fragments, manifest, blockCounts) {
45
+ const blockGroups = await Promise.all(fragments.map((fragment, i) => this._readBlocksFromFragment(fragment, manifest, blockCounts[i])));
46
+ return blockGroups.flat();
47
+ }
48
+ async _createImage(blocks, blockSize, imageInfo) {
49
+ const { w, h } = imageInfo;
50
+ return await (0, block_1.blocksToPngImage)(blocks, w, h, blockSize);
51
+ }
52
+ }
53
+ exports.ImageRestorer = ImageRestorer;
54
+ //# sourceMappingURL=restorer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restorer.js","sourceRoot":"","sources":["../src/restorer.ts"],"names":[],"mappings":";;;AAAA,uCAOsB;AACt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CACjE,CACF,CAAC;QACF,OAAO,WAAW,CAAC,IAAI,EAAE,CAAC;IAC5B,CAAC;IAEO,KAAK,CAAC,YAAY,CACxB,MAAgB,EAChB,SAAiB,EACjB,SAAoB;QAEpB,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC;QAC3B,OAAO,MAAM,IAAA,wBAAgB,EAAC,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC;IACzD,CAAC;CACF;AAxGD,sCAwGC"}
package/dist/utils.cjs ADDED
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.generateManifestId = generateManifestId;
7
+ const node_crypto_1 = __importDefault(require("node:crypto"));
8
+ /**
9
+ * Generate a unique manifest ID
10
+ * @returns A UUID string
11
+ */
12
+ function generateManifestId() {
13
+ return node_crypto_1.default.randomUUID();
14
+ }
15
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Generate a unique manifest ID
3
+ * @returns A UUID string
4
+ */
5
+ export declare function generateManifestId(): string;
6
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generate a unique manifest ID
3
+ * @returns A UUID string
4
+ */
5
+ export declare function generateManifestId(): string;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C"}
package/dist/utils.js ADDED
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.generateManifestId = generateManifestId;
7
+ const node_crypto_1 = __importDefault(require("node:crypto"));
8
+ /**
9
+ * Generate a unique manifest ID
10
+ * @returns A UUID string
11
+ */
12
+ function generateManifestId() {
13
+ return node_crypto_1.default.randomUUID();
14
+ }
15
+ //# sourceMappingURL=utils.js.map