@pixzle/core 0.0.23 → 0.0.25
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/validators.js.map +1 -1
- package/package.json +1 -1
- package/dist/block-operations.cjs +0 -146
- package/dist/block-operations.d.cts +0 -56
- package/dist/block-operations.d.ts.map +0 -1
- package/dist/block-utils.cjs +0 -86
- package/dist/block-utils.d.cts +0 -47
- package/dist/block-utils.d.ts.map +0 -1
- package/dist/cjs/block-operations.d.ts +0 -56
- package/dist/cjs/block-operations.d.ts.map +0 -1
- package/dist/cjs/block-operations.js +0 -146
- package/dist/cjs/block-operations.js.map +0 -1
- package/dist/cjs/block-utils.d.ts +0 -47
- package/dist/cjs/block-utils.d.ts.map +0 -1
- package/dist/cjs/block-utils.js +0 -86
- package/dist/cjs/block-utils.js.map +0 -1
- package/dist/cjs/constants.d.ts +0 -8
- package/dist/cjs/constants.d.ts.map +0 -1
- package/dist/cjs/constants.js +0 -11
- package/dist/cjs/constants.js.map +0 -1
- package/dist/cjs/helpers.d.ts +0 -45
- package/dist/cjs/helpers.d.ts.map +0 -1
- package/dist/cjs/helpers.js +0 -101
- package/dist/cjs/helpers.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -8
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -27
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/types.d.ts +0 -65
- package/dist/cjs/types.d.ts.map +0 -1
- package/dist/cjs/types.js +0 -3
- package/dist/cjs/types.js.map +0 -1
- package/dist/cjs/validators.d.ts +0 -16
- package/dist/cjs/validators.d.ts.map +0 -1
- package/dist/cjs/validators.js +0 -48
- package/dist/cjs/validators.js.map +0 -1
- package/dist/constants.cjs +0 -11
- package/dist/constants.d.cts +0 -8
- package/dist/constants.d.ts.map +0 -1
- package/dist/esm/block-operations.d.ts +0 -56
- package/dist/esm/block-operations.d.ts.map +0 -1
- package/dist/esm/block-operations.js +0 -140
- package/dist/esm/block-operations.js.map +0 -1
- package/dist/esm/block-utils.d.ts +0 -47
- package/dist/esm/block-utils.d.ts.map +0 -1
- package/dist/esm/block-utils.js +0 -78
- package/dist/esm/block-utils.js.map +0 -1
- package/dist/esm/constants.d.ts +0 -8
- package/dist/esm/constants.d.ts.map +0 -1
- package/dist/esm/constants.js +0 -8
- package/dist/esm/constants.js.map +0 -1
- package/dist/esm/helpers.d.ts +0 -45
- package/dist/esm/helpers.d.ts.map +0 -1
- package/dist/esm/helpers.js +0 -93
- package/dist/esm/helpers.js.map +0 -1
- package/dist/esm/index.d.ts +0 -8
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js +0 -9
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/types.d.ts +0 -65
- package/dist/esm/types.d.ts.map +0 -1
- package/dist/esm/types.js +0 -2
- package/dist/esm/types.js.map +0 -1
- package/dist/esm/validators.d.ts +0 -16
- package/dist/esm/validators.d.ts.map +0 -1
- package/dist/esm/validators.js +0 -44
- package/dist/esm/validators.js.map +0 -1
- package/dist/helpers.cjs +0 -101
- package/dist/helpers.d.cts +0 -45
- package/dist/helpers.d.ts.map +0 -1
- package/dist/index.cjs +0 -27
- package/dist/index.d.cts +0 -8
- package/dist/index.d.ts.map +0 -1
- package/dist/types.cjs +0 -3
- package/dist/types.d.cts +0 -65
- package/dist/types.d.ts.map +0 -1
- package/dist/validators.cjs +0 -48
- package/dist/validators.d.cts +0 -16
- package/dist/validators.d.ts.map +0 -1
package/dist/helpers.cjs
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.encodeFileName = encodeFileName;
|
|
4
|
-
exports.decodeFileName = decodeFileName;
|
|
5
|
-
exports.generateFileName = generateFileName;
|
|
6
|
-
exports.generateFragmentFileName = generateFragmentFileName;
|
|
7
|
-
exports.generateRestoredFileName = generateRestoredFileName;
|
|
8
|
-
exports.generateRestoredOriginalFileName = generateRestoredOriginalFileName;
|
|
9
|
-
/**
|
|
10
|
-
* Encode file name to base64 for safe storage (cross-platform)
|
|
11
|
-
* @param name - Original file name
|
|
12
|
-
* @returns Base64 encoded file name
|
|
13
|
-
*/
|
|
14
|
-
function encodeFileName(name) {
|
|
15
|
-
// Use TextEncoder for UTF-8 encoding (available in both browser and Node.js)
|
|
16
|
-
const encoder = new TextEncoder();
|
|
17
|
-
const bytes = encoder.encode(name);
|
|
18
|
-
// Convert bytes to binary string for btoa (cross-platform)
|
|
19
|
-
// Use loop to avoid stack overflow with large arrays
|
|
20
|
-
let binaryString = "";
|
|
21
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
22
|
-
const byte = bytes[i];
|
|
23
|
-
binaryString += String.fromCharCode(byte);
|
|
24
|
-
}
|
|
25
|
-
return btoa(binaryString);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Decode file name from base64 (cross-platform)
|
|
29
|
-
* @param encodedName - Base64 encoded file name
|
|
30
|
-
* @returns Decoded original file name
|
|
31
|
-
*/
|
|
32
|
-
function decodeFileName(encodedName) {
|
|
33
|
-
// Use atob for base64 decoding (cross-platform)
|
|
34
|
-
const binaryString = atob(encodedName);
|
|
35
|
-
// Convert binary string to bytes
|
|
36
|
-
const bytes = Uint8Array.from(binaryString, (c) => c.charCodeAt(0));
|
|
37
|
-
// Use TextDecoder for UTF-8 decoding (available in both browser and Node.js)
|
|
38
|
-
const decoder = new TextDecoder();
|
|
39
|
-
return decoder.decode(bytes);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Generate a file name with prefix, 1-based zero-padded index, and extension
|
|
43
|
-
* @param manifest - Manifest data
|
|
44
|
-
* @param index - Index number (0-based, but output is 1-based)
|
|
45
|
-
* @param options - Options for the file name
|
|
46
|
-
* @param options.isFragmented - Whether the fragment is fragmented
|
|
47
|
-
* @returns File name (e.g., img_1.png.enc)
|
|
48
|
-
*/
|
|
49
|
-
function generateFileName(manifest, index, options = {
|
|
50
|
-
isFragmented: false,
|
|
51
|
-
}) {
|
|
52
|
-
const prefix = manifest.config.prefix;
|
|
53
|
-
const totalLength = manifest.images.length;
|
|
54
|
-
const extension = "png";
|
|
55
|
-
const numDigits = String(totalLength).length;
|
|
56
|
-
const paddedIndex = String(index + 1).padStart(numDigits, "0");
|
|
57
|
-
const filenameSuffix = options.isFragmented ? "_fragmented" : "";
|
|
58
|
-
const filename = `${prefix}_${paddedIndex}${filenameSuffix}`;
|
|
59
|
-
return `${filename}.${extension}`;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Generate a fragment file name
|
|
63
|
-
* @param manifest - Manifest data
|
|
64
|
-
* @param index - Index number (0-based, but output is 1-based)
|
|
65
|
-
* @returns Fragment file name (e.g., img_1_fragmented.png)
|
|
66
|
-
*/
|
|
67
|
-
function generateFragmentFileName(manifest, index) {
|
|
68
|
-
return generateFileName(manifest, index, {
|
|
69
|
-
isFragmented: true,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Generate a restored file name
|
|
74
|
-
* @param manifest - Manifest data
|
|
75
|
-
* @param index - Index number (0-based, but output is 1-based)
|
|
76
|
-
* @returns Restored file name (e.g., img_1.png)
|
|
77
|
-
*/
|
|
78
|
-
function generateRestoredFileName(manifest, index) {
|
|
79
|
-
return generateFileName(manifest, index, {
|
|
80
|
-
isFragmented: false,
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Generate a restored original file name
|
|
85
|
-
* @param imageInfo - Image information
|
|
86
|
-
* @returns Restored original file name
|
|
87
|
-
*/
|
|
88
|
-
function generateRestoredOriginalFileName(imageInfo) {
|
|
89
|
-
if (!imageInfo.name) {
|
|
90
|
-
return undefined;
|
|
91
|
-
}
|
|
92
|
-
try {
|
|
93
|
-
const decodedName = decodeFileName(imageInfo.name);
|
|
94
|
-
return decodedName ? `${decodedName}.png` : undefined;
|
|
95
|
-
}
|
|
96
|
-
catch {
|
|
97
|
-
// Fallback: if decoding fails, treat as already decoded (backward compatibility)
|
|
98
|
-
return `${imageInfo.name}.png`;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
//# sourceMappingURL=helpers.js.map
|
package/dist/helpers.d.cts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { ManifestData } from "./types";
|
|
2
|
-
/**
|
|
3
|
-
* Encode file name to base64 for safe storage (cross-platform)
|
|
4
|
-
* @param name - Original file name
|
|
5
|
-
* @returns Base64 encoded file name
|
|
6
|
-
*/
|
|
7
|
-
export declare function encodeFileName(name: string): string;
|
|
8
|
-
/**
|
|
9
|
-
* Decode file name from base64 (cross-platform)
|
|
10
|
-
* @param encodedName - Base64 encoded file name
|
|
11
|
-
* @returns Decoded original file name
|
|
12
|
-
*/
|
|
13
|
-
export declare function decodeFileName(encodedName: string): string;
|
|
14
|
-
/**
|
|
15
|
-
* Generate a file name with prefix, 1-based zero-padded index, and extension
|
|
16
|
-
* @param manifest - Manifest data
|
|
17
|
-
* @param index - Index number (0-based, but output is 1-based)
|
|
18
|
-
* @param options - Options for the file name
|
|
19
|
-
* @param options.isFragmented - Whether the fragment is fragmented
|
|
20
|
-
* @returns File name (e.g., img_1.png.enc)
|
|
21
|
-
*/
|
|
22
|
-
export declare function generateFileName(manifest: ManifestData, index: number, options?: {
|
|
23
|
-
isFragmented: boolean;
|
|
24
|
-
}): string;
|
|
25
|
-
/**
|
|
26
|
-
* Generate a fragment file name
|
|
27
|
-
* @param manifest - Manifest data
|
|
28
|
-
* @param index - Index number (0-based, but output is 1-based)
|
|
29
|
-
* @returns Fragment file name (e.g., img_1_fragmented.png)
|
|
30
|
-
*/
|
|
31
|
-
export declare function generateFragmentFileName(manifest: ManifestData, index: number): string;
|
|
32
|
-
/**
|
|
33
|
-
* Generate a restored file name
|
|
34
|
-
* @param manifest - Manifest data
|
|
35
|
-
* @param index - Index number (0-based, but output is 1-based)
|
|
36
|
-
* @returns Restored file name (e.g., img_1.png)
|
|
37
|
-
*/
|
|
38
|
-
export declare function generateRestoredFileName(manifest: ManifestData, index: number): string;
|
|
39
|
-
/**
|
|
40
|
-
* Generate a restored original file name
|
|
41
|
-
* @param imageInfo - Image information
|
|
42
|
-
* @returns Restored original file name
|
|
43
|
-
*/
|
|
44
|
-
export declare function generateRestoredOriginalFileName(imageInfo: ManifestData["images"][number]): string | undefined;
|
|
45
|
-
//# sourceMappingURL=helpers.d.ts.map
|
package/dist/helpers.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAYnD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAQ1D;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;IACP,YAAY,EAAE,OAAO,CAAC;CAGvB,GACA,MAAM,CASR;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE,MAAM,GACZ,MAAM,CAIR;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE,MAAM,GACZ,MAAM,CAIR;AAED;;;;GAIG;AACH,wBAAgB,gCAAgC,CAC9C,SAAS,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GACxC,MAAM,GAAG,SAAS,CAWpB"}
|
package/dist/index.cjs
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.DEFAULT_FRAGMENTATION_CONFIG = void 0;
|
|
18
|
-
__exportStar(require("./types"), exports);
|
|
19
|
-
__exportStar(require("./constants"), exports);
|
|
20
|
-
__exportStar(require("./helpers"), exports);
|
|
21
|
-
__exportStar(require("./block-utils"), exports);
|
|
22
|
-
__exportStar(require("./block-operations"), exports);
|
|
23
|
-
__exportStar(require("./validators"), exports);
|
|
24
|
-
// Re-export constants with old name for backward compatibility
|
|
25
|
-
var constants_1 = require("./constants");
|
|
26
|
-
Object.defineProperty(exports, "DEFAULT_FRAGMENTATION_CONFIG", { enumerable: true, get: function () { return constants_1.DEFAULT_FRAGMENTATION_CONFIG; } });
|
|
27
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.d.cts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export * from "./types";
|
|
2
|
-
export * from "./constants";
|
|
3
|
-
export * from "./helpers";
|
|
4
|
-
export * from "./block-utils";
|
|
5
|
-
export * from "./block-operations";
|
|
6
|
-
export * from "./validators";
|
|
7
|
-
export { DEFAULT_FRAGMENTATION_CONFIG } from "./constants";
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAG7B,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/types.cjs
DELETED
package/dist/types.d.cts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
export interface ShuffleOptions {
|
|
2
|
-
/** Image paths (e.g., ["image1.png", "image2.png"]) */
|
|
3
|
-
imagePaths: string[];
|
|
4
|
-
/** Fragmentation config */
|
|
5
|
-
config?: FragmentationConfig;
|
|
6
|
-
/** Output directory (e.g., "./output/fragments") */
|
|
7
|
-
outputDir: string;
|
|
8
|
-
}
|
|
9
|
-
export interface RestoreOptions {
|
|
10
|
-
/** Image paths (e.g., ["fragment1.png", "fragment2.png"]) */
|
|
11
|
-
imagePaths: string[];
|
|
12
|
-
/** Manifest path (e.g., "./output/fragments/manifest.json") */
|
|
13
|
-
manifestPath: string;
|
|
14
|
-
/** Output directory (e.g., "./output/restored") */
|
|
15
|
-
outputDir: string;
|
|
16
|
-
}
|
|
17
|
-
export interface FragmentationConfig {
|
|
18
|
-
/** Pixel block size (e.g., 10x10 to 10) */
|
|
19
|
-
blockSize?: number;
|
|
20
|
-
/** Prefix for fragment files (optional, default: "fragment") */
|
|
21
|
-
prefix?: string;
|
|
22
|
-
/** Random seed (auto-generated if not specified) */
|
|
23
|
-
seed?: number | string;
|
|
24
|
-
/** Preserve original file name (optional, default: false) */
|
|
25
|
-
preserveName?: boolean;
|
|
26
|
-
/** Shuffle blocks across all images instead of within each image independently (optional, default: false) */
|
|
27
|
-
crossImageShuffle?: boolean;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Information about the image before fragmentation.
|
|
31
|
-
* This includes dimensions, channels, and block counts.
|
|
32
|
-
*/
|
|
33
|
-
export interface ImageInfo {
|
|
34
|
-
/** Width */
|
|
35
|
-
w: number;
|
|
36
|
-
/** Height */
|
|
37
|
-
h: number;
|
|
38
|
-
/** Number of channels */
|
|
39
|
-
c: number;
|
|
40
|
-
/** Number of blocks X */
|
|
41
|
-
x: number;
|
|
42
|
-
/** Number of blocks Y */
|
|
43
|
-
y: number;
|
|
44
|
-
/** Original file name in base64 encoding (optional) */
|
|
45
|
-
name?: string;
|
|
46
|
-
}
|
|
47
|
-
export interface ManifestData {
|
|
48
|
-
/** UUID */
|
|
49
|
-
id: string;
|
|
50
|
-
/** Version */
|
|
51
|
-
version: string;
|
|
52
|
-
/** Timestamp */
|
|
53
|
-
timestamp: string;
|
|
54
|
-
/** Config */
|
|
55
|
-
config: Required<FragmentationConfig>;
|
|
56
|
-
/** Image information */
|
|
57
|
-
images: ImageInfo[];
|
|
58
|
-
}
|
|
59
|
-
export interface FragmentationResult {
|
|
60
|
-
/** Manifest data */
|
|
61
|
-
manifest: ManifestData;
|
|
62
|
-
/** Fragmented images */
|
|
63
|
-
fragmentedImages: Buffer[];
|
|
64
|
-
}
|
|
65
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,uDAAuD;IACvD,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,2BAA2B;IAC3B,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,oDAAoD;IACpD,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,6DAA6D;IAC7D,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,+DAA+D;IAC/D,YAAY,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,6DAA6D;IAC7D,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,6GAA6G;IAC7G,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,YAAY;IACZ,CAAC,EAAE,MAAM,CAAC;IACV,aAAa;IACb,CAAC,EAAE,MAAM,CAAC;IACV,yBAAyB;IACzB,CAAC,EAAE,MAAM,CAAC;IACV,yBAAyB;IACzB,CAAC,EAAE,MAAM,CAAC;IACV,yBAAyB;IACzB,CAAC,EAAE,MAAM,CAAC;IACV,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,WAAW;IACX,EAAE,EAAE,MAAM,CAAC;IACX,cAAc;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa;IACb,MAAM,EAAE,QAAQ,CAAC,mBAAmB,CAAC,CAAC;IACtC,wBAAwB;IACxB,MAAM,EAAE,SAAS,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB;IAClC,oBAAoB;IACpB,QAAQ,EAAE,YAAY,CAAC;IACvB,wBAAwB;IACxB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B"}
|
package/dist/validators.cjs
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateFragmentImageCount = validateFragmentImageCount;
|
|
4
|
-
exports.validateFileNames = validateFileNames;
|
|
5
|
-
const helpers_1 = require("./helpers");
|
|
6
|
-
/**
|
|
7
|
-
* Validates that the number of fragment images matches the number of images in the manifest
|
|
8
|
-
* @param fragmentImages - Array of fragment images (file paths or buffers)
|
|
9
|
-
* @param manifest - The manifest data containing image information
|
|
10
|
-
* @throws {Error} When the counts don't match
|
|
11
|
-
*/
|
|
12
|
-
function validateFragmentImageCount(fragmentImages, manifest) {
|
|
13
|
-
const manifestImageCount = manifest.images.length;
|
|
14
|
-
const fragmentImageCount = fragmentImages.length;
|
|
15
|
-
if (manifestImageCount !== fragmentImageCount) {
|
|
16
|
-
throw new Error(`Fragment image count mismatch: expected ${manifestImageCount} but got ${fragmentImageCount}`);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Validates that there are no duplicate file names in the image infos
|
|
21
|
-
* @param imageInfos - Array of image information objects
|
|
22
|
-
* @param preserveName - Whether name preservation is enabled
|
|
23
|
-
* @throws {Error} When duplicate file names are detected
|
|
24
|
-
*/
|
|
25
|
-
function validateFileNames(imageInfos, preserveName) {
|
|
26
|
-
if (!preserveName || imageInfos.length <= 1) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const nameSet = new Set();
|
|
30
|
-
for (const info of imageInfos) {
|
|
31
|
-
if (info.name !== undefined) {
|
|
32
|
-
// Decode base64 to get original name for comparison
|
|
33
|
-
let decodedName;
|
|
34
|
-
try {
|
|
35
|
-
decodedName = (0, helpers_1.decodeFileName)(info.name);
|
|
36
|
-
}
|
|
37
|
-
catch {
|
|
38
|
-
// If decoding fails, treat as already decoded (backward compatibility)
|
|
39
|
-
decodedName = info.name;
|
|
40
|
-
}
|
|
41
|
-
if (nameSet.has(decodedName)) {
|
|
42
|
-
throw new Error(`Duplicate file name detected: ${decodedName}`);
|
|
43
|
-
}
|
|
44
|
-
nameSet.add(decodedName);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=validators.js.map
|
package/dist/validators.d.cts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { ImageInfo, ManifestData } from "./types";
|
|
2
|
-
/**
|
|
3
|
-
* Validates that the number of fragment images matches the number of images in the manifest
|
|
4
|
-
* @param fragmentImages - Array of fragment images (file paths or buffers)
|
|
5
|
-
* @param manifest - The manifest data containing image information
|
|
6
|
-
* @throws {Error} When the counts don't match
|
|
7
|
-
*/
|
|
8
|
-
export declare function validateFragmentImageCount(fragmentImages: (string | Buffer)[], manifest: ManifestData): void;
|
|
9
|
-
/**
|
|
10
|
-
* Validates that there are no duplicate file names in the image infos
|
|
11
|
-
* @param imageInfos - Array of image information objects
|
|
12
|
-
* @param preserveName - Whether name preservation is enabled
|
|
13
|
-
* @throws {Error} When duplicate file names are detected
|
|
14
|
-
*/
|
|
15
|
-
export declare function validateFileNames(imageInfos: ImageInfo[], preserveName: boolean): void;
|
|
16
|
-
//# sourceMappingURL=validators.d.ts.map
|
package/dist/validators.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvD;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,cAAc,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EACnC,QAAQ,EAAE,YAAY,GACrB,IAAI,CASN;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,SAAS,EAAE,EACvB,YAAY,EAAE,OAAO,GACpB,IAAI,CAuBN"}
|