autoangel 0.6.4 → 0.8.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/README.md +2 -2
- package/autoangel.d.ts +24 -4
- package/autoangel.js +162 -2
- package/autoangel_bg.wasm +0 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ npm install autoangel
|
|
|
13
13
|
### CDN
|
|
14
14
|
|
|
15
15
|
```js
|
|
16
|
-
import init, { ElementsData, PckPackage } from 'https://cdn.jsdelivr.net/npm/autoangel@0.
|
|
16
|
+
import init, { ElementsData, PckPackage } from 'https://cdn.jsdelivr.net/npm/autoangel@0.8.0/autoangel.js';
|
|
17
17
|
await init();
|
|
18
18
|
```
|
|
19
19
|
|
|
@@ -155,7 +155,7 @@ Full TypeScript definitions are included in the package (`autoangel.d.ts`).
|
|
|
155
155
|
|
|
156
156
|
## Live Demo
|
|
157
157
|
|
|
158
|
-
A browser-based PCK viewer built with this package is available at [smertig.github.io/
|
|
158
|
+
A browser-based PCK viewer built with this package is available at [smertig.github.io/autoangel-rs](https://smertig.github.io/autoangel-rs/master/viewer/).
|
|
159
159
|
|
|
160
160
|
## Development
|
|
161
161
|
|
package/autoangel.d.ts
CHANGED
|
@@ -39,7 +39,13 @@ export class ElementsData {
|
|
|
39
39
|
*/
|
|
40
40
|
getList(index: number): ElementsDataList;
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
42
|
+
* Open elements.data from an OPFS sync access handle (Web Worker only).
|
|
43
|
+
* The file is NOT loaded into memory — reads happen on demand.
|
|
44
|
+
* If `config` is not provided, the header is read to determine the version.
|
|
45
|
+
*/
|
|
46
|
+
static open(handle: FileSystemSyncAccessHandle, config?: ElementsConfig | null): ElementsData;
|
|
47
|
+
/**
|
|
48
|
+
* Parse elements.data from a byte array (loads entire file into WASM memory).
|
|
43
49
|
* If `config` is not provided, a bundled config is chosen based on the data version.
|
|
44
50
|
*/
|
|
45
51
|
static parse(bytes: Uint8Array, config?: ElementsConfig | null): ElementsData;
|
|
@@ -143,7 +149,16 @@ export class PckPackage {
|
|
|
143
149
|
*/
|
|
144
150
|
getFile(path: string): Uint8Array | undefined;
|
|
145
151
|
/**
|
|
146
|
-
*
|
|
152
|
+
* Open a pck package from an OPFS sync access handle (Web Worker only).
|
|
153
|
+
* The file is NOT loaded into memory — reads happen on demand.
|
|
154
|
+
*/
|
|
155
|
+
static open(handle: FileSystemSyncAccessHandle, config?: PackageConfig | null): PckPackage;
|
|
156
|
+
/**
|
|
157
|
+
* Open a pck+pkx pair from two OPFS sync access handles (Web Worker only).
|
|
158
|
+
*/
|
|
159
|
+
static open2(pck_handle: FileSystemSyncAccessHandle, pkx_handle: FileSystemSyncAccessHandle, config?: PackageConfig | null): PckPackage;
|
|
160
|
+
/**
|
|
161
|
+
* Parse a pck package from bytes (loads entire file into WASM memory).
|
|
147
162
|
*/
|
|
148
163
|
static parse(bytes: Uint8Array, config?: PackageConfig | null): PckPackage;
|
|
149
164
|
/**
|
|
@@ -170,6 +185,7 @@ export interface InitOutput {
|
|
|
170
185
|
readonly elementsdata_findEntry: (a: number, b: number) => number;
|
|
171
186
|
readonly elementsdata_getList: (a: number, b: number) => [number, number, number];
|
|
172
187
|
readonly elementsdata_listCount: (a: number) => number;
|
|
188
|
+
readonly elementsdata_open: (a: any, b: number) => [number, number, number];
|
|
173
189
|
readonly elementsdata_parse: (a: number, b: number, c: number) => [number, number, number];
|
|
174
190
|
readonly elementsdata_saveBytes: (a: number) => [number, number, number, number];
|
|
175
191
|
readonly elementsdata_version: (a: number) => number;
|
|
@@ -192,12 +208,16 @@ export interface InitOutput {
|
|
|
192
208
|
readonly pckpackage_fileList: (a: number) => [number, number];
|
|
193
209
|
readonly pckpackage_findPrefix: (a: number, b: number, c: number) => [number, number];
|
|
194
210
|
readonly pckpackage_getFile: (a: number, b: number, c: number) => [number, number];
|
|
211
|
+
readonly pckpackage_open: (a: any, b: number) => [number, number, number];
|
|
212
|
+
readonly pckpackage_open2: (a: any, b: any, c: number) => [number, number, number];
|
|
195
213
|
readonly pckpackage_parse: (a: number, b: number, c: number) => [number, number, number];
|
|
196
214
|
readonly pckpackage_version: (a: number) => number;
|
|
197
|
-
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
198
|
-
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
199
215
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
200
216
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
217
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
218
|
+
readonly __externref_table_alloc: () => number;
|
|
219
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
220
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
201
221
|
readonly __externref_table_dealloc: (a: number) => void;
|
|
202
222
|
readonly __externref_drop_slice: (a: number, b: number) => void;
|
|
203
223
|
readonly __wbindgen_start: () => void;
|
package/autoangel.js
CHANGED
|
@@ -114,7 +114,27 @@ export class ElementsData {
|
|
|
114
114
|
return ret >>> 0;
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
|
-
*
|
|
117
|
+
* Open elements.data from an OPFS sync access handle (Web Worker only).
|
|
118
|
+
* The file is NOT loaded into memory — reads happen on demand.
|
|
119
|
+
* If `config` is not provided, the header is read to determine the version.
|
|
120
|
+
* @param {FileSystemSyncAccessHandle} handle
|
|
121
|
+
* @param {ElementsConfig | null} [config]
|
|
122
|
+
* @returns {ElementsData}
|
|
123
|
+
*/
|
|
124
|
+
static open(handle, config) {
|
|
125
|
+
let ptr0 = 0;
|
|
126
|
+
if (!isLikeNone(config)) {
|
|
127
|
+
_assertClass(config, ElementsConfig);
|
|
128
|
+
ptr0 = config.__destroy_into_raw();
|
|
129
|
+
}
|
|
130
|
+
const ret = wasm.elementsdata_open(handle, ptr0);
|
|
131
|
+
if (ret[2]) {
|
|
132
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
133
|
+
}
|
|
134
|
+
return ElementsData.__wrap(ret[0]);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Parse elements.data from a byte array (loads entire file into WASM memory).
|
|
118
138
|
* If `config` is not provided, a bundled config is chosen based on the data version.
|
|
119
139
|
* @param {Uint8Array} bytes
|
|
120
140
|
* @param {ElementsConfig | null} [config]
|
|
@@ -434,7 +454,45 @@ export class PckPackage {
|
|
|
434
454
|
return v2;
|
|
435
455
|
}
|
|
436
456
|
/**
|
|
437
|
-
*
|
|
457
|
+
* Open a pck package from an OPFS sync access handle (Web Worker only).
|
|
458
|
+
* The file is NOT loaded into memory — reads happen on demand.
|
|
459
|
+
* @param {FileSystemSyncAccessHandle} handle
|
|
460
|
+
* @param {PackageConfig | null} [config]
|
|
461
|
+
* @returns {PckPackage}
|
|
462
|
+
*/
|
|
463
|
+
static open(handle, config) {
|
|
464
|
+
let ptr0 = 0;
|
|
465
|
+
if (!isLikeNone(config)) {
|
|
466
|
+
_assertClass(config, PackageConfig);
|
|
467
|
+
ptr0 = config.__destroy_into_raw();
|
|
468
|
+
}
|
|
469
|
+
const ret = wasm.pckpackage_open(handle, ptr0);
|
|
470
|
+
if (ret[2]) {
|
|
471
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
472
|
+
}
|
|
473
|
+
return PckPackage.__wrap(ret[0]);
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Open a pck+pkx pair from two OPFS sync access handles (Web Worker only).
|
|
477
|
+
* @param {FileSystemSyncAccessHandle} pck_handle
|
|
478
|
+
* @param {FileSystemSyncAccessHandle} pkx_handle
|
|
479
|
+
* @param {PackageConfig | null} [config]
|
|
480
|
+
* @returns {PckPackage}
|
|
481
|
+
*/
|
|
482
|
+
static open2(pck_handle, pkx_handle, config) {
|
|
483
|
+
let ptr0 = 0;
|
|
484
|
+
if (!isLikeNone(config)) {
|
|
485
|
+
_assertClass(config, PackageConfig);
|
|
486
|
+
ptr0 = config.__destroy_into_raw();
|
|
487
|
+
}
|
|
488
|
+
const ret = wasm.pckpackage_open2(pck_handle, pkx_handle, ptr0);
|
|
489
|
+
if (ret[2]) {
|
|
490
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
491
|
+
}
|
|
492
|
+
return PckPackage.__wrap(ret[0]);
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Parse a pck package from bytes (loads entire file into WASM memory).
|
|
438
496
|
* @param {Uint8Array} bytes
|
|
439
497
|
* @param {PackageConfig | null} [config]
|
|
440
498
|
* @returns {PckPackage}
|
|
@@ -471,20 +529,42 @@ function __wbg_get_imports() {
|
|
|
471
529
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
472
530
|
return ret;
|
|
473
531
|
},
|
|
532
|
+
__wbg___wbindgen_debug_string_dd5d2d07ce9e6c57: function(arg0, arg1) {
|
|
533
|
+
const ret = debugString(arg1);
|
|
534
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
535
|
+
const len1 = WASM_VECTOR_LEN;
|
|
536
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
537
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
538
|
+
},
|
|
474
539
|
__wbg___wbindgen_throw_81fc77679af83bc6: function(arg0, arg1) {
|
|
475
540
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
476
541
|
},
|
|
542
|
+
__wbg_getSize_6037025a1b5d08db: function() { return handleError(function (arg0) {
|
|
543
|
+
const ret = arg0.getSize();
|
|
544
|
+
return ret;
|
|
545
|
+
}, arguments); },
|
|
477
546
|
__wbg_length_0c32cb8543c8e4c8: function(arg0) {
|
|
478
547
|
const ret = arg0.length;
|
|
479
548
|
return ret;
|
|
480
549
|
},
|
|
550
|
+
__wbg_new_4f9fafbb3909af72: function() {
|
|
551
|
+
const ret = new Object();
|
|
552
|
+
return ret;
|
|
553
|
+
},
|
|
481
554
|
__wbg_new_with_length_9cedd08484b73942: function(arg0) {
|
|
482
555
|
const ret = new Uint8Array(arg0 >>> 0);
|
|
483
556
|
return ret;
|
|
484
557
|
},
|
|
558
|
+
__wbg_read_8569bf7e69cc3089: function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
559
|
+
const ret = arg0.read(getArrayU8FromWasm0(arg1, arg2), arg3);
|
|
560
|
+
return ret;
|
|
561
|
+
}, arguments); },
|
|
485
562
|
__wbg_set_16a9c1a07b3d38ec: function(arg0, arg1, arg2) {
|
|
486
563
|
arg0.set(getArrayU8FromWasm0(arg1, arg2));
|
|
487
564
|
},
|
|
565
|
+
__wbg_set_at_da2d1d4dc8ed37da: function(arg0, arg1) {
|
|
566
|
+
arg0.at = arg1;
|
|
567
|
+
},
|
|
488
568
|
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
489
569
|
// Cast intrinsic for `F64 -> Externref`.
|
|
490
570
|
const ret = arg0;
|
|
@@ -530,12 +610,83 @@ const PckPackageFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
530
610
|
? { register: () => {}, unregister: () => {} }
|
|
531
611
|
: new FinalizationRegistry(ptr => wasm.__wbg_pckpackage_free(ptr >>> 0, 1));
|
|
532
612
|
|
|
613
|
+
function addToExternrefTable0(obj) {
|
|
614
|
+
const idx = wasm.__externref_table_alloc();
|
|
615
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
616
|
+
return idx;
|
|
617
|
+
}
|
|
618
|
+
|
|
533
619
|
function _assertClass(instance, klass) {
|
|
534
620
|
if (!(instance instanceof klass)) {
|
|
535
621
|
throw new Error(`expected instance of ${klass.name}`);
|
|
536
622
|
}
|
|
537
623
|
}
|
|
538
624
|
|
|
625
|
+
function debugString(val) {
|
|
626
|
+
// primitive types
|
|
627
|
+
const type = typeof val;
|
|
628
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
629
|
+
return `${val}`;
|
|
630
|
+
}
|
|
631
|
+
if (type == 'string') {
|
|
632
|
+
return `"${val}"`;
|
|
633
|
+
}
|
|
634
|
+
if (type == 'symbol') {
|
|
635
|
+
const description = val.description;
|
|
636
|
+
if (description == null) {
|
|
637
|
+
return 'Symbol';
|
|
638
|
+
} else {
|
|
639
|
+
return `Symbol(${description})`;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
if (type == 'function') {
|
|
643
|
+
const name = val.name;
|
|
644
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
645
|
+
return `Function(${name})`;
|
|
646
|
+
} else {
|
|
647
|
+
return 'Function';
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
// objects
|
|
651
|
+
if (Array.isArray(val)) {
|
|
652
|
+
const length = val.length;
|
|
653
|
+
let debug = '[';
|
|
654
|
+
if (length > 0) {
|
|
655
|
+
debug += debugString(val[0]);
|
|
656
|
+
}
|
|
657
|
+
for(let i = 1; i < length; i++) {
|
|
658
|
+
debug += ', ' + debugString(val[i]);
|
|
659
|
+
}
|
|
660
|
+
debug += ']';
|
|
661
|
+
return debug;
|
|
662
|
+
}
|
|
663
|
+
// Test for built-in
|
|
664
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
665
|
+
let className;
|
|
666
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
667
|
+
className = builtInMatches[1];
|
|
668
|
+
} else {
|
|
669
|
+
// Failed to match the standard '[object ClassName]'
|
|
670
|
+
return toString.call(val);
|
|
671
|
+
}
|
|
672
|
+
if (className == 'Object') {
|
|
673
|
+
// we're a user defined class or Object
|
|
674
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
675
|
+
// easier than looping through ownProperties of `val`.
|
|
676
|
+
try {
|
|
677
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
678
|
+
} catch (_) {
|
|
679
|
+
return 'Object';
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
// errors
|
|
683
|
+
if (val instanceof Error) {
|
|
684
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
685
|
+
}
|
|
686
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
687
|
+
return className;
|
|
688
|
+
}
|
|
689
|
+
|
|
539
690
|
function getArrayJsValueFromWasm0(ptr, len) {
|
|
540
691
|
ptr = ptr >>> 0;
|
|
541
692
|
const mem = getDataViewMemory0();
|
|
@@ -573,6 +724,15 @@ function getUint8ArrayMemory0() {
|
|
|
573
724
|
return cachedUint8ArrayMemory0;
|
|
574
725
|
}
|
|
575
726
|
|
|
727
|
+
function handleError(f, args) {
|
|
728
|
+
try {
|
|
729
|
+
return f.apply(this, args);
|
|
730
|
+
} catch (e) {
|
|
731
|
+
const idx = addToExternrefTable0(e);
|
|
732
|
+
wasm.__wbindgen_exn_store(idx);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
|
|
576
736
|
function isLikeNone(x) {
|
|
577
737
|
return x === undefined || x === null;
|
|
578
738
|
}
|
package/autoangel_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
"Smertig <akaraevz@mail.ru>"
|
|
6
6
|
],
|
|
7
7
|
"description": "WASM bindings for Angelica Engine game file parsing",
|
|
8
|
-
"version": "0.
|
|
8
|
+
"version": "0.8.0",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
|
-
"url": "https://github.com/Smertig/
|
|
12
|
+
"url": "https://github.com/Smertig/autoangel-rs"
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
15
|
"autoangel_bg.wasm",
|