Skip to content

Commit

Permalink
chore: Updated modules id
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Sep 28, 2021
1 parent d3bec6f commit 851e0e7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/tools/updateModuleID.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async function start() {
}
const resultName = dir ? `${dir}.${name}` : name;

result[resultName] = (module as any).__wa_id;
result[resultName] = window.WPP.whatsapp._moduleIdMap.get(module);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/whatsapp/enums/SendMsgResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { exportModule } from '../exportModule';

/**
* @whatsapp 2.2134.10:88300
* @whatsapp 2.2136.10:88300
*/
export declare enum SendMsgResult {
OK = 'OK',
Expand Down
10 changes: 5 additions & 5 deletions src/whatsapp/exportModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

import * as webpack from '../webpack';

const moduleIdMap = new WeakMap<any, string>();

export const _moduleIdMap = moduleIdMap;

/**
* The object of this function is to override the exports to create getters.
*
Expand Down Expand Up @@ -82,11 +86,7 @@ export function exportModule(
});

try {
// Hidden property to get ID
Object.defineProperty(value, '__wa_id', {
get: () => moduleId,
enumerable: false,
});
moduleIdMap.set(value, moduleId);
} catch (error) {}
}

Expand Down
1 change: 1 addition & 0 deletions src/whatsapp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

export * from './collections';
export * as enums from './enums';
export { _moduleIdMap } from './exportModule';
export * as functions from './functions';
export * from './misc';
export * from './models';
Expand Down

0 comments on commit 851e0e7

Please sign in to comment.