discord-protos 1.0.1 → 1.0.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "discord-protos",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "A parser for Discord's protobufs",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -19,11 +19,15 @@
19
19
  ],
20
20
  "license": "MIT",
21
21
  "scripts": {
22
- "build": "pbjs -t static-module --keep-case -w commonjs -o src/proto.js out/*.proto && pbts -o src/proto.d.ts src/proto.js",
23
- "load": "node src/load.js",
24
- "test": "node src/test.js"
22
+ "py": "protoc --python_out=./ ./out/*.proto",
23
+ "js": "protoc --proto_path=./out/ --ts_out src/proto PreloadedUserSettings.proto FrecencyUserSettings.proto",
24
+ "build": "tsc",
25
+ "load": "yarn build && node dist/load.js",
26
+ "test": "yarn build && node dist/test.js"
25
27
  },
26
28
  "devDependencies": {
29
+ "@protobuf-ts/plugin": "^2.8.2",
30
+ "@protobuf-ts/protoc": "^2.8.2",
27
31
  "protobufjs-cli": "^1.1.1",
28
32
  "puppeteer": "^19.7.0",
29
33
  "typescript": "^4.9.5"
package/tsconfig.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
- "include": ["./src/**/index.js"],
3
- "exclude": ["./src/*.d.ts"],
4
2
  "compilerOptions": {
5
- "target": "es2016",
3
+ "target": "ES2020",
6
4
  "module": "commonjs",
7
5
  "allowJs": true,
8
6
  "declaration": true,
9
- "emitDeclarationOnly": true,
7
+ "outDir": "./dist",
8
+ "rootDir": "./src",
10
9
  }
11
10
  }
package/src/index.d.ts DELETED
@@ -1,31 +0,0 @@
1
- declare const _exports: {
2
- discord_users: typeof proto.discord_protos.discord_users;
3
- PreloadedUserSettings: typeof PreloadedUserSettings;
4
- FrecencyUserSettings: typeof FrecencyUserSettings;
5
- };
6
- export = _exports;
7
- import proto = require("./proto");
8
- declare class PreloadedUserSettings extends proto.discord_protos.discord_users.v1.PreloadedUserSettings.PreloadedUserSettings {
9
- /**
10
- * @param {proto.discord_protos.discord_users.v1.PreloadedUserSettings.IPreloadedUserSettings} data
11
- * @returns {string}
12
- */
13
- static toBase64(data: proto.discord_protos.discord_users.v1.PreloadedUserSettings.IPreloadedUserSettings): string;
14
- /**
15
- * @param {string} base64
16
- * @returns {proto.discord_protos.discord_users.v1.PreloadedUserSettings.PreloadedUserSettings}
17
- */
18
- static fromBase64(base64: string): proto.discord_protos.discord_users.v1.PreloadedUserSettings.PreloadedUserSettings;
19
- }
20
- declare class FrecencyUserSettings extends proto.discord_protos.discord_users.v1.FrecencyUserSettings.FrecencyUserSettings {
21
- /**
22
- * @param {proto.discord_protos.discord_users.v1.FrecencyUserSettings.IFrecencyUserSettings} data
23
- * @returns {string}
24
- */
25
- static toBase64(data: proto.discord_protos.discord_users.v1.FrecencyUserSettings.IFrecencyUserSettings): string;
26
- /**
27
- * @param {string} base64
28
- * @returns {proto.discord_protos.discord_users.v1.FrecencyUserSettings.FrecencyUserSettings}
29
- */
30
- static fromBase64(base64: string): proto.discord_protos.discord_users.v1.FrecencyUserSettings.FrecencyUserSettings;
31
- }
package/src/index.js DELETED
@@ -1,51 +0,0 @@
1
- const proto = require("./proto");
2
-
3
- function toBase64(data) {
4
- return Buffer.from(this.encode(data).finish()).toString("base64");
5
- }
6
-
7
- function fromBase64(base64) {
8
- return this.decode(Buffer.from(base64, "base64")).toJSON();
9
- }
10
-
11
- class PreloadedUserSettings extends proto.discord_protos.discord_users.v1.PreloadedUserSettings.PreloadedUserSettings {
12
- /**
13
- * @param {proto.discord_protos.discord_users.v1.PreloadedUserSettings.IPreloadedUserSettings} data
14
- * @returns {string}
15
- */
16
- static toBase64(data) {
17
- return toBase64.call(this, data);
18
- }
19
-
20
- /**
21
- * @param {string} base64
22
- * @returns {proto.discord_protos.discord_users.v1.PreloadedUserSettings.PreloadedUserSettings}
23
- */
24
- static fromBase64(base64) {
25
- return fromBase64.call(this, base64);
26
- }
27
- }
28
-
29
- class FrecencyUserSettings extends proto.discord_protos.discord_users.v1.FrecencyUserSettings.FrecencyUserSettings {
30
- /**
31
- * @param {proto.discord_protos.discord_users.v1.FrecencyUserSettings.IFrecencyUserSettings} data
32
- * @returns {string}
33
- */
34
- static toBase64(data) {
35
- return toBase64.call(this, data);
36
- }
37
-
38
- /**
39
- * @param {string} base64
40
- * @returns {proto.discord_protos.discord_users.v1.FrecencyUserSettings.FrecencyUserSettings}
41
- */
42
- static fromBase64(base64) {
43
- return fromBase64.call(this, base64);
44
- }
45
- }
46
-
47
- module.exports = {
48
- PreloadedUserSettings,
49
- FrecencyUserSettings,
50
- ...proto.discord_protos,
51
- };
package/src/load.js DELETED
@@ -1,26 +0,0 @@
1
- const puppeteer = require("puppeteer");
2
- const fs = require("fs");
3
- const { join } = require("path");
4
- const script = fs.readFileSync(join(__dirname, "parse.js"), "utf8");
5
-
6
- async function main() {
7
- const browser = await puppeteer.launch({
8
- headless: true,
9
- });
10
-
11
- const page = await browser.newPage();
12
- await page.goto("https://discord.com/app", { waitUntil: "networkidle0" });
13
-
14
- const protos = await page.evaluate(`${script}; protos`);
15
-
16
- for (const [name, proto] of Object.entries(protos)) {
17
- fs.writeFileSync(
18
- join(__dirname, "..", "out", name + ".proto"),
19
- proto.data,
20
- );
21
- }
22
-
23
- await browser.close();
24
- }
25
-
26
- main();