objdiff-wasm 3.0.0 → 3.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.
@@ -45,6 +45,14 @@ export interface DiffResult {
45
45
  left?: ObjectDiff,
46
46
  right?: ObjectDiff,
47
47
  }
48
+ /**
49
+ * # Variants
50
+ *
51
+ * ## `"target"`
52
+ *
53
+ * ## `"base"`
54
+ */
55
+ export type DiffSide = 'target' | 'base';
48
56
 
49
57
  export class DiffConfig {
50
58
  constructor()
@@ -57,7 +65,7 @@ export class Object {
57
65
  * This type does not have a public constructor.
58
66
  */
59
67
  private constructor();
60
- static parse(data: Uint8Array, config: DiffConfig): Object;
68
+ static parse(data: Uint8Array, config: DiffConfig, side: DiffSide): Object;
61
69
  hash(): bigint;
62
70
  }
63
71
 
Binary file
package/dist/objdiff.js CHANGED
@@ -76,7 +76,7 @@ function utf8Encode(s, realloc, memory) {
76
76
  let exports0;
77
77
  let exports1;
78
78
  let memory0;
79
- function trampoline3(arg0, arg1, arg2, arg3, arg4) {
79
+ function trampoline4(arg0, arg1, arg2, arg3, arg4) {
80
80
  let enum0;
81
81
  switch(arg0){
82
82
  case 0:
@@ -125,7 +125,7 @@ const handleTable0 = [
125
125
  ];
126
126
  const finalizationRegistry0 = finalizationRegistryCreate((handle)=>{
127
127
  const { rep } = rscTableRemove(handleTable0, handle);
128
- exports0['1'](rep);
128
+ exports0['3'](rep);
129
129
  });
130
130
  handleTables[0] = handleTable0;
131
131
  const trampoline0 = rscTableCreateOwn.bind(null, handleTable0);
@@ -139,16 +139,20 @@ const finalizationRegistry1 = finalizationRegistryCreate((handle)=>{
139
139
  });
140
140
  handleTables[1] = handleTable1;
141
141
  const trampoline1 = rscTableCreateOwn.bind(null, handleTable1);
142
+ function trampoline2(handle) {
143
+ const handleEntry = rscTableRemove(handleTable0, handle);
144
+ if (handleEntry.own) exports0['3'](handleEntry.rep);
145
+ }
142
146
  const handleTable2 = [
143
147
  T_FLAG,
144
148
  0
145
149
  ];
146
150
  const finalizationRegistry2 = finalizationRegistryCreate((handle)=>{
147
151
  const { rep } = rscTableRemove(handleTable2, handle);
148
- exports0['3'](rep);
152
+ exports0['1'](rep);
149
153
  });
150
154
  handleTables[2] = handleTable2;
151
- const trampoline2 = rscTableCreateOwn.bind(null, handleTable2);
155
+ const trampoline3 = rscTableCreateOwn.bind(null, handleTable2);
152
156
  let exports1Init;
153
157
  function init(arg0) {
154
158
  var val0 = arg0;
@@ -198,15 +202,15 @@ class DiffConfig {
198
202
  writable: true,
199
203
  value: handle1
200
204
  });
201
- finalizationRegistry1.register(rsc0, handle1, rsc0);
205
+ finalizationRegistry2.register(rsc0, handle1, rsc0);
202
206
  Object.defineProperty(rsc0, symbolDispose, {
203
207
  writable: true,
204
208
  value: function() {
205
- finalizationRegistry1.unregister(rsc0);
206
- rscTableRemove(handleTable1, handle1);
209
+ finalizationRegistry2.unregister(rsc0);
210
+ rscTableRemove(handleTable2, handle1);
207
211
  rsc0[symbolDispose] = emptyFunc;
208
212
  rsc0[symbolRscHandle] = void 0;
209
- exports0['2'](handleTable1[(handle1 << 1) + 1] & ~T_FLAG);
213
+ exports0['1'](handleTable2[(handle1 << 1) + 1] & ~T_FLAG);
210
214
  }
211
215
  });
212
216
  return rsc0;
@@ -215,8 +219,8 @@ class DiffConfig {
215
219
  let diffMethodDiffConfigSetProperty;
216
220
  DiffConfig.prototype.setProperty = function(arg1, arg2) {
217
221
  var handle1 = this[symbolRscHandle];
218
- if (!handle1 || (handleTable1[(handle1 << 1) + 1] & T_FLAG) === 0) throw new TypeError('Resource error: Not a valid "DiffConfig" resource.');
219
- var handle0 = handleTable1[(handle1 << 1) + 1] & ~T_FLAG;
222
+ if (!handle1 || (handleTable2[(handle1 << 1) + 1] & T_FLAG) === 0) throw new TypeError('Resource error: Not a valid "DiffConfig" resource.');
223
+ var handle0 = handleTable2[(handle1 << 1) + 1] & ~T_FLAG;
220
224
  var ptr2 = utf8Encode(arg1, realloc0, memory0);
221
225
  var len2 = utf8EncodedLen;
222
226
  var ptr3 = utf8Encode(arg2, realloc0, memory0);
@@ -250,8 +254,8 @@ DiffConfig.prototype.setProperty = function(arg1, arg2) {
250
254
  let diffMethodDiffConfigGetProperty;
251
255
  DiffConfig.prototype.getProperty = function(arg1) {
252
256
  var handle1 = this[symbolRscHandle];
253
- if (!handle1 || (handleTable1[(handle1 << 1) + 1] & T_FLAG) === 0) throw new TypeError('Resource error: Not a valid "DiffConfig" resource.');
254
- var handle0 = handleTable1[(handle1 << 1) + 1] & ~T_FLAG;
257
+ if (!handle1 || (handleTable2[(handle1 << 1) + 1] & T_FLAG) === 0) throw new TypeError('Resource error: Not a valid "DiffConfig" resource.');
258
+ var handle0 = handleTable2[(handle1 << 1) + 1] & ~T_FLAG;
255
259
  var ptr2 = utf8Encode(arg1, realloc0, memory0);
256
260
  var len2 = utf8EncodedLen;
257
261
  const ret = diffMethodDiffConfigGetProperty(handle0, ptr2, len2);
@@ -289,54 +293,67 @@ class Object$1 {
289
293
  throw new Error('"Object$1" resource does not define a constructor');
290
294
  }
291
295
  }
292
- Object$1.parse = function(arg0, arg1) {
296
+ Object$1.parse = function(arg0, arg1, arg2) {
293
297
  var val0 = arg0;
294
298
  var len0 = val0.byteLength;
295
299
  var ptr0 = realloc0(0, 0, 1, +len0);
296
300
  var src0 = new Uint8Array(val0.buffer || val0, val0.byteOffset, +len0);
297
301
  new Uint8Array(memory0.buffer, ptr0, +len0).set(src0);
298
302
  var handle2 = arg1[symbolRscHandle];
299
- if (!handle2 || (handleTable1[(handle2 << 1) + 1] & T_FLAG) === 0) throw new TypeError('Resource error: Not a valid "DiffConfig" resource.');
300
- var handle1 = handleTable1[(handle2 << 1) + 1] & ~T_FLAG;
301
- const ret = diffStaticObjectParse(ptr0, len0, handle1);
302
- let variant6;
303
+ if (!handle2 || (handleTable2[(handle2 << 1) + 1] & T_FLAG) === 0) throw new TypeError('Resource error: Not a valid "DiffConfig" resource.');
304
+ var handle1 = handleTable2[(handle2 << 1) + 1] & ~T_FLAG;
305
+ var val3 = arg2;
306
+ let enum3;
307
+ switch(val3){
308
+ case 'target':
309
+ enum3 = 0;
310
+ break;
311
+ case 'base':
312
+ enum3 = 1;
313
+ break;
314
+ default:
315
+ if (arg2 instanceof Error) console.error(arg2);
316
+ throw new TypeError(`"${val3}" is not one of the cases of diff-side`);
317
+ }
318
+ const ret = diffStaticObjectParse(ptr0, len0, handle1, enum3);
319
+ let variant7;
303
320
  switch(dataView(memory0).getUint8(ret + 0, true)){
304
321
  case 0:
305
- var handle4 = dataView(memory0).getInt32(ret + 4, true);
306
- var rsc3 = new.target === Object$1 ? this : Object.create(Object$1.prototype);
307
- Object.defineProperty(rsc3, symbolRscHandle, {
322
+ var handle5 = dataView(memory0).getInt32(ret + 4, true);
323
+ var rsc4 = new.target === Object$1 ? this : Object.create(Object$1.prototype);
324
+ Object.defineProperty(rsc4, symbolRscHandle, {
308
325
  writable: true,
309
- value: handle4
326
+ value: handle5
310
327
  });
311
- finalizationRegistry2.register(rsc3, handle4, rsc3);
312
- Object.defineProperty(rsc3, symbolDispose, {
328
+ finalizationRegistry1.register(rsc4, handle5, rsc4);
329
+ Object.defineProperty(rsc4, symbolDispose, {
313
330
  writable: true,
314
331
  value: function() {
315
- finalizationRegistry2.unregister(rsc3);
316
- rscTableRemove(handleTable2, handle4);
317
- rsc3[symbolDispose] = emptyFunc;
318
- rsc3[symbolRscHandle] = void 0;
319
- exports0['3'](handleTable2[(handle4 << 1) + 1] & ~T_FLAG);
332
+ finalizationRegistry1.unregister(rsc4);
333
+ rscTableRemove(handleTable1, handle5);
334
+ rsc4[symbolDispose] = emptyFunc;
335
+ rsc4[symbolRscHandle] = void 0;
336
+ exports0['2'](handleTable1[(handle5 << 1) + 1] & ~T_FLAG);
320
337
  }
321
338
  });
322
- variant6 = {
339
+ variant7 = {
323
340
  tag: 'ok',
324
- val: rsc3
341
+ val: rsc4
325
342
  };
326
343
  break;
327
344
  case 1:
328
- var ptr5 = dataView(memory0).getInt32(ret + 4, true);
329
- var len5 = dataView(memory0).getInt32(ret + 8, true);
330
- var result5 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr5, len5));
331
- variant6 = {
345
+ var ptr6 = dataView(memory0).getInt32(ret + 4, true);
346
+ var len6 = dataView(memory0).getInt32(ret + 8, true);
347
+ var result6 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr6, len6));
348
+ variant7 = {
332
349
  tag: 'err',
333
- val: result5
350
+ val: result6
334
351
  };
335
352
  break;
336
353
  default:
337
354
  throw new TypeError('invalid variant discriminant for expected');
338
355
  }
339
- const retVal = variant6;
356
+ const retVal = variant7;
340
357
  postReturn1(ret);
341
358
  if ('object' == typeof retVal && 'err' === retVal.tag) throw new ComponentError(retVal.val);
342
359
  return retVal.val;
@@ -344,8 +361,8 @@ Object$1.parse = function(arg0, arg1) {
344
361
  let diffMethodObjectHash;
345
362
  Object$1.prototype.hash = function() {
346
363
  var handle1 = this[symbolRscHandle];
347
- if (!handle1 || (handleTable2[(handle1 << 1) + 1] & T_FLAG) === 0) throw new TypeError('Resource error: Not a valid "Object" resource.');
348
- var handle0 = handleTable2[(handle1 << 1) + 1] & ~T_FLAG;
364
+ if (!handle1 || (handleTable1[(handle1 << 1) + 1] & T_FLAG) === 0) throw new TypeError('Resource error: Not a valid "Object" resource.');
365
+ var handle0 = handleTable1[(handle1 << 1) + 1] & ~T_FLAG;
349
366
  const ret = diffMethodObjectHash(handle0);
350
367
  return BigInt.asUintN(64, ret);
351
368
  };
@@ -637,8 +654,8 @@ function runDiff(arg0, arg1, arg2, arg3) {
637
654
  } else {
638
655
  const e = variant2;
639
656
  var handle1 = e[symbolRscHandle];
640
- if (!handle1 || (handleTable2[(handle1 << 1) + 1] & T_FLAG) === 0) throw new TypeError('Resource error: Not a valid "Object" resource.');
641
- var handle0 = handleTable2[(handle1 << 1) + 1] & ~T_FLAG;
657
+ if (!handle1 || (handleTable1[(handle1 << 1) + 1] & T_FLAG) === 0) throw new TypeError('Resource error: Not a valid "Object" resource.');
658
+ var handle0 = handleTable1[(handle1 << 1) + 1] & ~T_FLAG;
642
659
  variant2_0 = 1;
643
660
  variant2_1 = handle0;
644
661
  }
@@ -651,14 +668,14 @@ function runDiff(arg0, arg1, arg2, arg3) {
651
668
  } else {
652
669
  const e = variant5;
653
670
  var handle4 = e[symbolRscHandle];
654
- if (!handle4 || (handleTable2[(handle4 << 1) + 1] & T_FLAG) === 0) throw new TypeError('Resource error: Not a valid "Object" resource.');
655
- var handle3 = handleTable2[(handle4 << 1) + 1] & ~T_FLAG;
671
+ if (!handle4 || (handleTable1[(handle4 << 1) + 1] & T_FLAG) === 0) throw new TypeError('Resource error: Not a valid "Object" resource.');
672
+ var handle3 = handleTable1[(handle4 << 1) + 1] & ~T_FLAG;
656
673
  variant5_0 = 1;
657
674
  variant5_1 = handle3;
658
675
  }
659
676
  var handle7 = arg2[symbolRscHandle];
660
- if (!handle7 || (handleTable1[(handle7 << 1) + 1] & T_FLAG) === 0) throw new TypeError('Resource error: Not a valid "DiffConfig" resource.');
661
- var handle6 = handleTable1[(handle7 << 1) + 1] & ~T_FLAG;
677
+ if (!handle7 || (handleTable2[(handle7 << 1) + 1] & T_FLAG) === 0) throw new TypeError('Resource error: Not a valid "DiffConfig" resource.');
678
+ var handle6 = handleTable2[(handle7 << 1) + 1] & ~T_FLAG;
662
679
  var { mappings: v8_0, selectingLeft: v8_1, selectingRight: v8_2 } = arg3;
663
680
  var vec12 = v8_0;
664
681
  var len12 = vec12.length;
@@ -733,7 +750,7 @@ function runDiff(arg0, arg1, arg2, arg3) {
733
750
  rscTableRemove(handleTable0, handle18);
734
751
  rsc17[symbolDispose] = emptyFunc;
735
752
  rsc17[symbolRscHandle] = void 0;
736
- exports0['1'](handleTable0[(handle18 << 1) + 1] & ~T_FLAG);
753
+ exports0['3'](handleTable0[(handle18 << 1) + 1] & ~T_FLAG);
737
754
  }
738
755
  });
739
756
  variant19 = rsc17;
@@ -761,7 +778,7 @@ function runDiff(arg0, arg1, arg2, arg3) {
761
778
  rscTableRemove(handleTable0, handle21);
762
779
  rsc20[symbolDispose] = emptyFunc;
763
780
  rsc20[symbolRscHandle] = void 0;
764
- exports0['1'](handleTable0[(handle21 << 1) + 1] & ~T_FLAG);
781
+ exports0['3'](handleTable0[(handle21 << 1) + 1] & ~T_FLAG);
765
782
  }
766
783
  });
767
784
  variant22 = rsc20;
@@ -1029,8 +1046,8 @@ function displayInstructionRow(arg0, arg1, arg2, arg3) {
1029
1046
  if (!handle1 || (handleTable0[(handle1 << 1) + 1] & T_FLAG) === 0) throw new TypeError('Resource error: Not a valid "ObjectDiff" resource.');
1030
1047
  var handle0 = handleTable0[(handle1 << 1) + 1] & ~T_FLAG;
1031
1048
  var handle3 = arg3[symbolRscHandle];
1032
- if (!handle3 || (handleTable1[(handle3 << 1) + 1] & T_FLAG) === 0) throw new TypeError('Resource error: Not a valid "DiffConfig" resource.');
1033
- var handle2 = handleTable1[(handle3 << 1) + 1] & ~T_FLAG;
1049
+ if (!handle3 || (handleTable2[(handle3 << 1) + 1] & T_FLAG) === 0) throw new TypeError('Resource error: Not a valid "DiffConfig" resource.');
1050
+ var handle2 = handleTable2[(handle3 << 1) + 1] & ~T_FLAG;
1034
1051
  const ret = displayDisplayInstructionRow(handle0, toUint32(arg1), toUint32(arg2), handle2);
1035
1052
  var len12 = dataView(memory0).getInt32(ret + 4, true);
1036
1053
  var base12 = dataView(memory0).getInt32(ret + 0, true);
@@ -1381,8 +1398,8 @@ function instructionContext(arg0, arg1, arg2, arg3) {
1381
1398
  if (!handle1 || (handleTable0[(handle1 << 1) + 1] & T_FLAG) === 0) throw new TypeError('Resource error: Not a valid "ObjectDiff" resource.');
1382
1399
  var handle0 = handleTable0[(handle1 << 1) + 1] & ~T_FLAG;
1383
1400
  var handle3 = arg3[symbolRscHandle];
1384
- if (!handle3 || (handleTable1[(handle3 << 1) + 1] & T_FLAG) === 0) throw new TypeError('Resource error: Not a valid "DiffConfig" resource.');
1385
- var handle2 = handleTable1[(handle3 << 1) + 1] & ~T_FLAG;
1401
+ if (!handle3 || (handleTable2[(handle3 << 1) + 1] & T_FLAG) === 0) throw new TypeError('Resource error: Not a valid "DiffConfig" resource.');
1402
+ var handle2 = handleTable2[(handle3 << 1) + 1] & ~T_FLAG;
1386
1403
  const ret = displayInstructionContext(handle0, toUint32(arg1), toUint32(arg2), handle2);
1387
1404
  var len10 = dataView(memory0).getInt32(ret + 4, true);
1388
1405
  var base10 = dataView(memory0).getInt32(ret + 0, true);
@@ -1465,8 +1482,8 @@ function instructionHover(arg0, arg1, arg2, arg3) {
1465
1482
  if (!handle1 || (handleTable0[(handle1 << 1) + 1] & T_FLAG) === 0) throw new TypeError('Resource error: Not a valid "ObjectDiff" resource.');
1466
1483
  var handle0 = handleTable0[(handle1 << 1) + 1] & ~T_FLAG;
1467
1484
  var handle3 = arg3[symbolRscHandle];
1468
- if (!handle3 || (handleTable1[(handle3 << 1) + 1] & T_FLAG) === 0) throw new TypeError('Resource error: Not a valid "DiffConfig" resource.');
1469
- var handle2 = handleTable1[(handle3 << 1) + 1] & ~T_FLAG;
1485
+ if (!handle3 || (handleTable2[(handle3 << 1) + 1] & T_FLAG) === 0) throw new TypeError('Resource error: Not a valid "DiffConfig" resource.');
1486
+ var handle2 = handleTable2[(handle3 << 1) + 1] & ~T_FLAG;
1470
1487
  const ret = displayInstructionHover(handle0, toUint32(arg1), toUint32(arg2), handle2);
1471
1488
  var len8 = dataView(memory0).getInt32(ret + 4, true);
1472
1489
  var base8 = dataView(memory0).getInt32(ret + 0, true);
@@ -1530,13 +1547,14 @@ function instructionHover(arg0, arg1, arg2, arg3) {
1530
1547
  const $init = (()=>{
1531
1548
  let gen = function*() {
1532
1549
  const module0 = fetchCompile(new URL('./objdiff.core.wasm', import.meta.url));
1533
- const module1 = base64Compile('AGFzbQEAAAABDQJgAX8AYAV/f39/fwADBQQBAAAABAUBcAEEBAccBQEwAAABMQABATIAAgEzAAMIJGltcG9ydHMBAAoxBBEAIAAgASACIAMgBEEAEQEACwkAIABBAREAAAsJACAAQQIRAAALCQAgAEEDEQAACwAvCXByb2R1Y2VycwEMcHJvY2Vzc2VkLWJ5AQ13aXQtY29tcG9uZW50BzAuMjM0LjA');
1534
- const module2 = base64Compile('AGFzbQEAAAABDQJgAX8AYAV/f39/fwACJAUAATAAAQABMQAAAAEyAAAAATMAAAAIJGltcG9ydHMBcAEEBAkKAQBBAAsEAAECAwAvCXByb2R1Y2VycwEMcHJvY2Vzc2VkLWJ5AQ13aXQtY29tcG9uZW50BzAuMjM0LjA');
1550
+ const module1 = base64Compile('AGFzbQEAAAABDQJgAX8AYAV/f39/fwADBQQBAAAABAUBcAEEBAccBQEwAAABMQABATIAAgEzAAMIJGltcG9ydHMBAAoxBBEAIAAgASACIAMgBEEAEQEACwkAIABBAREAAAsJACAAQQIRAAALCQAgAEEDEQAACwAvCXByb2R1Y2VycwEMcHJvY2Vzc2VkLWJ5AQ13aXQtY29tcG9uZW50BzAuMjM3LjA');
1551
+ const module2 = base64Compile('AGFzbQEAAAABDQJgAX8AYAV/f39/fwACJAUAATAAAQABMQAAAAEyAAAAATMAAAAIJGltcG9ydHMBcAEEBAkKAQBBAAsEAAECAwAvCXByb2R1Y2VycwEMcHJvY2Vzc2VkLWJ5AQ13aXQtY29tcG9uZW50BzAuMjM3LjA');
1535
1552
  ({ exports: exports0 } = yield instantiateCore((yield module1)));
1536
1553
  ({ exports: exports1 } = yield instantiateCore((yield module0), {
1537
1554
  '[export]objdiff:core/diff': {
1538
- '[resource-new]diff-config': trampoline1,
1539
- '[resource-new]object': trampoline2,
1555
+ '[resource-drop]object-diff': trampoline2,
1556
+ '[resource-new]diff-config': trampoline3,
1557
+ '[resource-new]object': trampoline1,
1540
1558
  '[resource-new]object-diff': trampoline0
1541
1559
  },
1542
1560
  'wasi:logging/logging@0.1.0-draft': {
@@ -1547,10 +1565,10 @@ const $init = (()=>{
1547
1565
  ({ exports: exports2 } = yield instantiateCore((yield module2), {
1548
1566
  '': {
1549
1567
  $imports: exports0.$imports,
1550
- 0: trampoline3,
1551
- 1: exports1['objdiff:core/diff#[dtor]object-diff'],
1552
- 2: exports1['objdiff:core/diff#[dtor]diff-config'],
1553
- 3: exports1['objdiff:core/diff#[dtor]object']
1568
+ 0: trampoline4,
1569
+ 1: exports1['objdiff:core/diff#[dtor]diff-config'],
1570
+ 2: exports1['objdiff:core/diff#[dtor]object'],
1571
+ 3: exports1['objdiff:core/diff#[dtor]object-diff']
1554
1572
  }
1555
1573
  }));
1556
1574
  postReturn0 = exports1.cabi_post_version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "objdiff-wasm",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "A local diffing tool for decompilation projects.",
5
5
  "author": {
6
6
  "name": "Luke Street",
@@ -19,8 +19,8 @@
19
19
  "types": "dist/objdiff.d.ts",
20
20
  "scripts": {
21
21
  "build": "npm run build:wasm && npm run build:transpile && npm run build:lib",
22
- "build:wasm": "cargo +nightly -Zbuild-std=panic_abort,core,alloc -Zbuild-std-features=compiler-builtins-mem build --target wasm32-wasip2 --release --no-default-features",
23
- "build:transpile": "jco transpile ../target/wasm32-wasip2/release/objdiff_wasm.wasm --no-nodejs-compat --no-wasi-shim --no-namespaced-exports --map wasi:logging/logging=./wasi-logging.js --optimize -o pkg --name objdiff",
22
+ "build:wasm": "cargo build --profile release-min --no-default-features",
23
+ "build:transpile": "jco transpile ../target/wasm32-wasip2/release-min/objdiff_wasm.wasm --no-nodejs-compat --no-wasi-shim --no-namespaced-exports --map wasi:logging/logging=./wasi-logging.js --optimize -o pkg --name objdiff",
24
24
  "build:lib": "rslib build"
25
25
  },
26
26
  "devDependencies": {