objdiff-wasm 2.0.0-beta.8 → 2.0.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/main.d.ts CHANGED
@@ -620,98 +620,36 @@ interface DiffResult {
620
620
  */
621
621
  declare const DiffResult: DiffResult$Type;
622
622
 
623
- /**
624
- */
625
- declare enum ArmR9Usage {
626
- GeneralPurpose = 0,
627
- Sb = 1,
628
- Tr = 2,
629
- }
630
- /**
631
- */
632
- declare enum ArmArchVersion {
633
- Auto = 0,
634
- V4T = 1,
635
- V5TE = 2,
636
- V6K = 3,
637
- }
638
- /**
639
- */
640
- declare enum X86Formatter {
641
- Intel = 0,
642
- Gas = 1,
643
- Nasm = 2,
644
- Masm = 3,
645
- }
646
- /**
647
- */
648
- declare enum MipsAbi {
649
- Auto = 0,
650
- O32 = 1,
651
- N32 = 2,
652
- N64 = 3,
653
- }
654
- /**
655
- */
656
- declare enum MipsInstrCategory {
657
- Auto = 0,
658
- Cpu = 1,
659
- Rsp = 2,
660
- R3000Gte = 3,
661
- R4000Allegrex = 4,
662
- R5900 = 5,
663
- }
664
- /**
665
- */
666
- declare class DiffObjConfig$1 {
667
- free(): void;
668
- /**
669
- */
670
- arm_arch_version: ArmArchVersion;
671
- /**
672
- */
673
- arm_av_registers: boolean;
674
- /**
675
- */
676
- arm_fp_usage: boolean;
677
- /**
678
- */
679
- arm_ip_usage: boolean;
680
- /**
681
- */
682
- arm_r9_usage: ArmR9Usage;
683
- /**
684
- */
685
- arm_sl_usage: boolean;
686
- /**
687
- */
688
- arm_unified_syntax: boolean;
689
- /**
690
- */
691
- combine_data_sections: boolean;
692
- /**
693
- */
694
- mips_abi: MipsAbi;
695
- /**
696
- */
697
- mips_instr_category: MipsInstrCategory;
698
- /**
699
- */
700
- relax_reloc_diffs: boolean;
701
- /**
702
- */
703
- space_between_args: boolean;
704
- /**
705
- */
706
- x86_formatter: X86Formatter;
623
+ interface DiffObjConfig {
624
+ relax_reloc_diffs?: boolean;
625
+ space_between_args?: boolean;
626
+ combine_data_sections?: boolean;
627
+ x86_formatter?: X86Formatter;
628
+ mips_abi?: MipsAbi;
629
+ mips_instr_category?: MipsInstrCategory;
630
+ arm_arch_version?: ArmArchVersion;
631
+ arm_unified_syntax?: boolean;
632
+ arm_av_registers?: boolean;
633
+ arm_r9_usage?: ArmR9Usage;
634
+ arm_sl_usage?: boolean;
635
+ arm_fp_usage?: boolean;
636
+ arm_ip_usage?: boolean;
707
637
  }
708
638
 
709
- type DiffObjConfig = Omit<Partial<DiffObjConfig$1>, 'free'>;
639
+ type ArmR9Usage = "GeneralPurpose" | "Sb" | "Tr";
640
+
641
+ type ArmArchVersion = "Auto" | "V4T" | "V5TE" | "V6K";
642
+
643
+ type MipsInstrCategory = "Auto" | "Cpu" | "Rsp" | "R3000Gte" | "R4000Allegrex" | "R5900";
644
+
645
+ type MipsAbi = "Auto" | "O32" | "N32" | "N64";
646
+
647
+ type X86Formatter = "Intel" | "Gas" | "Nasm" | "Masm";
710
648
 
711
649
  declare function initialize(data?: {
712
650
  workerUrl?: string | URL;
713
651
  wasmUrl?: string | URL;
714
- }): Promise<void>;
652
+ }): Promise<Worker>;
715
653
  declare function runDiff(left: Uint8Array | undefined, right: Uint8Array | undefined, config?: DiffObjConfig): Promise<DiffResult>;
716
654
  type DiffText = DiffTextBasic | DiffTextBasicColor | DiffTextAddress | DiffTextLine | DiffTextOpcode | DiffTextArgument | DiffTextSymbol | DiffTextBranchDest | DiffTextSpacing;
717
655
  type DiffTextBase = {
@@ -755,11 +693,6 @@ type DiffTextSpacing = DiffTextBase & {
755
693
  type: 'spacing';
756
694
  count: number;
757
695
  };
758
- declare function oneof<T extends {
759
- oneofKind: string;
760
- }>(type: T): T & {
761
- oneofKind: string;
762
- };
763
696
  declare function displayDiff(diff: InstructionDiff, baseAddr: bigint, cb: (text: DiffText) => void): void;
764
697
 
765
- export { Argument, ArgumentDiff, ArgumentRelocation, ArgumentValue, ArmArchVersion, ArmR9Usage, DataDiff, DiffKind, type DiffObjConfig, DiffResult, type DiffText, type DiffTextAddress, type DiffTextArgument, type DiffTextBasic, type DiffTextBasicColor, type DiffTextBranchDest, type DiffTextLine, type DiffTextOpcode, type DiffTextSpacing, type DiffTextSymbol, FunctionDiff, Instruction, InstructionBranchFrom, InstructionBranchTo, InstructionDiff, MipsAbi, MipsInstrCategory, ObjectDiff, Relocation, RelocationTarget, SectionDiff, SectionKind, Symbol, SymbolFlag, X86Formatter, displayDiff, initialize, oneof, runDiff };
698
+ export { Argument, ArgumentDiff, ArgumentRelocation, ArgumentValue, type ArmArchVersion, type ArmR9Usage, DataDiff, DiffKind, type DiffObjConfig, DiffResult, type DiffText, type DiffTextAddress, type DiffTextArgument, type DiffTextBasic, type DiffTextBasicColor, type DiffTextBranchDest, type DiffTextLine, type DiffTextOpcode, type DiffTextSpacing, type DiffTextSymbol, FunctionDiff, Instruction, InstructionBranchFrom, InstructionBranchTo, InstructionDiff, type MipsAbi, type MipsInstrCategory, ObjectDiff, Relocation, RelocationTarget, SectionDiff, SectionKind, Symbol, SymbolFlag, type X86Formatter, displayDiff, initialize, runDiff };
package/dist/main.js CHANGED
@@ -1245,29 +1245,40 @@ var DiffResult = new DiffResult$Type();
1245
1245
 
1246
1246
  // src/main.ts
1247
1247
  var workerInit = false;
1248
- var workerCallbacks = null;
1248
+ var workerCallbacks;
1249
1249
  var workerReady = new Promise((resolve, reject) => {
1250
1250
  workerCallbacks = { start: performance.now(), resolve, reject };
1251
1251
  });
1252
1252
  async function initialize(data) {
1253
1253
  if (workerInit) {
1254
- return;
1254
+ return workerReady;
1255
1255
  }
1256
1256
  workerInit = true;
1257
1257
  let { workerUrl, wasmUrl } = data || {};
1258
1258
  if (!workerUrl) {
1259
- workerUrl = new URL("./worker.js", import.meta.url);
1259
+ try {
1260
+ workerUrl = new URL("./worker.js", import.meta.url);
1261
+ } catch (_) {
1262
+ workerUrl = "worker.js";
1263
+ }
1260
1264
  }
1261
1265
  if (!wasmUrl) {
1262
- wasmUrl = new URL("./objdiff_core_bg.wasm", import.meta.url);
1266
+ try {
1267
+ wasmUrl = new URL("./objdiff_core_bg.wasm", import.meta.url);
1268
+ } catch (_) {
1269
+ wasmUrl = "objdiff_core_bg.js";
1270
+ }
1263
1271
  }
1264
- const worker = new Worker(workerUrl, { type: "module" });
1272
+ const worker = new Worker(workerUrl, {
1273
+ name: "objdiff",
1274
+ type: "module"
1275
+ });
1265
1276
  worker.onmessage = onMessage;
1266
1277
  worker.onerror = (event) => {
1267
1278
  console.error("Worker error", event);
1268
- workerCallbacks.reject(event);
1279
+ workerCallbacks.reject("Worker failed to initialize, wrong URL?");
1269
1280
  };
1270
- await defer({
1281
+ defer({
1271
1282
  type: "init",
1272
1283
  // URL can't be sent directly
1273
1284
  wasmUrl: wasmUrl.toString()
@@ -1275,8 +1286,8 @@ async function initialize(data) {
1275
1286
  workerCallbacks.resolve(worker);
1276
1287
  }, (e) => {
1277
1288
  workerCallbacks.reject(e);
1278
- throw e;
1279
1289
  });
1290
+ return workerReady;
1280
1291
  }
1281
1292
  var globalMessageId = 0;
1282
1293
  var messageCallbacks = /* @__PURE__ */ new Map();
@@ -1302,12 +1313,7 @@ function onMessage(event) {
1302
1313
  }
1303
1314
  }
1304
1315
  async function defer(message, worker) {
1305
- if (worker == null) {
1306
- if (!workerInit) {
1307
- throw new Error("Worker not initialized");
1308
- }
1309
- worker = await workerReady;
1310
- }
1316
+ worker = worker || await initialize();
1311
1317
  const messageId = globalMessageId++;
1312
1318
  const promise = new Promise((resolve, reject) => {
1313
1319
  messageCallbacks.set(messageId, { start: performance.now(), resolve, reject });
@@ -1331,9 +1337,6 @@ async function runDiff(left, right, config) {
1331
1337
  console.debug(`Parsing message took ${end - parseStart}ms`);
1332
1338
  return result;
1333
1339
  }
1334
- function oneof(type) {
1335
- return type;
1336
- }
1337
1340
  function displayDiff(diff, baseAddr, cb) {
1338
1341
  const ins = diff.instruction;
1339
1342
  if (!ins) {
@@ -1353,7 +1356,7 @@ function displayDiff(diff, baseAddr, cb) {
1353
1356
  if (i === 0) {
1354
1357
  cb({ type: "spacing", count: 1 });
1355
1358
  }
1356
- const arg = oneof(ins.arguments[i].value);
1359
+ const arg = ins.arguments[i].value;
1357
1360
  const diff_index = diff.arg_diff[i]?.diff_index;
1358
1361
  switch (arg.oneofKind) {
1359
1362
  case "plain_text":
@@ -1402,7 +1405,6 @@ export {
1402
1405
  SymbolFlag,
1403
1406
  displayDiff,
1404
1407
  initialize,
1405
- oneof,
1406
1408
  runDiff
1407
1409
  };
1408
1410
  //# sourceMappingURL=main.js.map