Skip to content

Commit eb8abd2

Browse files
committed
refactor: drop webgl-constants dep, inline the 9 values we use
webgl-constants only got us minifier-friendly WebGL enum literals (`34962` etc.) instead of property accesses on the `gl` context. We use exactly 9 of them, inside calculateMagicPixelId. Inlining as module-local `const` declarations yields the same inlinable literals without a runtime dep — the Khronos spec URL in the leading comment pins the values. Bundle: 7.97 kB → 7.65 kB (gzip 3.68 kB → 3.61 kB).
1 parent ab79f54 commit eb8abd2

3 files changed

Lines changed: 14 additions & 26 deletions

File tree

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@
6060
"build": "tsdown",
6161
"update-benchmarks": "node ./scripts/update_benchmarks.ts"
6262
},
63-
"dependencies": {
64-
"webgl-constants": "^1.1.1"
65-
},
6663
"devDependencies": {
6764
"@types/node": "^25.6.0",
6865
"@types/tar": "^7.0.87",

pnpm-lock.yaml

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/internal/deobfuscateAppleGPU.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
// Vendor
2-
import {
3-
GL_ARRAY_BUFFER,
4-
GL_COLOR_BUFFER_BIT,
5-
GL_FLOAT,
6-
GL_FRAGMENT_SHADER,
7-
GL_RGBA,
8-
GL_STATIC_DRAW,
9-
GL_TRIANGLES,
10-
GL_UNSIGNED_BYTE,
11-
GL_VERTEX_SHADER,
12-
} from 'webgl-constants';
13-
14-
// Internal
151
import { deviceInfo } from './deviceInfo';
162

3+
// WebGL enum values, inlined to avoid a dep on `webgl-constants`. Same
4+
// numbers as `gl.ARRAY_BUFFER` etc., which minifiers can't fold because
5+
// they're property accesses. SEE:
6+
// https://registry.khronos.org/webgl/specs/latest/1.0/#5.14
7+
const GL_ARRAY_BUFFER = 0x8892;
8+
const GL_COLOR_BUFFER_BIT = 0x4000;
9+
const GL_FLOAT = 0x1406;
10+
const GL_FRAGMENT_SHADER = 0x8b30;
11+
const GL_RGBA = 0x1908;
12+
const GL_STATIC_DRAW = 0x88e4;
13+
const GL_TRIANGLES = 0x0004;
14+
const GL_UNSIGNED_BYTE = 0x1401;
15+
const GL_VERTEX_SHADER = 0x8b31;
16+
1717
const debug = false ? console.warn : undefined;
1818

1919
export function deobfuscateAppleGPU(

0 commit comments

Comments
 (0)