Compare commits

...
Sign in to create a new pull request.

24 commits
main ... bun

Author SHA1 Message Date
thororen1234
b42e06d12d
Merge branch 'dev' into bun
All checks were successful
Build Branches / Build Equicord (push) Has been skipped
2026-05-07 11:55:46 -04:00
thororen1234
480110a285
Update bun.lock 2026-05-07 11:29:44 -04:00
thororen1234
86528e30f7
Merge branch 'dev' into bun 2026-05-07 11:29:24 -04:00
thororen1234
66991c826f
Merge branch 'dev' into bun 2026-04-10 07:46:44 -04:00
thororen1234
f5e5b12876
Merge branch 'dev' into bun 2026-04-09 18:13:01 -04:00
thororen1234
cca3a14fd3
Merge branch 'dev' into bun 2026-03-06 21:16:34 -05:00
thororen1234
0ec0d1e4fb
Merge branch 'dev' into bun 2026-03-02 17:28:06 -05:00
thororen1234
59a440c964
Update bun.lock 2026-03-02 17:25:11 -05:00
thororen1234
3f5be2f949
Merge branch 'dev' into bun 2026-03-02 17:25:09 -05:00
thororen1234
aad290c9a3
Merge branch 'dev' into bun 2026-02-26 11:37:40 -05:00
prism
faf400acf3
migrate to bun (#781) 2026-02-18 17:21:01 -05:00
thororen1234
022e2a7a37
Merge branch 'dev' into bun 2026-02-15 09:35:04 -05:00
thororen1234
8e0315ac2a
Merge branch 'dev' into bun 2026-02-15 09:29:42 -05:00
thororen1234
bd92fb79d5
Merge branch 'dev' into bun 2026-02-11 18:17:12 -05:00
thororen1234
585dd82dc1
Merge branch 'dev' into bun 2025-12-31 21:35:12 -05:00
thororen1234
58e886a884
Merge branch 'dev' into bun 2025-12-16 23:58:42 -05:00
thororen1234
f656dc2612
Merge branch 'dev' into bun 2025-12-16 23:43:06 -05:00
thororen1234
d0212642d2
Merge branch 'dev' into bun 2025-10-29 16:36:35 -04:00
thororen1234
c7a0b23ad2
Update Install Instructions 2025-10-24 23:54:41 -04:00
thororen1234
4348c4b4e6
Update Package Link 2025-10-24 23:52:42 -04:00
thororen1234
f300928aa8
rename types 2025-10-24 23:40:51 -04:00
thororen1234
3a6f4713e3
Merge branch 'dev' into bun 2025-10-24 23:40:46 -04:00
thororen1234
b415877b2f
Merge branch 'dev' into bun 2025-06-09 22:12:04 -04:00
Creation's
fbd1d1b551
Move everything away from pnpm and use bun (#278)
* testing bun migration

* e

* try no node

* test noxos

* reporter?

* reporter2

* Fix Patches

* change readme(s)

* make readme simpler

* bleh

---------

Co-authored-by: thororen1234 <78185467+thororen1234@users.noreply.github.com>
2025-06-04 11:17:57 -04:00
30 changed files with 1683 additions and 6203 deletions

View file

@ -17,56 +17,43 @@ jobs:
Build: Build:
name: Build Equicord name: Build Equicord
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- uses: pnpm/action-setup@v6
- name: Use Node.js 24
uses: actions/setup-node@v6
with: with:
node-version: 24 bun-version: latest
cache: "pnpm"
- name: Install dependencies - name: Install dependencies
run: pnpm install --frozen-lockfile run: bun install
- name: Build web - name: Build web
run: pnpm buildWebStandalone run: bun run buildWebStandalone
- name: Build - name: Build
run: pnpm buildStandalone run: bun run buildStandalone
- name: Generate plugin lists - name: Generate plugin lists
run: | run: |
pnpm generatePluginJson dist/plugins.json bun run generatePluginJson dist/plugins.json
pnpm generateEquicordPluginJson dist/equicordplugins.json bun run generateEquicordPluginJson dist/equicordplugins.json
pnpm generateVencordPluginJson dist/vencordplugins.json bun run generateVencordPluginJson dist/vencordplugins.json
pnpm generateDevsList dist/devs.json bun run generateDevsList dist/devs.json
- name: Collect files to be released - name: Collect files to be released
run: | run: |
cd dist cd dist
mkdir release mkdir release
cp browser/browser.* release cp browser/browser.* release
cp Equicord.user.{js,js.LEGAL.txt} release cp Equicord.user.{js,js.LEGAL.txt} release
# copy the plugin data jsons, the extension zips and the desktop/equibop asars # copy the plugin data jsons, the extension zips and the desktop/equibop asars
cp *.{json,zip,asar} release cp *.{json,zip,asar} release
# legacy un-asared files # legacy un-asared files
cp desktop/* release cp desktop/* release
for file in equibop/*; do for file in equibop/*; do
filename=$(basename "$file") filename=$(basename "$file")
cp "$file" "release/equibop${filename^}" cp "$file" "release/equibop${filename^}"
done done
find release -size 0 -delete find release -size 0 -delete
rm release/package.json rm release/package.json
rm release/*.map rm release/*.map
- name: Upload Equicord Stable - name: Upload Equicord Stable
if: ${{ vars.ACT == 'false' }} if: ${{ vars.ACT == 'false' }}
run: | run: |
@ -83,6 +70,5 @@ jobs:
cp ../dist/release/*plugins.json . cp ../dist/release/*plugins.json .
cp ../dist/release/devs.json . cp ../dist/release/devs.json .
git add -A git add -A
git commit -m "Plugins for https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA" git commit -m "Plugins for https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA"
git push --force https://$USERNAME:$GITHUB_TOKEN@github.com/$REPO.git git push --force https://$USERNAME:$GITHUB_TOKEN@github.com/$REPO.git

View file

@ -16,58 +16,45 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- uses: pnpm/action-setup@v6
- name: Use Node.js 24
uses: actions/setup-node@v6
with: with:
node-version: 24 bun-version: latest
cache: "pnpm"
- name: Install dependencies - name: Install dependencies
run: pnpm install --frozen-lockfile run: bun install
- name: Build web - name: Build web
run: pnpm buildWebStandalone run: bun run buildWebStandalone
- name: Build - name: Build
run: pnpm buildStandalone run: bun run buildStandalone
- name: Generate plugin lists - name: Generate plugin lists
run: | run: |
pnpm generatePluginJson dist/plugins.json bun run generatePluginJson dist/plugins.json
pnpm generateEquicordPluginJson dist/equicordplugins.json bun run generateEquicordPluginJson dist/equicordplugins.json
pnpm generateVencordPluginJson dist/vencordplugins.json bun run generateVencordPluginJson dist/vencordplugins.json
pnpm generateDevsList dist/devs.json bun run generateDevsList dist/devs.json
- name: Collect files to be released - name: Collect files to be released
run: | run: |
cd dist cd dist
mkdir release mkdir release
cp browser/browser.* release cp browser/browser.* release
cp Equicord.user.{js,js.LEGAL.txt} release cp Equicord.user.{js,js.LEGAL.txt} release
# copy the plugin data jsons, the extension zips and the desktop/equibop asars # copy the plugin data jsons, the extension zips and the desktop/equibop asars
cp *.{json,zip,asar} release cp *.{json,zip,asar} release
# legacy un-asared files # legacy un-asared files
cp desktop/* release cp desktop/* release
for file in equibop/*; do for file in equibop/*; do
filename=$(basename "$file") filename=$(basename "$file")
cp "$file" "release/equibop${filename^}" cp "$file" "release/equibop${filename^}"
done done
find release -size 0 -delete find release -size 0 -delete
rm release/package.json rm release/package.json
rm release/*.map rm release/*.map
- name: Get current date - name: Get current date
id: date id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')" run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Upload Equicord Stable - name: Upload Equicord Stable
if: ${{ vars.ACT == 'false' }} if: ${{ vars.ACT == 'false' }}
run: | run: |

View file

@ -58,24 +58,19 @@ jobs:
with: with:
tag_prefix: "v" tag_prefix: "v"
- name: Setup PNPM - name: Setup Bun
if: steps.check.outputs.release == 'true' if: steps.check.outputs.release == 'true'
uses: pnpm/action-setup@v6 uses: oven-sh/setup-bun@v2
- name: Use Node.js 24
if: steps.check.outputs.release == 'true'
uses: actions/setup-node@v6
with: with:
node-version: 24 bun-version: latest
cache: "pnpm"
- name: Install dependencies - name: Install dependencies
if: steps.check.outputs.release == 'true' if: steps.check.outputs.release == 'true'
run: pnpm install --frozen-lockfile run: bun install --frozen-lockfile
- name: Build web - name: Build web
if: steps.check.outputs.release == 'true' if: steps.check.outputs.release == 'true'
run: pnpm buildWebStandalone run: bun run buildWebStandalone
- name: Create sources zip - name: Create sources zip
if: steps.check.outputs.release == 'true' if: steps.check.outputs.release == 'true'
@ -84,7 +79,7 @@ jobs:
- name: Publish extension - name: Publish extension
if: steps.check.outputs.release == 'true' && !vars.ACT == 'false' if: steps.check.outputs.release == 'true' && !vars.ACT == 'false'
run: pnpx @equicord/publish-browser-extension@latest --chrome-zip run: bunx @equicord/publish-browser-extension@latest --chrome-zip
dist/extension-chrome.zip --firefox-zip dist/extension-chrome.zip --firefox-zip
dist/extension-firefox.zip --firefox-sources-zip dist/extension-firefox.zip --firefox-sources-zip
dist/extension-sources.zip --edge-zip dist/extension-sources.zip --edge-zip

View file

@ -33,28 +33,24 @@ jobs:
with: with:
ref: ${{ github.event_name == 'schedule' && 'dev' || github.ref }} ref: ${{ github.event_name == 'schedule' && 'dev' || github.ref }}
- uses: pnpm/action-setup@v6 # Install pnpm using packageManager key in package.json - uses: oven-sh/setup-bun@v2
- name: Use Node.js 24
uses: actions/setup-node@v6
with: with:
node-version: 24 bun-version: latest
cache: "pnpm"
- name: Install dependencies - name: Install dependencies
run: | run: |
pnpm install --frozen-lockfile --prefer-offline bun install
- name: Build Equicord Reporter Version - name: Build Equicord Reporter Version
run: pnpm buildReporter run: bun run buildReporter
- name: Run Reporter - name: Run Reporter
timeout-minutes: 10 timeout-minutes: 10
run: | run: |
export PATH="$PWD/node_modules/.bin:$PATH"
export CHROMIUM_BIN=/usr/bin/google-chrome export CHROMIUM_BIN=/usr/bin/google-chrome
esbuild scripts/generateReport.ts > dist/report.mjs bun build scripts/generateReport.ts --outfile dist/report.mjs --target bun
stable_output_file=$(mktemp) stable_output_file=$(mktemp)
canary_output_file=$(mktemp) canary_output_file=$(mktemp)
@ -67,12 +63,12 @@ jobs:
fi fi
if [[ "$branch" = "both" || "$branch" = "stable" ]]; then if [[ "$branch" = "both" || "$branch" = "stable" ]]; then
node dist/report.mjs > "$stable_output_file" & bun run dist/report.mjs > "$stable_output_file" &
pids+=" $!" pids+=" $!"
fi fi
if [[ "$branch" = "both" || "$branch" = "canary" ]]; then if [[ "$branch" = "both" || "$branch" = "canary" ]]; then
USE_CANARY=true node dist/report.mjs > "$canary_output_file" & USE_CANARY=true bun run dist/report.mjs > "$canary_output_file" &
pids+=" $!" pids+=" $!"
fi fi

View file

@ -8,30 +8,20 @@ on:
branches: branches:
- main - main
- dev - dev
jobs: jobs:
Test: Test:
name: Test name: Test
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@v4
- uses: pnpm/action-setup@v6 # Install pnpm using packageManager key in package.json - uses: oven-sh/setup-bun@v2
- name: Use Node.js 24
uses: actions/setup-node@v6
with: with:
node-version: 24 bun-version: latest
cache: "pnpm"
- name: Install dependencies - name: Install dependencies
run: pnpm install --frozen-lockfile run: bun install
- name: Lint & Test if desktop version compiles - name: Lint & Test if desktop version compiles
run: pnpm test run: bun run test
- name: Test if web version compiles - name: Test if web version compiles
run: pnpm buildWeb run: bun run buildWeb
- name: Test if plugin structure is valid - name: Test if plugin structure is valid
run: pnpm generatePluginJson run: bun run generatePluginJson

3
.gitignore vendored
View file

@ -13,15 +13,14 @@ equicord_installer
.DS_Store .DS_Store
yarn.lock yarn.lock
bun.lock
package-lock.json package-lock.json
pnpm-lock.yaml
*.log *.log
npm-debug.log* npm-debug.log*
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*
lerna-debug.log* lerna-debug.log*
.pnpm-debug.log*
*.tsbuildinfo *.tsbuildinfo
.modules/ .modules/

2
.npmrc
View file

@ -1,2 +0,0 @@
strict-peer-dependencies=false
package-manager-strict=false

27
.vscode/tasks.json vendored
View file

@ -6,7 +6,7 @@
{ {
"label": "Build", "label": "Build",
"type": "shell", "type": "shell",
"command": "pnpm build", "command": "bun run build",
"group": { "group": {
"kind": "build", "kind": "build",
"isDefault": true "isDefault": true
@ -16,7 +16,7 @@
// for use with the vencord companion extension // for use with the vencord companion extension
"label": "Build Companion Reporter", "label": "Build Companion Reporter",
"type": "shell", "type": "shell",
"command": "pnpm build --dev --reporter --companion-test", "command": "bun run build --dev --reporter --companion-test",
"presentation": { "presentation": {
"echo": true, "echo": true,
"reveal": "silent", "reveal": "silent",
@ -28,32 +28,13 @@
{ {
"label": "Build Dev", "label": "Build Dev",
"type": "shell", "type": "shell",
"command": "pnpm build --dev", "command": "bun run build --dev",
"group": "build"
},
{
// for use with the vencord companion extension
"label": "Build Companion Reporter",
"type": "shell",
"command": "pnpm build --dev --reporter --companion-test",
"presentation": {
"echo": true,
"reveal": "silent",
"panel": "shared",
"showReuseMessage": true,
"clear": true
}
},
{
"label": "Build Dev",
"type": "shell",
"command": "pnpm build --dev",
"group": "build" "group": "build"
}, },
{ {
"label": "Watch", "label": "Watch",
"type": "shell", "type": "shell",
"command": "pnpm watch", "command": "bun run watch",
"problemMatcher": [], "problemMatcher": [],
"group": { "group": {
"kind": "build" "kind": "build"

View file

@ -37,15 +37,10 @@ sh -c "$(curl -sS https://raw.githubusercontent.com/Equicord/Equicord/refs/heads
### Dependencies ### Dependencies
[Git](https://git-scm.com/download) and [Node.JS LTS](https://nodejs.dev/en/) are required. [Git](https://git-scm.com/download) and [Bun](https://bun.sh/docs/installation) are required.
Install `pnpm`: Install Bun:
> :exclamation: This next command may need to be run as admin/root depending on your system, and you may need to close and reopen your terminal for Bun to be in your PATH.
> :exclamation: This next command may need to be run as admin/root depending on your system, and you may need to close and reopen your terminal for pnpm to be in your PATH.
```shell
npm i -g pnpm
```
> :exclamation: **IMPORTANT** Make sure you aren't using an admin/root terminal from here onwards. It **will** mess up your Discord/Equicord instance and you **will** most likely have to reinstall. > :exclamation: **IMPORTANT** Make sure you aren't using an admin/root terminal from here onwards. It **will** mess up your Discord/Equicord instance and you **will** most likely have to reinstall.
@ -59,25 +54,32 @@ cd Equicord
Install dependencies: Install dependencies:
```shell ```shell
pnpm install --frozen-lockfile cd packages/vencord-types
bun link @vencord/types
cd ../discord-types
bun link @vencord/discord-types
cd ../..
bun install
``` ```
Build Equicord: Build Equicord:
```shell ```shell
pnpm build bun run build
``` ```
Inject Equicord into your desktop client: Inject Equicord into your desktop client:
```shell ```shell
pnpm inject bun run inject
``` ```
Build Equicord for web: Build Equicord for web:
```shell ```shell
pnpm buildWeb bun run buildWeb
``` ```
After building Equicord's web extension, locate the appropriate ZIP file in the `dist` directory and follow your browser’s guide for installing custom extensions, if supported. After building Equicord's web extension, locate the appropriate ZIP file in the `dist` directory and follow your browser’s guide for installing custom extensions, if supported.

1408
bun.lock Normal file

File diff suppressed because it is too large Load diff

View file

@ -13,31 +13,36 @@
}, },
"license": "GPL-3.0-or-later", "license": "GPL-3.0-or-later",
"author": "Equicord", "author": "Equicord",
"workspaces": [
"packages/discord-types",
"packages/vencord-types"
],
"scripts": { "scripts": {
"build": "pnpm depCheck && node --require=./scripts/suppressExperimentalWarnings.js scripts/build/build.mjs", "build": "bun run depCheck && bun run scripts/build/build.mjs",
"buildStandalone": "pnpm build --standalone", "buildStandalone": "bun run build --standalone",
"buildWeb": "pnpm depCheck && node --require=./scripts/suppressExperimentalWarnings.js scripts/build/buildWeb.mjs", "buildWeb": "bun run depCheck && bun run scripts/build/buildWeb.mjs",
"buildWebStandalone": "pnpm buildWeb --standalone", "buildWebStandalone": "bun run buildWeb --standalone",
"buildReporter": "pnpm buildWebStandalone --reporter --skip-extension", "buildReporter": "bun run buildWebStandalone --reporter --skip-extension",
"buildReporterDesktop": "pnpm build --reporter", "buildReporterDesktop": "bun run build --reporter",
"watch": "pnpm build --watch", "watch": "bun run build --watch",
"dev": "pnpm watch", "dev": "bun run watch",
"watchWeb": "pnpm buildWeb --watch", "watchWeb": "bun run buildWeb --watch",
"generateDevsList": "tsx scripts/generateDevsList.ts", "generateDevsList": "bun run scripts/generateDevsList.ts",
"generatePluginJson": "tsx scripts/generatePluginList.ts", "generatePluginJson": "bun run scripts/generatePluginList.ts",
"generateEquicordPluginJson": "tsx scripts/generatePluginList.ts --equicord", "generateEquicordPluginJson": "bun run scripts/generatePluginList.ts --equicord",
"generateVencordPluginJson": "tsx scripts/generatePluginList.ts --vencord", "generateVencordPluginJson": "bun run scripts/generatePluginList.ts --vencord",
"generateTypes": "tspc --emitDeclarationOnly --declaration --outDir packages/vencord-types --allowJs false", "generateTypes": "tspc --emitDeclarationOnly --declaration --outDir packages/vencord-types --allowJs false",
"inject": "node scripts/runInstaller.mjs -- --install", "inject": "bun run scripts/runInstaller.mjs --install",
"uninject": "node scripts/runInstaller.mjs -- --uninstall", "uninject": "bun run scripts/runInstaller.mjs --uninstall",
"repair": "node scripts/runInstaller.mjs -- --repair", "repair": "bun run scripts/runInstaller.mjs --repair",
"lint": "eslint", "lint": "eslint",
"lint-styles": "stylelint \"src/**/*.css\" --ignore-pattern src/userplugins", "lint-styles": "stylelint \"src/**/*.css\" --ignore-pattern src/userplugins",
"lint:fix": "pnpm lint --fix", "lint:fix": "bun run lint --fix",
"test": "pnpm buildStandalone && pnpm testTsc && pnpm lint:fix && pnpm lint-styles && pnpm generatePluginJson", "test": "bun run buildStandalone && bun run testTsc && bun run lint:fix && bun run lint-styles && bun run generatePluginJson",
"testWeb": "pnpm lint:fix && pnpm buildWeb && pnpm testTsc", "testWeb": "bun run lint:fix && bun run buildWeb && bun run testTsc",
"testTsc": "tsc --noEmit", "testTsc": "tsc --noEmit",
"depCheck": "node scripts/depCheck.mjs" "postinstall": "bun run scripts/applyPatches.mjs",
"depCheck": "bun run scripts/depCheck.mjs"
}, },
"dependencies": { "dependencies": {
"@ffmpeg/ffmpeg": "^0.12.10", "@ffmpeg/ffmpeg": "^0.12.10",
@ -64,13 +69,14 @@
"devDependencies": { "devDependencies": {
"@electron/asar": "^4.2.0", "@electron/asar": "^4.2.0",
"@stylistic/eslint-plugin": "^5.10.0", "@stylistic/eslint-plugin": "^5.10.0",
"@types/bun": "^1.3.9",
"@types/chrome": "^0.1.40", "@types/chrome": "^0.1.40",
"@types/lodash": "^4.17.24", "@types/lodash": "^4.17.24",
"@types/node": "^25.6.0", "@types/node": "^25.6.0",
"@types/react": "^19.0.10", "@types/react": "^19.0.10",
"@types/react-dom": "^19.0.4", "@types/react-dom": "^19.0.4",
"@types/yazl": "^3.3.1", "@types/yazl": "^3.3.1",
"@vencord/discord-types": "link:packages/discord-types", "@vencord/discord-types": "workspace:*",
"diff": "^9.0.0", "diff": "^9.0.0",
"esbuild": "^0.28.0", "esbuild": "^0.28.0",
"eslint": "10.2.0", "eslint": "10.2.0",
@ -90,39 +96,21 @@
"svgo": "^4.0.1", "svgo": "^4.0.1",
"ts-patch": "^3.3.0", "ts-patch": "^3.3.0",
"ts-pattern": "^5.9.0", "ts-pattern": "^5.9.0",
"tsx": "^4.21.0",
"type-fest": "^5.5.0", "type-fest": "^5.5.0",
"typescript": "^6.0.2", "typescript": "^6.0.2",
"typescript-eslint": "^8.58.2", "typescript-eslint": "^8.58.2",
"typescript-transform-paths": "^3.5.6", "typescript-transform-paths": "^3.5.6",
"zip-local": "^0.3.5" "zip-local": "^0.3.5"
}, },
"packageManager": "pnpm@10.33.0", "packageManager": "bun@1.3.9",
"pnpm": { "trustedDependencies": [
"patchedDependencies": {
"@types/less@3.0.8": "patches/@types__less@3.0.8.patch"
},
"peerDependencyRules": {
"ignoreMissing": [
"eslint-plugin-import",
"eslint"
]
},
"allowedDeprecatedVersions": {
"source-map-resolve": "*",
"resolve-url": "*",
"source-map-url": "*",
"urix": "*",
"q": "*"
},
"onlyBuiltDependencies": [
"esbuild" "esbuild"
], ],
"overrides": { "overrides": {
"@eslint/plugin-kit@<0.3.4": ">=0.3.4" "@eslint/plugin-kit": ">=0.3.4"
}
}, },
"engines": { "engines": {
"node": ">=18" "node": ">=18",
"bun": ">=1.0.0"
} }
} }

View file

@ -1,5 +1,5 @@
{ {
"name": "@equicord/discord-types", "name": "@vencord/discord-types",
"author": "Equicord & Vencord Contributors", "author": "Equicord & Vencord Contributors",
"private": false, "private": false,
"description": "Typescript definitions for the webpack modules of the Discord Web app", "description": "Typescript definitions for the webpack modules of the Discord Web app",

View file

@ -1,5 +1,5 @@
# How to publish # How to publish
1. run `pnpm generateTypes` in the project root 1. run `bun generateTypes` in the project root
2. bump package.json version 2. bump package.json version
3. npm publish 3. npm publish

View file

@ -7,5 +7,5 @@ npm i @equicord/types
yarn add @equicord/types yarn add @equicord/types
pnpm add @equicord/types bun add @vencord/types
``` ```

View file

@ -1,5 +1,5 @@
{ {
"name": "@equicord/types", "name": "@vencord/types",
"private": false, "private": false,
"version": "1.14.2", "version": "1.14.2",
"description": "", "description": "",
@ -19,7 +19,7 @@
"dependencies": { "dependencies": {
"@types/lodash": "4.17.15", "@types/lodash": "4.17.15",
"@types/node": "^22.13.4", "@types/node": "^22.13.4",
"@vencord/discord-types": "^1.0.0", "@vencord/discord-types": "workspace:*",
"highlight.js": "11.11.1", "highlight.js": "11.11.1",
"moment": "^2.22.2", "moment": "^2.22.2",
"ts-pattern": "^5.6.0", "ts-pattern": "^5.6.0",

5815
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff

View file

@ -1,2 +0,0 @@
packages:
- packages/*

31
scripts/applyPatches.mjs Normal file
View file

@ -0,0 +1,31 @@
#!/usr/bin/env bun
import { join } from "path";
const ROOT = join(import.meta.dir, "..");
const patches = {
"@types/less": {
file: join(ROOT, "node_modules/@types/less/index.d.ts"),
original: "export = less;",
patched: "export = LessStatic;",
removeLines: ["declare var less: LessStatic;"]
}
};
for (const [pkg, patch] of Object.entries(patches)) {
const file = Bun.file(patch.file);
if (!await file.exists()) continue;
let content = await file.text();
if (content.includes(patch.patched)) continue;
content = content.replace(patch.original, patch.patched);
for (const line of patch.removeLines) {
content = content.replace(line, "").replace(/\n{3,}/g, "\n\n");
}
await Bun.write(patch.file, content.trimEnd() + "\n");
console.log(`Patched ${pkg}`);
}

View file

@ -1,4 +1,4 @@
#!/usr/bin/node #!/usr/bin/env bun
/* /*
* Vencord, a modification for Discord's desktop app * Vencord, a modification for Discord's desktop app
* Copyright (c) 2022 Vendicated and contributors * Copyright (c) 2022 Vendicated and contributors
@ -20,12 +20,13 @@
// @ts-check // @ts-check
import { createPackage } from "@electron/asar"; import { createPackage } from "@electron/asar";
import { readdir, writeFile } from "fs/promises"; import { readdir } from "fs/promises";
import { dirname, join, resolve } from "path"; import { join, resolve } from "path";
import { fileURLToPath } from "url";
import { BUILD_TIMESTAMP, commonOpts, exists, globPlugins, IS_DEV, IS_REPORTER, IS_COMPANION_TEST, IS_STANDALONE, IS_UPDATER_DISABLED, resolvePluginName, VERSION, commonRendererPlugins, watch, buildOrWatchAll, stringifyValues, IS_ANTI_CRASH_TEST } from "./common.mjs"; import { BUILD_TIMESTAMP, commonOpts, exists, globPlugins, IS_DEV, IS_REPORTER, IS_COMPANION_TEST, IS_STANDALONE, IS_UPDATER_DISABLED, resolvePluginName, VERSION, commonRendererPlugins, watch, buildOrWatchAll, stringifyValues, IS_ANTI_CRASH_TEST } from "./common.mjs";
const __dirname = import.meta.dir;
const defines = stringifyValues({ const defines = stringifyValues({
IS_STANDALONE, IS_STANDALONE,
IS_DEV, IS_DEV,
@ -123,7 +124,7 @@ const buildConfigs = ([
// Discord Desktop main & renderer & preload // Discord Desktop main & renderer & preload
{ {
...nodeCommonOpts, ...nodeCommonOpts,
entryPoints: [join(dirname(fileURLToPath(import.meta.url)), "../../src/main/index.ts")], entryPoints: [join(__dirname, "../../src/main/index.ts")],
outfile: "dist/desktop/patcher.js", outfile: "dist/desktop/patcher.js",
footer: { js: "//# sourceURL=file:///VencordPatcher\n" + sourceMapFooter("patcher") }, footer: { js: "//# sourceURL=file:///VencordPatcher\n" + sourceMapFooter("patcher") },
sourcemap, sourcemap,
@ -141,7 +142,7 @@ const buildConfigs = ([
}, },
{ {
...commonOpts, ...commonOpts,
entryPoints: [join(dirname(fileURLToPath(import.meta.url)), "../../src/Vencord.ts")], entryPoints: [join(__dirname, "../../src/Vencord.ts")],
outfile: "dist/desktop/renderer.js", outfile: "dist/desktop/renderer.js",
format: "iife", format: "iife",
target: ["esnext"], target: ["esnext"],
@ -161,7 +162,7 @@ const buildConfigs = ([
}, },
{ {
...nodeCommonOpts, ...nodeCommonOpts,
entryPoints: [join(dirname(fileURLToPath(import.meta.url)), "../../src/preload.ts")], entryPoints: [join(__dirname, "../../src/preload.ts")],
outfile: "dist/desktop/preload.js", outfile: "dist/desktop/preload.js",
footer: { js: "//# sourceURL=file:///VencordPreload\n" + sourceMapFooter("preload") }, footer: { js: "//# sourceURL=file:///VencordPreload\n" + sourceMapFooter("preload") },
sourcemap, sourcemap,
@ -176,7 +177,7 @@ const buildConfigs = ([
// Vencord Desktop main & renderer & preload // Vencord Desktop main & renderer & preload
{ {
...nodeCommonOpts, ...nodeCommonOpts,
entryPoints: [join(dirname(fileURLToPath(import.meta.url)), "../../src/main/index.ts")], entryPoints: [join(__dirname, "../../src/main/index.ts")],
outfile: "dist/equibop/main.js", outfile: "dist/equibop/main.js",
footer: { js: "//# sourceURL=file:///VencordDesktopMain\n" + sourceMapFooter("main") }, footer: { js: "//# sourceURL=file:///VencordDesktopMain\n" + sourceMapFooter("main") },
sourcemap, sourcemap,
@ -193,7 +194,7 @@ const buildConfigs = ([
}, },
{ {
...commonOpts, ...commonOpts,
entryPoints: [join(dirname(fileURLToPath(import.meta.url)), "../../src/Vencord.ts")], entryPoints: [join(__dirname, "../../src/Vencord.ts")],
outfile: "dist/equibop/renderer.js", outfile: "dist/equibop/renderer.js",
format: "iife", format: "iife",
target: ["esnext"], target: ["esnext"],
@ -213,7 +214,7 @@ const buildConfigs = ([
}, },
{ {
...nodeCommonOpts, ...nodeCommonOpts,
entryPoints: [join(dirname(fileURLToPath(import.meta.url)), "../../src/preload.ts")], entryPoints: [join(__dirname, "../../src/preload.ts")],
outfile: "dist/equibop/preload.js", outfile: "dist/equibop/preload.js",
footer: { js: "//# sourceURL=file:///VencordPreload\n" + sourceMapFooter("preload") }, footer: { js: "//# sourceURL=file:///VencordPreload\n" + sourceMapFooter("preload") },
sourcemap, sourcemap,
@ -229,11 +230,11 @@ const buildConfigs = ([
await buildOrWatchAll(buildConfigs); await buildOrWatchAll(buildConfigs);
await Promise.all([ await Promise.all([
writeFile("dist/desktop/package.json", JSON.stringify({ Bun.write("dist/desktop/package.json", JSON.stringify({
name: "equicord", name: "equicord",
main: "patcher.js" main: "patcher.js"
})), })),
writeFile("dist/equibop/package.json", JSON.stringify({ Bun.write("dist/equibop/package.json", JSON.stringify({
name: "equicord", name: "equicord",
main: "main.js" main: "main.js"
})) }))

View file

@ -1,4 +1,4 @@
#!/usr/bin/node #!/usr/bin/env bun
/* /*
* Vencord, a modification for Discord's desktop app * Vencord, a modification for Discord's desktop app
* Copyright (c) 2022 Vendicated and contributors * Copyright (c) 2022 Vendicated and contributors
@ -19,9 +19,8 @@
// @ts-check // @ts-check
import { readFileSync } from "fs"; import { appendFile, mkdir, readdir, rm } from "fs/promises";
import { appendFile, mkdir, readdir, readFile, rm, writeFile } from "fs/promises"; import { join } from "path";
import path, { join } from "path";
import Zip from "zip-local"; import Zip from "zip-local";
import { BUILD_TIMESTAMP, commonOpts, globPlugins, IS_DEV, IS_REPORTER, IS_COMPANION_TEST, VERSION, commonRendererPlugins, buildOrWatchAll, stringifyValues, IS_ANTI_CRASH_TEST } from "./common.mjs"; import { BUILD_TIMESTAMP, commonOpts, globPlugins, IS_DEV, IS_REPORTER, IS_COMPANION_TEST, VERSION, commonRendererPlugins, buildOrWatchAll, stringifyValues, IS_ANTI_CRASH_TEST } from "./common.mjs";
@ -107,7 +106,7 @@ const buildConfigs = [
}, },
outfile: "dist/Equicord.user.js", outfile: "dist/Equicord.user.js",
banner: { banner: {
js: readFileSync("browser/userscript.meta.js", "utf-8").replace("%version%", `${VERSION}.${new Date().getTime()}`) js: (await Bun.file("browser/userscript.meta.js").text()).replace("%version%", `${VERSION}.${Date.now()}`)
}, },
footer: { footer: {
// UserScripts get wrapped in an iife, so define Vencord prop on window that returns our local // UserScripts get wrapped in an iife, so define Vencord prop on window that returns our local
@ -144,7 +143,7 @@ async function loadDir(dir, basePath = "") {
await Promise.all( await Promise.all(
files.map( files.map(
async f => async f =>
[f.slice(basePath.length), await readFile(f)] [f.slice(basePath.length), Buffer.from(await Bun.file(f).arrayBuffer())]
) )
) )
); );
@ -155,15 +154,15 @@ async function loadDir(dir, basePath = "") {
*/ */
async function buildExtension(target, files) { async function buildExtension(target, files) {
const entries = { const entries = {
"dist/Equicord.js": await readFile("dist/browser/extension.js"), "dist/Equicord.js": Buffer.from(await Bun.file("dist/browser/extension.js").arrayBuffer()),
"dist/Equicord.css": await readFile("dist/browser/extension.css"), "dist/Equicord.css": Buffer.from(await Bun.file("dist/browser/extension.css").arrayBuffer()),
...await loadDir("dist/browser/vendor/monaco", "dist/browser/"), ...await loadDir("dist/browser/vendor/monaco", "dist/browser/"),
...Object.fromEntries(await Promise.all(files.map(async f => { ...Object.fromEntries(await Promise.all(files.map(async f => {
let content = await readFile(join("browser", f)); let content = Buffer.from(await Bun.file(join("browser", f)).arrayBuffer());
if (f.startsWith("manifest")) { if (f.startsWith("manifest")) {
const json = JSON.parse(content.toString("utf-8")); const json = JSON.parse(content.toString("utf-8"));
json.version = VERSION; json.version = VERSION;
content = Buffer.from(new TextEncoder().encode(JSON.stringify(json))); content = Buffer.from(JSON.stringify(json));
} }
return [ return [
@ -178,13 +177,13 @@ async function buildExtension(target, files) {
const dest = join("dist/browser", target, file); const dest = join("dist/browser", target, file);
const parentDirectory = join(dest, ".."); const parentDirectory = join(dest, "..");
await mkdir(parentDirectory, { recursive: true }); await mkdir(parentDirectory, { recursive: true });
await writeFile(dest, content); await Bun.write(dest, content);
})); }));
console.info("Unpacked Extension written to dist/browser/" + target); console.info("Unpacked Extension written to dist/browser/" + target);
} }
const appendCssRuntime = readFile("dist/Equicord.user.css", "utf-8").then(content => { const appendCssRuntime = Bun.file("dist/Equicord.user.css").text().then(content => {
const cssRuntime = `unsafeWindow._vcUserScriptRendererCss=\`${content.replaceAll("`", "\\`")}\``; const cssRuntime = `unsafeWindow._vcUserScriptRendererCss=\`${content.replaceAll("`", "\\`")}\``;
return appendFile("dist/Equicord.user.js", cssRuntime); return appendFile("dist/Equicord.user.js", cssRuntime);

View file

@ -18,21 +18,17 @@
// @ts-check // @ts-check
import "../suppressExperimentalWarnings.js";
import "../checkNodeVersion.js";
import { exec, execSync } from "child_process";
import esbuild, { build, context } from "esbuild"; import esbuild, { build, context } from "esbuild";
import { constants as FsConstants, readFileSync } from "fs"; import { existsSync } from "fs";
import { access, readdir, readFile } from "fs/promises"; import { readdir } from "fs/promises";
import { minify as minifyHtml } from "html-minifier-terser"; import { minify as minifyHtml } from "html-minifier-terser";
import { dirname, join, relative, resolve } from "path"; import { join, relative, resolve } from "path";
import { fileURLToPath } from "url";
import { promisify } from "util";
import { getPluginTarget } from "../utils.mjs"; import { getPluginTarget } from "../utils.mjs";
const PackageJSON = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), "../../package.json"), "utf-8")); const __dirname = import.meta.dir;
const PackageJSON = await Bun.file(join(__dirname, "../../package.json")).json();
export const VERSION = PackageJSON.version; export const VERSION = PackageJSON.version;
// https://reproducible-builds.org/docs/source-date-epoch/ // https://reproducible-builds.org/docs/source-date-epoch/
@ -48,7 +44,7 @@ if (!IS_COMPANION_TEST && process.argv.includes("--companion-test"))
console.error("--companion-test must be run with --reporter for any effect"); console.error("--companion-test must be run with --reporter for any effect");
export const IS_UPDATER_DISABLED = process.argv.includes("--disable-updater"); export const IS_UPDATER_DISABLED = process.argv.includes("--disable-updater");
export const gitHash = process.env.EQUICORD_HASH || execSync("git rev-parse HEAD", { encoding: "utf-8" }).trim(); export const gitHash = process.env.EQUICORD_HASH || new TextDecoder().decode(Bun.spawnSync(["git", "rev-parse", "HEAD"]).stdout).trim();
export const banner = { export const banner = {
js: ` js: `
@ -96,14 +92,11 @@ const PluginDefinitionNameMatcher = /definePlugin\(\{\s*(["'])?name\1:\s*(["'`])
export async function resolvePluginName(base, dirent) { export async function resolvePluginName(base, dirent) {
const fullPath = join(base, dirent.name); const fullPath = join(base, dirent.name);
const content = dirent.isFile() const content = dirent.isFile()
? await readFile(fullPath, "utf-8") ? await Bun.file(fullPath).text()
: await (async () => { : await (async () => {
for (const file of ["index.ts", "index.tsx"]) { for (const file of ["index.ts", "index.tsx"]) {
try { const f = Bun.file(join(fullPath, file));
return await readFile(join(fullPath, file), "utf-8"); if (await f.exists()) return await f.text();
} catch {
continue;
}
} }
throw new Error(`Invalid plugin ${fullPath}: could not resolve entry point`); throw new Error(`Invalid plugin ${fullPath}: could not resolve entry point`);
})(); })();
@ -114,10 +107,8 @@ export async function resolvePluginName(base, dirent) {
})(); })();
} }
export async function exists(path) { export function exists(path) {
return await access(path, FsConstants.F_OK) return Bun.file(path).exists().then(e => e || existsSync(path));
.then(() => true)
.catch(() => false);
} }
// https://github.com/evanw/esbuild/issues/619#issuecomment-751995294 // https://github.com/evanw/esbuild/issues/619#issuecomment-751995294
@ -231,8 +222,8 @@ export const gitRemotePlugin = {
build.onLoad({ filter, namespace: "git-remote" }, async () => { build.onLoad({ filter, namespace: "git-remote" }, async () => {
let remote = process.env.EQUICORD_REMOTE; let remote = process.env.EQUICORD_REMOTE;
if (!remote) { if (!remote) {
const res = await promisify(exec)("git remote get-url origin", { encoding: "utf-8" }); const proc = Bun.spawn(["git", "remote", "get-url", "origin"], { stdout: "pipe" });
remote = res.stdout.trim() remote = (await new Response(proc.stdout).text()).trim()
.replace("https://github.com/", "") .replace("https://github.com/", "")
.replace("git@github.com:", "") .replace("git@github.com:", "")
.replace(/.git$/, ""); .replace(/.git$/, "");
@ -264,15 +255,18 @@ export const fileUrlPlugin = {
const minify = searchParams.has("minify"); const minify = searchParams.has("minify");
const noTrim = searchParams.get("trim") === "false"; const noTrim = searchParams.get("trim") === "false";
const encoding = base64 ? "base64" : "utf-8";
let content; let content;
if (!minify) { if (!minify) {
content = await readFile(path, encoding); if (base64) {
const buf = Buffer.from(await Bun.file(path).arrayBuffer());
content = buf.toString("base64");
} else {
content = await Bun.file(path).text();
if (!noTrim) content = content.trimEnd(); if (!noTrim) content = content.trimEnd();
}
} else { } else {
if (path.endsWith(".html")) { if (path.endsWith(".html")) {
content = await minifyHtml(await readFile(path, "utf-8"), { content = await minifyHtml(await Bun.file(path).text(), {
collapseWhitespace: true, collapseWhitespace: true,
removeComments: true, removeComments: true,
minifyCSS: true, minifyCSS: true,
@ -317,7 +311,7 @@ export const banImportPlugin = (filter, message) => ({
} }
}); });
const styleModule = readFileSync(join(dirname(fileURLToPath(import.meta.url)), "module/style.js"), "utf-8"); const styleModule = await Bun.file(join(__dirname, "module/style.js")).text();
/** /**
* @type {import("esbuild").Plugin} * @type {import("esbuild").Plugin}
@ -330,7 +324,7 @@ export const stylePlugin = {
namespace: "managed-style", namespace: "managed-style",
})); }));
onLoad({ filter: /\.css$/, namespace: "managed-style" }, async ({ path }) => { onLoad({ filter: /\.css$/, namespace: "managed-style" }, async ({ path }) => {
const css = await readFile(path, "utf-8"); const css = await Bun.file(path).text();
const name = relative(process.cwd(), path).replaceAll("\\", "/"); const name = relative(process.cwd(), path).replaceAll("\\", "/");
return { return {
@ -355,7 +349,7 @@ export const commonOpts = {
banner, banner,
plugins: [fileUrlPlugin, gitHashPlugin, gitRemotePlugin, stylePlugin], plugins: [fileUrlPlugin, gitHashPlugin, gitRemotePlugin, stylePlugin],
external: ["~plugins", "~git-hash", "~git-remote", "/assets/*"], external: ["~plugins", "~git-hash", "~git-remote", "/assets/*"],
inject: [join(dirname(fileURLToPath(import.meta.url)), "inject/react.mjs")], inject: [join(__dirname, "inject/react.mjs")],
jsx: "transform", jsx: "transform",
jsxFactory: "VencordCreateElement", jsxFactory: "VencordCreateElement",
jsxFragment: "VencordFragment" jsxFragment: "VencordFragment"

View file

@ -1,20 +0,0 @@
/*
* Vencord, a modification for Discord's desktop app
* Copyright (c) 2023 Vendicated and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (Number(process.versions.node.split(".")[0]) < 18)
throw `Your node version (${process.version}) is too old, please update to v18 or higher https://nodejs.org/en/download/`;

View file

@ -16,7 +16,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { readFileSync, writeFileSync } from "fs";
import { BigIntLiteral, createSourceFile, Identifier, isCallExpression, isIdentifier, isObjectLiteralExpression, isPropertyAssignment, isSatisfiesExpression, isVariableStatement, NamedDeclaration, ObjectLiteralExpression, ScriptTarget, StringLiteral } from "typescript"; import { BigIntLiteral, createSourceFile, Identifier, isCallExpression, isIdentifier, isObjectLiteralExpression, isPropertyAssignment, isSatisfiesExpression, isVariableStatement, NamedDeclaration, ObjectLiteralExpression, ScriptTarget, StringLiteral } from "typescript";
interface Dev { interface Dev {
@ -41,8 +40,8 @@ function getObjectProp(node: ObjectLiteralExpression, name: string) {
return prop; return prop;
} }
function parseDevs() { async function parseDevs() {
const file = createSourceFile("constants.ts", readFileSync("src/utils/constants.ts", "utf8"), ScriptTarget.Latest); const file = createSourceFile("constants.ts", await Bun.file("src/utils/constants.ts").text(), ScriptTarget.Latest);
for (const child of file.getChildAt(0).getChildren()) { for (const child of file.getChildAt(0).getChildren()) {
if (!isVariableStatement(child)) continue; if (!isVariableStatement(child)) continue;
@ -72,8 +71,8 @@ function parseDevs() {
throw new Error("Could not find Devs constant"); throw new Error("Could not find Devs constant");
} }
function parseEquicordDevs() { async function parseEquicordDevs() {
const file = createSourceFile("constants.ts", readFileSync("src/utils/constants.ts", "utf8"), ScriptTarget.Latest); const file = createSourceFile("constants.ts", await Bun.file("src/utils/constants.ts").text(), ScriptTarget.Latest);
for (const child of file.getChildAt(0).getChildren()) { for (const child of file.getChildAt(0).getChildren()) {
if (!isVariableStatement(child)) continue; if (!isVariableStatement(child)) continue;
@ -104,8 +103,8 @@ function parseEquicordDevs() {
} }
(async () => { (async () => {
parseDevs(); await parseDevs();
parseEquicordDevs(); await parseEquicordDevs();
const allDevs = { const allDevs = {
vencord: devs, vencord: devs,
@ -114,7 +113,7 @@ function parseEquicordDevs() {
const data = JSON.stringify(allDevs, null, 2); const data = JSON.stringify(allDevs, null, 2);
if (process.argv.length > 2) { if (process.argv.length > 2) {
writeFileSync(process.argv[2], data); await Bun.write(process.argv[2], data);
} else { } else {
console.log(data); console.log(data);
} }

View file

@ -16,12 +16,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { readdirSync, writeFileSync } from "fs"; import { readdirSync } from "fs";
import { getEntryPoint, isPluginFile, parseDevs, parseEquicordDevs, parseFile, PluginData } from "./utils"; import { getEntryPoint, isPluginFile, parseDevs, parseEquicordDevs, parseFile, PluginData } from "./utils";
(async () => { (async () => {
parseDevs(); await parseDevs();
parseEquicordDevs(); await parseEquicordDevs();
const args = process.argv.slice(2); const args = process.argv.slice(2);
@ -56,7 +56,7 @@ import { getEntryPoint, isPluginFile, parseDevs, parseEquicordDevs, parseFile, P
const data = JSON.stringify(plugins); const data = JSON.stringify(plugins);
if (outputPath) { if (outputPath) {
writeFileSync(outputPath, data); await Bun.write(outputPath, data);
} else { } else {
console.log(data); console.log(data);
} }

View file

@ -20,7 +20,6 @@
/// <reference types="../src/modules" /> /// <reference types="../src/modules" />
import { createHmac } from "crypto"; import { createHmac } from "crypto";
import { readFileSync, writeFileSync } from "fs";
import { join } from "path"; import { join } from "path";
import pup, { JSHandle } from "puppeteer-core"; import pup, { JSHandle } from "puppeteer-core";
@ -361,7 +360,7 @@ page.on("pageerror", (e: any) => {
await page.evaluateOnNewDocument(` await page.evaluateOnNewDocument(`
if (location.host.endsWith("discord.com")) { if (location.host.endsWith("discord.com")) {
${readFileSync("./dist/browser/browser.js", "utf-8")}; ${await Bun.file("./dist/browser/browser.js").text()};
} }
`); `);

View file

@ -16,20 +16,14 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import "./checkNodeVersion.js"; import { mkdirSync } from "fs";
import { join } from "path";
import { execFileSync, execSync } from "child_process";
import { createWriteStream, existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
import { dirname, join } from "path";
import { Readable } from "stream";
import { finished } from "stream/promises";
import { fileURLToPath } from "url";
const BASE_URL = "https://github.com/Equicord/Equilotl/releases/latest/download/"; const BASE_URL = "https://github.com/Equicord/Equilotl/releases/latest/download/";
const INSTALLER_PATH_DARWIN = "Equilotl.app/Contents/MacOS/Equilotl"; const INSTALLER_PATH_DARWIN = "Equilotl.app/Contents/MacOS/Equilotl";
const INSTALLER_APP_DARWIN = "Equilotl.app"; const INSTALLER_APP_DARWIN = "Equilotl.app";
const BASE_DIR = join(dirname(fileURLToPath(import.meta.url)), ".."); const BASE_DIR = join(import.meta.dir, "..");
const FILE_DIR = join(BASE_DIR, "dist", "Installer"); const FILE_DIR = join(BASE_DIR, "dist", "Installer");
const ETAG_FILE = join(FILE_DIR, "etag.txt"); const ETAG_FILE = join(FILE_DIR, "etag.txt");
@ -60,8 +54,9 @@ async function ensureBinary() {
? join(FILE_DIR, INSTALLER_APP_DARWIN) ? join(FILE_DIR, INSTALLER_APP_DARWIN)
: null; : null;
const etag = existsSync(outputFile) && existsSync(ETAG_FILE) const etagFile = Bun.file(ETAG_FILE);
? readFileSync(ETAG_FILE, "utf-8") const etag = await Bun.file(outputFile).exists() && await etagFile.exists()
? await etagFile.text()
: null; : null;
const res = await fetch(BASE_URL + filename, { const res = await fetch(BASE_URL + filename, {
@ -78,33 +73,31 @@ async function ensureBinary() {
if (!res.ok) if (!res.ok)
throw new Error(`Failed to download installer: ${res.status} ${res.statusText}`); throw new Error(`Failed to download installer: ${res.status} ${res.statusText}`);
writeFileSync(ETAG_FILE, res.headers.get("etag")); await Bun.write(ETAG_FILE, res.headers.get("etag"));
if (process.platform === "darwin") { if (process.platform === "darwin") {
console.log("Saving zip..."); console.log("Saving zip...");
const zip = new Uint8Array(await res.arrayBuffer()); await Bun.write(downloadName, new Uint8Array(await res.arrayBuffer()));
writeFileSync(downloadName, zip);
console.log("Unzipping app bundle..."); console.log("Unzipping app bundle...");
execSync(`ditto -x -k '${downloadName}' '${FILE_DIR}'`); Bun.spawnSync(["ditto", "-x", "-k", downloadName, FILE_DIR], { stdio: ["inherit", "inherit", "inherit"] });
console.log("Clearing quarantine from installer app (this is required to run it)"); console.log("Clearing quarantine from installer app (this is required to run it)");
console.log("xattr might error, that's okay"); console.log("xattr might error, that's okay");
const logAndRun = cmd => { const logAndRun = args => {
console.log("Running", cmd); console.log("Running", args.join(" "));
try { try {
execSync(cmd); Bun.spawnSync(args, { stdio: ["inherit", "inherit", "inherit"] });
} catch { } } catch { }
}; };
logAndRun(`sudo xattr -dr com.apple.quarantine '${outputApp}'`); logAndRun(["sudo", "xattr", "-dr", "com.apple.quarantine", outputApp]);
} else { } else {
// WHY DOES NODE FETCH RETURN A WEB STREAM OH MY GOD await Bun.write(outputFile, new Uint8Array(await res.arrayBuffer()));
const body = Readable.fromWeb(res.body); if (process.platform !== "win32") {
await finished(body.pipe(createWriteStream(outputFile, { const { chmodSync } = await import("fs");
mode: 0o755, chmodSync(outputFile, 0o755);
autoClose: true }
})));
} }
console.log("Finished downloading!"); console.log("Finished downloading!");
@ -118,12 +111,10 @@ const installerBin = await ensureBinary();
console.log("Now running Installer..."); console.log("Now running Installer...");
const argStart = process.argv.indexOf("--"); const args = process.argv.slice(2);
const args = argStart === -1 ? [] : process.argv.slice(argStart + 1);
try { const result = Bun.spawnSync([installerBin, ...args], {
execFileSync(installerBin, args, { stdio: ["inherit", "inherit", "inherit"],
stdio: "inherit",
env: { env: {
...process.env, ...process.env,
EQUICORD_USER_DATA_DIR: BASE_DIR, EQUICORD_USER_DATA_DIR: BASE_DIR,
@ -131,6 +122,7 @@ try {
EQUICORD_DEV_INSTALL: "1" EQUICORD_DEV_INSTALL: "1"
} }
}); });
} catch {
if (!result.success) {
console.error("Something went wrong. Please check the logs above."); console.error("Something went wrong. Please check the logs above.");
} }

View file

@ -1,24 +0,0 @@
/*
* Vencord, a modification for Discord's desktop app
* Copyright (c) 2022 Vendicated and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
process.emit = (originalEmit => function (name, data) {
if (name === "warning" && data?.name === "ExperimentalWarning")
return false;
return originalEmit.apply(process, arguments);
})(process.emit);

View file

@ -16,8 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { Dirent, readdirSync, readFileSync, writeFileSync } from "fs"; import { Dirent, readdirSync } from "fs";
import { access, readFile } from "fs/promises";
import { join, sep } from "path"; import { join, sep } from "path";
import { normalize as posixNormalize, sep as posixSep } from "path/posix"; import { normalize as posixNormalize, sep as posixSep } from "path/posix";
import { BigIntLiteral, createSourceFile, Identifier, isArrayLiteralExpression, isCallExpression, isExportAssignment, isIdentifier, isObjectLiteralExpression, isPropertyAccessExpression, isPropertyAssignment, isSatisfiesExpression, isStringLiteral, isVariableStatement, NamedDeclaration, NodeArray, ObjectLiteralExpression, PropertyAssignment, ScriptTarget, StringLiteral, SyntaxKind } from "typescript"; import { BigIntLiteral, createSourceFile, Identifier, isArrayLiteralExpression, isCallExpression, isExportAssignment, isIdentifier, isObjectLiteralExpression, isPropertyAccessExpression, isPropertyAssignment, isSatisfiesExpression, isStringLiteral, isVariableStatement, NamedDeclaration, NodeArray, ObjectLiteralExpression, PropertyAssignment, ScriptTarget, StringLiteral, SyntaxKind } from "typescript";
@ -69,8 +68,8 @@ export function getObjectProp(node: ObjectLiteralExpression, name: string) {
return prop; return prop;
} }
export function parseDevs() { export async function parseDevs() {
const file = createSourceFile("constants.ts", readFileSync("src/utils/constants.ts", "utf8"), ScriptTarget.Latest); const file = createSourceFile("constants.ts", await Bun.file("src/utils/constants.ts").text(), ScriptTarget.Latest);
for (const child of file.getChildAt(0).getChildren()) { for (const child of file.getChildAt(0).getChildren()) {
if (!isVariableStatement(child)) continue; if (!isVariableStatement(child)) continue;
@ -100,8 +99,8 @@ export function parseDevs() {
throw new Error("Could not find Devs constant"); throw new Error("Could not find Devs constant");
} }
export function parseEquicordDevs() { export async function parseEquicordDevs() {
const file = createSourceFile("constants.ts", readFileSync("src/utils/constants.ts", "utf8"), ScriptTarget.Latest); const file = createSourceFile("constants.ts", await Bun.file("src/utils/constants.ts").text(), ScriptTarget.Latest);
for (const child of file.getChildAt(0).getChildren()) { for (const child of file.getChildAt(0).getChildren()) {
if (!isVariableStatement(child)) continue; if (!isVariableStatement(child)) continue;
@ -132,7 +131,7 @@ export function parseEquicordDevs() {
} }
export async function parseFile(fileName: string) { export async function parseFile(fileName: string) {
const file = createSourceFile(fileName, await readFile(fileName, "utf8"), ScriptTarget.Latest); const file = createSourceFile(fileName, await Bun.file(fileName).text(), ScriptTarget.Latest);
const fail = (reason: string) => { const fail = (reason: string) => {
return new Error(`Invalid plugin ${fileName}, because ${reason}`); return new Error(`Invalid plugin ${fileName}, because ${reason}`);
@ -263,10 +262,7 @@ export async function getEntryPoint(dir: string, dirent: Dirent) {
for (const name of ["index.ts", "index.tsx"]) { for (const name of ["index.ts", "index.tsx"]) {
const full = join(base, name); const full = join(base, name);
try { if (await Bun.file(full).exists()) return full;
await access(full);
return full;
} catch { }
} }
throw new Error(`${dirent.name}: Couldn't find entry point`); throw new Error(`${dirent.name}: Couldn't find entry point`);

View file

@ -63,7 +63,7 @@ export default definePlugin({
start() { start() {
// if we're running the reporter, we need to initws in the reporter file to avoid a race condition // if we're running the reporter, we need to initws in the reporter file to avoid a race condition
if (!IS_DEV) throw new Error("This plugin requires dev mode to run, please build with pnpm build --dev"); if (!IS_DEV) throw new Error("This plugin requires dev mode to run, please build with bun run build --dev");
initWs(); initWs();
window.reconnectDevtools = () => { window.reconnectDevtools = () => {
socket?.close(1000, "Reconnecting"); socket?.close(1000, "Reconnecting");