iso2x-wasm 0.1.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/dist/attach.d.ts +10 -0
- package/dist/attach.js +12 -0
- package/dist/constants.d.ts +53 -0
- package/dist/constants.js +75 -0
- package/dist/detect.d.ts +53 -0
- package/dist/detect.js +128 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -0
- package/dist/inspect.d.ts +2 -0
- package/dist/inspect.js +14 -0
- package/dist/session.d.ts +117 -0
- package/dist/session.js +143 -0
- package/dist/types.d.ts +147 -0
- package/dist/types.js +1 -0
- package/dist/wasm/iso2x_wasm.d.ts +216 -0
- package/dist/wasm/iso2x_wasm.js +1111 -0
- package/dist/wasm/iso2x_wasm_bg.wasm +0 -0
- package/dist/wasm/iso2x_wasm_bg.wasm.d.ts +37 -0
- package/package.json +39 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
export type SourceReadFn = (offset: number, length: number) => Uint8Array;
|
|
2
|
+
export interface SourceInfoResult {
|
|
3
|
+
titleId: string;
|
|
4
|
+
contentType: string;
|
|
5
|
+
detectedTitle: string | undefined;
|
|
6
|
+
}
|
|
7
|
+
export type ConversionFormat = 'god' | 'xiso' | 'extracted' | 'ciso' | 'cci' | 'zar';
|
|
8
|
+
/**
|
|
9
|
+
* `fetchSize` lives here, and only here - it's a read-side setting (bytes
|
|
10
|
+
* pulled per `readFn` call while opening/reading the source container).
|
|
11
|
+
* A write-side fetch size isn't a meaningful concept, so it has no place
|
|
12
|
+
* on `OpenConversionSessionOptions`.
|
|
13
|
+
*/
|
|
14
|
+
export interface SourceOptions {
|
|
15
|
+
format: ConversionFormat;
|
|
16
|
+
fetchSize?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface SourcePart {
|
|
19
|
+
name: string;
|
|
20
|
+
size: number;
|
|
21
|
+
readFn: SourceReadFn;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* xiso's own write-mode enum (wire values are these lowercase strings):
|
|
25
|
+
*
|
|
26
|
+
* - `'trim'` - cuts trailing padding after the last used byte; nothing is
|
|
27
|
+
* zeroed, so interior gaps pass through untouched.
|
|
28
|
+
* - `'zero'` - zeroes unused sectors in place without trimming; total size
|
|
29
|
+
* matches the source (Xbox 360 images are an exception: still trimmed
|
|
30
|
+
* but not zeroed).
|
|
31
|
+
* - `'full'` - full reauthor via a fresh XDVDFS rebuild. Slowest, but
|
|
32
|
+
* independent of source layout. Default when `mode` is omitted.
|
|
33
|
+
*
|
|
34
|
+
* Not the same shape as `ScrubMode` below despite both being three-option
|
|
35
|
+
* "how much to reprocess" enums: `'trim'`/`'zero'` are independent
|
|
36
|
+
* operations xiso can apply separately, while `ScrubMode` only exposes
|
|
37
|
+
* "neither" or "both together". `'full'` is the one variant that's
|
|
38
|
+
* identical between the two.
|
|
39
|
+
*/
|
|
40
|
+
export type XisoMode = 'trim' | 'zero' | 'full';
|
|
41
|
+
/**
|
|
42
|
+
* ciso/cci/god's shared write-mode enum (wire values are these lowercase
|
|
43
|
+
* strings):
|
|
44
|
+
*
|
|
45
|
+
* - `'none'` - straight sector copy, no trim, no zero, no directory scan.
|
|
46
|
+
* - `'partial'` - trims trailing padding and zeroes interior gaps in one
|
|
47
|
+
* pass. On original Xbox (OGX) images this also tries to leave the
|
|
48
|
+
* disc's security-sector region alone; on Xbox 360 images interior gaps
|
|
49
|
+
* are never zeroed, only trimmed.
|
|
50
|
+
* - `'full'` - full reauthor via a fresh XDVDFS rebuild. Slowest, but
|
|
51
|
+
* independent of source layout. Default when `mode` is omitted.
|
|
52
|
+
*
|
|
53
|
+
* ZAR has no equivalent - it has no padding/junk concept to trim or zero
|
|
54
|
+
* (every file is addressed by name, not by sector), so its
|
|
55
|
+
* `OpenConversionSessionOptions` variant doesn't take a `mode` at all.
|
|
56
|
+
*/
|
|
57
|
+
export type ScrubMode = 'none' | 'partial' | 'full';
|
|
58
|
+
export type OpenConversionSessionOptions = {
|
|
59
|
+
format: 'god';
|
|
60
|
+
/** Write mode - see `ScrubMode`. Defaults to `'full'` if omitted. */
|
|
61
|
+
mode?: ScrubMode;
|
|
62
|
+
gameTitle?: string;
|
|
63
|
+
} | {
|
|
64
|
+
format: 'xiso';
|
|
65
|
+
mode?: XisoMode;
|
|
66
|
+
split?: boolean;
|
|
67
|
+
outputName?: string;
|
|
68
|
+
sectorsPerChunk?: number;
|
|
69
|
+
} | {
|
|
70
|
+
format: 'ciso';
|
|
71
|
+
/** Write mode - see `ScrubMode`. Defaults to `'full'` if omitted. */
|
|
72
|
+
mode?: ScrubMode;
|
|
73
|
+
/**
|
|
74
|
+
* Filename stem (no extension) the split output files are named
|
|
75
|
+
* after, e.g. "game" produces "game.1.cso", "game.2.cso", etc.
|
|
76
|
+
* once the image crosses the ~4.29 GB split threshold - and
|
|
77
|
+
* still produces "game.1.cso" even when it doesn't split.
|
|
78
|
+
*/
|
|
79
|
+
outputName: string;
|
|
80
|
+
} | {
|
|
81
|
+
format: 'cci';
|
|
82
|
+
/** Write mode - see `ScrubMode`. Defaults to `'full'` if omitted. */
|
|
83
|
+
mode?: ScrubMode;
|
|
84
|
+
/**
|
|
85
|
+
* Filename stem (no extension) the split output files are named
|
|
86
|
+
* after, e.g. "game" produces "game.1.cci", "game.2.cci", etc.
|
|
87
|
+
* once the image crosses the ~4.28 GB split threshold - and
|
|
88
|
+
* still produces "game.1.cci" even when it doesn't split. Unlike
|
|
89
|
+
* ciso, each ".N.cci" part is fully self-contained with its own
|
|
90
|
+
* header and index rather than one shared index in part 1 - see
|
|
91
|
+
* cciFileSplitPoint().
|
|
92
|
+
*/
|
|
93
|
+
outputName: string;
|
|
94
|
+
} | {
|
|
95
|
+
format: 'extracted';
|
|
96
|
+
skipSystemUpdate?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* ORs the HARD_DISK / NONSECURE_HARD_DISK / MEDIA_BOARD flags into
|
|
99
|
+
* the root-level `default.xbe`'s `allowed_media_types`, so the
|
|
100
|
+
* extracted title boots from a softmod HDD/media-board dashboard
|
|
101
|
+
* even if the original disc only authorized DVD. No-op if the
|
|
102
|
+
* source has no root-level `default.xbe` (e.g. a GoD/XEX source).
|
|
103
|
+
*/
|
|
104
|
+
allowedMediaPatch?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Overwrites the cert's `title_name` with this string (UTF-16 on
|
|
107
|
+
* the wasm side, truncated/zero-padded to the field's fixed
|
|
108
|
+
* 40-code-unit width). Typically pre-filled from
|
|
109
|
+
* `inspectSource(...).detectedTitle` and left editable in the UI.
|
|
110
|
+
* Omitted/undefined leaves the title untouched.
|
|
111
|
+
*/
|
|
112
|
+
renameTitle?: string;
|
|
113
|
+
} | {
|
|
114
|
+
format: 'zar';
|
|
115
|
+
/**
|
|
116
|
+
* Filename stem (no extension) the output file is named after,
|
|
117
|
+
* e.g. "game" produces "game.zar". Required, like ciso/cci's
|
|
118
|
+
* `outputName` - unlike xiso's optional one. ZAR is never split
|
|
119
|
+
* (unlike xiso/ciso/cci), so there's exactly one output file
|
|
120
|
+
* regardless of size.
|
|
121
|
+
*/
|
|
122
|
+
outputName: string;
|
|
123
|
+
};
|
|
124
|
+
export type ResolvedSource = {
|
|
125
|
+
kind: 'file';
|
|
126
|
+
format: ConversionFormat;
|
|
127
|
+
readFn: SourceReadFn;
|
|
128
|
+
fileSize: number;
|
|
129
|
+
} | {
|
|
130
|
+
kind: 'dir';
|
|
131
|
+
format: ConversionFormat;
|
|
132
|
+
parts: SourcePart[];
|
|
133
|
+
};
|
|
134
|
+
export interface SplitCciResult {
|
|
135
|
+
kind: 'cci-split';
|
|
136
|
+
parts: [string, string];
|
|
137
|
+
}
|
|
138
|
+
export interface SplitXisoResult {
|
|
139
|
+
kind: 'xiso-split';
|
|
140
|
+
parts: string[];
|
|
141
|
+
}
|
|
142
|
+
export interface IsoRootOffsetCandidate {
|
|
143
|
+
/** Variant name for the root-offset candidate, e.g. "Xsf", "Xgd2", "Xgd1", "Xgd3". */
|
|
144
|
+
name: string;
|
|
145
|
+
/** Byte offset of the XDVDFS volume from the start of the file for this candidate. */
|
|
146
|
+
rootOffset: number;
|
|
147
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* One format-agnostic session type exposed to JS. The worker drives this
|
|
6
|
+
* the same way regardless of format - `nextChunk`/`isDone`/`totalUnits`
|
|
7
|
+
* is the entire contract, with `hashNextPart` as an extra pre-streaming
|
|
8
|
+
* step that's a no-op where nothing needs precomputing.
|
|
9
|
+
*/
|
|
10
|
+
export class ConversionSession {
|
|
11
|
+
private constructor();
|
|
12
|
+
free(): void;
|
|
13
|
+
[Symbol.dispose](): void;
|
|
14
|
+
currentEntryName(): string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Drives one bounded step of pre-streaming hashing/sizing (see
|
|
17
|
+
* `SessionInner::hash_next_part`). Call this in a loop from JS,
|
|
18
|
+
* yielding to the event loop between calls, until it returns `true`,
|
|
19
|
+
* *before* calling `nextChunk()`. Bounding each call's work is what
|
|
20
|
+
* makes hashing/sizing cancellable from JS.
|
|
21
|
+
*/
|
|
22
|
+
hashNextPart(): boolean;
|
|
23
|
+
isDone(): boolean;
|
|
24
|
+
nextChunk(max_bytes: number): Uint8Array | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Array of `{ name, size }` for formats that produce multiple output
|
|
27
|
+
* files. Safe to call right after `open()`, before streaming - though
|
|
28
|
+
* it may be empty until sizing/hashing finishes, or permanently empty
|
|
29
|
+
* for single-stream formats.
|
|
30
|
+
*/
|
|
31
|
+
outputManifest(): any;
|
|
32
|
+
totalUnits(): number;
|
|
33
|
+
/**
|
|
34
|
+
* See `ChunkSource::units_done` - `null` for every format except
|
|
35
|
+
* zar, where it's the authoritative "raw input bytes consumed" count
|
|
36
|
+
* to use instead of summing `nextChunk()`'s returned byte lengths.
|
|
37
|
+
*/
|
|
38
|
+
unitsDone(): number | undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export class SourceInfo {
|
|
42
|
+
private constructor();
|
|
43
|
+
free(): void;
|
|
44
|
+
[Symbol.dispose](): void;
|
|
45
|
+
contentType(): string;
|
|
46
|
+
detectedTitle(): string | undefined;
|
|
47
|
+
titleId(): string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function cciFileSplitPoint(): number;
|
|
51
|
+
|
|
52
|
+
export function cciSectorSize(): number;
|
|
53
|
+
|
|
54
|
+
export function cciSizingBatchSectors(): number;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Chains `next_digest` onto the end of the hash list encoded in `mht_bytes`
|
|
58
|
+
* and returns the recomputed digest bytes.
|
|
59
|
+
*
|
|
60
|
+
* # Errors
|
|
61
|
+
*
|
|
62
|
+
* Returns an error if `mht_bytes` is not a valid hash list, or if
|
|
63
|
+
* `next_digest` is not exactly 20 bytes long.
|
|
64
|
+
*/
|
|
65
|
+
export function chainMhtDigest(mht_bytes: Uint8Array, next_digest: Uint8Array): Uint8Array;
|
|
66
|
+
|
|
67
|
+
export function cisoFilePaddingModulus(): number;
|
|
68
|
+
|
|
69
|
+
export function cisoFileSplitPoint(): number;
|
|
70
|
+
|
|
71
|
+
export function cisoSectorSize(): number;
|
|
72
|
+
|
|
73
|
+
export function cisoSizingBatchSectors(): number;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Wasm wrapper around `core::source::detect_dir` - the directory-shape
|
|
77
|
+
* path (God/Extracted). Takes the flat list of forward-slash-normalized
|
|
78
|
+
* relative paths for every regular file in the dropped folder.
|
|
79
|
+
*
|
|
80
|
+
* Returns `None` when the listing matches neither shape (e.g. a folder of
|
|
81
|
+
* loose split-XISO parts) - the caller should resolve each entry via
|
|
82
|
+
* `detectFormat` instead.
|
|
83
|
+
*/
|
|
84
|
+
export function detectDirFormat(entries: string[]): string | undefined;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Wasm wrapper around `core::source::detect` - the single-file, magic-byte
|
|
88
|
+
* path (Xiso/Ciso/Cci). For a dropped folder use `detectDirFormat` instead.
|
|
89
|
+
*
|
|
90
|
+
* # Errors
|
|
91
|
+
*
|
|
92
|
+
* Returns an error if reading from `read_fn` fails or if the file's magic
|
|
93
|
+
* bytes don't match any known single-file format.
|
|
94
|
+
*/
|
|
95
|
+
export function detectFormat(read_fn: Function, file_size: number): string;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Generates a bootable "default.xbe" attach stub for an OGX (original
|
|
99
|
+
* Xbox) source, so an ISO/CCI/CISO conversion output can still be
|
|
100
|
+
* launched from a softmod dashboard. Rejects `GoD` (XEX) sources - this
|
|
101
|
+
* only makes sense for OGX, and this function enforces that
|
|
102
|
+
* unconditionally regardless of what the caller has already checked.
|
|
103
|
+
*
|
|
104
|
+
* # Errors
|
|
105
|
+
*
|
|
106
|
+
* Returns an error if `source` is unresolved or invalid, if reading
|
|
107
|
+
* `source_parts` fails, if the source is a `GoD` (XEX) source rather than
|
|
108
|
+
* OGX, if the XDVDFS root or `default.xbe` can't be located, or if
|
|
109
|
+
* building the attach stub fails.
|
|
110
|
+
*/
|
|
111
|
+
export function generateAttachXbe(read_fn: Function, file_size: number, source: any, source_parts: any): Uint8Array;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Shows title/content-type for a source, before its conversion session is opened.
|
|
115
|
+
* Image-backed sources are inspected by locating and parsing the XDVDFS
|
|
116
|
+
* root; an extracted source has no such root, so it's inspected instead
|
|
117
|
+
* by locating and parsing `default.xbe`/`default.xex` directly off the
|
|
118
|
+
* directory.
|
|
119
|
+
*
|
|
120
|
+
* # Errors
|
|
121
|
+
*
|
|
122
|
+
* Returns an error if `source` is unresolved or invalid, if reading
|
|
123
|
+
* `source_parts` fails, or if the launch executable / XDVDFS root can't
|
|
124
|
+
* be located or parsed for the resolved source.
|
|
125
|
+
*/
|
|
126
|
+
export function inspectSource(read_fn: Function, file_size: number, source: any, source_parts: any): SourceInfo;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Exposes the root-offset candidates `IsoType::read` actually probes -
|
|
130
|
+
* Xsf, Xgd2, Xgd1, Xgd3, in that order (iso2god-rs's `iso/iso_type.rs`) -
|
|
131
|
+
* so JS callers reference the real values instead of hardcoding magic
|
|
132
|
+
* numbers that could silently drift if iso2god-rs reorders or changes them.
|
|
133
|
+
*/
|
|
134
|
+
export function isoRootOffsetCandidates(): Array<any>;
|
|
135
|
+
|
|
136
|
+
export function mhtSize(): number;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Opens a conversion session for the given source and the requested
|
|
140
|
+
* target-format `options`.
|
|
141
|
+
*
|
|
142
|
+
* # Errors
|
|
143
|
+
*
|
|
144
|
+
* Returns an error if `options` fails to deserialize into a known
|
|
145
|
+
* `FormatOptions` variant, if `source` is unresolved or invalid, if
|
|
146
|
+
* reading `source_parts` fails, or if the resolved source can't be
|
|
147
|
+
* opened as the requested target format (e.g. an extracted-only source
|
|
148
|
+
* requested as an image-only target).
|
|
149
|
+
*/
|
|
150
|
+
export function openConversionSession(read_fn: Function, file_size: number, options: any, source: any, source_parts: any): ConversionSession;
|
|
151
|
+
|
|
152
|
+
export function xisoSplitMargin(): number;
|
|
153
|
+
|
|
154
|
+
export function zarBlockSize(): number;
|
|
155
|
+
|
|
156
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
157
|
+
|
|
158
|
+
export interface InitOutput {
|
|
159
|
+
readonly memory: WebAssembly.Memory;
|
|
160
|
+
readonly __wbg_conversionsession_free: (a: number, b: number) => void;
|
|
161
|
+
readonly __wbg_sourceinfo_free: (a: number, b: number) => void;
|
|
162
|
+
readonly cciFileSplitPoint: () => number;
|
|
163
|
+
readonly cciSectorSize: () => number;
|
|
164
|
+
readonly cciSizingBatchSectors: () => number;
|
|
165
|
+
readonly chainMhtDigest: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
166
|
+
readonly cisoFilePaddingModulus: () => number;
|
|
167
|
+
readonly cisoFileSplitPoint: () => number;
|
|
168
|
+
readonly conversionsession_currentEntryName: (a: number, b: number) => void;
|
|
169
|
+
readonly conversionsession_hashNextPart: (a: number, b: number) => void;
|
|
170
|
+
readonly conversionsession_isDone: (a: number) => number;
|
|
171
|
+
readonly conversionsession_nextChunk: (a: number, b: number, c: number) => void;
|
|
172
|
+
readonly conversionsession_outputManifest: (a: number, b: number) => void;
|
|
173
|
+
readonly conversionsession_totalUnits: (a: number) => number;
|
|
174
|
+
readonly conversionsession_unitsDone: (a: number, b: number) => void;
|
|
175
|
+
readonly detectDirFormat: (a: number, b: number, c: number) => void;
|
|
176
|
+
readonly detectFormat: (a: number, b: number, c: number) => void;
|
|
177
|
+
readonly generateAttachXbe: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
178
|
+
readonly inspectSource: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
179
|
+
readonly isoRootOffsetCandidates: () => number;
|
|
180
|
+
readonly mhtSize: () => number;
|
|
181
|
+
readonly openConversionSession: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
182
|
+
readonly sourceinfo_contentType: (a: number, b: number) => void;
|
|
183
|
+
readonly sourceinfo_detectedTitle: (a: number, b: number) => void;
|
|
184
|
+
readonly sourceinfo_titleId: (a: number, b: number) => void;
|
|
185
|
+
readonly zarBlockSize: () => number;
|
|
186
|
+
readonly cisoSectorSize: () => number;
|
|
187
|
+
readonly cisoSizingBatchSectors: () => number;
|
|
188
|
+
readonly xisoSplitMargin: () => number;
|
|
189
|
+
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
190
|
+
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
191
|
+
readonly __wbindgen_export3: (a: number) => void;
|
|
192
|
+
readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
|
|
193
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
200
|
+
* a precompiled `WebAssembly.Module`.
|
|
201
|
+
*
|
|
202
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
203
|
+
*
|
|
204
|
+
* @returns {InitOutput}
|
|
205
|
+
*/
|
|
206
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
210
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
211
|
+
*
|
|
212
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
213
|
+
*
|
|
214
|
+
* @returns {Promise<InitOutput>}
|
|
215
|
+
*/
|
|
216
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|