[
  {
    "path": ".github/ISSUE_TEMPLATE/config.yml",
    "content": "blank_issues_enabled: false\ncontact_links:\n    - name: Vencord Support Server\n      url: https://discord.gg/D9uwnFnqmd\n      about: \"Need Help? Join our support server and ask in the #vesktop-support channel!\"\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/dev-issue.yml",
    "content": "name: Vesktop Developer Issue\ndescription: Reserved for Vesktop Developers. Join our support server for support.\n\nbody:\n    - type: markdown\n      attributes:\n          value: |\n              # This form is reserved for Vesktop Developers. Do not open an issue.\n\n              Instead, use the [#vesktop-support channel](https://discord.com/channels/1015060230222131221/1345457031426871417) on our [Discord server](https://vencord.dev/discord) for help and reporting issues.\n\n              Your issue will be closed immediately with no comment and you will be blocked if you ignore this.\n\n              This is because 99% of issues are not actually bugs, but rather user or system issues and it adds a lot of noise to our development process.\n    - type: textarea\n      id: content\n      attributes:\n          label: Content\n      validations:\n          required: true\n"
  },
  {
    "path": ".github/workflows/meta.yml",
    "content": "name: Update metainfo on release\r\n\r\non:\r\n    release:\r\n        types:\r\n            - published\r\n    workflow_dispatch:\r\n\r\npermissions:\r\n    contents: write\r\n\r\njobs:\r\n    update:\r\n        runs-on: ubuntu-latest\r\n\r\n        steps:\r\n            - uses: actions/checkout@v4\r\n            - uses: pnpm/action-setup@v4 # Install pnpm using packageManager key in package.json\r\n\r\n            - name: Use Node.js 20\r\n              uses: actions/setup-node@v4\r\n              with:\r\n                  node-version: 20\r\n\r\n            - name: Install dependencies\r\n              run: pnpm i\r\n\r\n            - name: Update metainfo\r\n              run: pnpm generateMeta\r\n\r\n            - name: Commit and merge in changes\r\n              run: |\r\n                  git config user.name \"github-actions[bot]\"\r\n                  git config user.email \"41898282+github-actions[bot]@users.noreply.github.com\"\r\n\r\n                  gh release upload \"${{ github.event.release.tag_name }}\" dist/dev.vencord.Vesktop.metainfo.xml\r\n              env:\r\n                  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\r\n"
  },
  {
    "path": ".github/workflows/release.yml",
    "content": "name: Release\n\non:\n    push:\n        tags:\n            - v*\n    workflow_dispatch:\n\njobs:\n    release:\n        runs-on: ${{ matrix.os }}\n\n        strategy:\n            matrix:\n                os: [macos-latest, ubuntu-latest, windows-latest]\n                include:\n                    - os: macos-latest\n                      platform: mac\n                    - os: ubuntu-latest\n                      platform: linux\n                    - os: windows-latest\n                      platform: windows\n\n        steps:\n            - uses: actions/checkout@v4\n            - uses: pnpm/action-setup@v4 # Install pnpm using packageManager key in package.json\n\n            - name: Use Node.js 20\n              uses: actions/setup-node@v4\n              with:\n                  node-version: 20\n                  cache: \"pnpm\"\n\n            - name: Install dependencies\n              run: pnpm install --frozen-lockfile\n\n            - name: Build\n              run: pnpm build\n\n            - name: Run Electron Builder\n              if: ${{ matrix.platform != 'mac' }}\n              run: |\n                  pnpm electron-builder --${{ matrix.platform }} --publish always\n              env:\n                  GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n\n            - name: Run Electron Builder\n              if: ${{ matrix.platform == 'mac' }}\n              run: |\n                  echo \"$API_KEY\" > apple.p8\n                  pnpm electron-builder --${{ matrix.platform }} --publish always\n              env:\n                GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n                CSC_LINK: ${{ secrets.APPLE_SIGNING_CERT }}\n                CSC_KEY_PASSWORD: ${{ secrets.APPLE_SIGNING_CERT_PASSWORD }}\n                API_KEY: ${{ secrets.APPLE_API_KEY }}\n                APPLE_API_KEY: apple.p8\n                APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}\n                APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}\n"
  },
  {
    "path": ".github/workflows/test.yml",
    "content": "name: test\non:\n    push:\n        branches:\n            - main\n    pull_request:\n        branches:\n            - main\njobs:\n    test:\n        runs-on: ubuntu-latest\n\n        steps:\n            - uses: actions/checkout@v4\n            - uses: pnpm/action-setup@v4 # Install pnpm using packageManager key in package.json\n\n            - name: Use Node.js 20\n              uses: actions/setup-node@v4\n              with:\n                  node-version: 20\n                  cache: \"pnpm\"\n\n            - name: Install dependencies\n              run: pnpm install --frozen-lockfile\n\n            - name: Run tests\n              run: pnpm test\n\n            - name: Test if it compiles\n              run: |\n                  pnpm build\n                  pnpm build --dev\n"
  },
  {
    "path": ".github/workflows/update-vencord-dev.yml",
    "content": "name: Update vencord.dev Vesktop version\n\non:\n    release:\n        types:\n            - published\n\njobs:\n    update:\n        runs-on: ubuntu-latest\n        steps:\n            - name: Update scripts/_latestVesktopVersion.txt file in vencord.dev repo\n              run: |\n                  git config --global user.name \"$USERNAME\"\n                  git config --global user.email \"41898282+github-actions[bot]@users.noreply.github.com\"\n\n                  git clone https://$USERNAME:$API_TOKEN@github.com/$GH_REPO.git repo\n\n                  cd repo\n                  version=\"${{ github.event.release.tag_name }}\"\n                  echo \"${version#v}\" > scripts/_latestVesktopVersion.txt\n                  \n                  git add scripts/_latestVesktopVersion.txt\n                  git commit -m \"Update Vesktop version to ${{ github.event.release.tag_name }}\"\n                  git push https://$USERNAME:$API_TOKEN@github.com/$GH_REPO.git\n              env:\n                  API_TOKEN: ${{ secrets.VENCORD_DEV_GITHUB_TOKEN }}\n                  GH_REPO: Vencord/vencord.dev\n                  USERNAME: GitHub-Actions\n"
  },
  {
    "path": ".github/workflows/winget-submission.yml",
    "content": "name: Submit to Winget Community Repo\n\non:\n  release:\n    types: [published]\n  workflow_dispatch:\n    inputs:\n      tag:\n        type: string\n        description: The release tag to submit\n        required: true\n\njobs:\n  winget:\n    name: Publish winget package\n    runs-on: windows-latest\n    steps:\n      - name: Submit package to Winget Community Repo\n        uses: vedantmgoyal2009/winget-releaser@0db4f0a478166abd0fa438c631849f0b8dcfb99f\n        with:\n          identifier: Vencord.Vesktop\n          token: ${{ secrets.WINGET_PAT }}\n          installers-regex: '\\.exe$'\n          release-tag: ${{ inputs.tag || github.event.release.tag_name }}\n          fork-user: shiggybot\n"
  },
  {
    "path": ".gitignore",
    "content": "dist\nnode_modules\n.env\n.DS_Store\n.idea/\n.pnpm-store/"
  },
  {
    "path": ".npmrc",
    "content": "node-linker=hoisted\npackage-manager-strict=false"
  },
  {
    "path": ".prettierrc.yaml",
    "content": "tabWidth: 4\nsemi: true\nprintWidth: 120\ntrailingComma: none\nbracketSpacing: true\narrowParens: avoid\nuseTabs: false\nendOfLine: lf\n"
  },
  {
    "path": ".vscode/settings.json",
    "content": "{\r\n    \"editor.formatOnSave\": true,\r\n    \"editor.codeActionsOnSave\": {\r\n        \"source.fixAll.eslint\": \"explicit\"\r\n    },\r\n    \"[typescript]\": {\r\n        \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\r\n    },\r\n    \"[javascript]\": {\r\n        \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\r\n    },\r\n    \"[typescriptreact]\": {\r\n        \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\r\n    },\r\n    \"[javascriptreact]\": {\r\n        \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\r\n    },\r\n    \"[json]\": {\r\n        \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\r\n    },\r\n    \"[jsonc]\": {\r\n        \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\r\n    },\r\n    \"cSpell.words\": [\"Vesktop\"]\r\n}\r\n"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<https://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<https://www.gnu.org/licenses/why-not-lgpl.html>.\n"
  },
  {
    "path": "README.md",
    "content": "# Vesktop\n\nVesktop is a custom Discord desktop app\n\n**Main features**:\n- Vencord preinstalled\n- Much more lightweight and faster than the official Discord app\n- Linux Screenshare with sound & wayland\n- Much better privacy, since Discord has no access to your system\n\n**Not yet supported**:\n- Global Keybinds\n- see the [Roadmap](https://github.com/Vencord/Vesktop/issues/324)\n\n![](https://github.com/Vencord/Vesktop/assets/45497981/8608a899-96a9-4027-9725-2cb02ba189fd)\n![](https://github.com/Vencord/Vesktop/assets/45497981/8701e5de-52c4-4346-a990-719cb971642e)\n\n## Installing\n\nVisit https://vesktop.dev/install\n\n## Building from Source\n\nYou need to have the following dependencies installed:\n- [Git](https://git-scm.com/downloads)\n- [Node.js](https://nodejs.org/en/download)\n- pnpm: `npm install --global pnpm`\n\nPackaging will create builds in the dist/ folder\n\n```sh\ngit clone https://github.com/Vencord/Vesktop\ncd Vesktop\n\n# Install Dependencies\npnpm i\n\n# Either run it without packaging\npnpm start\n\n# Or package (will build packages for your OS)\npnpm package\n\n# Or only build the Linux Pacman package\npnpm package --linux pacman\n\n# Or package to a directory only\npnpm package:dir\n```\n\n## Building LibVesktop from Source\n\nThis is a small C++ helper library Vesktop uses on Linux to emit D-Bus events. By default, prebuilt binaries for x64 and arm64 are used.\n\nIf you want to build it from source:\n1. Install build dependencies:\n    - Debian/Ubuntu: `apt install build-essential python3 curl pkg-config libglib2.0-dev`\n    - Fedora: `dnf install @c-development @development-tools python3 curl pkgconf-pkg-config glib2-devel`\n2. Run `pnpm buildLibVesktop`\n3. From now on, building Vesktop will use your own build"
  },
  {
    "path": "build/entitlements.mac.plist",
    "content": "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n  <dict>\n\t<key>com.apple.security.cs.allow-unsigned-executable-memory</key>\n\t<true/>\n\t<key>com.apple.security.cs.allow-jit</key>\n\t<true/>\n\t<key>com.apple.security.network.client</key>\n\t<true/>\n\t<key>com.apple.security.device.audio-input</key>\n\t<true/>\n\t<key>com.apple.security.device.camera</key>\n\t<true/>\n\t<key>com.apple.security.device.bluetooth</key>\n\t<true/>\n\t<key>com.apple.security.cs.allow-dyld-environment-variables</key>\n\t<true/>\n\t<key>com.apple.security.cs.disable-library-validation</key>\n\t<true/>\n  </dict>\n</plist>\n"
  },
  {
    "path": "build/installer.nsh",
    "content": "!macro preInit\n SetRegView 64\n  WriteRegExpandStr HKLM \"${INSTALL_REGISTRY_KEY}\" InstallLocation \"$LocalAppData\\vesktop\"\n  WriteRegExpandStr HKCU \"${INSTALL_REGISTRY_KEY}\" InstallLocation \"$LocalAppData\\vesktop\"\n SetRegView 32\n  WriteRegExpandStr HKLM \"${INSTALL_REGISTRY_KEY}\" InstallLocation \"$LocalAppData\\vesktop\"\n  WriteRegExpandStr HKCU \"${INSTALL_REGISTRY_KEY}\" InstallLocation \"$LocalAppData\\vesktop\"\n!macroend\n"
  },
  {
    "path": "eslint.config.mjs",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\n//@ts-check\n\nimport { defineConfig } from \"eslint/config\";\nimport stylistic from \"@stylistic/eslint-plugin\";\nimport pathAlias from \"eslint-plugin-path-alias\";\nimport react from \"eslint-plugin-react\";\nimport simpleHeader from \"eslint-plugin-simple-header\";\nimport importSort from \"eslint-plugin-simple-import-sort\";\nimport unusedImports from \"eslint-plugin-unused-imports\";\nimport tseslint from \"typescript-eslint\";\nimport prettier from \"eslint-plugin-prettier\";\n\nexport default defineConfig(\n    { ignores: [\"dist\"] },\n    {\n        files: [\"src/**/*.{tsx,ts,mts,mjs,js,jsx}\"],\n        settings: {\n            react: {\n                version: \"19\"\n            }\n        },\n        ...react.configs.flat.recommended,\n        rules: {\n            ...react.configs.flat.recommended.rules,\n            \"react/react-in-jsx-scope\": \"off\",\n            \"react/prop-types\": \"off\",\n            \"react/display-name\": \"off\",\n            \"react/no-unescaped-entities\": \"off\"\n        }\n    },\n    {\n        files: [\"src/**/*.{tsx,ts,mts,mjs,js,jsx}\"],\n        plugins: {\n            simpleHeader,\n            stylistic,\n            importSort,\n            unusedImports,\n            // @ts-expect-error Missing types\n            pathAlias,\n            prettier,\n            \"@typescript-eslint\": tseslint.plugin\n        },\n        settings: {\n            \"import/resolver\": {\n                alias: {\n                    map: []\n                }\n            }\n        },\n        languageOptions: {\n            parser: tseslint.parser,\n            parserOptions: {\n                project: true,\n                tsconfigRootDir: import.meta.dirname\n            }\n        },\n        rules: {\n            \"simpleHeader/header\": [\n                \"error\",\n                {\n                    files: [\"scripts/header.txt\"],\n                    templates: { author: [\".*\", \"Vendicated and Vesktop contributors\"] }\n                }\n            ],\n\n            // ESLint Rules\n            yoda: \"error\",\n            eqeqeq: [\"error\", \"always\", { null: \"ignore\" }],\n            \"prefer-destructuring\": [\n                \"error\",\n                {\n                    VariableDeclarator: { array: false, object: true },\n                    AssignmentExpression: { array: false, object: false }\n                }\n            ],\n            \"operator-assignment\": [\"error\", \"always\"],\n            \"no-useless-computed-key\": \"error\",\n            \"no-unneeded-ternary\": [\"error\", { defaultAssignment: false }],\n            \"no-invalid-regexp\": \"error\",\n            \"no-constant-condition\": [\"error\", { checkLoops: false }],\n            \"no-duplicate-imports\": \"error\",\n            \"@typescript-eslint/dot-notation\": [\n                \"error\",\n                {\n                    allowPrivateClassPropertyAccess: true,\n                    allowProtectedClassPropertyAccess: true\n                }\n            ],\n            \"no-useless-escape\": [\n                \"error\",\n                {\n                    allowRegexCharacters: [\"i\"]\n                }\n            ],\n            \"no-fallthrough\": \"error\",\n            \"for-direction\": \"error\",\n            \"no-async-promise-executor\": \"error\",\n            \"no-cond-assign\": \"error\",\n            \"no-dupe-else-if\": \"error\",\n            \"no-duplicate-case\": \"error\",\n            \"no-irregular-whitespace\": \"error\",\n            \"no-loss-of-precision\": \"error\",\n            \"no-misleading-character-class\": \"error\",\n            \"no-prototype-builtins\": \"error\",\n            \"no-regex-spaces\": \"error\",\n            \"no-shadow-restricted-names\": \"error\",\n            \"no-unexpected-multiline\": \"error\",\n            \"no-unsafe-optional-chaining\": \"error\",\n            \"no-useless-backreference\": \"error\",\n            \"use-isnan\": \"error\",\n            \"prefer-const\": [\"error\", { destructuring: \"all\" }],\n            \"prefer-spread\": \"error\",\n\n            // Styling Rules\n            \"stylistic/spaced-comment\": [\"error\", \"always\", { markers: [\"!\"] }],\n            \"stylistic/no-extra-semi\": \"error\",\n\n            // Plugin Rules\n            \"importSort/imports\": \"error\",\n            \"importSort/exports\": \"error\",\n            \"unusedImports/no-unused-imports\": \"error\",\n            \"pathAlias/no-relative\": \"error\",\n            \"prettier/prettier\": \"error\"\n        }\n    }\n);\n"
  },
  {
    "path": "package.json",
    "content": "{\n    \"name\": \"vesktop\",\n    \"version\": \"1.6.5\",\n    \"private\": true,\n    \"description\": \"Vesktop is a custom Discord desktop app\",\n    \"keywords\": [],\n    \"homepage\": \"https://vencord.dev/\",\n    \"license\": \"GPL-3.0-or-later\",\n    \"author\": \"Vendicated <vendicated@riseup.net>\",\n    \"main\": \"dist/js/main.js\",\n    \"scripts\": {\n        \"build\": \"tsx scripts/build/build.mts\",\n        \"build:dev\": \"pnpm build --dev\",\n        \"buildLibVesktop\": \"pnpm -C packages/libvesktop install && pnpm -C packages/libvesktop run build\",\n        \"package\": \"pnpm build && electron-builder\",\n        \"package:dir\": \"pnpm build && electron-builder --dir\",\n        \"lint\": \"eslint\",\n        \"lint:fix\": \"pnpm lint --fix\",\n        \"start\": \"pnpm build && electron .\",\n        \"start:dev\": \"pnpm build:dev && electron .\",\n        \"start:watch\": \"pnpm build:dev && tsx scripts/startWatch.mts\",\n        \"test\": \"pnpm lint && pnpm testTypes\",\n        \"testTypes\": \"tsc --noEmit\",\n        \"watch\": \"pnpm build --watch\",\n        \"generateMeta\": \"tsx scripts/utils/generateMeta.mts\",\n        \"updateArrpcDB\": \"node ./node_modules/arrpc/update_db.js\",\n        \"postinstall\": \"pnpm updateArrpcDB\"\n    },\n    \"dependencies\": {\n        \"arrpc\": \"github:OpenAsar/arrpc#2234e9c9111f4c42ebcc3aa6a2215bfd979eef77\",\n        \"electron-updater\": \"^6.6.2\"\n    },\n    \"optionalDependencies\": {\n        \"@vencord/venmic\": \"^6.1.0\"\n    },\n    \"devDependencies\": {\n        \"@fal-works/esbuild-plugin-global-externals\": \"^2.1.2\",\n        \"@stylistic/eslint-plugin\": \"^5.8.0\",\n        \"@types/node\": \"^25.2.3\",\n        \"@types/react\": \"19.2.9\",\n        \"@vencord/types\": \"^1.14.1\",\n        \"dotenv\": \"^17.2.4\",\n        \"electron\": \"^40.4.0\",\n        \"electron-builder\": \"^26.7.0\",\n        \"esbuild\": \"^0.27.3\",\n        \"eslint\": \"^10.0.0\",\n        \"eslint-import-resolver-alias\": \"^1.1.2\",\n        \"eslint-plugin-path-alias\": \"^2.1.0\",\n        \"eslint-plugin-prettier\": \"^5.5.5\",\n        \"eslint-plugin-react\": \"^7.37.5\",\n        \"eslint-plugin-simple-header\": \"^1.2.2\",\n        \"eslint-plugin-simple-import-sort\": \"^12.1.1\",\n        \"eslint-plugin-unused-imports\": \"^4.4.1\",\n        \"libvesktop\": \"link:packages/libvesktop\",\n        \"prettier\": \"^3.8.1\",\n        \"source-map-support\": \"^0.5.21\",\n        \"tsx\": \"^4.21.0\",\n        \"type-fest\": \"^5.4.4\",\n        \"typescript\": \"^5.9.3\",\n        \"typescript-eslint\": \"^8.55.0\",\n        \"xml-formatter\": \"^3.6.7\"\n    },\n    \"packageManager\": \"pnpm@10.7.1\",\n    \"engines\": {\n        \"node\": \">=18\",\n        \"pnpm\": \">=8\"\n    },\n    \"build\": {\n        \"appId\": \"dev.vencord.vesktop\",\n        \"productName\": \"Vesktop\",\n        \"executableName\": \"vesktop\",\n        \"files\": [\n            \"!*\",\n            \"!node_modules\",\n            \"dist/js\",\n            \"static\",\n            \"package.json\",\n            \"LICENSE\"\n        ],\n        \"protocols\": {\n            \"name\": \"Discord\",\n            \"schemes\": [\n                \"discord\"\n            ]\n        },\n        \"beforePack\": \"scripts/build/beforePack.mjs\",\n        \"afterPack\": \"scripts/build/afterPack.mjs\",\n        \"linux\": {\n            \"icon\": \"build/icon.svg\",\n            \"category\": \"Network\",\n            \"maintainer\": \"vendicated+vesktop@riseup.net\",\n            \"target\": [\n                {\n                    \"target\": \"deb\",\n                    \"arch\": [\n                        \"x64\",\n                        \"arm64\"\n                    ]\n                },\n                {\n                    \"target\": \"tar.gz\",\n                    \"arch\": [\n                        \"x64\",\n                        \"arm64\"\n                    ]\n                },\n                {\n                    \"target\": \"rpm\",\n                    \"arch\": [\n                        \"x64\",\n                        \"arm64\"\n                    ]\n                },\n                {\n                    \"target\": \"AppImage\",\n                    \"arch\": [\n                        \"x64\",\n                        \"arm64\"\n                    ]\n                }\n            ],\n            \"desktop\": {\n                \"entry\": {\n                    \"Name\": \"Vesktop\",\n                    \"GenericName\": \"Internet Messenger\",\n                    \"Type\": \"Application\",\n                    \"Categories\": \"Network;InstantMessaging;Chat;\",\n                    \"Keywords\": \"discord;vencord;electron;chat;\",\n                    \"MimeType\": \"x-scheme-handler/discord\",\n                    \"StartupWMClass\": \"vesktop\"\n                }\n            }\n        },\n        \"mac\": {\n            \"target\": [\n                {\n                    \"target\": \"default\",\n                    \"arch\": [\n                        \"universal\"\n                    ]\n                }\n            ],\n            \"category\": \"public.app-category.social-networking\",\n            \"darkModeSupport\": true,\n            \"extendInfo\": {\n                \"NSMicrophoneUsageDescription\": \"This app needs access to the microphone\",\n                \"NSCameraUsageDescription\": \"This app needs access to the camera\",\n                \"com.apple.security.device.audio-input\": true,\n                \"com.apple.security.device.camera\": true,\n                \"CFBundleIconName\": \"Icon\"\n            },\n            \"notarize\": true\n        },\n        \"dmg\": {\n            \"background\": \"build/background.tiff\",\n            \"icon\": \"build/icon.icns\",\n            \"iconSize\": 105,\n            \"window\": {\n                \"width\": 512,\n                \"height\": 340\n            },\n            \"contents\": [\n                {\n                    \"x\": 140,\n                    \"y\": 160\n                },\n                {\n                    \"x\": 372,\n                    \"y\": 160,\n                    \"type\": \"link\",\n                    \"path\": \"/Applications\"\n                }\n            ]\n        },\n        \"nsis\": {\n            \"include\": \"build/installer.nsh\",\n            \"oneClick\": false\n        },\n        \"win\": {\n            \"icon\": \"build/icon.ico\",\n            \"target\": [\n                {\n                    \"target\": \"nsis\",\n                    \"arch\": [\n                        \"x64\",\n                        \"arm64\"\n                    ]\n                },\n                {\n                    \"target\": \"zip\",\n                    \"arch\": [\n                        \"x64\",\n                        \"arm64\"\n                    ]\n                }\n            ]\n        },\n        \"publish\": {\n            \"provider\": \"github\"\n        },\n        \"rpm\": {\n            \"fpm\": [\n                \"--rpm-rpmbuild-define=_build_id_links none\"\n            ]\n        },\n        \"electronFuses\": {\n            \"runAsNode\": false,\n            \"enableCookieEncryption\": false,\n            \"enableNodeOptionsEnvironmentVariable\": false,\n            \"enableNodeCliInspectArguments\": false,\n            \"enableEmbeddedAsarIntegrityValidation\": false,\n            \"onlyLoadAppFromAsar\": true,\n            \"loadBrowserProcessSpecificV8Snapshot\": false,\n            \"grantFileProtocolExtraPrivileges\": false\n        }\n    },\n    \"pnpm\": {\n        \"patchedDependencies\": {\n            \"arrpc@3.5.0\": \"patches/arrpc@3.5.0.patch\",\n            \"electron-updater\": \"patches/electron-updater.patch\"\n        },\n        \"onlyBuiltDependencies\": [\n            \"@vencord/venmic\",\n            \"electron\",\n            \"esbuild\"\n        ]\n    }\n}\n"
  },
  {
    "path": "packages/libvesktop/.gitignore",
    "content": "build"
  },
  {
    "path": "packages/libvesktop/Dockerfile",
    "content": "# Dockerfile for building both x64 and arm64 on an old distro for maximum compatibility.\n\n#  ubuntu20 is dead but debian11 is still supported for now\nFROM debian:11\nENV DEBIAN_FRONTEND=noninteractive\n\nRUN dpkg --add-architecture arm64\n\nRUN apt-get update && apt-get install -y \\\n    build-essential python3 curl pkg-config \\\n    g++-aarch64-linux-gnu libglib2.0-dev:amd64 libglib2.0-dev:arm64 \\\n    ca-certificates \\\n && rm -rf /var/lib/apt/lists/*\n\nRUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \\\n && apt-get update && apt-get install -y nodejs \\\n && rm -rf /var/lib/apt/lists/*\n\nWORKDIR /src\n"
  },
  {
    "path": "packages/libvesktop/binding.gyp",
    "content": "{\n  \"targets\": [\n    {\n      \"target_name\": \"libvesktop\",\n      \"sources\": [ \"src/libvesktop.cc\" ],\n      \"include_dirs\": [\n        \"<!@(node -p \\\"require('node-addon-api').include\\\")\"\n      ],\n      \"cflags_cc\": [\n        \"<!(pkg-config --cflags glib-2.0 gio-2.0)\",\n        \"-O3\"\n      ],\n      \"libraries\": [\n        \"<!@(pkg-config  --libs-only-l --libs-only-other glib-2.0 gio-2.0)\"\n      ],\n      \"cflags_cc!\": [\"-fno-exceptions\"],\n    }\n  ]\n}"
  },
  {
    "path": "packages/libvesktop/build.sh",
    "content": "#!/bin/sh\nset -e\n\ndocker build -t libvesktop-builder -f Dockerfile .\n\ndocker run --rm -v \"$PWD\":/src -w /src libvesktop-builder bash -c \"\n  set -e\n\n  echo '=== Building x64 ==='\n  npx node-gyp rebuild --arch=x64\n  mv build/Release/vesktop.node prebuilds/vesktop-x64.node\n\n  echo '=== Building arm64 ==='\n  export CXX=aarch64-linux-gnu-g++\n  npx node-gyp rebuild --arch=arm64\n  mv build/Release/vesktop.node prebuilds/vesktop-arm64.node\n\""
  },
  {
    "path": "packages/libvesktop/index.d.ts",
    "content": "export function getAccentColor(): number | null;\nexport function requestBackground(autoStart: boolean, commandLine: string[]): boolean;\nexport function updateUnityLauncherCount(count: number): boolean;\n"
  },
  {
    "path": "packages/libvesktop/package.json",
    "content": "{\n    \"name\": \"libvesktop\",\n    \"main\": \"build/Release/vesktop.node\",\n    \"types\": \"index.d.ts\",\n    \"devDependencies\": {\n        \"node-addon-api\": \"^8.5.0\",\n        \"node-gyp\": \"^11.4.2\"\n    },\n    \"scripts\": {\n        \"build\": \"node-gyp configure build\",\n        \"clean\": \"node-gyp clean\",\n        \"test\": \"npm run build && node test.js\"\n    }\n}\n"
  },
  {
    "path": "packages/libvesktop/src/libvesktop.cc",
    "content": "#include <gio/gio.h>\n#include <cstdlib>\n#include <cstdint>\n#include <iostream>\n#include <napi.h>\n#include <optional>\n#include <cmath>\n#include <memory>\n\ntemplate <typename T>\nstruct GObjectDeleter\n{\n    void operator()(T *obj) const\n    {\n        if (obj)\n            g_object_unref(obj);\n    }\n};\n\ntemplate <typename T>\nusing GObjectPtr = std::unique_ptr<T, GObjectDeleter<T>>;\n\nstruct GVariantDeleter\n{\n    void operator()(GVariant *variant) const\n    {\n        if (variant)\n            g_variant_unref(variant);\n    }\n};\n\nusing GVariantPtr = std::unique_ptr<GVariant, GVariantDeleter>;\n\nstruct GErrorDeleter\n{\n    void operator()(GError *error) const\n    {\n        if (error)\n            g_error_free(error);\n    }\n};\n\nusing GErrorPtr = std::unique_ptr<GError, GErrorDeleter>;\n\nbool update_launcher_count(int count)\n{\n    GError *error = nullptr;\n\n    const char *chromeDesktop = std::getenv(\"CHROME_DESKTOP\");\n    std::string desktop_id = std::string(\"application://\") + (chromeDesktop ? chromeDesktop : \"vesktop.desktop\");\n\n    GObjectPtr<GDBusConnection> bus(g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, &error));\n    if (!bus)\n    {\n        GErrorPtr error_ptr(error);\n        std::cerr << \"[libvesktop::update_launcher_count] Failed to connect to session bus: \"\n                  << (error_ptr ? error_ptr->message : \"unknown error\") << std::endl;\n        return false;\n    }\n\n    GVariantBuilder builder;\n    g_variant_builder_init(&builder, G_VARIANT_TYPE(\"a{sv}\"));\n    g_variant_builder_add(&builder, \"{sv}\", \"count\", g_variant_new_int64(count));\n    g_variant_builder_add(&builder, \"{sv}\", \"count-visible\", g_variant_new_boolean(count != 0));\n\n    gboolean result = g_dbus_connection_emit_signal(\n        bus.get(),\n        nullptr,\n        \"/\",\n        \"com.canonical.Unity.LauncherEntry\",\n        \"Update\",\n        g_variant_new(\"(sa{sv})\", desktop_id.c_str(), &builder),\n        &error);\n\n    if (!result || error)\n    {\n        GErrorPtr error_ptr(error);\n        std::cerr << \"[libvesktop::update_launcher_count] Failed to emit Update signal: \"\n                  << (error_ptr ? error_ptr->message : \"unknown error\") << std::endl;\n        return false;\n    }\n\n    return true;\n}\n\nstd::optional<int32_t> get_accent_color()\n{\n    GError *error = nullptr;\n\n    GObjectPtr<GDBusConnection> bus(g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, &error));\n    if (!bus)\n    {\n        GErrorPtr error_ptr(error);\n        std::cerr << \"[libvesktop::get_accent_color] Failed to connect to session bus: \"\n                  << (error_ptr ? error_ptr->message : \"unknown error\") << std::endl;\n        return std::nullopt;\n    }\n\n    GVariantPtr reply(g_dbus_connection_call_sync(\n        bus.get(),\n        \"org.freedesktop.portal.Desktop\",\n        \"/org/freedesktop/portal/desktop\",\n        \"org.freedesktop.portal.Settings\",\n        \"Read\",\n        g_variant_new(\"(ss)\", \"org.freedesktop.appearance\", \"accent-color\"),\n        nullptr,\n        G_DBUS_CALL_FLAGS_NONE,\n        5000,\n        nullptr,\n        &error));\n\n    if (!reply)\n    {\n        GErrorPtr error_ptr(error);\n        std::cerr << \"[libvesktop::get_accent_color] Failed to call Read: \"\n                  << (error_ptr ? error_ptr->message : \"unknown error\") << std::endl;\n        return std::nullopt;\n    }\n\n    GVariant *inner_raw = nullptr;\n    g_variant_get(reply.get(), \"(v)\", &inner_raw);\n    if (!inner_raw)\n    {\n        std::cerr << \"[libvesktop::get_accent_color] Inner variant is null\" << std::endl;\n        return std::nullopt;\n    }\n\n    GVariantPtr inner(inner_raw);\n\n    // Unwrap nested variants\n    while (g_variant_is_of_type(inner.get(), G_VARIANT_TYPE_VARIANT))\n    {\n        GVariant *next = g_variant_get_variant(inner.get());\n        inner.reset(next);\n    }\n\n    if (!g_variant_is_of_type(inner.get(), G_VARIANT_TYPE_TUPLE) ||\n        g_variant_n_children(inner.get()) < 3)\n    {\n        std::cerr << \"[libvesktop::get_accent_color] Inner variant is not a tuple of 3 doubles\" << std::endl;\n        return std::nullopt;\n    }\n\n    double r = 0.0, g = 0.0, b = 0.0;\n    g_variant_get(inner.get(), \"(ddd)\", &r, &g, &b);\n\n    bool discard = false;\n    auto toInt = [&discard](double v) -> int\n    {\n        if (!std::isfinite(v) || v < 0.0 || v > 1.0)\n        {\n            discard = true;\n            return 0;\n        }\n\n        return static_cast<int>(std::round(v * 255.0));\n    };\n\n    int32_t rgb = (toInt(r) << 16) | (toInt(g) << 8) | toInt(b);\n    if (discard)\n        return std::nullopt;\n\n    return rgb;\n}\n\nbool request_background(bool autostart, const std::vector<std::string> &commandline)\n{\n    GError *error = nullptr;\n\n    GObjectPtr<GDBusConnection> bus(g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, &error));\n    if (!bus)\n    {\n        GErrorPtr error_ptr(error);\n        std::cerr << \"[libvesktop::request_background] Failed to connect to session bus: \"\n                  << (error_ptr ? error_ptr->message : \"unknown error\") << std::endl;\n        return false;\n    }\n\n    GVariantBuilder builder;\n    g_variant_builder_init(&builder, G_VARIANT_TYPE(\"a{sv}\"));\n    g_variant_builder_add(&builder, \"{sv}\", \"autostart\", g_variant_new_boolean(autostart));\n\n    if (!commandline.empty())\n    {\n        GVariantBuilder cmd_builder;\n        g_variant_builder_init(&cmd_builder, G_VARIANT_TYPE(\"as\"));\n        for (const auto &s : commandline)\n            g_variant_builder_add(&cmd_builder, \"s\", s.c_str());\n        g_variant_builder_add(&builder, \"{sv}\", \"commandline\", g_variant_builder_end(&cmd_builder));\n    }\n\n    GVariantPtr reply(g_dbus_connection_call_sync(\n        bus.get(),\n        \"org.freedesktop.portal.Desktop\",\n        \"/org/freedesktop/portal/desktop\",\n        \"org.freedesktop.portal.Background\",\n        \"RequestBackground\",\n        g_variant_new(\"(sa{sv})\", \"\", &builder),\n        nullptr,\n        G_DBUS_CALL_FLAGS_NONE,\n        5000,\n        nullptr,\n        &error));\n\n    if (!reply)\n    {\n        GErrorPtr error_ptr(error);\n        std::cerr << \"[libvesktop::request_background] Failed to call RequestBackground: \"\n                  << (error_ptr ? error_ptr->message : \"unknown error\") << std::endl;\n        return false;\n    }\n\n    return true;\n}\n\nNapi::Value updateUnityLauncherCount(Napi::CallbackInfo const &info)\n{\n    if (info.Length() < 1 || !info[0].IsNumber())\n    {\n        Napi::TypeError::New(info.Env(), \"Expected (number)\").ThrowAsJavaScriptException();\n        return info.Env().Undefined();\n    }\n\n    int count = info[0].As<Napi::Number>().Int32Value();\n    bool success = update_launcher_count(count);\n    return Napi::Boolean::New(info.Env(), success);\n}\n\nNapi::Value getAccentColor(const Napi::CallbackInfo &info)\n{\n    auto color = get_accent_color();\n    if (color)\n        return Napi::Number::New(info.Env(), *color);\n    return info.Env().Null();\n}\n\nNapi::Value RequestBackground(const Napi::CallbackInfo &info)\n{\n    Napi::Env env = info.Env();\n\n    if (info.Length() < 2 || !info[0].IsBoolean() || !info[1].IsArray())\n    {\n        Napi::TypeError::New(env, \"Expected (boolean, string[])\").ThrowAsJavaScriptException();\n        return env.Null();\n    }\n\n    bool autostart = info[0].As<Napi::Boolean>();\n    Napi::Array arr = info[1].As<Napi::Array>();\n    std::vector<std::string> commandline;\n    for (uint32_t i = 0; i < arr.Length(); i++)\n    {\n        Napi::Value v = arr.Get(i);\n        if (v.IsString())\n            commandline.push_back(v.As<Napi::String>().Utf8Value());\n    }\n\n    bool ok = request_background(autostart, commandline);\n    return Napi::Boolean::New(env, ok);\n}\n\nNapi::Object Init(Napi::Env env, Napi::Object exports)\n{\n    exports.Set(\"updateUnityLauncherCount\", Napi::Function::New(env, updateUnityLauncherCount));\n    exports.Set(\"getAccentColor\", Napi::Function::New(env, getAccentColor));\n    exports.Set(\"requestBackground\", Napi::Function::New(env, RequestBackground));\n    return exports;\n}\n\nNODE_API_MODULE(libvesktop, Init)\n"
  },
  {
    "path": "packages/libvesktop/test.js",
    "content": "/**\n * @type {typeof import(\".\")}\n */\nconst libVesktop = require(\".\");\nconst test = require(\"node:test\");\nconst assert = require(\"node:assert/strict\");\n\ntest(\"getAccentColor should return a number\", () => {\n    const color = libVesktop.getAccentColor();\n    assert.strictEqual(typeof color, \"number\");\n});\n\ntest(\"updateUnityLauncherCount should return true (success)\", () => {\n    assert.strictEqual(libVesktop.updateUnityLauncherCount(5), true);\n    assert.strictEqual(libVesktop.updateUnityLauncherCount(0), true);\n    assert.strictEqual(libVesktop.updateUnityLauncherCount(10), true);\n});\n\ntest(\"requestBackground should return true (success)\", () => {\n    assert.strictEqual(libVesktop.requestBackground(true, [\"bash\"]), true);\n    assert.strictEqual(libVesktop.requestBackground(false, []), true);\n});\n"
  },
  {
    "path": "patches/arrpc@3.5.0.patch",
    "content": "diff --git a/src/process/index.js b/src/process/index.js\nindex 389b0845256a34b4536d6da99edb00d17f13a6b4..f17a0ac687e9110ebfd33cb91fd2f6250d318643 100644\n--- a/src/process/index.js\n+++ b/src/process/index.js\n@@ -5,8 +5,20 @@ import fs from 'node:fs';\n import { dirname, join } from 'path';\n import { fileURLToPath } from 'url';\n \n-const __dirname = dirname(fileURLToPath(import.meta.url));\n-const DetectableDB = JSON.parse(fs.readFileSync(join(__dirname, 'detectable.json'), 'utf8'));\n+const DetectableDB = require('./detectable.json');\n+DetectableDB.push(\n+  {\n+    aliases: [\"Obs\"],\n+    executables: [\n+      { is_launcher: false, name: \"obs\", os: \"linux\" },\n+      { is_launcher: false, name: \"obs.exe\", os: \"win32\" },\n+      { is_launcher: false, name: \"obs.app\", os: \"darwin\" }\n+    ],\n+    hook: true,\n+    id: \"STREAMERMODE\",\n+    name: \"OBS\"\n+  }\n+);\n \n import * as Natives from './native/index.js';\n const Native = Natives[process.platform];\n"
  },
  {
    "path": "patches/electron-updater.patch",
    "content": "diff --git a/out/RpmUpdater.js b/out/RpmUpdater.js\nindex 563187bb18cb0bd154dff6620cb62b8c8f534cd6..d91594026c2bac9cc78ef3b1183df3241d7d9624 100644\n--- a/out/RpmUpdater.js\n+++ b/out/RpmUpdater.js\n@@ -32,7 +32,10 @@ class RpmUpdater extends BaseUpdater_1.BaseUpdater {\n         const sudo = this.wrapSudo();\n         // pkexec doesn't want the command to be wrapped in \" quotes\n         const wrapper = /pkexec/i.test(sudo) ? \"\" : `\"`;\n-        const packageManager = this.spawnSyncLog(\"which zypper\");\n+        let packageManager;\n+        try {\n+            packageManager = this.spawnSyncLog(\"which zypper\");\n+        } catch {}\n         const installerPath = this.installerPath;\n         if (installerPath == null) {\n             this.dispatchError(new Error(\"No valid update available, can't quit and install\"));\n"
  },
  {
    "path": "scripts/build/addAssetsCar.mjs",
    "content": "import { copyFile, readdir } from \"fs/promises\";\n\n/**\n * @param {{\n *   readonly appOutDir: string;\n *   readonly arch: Arch;\n *   readonly electronPlatformName: string;\n *   readonly outDir: string;\n *   readonly packager: PlatformPackager;\n *   readonly targets: Target[];\n * }} context\n */\nexport async function addAssetsCar({ appOutDir }) {\n    if (process.platform !== \"darwin\") return;\n\n    const appName = (await readdir(appOutDir)).find(item => item.endsWith(\".app\"));\n\n    if (!appName) {\n        console.warn(`Could not find .app directory in ${appOutDir}. Skipping adding assets.car`);\n        return;\n    }\n\n    await copyFile(\"build/Assets.car\", `${appOutDir}/${appName}/Contents/Resources/Assets.car`);\n}\n"
  },
  {
    "path": "scripts/build/afterPack.mjs",
    "content": "import { addAssetsCar } from \"./addAssetsCar.mjs\";\n\nexport default async function afterPack(context) {\n    await addAssetsCar(context);\n}\n"
  },
  {
    "path": "scripts/build/beforePack.mjs",
    "content": "import { applyAppImageSandboxFix } from \"./sandboxFix.mjs\";\n\nexport default async function beforePack() {\n    await applyAppImageSandboxFix();\n}\n"
  },
  {
    "path": "scripts/build/build.mts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { BuildContext, BuildOptions, context } from \"esbuild\";\nimport { copyFile } from \"fs/promises\";\n\nimport vencordDep from \"./vencordDep.mjs\";\nimport { includeDirPlugin } from \"./includeDirPlugin.mts\";\n\nconst isDev = process.argv.includes(\"--dev\");\n\nconst CommonOpts: BuildOptions = {\n    minify: !isDev,\n    bundle: true,\n    sourcemap: \"linked\",\n    logLevel: \"info\"\n};\n\nconst NodeCommonOpts: BuildOptions = {\n    ...CommonOpts,\n    format: \"cjs\",\n    platform: \"node\",\n    external: [\"electron\"],\n    target: [\"esnext\"],\n    loader: {\n        \".node\": \"file\"\n    },\n    define: {\n        IS_DEV: JSON.stringify(isDev)\n    }\n};\n\nconst contexts = [] as BuildContext[];\nasync function createContext(options: BuildOptions) {\n    contexts.push(await context(options));\n}\n\nasync function copyVenmic() {\n    if (process.platform !== \"linux\") return;\n\n    return Promise.all([\n        copyFile(\n            \"./node_modules/@vencord/venmic/prebuilds/venmic-addon-linux-x64/node-napi-v7.node\",\n            \"./static/dist/venmic-x64.node\"\n        ),\n        copyFile(\n            \"./node_modules/@vencord/venmic/prebuilds/venmic-addon-linux-arm64/node-napi-v7.node\",\n            \"./static/dist/venmic-arm64.node\"\n        )\n    ]).catch(() => console.warn(\"Failed to copy venmic. Building without venmic support\"));\n}\n\nasync function copyLibVesktop() {\n    if (process.platform !== \"linux\") return;\n\n    try {\n        await copyFile(\n            \"./packages/libvesktop/build/Release/vesktop.node\",\n            `./static/dist/libvesktop-${process.arch}.node`\n        );\n        console.log(\"Using local libvesktop build\");\n    } catch {\n        console.log(\n            \"Using prebuilt libvesktop binaries. Run `pnpm buildLibVesktop` and build again to build from source - see README.md for more details\"\n        );\n        return Promise.all([\n            copyFile(\"./packages/libvesktop/prebuilds/vesktop-x64.node\", \"./static/dist/libvesktop-x64.node\"),\n            copyFile(\"./packages/libvesktop/prebuilds/vesktop-arm64.node\", \"./static/dist/libvesktop-arm64.node\")\n        ]).catch(() => console.warn(\"Failed to copy libvesktop. Building without libvesktop support\"));\n    }\n}\n\nawait Promise.all([\n    copyVenmic(),\n    copyLibVesktop(),\n    createContext({\n        ...NodeCommonOpts,\n        entryPoints: [\"src/main/index.ts\"],\n        outfile: \"dist/js/main.js\",\n        footer: { js: \"//# sourceURL=VesktopMain\" }\n    }),\n    createContext({\n        ...NodeCommonOpts,\n        entryPoints: [\"src/main/arrpc/worker.ts\"],\n        outfile: \"dist/js/arRpcWorker.js\",\n        footer: { js: \"//# sourceURL=VesktopArRpcWorker\" }\n    }),\n    createContext({\n        ...NodeCommonOpts,\n        entryPoints: [\"src/preload/index.ts\"],\n        outfile: \"dist/js/preload.js\",\n        footer: { js: \"//# sourceURL=VesktopPreload\" }\n    }),\n    createContext({\n        ...NodeCommonOpts,\n        entryPoints: [\"src/preload/splash.ts\"],\n        outfile: \"dist/js/splashPreload.js\",\n        footer: { js: \"//# sourceURL=VesktopSplashPreload\" }\n    }),\n    createContext({\n        ...NodeCommonOpts,\n        entryPoints: [\"src/preload/updater.ts\"],\n        outfile: \"dist/js/updaterPreload.js\",\n        footer: { js: \"//# sourceURL=VesktopUpdaterPreload\" }\n    }),\n    createContext({\n        ...CommonOpts,\n        globalName: \"Vesktop\",\n        entryPoints: [\"src/renderer/index.ts\"],\n        outfile: \"dist/js/renderer.js\",\n        format: \"iife\",\n        inject: [\"./scripts/build/injectReact.mjs\"],\n        jsxFactory: \"VencordCreateElement\",\n        jsxFragment: \"VencordFragment\",\n        external: [\"@vencord/types/*\"],\n        plugins: [vencordDep, includeDirPlugin(\"patches\", \"src/renderer/patches\")],\n        footer: { js: \"//# sourceURL=VesktopRenderer\" }\n    })\n]);\n\nconst watch = process.argv.includes(\"--watch\");\n\nif (watch) {\n    await Promise.all(contexts.map(ctx => ctx.watch()));\n} else {\n    await Promise.all(\n        contexts.map(async ctx => {\n            await ctx.rebuild();\n            await ctx.dispose();\n        })\n    );\n}\n"
  },
  {
    "path": "scripts/build/includeDirPlugin.mts",
    "content": "import { Plugin } from \"esbuild\";\nimport { readdir } from \"fs/promises\";\n\nconst makeImportAllCode = (files: string[]) =>\n    files.map(f => `require(\"./${f.replace(/\\.[cm]?[tj]sx?$/, \"\")}\")`).join(\"\\n\");\n\nconst makeImportDirRecursiveCode = (dir: string) => readdir(dir).then(files => makeImportAllCode(files));\n\nexport function includeDirPlugin(namespace: string, path: string): Plugin {\n    return {\n        name: `include-dir-plugin:${namespace}`,\n        setup(build) {\n            const filter = new RegExp(`^__${namespace}__$`);\n\n            build.onResolve({ filter }, args => ({ path: args.path, namespace }));\n\n            build.onLoad({ filter, namespace }, async args => {\n                return {\n                    contents: await makeImportDirRecursiveCode(path),\n                    resolveDir: path\n                };\n            });\n        }\n    };\n}\n"
  },
  {
    "path": "scripts/build/injectReact.mjs",
    "content": "export const VencordFragment = /* #__PURE__*/ Symbol.for(\"react.fragment\");\nexport let VencordCreateElement = (...args) =>\n    (VencordCreateElement = Vencord.Webpack.Common.React.createElement)(...args);\n"
  },
  {
    "path": "scripts/build/sandboxFix.mjs",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\n// Based on https://github.com/gergof/electron-builder-sandbox-fix/blob/master/lib/index.js\n\nimport fs from \"fs/promises\";\nimport path from \"path\";\nimport AppImageTarget from \"app-builder-lib/out/targets/AppImageTarget.js\";\n\nlet isApplied = false;\n\nexport async function applyAppImageSandboxFix() {\n    if (process.platform !== \"linux\") {\n        // this fix is only required on linux\n        return;\n    }\n\n    if (isApplied) return;\n    isApplied = true;\n\n    const oldBuildMethod = AppImageTarget.default.prototype.build;\n    AppImageTarget.default.prototype.build = async function (...args) {\n        console.log(\"Running AppImage builder hook\", args);\n        const oldPath = args[0];\n        const newPath = oldPath + \"-appimage-sandbox-fix\";\n        // just in case\n        try {\n            await fs.rm(newPath, {\n                recursive: true\n            });\n        } catch {}\n\n        console.log(\"Copying to apply appimage fix\", oldPath, newPath);\n        await fs.cp(oldPath, newPath, {\n            recursive: true\n        });\n        args[0] = newPath;\n\n        const executable = path.join(newPath, this.packager.executableName);\n\n        const loaderScript = `\n#!/usr/bin/env bash\n\nSCRIPT_DIR=\"$( cd \"$( dirname \"\\${BASH_SOURCE[0]}\" )\" && pwd )\"\nIS_STEAMOS=0\n\nif [[ \"$SteamOS\" == \"1\" && \"$SteamGamepadUI\" == \"1\" ]]; then\n    echo \"Running Vesktop on SteamOS, disabling sandbox\"\n    IS_STEAMOS=1\nfi\n\nexec \"$SCRIPT_DIR/${this.packager.executableName}.bin\" \"$([ \"$IS_STEAMOS\" == 1 ] && echo '--no-sandbox')\" \"$@\"\n                `.trim();\n\n        try {\n            await fs.rename(executable, executable + \".bin\");\n            await fs.writeFile(executable, loaderScript);\n            await fs.chmod(executable, 0o755);\n        } catch (e) {\n            console.error(\"failed to create loder for sandbox fix: \" + e.message);\n            throw new Error(\"Failed to create loader for sandbox fix\");\n        }\n\n        const ret = await oldBuildMethod.apply(this, args);\n\n        await fs.rm(newPath, {\n            recursive: true\n        });\n\n        return ret;\n    };\n}\n"
  },
  {
    "path": "scripts/build/vencordDep.mts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { globalExternalsWithRegExp } from \"@fal-works/esbuild-plugin-global-externals\";\n\nconst names = {\n    webpack: \"Vencord.Webpack\",\n    \"webpack/common\": \"Vencord.Webpack.Common\",\n    utils: \"Vencord.Util\",\n    api: \"Vencord.Api\",\n    \"api/settings\": \"Vencord\",\n    components: \"Vencord.Components\"\n};\n\nexport default globalExternalsWithRegExp({\n    getModuleInfo(modulePath) {\n        const path = modulePath.replace(\"@vencord/types/\", \"\");\n        let varName = names[path];\n        if (!varName) {\n            const altMapping = names[path.split(\"/\")[0]];\n            if (!altMapping) throw new Error(\"Unknown module path: \" + modulePath);\n\n            varName =\n                altMapping +\n                \".\" +\n                // @ts-ignore\n                path.split(\"/\")[1].replaceAll(\"/\", \".\");\n        }\n        return {\n            varName,\n            type: \"cjs\"\n        };\n    },\n    modulePathFilter: /^@vencord\\/types.+$/\n});\n"
  },
  {
    "path": "scripts/header.txt",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) {year} {author}\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n"
  },
  {
    "path": "scripts/start.ts",
    "content": "/*\n * SPDX-License-Identifier: GPL-3.0\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n */\n\nimport \"./utils/dotenv\";\n\nimport { spawnNodeModuleBin } from \"./utils/spawn.mjs\";\n\nspawnNodeModuleBin(\"electron\", [process.cwd(), ...(process.env.ELECTRON_LAUNCH_FLAGS?.split(\" \") ?? [])]);\n"
  },
  {
    "path": "scripts/startWatch.mts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport \"./start\";\n\nimport { spawnNodeModuleBin } from \"./utils/spawn.mjs\";\nspawnNodeModuleBin(\"tsx\", [\"scripts/build/build.mts\", \"--\", \"--watch\", \"--dev\"]);\n"
  },
  {
    "path": "scripts/utils/dotenv.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { config } from \"dotenv\";\n\nconfig();\n"
  },
  {
    "path": "scripts/utils/generateMeta.mts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { promises as fs } from \"node:fs\";\nimport { mkdir } from \"node:fs/promises\";\nimport { DOMParser, XMLSerializer } from \"@xmldom/xmldom\";\nimport xmlFormat from \"xml-formatter\";\n\nfunction generateDescription(description: string, descriptionNode: Element) {\n    const lines = description.replace(/\\r/g, \"\").split(\"\\n\");\n    let currentList: Element | null = null;\n\n    for (let i = 0; i < lines.length; i++) {\n        const line = lines[i];\n\n        if (line.includes(\"New Contributors\")) {\n            // we're done, don't parse any more since the new contributors section is the last one\n            break;\n        }\n\n        if (line.startsWith(\"## \")) {\n            const pNode = descriptionNode.ownerDocument.createElement(\"p\");\n            pNode.textContent = line.slice(3);\n            descriptionNode.appendChild(pNode);\n        } else if (line.startsWith(\"* \")) {\n            const liNode = descriptionNode.ownerDocument.createElement(\"li\");\n            liNode.textContent = line.slice(2).split(\"in https://github.com\")[0].trim(); // don't include links to github\n\n            if (!currentList) {\n                currentList = descriptionNode.ownerDocument.createElement(\"ul\");\n            }\n\n            currentList.appendChild(liNode);\n        }\n\n        if (currentList && !lines[i + 1].startsWith(\"* \")) {\n            descriptionNode.appendChild(currentList);\n            currentList = null;\n        }\n    }\n}\n\nconst releases = await fetch(\"https://api.github.com/repos/Vencord/Vesktop/releases\", {\n    headers: {\n        Accept: \"application/vnd.github+json\",\n        \"X-Github-Api-Version\": \"2022-11-28\"\n    }\n}).then(res => res.json());\n\nconst latestReleaseInformation = releases[0];\n\nconst metaInfo = await (async () => {\n    for (const release of releases) {\n        const metaAsset = release.assets.find((a: any) => a.name === \"dev.vencord.Vesktop.metainfo.xml\");\n        if (metaAsset) return fetch(metaAsset.browser_download_url).then(res => res.text());\n    }\n})();\n\nif (!metaInfo) {\n    throw new Error(\"Could not find existing meta information from any release\");\n}\n\nconst parser = new DOMParser().parseFromString(metaInfo, \"text/xml\");\n\nconst releaseList = parser.getElementsByTagName(\"releases\")[0];\n\nfor (let i = 0; i < releaseList.childNodes.length; i++) {\n    const release = releaseList.childNodes[i] as Element;\n\n    if (release.nodeType === 1 && release.getAttribute(\"version\") === latestReleaseInformation.name) {\n        console.log(\"Latest release already added, nothing to be done\");\n        process.exit(0);\n    }\n}\n\nconst release = parser.createElement(\"release\");\nrelease.setAttribute(\"version\", latestReleaseInformation.name);\nrelease.setAttribute(\"date\", latestReleaseInformation.published_at.split(\"T\")[0]);\nrelease.setAttribute(\"type\", \"stable\");\n\nconst releaseUrl = parser.createElement(\"url\");\nreleaseUrl.textContent = latestReleaseInformation.html_url;\n\nrelease.appendChild(releaseUrl);\n\nconst description = parser.createElement(\"description\");\n\n// we're not using a full markdown parser here since we don't have a lot of formatting options to begin with\ngenerateDescription(latestReleaseInformation.body, description);\n\nrelease.appendChild(description);\n\nreleaseList.insertBefore(release, releaseList.childNodes[0]);\n\nconst output = xmlFormat(new XMLSerializer().serializeToString(parser), {\n    lineSeparator: \"\\n\",\n    collapseContent: true,\n    indentation: \"  \"\n});\n\nawait mkdir(\"./dist\", { recursive: true });\nawait fs.writeFile(\"./dist/dev.vencord.Vesktop.metainfo.xml\", output, \"utf-8\");\n\nconsole.log(\"Updated meta information written to ./dist/dev.vencord.Vesktop.metainfo.xml\");\n"
  },
  {
    "path": "scripts/utils/spawn.mts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { spawn as spaaawn, SpawnOptions } from \"child_process\";\nimport { join } from \"path\";\n\nconst EXT = process.platform === \"win32\" ? \".cmd\" : \"\";\n\nconst OPTS: SpawnOptions = {\n    stdio: \"inherit\"\n};\n\nexport function spawnNodeModuleBin(bin: string, args: string[]) {\n    spaaawn(join(\"node_modules\", \".bin\", bin + EXT), args, OPTS);\n}\n"
  },
  {
    "path": "src/globals.d.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\ndeclare global {\n    export var VesktopNative: typeof import(\"preload/VesktopNative\").VesktopNative;\n    export var Vesktop: typeof import(\"renderer/index\");\n    export var VesktopPatchGlobals: any;\n\n    export var IS_DEV: boolean;\n}\n\nexport {};\n"
  },
  {
    "path": "src/main/about.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { app, BrowserWindow } from \"electron\";\n\nimport { makeLinksOpenExternally } from \"./utils/makeLinksOpenExternally\";\nimport { loadView } from \"./vesktopStatic\";\n\nexport async function createAboutWindow() {\n    const height = 750;\n    const width = height * (4 / 3);\n\n    const about = new BrowserWindow({\n        center: true,\n        autoHideMenuBar: true,\n        height,\n        width\n    });\n\n    makeLinksOpenExternally(about);\n\n    const data = new URLSearchParams({\n        APP_VERSION: app.getVersion()\n    });\n\n    loadView(about, \"about.html\", data);\n\n    return about;\n}\n"
  },
  {
    "path": "src/main/appBadge.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { app, NativeImage, nativeImage } from \"electron\";\nimport { join } from \"path\";\nimport { BADGE_DIR } from \"shared/paths\";\n\nimport { updateUnityLauncherCount } from \"./dbus\";\nimport { AppEvents } from \"./events\";\nimport { mainWin } from \"./mainWindow\";\n\nconst imgCache = new Map<number, NativeImage>();\nfunction loadBadge(index: number) {\n    const cached = imgCache.get(index);\n    if (cached) return cached;\n\n    const img = nativeImage.createFromPath(join(BADGE_DIR, `${index}.ico`));\n    imgCache.set(index, img);\n\n    return img;\n}\n\nlet lastIndex: null | number = -1;\n\n/**\n * -1 = show unread indicator\n * 0 = clear\n */\nexport function setBadgeCount(count: number) {\n    AppEvents.emit(\"setTrayVariant\", count !== 0 ? \"trayUnread\" : \"tray\");\n\n    switch (process.platform) {\n        case \"linux\":\n            if (count === -1) count = 0;\n            updateUnityLauncherCount(count);\n            break;\n        case \"darwin\":\n            if (count === 0) {\n                app.dock!.setBadge(\"\");\n                break;\n            }\n            app.dock!.setBadge(count === -1 ? \"•\" : count.toString());\n            break;\n        case \"win32\":\n            const [index, description] = getBadgeIndexAndDescription(count);\n            if (lastIndex === index) break;\n\n            lastIndex = index;\n\n            mainWin.setOverlayIcon(index === null ? null : loadBadge(index), description);\n            break;\n    }\n}\n\nfunction getBadgeIndexAndDescription(count: number): [number | null, string] {\n    if (count === -1) return [11, \"Unread Messages\"];\n    if (count === 0) return [null, \"No Notifications\"];\n\n    const index = Math.max(1, Math.min(count, 10));\n    return [index, `${index} Notification`];\n}\n"
  },
  {
    "path": "src/main/arrpc/index.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { resolve } from \"path\";\nimport { IpcCommands } from \"shared/IpcEvents\";\nimport { MessageChannel, Worker } from \"worker_threads\";\n\nimport { sendRendererCommand } from \"../ipcCommands\";\nimport { Settings } from \"../settings\";\nimport { ArRpcEvent, ArRpcHostEvent } from \"./types\";\n\nlet worker: Worker;\n\nconst inviteCodeRegex = /^(\\w|-)+$/;\n\nexport async function initArRPC() {\n    if (worker || !Settings.store.arRPC) return;\n\n    try {\n        const { port1: hostPort, port2: workerPort } = new MessageChannel();\n\n        worker = new Worker(resolve(__dirname, \"./arRpcWorker.js\"), {\n            workerData: {\n                workerPort\n            },\n            transferList: [workerPort]\n        });\n\n        hostPort.on(\"message\", async ({ type, nonce, data }: ArRpcEvent) => {\n            switch (type) {\n                case \"activity\": {\n                    sendRendererCommand(IpcCommands.RPC_ACTIVITY, data);\n                    break;\n                }\n\n                case \"invite\": {\n                    const invite = String(data);\n\n                    const response: ArRpcHostEvent = {\n                        type: \"ack-invite\",\n                        nonce,\n                        data: false\n                    };\n\n                    if (!inviteCodeRegex.test(invite)) {\n                        return hostPort.postMessage(response);\n                    }\n\n                    response.data = await sendRendererCommand(IpcCommands.RPC_INVITE, invite).catch(() => false);\n\n                    hostPort.postMessage(response);\n                    break;\n                }\n\n                case \"link\": {\n                    const response: ArRpcHostEvent = {\n                        type: \"ack-link\",\n                        nonce: nonce,\n                        data: false\n                    };\n\n                    response.data = await sendRendererCommand(IpcCommands.RPC_DEEP_LINK, data).catch(() => false);\n\n                    hostPort.postMessage(response);\n                    break;\n                }\n            }\n        });\n    } catch (e) {\n        console.error(\"Failed to start arRPC server\", e);\n    }\n}\n\nSettings.addChangeListener(\"arRPC\", initArRPC);\n"
  },
  {
    "path": "src/main/arrpc/types.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vesktop contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nexport type ArRpcEvent = ArRpcActivityEvent | ArRpcInviteEvent | ArRpcLinkEvent;\nexport type ArRpcHostEvent = ArRpcHostAckInviteEvent | ArRpcHostAckLinkEvent;\n\nexport interface ArRpcActivityEvent {\n    type: \"activity\";\n    nonce: string;\n    data: string;\n}\n\nexport interface ArRpcInviteEvent {\n    type: \"invite\";\n    nonce: string;\n    data: string;\n}\n\nexport interface ArRpcLinkEvent {\n    type: \"link\";\n    nonce: string;\n    data: any;\n}\n\nexport interface ArRpcHostAckInviteEvent {\n    type: \"ack-invite\";\n    nonce: string;\n    data: boolean;\n}\n\nexport interface ArRpcHostAckLinkEvent {\n    type: \"ack-link\";\n    nonce: string;\n    data: boolean;\n}\n"
  },
  {
    "path": "src/main/arrpc/worker.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vesktop contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport Server from \"arrpc\";\nimport { randomUUID } from \"crypto\";\nimport { MessagePort, workerData } from \"worker_threads\";\n\nimport { ArRpcEvent, ArRpcHostEvent } from \"./types\";\n\nlet server: any;\n\ntype InviteCallback = (valid: boolean) => void;\ntype LinkCallback = InviteCallback;\n\nconst inviteCallbacks = new Map<string, InviteCallback>();\nconst linkCallbacks = new Map<string, LinkCallback>();\n\n(async function () {\n    const { workerPort } = workerData as { workerPort: MessagePort };\n\n    server = await new Server();\n\n    server.on(\"activity\", (data: any) => {\n        const event: ArRpcEvent = {\n            type: \"activity\",\n            data: JSON.stringify(data),\n            nonce: randomUUID()\n        };\n        workerPort.postMessage(event);\n    });\n\n    server.on(\"invite\", (invite: string, callback: InviteCallback) => {\n        const nonce = randomUUID();\n        inviteCallbacks.set(nonce, callback);\n\n        const event: ArRpcEvent = {\n            type: \"invite\",\n            data: invite,\n            nonce\n        };\n        workerPort.postMessage(event);\n    });\n\n    server.on(\"link\", async (data: any, callback: LinkCallback) => {\n        const nonce = randomUUID();\n        linkCallbacks.set(nonce, callback);\n\n        const event: ArRpcEvent = {\n            type: \"link\",\n            data,\n            nonce\n        };\n        workerPort.postMessage(event);\n    });\n\n    workerPort.on(\"message\", (e: ArRpcHostEvent) => {\n        switch (e.type) {\n            case \"ack-invite\": {\n                inviteCallbacks.get(e.nonce)?.(e.data);\n                inviteCallbacks.delete(e.nonce);\n                break;\n            }\n            case \"ack-link\": {\n                linkCallbacks.get(e.nonce)?.(e.data);\n                linkCallbacks.delete(e.nonce);\n                break;\n            }\n        }\n    });\n})();\n"
  },
  {
    "path": "src/main/autoStart.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { app } from \"electron\";\nimport { existsSync, mkdirSync, rmSync, writeFileSync } from \"fs\";\nimport { join } from \"path\";\nimport { stripIndent } from \"shared/utils/text\";\n\nimport { IS_FLATPAK } from \"./constants\";\nimport { requestBackground } from \"./dbus\";\nimport { Settings, State } from \"./settings\";\nimport { escapeDesktopFileArgument } from \"./utils/desktopFileEscape\";\n\ninterface AutoStart {\n    isEnabled(): boolean;\n    enable(): void;\n    disable(): void;\n}\n\nfunction getEscapedCommandLine() {\n    const args = process.argv.map(escapeDesktopFileArgument);\n    if (Settings.store.autoStartMinimized) args.push(\"--start-minimized\");\n    return args;\n}\n\nfunction makeAutoStartLinuxDesktop(): AutoStart {\n    const configDir = process.env.XDG_CONFIG_HOME || join(process.env.HOME!, \".config\");\n    const dir = join(configDir, \"autostart\");\n    const file = join(dir, \"vesktop.desktop\");\n\n    return {\n        isEnabled: () => existsSync(file),\n        enable() {\n            const desktopFile = stripIndent`\n                [Desktop Entry]\n                Type=Application\n                Name=Vesktop\n                Comment=Vesktop autostart script\n                Exec=${getEscapedCommandLine().join(\" \")}\n                StartupNotify=false\n                Terminal=false\n                Icon=vesktop\n            `;\n\n            mkdirSync(dir, { recursive: true });\n            writeFileSync(file, desktopFile);\n        },\n        disable: () => rmSync(file, { force: true })\n    };\n}\n\nfunction makeAutoStartLinuxPortal() {\n    return {\n        isEnabled: () => State.store.linuxAutoStartEnabled === true,\n        enable() {\n            const success = requestBackground(true, getEscapedCommandLine());\n            if (success) {\n                State.store.linuxAutoStartEnabled = true;\n            }\n            return success;\n        },\n        disable() {\n            const success = requestBackground(false, []);\n            if (success) {\n                State.store.linuxAutoStartEnabled = false;\n            }\n            return success;\n        }\n    };\n}\n\nconst autoStartWindowsMac: AutoStart = {\n    isEnabled: () => app.getLoginItemSettings().openAtLogin,\n    enable: () =>\n        app.setLoginItemSettings({\n            openAtLogin: true,\n            args: Settings.store.autoStartMinimized ? [\"--start-minimized\"] : []\n        }),\n    disable: () => app.setLoginItemSettings({ openAtLogin: false })\n};\n\n// The portal call uses the app id by default, which is org.chromium.Chromium, even in packaged Vesktop.\n// This leads to an autostart entry named \"Chromium\" instead of \"Vesktop\".\n// Thus, only use the portal inside Flatpak, where the app is actually correct.\n// Maybe there is a way to fix it outside of flatpak, but I couldn't figure it out.\nexport const autoStart =\n    process.platform !== \"linux\"\n        ? autoStartWindowsMac\n        : IS_FLATPAK\n          ? makeAutoStartLinuxPortal()\n          : makeAutoStartLinuxDesktop();\n\nSettings.addChangeListener(\"autoStartMinimized\", () => {\n    if (!autoStart.isEnabled()) return;\n\n    autoStart.enable();\n});\n"
  },
  {
    "path": "src/main/cli.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vesktop contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { app } from \"electron\";\nimport { basename } from \"path\";\nimport { stripIndent } from \"shared/utils/text\";\nimport { parseArgs, ParseArgsOptionDescriptor } from \"util\";\n\ntype Option = ParseArgsOptionDescriptor & {\n    description: string;\n    hidden?: boolean;\n    options?: string[];\n    argumentName?: string;\n};\n\nconst options = {\n    \"start-minimized\": {\n        default: false,\n        type: \"boolean\",\n        short: \"m\",\n        description: \"Start the application minimized to the system tray\"\n    },\n    version: {\n        type: \"boolean\",\n        short: \"v\",\n        description: \"Print the application version and exit\"\n    },\n    help: {\n        type: \"boolean\",\n        short: \"h\",\n        description: \"Print help information and exit\"\n    },\n    \"user-agent\": {\n        type: \"string\",\n        argumentName: \"ua\",\n        description: \"Set a custom User-Agent. May trigger anti-spam or break voice chat\"\n    },\n    \"user-agent-os\": {\n        type: \"string\",\n        description: \"Set User-Agent to a specific operating system. May trigger anti-spam or break voice chat\",\n        options: [\"windows\", \"linux\", \"darwin\"]\n    }\n} satisfies Record<string, Option>;\n\n// only for help display\nconst extraOptions = {\n    \"enable-features\": {\n        type: \"string\",\n        description: \"Enable specific Chromium features\",\n        argumentName: \"feature1,feature2,…\"\n    },\n    \"disable-features\": {\n        type: \"string\",\n        description: \"Disable specific Chromium features\",\n        argumentName: \"feature1,feature2,…\"\n    },\n    \"ozone-platform\": {\n        hidden: process.platform !== \"linux\",\n        type: \"string\",\n        description: \"Whether to run Vesktop in Wayland or X11 (XWayland)\",\n        options: [\"x11\", \"wayland\"]\n    }\n} satisfies Record<string, Option>;\n\nconst args = basename(process.argv[0]).toLowerCase().startsWith(\"electron\")\n    ? process.argv.slice(2)\n    : process.argv.slice(1);\n\nexport const CommandLine = parseArgs({\n    args,\n    options,\n    strict: false as true, // we manually check later, so cast to true to get better types\n    allowPositionals: true\n});\n\nexport function checkCommandLineForHelpOrVersion() {\n    const { help, version } = CommandLine.values;\n\n    if (version) {\n        console.log(`Vesktop v${app.getVersion()}`);\n        app.exit(0);\n    }\n\n    if (help) {\n        const base = stripIndent`\n            Vesktop v${app.getVersion()}\n\n            Usage: ${basename(process.execPath)} [options] [url]\n\n            Electron Options:\n              See <https://www.electronjs.org/docs/latest/api/command-line-switches#electron-cli-flags>\n\n            Chromium Options:\n              See <https://peter.sh/experiments/chromium-command-line-switches> - only some of them work\n\n            Vesktop Options:\n        `;\n\n        const optionLines = Object.entries(options)\n            .sort(([a], [b]) => a.localeCompare(b))\n            .concat(Object.entries(extraOptions))\n            .filter(([, opt]) => !(\"hidden\" in opt && opt.hidden))\n            .map(([name, opt]) => {\n                const flags = [\n                    \"short\" in opt && `-${opt.short}`,\n                    `--${name}`,\n                    opt.type !== \"boolean\" &&\n                        (\"options\" in opt ? `<${opt.options.join(\" | \")}>` : `<${opt.argumentName ?? opt.type}>`)\n                ]\n                    .filter(Boolean)\n                    .join(\" \");\n\n                return [flags, opt.description];\n            });\n\n        const padding = optionLines.reduce((max, [flags]) => Math.max(max, flags.length), 0) + 4;\n\n        const optionsHelp = optionLines\n            .map(([flags, description]) => `  ${flags.padEnd(padding, \" \")}${description}`)\n            .join(\"\\n\");\n\n        console.log(base + \"\\n\" + optionsHelp);\n        app.exit(0);\n    }\n\n    for (const [name, def] of Object.entries(options)) {\n        const value = CommandLine.values[name];\n        if (value == null) continue;\n\n        if (typeof value !== def.type) {\n            console.error(`Invalid options. Expected ${def.type === \"boolean\" ? \"no\" : \"an\"} argument for --${name}`);\n            app.exit(1);\n        }\n\n        if (\"options\" in def && !def.options?.includes(value as string)) {\n            console.error(`Invalid value for --${name}: ${value}\\nExpected one of: ${def.options.join(\", \")}`);\n            app.exit(1);\n        }\n    }\n}\n\ncheckCommandLineForHelpOrVersion();\n"
  },
  {
    "path": "src/main/constants.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { app } from \"electron\";\nimport { existsSync, mkdirSync } from \"fs\";\nimport { dirname, join } from \"path\";\n\nimport { CommandLine } from \"./cli\";\n\nconst vesktopDir = dirname(process.execPath);\n\nexport const PORTABLE =\n    process.platform === \"win32\" &&\n    !process.execPath.toLowerCase().endsWith(\"electron.exe\") &&\n    !existsSync(join(vesktopDir, \"Uninstall Vesktop.exe\"));\n\nexport const DATA_DIR =\n    process.env.VENCORD_USER_DATA_DIR || (PORTABLE ? join(vesktopDir, \"Data\") : join(app.getPath(\"userData\")));\n\nmkdirSync(DATA_DIR, { recursive: true });\n\nexport const SESSION_DATA_DIR = join(DATA_DIR, \"sessionData\");\napp.setPath(\"sessionData\", SESSION_DATA_DIR);\n\nexport const VENCORD_SETTINGS_DIR = join(DATA_DIR, \"settings\");\nmkdirSync(VENCORD_SETTINGS_DIR, { recursive: true });\nexport const VENCORD_QUICKCSS_FILE = join(VENCORD_SETTINGS_DIR, \"quickCss.css\");\nexport const VENCORD_SETTINGS_FILE = join(VENCORD_SETTINGS_DIR, \"settings.json\");\nexport const VENCORD_THEMES_DIR = join(DATA_DIR, \"themes\");\n\nexport const USER_AGENT = `Vesktop/${app.getVersion()} (https://github.com/Vencord/Vesktop)`;\n\n// dimensions shamelessly stolen from Discord Desktop :3\nexport const MIN_WIDTH = 940;\nexport const MIN_HEIGHT = 500;\nexport const DEFAULT_WIDTH = 1280;\nexport const DEFAULT_HEIGHT = 720;\n\nexport const DISCORD_HOSTNAMES = [\"discord.com\", \"canary.discord.com\", \"ptb.discord.com\"];\n\nconst VersionString = `AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${process.versions.chrome.split(\".\")[0]}.0.0.0 Safari/537.36`;\nconst BrowserUserAgents = {\n    darwin: `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) ${VersionString}`,\n    linux: `Mozilla/5.0 (X11; Linux x86_64) ${VersionString}`,\n    windows: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) ${VersionString}`\n};\n\nexport const BrowserUserAgent =\n    CommandLine.values[\"user-agent\"] ||\n    BrowserUserAgents[CommandLine.values[\"user-agent-os\"] || process.platform] ||\n    BrowserUserAgents.windows;\n\nexport const enum MessageBoxChoice {\n    Default,\n    Cancel\n}\n\nexport const IS_FLATPAK = process.env.FLATPAK_ID !== undefined;\n"
  },
  {
    "path": "src/main/dbus.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vesktop contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { app } from \"electron\";\nimport { join } from \"path\";\nimport { STATIC_DIR } from \"shared/paths\";\n\nlet libVesktop: typeof import(\"libvesktop\") | null = null;\n\nfunction loadLibVesktop() {\n    try {\n        if (!libVesktop) {\n            libVesktop = require(join(STATIC_DIR, `dist/libvesktop-${process.arch}.node`));\n        }\n    } catch (e) {\n        console.error(\"Failed to load libvesktop:\", e);\n    }\n\n    return libVesktop;\n}\n\nexport function getAccentColor() {\n    return loadLibVesktop()?.getAccentColor() ?? null;\n}\n\nexport function updateUnityLauncherCount(count: number) {\n    const libVesktop = loadLibVesktop();\n    if (!libVesktop) {\n        return app.setBadgeCount(count);\n    }\n\n    return libVesktop.updateUnityLauncherCount(count);\n}\n\nexport function requestBackground(autoStart: boolean, commandLine: string[]) {\n    return loadLibVesktop()?.requestBackground(autoStart, commandLine) ?? false;\n}\n"
  },
  {
    "path": "src/main/events.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vesktop contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { EventEmitter } from \"events\";\n\nimport { UserAssetType } from \"./userAssets\";\n\nexport const AppEvents = new EventEmitter<{\n    appLoaded: [];\n    userAssetChanged: [UserAssetType];\n    setTrayVariant: [\"tray\" | \"trayUnread\"];\n}>();\n"
  },
  {
    "path": "src/main/firstLaunch.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { app } from \"electron\";\nimport { BrowserWindow } from \"electron/main\";\nimport { copyFileSync, mkdirSync, readdirSync } from \"fs\";\nimport { join } from \"path\";\nimport { SplashProps } from \"shared/browserWinProperties\";\n\nimport { autoStart } from \"./autoStart\";\nimport { DATA_DIR } from \"./constants\";\nimport { createWindows } from \"./mainWindow\";\nimport { Settings, State } from \"./settings\";\nimport { makeLinksOpenExternally } from \"./utils/makeLinksOpenExternally\";\nimport { loadView } from \"./vesktopStatic\";\n\ninterface Data {\n    discordBranch: \"stable\" | \"canary\" | \"ptb\";\n    minimizeToTray?: \"on\";\n    autoStart?: \"on\";\n    importSettings?: \"on\";\n    richPresence?: \"on\";\n}\n\nexport function createFirstLaunchTour() {\n    const win = new BrowserWindow({\n        ...SplashProps,\n        transparent: false,\n        frame: true,\n        autoHideMenuBar: true,\n        height: 550,\n        width: 600\n    });\n\n    makeLinksOpenExternally(win);\n\n    loadView(win, \"first-launch.html\");\n    win.webContents.addListener(\"console-message\", (_e, _l, msg) => {\n        if (msg === \"cancel\") return app.exit();\n\n        if (!msg.startsWith(\"form:\")) return;\n        const data = JSON.parse(msg.slice(5)) as Data;\n\n        State.store.firstLaunch = false;\n        Settings.store.discordBranch = data.discordBranch;\n        Settings.store.minimizeToTray = !!data.minimizeToTray;\n        Settings.store.arRPC = !!data.richPresence;\n\n        if (data.autoStart) autoStart.enable();\n\n        if (data.importSettings) {\n            const from = join(app.getPath(\"userData\"), \"..\", \"Vencord\", \"settings\");\n            const to = join(DATA_DIR, \"settings\");\n            try {\n                const files = readdirSync(from);\n                mkdirSync(to, { recursive: true });\n\n                for (const file of files) {\n                    copyFileSync(join(from, file), join(to, file));\n                }\n            } catch (e) {\n                if (e instanceof Error && \"code\" in e && e.code === \"ENOENT\") {\n                    console.log(\"No Vencord settings found to import.\");\n                } else {\n                    console.error(\"Failed to import Vencord settings:\", e);\n                }\n            }\n        }\n\n        win.close();\n\n        createWindows();\n    });\n}\n"
  },
  {
    "path": "src/main/index.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport \"./cli\";\nimport \"./updater\";\nimport \"./ipc\";\nimport \"./userAssets\";\nimport \"./vesktopProtocol\";\n\nimport { app, BrowserWindow, nativeTheme } from \"electron\";\n\nimport { DATA_DIR } from \"./constants\";\nimport { createFirstLaunchTour } from \"./firstLaunch\";\nimport { createWindows, mainWin } from \"./mainWindow\";\nimport { registerMediaPermissionsHandler } from \"./mediaPermissions\";\nimport { registerScreenShareHandler } from \"./screenShare\";\nimport { Settings, State } from \"./settings\";\nimport { setAsDefaultProtocolClient } from \"./utils/setAsDefaultProtocolClient\";\nimport { isDeckGameMode } from \"./utils/steamOS\";\n\nconsole.log(\"Vesktop v\" + app.getVersion());\n\n// Make the Vencord files use our DATA_DIR\nprocess.env.VENCORD_USER_DATA_DIR = DATA_DIR;\n\nconst isLinux = process.platform === \"linux\";\n\nexport let enableHardwareAcceleration = true;\n\nfunction init() {\n    setAsDefaultProtocolClient(\"discord\");\n\n    const { disableSmoothScroll, hardwareAcceleration, hardwareVideoAcceleration } = Settings.store;\n\n    const enabledFeatures = new Set(app.commandLine.getSwitchValue(\"enable-features\").split(\",\"));\n    const disabledFeatures = new Set(app.commandLine.getSwitchValue(\"disable-features\").split(\",\"));\n    app.commandLine.removeSwitch(\"enable-features\");\n    app.commandLine.removeSwitch(\"disable-features\");\n\n    if (hardwareAcceleration === false || process.argv.includes(\"--disable-gpu\")) {\n        enableHardwareAcceleration = false;\n        app.disableHardwareAcceleration();\n    } else {\n        if (hardwareVideoAcceleration) {\n            enabledFeatures.add(\"AcceleratedVideoEncoder\");\n            enabledFeatures.add(\"AcceleratedVideoDecoder\");\n\n            if (isLinux) {\n                enabledFeatures.add(\"AcceleratedVideoDecodeLinuxGL\");\n                enabledFeatures.add(\"AcceleratedVideoDecodeLinuxZeroCopyGL\");\n            }\n        }\n    }\n\n    if (disableSmoothScroll) {\n        app.commandLine.appendSwitch(\"disable-smooth-scrolling\");\n    }\n\n    // disable renderer backgrounding to prevent the app from unloading when in the background\n    // https://github.com/electron/electron/issues/2822\n    // https://github.com/GoogleChrome/chrome-launcher/blob/5a27dd574d47a75fec0fb50f7b774ebf8a9791ba/docs/chrome-flags-for-tools.md#task-throttling\n    app.commandLine.appendSwitch(\"disable-renderer-backgrounding\");\n    app.commandLine.appendSwitch(\"disable-background-timer-throttling\");\n    app.commandLine.appendSwitch(\"disable-backgrounding-occluded-windows\");\n    if (process.platform === \"win32\") {\n        disabledFeatures.add(\"CalculateNativeWinOcclusion\");\n    }\n\n    // work around chrome 66 disabling autoplay by default\n    app.commandLine.appendSwitch(\"autoplay-policy\", \"no-user-gesture-required\");\n\n    // WinRetrieveSuggestionsOnlyOnDemand: Work around electron 13 bug w/ async spellchecking on Windows.\n    // HardwareMediaKeyHandling, MediaSessionService: Prevent Discord from registering as a media service.\n    disabledFeatures.add(\"WinRetrieveSuggestionsOnlyOnDemand\");\n    disabledFeatures.add(\"HardwareMediaKeyHandling\");\n    disabledFeatures.add(\"MediaSessionService\");\n\n    if (isLinux) {\n        // Support TTS on Linux using https://wiki.archlinux.org/title/Speech_dispatcher\n        app.commandLine.appendSwitch(\"enable-speech-dispatcher\");\n    }\n\n    disabledFeatures.forEach(feat => enabledFeatures.delete(feat));\n\n    const enabledFeaturesArray = enabledFeatures.values().filter(Boolean).toArray();\n    const disabledFeaturesArray = disabledFeatures.values().filter(Boolean).toArray();\n\n    if (enabledFeaturesArray.length) {\n        app.commandLine.appendSwitch(\"enable-features\", enabledFeaturesArray.join(\",\"));\n        console.log(\"Enabled Chromium features:\", enabledFeaturesArray.join(\", \"));\n    }\n\n    if (disabledFeaturesArray.length) {\n        app.commandLine.appendSwitch(\"disable-features\", disabledFeaturesArray.join(\",\"));\n        console.log(\"Disabled Chromium features:\", disabledFeaturesArray.join(\", \"));\n    }\n\n    // In the Flatpak on SteamOS the theme is detected as light, but SteamOS only has a dark mode, so we just override it\n    if (isDeckGameMode) nativeTheme.themeSource = \"dark\";\n\n    app.on(\"second-instance\", (_event, _cmdLine, _cwd, data: any) => {\n        if (data.IS_DEV) app.quit();\n        else if (mainWin) {\n            if (mainWin.isMinimized()) mainWin.restore();\n            if (!mainWin.isVisible()) mainWin.show();\n            mainWin.focus();\n        }\n    });\n\n    app.whenReady().then(async () => {\n        if (process.platform === \"win32\") app.setAppUserModelId(\"dev.vencord.vesktop\");\n\n        registerScreenShareHandler();\n        registerMediaPermissionsHandler();\n\n        bootstrap();\n\n        app.on(\"activate\", () => {\n            if (BrowserWindow.getAllWindows().length === 0) createWindows();\n        });\n    });\n}\n\nif (!app.requestSingleInstanceLock({ IS_DEV })) {\n    if (IS_DEV) {\n        console.log(\"Vesktop is already running. Quitting previous instance...\");\n        init();\n    } else {\n        console.log(\"Vesktop is already running. Quitting...\");\n        app.quit();\n    }\n} else {\n    init();\n}\n\nasync function bootstrap() {\n    if (!Object.hasOwn(State.store, \"firstLaunch\")) {\n        createFirstLaunchTour();\n    } else {\n        createWindows();\n    }\n}\n\n// MacOS only event\nexport let darwinURL: string | undefined;\napp.on(\"open-url\", (_, url) => {\n    darwinURL = url;\n});\n\napp.on(\"window-all-closed\", () => {\n    if (process.platform !== \"darwin\") app.quit();\n});\n"
  },
  {
    "path": "src/main/ipc.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nif (process.platform === \"linux\") import(\"./venmic\");\n\nimport { execFile } from \"child_process\";\nimport {\n    app,\n    BrowserWindow,\n    clipboard,\n    dialog,\n    IpcMainInvokeEvent,\n    nativeImage,\n    RelaunchOptions,\n    session,\n    shell\n} from \"electron\";\nimport { readFileSync, watch } from \"fs\";\nimport { readFile, stat } from \"fs/promises\";\nimport { enableHardwareAcceleration } from \"main\";\nimport { release } from \"os\";\nimport { join } from \"path\";\n\nimport { IpcEvents } from \"../shared/IpcEvents\";\nimport { setBadgeCount } from \"./appBadge\";\nimport { autoStart } from \"./autoStart\";\nimport { mainWin } from \"./mainWindow\";\nimport { Settings, State } from \"./settings\";\nimport { handle, handleSync } from \"./utils/ipcWrappers\";\nimport { PopoutWindows } from \"./utils/popout\";\nimport { isDeckGameMode, showGamePage } from \"./utils/steamOS\";\nimport { isValidVencordInstall } from \"./utils/vencordLoader\";\nimport { VENCORD_FILES_DIR } from \"./vencordFilesDir\";\n\nhandleSync(IpcEvents.DEPRECATED_GET_VENCORD_PRELOAD_SCRIPT_PATH, () =>\n    join(VENCORD_FILES_DIR, \"vencordDesktopPreload.js\")\n);\nhandleSync(IpcEvents.GET_VENCORD_PRELOAD_SCRIPT, () =>\n    readFileSync(join(VENCORD_FILES_DIR, \"vencordDesktopPreload.js\"), \"utf-8\")\n);\nhandleSync(IpcEvents.GET_VENCORD_RENDERER_SCRIPT, () =>\n    readFileSync(join(VENCORD_FILES_DIR, \"vencordDesktopRenderer.js\"), \"utf-8\")\n);\n\nconst VESKTOP_RENDERER_JS_PATH = join(__dirname, \"renderer.js\");\nconst VESKTOP_RENDERER_CSS_PATH = join(__dirname, \"renderer.css\");\nhandleSync(IpcEvents.GET_VESKTOP_RENDERER_SCRIPT, () => readFileSync(VESKTOP_RENDERER_JS_PATH, \"utf-8\"));\nhandle(IpcEvents.GET_VESKTOP_RENDERER_CSS, () => readFile(VESKTOP_RENDERER_CSS_PATH, \"utf-8\"));\n\nif (IS_DEV) {\n    watch(VESKTOP_RENDERER_CSS_PATH, { persistent: false }, async () => {\n        mainWin?.webContents.postMessage(\n            IpcEvents.VESKTOP_RENDERER_CSS_UPDATE,\n            await readFile(VESKTOP_RENDERER_CSS_PATH, \"utf-8\")\n        );\n    });\n}\n\nhandleSync(IpcEvents.GET_SETTINGS, () => Settings.plain);\nhandleSync(IpcEvents.GET_VERSION, () => app.getVersion());\nhandleSync(IpcEvents.GET_ENABLE_HARDWARE_ACCELERATION, () => enableHardwareAcceleration);\n\nhandleSync(\n    IpcEvents.SUPPORTS_WINDOWS_TRANSPARENCY,\n    () => process.platform === \"win32\" && Number(release().split(\".\").pop()) >= 22621\n);\n\nhandleSync(IpcEvents.AUTOSTART_ENABLED, () => autoStart.isEnabled());\nhandle(IpcEvents.ENABLE_AUTOSTART, autoStart.enable);\nhandle(IpcEvents.DISABLE_AUTOSTART, autoStart.disable);\n\nhandle(IpcEvents.SET_SETTINGS, (_, settings: typeof Settings.store, path?: string) => {\n    Settings.setData(settings, path);\n});\n\nhandle(IpcEvents.RELAUNCH, async () => {\n    const options: RelaunchOptions = {\n        args: process.argv.slice(1).concat([\"--relaunch\"])\n    };\n    if (isDeckGameMode) {\n        // We can't properly relaunch when running under gamescope, but we can at least navigate to our page in Steam.\n        await showGamePage();\n    } else if (app.isPackaged && process.env.APPIMAGE) {\n        execFile(process.env.APPIMAGE, options.args);\n    } else {\n        app.relaunch(options);\n    }\n    app.exit();\n});\n\nhandleSync(IpcEvents.IS_USING_CUSTOM_VENCORD_DIR, () => !!State.store.vencordDir);\nhandle(IpcEvents.SHOW_CUSTOM_VENCORD_DIR, async () => {\n    const { vencordDir } = State.store;\n    if (!vencordDir) return;\n\n    const stats = await stat(vencordDir);\n    if (!stats.isDirectory()) return;\n\n    shell.openPath(vencordDir);\n});\n\nfunction getWindow(e: IpcMainInvokeEvent, key?: string) {\n    return key ? PopoutWindows.get(key)! : (BrowserWindow.fromWebContents(e.sender) ?? mainWin);\n}\n\nhandle(IpcEvents.FOCUS, () => {\n    mainWin.show();\n    mainWin.setSkipTaskbar(false);\n});\n\nhandle(IpcEvents.CLOSE, (e, key?: string) => {\n    getWindow(e, key).close();\n});\n\nhandle(IpcEvents.MINIMIZE, (e, key?: string) => {\n    getWindow(e, key).minimize();\n});\n\nhandle(IpcEvents.MAXIMIZE, (e, key?: string) => {\n    const win = getWindow(e, key);\n    if (win.isMaximized()) {\n        win.unmaximize();\n    } else {\n        win.maximize();\n    }\n});\n\nhandleSync(IpcEvents.SPELLCHECK_GET_AVAILABLE_LANGUAGES, e => {\n    e.returnValue = session.defaultSession.availableSpellCheckerLanguages;\n});\n\nhandle(IpcEvents.SPELLCHECK_REPLACE_MISSPELLING, (e, word: string) => {\n    e.sender.replaceMisspelling(word);\n});\n\nhandle(IpcEvents.SPELLCHECK_ADD_TO_DICTIONARY, (e, word: string) => {\n    e.sender.session.addWordToSpellCheckerDictionary(word);\n});\n\nhandle(IpcEvents.SELECT_VENCORD_DIR, async (_e, value?: null) => {\n    if (value === null) {\n        delete State.store.vencordDir;\n        return \"ok\";\n    }\n\n    const res = await dialog.showOpenDialog(mainWin!, {\n        properties: [\"openDirectory\"]\n    });\n    if (!res.filePaths.length) return \"cancelled\";\n\n    const dir = res.filePaths[0];\n    if (!isValidVencordInstall(dir)) return \"invalid\";\n\n    State.store.vencordDir = dir;\n\n    return \"ok\";\n});\n\nhandle(IpcEvents.SET_BADGE_COUNT, (_, count: number) => setBadgeCount(count));\n\nhandle(IpcEvents.FLASH_FRAME, (_, flag: boolean) => {\n    if (!mainWin || mainWin.isDestroyed() || (flag && mainWin.isFocused())) return;\n    mainWin.flashFrame(flag);\n});\n\nhandle(IpcEvents.CLIPBOARD_COPY_IMAGE, async (_, buf: ArrayBuffer, src: string) => {\n    clipboard.write({\n        html: `<img src=\"${src.replaceAll('\"', '\\\\\"')}\">`,\n        image: nativeImage.createFromBuffer(Buffer.from(buf))\n    });\n});\n\nfunction openDebugPage(page: string) {\n    const win = new BrowserWindow({\n        autoHideMenuBar: true\n    });\n\n    win.loadURL(page);\n}\n\nhandle(IpcEvents.DEBUG_LAUNCH_GPU, () => openDebugPage(\"chrome://gpu\"));\nhandle(IpcEvents.DEBUG_LAUNCH_WEBRTC_INTERNALS, () => openDebugPage(\"chrome://webrtc-internals\"));\n"
  },
  {
    "path": "src/main/ipcCommands.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { randomUUID } from \"crypto\";\nimport { ipcMain } from \"electron\";\nimport { IpcEvents } from \"shared/IpcEvents\";\n\nimport { mainWin } from \"./mainWindow\";\n\nconst resolvers = new Map<string, Record<\"resolve\" | \"reject\", (data: any) => void>>();\n\nexport interface IpcMessage {\n    nonce: string;\n    message: string;\n    data?: any;\n}\n\nexport interface IpcResponse {\n    nonce: string;\n    ok: boolean;\n    data?: any;\n}\n\n/**\n * Sends a message to the renderer process and waits for a response.\n * `data` must be serializable as it will be sent over IPC.\n *\n * You must add a handler for the message in the renderer process.\n */\nexport function sendRendererCommand<T = any>(message: string, data?: any) {\n    if (mainWin.isDestroyed()) {\n        console.warn(\"Main window is destroyed, cannot send IPC command:\", message);\n        return Promise.reject(new Error(\"Main window is destroyed\"));\n    }\n\n    const nonce = randomUUID();\n\n    const promise = new Promise<T>((resolve, reject) => {\n        resolvers.set(nonce, { resolve, reject });\n    });\n\n    mainWin.webContents.send(IpcEvents.IPC_COMMAND, { nonce, message, data });\n\n    return promise;\n}\n\nipcMain.on(IpcEvents.IPC_COMMAND, (_event, { nonce, ok, data }: IpcResponse) => {\n    const resolver = resolvers.get(nonce);\n    if (!resolver) throw new Error(`Unknown message: ${nonce}`);\n\n    if (ok) {\n        resolver.resolve(data);\n    } else {\n        resolver.reject(data);\n    }\n\n    resolvers.delete(nonce);\n});\n"
  },
  {
    "path": "src/main/mainWindow.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport {\n    app,\n    BrowserWindow,\n    BrowserWindowConstructorOptions,\n    Menu,\n    MenuItemConstructorOptions,\n    nativeTheme,\n    Rectangle,\n    screen,\n    session\n} from \"electron\";\nimport { join } from \"path\";\nimport { IpcCommands, IpcEvents } from \"shared/IpcEvents\";\nimport { isTruthy } from \"shared/utils/guards\";\nimport { once } from \"shared/utils/once\";\nimport type { SettingsStore } from \"shared/utils/SettingsStore\";\n\nimport { createAboutWindow } from \"./about\";\nimport { initArRPC } from \"./arrpc\";\nimport { CommandLine } from \"./cli\";\nimport { BrowserUserAgent, DEFAULT_HEIGHT, DEFAULT_WIDTH, MIN_HEIGHT, MIN_WIDTH } from \"./constants\";\nimport { AppEvents } from \"./events\";\nimport { darwinURL } from \"./index\";\nimport { sendRendererCommand } from \"./ipcCommands\";\nimport { Settings, State, VencordSettings } from \"./settings\";\nimport { createSplashWindow, updateSplashMessage } from \"./splash\";\nimport { destroyTray, initTray } from \"./tray\";\nimport { clearData } from \"./utils/clearData\";\nimport { makeLinksOpenExternally } from \"./utils/makeLinksOpenExternally\";\nimport { applyDeckKeyboardFix, askToApplySteamLayout, isDeckGameMode } from \"./utils/steamOS\";\nimport { downloadVencordFiles, ensureVencordFiles, vencordSupportsSandboxing } from \"./utils/vencordLoader\";\nimport { VENCORD_FILES_DIR } from \"./vencordFilesDir\";\n\nlet isQuitting = false;\n\napplyDeckKeyboardFix();\n\napp.on(\"before-quit\", () => {\n    isQuitting = true;\n});\n\nexport let mainWin: BrowserWindow;\n\nfunction makeSettingsListenerHelpers<O extends object>(o: SettingsStore<O>) {\n    const listeners = new Map<(data: any) => void, PropertyKey>();\n\n    const addListener: typeof o.addChangeListener = (path, cb) => {\n        listeners.set(cb, path);\n        o.addChangeListener(path, cb);\n    };\n    const removeAllListeners = () => {\n        for (const [listener, path] of listeners) {\n            o.removeChangeListener(path as any, listener);\n        }\n\n        listeners.clear();\n    };\n\n    return [addListener, removeAllListeners] as const;\n}\n\nconst [addSettingsListener, removeSettingsListeners] = makeSettingsListenerHelpers(Settings);\nconst [addVencordSettingsListener, removeVencordSettingsListeners] = makeSettingsListenerHelpers(VencordSettings);\n\ntype MenuItemList = Array<MenuItemConstructorOptions | false>;\n\nfunction initMenuBar(win: BrowserWindow) {\n    const isWindows = process.platform === \"win32\";\n    const isDarwin = process.platform === \"darwin\";\n    const wantCtrlQ = !isWindows || VencordSettings.store.winCtrlQ;\n\n    const subMenu = [\n        {\n            label: \"About Vesktop\",\n            click: createAboutWindow\n        },\n        {\n            label: \"Force Update Vencord\",\n            async click() {\n                await downloadVencordFiles();\n                app.relaunch();\n                app.quit();\n            },\n            toolTip: \"Vesktop will automatically restart after this operation\"\n        },\n        {\n            label: \"Reset Vesktop\",\n            async click() {\n                await clearData(win);\n            },\n            toolTip: \"Vesktop will automatically restart after this operation\"\n        },\n        {\n            label: \"Relaunch\",\n            accelerator: \"CmdOrCtrl+Shift+R\",\n            click() {\n                app.relaunch();\n                app.quit();\n            }\n        },\n        ...(!isDarwin\n            ? []\n            : ([\n                  {\n                      type: \"separator\"\n                  },\n                  {\n                      label: \"Settings\",\n                      accelerator: \"CmdOrCtrl+,\",\n                      async click() {\n                          sendRendererCommand(IpcCommands.NAVIGATE_SETTINGS);\n                      }\n                  },\n                  {\n                      type: \"separator\"\n                  },\n                  {\n                      role: \"hide\"\n                  },\n                  {\n                      role: \"hideOthers\"\n                  },\n                  {\n                      role: \"unhide\"\n                  },\n                  {\n                      type: \"separator\"\n                  }\n              ] satisfies MenuItemList)),\n        {\n            label: \"Quit\",\n            accelerator: wantCtrlQ ? \"CmdOrCtrl+Q\" : void 0,\n            visible: !isWindows,\n            role: \"quit\",\n            click() {\n                app.quit();\n            }\n        },\n        isWindows && {\n            label: \"Quit\",\n            accelerator: \"Alt+F4\",\n            role: \"quit\",\n            click() {\n                app.quit();\n            }\n        },\n        // See https://github.com/electron/electron/issues/14742 and https://github.com/electron/electron/issues/5256\n        {\n            label: \"Zoom in (hidden, hack for Qwertz and others)\",\n            accelerator: \"CmdOrCtrl+=\",\n            role: \"zoomIn\",\n            visible: false\n        }\n    ] satisfies MenuItemList;\n\n    const menuItems = [\n        {\n            label: \"Vesktop\",\n            role: \"appMenu\",\n            submenu: subMenu.filter(isTruthy)\n        },\n        { role: \"fileMenu\" },\n        { role: \"editMenu\" },\n        { role: \"viewMenu\" },\n        isDarwin && { role: \"windowMenu\" }\n    ] satisfies MenuItemList;\n\n    const menu = Menu.buildFromTemplate(menuItems.filter(isTruthy));\n\n    Menu.setApplicationMenu(menu);\n}\n\nfunction initWindowBoundsListeners(win: BrowserWindow) {\n    const saveState = () => {\n        State.store.maximized = win.isMaximized();\n        State.store.minimized = win.isMinimized();\n    };\n\n    win.on(\"maximize\", saveState);\n    win.on(\"minimize\", saveState);\n    win.on(\"unmaximize\", saveState);\n\n    const saveBounds = () => {\n        State.store.windowBounds = win.getBounds();\n    };\n\n    win.on(\"resize\", saveBounds);\n    win.on(\"move\", saveBounds);\n}\n\nfunction initSettingsListeners(win: BrowserWindow) {\n    addSettingsListener(\"tray\", enable => {\n        if (enable) initTray(win, q => (isQuitting = q));\n        else destroyTray();\n    });\n\n    addSettingsListener(\"disableMinSize\", disable => {\n        if (disable) {\n            // 0 no work\n            win.setMinimumSize(1, 1);\n        } else {\n            win.setMinimumSize(MIN_WIDTH, MIN_HEIGHT);\n\n            const { width, height } = win.getBounds();\n            win.setBounds({\n                width: Math.max(width, MIN_WIDTH),\n                height: Math.max(height, MIN_HEIGHT)\n            });\n        }\n    });\n\n    addVencordSettingsListener(\"macosTranslucency\", enabled => {\n        if (enabled) {\n            win.setVibrancy(\"sidebar\");\n            win.setBackgroundColor(\"#ffffff00\");\n        } else {\n            win.setVibrancy(null);\n            win.setBackgroundColor(\"#ffffff\");\n        }\n    });\n\n    addSettingsListener(\"enableMenu\", enabled => {\n        win.setAutoHideMenuBar(enabled ?? false);\n    });\n\n    addSettingsListener(\"spellCheckLanguages\", languages => initSpellCheckLanguages(win, languages));\n}\n\nasync function initSpellCheckLanguages(win: BrowserWindow, languages?: string[]) {\n    languages ??= await sendRendererCommand(IpcCommands.GET_LANGUAGES);\n    if (!languages) return;\n\n    const ses = session.defaultSession;\n\n    const available = ses.availableSpellCheckerLanguages;\n    const applicable = languages.filter(l => available.includes(l)).slice(0, 5);\n    if (applicable.length) ses.setSpellCheckerLanguages(applicable);\n}\n\nfunction initSpellCheck(win: BrowserWindow) {\n    win.webContents.on(\"context-menu\", (_, data) => {\n        win.webContents.send(IpcEvents.SPELLCHECK_RESULT, data.misspelledWord, data.dictionarySuggestions);\n    });\n\n    initSpellCheckLanguages(win, Settings.store.spellCheckLanguages);\n}\n\nfunction initDevtoolsListeners(win: BrowserWindow) {\n    win.webContents.on(\"devtools-opened\", () => {\n        win.webContents.send(IpcEvents.DEVTOOLS_OPENED);\n    });\n    win.webContents.on(\"devtools-closed\", () => {\n        win.webContents.send(IpcEvents.DEVTOOLS_CLOSED);\n    });\n}\n\nfunction initStaticTitle(win: BrowserWindow) {\n    const listener = (e: { preventDefault: Function }) => e.preventDefault();\n\n    if (Settings.store.staticTitle) win.on(\"page-title-updated\", listener);\n\n    addSettingsListener(\"staticTitle\", enabled => {\n        if (enabled) {\n            win.setTitle(\"Vesktop\");\n            win.on(\"page-title-updated\", listener);\n        } else {\n            win.off(\"page-title-updated\", listener);\n        }\n    });\n}\n\nfunction getWindowBoundsOptions(): BrowserWindowConstructorOptions {\n    // We want the default window behaviour to apply in game mode since it expects everything to be fullscreen and maximized.\n    if (isDeckGameMode) return {};\n\n    const { x, y, width = DEFAULT_WIDTH, height = DEFAULT_HEIGHT } = State.store.windowBounds ?? {};\n\n    const options = { width, height } as BrowserWindowConstructorOptions;\n\n    if (x != null && y != null) {\n        function isInBounds(rect: Rectangle, display: Rectangle) {\n            return !(\n                rect.x + rect.width < display.x ||\n                rect.x > display.x + display.width ||\n                rect.y + rect.height < display.y ||\n                rect.y > display.y + display.height\n            );\n        }\n\n        const inBounds = screen.getAllDisplays().some(d => isInBounds({ x, y, width, height }, d.bounds));\n        if (inBounds) {\n            options.x = x;\n            options.y = y;\n        }\n    }\n\n    if (!Settings.store.disableMinSize) {\n        options.minWidth = MIN_WIDTH;\n        options.minHeight = MIN_HEIGHT;\n    }\n\n    return options;\n}\n\nfunction buildBrowserWindowOptions(): BrowserWindowConstructorOptions {\n    const { staticTitle, transparencyOption, enableMenu, customTitleBar, splashTheming, splashBackground } =\n        Settings.store;\n\n    const { frameless, transparent, macosVibrancyStyle } = VencordSettings.store;\n\n    const noFrame = frameless === true || customTitleBar === true;\n    const backgroundColor =\n        splashTheming !== false ? splashBackground : nativeTheme.shouldUseDarkColors ? \"#313338\" : \"#ffffff\";\n\n    const options: BrowserWindowConstructorOptions = {\n        show: Settings.store.enableSplashScreen === false && !CommandLine.values[\"start-minimized\"],\n        backgroundColor,\n        webPreferences: {\n            nodeIntegration: false,\n            sandbox: vencordSupportsSandboxing(),\n            contextIsolation: true,\n            devTools: true,\n            preload: join(__dirname, \"preload.js\"),\n            spellcheck: true,\n            // disable renderer backgrounding to prevent the app from unloading when in the background\n            backgroundThrottling: false\n        },\n        frame: !noFrame,\n        autoHideMenuBar: enableMenu,\n        ...getWindowBoundsOptions()\n    };\n\n    if (transparent) {\n        options.transparent = true;\n        options.backgroundColor = \"#00000000\";\n    }\n\n    if (transparencyOption && transparencyOption !== \"none\") {\n        options.backgroundColor = \"#00000000\";\n        options.backgroundMaterial = transparencyOption;\n\n        if (customTitleBar) {\n            options.transparent = true;\n        }\n    }\n\n    if (staticTitle) {\n        options.title = \"Vesktop\";\n    }\n\n    if (process.platform === \"darwin\") {\n        options.titleBarStyle = \"hidden\";\n        options.trafficLightPosition = { x: 10, y: 10 };\n\n        if (macosVibrancyStyle) {\n            options.vibrancy = macosVibrancyStyle;\n            options.backgroundColor = \"#00000000\";\n        }\n    }\n\n    return options;\n}\n\nfunction createMainWindow() {\n    // Clear up previous settings listeners\n    removeSettingsListeners();\n    removeVencordSettingsListeners();\n\n    const win = (mainWin = new BrowserWindow(buildBrowserWindowOptions()));\n\n    win.setMenuBarVisibility(false);\n    if (process.platform === \"darwin\" && Settings.store.customTitleBar) win.setWindowButtonVisibility(false);\n\n    win.on(\"close\", e => {\n        const useTray = !isDeckGameMode && Settings.store.minimizeToTray !== false && Settings.store.tray !== false;\n        if (isQuitting || (process.platform !== \"darwin\" && !useTray)) return;\n\n        e.preventDefault();\n\n        if (process.platform === \"darwin\") app.hide();\n        else win.hide();\n\n        return false;\n    });\n\n    win.on(\"focus\", () => {\n        win.flashFrame(false);\n    });\n\n    initWindowBoundsListeners(win);\n    if (!isDeckGameMode && (Settings.store.tray ?? true) && process.platform !== \"darwin\")\n        initTray(win, q => (isQuitting = q));\n\n    initMenuBar(win);\n    makeLinksOpenExternally(win);\n    initSettingsListeners(win);\n    initSpellCheck(win);\n    initDevtoolsListeners(win);\n    initStaticTitle(win);\n\n    win.webContents.setUserAgent(BrowserUserAgent);\n\n    // if the open-url event is fired (in index.ts) while starting up, darwinURL will be set. If not fall back to checking the process args (which Windows and Linux use for URI calling.)\n    // win.webContents.session.clearCache().then(() => {\n    loadUrl(darwinURL || process.argv.find(arg => arg.startsWith(\"discord://\")));\n    // });\n\n    return win;\n}\n\nconst runVencordMain = once(() => require(join(VENCORD_FILES_DIR, \"vencordDesktopMain.js\")));\n\nexport function loadUrl(uri: string | undefined) {\n    const branch = Settings.store.discordBranch;\n    const subdomain = branch === \"canary\" || branch === \"ptb\" ? `${branch}.` : \"\";\n\n    // we do not rely on 'did-finish-load' because it fires even if loadURL fails which triggers early detruction of the splash\n    mainWin\n        .loadURL(`https://${subdomain}discord.com/${uri ? new URL(uri).pathname.slice(1) || \"app\" : \"app\"}`)\n        .then(() => AppEvents.emit(\"appLoaded\"))\n        .catch(error => retryUrl(error.url, error.code));\n}\n\nconst retryDelay = 1000;\nfunction retryUrl(url: string, description: string) {\n    console.log(`retrying in ${retryDelay}ms`);\n    updateSplashMessage(`Failed to load Discord: ${description}`);\n    setTimeout(() => loadUrl(url), retryDelay);\n}\n\nexport async function createWindows() {\n    const startMinimized = CommandLine.values[\"start-minimized\"];\n\n    let splash: BrowserWindow | undefined;\n    if (Settings.store.enableSplashScreen !== false) {\n        splash = createSplashWindow(startMinimized);\n\n        // SteamOS letterboxes and scales it terribly, so just full screen it\n        if (isDeckGameMode) splash.setFullScreen(true);\n    }\n\n    await ensureVencordFiles();\n    runVencordMain();\n\n    mainWin = createMainWindow();\n\n    AppEvents.on(\"appLoaded\", () => {\n        splash?.destroy();\n\n        if (!startMinimized) {\n            if (splash) mainWin!.show();\n            if (State.store.maximized && !isDeckGameMode) mainWin!.maximize();\n        }\n\n        if (isDeckGameMode) {\n            // always use entire display\n            mainWin!.setFullScreen(true);\n\n            askToApplySteamLayout(mainWin);\n        }\n\n        mainWin.once(\"show\", () => {\n            if (State.store.maximized && !mainWin!.isMaximized() && !isDeckGameMode) {\n                mainWin!.maximize();\n            }\n        });\n    });\n\n    mainWin.webContents.on(\"did-navigate\", (_, url: string, responseCode: number) => {\n        updateSplashMessage(\"\"); // clear the splash message\n\n        // check url to ensure app doesn't loop\n        if (responseCode >= 300 && new URL(url).pathname !== `/app`) {\n            loadUrl(undefined);\n            console.warn(`'did-navigate': Caught bad page response: ${responseCode}, redirecting to main app`);\n        }\n    });\n\n    initArRPC();\n}\n"
  },
  {
    "path": "src/main/mediaPermissions.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { session, systemPreferences } from \"electron\";\n\nexport function registerMediaPermissionsHandler() {\n    if (process.platform !== \"darwin\") return;\n\n    session.defaultSession.setPermissionRequestHandler(async (_webContents, permission, callback, details) => {\n        let granted = true;\n\n        if (\"mediaTypes\" in details) {\n            if (details.mediaTypes?.includes(\"audio\")) {\n                granted &&= await systemPreferences.askForMediaAccess(\"microphone\");\n            }\n            if (details.mediaTypes?.includes(\"video\")) {\n                granted &&= await systemPreferences.askForMediaAccess(\"camera\");\n            }\n        }\n\n        callback(granted);\n    });\n}\n"
  },
  {
    "path": "src/main/screenShare.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { desktopCapturer, session, Streams } from \"electron\";\nimport type { StreamPick } from \"renderer/components/ScreenSharePicker\";\nimport { IpcCommands, IpcEvents } from \"shared/IpcEvents\";\n\nimport { sendRendererCommand } from \"./ipcCommands\";\nimport { handle } from \"./utils/ipcWrappers\";\n\nconst isWayland =\n    process.platform === \"linux\" && (process.env.XDG_SESSION_TYPE === \"wayland\" || !!process.env.WAYLAND_DISPLAY);\n\nexport function registerScreenShareHandler() {\n    handle(IpcEvents.CAPTURER_GET_LARGE_THUMBNAIL, async (_, id: string) => {\n        const sources = await desktopCapturer.getSources({\n            types: [\"window\", \"screen\"],\n            thumbnailSize: {\n                width: 1920,\n                height: 1080\n            }\n        });\n        return sources.find(s => s.id === id)?.thumbnail.toDataURL();\n    });\n\n    session.defaultSession.setDisplayMediaRequestHandler(async (request, callback) => {\n        // request full resolution on wayland right away because we always only end up with one result anyway\n        const width = isWayland ? 1920 : 176;\n        const sources = await desktopCapturer\n            .getSources({\n                types: [\"window\", \"screen\"],\n                thumbnailSize: {\n                    width,\n                    height: width * (9 / 16)\n                }\n            })\n            .catch(err => console.error(\"Error during screenshare picker\", err));\n\n        if (!sources) return callback({});\n\n        const data = sources.map(({ id, name, thumbnail }) => ({\n            id,\n            name,\n            url: thumbnail.toDataURL()\n        }));\n\n        if (isWayland) {\n            const video = data[0];\n            if (video) {\n                const stream = await sendRendererCommand<StreamPick>(IpcCommands.SCREEN_SHARE_PICKER, {\n                    screens: [video],\n                    skipPicker: true\n                }).catch(() => null);\n\n                if (stream === null) return callback({});\n            }\n\n            callback(video ? { video: sources[0] } : {});\n            return;\n        }\n\n        const choice = await sendRendererCommand<StreamPick>(IpcCommands.SCREEN_SHARE_PICKER, {\n            screens: data,\n            skipPicker: false\n        }).catch(e => {\n            console.error(\"Error during screenshare picker\", e);\n            return null;\n        });\n\n        if (!choice) return callback({});\n\n        const source = sources.find(s => s.id === choice.id);\n        if (!source) return callback({});\n\n        const streams: Streams = {\n            video: source\n        };\n        if (choice.audio && process.platform === \"win32\") streams.audio = \"loopback\";\n\n        callback(streams);\n    });\n}\n"
  },
  {
    "path": "src/main/settings.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { type Settings as TVencordSettings } from \"@vencord/types/Vencord\";\nimport { mkdirSync, readFileSync, writeFileSync } from \"fs\";\nimport { dirname, join } from \"path\";\nimport type { Settings as TSettings, State as TState } from \"shared/settings\";\nimport { SettingsStore } from \"shared/utils/SettingsStore\";\n\nimport { DATA_DIR, VENCORD_SETTINGS_FILE } from \"./constants\";\n\nconst SETTINGS_FILE = join(DATA_DIR, \"settings.json\");\nconst STATE_FILE = join(DATA_DIR, \"state.json\");\n\nfunction loadSettings<T extends object = any>(file: string, name: string) {\n    let settings = {} as T;\n    try {\n        const content = readFileSync(file, \"utf8\");\n        try {\n            settings = JSON.parse(content);\n        } catch (err) {\n            console.error(`Failed to parse ${name}.json:`, err);\n        }\n    } catch {}\n\n    const store = new SettingsStore(settings);\n    store.addGlobalChangeListener(o => {\n        try {\n            mkdirSync(dirname(file), { recursive: true });\n            writeFileSync(file, JSON.stringify(o, null, 4));\n        } catch (err) {\n            console.error(`Failed to save settings to ${name}.json:`, err);\n        }\n    });\n\n    return store;\n}\n\nexport const Settings = loadSettings<TSettings>(SETTINGS_FILE, \"Vesktop settings\");\nexport const VencordSettings = loadSettings<TVencordSettings>(VENCORD_SETTINGS_FILE, \"Vencord settings\");\nexport const State = loadSettings<TState>(STATE_FILE, \"Vesktop state\");\n"
  },
  {
    "path": "src/main/splash.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { BrowserWindow } from \"electron\";\nimport { join } from \"path\";\nimport { SplashProps } from \"shared/browserWinProperties\";\n\nimport { Settings } from \"./settings\";\nimport { loadView } from \"./vesktopStatic\";\n\nlet splash: BrowserWindow | undefined;\n\nexport function createSplashWindow(startMinimized = false) {\n    splash = new BrowserWindow({\n        ...SplashProps,\n        show: !startMinimized,\n        webPreferences: {\n            preload: join(__dirname, \"splashPreload.js\")\n        }\n    });\n\n    loadView(splash, \"splash.html\");\n\n    const { splashBackground, splashColor, splashTheming, splashPixelated } = Settings.store;\n\n    if (splashTheming !== false) {\n        if (splashColor) {\n            const semiTransparentSplashColor = splashColor.replace(\"rgb(\", \"rgba(\").replace(\")\", \", 0.2)\");\n\n            splash.webContents.insertCSS(`body { --fg: ${splashColor} !important }`);\n            splash.webContents.insertCSS(`body { --fg-semi-trans: ${semiTransparentSplashColor} !important }`);\n        }\n\n        if (splashBackground) {\n            splash.webContents.insertCSS(`body { --bg: ${splashBackground} !important }`);\n        }\n    }\n\n    if (splashPixelated) {\n        splash.webContents.insertCSS(`img { image-rendering: pixelated; }`);\n    }\n\n    return splash;\n}\n\nexport function updateSplashMessage(message: string) {\n    if (splash && !splash.isDestroyed()) splash.webContents.send(\"update-splash-message\", message);\n}\n"
  },
  {
    "path": "src/main/tray.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vesktop contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { app, BrowserWindow, Menu, Tray } from \"electron\";\n\nimport { createAboutWindow } from \"./about\";\nimport { AppEvents } from \"./events\";\nimport { Settings } from \"./settings\";\nimport { resolveAssetPath } from \"./userAssets\";\nimport { clearData } from \"./utils/clearData\";\nimport { downloadVencordFiles } from \"./utils/vencordLoader\";\n\nlet tray: Tray;\nlet trayVariant: \"tray\" | \"trayUnread\" = \"tray\";\n\nAppEvents.on(\"userAssetChanged\", async asset => {\n    if (tray && (asset === \"tray\" || asset === \"trayUnread\")) {\n        tray.setImage(await resolveAssetPath(trayVariant));\n    }\n});\n\nAppEvents.on(\"setTrayVariant\", async variant => {\n    if (trayVariant === variant) return;\n\n    trayVariant = variant;\n    if (!tray) return;\n\n    tray.setImage(await resolveAssetPath(trayVariant));\n});\n\nexport function destroyTray() {\n    tray?.destroy();\n}\n\nexport async function initTray(win: BrowserWindow, setIsQuitting: (val: boolean) => void) {\n    const onTrayClick = () => {\n        if (Settings.store.clickTrayToShowHide && win.isVisible()) win.hide();\n        else win.show();\n    };\n\n    const trayMenu = Menu.buildFromTemplate([\n        {\n            label: \"Open\",\n            click() {\n                win.show();\n            }\n        },\n        {\n            label: \"About\",\n            click: createAboutWindow\n        },\n        {\n            label: \"Repair Vencord\",\n            async click() {\n                await downloadVencordFiles();\n                app.relaunch();\n                app.quit();\n            }\n        },\n        {\n            label: \"Reset Vesktop\",\n            async click() {\n                await clearData(win);\n            }\n        },\n        {\n            type: \"separator\"\n        },\n        {\n            label: \"Restart\",\n            click() {\n                app.relaunch();\n                app.quit();\n            }\n        },\n        {\n            label: \"Quit\",\n            click() {\n                setIsQuitting(true);\n                app.quit();\n            }\n        }\n    ]);\n\n    tray = new Tray(await resolveAssetPath(trayVariant));\n    tray.setToolTip(\"Vesktop\");\n    tray.setContextMenu(trayMenu);\n    tray.on(\"click\", onTrayClick);\n}\n"
  },
  {
    "path": "src/main/updater.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vesktop contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { app, BrowserWindow, ipcMain } from \"electron\";\nimport { autoUpdater, UpdateInfo } from \"electron-updater\";\nimport { join } from \"path\";\nimport { IpcEvents, UpdaterIpcEvents } from \"shared/IpcEvents\";\nimport { Millis } from \"shared/utils/millis\";\n\nimport { State } from \"./settings\";\nimport { handle } from \"./utils/ipcWrappers\";\nimport { makeLinksOpenExternally } from \"./utils/makeLinksOpenExternally\";\nimport { loadView } from \"./vesktopStatic\";\n\nlet updaterWindow: BrowserWindow | null = null;\n\nautoUpdater.on(\"update-available\", update => {\n    if (State.store.updater?.ignoredVersion === update.version) return;\n    if ((State.store.updater?.snoozeUntil ?? 0) > Date.now()) return;\n\n    openUpdater(update);\n});\n\nautoUpdater.on(\"update-downloaded\", () => setTimeout(() => autoUpdater.quitAndInstall(), 100));\nautoUpdater.on(\"download-progress\", p =>\n    updaterWindow?.webContents.send(UpdaterIpcEvents.DOWNLOAD_PROGRESS, p.percent)\n);\nautoUpdater.on(\"error\", err => updaterWindow?.webContents.send(UpdaterIpcEvents.ERROR, err.message));\n\nautoUpdater.autoDownload = false;\nautoUpdater.autoInstallOnAppQuit = false;\nautoUpdater.fullChangelog = true;\n\nconst isOutdated = autoUpdater.checkForUpdates().then(res => Boolean(res?.isUpdateAvailable));\n\nhandle(IpcEvents.UPDATER_IS_OUTDATED, () => isOutdated);\nhandle(IpcEvents.UPDATER_OPEN, async () => {\n    const res = await autoUpdater.checkForUpdates();\n    if (res?.isUpdateAvailable && res.updateInfo) openUpdater(res.updateInfo);\n});\n\nfunction openUpdater(update: UpdateInfo) {\n    updaterWindow = new BrowserWindow({\n        title: \"Vesktop Updater\",\n        autoHideMenuBar: true,\n        webPreferences: {\n            preload: join(__dirname, \"updaterPreload.js\")\n        },\n        minHeight: 400,\n        minWidth: 750\n    });\n    makeLinksOpenExternally(updaterWindow);\n\n    handle(UpdaterIpcEvents.GET_DATA, () => ({ update, version: app.getVersion() }));\n    handle(UpdaterIpcEvents.INSTALL, async () => {\n        await autoUpdater.downloadUpdate();\n    });\n    handle(UpdaterIpcEvents.SNOOZE_UPDATE, () => {\n        State.store.updater ??= {};\n        State.store.updater.snoozeUntil = Date.now() + 1 * Millis.DAY;\n        updaterWindow?.close();\n    });\n    handle(UpdaterIpcEvents.IGNORE_UPDATE, () => {\n        State.store.updater ??= {};\n        State.store.updater.ignoredVersion = update.version;\n        updaterWindow?.close();\n    });\n\n    updaterWindow.on(\"closed\", () => {\n        ipcMain.removeHandler(UpdaterIpcEvents.GET_DATA);\n        ipcMain.removeHandler(UpdaterIpcEvents.INSTALL);\n        ipcMain.removeHandler(UpdaterIpcEvents.SNOOZE_UPDATE);\n        ipcMain.removeHandler(UpdaterIpcEvents.IGNORE_UPDATE);\n        updaterWindow = null;\n    });\n\n    loadView(updaterWindow, \"updater/index.html\");\n}\n"
  },
  {
    "path": "src/main/userAssets.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vesktop contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { app, dialog, net } from \"electron\";\nimport { copyFile, mkdir, rm } from \"fs/promises\";\nimport { join } from \"path\";\nimport { IpcEvents } from \"shared/IpcEvents\";\nimport { STATIC_DIR } from \"shared/paths\";\nimport { pathToFileURL } from \"url\";\n\nimport { DATA_DIR } from \"./constants\";\nimport { AppEvents } from \"./events\";\nimport { mainWin } from \"./mainWindow\";\nimport { fileExistsAsync } from \"./utils/fileExists\";\nimport { handle } from \"./utils/ipcWrappers\";\n\nconst CUSTOMIZABLE_ASSETS = [\"splash\", \"tray\", \"trayUnread\"] as const;\nexport type UserAssetType = (typeof CUSTOMIZABLE_ASSETS)[number];\n\nconst DEFAULT_ASSETS: Record<UserAssetType, string> = {\n    splash: \"splash.webp\",\n    tray: `tray/${process.platform === \"darwin\" ? \"trayTemplate\" : \"tray\"}.png`,\n    trayUnread: \"tray/trayUnread.png\"\n};\n\nconst UserAssetFolder = join(DATA_DIR, \"userAssets\");\n\nexport async function resolveAssetPath(asset: UserAssetType) {\n    if (!CUSTOMIZABLE_ASSETS.includes(asset)) {\n        throw new Error(`Invalid asset: ${asset}`);\n    }\n\n    const assetPath = join(UserAssetFolder, asset);\n    if (await fileExistsAsync(assetPath)) {\n        return assetPath;\n    }\n\n    return join(STATIC_DIR, DEFAULT_ASSETS[asset]);\n}\n\nexport async function handleVesktopAssetsProtocol(path: string, req: Request) {\n    const asset = path.slice(1);\n\n    // @ts-expect-error dumb types\n    if (!CUSTOMIZABLE_ASSETS.includes(asset)) {\n        return new Response(null, { status: 404 });\n    }\n\n    try {\n        const res = await net.fetch(pathToFileURL(join(UserAssetFolder, asset)).href);\n        if (res.ok) return res;\n    } catch {}\n\n    return net.fetch(pathToFileURL(join(STATIC_DIR, DEFAULT_ASSETS[asset])).href);\n}\n\nhandle(IpcEvents.CHOOSE_USER_ASSET, async (_event, asset: UserAssetType, value?: null) => {\n    if (!CUSTOMIZABLE_ASSETS.includes(asset)) {\n        throw `Invalid asset: ${asset}`;\n    }\n\n    const assetPath = join(UserAssetFolder, asset);\n\n    if (value === null) {\n        try {\n            await rm(assetPath, { force: true });\n            AppEvents.emit(\"userAssetChanged\", asset);\n            return \"ok\";\n        } catch (e) {\n            console.error(`Failed to remove user asset ${asset}:`, e);\n            return \"failed\";\n        }\n    }\n\n    const res = await dialog.showOpenDialog(mainWin, {\n        properties: [\"openFile\"],\n        title: `Select an image to use as ${asset}`,\n        defaultPath: app.getPath(\"pictures\"),\n        filters: [\n            {\n                name: \"Images\",\n                extensions: [\"png\", \"jpg\", \"jpeg\", \"webp\", \"gif\", \"avif\", \"svg\"]\n            }\n        ]\n    });\n\n    if (res.canceled || !res.filePaths.length) return \"cancelled\";\n\n    try {\n        await mkdir(UserAssetFolder, { recursive: true });\n        await copyFile(res.filePaths[0], assetPath);\n        AppEvents.emit(\"userAssetChanged\", asset);\n        return \"ok\";\n    } catch (e) {\n        console.error(`Failed to copy user asset ${asset}:`, e);\n        return \"failed\";\n    }\n});\n"
  },
  {
    "path": "src/main/utils/clearData.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vesktop contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { app, BrowserWindow, dialog } from \"electron\";\nimport { rm } from \"fs/promises\";\nimport { DATA_DIR, MessageBoxChoice } from \"main/constants\";\n\nexport async function clearData(win: BrowserWindow) {\n    const { response } = await dialog.showMessageBox(win, {\n        message: \"Are you sure you want to reset Vesktop?\",\n        detail: \"This will log you out, clear caches and reset all your settings!\\n\\nVesktop will automatically restart after this operation.\",\n        buttons: [\"Yes\", \"No\"],\n        cancelId: MessageBoxChoice.Cancel,\n        defaultId: MessageBoxChoice.Default,\n        type: \"warning\"\n    });\n\n    if (response === MessageBoxChoice.Cancel) return;\n\n    win.close();\n\n    await win.webContents.session.clearStorageData();\n    await win.webContents.session.clearCache();\n    await win.webContents.session.clearCodeCaches({});\n    await rm(DATA_DIR, { force: true, recursive: true });\n\n    app.relaunch();\n    app.quit();\n}\n"
  },
  {
    "path": "src/main/utils/desktopFileEscape.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vesktop contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\n// https://specifications.freedesktop.org/desktop-entry-spec/latest/exec-variables.html\n\n// \"If an argument contains a reserved character the argument must be quoted.\"\nconst desktopFileReservedChars = new Set([\n    \" \",\n    \"\\t\",\n    \"\\n\",\n    '\"',\n    \"'\",\n    \"\\\\\",\n    \">\",\n    \"<\",\n    \"~\",\n    \"|\",\n    \"&\",\n    \";\",\n    \"$\",\n    \"*\",\n    \"?\",\n    \"#\",\n    \"(\",\n    \")\",\n    \"`\"\n]);\n\nexport function escapeDesktopFileArgument(arg: string) {\n    let needsQuoting = false;\n    let out = \"\";\n\n    for (const c of arg) {\n        if (desktopFileReservedChars.has(c)) {\n            // \"Quoting must be done by enclosing the argument between double quotes\"\n            needsQuoting = true;\n            // \"and escaping the double quote character, backtick character (\"`\"), dollar sign (\"$\")\n            // and backslash character (\"\\\") by preceding it with an additional backslash character\"\n            if (c === '\"' || c === \"`\" || c === \"$\" || c === \"\\\\\") {\n                out += \"\\\\\";\n            }\n        }\n\n        // \"Literal percentage characters must be escaped as %%\"\n        if (c === \"%\") {\n            out += \"%%\";\n        } else {\n            out += c;\n        }\n    }\n\n    return needsQuoting ? `\"${out}\"` : out;\n}\n"
  },
  {
    "path": "src/main/utils/fileExists.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vesktop contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { access, constants } from \"fs/promises\";\n\nexport async function fileExistsAsync(path: string) {\n    return await access(path, constants.F_OK)\n        .then(() => true)\n        .catch(() => false);\n}\n"
  },
  {
    "path": "src/main/utils/http.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { createWriteStream } from \"fs\";\nimport { Readable } from \"stream\";\nimport { pipeline } from \"stream/promises\";\nimport { setTimeout } from \"timers/promises\";\n\ninterface FetchieOptions {\n    retryOnNetworkError?: boolean;\n}\n\nexport async function downloadFile(url: string, file: string, options: RequestInit = {}, fetchieOpts?: FetchieOptions) {\n    const res = await fetchie(url, options, fetchieOpts);\n    await pipeline(\n        // @ts-expect-error odd type error\n        Readable.fromWeb(res.body!),\n        createWriteStream(file, {\n            autoClose: true\n        })\n    );\n}\n\nconst ONE_MINUTE_MS = 1000 * 60;\n\nexport async function fetchie(url: string, options?: RequestInit, { retryOnNetworkError }: FetchieOptions = {}) {\n    let res: Response | undefined;\n\n    try {\n        res = await fetch(url, options);\n    } catch (err) {\n        if (retryOnNetworkError) {\n            console.error(\"Failed to fetch\", url + \".\", \"Gonna retry with backoff.\");\n\n            for (let tries = 0, delayMs = 500; tries < 20; tries++, delayMs = Math.min(2 * delayMs, ONE_MINUTE_MS)) {\n                await setTimeout(delayMs);\n                try {\n                    res = await fetch(url, options);\n                    break;\n                } catch {}\n            }\n        }\n\n        if (!res) throw new Error(`Failed to fetch ${url}\\n${err}`);\n    }\n\n    if (res.ok) return res;\n\n    let msg = `Got non-OK response for ${url}: ${res.status} ${res.statusText}`;\n\n    const reason = await res.text().catch(() => \"\");\n    if (reason) msg += `\\n${reason}`;\n\n    throw new Error(msg);\n}\n"
  },
  {
    "path": "src/main/utils/ipcWrappers.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { ipcMain, IpcMainEvent, IpcMainInvokeEvent, WebFrameMain } from \"electron\";\nimport { DISCORD_HOSTNAMES } from \"main/constants\";\nimport { IpcEvents, UpdaterIpcEvents } from \"shared/IpcEvents\";\n\nexport function validateSender(frame: WebFrameMain | null, event: string) {\n    if (!frame) throw new Error(`ipc[${event}]: No sender frame`);\n    if (!frame.url) return;\n\n    try {\n        var { hostname, protocol } = new URL(frame.url);\n    } catch (e) {\n        throw new Error(`ipc[${event}]: Invalid URL ${frame.url}`);\n    }\n\n    if (protocol === \"file:\" || protocol === \"vesktop:\") return;\n\n    if (!DISCORD_HOSTNAMES.includes(hostname)) {\n        throw new Error(`ipc[${event}]: Disallowed hostname ${hostname}`);\n    }\n}\n\nexport function handleSync(event: IpcEvents | UpdaterIpcEvents, cb: (e: IpcMainEvent, ...args: any[]) => any) {\n    ipcMain.on(event, (e, ...args) => {\n        validateSender(e.senderFrame, event);\n        e.returnValue = cb(e, ...args);\n    });\n}\n\nexport function handle(event: IpcEvents | UpdaterIpcEvents, cb: (e: IpcMainInvokeEvent, ...args: any[]) => any) {\n    ipcMain.handle(event, (e, ...args) => {\n        validateSender(e.senderFrame, event);\n        return cb(e, ...args);\n    });\n}\n"
  },
  {
    "path": "src/main/utils/isPathInDirectory.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vesktop contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { resolve, sep } from \"path\";\n\nexport function isPathInDirectory(filePath: string, directory: string) {\n    const resolvedPath = resolve(filePath);\n    const resolvedDirectory = resolve(directory);\n\n    const normalizedDirectory = resolvedDirectory.endsWith(sep) ? resolvedDirectory : resolvedDirectory + sep;\n\n    return resolvedPath.startsWith(normalizedDirectory) || resolvedPath === resolvedDirectory;\n}\n"
  },
  {
    "path": "src/main/utils/makeLinksOpenExternally.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { BrowserWindow, shell } from \"electron\";\nimport { DISCORD_HOSTNAMES } from \"main/constants\";\n\nimport { Settings } from \"../settings\";\nimport { createOrFocusPopup, setupPopout } from \"./popout\";\nimport { execSteamURL, isDeckGameMode, steamOpenURL } from \"./steamOS\";\n\nexport function handleExternalUrl(url: string, protocol?: string): { action: \"deny\" | \"allow\" } {\n    if (protocol == null) {\n        try {\n            protocol = new URL(url).protocol;\n        } catch {\n            return { action: \"deny\" };\n        }\n    }\n\n    switch (protocol) {\n        case \"http:\":\n        case \"https:\":\n            if (Settings.store.openLinksWithElectron) {\n                return { action: \"allow\" };\n            }\n        // eslint-disable-next-line no-fallthrough\n        case \"mailto:\":\n        case \"spotify:\":\n            if (isDeckGameMode) {\n                steamOpenURL(url);\n            } else {\n                shell.openExternal(url);\n            }\n            break;\n        case \"steam:\":\n            if (isDeckGameMode) {\n                execSteamURL(url);\n            } else {\n                shell.openExternal(url);\n            }\n            break;\n    }\n\n    return { action: \"deny\" };\n}\n\nexport function makeLinksOpenExternally(win: BrowserWindow) {\n    win.webContents.setWindowOpenHandler(({ url, frameName, features }) => {\n        try {\n            var { protocol, hostname, pathname, searchParams } = new URL(url);\n        } catch {\n            return { action: \"deny\" };\n        }\n\n        if (frameName.startsWith(\"DISCORD_\") && pathname === \"/popout\" && DISCORD_HOSTNAMES.includes(hostname)) {\n            return createOrFocusPopup(frameName, features);\n        }\n\n        if (url === \"about:blank\") return { action: \"allow\" };\n\n        // Drop the static temp page Discord web loads for the connections popout\n        if (frameName === \"authorize\" && searchParams.get(\"loading\") === \"true\") return { action: \"deny\" };\n\n        return handleExternalUrl(url, protocol);\n    });\n\n    win.webContents.on(\"did-create-window\", (win, { frameName }) => {\n        if (frameName.startsWith(\"DISCORD_\")) setupPopout(win, frameName);\n    });\n}\n"
  },
  {
    "path": "src/main/utils/popout.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { BrowserWindow, BrowserWindowConstructorOptions } from \"electron\";\nimport { Settings } from \"main/settings\";\n\nimport { handleExternalUrl } from \"./makeLinksOpenExternally\";\n\nconst ALLOWED_FEATURES = new Set([\n    \"width\",\n    \"height\",\n    \"left\",\n    \"top\",\n    \"resizable\",\n    \"movable\",\n    \"alwaysOnTop\",\n    \"frame\",\n    \"transparent\",\n    \"hasShadow\",\n    \"closable\",\n    \"skipTaskbar\",\n    \"backgroundColor\",\n    \"menubar\",\n    \"toolbar\",\n    \"location\",\n    \"directories\",\n    \"titleBarStyle\"\n]);\n\nconst MIN_POPOUT_WIDTH = 320;\nconst MIN_POPOUT_HEIGHT = 180;\nconst DEFAULT_POPOUT_OPTIONS: BrowserWindowConstructorOptions = {\n    title: \"Discord Popout\",\n    backgroundColor: \"#2f3136\",\n    minWidth: MIN_POPOUT_WIDTH,\n    minHeight: MIN_POPOUT_HEIGHT,\n    frame: Settings.store.customTitleBar !== true,\n    titleBarStyle: process.platform === \"darwin\" ? \"hidden\" : undefined,\n    trafficLightPosition:\n        process.platform === \"darwin\"\n            ? {\n                  x: 10,\n                  y: 3\n              }\n            : undefined,\n    webPreferences: {\n        nodeIntegration: false,\n        contextIsolation: true\n    },\n    autoHideMenuBar: Settings.store.enableMenu\n};\n\nexport const PopoutWindows = new Map<string, BrowserWindow>();\n\nfunction focusWindow(window: BrowserWindow) {\n    window.setAlwaysOnTop(true);\n    window.focus();\n    window.setAlwaysOnTop(false);\n}\n\nfunction parseFeatureValue(feature: string) {\n    if (feature === \"yes\") return true;\n    if (feature === \"no\") return false;\n\n    const n = Number(feature);\n    if (!isNaN(n)) return n;\n\n    return feature;\n}\n\nfunction parseWindowFeatures(features: string) {\n    const keyValuesParsed = features.split(\",\");\n\n    return keyValuesParsed.reduce((features, feature) => {\n        const [key, value] = feature.split(\"=\");\n        if (ALLOWED_FEATURES.has(key)) features[key] = parseFeatureValue(value);\n\n        return features;\n    }, {});\n}\n\nexport function createOrFocusPopup(key: string, features: string) {\n    const existingWindow = PopoutWindows.get(key);\n    if (existingWindow) {\n        focusWindow(existingWindow);\n        return <const>{ action: \"deny\" };\n    }\n\n    return <const>{\n        action: \"allow\",\n        overrideBrowserWindowOptions: {\n            ...DEFAULT_POPOUT_OPTIONS,\n            ...parseWindowFeatures(features)\n        }\n    };\n}\n\nexport function setupPopout(win: BrowserWindow, key: string) {\n    win.setMenuBarVisibility(false);\n\n    PopoutWindows.set(key, win);\n\n    /* win.webContents.on(\"will-navigate\", (evt, url) => {\n        // maybe prevent if not origin match\n    })*/\n\n    win.webContents.setWindowOpenHandler(({ url }) => handleExternalUrl(url));\n\n    win.once(\"closed\", () => {\n        win.removeAllListeners();\n        PopoutWindows.delete(key);\n    });\n}\n"
  },
  {
    "path": "src/main/utils/setAsDefaultProtocolClient.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vesktop contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { execFile } from \"child_process\";\nimport { app } from \"electron\";\n\nexport async function setAsDefaultProtocolClient(protocol: string) {\n    if (process.platform !== \"linux\") {\n        return app.setAsDefaultProtocolClient(protocol);\n    }\n\n    // electron setAsDefaultProtocolClient uses xdg-settings instead of xdg-mime.\n    // xdg-settings had a bug where it would also register the app as a handler for text/html,\n    // aka become your browser. This bug was fixed years ago (xdg-utils 1.2.0) but Ubuntu ships\n    // 7 (YES, SEVEN) years out of date xdg-utils which STILL has the bug.\n    // FIXME: remove this workaround when Ubuntu updates their xdg-utils or electron switches to xdg-mime.\n\n    const { CHROME_DESKTOP } = process.env;\n    if (!CHROME_DESKTOP) return false;\n\n    return new Promise<boolean>(resolve => {\n        execFile(\"xdg-mime\", [\"default\", CHROME_DESKTOP, `x-scheme-handler/${protocol}`], err => {\n            resolve(err == null);\n        });\n    });\n}\n"
  },
  {
    "path": "src/main/utils/steamOS.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { BrowserWindow, dialog } from \"electron\";\nimport { writeFile } from \"fs/promises\";\nimport { join } from \"path\";\n\nimport { MessageBoxChoice } from \"../constants\";\nimport { State } from \"../settings\";\n\n// Bump this to re-show the prompt\nconst layoutVersion = 2;\n// Get this from \"show details\" on the profile after exporting as a shared personal layout or using share with community\nconst layoutId = \"3080264545\"; // Vesktop Layout v2\nconst numberRegex = /^[0-9]*$/;\n\nlet steamPipeQueue = Promise.resolve();\n\nexport const isDeckGameMode = process.env.SteamOS === \"1\" && process.env.SteamGamepadUI === \"1\";\n\nexport function applyDeckKeyboardFix() {\n    if (!isDeckGameMode) return;\n    // Prevent constant virtual keyboard spam that eventually crashes Steam.\n    process.env.GTK_IM_MODULE = \"None\";\n}\n\n// For some reason SteamAppId is always 0 for non-steam apps so we do this insanity instead.\nfunction getAppId(): string | null {\n    // /home/deck/.local/share/Steam/steamapps/shadercache/APPID/fozmediav1\n    const path = process.env.STEAM_COMPAT_MEDIA_PATH;\n    if (!path) return null;\n    const pathElems = path?.split(\"/\");\n    const appId = pathElems[pathElems.length - 2];\n    if (appId.match(numberRegex)) {\n        console.log(`Got Steam App ID ${appId}`);\n        return appId;\n    }\n    return null;\n}\n\nexport function execSteamURL(url: string) {\n    // This doesn't allow arbitrary execution despite the weird syntax.\n    steamPipeQueue = steamPipeQueue.then(() =>\n        writeFile(\n            join(process.env.HOME || \"/home/deck\", \".steam\", \"steam.pipe\"),\n            // replace ' to prevent argument injection\n            `'${process.env.HOME}/.local/share/Steam/ubuntu12_32/steam' '-ifrunning' '${url.replaceAll(\"'\", \"%27\")}'\\n`,\n            \"utf-8\"\n        )\n    );\n}\n\nexport function steamOpenURL(url: string) {\n    execSteamURL(`steam://openurl/${url}`);\n}\n\nexport async function showGamePage() {\n    const appId = getAppId();\n    if (!appId) return;\n    await execSteamURL(`steam://nav/games/details/${appId}`);\n}\n\nasync function showLayout(appId: string) {\n    execSteamURL(`steam://controllerconfig/${appId}/${layoutId}`);\n}\n\nexport async function askToApplySteamLayout(win: BrowserWindow) {\n    const appId = getAppId();\n    if (!appId) return;\n    if (State.store.steamOSLayoutVersion === layoutVersion) return;\n    const update = Boolean(State.store.steamOSLayoutVersion);\n\n    // Touch screen breaks in some menus when native touch mode is enabled on latest SteamOS beta, remove most of the update specific text once that's fixed.\n    const { response } = await dialog.showMessageBox(win, {\n        message: `${update ? \"Update\" : \"Apply\"} Vesktop Steam Input Layout?`,\n        detail: `Would you like to ${update ? \"Update\" : \"Apply\"} Vesktop's recommended Steam Deck controller settings?\n${update ? \"Click yes using the touchpad\" : \"Tap yes\"}, then press the X button or tap Apply Layout to confirm.${\n            update ? \" Doing so will undo any customizations you have made.\" : \"\"\n        }\n${update ? \"Click\" : \"Tap\"} no to keep your current layout.`,\n        buttons: [\"Yes\", \"No\"],\n        cancelId: MessageBoxChoice.Cancel,\n        defaultId: MessageBoxChoice.Default,\n        type: \"question\"\n    });\n\n    if (State.store.steamOSLayoutVersion !== layoutVersion) {\n        State.store.steamOSLayoutVersion = layoutVersion;\n    }\n\n    if (response === MessageBoxChoice.Cancel) return;\n\n    await showLayout(appId);\n}\n"
  },
  {
    "path": "src/main/utils/vencordLoader.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { mkdirSync, readFileSync } from \"fs\";\nimport { access, constants as FsConstants, writeFile } from \"fs/promises\";\nimport { VENCORD_FILES_DIR } from \"main/vencordFilesDir\";\nimport { join } from \"path\";\n\nimport { USER_AGENT } from \"../constants\";\nimport { downloadFile, fetchie } from \"./http\";\n\nconst API_BASE = \"https://api.github.com\";\n\nexport const FILES_TO_DOWNLOAD = [\n    \"vencordDesktopMain.js\",\n    \"vencordDesktopPreload.js\",\n    \"vencordDesktopRenderer.js\",\n    \"vencordDesktopRenderer.css\"\n];\n\nexport interface ReleaseData {\n    name: string;\n    tag_name: string;\n    html_url: string;\n    assets: Array<{\n        name: string;\n        browser_download_url: string;\n    }>;\n}\n\nexport async function githubGet(endpoint: string) {\n    const opts: RequestInit = {\n        headers: {\n            Accept: \"application/vnd.github+json\",\n            \"User-Agent\": USER_AGENT\n        }\n    };\n\n    if (process.env.GITHUB_TOKEN) (opts.headers! as any).Authorization = `Bearer ${process.env.GITHUB_TOKEN}`;\n\n    return fetchie(API_BASE + endpoint, opts, { retryOnNetworkError: true });\n}\n\nexport async function downloadVencordFiles() {\n    const release = await githubGet(\"/repos/Vendicated/Vencord/releases/latest\");\n\n    const { assets }: ReleaseData = await release.json();\n\n    await Promise.all(\n        assets\n            .filter(({ name }) => FILES_TO_DOWNLOAD.some(f => name.startsWith(f)))\n            .map(({ name, browser_download_url }) =>\n                downloadFile(browser_download_url, join(VENCORD_FILES_DIR, name), {}, { retryOnNetworkError: true })\n            )\n    );\n}\n\nconst existsAsync = (path: string) =>\n    access(path, FsConstants.F_OK)\n        .then(() => true)\n        .catch(() => false);\n\nexport async function isValidVencordInstall(dir: string) {\n    const results = await Promise.all([\"package.json\", ...FILES_TO_DOWNLOAD].map(f => existsAsync(join(dir, f))));\n    return !results.includes(false);\n}\n\nexport async function ensureVencordFiles() {\n    if (await isValidVencordInstall(VENCORD_FILES_DIR)) return;\n\n    mkdirSync(VENCORD_FILES_DIR, { recursive: true });\n\n    await Promise.all([downloadVencordFiles(), writeFile(join(VENCORD_FILES_DIR, \"package.json\"), \"{}\")]);\n}\n\n// TODO: remove this once enough time has passed\nexport function vencordSupportsSandboxing() {\n    const supports = readFileSync(join(VENCORD_FILES_DIR, \"vencordDesktopMain.js\"), \"utf-8\").includes(\n        \"VencordGetRendererCss\"\n    );\n    if (!supports) {\n        console.warn(\n            \"⚠️  [VencordLoader] Vencord version is outdated and does not support sandboxing. Please update Vencord to the latest version.\"\n        );\n    }\n    return supports;\n}\n"
  },
  {
    "path": "src/main/vencordFilesDir.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vesktop contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { join } from \"path\";\n\nimport { SESSION_DATA_DIR } from \"./constants\";\nimport { State } from \"./settings\";\n\n// this is in a separate file to avoid circular dependencies\nexport const VENCORD_FILES_DIR = State.store.vencordDir || join(SESSION_DATA_DIR, \"vencordFiles\");\n"
  },
  {
    "path": "src/main/venmic.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport type { LinkData, Node, PatchBay as PatchBayType } from \"@vencord/venmic\";\nimport { app, ipcMain } from \"electron\";\nimport { join } from \"path\";\nimport { IpcEvents } from \"shared/IpcEvents\";\nimport { STATIC_DIR } from \"shared/paths\";\n\nimport { Settings } from \"./settings\";\n\nlet PatchBay: typeof PatchBayType | undefined;\nlet patchBayInstance: PatchBayType | undefined;\n\nlet imported = false;\nlet initialized = false;\n\nlet hasPipewirePulse = false;\nlet isGlibCxxOutdated = false;\n\nfunction importVenmic() {\n    if (imported) {\n        return;\n    }\n\n    imported = true;\n\n    try {\n        PatchBay = (require(join(STATIC_DIR, `dist/venmic-${process.arch}.node`)) as typeof import(\"@vencord/venmic\"))\n            .PatchBay;\n\n        hasPipewirePulse = PatchBay.hasPipeWire();\n    } catch (e: any) {\n        console.error(\"Failed to import venmic\", e);\n        isGlibCxxOutdated = (e?.stack || e?.message || \"\").toLowerCase().includes(\"glibc\");\n    }\n}\n\nfunction obtainVenmic() {\n    if (!imported) {\n        importVenmic();\n    }\n\n    if (PatchBay && !initialized) {\n        initialized = true;\n\n        try {\n            patchBayInstance = new PatchBay();\n        } catch (e: any) {\n            console.error(\"Failed to instantiate venmic\", e);\n        }\n    }\n\n    return patchBayInstance;\n}\n\nfunction getRendererAudioServicePid() {\n    return (\n        app\n            .getAppMetrics()\n            .find(proc => proc.name === \"Audio Service\")\n            ?.pid?.toString() ?? \"owo\"\n    );\n}\n\nipcMain.handle(IpcEvents.VIRT_MIC_LIST, () => {\n    const audioPid = getRendererAudioServicePid();\n\n    const { granularSelect } = Settings.store.audio ?? {};\n\n    const targets = obtainVenmic()\n        ?.list(granularSelect ? [\"node.name\"] : undefined)\n        .filter(s => s[\"application.process.id\"] !== audioPid);\n\n    return targets ? { ok: true, targets, hasPipewirePulse } : { ok: false, isGlibCxxOutdated };\n});\n\nipcMain.handle(IpcEvents.VIRT_MIC_START, (_, include: Node[]) => {\n    const pid = getRendererAudioServicePid();\n    const { ignoreDevices, ignoreInputMedia, ignoreVirtual, workaround } = Settings.store.audio ?? {};\n\n    const data: LinkData = {\n        include,\n        exclude: [{ \"application.process.id\": pid }],\n        ignore_devices: ignoreDevices\n    };\n\n    if (ignoreInputMedia ?? true) {\n        data.exclude.push({ \"media.class\": \"Stream/Input/Audio\" });\n    }\n\n    if (ignoreVirtual) {\n        data.exclude.push({ \"node.virtual\": \"true\" });\n    }\n\n    if (workaround) {\n        data.workaround = [{ \"application.process.id\": pid, \"media.name\": \"RecordStream\" }];\n    }\n\n    return obtainVenmic()?.link(data);\n});\n\nipcMain.handle(IpcEvents.VIRT_MIC_START_SYSTEM, (_, exclude: Node[]) => {\n    const pid = getRendererAudioServicePid();\n\n    const { workaround, ignoreDevices, ignoreInputMedia, ignoreVirtual, onlySpeakers, onlyDefaultSpeakers } =\n        Settings.store.audio ?? {};\n\n    const data: LinkData = {\n        include: [],\n        exclude: [{ \"application.process.id\": pid }, ...exclude],\n        only_speakers: onlySpeakers,\n        ignore_devices: ignoreDevices,\n        only_default_speakers: onlyDefaultSpeakers\n    };\n\n    if (ignoreInputMedia ?? true) {\n        data.exclude.push({ \"media.class\": \"Stream/Input/Audio\" });\n    }\n\n    if (ignoreVirtual) {\n        data.exclude.push({ \"node.virtual\": \"true\" });\n    }\n\n    if (workaround) {\n        data.workaround = [{ \"application.process.id\": pid, \"media.name\": \"RecordStream\" }];\n    }\n\n    return obtainVenmic()?.link(data);\n});\n\nipcMain.handle(IpcEvents.VIRT_MIC_STOP, () => obtainVenmic()?.unlink());\n"
  },
  {
    "path": "src/main/vesktopProtocol.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vesktop contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { app, protocol } from \"electron\";\n\nimport { handleVesktopAssetsProtocol } from \"./userAssets\";\nimport { handleVesktopStaticProtocol } from \"./vesktopStatic\";\n\napp.whenReady().then(() => {\n    protocol.handle(\"vesktop\", async req => {\n        const url = new URL(req.url);\n\n        switch (url.hostname) {\n            case \"assets\":\n                return handleVesktopAssetsProtocol(url.pathname, req);\n            case \"static\":\n                return handleVesktopStaticProtocol(url.pathname, req);\n            default:\n                return new Response(null, { status: 404 });\n        }\n    });\n});\n"
  },
  {
    "path": "src/main/vesktopStatic.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vesktop contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { BrowserWindow, net } from \"electron\";\nimport { join } from \"path\";\nimport { pathToFileURL } from \"url\";\n\nimport { isPathInDirectory } from \"./utils/isPathInDirectory\";\n\nconst STATIC_DIR = join(__dirname, \"..\", \"..\", \"static\");\n\nexport async function handleVesktopStaticProtocol(path: string, req: Request) {\n    const fullPath = join(STATIC_DIR, path);\n    if (!isPathInDirectory(fullPath, STATIC_DIR)) {\n        return new Response(null, { status: 404 });\n    }\n\n    return net.fetch(pathToFileURL(fullPath).href);\n}\n\nexport function loadView(browserWindow: BrowserWindow, view: string, params?: URLSearchParams) {\n    const url = new URL(`vesktop://static/views/${view}`);\n    if (params) {\n        url.search = params.toString();\n    }\n\n    return browserWindow.loadURL(url.toString());\n}\n"
  },
  {
    "path": "src/module.d.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vesktop contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\ndeclare module \"__patches__\" {\n    const never: never;\n    export default never;\n}\n"
  },
  {
    "path": "src/preload/VesktopNative.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport type { Node } from \"@vencord/venmic\";\nimport { ipcRenderer } from \"electron/renderer\";\nimport type { IpcMessage, IpcResponse } from \"main/ipcCommands\";\nimport type { Settings } from \"shared/settings\";\n\nimport { IpcEvents } from \"../shared/IpcEvents\";\nimport { invoke, sendSync } from \"./typedIpc\";\n\ntype SpellCheckerResultCallback = (word: string, suggestions: string[]) => void;\n\nconst spellCheckCallbacks = new Set<SpellCheckerResultCallback>();\n\nipcRenderer.on(IpcEvents.SPELLCHECK_RESULT, (_, w: string, s: string[]) => {\n    spellCheckCallbacks.forEach(cb => cb(w, s));\n});\n\nlet onDevtoolsOpen = () => {};\nlet onDevtoolsClose = () => {};\n\nipcRenderer.on(IpcEvents.DEVTOOLS_OPENED, () => onDevtoolsOpen());\nipcRenderer.on(IpcEvents.DEVTOOLS_CLOSED, () => onDevtoolsClose());\n\nexport const VesktopNative = {\n    app: {\n        relaunch: () => invoke<void>(IpcEvents.RELAUNCH),\n        getVersion: () => sendSync<void>(IpcEvents.GET_VERSION),\n        setBadgeCount: (count: number) => invoke<void>(IpcEvents.SET_BADGE_COUNT, count),\n        supportsWindowsTransparency: () => sendSync<boolean>(IpcEvents.SUPPORTS_WINDOWS_TRANSPARENCY),\n        getEnableHardwareAcceleration: () => sendSync<boolean>(IpcEvents.GET_ENABLE_HARDWARE_ACCELERATION),\n        isOutdated: () => invoke<boolean>(IpcEvents.UPDATER_IS_OUTDATED),\n        openUpdater: () => invoke<void>(IpcEvents.UPDATER_OPEN),\n        // used by vencord\n        getRendererCss: () => invoke<string>(IpcEvents.GET_VESKTOP_RENDERER_CSS),\n        onRendererCssUpdate: (cb: (newCss: string) => void) => {\n            if (!IS_DEV) return;\n\n            ipcRenderer.on(IpcEvents.VESKTOP_RENDERER_CSS_UPDATE, (_e, newCss: string) => cb(newCss));\n        }\n    },\n    autostart: {\n        isEnabled: () => sendSync<boolean>(IpcEvents.AUTOSTART_ENABLED),\n        enable: () => invoke<void>(IpcEvents.ENABLE_AUTOSTART),\n        disable: () => invoke<void>(IpcEvents.DISABLE_AUTOSTART)\n    },\n    fileManager: {\n        isUsingCustomVencordDir: () => sendSync<boolean>(IpcEvents.IS_USING_CUSTOM_VENCORD_DIR),\n        showCustomVencordDir: () => invoke<void>(IpcEvents.SHOW_CUSTOM_VENCORD_DIR),\n        selectVencordDir: (value?: null) => invoke<\"cancelled\" | \"invalid\" | \"ok\">(IpcEvents.SELECT_VENCORD_DIR, value),\n        chooseUserAsset: (asset: string, value?: null) =>\n            invoke<\"cancelled\" | \"invalid\" | \"ok\" | \"failed\">(IpcEvents.CHOOSE_USER_ASSET, asset, value)\n    },\n    settings: {\n        get: () => sendSync<Settings>(IpcEvents.GET_SETTINGS),\n        set: (settings: Settings, path?: string) => invoke<void>(IpcEvents.SET_SETTINGS, settings, path)\n    },\n    spellcheck: {\n        getAvailableLanguages: () => sendSync<string[]>(IpcEvents.SPELLCHECK_GET_AVAILABLE_LANGUAGES),\n        onSpellcheckResult(cb: SpellCheckerResultCallback) {\n            spellCheckCallbacks.add(cb);\n        },\n        offSpellcheckResult(cb: SpellCheckerResultCallback) {\n            spellCheckCallbacks.delete(cb);\n        },\n        replaceMisspelling: (word: string) => invoke<void>(IpcEvents.SPELLCHECK_REPLACE_MISSPELLING, word),\n        addToDictionary: (word: string) => invoke<void>(IpcEvents.SPELLCHECK_ADD_TO_DICTIONARY, word)\n    },\n    win: {\n        focus: () => invoke<void>(IpcEvents.FOCUS),\n        close: (key?: string) => invoke<void>(IpcEvents.CLOSE, key),\n        minimize: (key?: string) => invoke<void>(IpcEvents.MINIMIZE, key),\n        maximize: (key?: string) => invoke<void>(IpcEvents.MAXIMIZE, key),\n        flashFrame: (flag: boolean) => invoke<void>(IpcEvents.FLASH_FRAME, flag),\n        setDevtoolsCallbacks: (onOpen: () => void, onClose: () => void) => {\n            onDevtoolsOpen = onOpen;\n            onDevtoolsClose = onClose;\n        }\n    },\n    capturer: {\n        getLargeThumbnail: (id: string) => invoke<string>(IpcEvents.CAPTURER_GET_LARGE_THUMBNAIL, id)\n    },\n    /** only available on Linux. */\n    virtmic: {\n        list: () =>\n            invoke<\n                { ok: false; isGlibCxxOutdated: boolean } | { ok: true; targets: Node[]; hasPipewirePulse: boolean }\n            >(IpcEvents.VIRT_MIC_LIST),\n        start: (include: Node[]) => invoke<void>(IpcEvents.VIRT_MIC_START, include),\n        startSystem: (exclude: Node[]) => invoke<void>(IpcEvents.VIRT_MIC_START_SYSTEM, exclude),\n        stop: () => invoke<void>(IpcEvents.VIRT_MIC_STOP)\n    },\n    clipboard: {\n        copyImage: (imageBuffer: Uint8Array, imageSrc: string) =>\n            invoke<void>(IpcEvents.CLIPBOARD_COPY_IMAGE, imageBuffer, imageSrc)\n    },\n    debug: {\n        launchGpu: () => invoke<void>(IpcEvents.DEBUG_LAUNCH_GPU),\n        launchWebrtcInternals: () => invoke<void>(IpcEvents.DEBUG_LAUNCH_WEBRTC_INTERNALS)\n    },\n    commands: {\n        onCommand(cb: (message: IpcMessage) => void) {\n            ipcRenderer.on(IpcEvents.IPC_COMMAND, (_, message) => cb(message));\n        },\n        respond: (response: IpcResponse) => ipcRenderer.send(IpcEvents.IPC_COMMAND, response)\n    }\n};\n"
  },
  {
    "path": "src/preload/index.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { contextBridge, ipcRenderer, webFrame } from \"electron/renderer\";\n\nimport { IpcEvents } from \"../shared/IpcEvents\";\nimport { VesktopNative } from \"./VesktopNative\";\n\ncontextBridge.exposeInMainWorld(\"VesktopNative\", VesktopNative);\n\n// TODO: remove this legacy workaround once some time has passed\nconst isSandboxed = typeof __dirname === \"undefined\";\nif (isSandboxed) {\n    // While sandboxed, Electron \"polyfills\" these APIs as local variables.\n    // We have to pass them as arguments as they are not global\n    Function(\n        \"require\",\n        \"Buffer\",\n        \"process\",\n        \"clearImmediate\",\n        \"setImmediate\",\n        ipcRenderer.sendSync(IpcEvents.GET_VENCORD_PRELOAD_SCRIPT)\n    )(require, Buffer, process, clearImmediate, setImmediate);\n} else {\n    require(ipcRenderer.sendSync(IpcEvents.DEPRECATED_GET_VENCORD_PRELOAD_SCRIPT_PATH));\n}\n\nwebFrame.executeJavaScript(ipcRenderer.sendSync(IpcEvents.GET_VENCORD_RENDERER_SCRIPT));\nwebFrame.executeJavaScript(ipcRenderer.sendSync(IpcEvents.GET_VESKTOP_RENDERER_SCRIPT));\n"
  },
  {
    "path": "src/preload/splash.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vesktop contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { contextBridge, ipcRenderer } from \"electron/renderer\";\n\ncontextBridge.exposeInMainWorld(\"VesktopSplashNative\", {\n    onUpdateMessage(callback: (message: string) => void) {\n        ipcRenderer.on(\"update-splash-message\", (_, message: string) => callback(message));\n    }\n});\n"
  },
  {
    "path": "src/preload/typedIpc.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { ipcRenderer } from \"electron/renderer\";\nimport type { IpcEvents, UpdaterIpcEvents } from \"shared/IpcEvents\";\n\nexport function invoke<T = any>(event: IpcEvents | UpdaterIpcEvents, ...args: any[]) {\n    return ipcRenderer.invoke(event, ...args) as Promise<T>;\n}\n\nexport function sendSync<T = any>(event: IpcEvents | UpdaterIpcEvents, ...args: any[]) {\n    return ipcRenderer.sendSync(event, ...args) as T;\n}\n"
  },
  {
    "path": "src/preload/updater.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vesktop contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { contextBridge, ipcRenderer } from \"electron/renderer\";\nimport type { UpdateInfo } from \"electron-updater\";\nimport { UpdaterIpcEvents } from \"shared/IpcEvents\";\n\nimport { invoke } from \"./typedIpc\";\n\ncontextBridge.exposeInMainWorld(\"VesktopUpdaterNative\", {\n    getData: () => invoke<UpdateInfo>(UpdaterIpcEvents.GET_DATA),\n    installUpdate: () => invoke(UpdaterIpcEvents.INSTALL),\n    onProgress: (cb: (percent: number) => void) => {\n        ipcRenderer.on(UpdaterIpcEvents.DOWNLOAD_PROGRESS, (_, percent: number) => cb(percent));\n    },\n    onError: (cb: (message: string) => void) => {\n        ipcRenderer.on(UpdaterIpcEvents.ERROR, (_, message: string) => cb(message));\n    },\n    snoozeUpdate: () => invoke(UpdaterIpcEvents.SNOOZE_UPDATE),\n    ignoreUpdate: () => invoke(UpdaterIpcEvents.IGNORE_UPDATE)\n});\n"
  },
  {
    "path": "src/renderer/appBadge.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { filters, waitFor } from \"@vencord/types/webpack\";\nimport { RelationshipStore } from \"@vencord/types/webpack/common\";\n\nimport { VesktopLogger } from \"./logger\";\nimport { Settings } from \"./settings\";\n\nlet GuildReadStateStore: any;\nlet NotificationSettingsStore: any;\n\nexport function setBadge() {\n    if (Settings.store.appBadge === false) return;\n\n    try {\n        const mentionCount = GuildReadStateStore.getTotalMentionCount();\n        const pendingRequests = RelationshipStore.getPendingCount();\n        const hasUnread = GuildReadStateStore.hasAnyUnread();\n        const disableUnreadBadge = NotificationSettingsStore.getDisableUnreadBadge();\n\n        let totalCount = mentionCount + pendingRequests;\n        if (!totalCount && hasUnread && !disableUnreadBadge) totalCount = -1;\n\n        VesktopNative.app.setBadgeCount(totalCount);\n    } catch (e) {\n        VesktopLogger.error(\"Failed to update badge count\", e);\n    }\n}\n\nlet toFind = 3;\n\nfunction waitForAndSubscribeToStore(name: string, cb?: (m: any) => void) {\n    waitFor(filters.byStoreName(name), store => {\n        cb?.(store);\n        store.addChangeListener(setBadge);\n\n        toFind--;\n        if (toFind === 0) setBadge();\n    });\n}\n\nwaitForAndSubscribeToStore(\"GuildReadStateStore\", store => (GuildReadStateStore = store));\nwaitForAndSubscribeToStore(\"NotificationSettingsStore\", store => (NotificationSettingsStore = store));\nwaitForAndSubscribeToStore(\"RelationshipStore\");\n"
  },
  {
    "path": "src/renderer/arrpc.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport type arRpcPlugin from \"@vencord/types/plugins/arRPC.web\";\nimport { Logger } from \"@vencord/types/utils\";\nimport { findLazy, onceReady } from \"@vencord/types/webpack\";\nimport { FluxDispatcher, InviteActions, StreamerModeStore } from \"@vencord/types/webpack/common\";\nimport { IpcCommands } from \"shared/IpcEvents\";\n\nimport { onIpcCommand } from \"./ipcCommands\";\nimport { Settings } from \"./settings\";\n\nconst logger = new Logger(\"VesktopRPC\", \"#5865f2\");\n\nconst arRPC = Vencord.Plugins.plugins[\"WebRichPresence (arRPC)\"] as typeof arRpcPlugin;\n\nonIpcCommand(IpcCommands.RPC_ACTIVITY, async jsonData => {\n    if (!Settings.store.arRPC) return;\n\n    await onceReady;\n\n    const data = JSON.parse(jsonData);\n\n    if (data.socketId === \"STREAMERMODE\" && StreamerModeStore.autoToggle) {\n        FluxDispatcher.dispatch({\n            type: \"STREAMER_MODE_UPDATE\",\n            key: \"enabled\",\n            value: data.activity?.application_id === \"STREAMERMODE\"\n        });\n        return;\n    }\n\n    arRPC.handleEvent(new MessageEvent(\"message\", { data: jsonData }));\n});\n\nonIpcCommand(IpcCommands.RPC_INVITE, async code => {\n    const { invite } = await InviteActions.resolveInvite(code, \"Desktop Modal\");\n    if (!invite) return false;\n\n    VesktopNative.win.focus();\n\n    FluxDispatcher.dispatch({\n        type: \"INVITE_MODAL_OPEN\",\n        invite,\n        code,\n        context: \"APP\"\n    });\n\n    return true;\n});\n\nconst { DEEP_LINK } = findLazy(m => m.DEEP_LINK?.handler);\n\nonIpcCommand(IpcCommands.RPC_DEEP_LINK, async data => {\n    logger.debug(\"Opening deep link:\", data);\n    try {\n        DEEP_LINK.handler({ args: data });\n        return true;\n    } catch (err) {\n        logger.error(\"Failed to open deep link:\", err);\n        return false;\n    }\n});\n"
  },
  {
    "path": "src/renderer/components/ScreenSharePicker.tsx",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport \"./screenSharePicker.css\";\n\nimport { classNameFactory } from \"@vencord/types/api/Styles\";\nimport {\n    BaseText,\n    Button,\n    Card,\n    CogWheel,\n    FormSwitch,\n    Heading,\n    HeadingTertiary,\n    Margins,\n    Paragraph,\n    RestartIcon,\n    Span\n} from \"@vencord/types/components\";\nimport {\n    closeModal,\n    Logger,\n    ModalCloseButton,\n    Modals,\n    ModalSize,\n    openModal,\n    useAwaiter,\n    useForceUpdater\n} from \"@vencord/types/utils\";\nimport { onceReady } from \"@vencord/types/webpack\";\nimport { FluxDispatcher, MediaEngineStore, Select, UserStore, useState } from \"@vencord/types/webpack/common\";\nimport { Node } from \"@vencord/venmic\";\nimport type { Dispatch, SetStateAction } from \"react\";\nimport { addPatch } from \"renderer/patches/shared\";\nimport { State, useSettings, useVesktopState } from \"renderer/settings\";\nimport { isLinux, isWindows } from \"renderer/utils\";\n\nimport { SimpleErrorBoundary } from \"./SimpleErrorBoundary\";\n\nconst StreamResolutions = [\"480\", \"720\", \"1080\", \"1440\", \"2160\"] as const;\nconst StreamFps = [\"15\", \"30\", \"60\"] as const;\n\nconst cl = classNameFactory(\"vcd-screen-picker-\");\n\nexport type StreamResolution = (typeof StreamResolutions)[number];\nexport type StreamFps = (typeof StreamFps)[number];\n\ntype SpecialSource = \"None\" | \"Entire System\";\n\ntype AudioSource = SpecialSource | Node;\ntype AudioSources = SpecialSource | Node[];\n\ninterface AudioItem {\n    name: string;\n    value: AudioSource;\n}\n\ninterface StreamSettings {\n    audio: boolean;\n    contentHint?: string;\n    includeSources?: AudioSources;\n    excludeSources?: AudioSources;\n}\n\nexport interface StreamPick extends StreamSettings {\n    id: string;\n}\n\ninterface Source {\n    id: string;\n    name: string;\n    url: string;\n}\n\nexport let currentSettings: StreamSettings | null = null;\n\nconst logger = new Logger(\"VesktopScreenShare\");\n\naddPatch({\n    patches: [\n        {\n            find: \"this.getDefaultGoliveQuality()\",\n            replacement: {\n                match: /this\\.getDefaultGoliveQuality\\(\\)/,\n                replace: \"$self.patchStreamQuality($&)\"\n            }\n        }\n    ],\n    patchStreamQuality(opts: any) {\n        const { screenshareQuality } = State.store;\n        if (!screenshareQuality) return opts;\n\n        const framerate = Number(screenshareQuality.frameRate);\n        const height = Number(screenshareQuality.resolution);\n        const width = Math.round(height * (16 / 9));\n\n        Object.assign(opts, {\n            bitrateMin: 500000,\n            bitrateMax: 8000000,\n            bitrateTarget: 600000\n        });\n        if (opts?.encode) {\n            Object.assign(opts.encode, {\n                framerate,\n                width,\n                height,\n                pixelCount: height * width\n            });\n        }\n        Object.assign(opts.capture, {\n            framerate,\n            width,\n            height,\n            pixelCount: height * width\n        });\n        return opts;\n    }\n});\n\nif (isLinux) {\n    onceReady.then(() => {\n        FluxDispatcher.subscribe(\"STREAM_CLOSE\", ({ streamKey }: { streamKey: string }) => {\n            const owner = streamKey.split(\":\").at(-1);\n\n            if (owner !== UserStore.getCurrentUser().id) {\n                return;\n            }\n\n            VesktopNative.virtmic.stop();\n        });\n    });\n}\n\nexport function openScreenSharePicker(screens: Source[], skipPicker: boolean) {\n    let didSubmit = false;\n    return new Promise<StreamPick>((resolve, reject) => {\n        const key = openModal(\n            props => (\n                <ModalComponent\n                    screens={screens}\n                    modalProps={props}\n                    submit={async v => {\n                        didSubmit = true;\n\n                        if (v.includeSources && v.includeSources !== \"None\") {\n                            if (v.includeSources === \"Entire System\") {\n                                await VesktopNative.virtmic.startSystem(\n                                    !v.excludeSources || isSpecialSource(v.excludeSources) ? [] : v.excludeSources\n                                );\n                            } else {\n                                await VesktopNative.virtmic.start(v.includeSources);\n                            }\n                        }\n\n                        resolve(v);\n                    }}\n                    close={() => {\n                        props.onClose();\n                        if (!didSubmit) reject(\"Aborted\");\n                    }}\n                    skipPicker={skipPicker}\n                />\n            ),\n            {\n                onCloseRequest() {\n                    closeModal(key);\n                    reject(\"Aborted\");\n                },\n                onCloseCallback() {\n                    if (!didSubmit) reject(\"Aborted\");\n                }\n            }\n        );\n    });\n}\n\nfunction ScreenPicker({ screens, chooseScreen }: { screens: Source[]; chooseScreen: (id: string) => void }) {\n    return (\n        <div className={cl(\"screen-grid\")}>\n            {screens.map(({ id, name, url }) => (\n                <label key={id} className={cl(\"screen-label\")}>\n                    <input\n                        type=\"radio\"\n                        className={cl(\"screen-radio\")}\n                        name=\"screen\"\n                        value={id}\n                        onChange={() => chooseScreen(id)}\n                    />\n\n                    <img src={url} alt=\"\" />\n                    <Paragraph className={cl(\"screen-name\")}>{name}</Paragraph>\n                </label>\n            ))}\n        </div>\n    );\n}\n\nfunction AudioSettingsModal({\n    modalProps,\n    close,\n    setAudioSources\n}: {\n    modalProps: any;\n    close: () => void;\n    setAudioSources: (s: AudioSources) => void;\n}) {\n    const Settings = useSettings();\n\n    return (\n        <Modals.ModalRoot {...modalProps} size={ModalSize.MEDIUM}>\n            <Modals.ModalHeader className={cl(\"header\")}>\n                <BaseText size=\"lg\" weight=\"semibold\" tag=\"h3\" style={{ flexGrow: 1 }}>\n                    Audio Settings\n                </BaseText>\n                <ModalCloseButton onClick={close} />\n            </Modals.ModalHeader>\n\n            <Modals.ModalContent className={cl(\"modal\", \"venmic-settings\")}>\n                <FormSwitch\n                    title=\"Microphone Workaround\"\n                    description=\"Work around an issue that causes the microphone to be shared instead of the correct audio. Only enable if you're experiencing this issue.\"\n                    hideBorder\n                    onChange={v => (Settings.audio = { ...Settings.audio, workaround: v })}\n                    value={Settings.audio?.workaround ?? false}\n                />\n                <FormSwitch\n                    title=\"Only Speakers\"\n                    description={\n                        'When sharing entire desktop audio, only share apps that play to a speaker. You may want to disable this when using \"mix bussing\".'\n                    }\n                    hideBorder\n                    onChange={v => (Settings.audio = { ...Settings.audio, onlySpeakers: v })}\n                    value={Settings.audio?.onlySpeakers ?? true}\n                />\n                <FormSwitch\n                    title=\"Only Default Speakers\"\n                    description={\n                        <>\n                            When sharing entire desktop audio, only share apps that play to the <b>default</b> speakers.\n                            You may want to disable this when using \"mix bussing\".\n                        </>\n                    }\n                    hideBorder\n                    onChange={v => (Settings.audio = { ...Settings.audio, onlyDefaultSpeakers: v })}\n                    value={Settings.audio?.onlyDefaultSpeakers ?? true}\n                />\n                <FormSwitch\n                    title=\"Ignore Inputs\"\n                    description=\"Exclude nodes that are intended to capture audio.\"\n                    hideBorder\n                    onChange={v => (Settings.audio = { ...Settings.audio, ignoreInputMedia: v })}\n                    value={Settings.audio?.ignoreInputMedia ?? true}\n                />\n                <FormSwitch\n                    title=\"Ignore Virtual\"\n                    description={\n                        'Exclude virtual nodes, such as nodes belonging to loopbacks. This might be useful when using \"mix bussing\".'\n                    }\n                    hideBorder\n                    onChange={v => (Settings.audio = { ...Settings.audio, ignoreVirtual: v })}\n                    value={Settings.audio?.ignoreVirtual ?? false}\n                />\n                <FormSwitch\n                    title=\"Ignore Devices\"\n                    description=\"Exclude device nodes, such as nodes belonging to microphones or speakers.\"\n                    hideBorder\n                    onChange={v =>\n                        (Settings.audio = {\n                            ...Settings.audio,\n                            ignoreDevices: v,\n                            deviceSelect: v ? false : Settings.audio?.deviceSelect\n                        })\n                    }\n                    value={Settings.audio?.ignoreDevices ?? true}\n                />\n                <FormSwitch\n                    title=\"Granular Selection\"\n                    description=\"Allow to select applications more granularly.\"\n                    hideBorder\n                    onChange={value => {\n                        Settings.audio = { ...Settings.audio, granularSelect: value };\n                        setAudioSources(\"None\");\n                    }}\n                    value={Settings.audio?.granularSelect ?? false}\n                />\n                <FormSwitch\n                    title=\"Device Selection\"\n                    description={\n                        <>\n                            Allow to select devices such as microphones. Requires <b>Ignore Devices</b> to be turned\n                            off.\n                        </>\n                    }\n                    hideBorder\n                    onChange={value => {\n                        Settings.audio = { ...Settings.audio, deviceSelect: value };\n                        setAudioSources(\"None\");\n                    }}\n                    value={Settings.audio?.deviceSelect ?? false}\n                    disabled={Settings.audio?.ignoreDevices}\n                />\n            </Modals.ModalContent>\n            <Modals.ModalFooter className={cl(\"footer\")}>\n                <Button variant=\"secondary\" onClick={close}>\n                    Back\n                </Button>\n            </Modals.ModalFooter>\n        </Modals.ModalRoot>\n    );\n}\n\nfunction OptionRadio<Settings extends object, Key extends keyof Settings>(props: {\n    options: Array<string> | ReadonlyArray<string>;\n    labels?: Array<string>;\n    settings: Settings;\n    settingsKey: Key;\n    onChange: (option: string) => void;\n}) {\n    const { options, settings, settingsKey, labels, onChange } = props;\n\n    return (\n        <div className={cl(\"option-radios\")}>\n            {(options as string[]).map((option, idx) => (\n                <label className={cl(\"option-radio\")} data-checked={settings[settingsKey] === option} key={option}>\n                    <Span weight=\"bold\">{labels?.[idx] ?? option}</Span>\n                    <input\n                        className={cl(\"option-input\")}\n                        type=\"radio\"\n                        name=\"fps\"\n                        value={option}\n                        checked={settings[settingsKey] === option}\n                        onChange={() => onChange(option)}\n                    />\n                </label>\n            ))}\n        </div>\n    );\n}\n\nfunction StreamSettingsUi({\n    source,\n    settings,\n    setSettings,\n    skipPicker\n}: {\n    source: Source;\n    settings: StreamSettings;\n    setSettings: Dispatch<SetStateAction<StreamSettings>>;\n    skipPicker: boolean;\n}) {\n    const Settings = useSettings();\n    const qualitySettings = State.store.screenshareQuality!;\n\n    const [thumb] = useAwaiter(\n        () => (skipPicker ? Promise.resolve(source.url) : VesktopNative.capturer.getLargeThumbnail(source.id)),\n        {\n            fallbackValue: source.url,\n            deps: [source.id]\n        }\n    );\n\n    const openSettings = () => {\n        openModal(props => (\n            <AudioSettingsModal\n                modalProps={props}\n                close={() => props.onClose()}\n                setAudioSources={sources =>\n                    setSettings(s => ({ ...s, includeSources: sources, excludeSources: sources }))\n                }\n            />\n        ));\n    };\n\n    return (\n        <div>\n            <HeadingTertiary className={Margins.bottom8}>What you're streaming</HeadingTertiary>\n            <Card className={cl(\"card\", \"preview\")}>\n                <img src={thumb} alt=\"\" className={cl(isLinux ? \"preview-img-linux\" : \"preview-img\")} />\n                <Paragraph>{source.name}</Paragraph>\n            </Card>\n\n            <HeadingTertiary className={Margins.bottom8}>Stream Settings</HeadingTertiary>\n\n            <Card className={cl(\"card\")}>\n                <div className={cl(\"quality\")}>\n                    <section className={cl(\"quality-section\")}>\n                        <Heading tag=\"h5\">Resolution</Heading>\n                        <OptionRadio\n                            options={StreamResolutions}\n                            settings={qualitySettings}\n                            settingsKey=\"resolution\"\n                            onChange={value => (qualitySettings.resolution = value)}\n                        />\n                    </section>\n\n                    <section className={cl(\"quality-section\")}>\n                        <Heading tag=\"h5\">Frame Rate</Heading>\n                        <OptionRadio\n                            options={StreamFps}\n                            settings={qualitySettings}\n                            settingsKey=\"frameRate\"\n                            onChange={value => (qualitySettings.frameRate = value)}\n                        />\n                    </section>\n                </div>\n                <div className={cl(\"quality\")}>\n                    <section className={cl(\"quality-section\")}>\n                        <Heading tag=\"h5\">Content Type</Heading>\n                        <div>\n                            <OptionRadio\n                                options={[\"motion\", \"detail\"]}\n                                labels={[\"Prefer Smoothness\", \"Prefer Clarity\"]}\n                                settings={settings}\n                                settingsKey=\"contentHint\"\n                                onChange={option => setSettings(s => ({ ...s, contentHint: option }))}\n                            />\n\n                            <Paragraph className={Margins.top8}>\n                                Choosing \"Prefer Clarity\" will result in a significantly lower framerate in exchange for\n                                a much sharper and clearer image.\n                            </Paragraph>\n                        </div>\n                        {isWindows && (\n                            <FormSwitch\n                                title=\"Stream With Audio\"\n                                hideBorder\n                                value={settings.audio}\n                                onChange={checked => setSettings(s => ({ ...s, audio: checked }))}\n                                className={cl(\"audio\")}\n                            />\n                        )}\n                    </section>\n                </div>\n\n                {isLinux && (\n                    <AudioSourcePickerLinux\n                        openSettings={openSettings}\n                        includeSources={settings.includeSources}\n                        excludeSources={settings.excludeSources}\n                        deviceSelect={Settings.audio?.deviceSelect}\n                        granularSelect={Settings.audio?.granularSelect}\n                        setIncludeSources={sources => setSettings(s => ({ ...s, includeSources: sources }))}\n                        setExcludeSources={sources => setSettings(s => ({ ...s, excludeSources: sources }))}\n                    />\n                )}\n            </Card>\n        </div>\n    );\n}\n\nfunction isSpecialSource(value?: AudioSource | AudioSources): value is SpecialSource {\n    return typeof value === \"string\";\n}\n\nfunction hasMatchingProps(value: Node, other: Node) {\n    return Object.keys(value).every(key => value[key] === other[key]);\n}\n\nfunction mapToAudioItem(node: AudioSource, granularSelect?: boolean, deviceSelect?: boolean): AudioItem[] {\n    if (isSpecialSource(node)) {\n        return [{ name: node, value: node }];\n    }\n\n    const rtn: AudioItem[] = [];\n\n    const mediaClass = node[\"media.class\"];\n\n    if (mediaClass?.includes(\"Video\") || mediaClass?.includes(\"Midi\")) {\n        return rtn;\n    }\n\n    if (!deviceSelect && node[\"device.id\"]) {\n        return rtn;\n    }\n\n    const name = node[\"application.name\"];\n\n    if (name) {\n        rtn.push({ name: name, value: { \"application.name\": name } });\n    }\n\n    if (!granularSelect) {\n        return rtn;\n    }\n\n    const rawName = node[\"node.name\"];\n\n    if (!name) {\n        rtn.push({ name: rawName, value: { \"node.name\": rawName } });\n    }\n\n    const binary = node[\"application.process.binary\"];\n\n    if (!name && binary) {\n        rtn.push({ name: binary, value: { \"application.process.binary\": binary } });\n    }\n\n    const pid = node[\"application.process.id\"];\n\n    const first = rtn[0];\n    const firstValues = first.value as Node;\n\n    if (pid) {\n        rtn.push({\n            name: `${first.name} (${pid})`,\n            value: { ...firstValues, \"application.process.id\": pid }\n        });\n    }\n\n    const mediaName = node[\"media.name\"];\n\n    if (mediaName) {\n        rtn.push({\n            name: `${first.name} [${mediaName}]`,\n            value: { ...firstValues, \"media.name\": mediaName }\n        });\n    }\n\n    if (mediaClass) {\n        rtn.push({\n            name: `${first.name} [${mediaClass}]`,\n            value: { ...firstValues, \"media.class\": mediaClass }\n        });\n    }\n\n    return rtn;\n}\n\nfunction isItemSelected(sources?: AudioSources) {\n    return (value: AudioSource) => {\n        if (!sources) {\n            return false;\n        }\n\n        if (isSpecialSource(sources) || isSpecialSource(value)) {\n            return sources === value;\n        }\n\n        return sources.some(source => hasMatchingProps(source, value));\n    };\n}\n\nfunction updateItems(setSources: (s: AudioSources) => void, sources?: AudioSources) {\n    return (value: AudioSource) => {\n        if (isSpecialSource(value)) {\n            setSources(value);\n            return;\n        }\n\n        if (isSpecialSource(sources)) {\n            setSources([value]);\n            return;\n        }\n\n        if (isItemSelected(sources)(value)) {\n            setSources(sources?.filter(x => !hasMatchingProps(x, value)) ?? \"None\");\n            return;\n        }\n\n        setSources([...(sources || []), value]);\n    };\n}\n\nfunction AudioSourcePickerLinux({\n    includeSources,\n    excludeSources,\n    deviceSelect,\n    granularSelect,\n    openSettings,\n    setIncludeSources,\n    setExcludeSources\n}: {\n    includeSources?: AudioSources;\n    excludeSources?: AudioSources;\n    deviceSelect?: boolean;\n    granularSelect?: boolean;\n    openSettings: () => void;\n    setIncludeSources: (s: AudioSources) => void;\n    setExcludeSources: (s: AudioSources) => void;\n}) {\n    const [audioSourcesSignal, refreshAudioSources] = useForceUpdater(true);\n    const [sources, _, loading] = useAwaiter(() => VesktopNative.virtmic.list(), {\n        fallbackValue: { ok: true, targets: [], hasPipewirePulse: true },\n        deps: [audioSourcesSignal]\n    });\n\n    const hasPipewirePulse = sources.ok ? sources.hasPipewirePulse : true;\n    const [ignorePulseWarning, setIgnorePulseWarning] = useState(false);\n\n    if (!sources.ok && sources.isGlibCxxOutdated) {\n        return (\n            <Paragraph>\n                Failed to retrieve Audio Sources because your C++ library is too old to run\n                <a href=\"https://github.com/Vencord/venmic\" target=\"_blank\" rel=\"noreferrer\">\n                    venmic\n                </a>\n                . See{\" \"}\n                <a\n                    href=\"https://gist.github.com/Vendicated/b655044ffbb16b2716095a448c6d827a\"\n                    target=\"_blank\"\n                    rel=\"noreferrer\"\n                >\n                    this guide\n                </a>{\" \"}\n                for possible solutions.\n            </Paragraph>\n        );\n    }\n\n    if (!hasPipewirePulse && !ignorePulseWarning) {\n        return (\n            <Paragraph>\n                Could not find pipewire-pulse. See{\" \"}\n                <a\n                    href=\"https://gist.github.com/the-spyke/2de98b22ff4f978ebf0650c90e82027e#install\"\n                    target=\"_blank\"\n                    rel=\"noreferrer\"\n                >\n                    this guide\n                </a>{\" \"}\n                on how to switch to pipewire. <br />\n                You can still continue, however, please{\" \"}\n                <b>beware that you can only share audio of apps that are running under pipewire</b>.{\" \"}\n                <a onClick={() => setIgnorePulseWarning(true)}>I know what I'm doing!</a>\n            </Paragraph>\n        );\n    }\n\n    const specialSources: SpecialSource[] = [\"None\", \"Entire System\"] as const;\n\n    const uniqueName = (value: AudioItem, index: number, list: AudioItem[]) =>\n        list.findIndex(x => x.name === value.name) === index;\n\n    const allSources = sources.ok\n        ? [...specialSources, ...sources.targets]\n              .map(target => mapToAudioItem(target, granularSelect, deviceSelect))\n              .flat()\n              .filter(uniqueName)\n        : [];\n\n    return (\n        <>\n            <div className={cl(\"audio-sources\")}>\n                <section>\n                    <Heading tag=\"h5\">{loading ? \"Loading Sources...\" : \"Audio Sources\"}</Heading>\n                    <SimpleErrorBoundary>\n                        <Select\n                            options={allSources.map(({ name, value }) => ({\n                                label: name,\n                                value: value,\n                                default: name === \"None\"\n                            }))}\n                            isSelected={isItemSelected(includeSources)}\n                            select={updateItems(setIncludeSources, includeSources)}\n                            serialize={String}\n                            popoutPosition=\"top\"\n                            closeOnSelect={false}\n                        />\n                    </SimpleErrorBoundary>\n                </section>\n                {includeSources === \"Entire System\" && (\n                    <section>\n                        <Heading tag=\"h5\">Exclude Sources</Heading>\n                        <SimpleErrorBoundary>\n                            <Select\n                                options={allSources\n                                    .filter(x => x.name !== \"Entire System\")\n                                    .map(({ name, value }) => ({\n                                        label: name,\n                                        value: value,\n                                        default: name === \"None\"\n                                    }))}\n                                isSelected={isItemSelected(excludeSources)}\n                                select={updateItems(setExcludeSources, excludeSources)}\n                                serialize={String}\n                                popoutPosition=\"top\"\n                                closeOnSelect={false}\n                            />\n                        </SimpleErrorBoundary>\n                    </section>\n                )}\n            </div>\n            <div className={cl(\"settings-buttons\")}>\n                <Button variant=\"secondary\" onClick={refreshAudioSources} className={cl(\"settings-button\")}>\n                    <RestartIcon className={cl(\"settings-button-icon\")} />\n                    Refresh Audio Sources\n                </Button>\n                <Button variant=\"secondary\" onClick={openSettings} className={cl(\"settings-button\")}>\n                    <CogWheel className={cl(\"settings-button-icon\")} />\n                    Open Audio Settings\n                </Button>\n            </div>\n        </>\n    );\n}\n\nfunction ModalComponent({\n    screens,\n    modalProps,\n    submit,\n    close,\n    skipPicker\n}: {\n    screens: Source[];\n    modalProps: any;\n    submit: (data: StreamPick) => void;\n    close: () => void;\n    skipPicker: boolean;\n}) {\n    const [selected, setSelected] = useState<string | undefined>(skipPicker ? screens[0].id : void 0);\n    const [settings, setSettings] = useState<StreamSettings>({\n        contentHint: \"motion\",\n        audio: true,\n        includeSources: \"None\"\n    });\n    const qualitySettings = (useVesktopState().screenshareQuality ??= {\n        resolution: \"720\",\n        frameRate: \"30\"\n    });\n\n    return (\n        <Modals.ModalRoot {...modalProps} size={ModalSize.MEDIUM}>\n            <Modals.ModalHeader className={cl(\"header\")}>\n                <BaseText size=\"lg\" weight=\"semibold\" tag=\"h3\" style={{ flexGrow: 1 }}>\n                    Screen Share Picker\n                </BaseText>\n                <ModalCloseButton onClick={close} />\n            </Modals.ModalHeader>\n            <Modals.ModalContent className={cl(\"modal\")}>\n                {!selected ? (\n                    <ScreenPicker screens={screens} chooseScreen={setSelected} />\n                ) : (\n                    <StreamSettingsUi\n                        source={screens.find(s => s.id === selected)!}\n                        settings={settings}\n                        setSettings={setSettings}\n                        skipPicker={skipPicker}\n                    />\n                )}\n            </Modals.ModalContent>\n            <Modals.ModalFooter className={cl(\"footer\")}>\n                <Button\n                    disabled={!selected}\n                    onClick={() => {\n                        currentSettings = settings;\n                        try {\n                            const frameRate = Number(qualitySettings.frameRate);\n                            const height = Number(qualitySettings.resolution);\n                            const width = Math.round(height * (16 / 9));\n\n                            const conn = [...MediaEngineStore.getMediaEngine().connections].find(\n                                connection => connection.streamUserId === UserStore.getCurrentUser().id\n                            );\n\n                            if (conn) {\n                                conn.videoStreamParameters[0].maxFrameRate = frameRate;\n                                conn.videoStreamParameters[0].maxResolution.height = height;\n                                conn.videoStreamParameters[0].maxResolution.width = width;\n                            }\n\n                            submit({\n                                id: selected!,\n                                ...settings\n                            });\n\n                            setTimeout(async () => {\n                                const conn = [...MediaEngineStore.getMediaEngine().connections].find(\n                                    connection => connection.streamUserId === UserStore.getCurrentUser().id\n                                );\n                                if (!conn) return;\n\n                                const track = conn.input.stream.getVideoTracks()[0];\n\n                                const constraints = {\n                                    ...track.getConstraints(),\n                                    frameRate: { min: frameRate, ideal: frameRate },\n                                    width: { min: 640, ideal: width, max: width },\n                                    height: { min: 480, ideal: height, max: height },\n                                    advanced: [{ width: width, height: height }],\n                                    resizeMode: \"none\"\n                                };\n\n                                try {\n                                    await track.applyConstraints(constraints);\n\n                                    logger.info(\n                                        \"Applied constraints successfully. New constraints:\",\n                                        track.getConstraints()\n                                    );\n                                } catch (e) {\n                                    logger.error(\"Failed to apply constraints.\", e);\n                                }\n                            }, 100);\n                        } catch (error) {\n                            logger.error(\"Error while submitting stream.\", error);\n                        }\n\n                        close();\n                    }}\n                >\n                    Go Live\n                </Button>\n\n                {selected && !skipPicker ? (\n                    <Button variant=\"secondary\" onClick={() => setSelected(void 0)}>\n                        Back\n                    </Button>\n                ) : (\n                    <Button variant=\"secondary\" onClick={close}>\n                        Cancel\n                    </Button>\n                )}\n            </Modals.ModalFooter>\n        </Modals.ModalRoot>\n    );\n}\n"
  },
  {
    "path": "src/renderer/components/SimpleErrorBoundary.tsx",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vesktop contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { Card, ErrorBoundary, HeadingTertiary, Paragraph, TextButton } from \"@vencord/types/components\";\nimport { FluxDispatcher, InviteActions } from \"@vencord/types/webpack/common\";\nimport type { PropsWithChildren } from \"react\";\n\nasync function openSupportChannel() {\n    const code = \"YVbdG2ZRG4\";\n\n    try {\n        const { invite } = await InviteActions.resolveInvite(code, \"Desktop Modal\");\n\n        if (!invite) throw 0;\n\n        await FluxDispatcher.dispatch({\n            type: \"INVITE_MODAL_OPEN\",\n            invite,\n            code,\n            context: \"APP\"\n        });\n    } catch {\n        window.open(`https://discord.gg/${code}`, \"_blank\");\n    }\n}\n\nfunction Fallback() {\n    return (\n        <Card variant=\"danger\">\n            <HeadingTertiary>Something went wrong.</HeadingTertiary>\n            <Paragraph>\n                Please make sure Vencord and Vesktop are fully up to date. You can get help in our{\" \"}\n                <TextButton variant=\"link\" onClick={openSupportChannel}>\n                    Support Channel\n                </TextButton>\n            </Paragraph>\n        </Card>\n    );\n}\n\nexport function SimpleErrorBoundary({ children }: PropsWithChildren<{}>) {\n    return <ErrorBoundary fallback={Fallback}>{children}</ErrorBoundary>;\n}\n"
  },
  {
    "path": "src/renderer/components/index.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nexport * as ScreenShare from \"./ScreenSharePicker\";\n"
  },
  {
    "path": "src/renderer/components/screenSharePicker.css",
    "content": ".vcd-screen-picker-modal {\n    padding: 1em;\n}\n\n.vcd-screen-picker-header-close-button {\n    margin-left: auto;\n}\n\n.vcd-screen-picker-venmic-settings {\n    display: grid;\n    gap: 8px;\n}\n\n.vcd-screen-picker-footer {\n    display: flex;\n    gap: 1em;\n}\n\n.vcd-screen-picker-card {\n    flex-grow: 1;\n}\n\n\n/* Screen Grid */\n.vcd-screen-picker-screen-grid {\n    display: grid;\n    grid-template-columns: 1fr 1fr;\n    gap: 2em 1em;\n}\n\n.vcd-screen-picker-screen-radio {\n    appearance: none;\n    cursor: pointer;\n}\n\n.vcd-screen-picker-screen-label {\n    overflow: hidden;\n    padding: 8px;\n    cursor: pointer;\n    display: grid;\n    justify-items: center;\n}\n\n.vcd-screen-picker-screen-label:hover {\n    outline: 2px solid var(--brand-500);\n}\n\n.vcd-screen-picker-screen-name {\n    white-space: nowrap;\n    text-overflow: ellipsis;\n    overflow: hidden;\n    text-align: center;\n    font-weight: 600;\n    margin-inline: 0.5em;\n}\n\n.vcd-screen-picker-card {\n    padding: 0.5em;\n    box-sizing: border-box;\n}\n\n.vcd-screen-picker-preview-img-linux {\n    width: 60%;\n    margin-bottom: 0.5em;\n}\n\n.vcd-screen-picker-preview-img {\n    width: 90%;\n    margin-bottom: 0.5em;\n}\n\n.vcd-screen-picker-preview {\n    display: flex;\n    flex-direction: column;\n    justify-content: center;\n    align-items: center;\n    margin-bottom: 1em;\n}\n\n\n/* Option Radios */\n\n.vcd-screen-picker-option-radios {\n    display: grid;\n    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));\n    width: 100%;\n    border-radius: 3px;\n}\n\n.vcd-screen-picker-option-radio {\n    text-align: center;\n    background-color: var(--background-secondary);\n    border: 1px solid var(--primary-800);\n    padding: 0.3em;\n    cursor: pointer;\n}\n\n.vcd-screen-picker-option-radio:first-child {\n    border-radius: 3px 0 0 3px;\n}\n\n.vcd-screen-picker-option-radio:last-child {\n    border-radius: 0 3px 3px 0;\n}\n\n.vcd-screen-picker-option-input {\n    display: none;\n}\n\n.vcd-screen-picker-option-radio[data-checked=\"true\"] {\n    background-color: var(--brand-500);\n    border-color: var(--brand-500);\n}\n\n.vcd-screen-picker-quality {\n    display: flex;\n    gap: 1em;\n    margin-bottom: 0.5em;\n}\n\n.vcd-screen-picker-quality-section {\n    flex: 1 1 auto;\n}\n\n.vcd-screen-picker-settings-buttons {\n    display: flex;\n    justify-content: end;\n    gap: 0.5em;\n\n    margin-top: 0.75em;\n}\n\n.vcd-screen-picker-settings-button {\n    display: flex;\n    gap: 0.25em;\n    padding-inline: 0.5em 1em;\n}\n\n.vcd-screen-picker-settings-button-icon {\n    height: 1em;\n}\n\n.vcd-screen-picker-audio {\n    margin-bottom: 0;\n}\n\n.vcd-screen-picker-audio-sources {\n    display: flex;\n    gap: 1em;\n\n    >section {\n        flex: 1;\n    }\n}"
  },
  {
    "path": "src/renderer/components/settings/AutoStartToggle.tsx",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { useState } from \"@vencord/types/webpack/common\";\n\nimport { SettingsComponent } from \"./Settings\";\nimport { VesktopSettingsSwitch } from \"./VesktopSettingsSwitch\";\n\nexport const AutoStartToggle: SettingsComponent = ({ settings }) => {\n    const [autoStartEnabled, setAutoStartEnabled] = useState(VesktopNative.autostart.isEnabled());\n\n    return (\n        <>\n            <VesktopSettingsSwitch\n                title=\"Start With System\"\n                description=\"Automatically start Vesktop on computer start-up\"\n                value={autoStartEnabled}\n                onChange={async v => {\n                    await VesktopNative.autostart[v ? \"enable\" : \"disable\"]();\n                    setAutoStartEnabled(v);\n                }}\n            />\n\n            <VesktopSettingsSwitch\n                title=\"Auto Start Minimized\"\n                description={\"Start Vesktop minimized when starting with system\"}\n                value={settings.autoStartMinimized ?? false}\n                onChange={v => (settings.autoStartMinimized = v)}\n                disabled={!autoStartEnabled}\n            />\n        </>\n    );\n};\n"
  },
  {
    "path": "src/renderer/components/settings/DeveloperOptions.tsx",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { BaseText, Button, Heading, Paragraph, TextButton } from \"@vencord/types/components\";\nimport {\n    Margins,\n    ModalCloseButton,\n    ModalContent,\n    ModalHeader,\n    ModalRoot,\n    ModalSize,\n    openModal,\n    useForceUpdater\n} from \"@vencord/types/utils\";\nimport { Toasts } from \"@vencord/types/webpack/common\";\nimport { Settings } from \"shared/settings\";\n\nimport { cl, SettingsComponent } from \"./Settings\";\n\nexport const DeveloperOptionsButton: SettingsComponent = ({ settings }) => {\n    return <Button onClick={() => openDeveloperOptionsModal(settings)}>Open Developer Settings</Button>;\n};\n\nfunction openDeveloperOptionsModal(settings: Settings) {\n    openModal(props => (\n        <ModalRoot {...props} size={ModalSize.MEDIUM}>\n            <ModalHeader>\n                <BaseText size=\"lg\" weight=\"semibold\" tag=\"h3\" style={{ flexGrow: 1 }}>\n                    Vesktop Developer Options\n                </BaseText>\n                <ModalCloseButton onClick={props.onClose} />\n            </ModalHeader>\n\n            <ModalContent>\n                <div style={{ padding: \"1em 0\" }}>\n                    <Heading tag=\"h5\">Vencord Location</Heading>\n                    <VencordLocationPicker settings={settings} />\n\n                    <Heading tag=\"h5\" className={Margins.top16}>\n                        Debugging\n                    </Heading>\n                    <div className={cl(\"button-grid\")}>\n                        <Button onClick={() => VesktopNative.debug.launchGpu()}>Open chrome://gpu</Button>\n                        <Button onClick={() => VesktopNative.debug.launchWebrtcInternals()}>\n                            Open chrome://webrtc-internals\n                        </Button>\n                    </div>\n                </div>\n            </ModalContent>\n        </ModalRoot>\n    ));\n}\n\nconst VencordLocationPicker: SettingsComponent = ({ settings }) => {\n    const forceUpdate = useForceUpdater();\n    const usingCustomVencordDir = VesktopNative.fileManager.isUsingCustomVencordDir();\n\n    return (\n        <>\n            <Paragraph>\n                Vencord files are loaded from{\" \"}\n                {usingCustomVencordDir ? (\n                    <TextButton\n                        variant=\"link\"\n                        onClick={e => {\n                            e.preventDefault();\n                            VesktopNative.fileManager.showCustomVencordDir();\n                        }}\n                    >\n                        a custom location\n                    </TextButton>\n                ) : (\n                    \"the default location\"\n                )}\n            </Paragraph>\n            <div className={cl(\"button-grid\")}>\n                <Button\n                    onClick={async () => {\n                        const choice = await VesktopNative.fileManager.selectVencordDir();\n                        switch (choice) {\n                            case \"cancelled\":\n                                break;\n                            case \"ok\":\n                                Toasts.show({\n                                    message: \"Vencord install changed. Fully restart Vesktop to apply.\",\n                                    id: Toasts.genId(),\n                                    type: Toasts.Type.SUCCESS\n                                });\n                                break;\n                            case \"invalid\":\n                                Toasts.show({\n                                    message:\n                                        \"You did not choose a valid Vencord install. Make sure you're selecting the dist dir!\",\n                                    id: Toasts.genId(),\n                                    type: Toasts.Type.FAILURE\n                                });\n                                break;\n                        }\n                        forceUpdate();\n                    }}\n                >\n                    Change\n                </Button>\n                <Button\n                    variant=\"dangerPrimary\"\n                    onClick={async () => {\n                        await VesktopNative.fileManager.selectVencordDir(null);\n                        forceUpdate();\n                    }}\n                >\n                    Reset\n                </Button>\n            </div>\n        </>\n    );\n};\n"
  },
  {
    "path": "src/renderer/components/settings/DiscordBranchPicker.tsx",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { Select } from \"@vencord/types/webpack/common\";\n\nimport { SimpleErrorBoundary } from \"../SimpleErrorBoundary\";\nimport { SettingsComponent } from \"./Settings\";\n\nexport const DiscordBranchPicker: SettingsComponent = ({ settings }) => {\n    return (\n        <SimpleErrorBoundary>\n            <Select\n                placeholder=\"Stable\"\n                options={[\n                    { label: \"Stable\", value: \"stable\", default: true },\n                    { label: \"Canary\", value: \"canary\" },\n                    { label: \"PTB\", value: \"ptb\" }\n                ]}\n                closeOnSelect={true}\n                select={v => (settings.discordBranch = v)}\n                isSelected={v => v === settings.discordBranch}\n                serialize={s => s}\n            />\n        </SimpleErrorBoundary>\n    );\n};\n"
  },
  {
    "path": "src/renderer/components/settings/NotificationBadgeToggle.tsx",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { setBadge } from \"renderer/appBadge\";\n\nimport { SettingsComponent } from \"./Settings\";\nimport { VesktopSettingsSwitch } from \"./VesktopSettingsSwitch\";\n\nexport const NotificationBadgeToggle: SettingsComponent = ({ settings }) => {\n    return (\n        <VesktopSettingsSwitch\n            title=\"Notification Badge\"\n            description=\"Show mention badge on the app icon\"\n            value={settings.appBadge ?? true}\n            onChange={v => {\n                settings.appBadge = v;\n                if (v) setBadge();\n                else VesktopNative.app.setBadgeCount(0);\n            }}\n        />\n    );\n};\n"
  },
  {
    "path": "src/renderer/components/settings/OutdatedVesktopWarning.tsx",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vesktop contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { Button, Card, HeadingTertiary, Paragraph } from \"@vencord/types/components\";\nimport { useAwaiter } from \"@vencord/types/utils\";\n\nimport { cl } from \"./Settings\";\n\nexport function OutdatedVesktopWarning() {\n    const [isOutdated] = useAwaiter(VesktopNative.app.isOutdated);\n\n    if (!isOutdated) return null;\n\n    return (\n        <Card variant=\"warning\" className={cl(\"updater-card\")}>\n            <HeadingTertiary>Your Vesktop is outdated!</HeadingTertiary>\n            <Paragraph>Staying up to date is important for security and stability.</Paragraph>\n\n            <Button onClick={() => VesktopNative.app.openUpdater()} variant=\"secondary\">\n                Open Updater\n            </Button>\n        </Card>\n    );\n}\n"
  },
  {
    "path": "src/renderer/components/settings/Settings.tsx",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport \"./settings.css\";\n\nimport { classNameFactory } from \"@vencord/types/api/Styles\";\nimport { BaseText, Divider, ErrorBoundary } from \"@vencord/types/components\";\nimport { ComponentType } from \"react\";\nimport { Settings, useSettings } from \"renderer/settings\";\nimport { isMac, isWindows } from \"renderer/utils\";\n\nimport { AutoStartToggle } from \"./AutoStartToggle\";\nimport { DeveloperOptionsButton } from \"./DeveloperOptions\";\nimport { DiscordBranchPicker } from \"./DiscordBranchPicker\";\nimport { NotificationBadgeToggle } from \"./NotificationBadgeToggle\";\nimport { OutdatedVesktopWarning } from \"./OutdatedVesktopWarning\";\nimport { UserAssetsButton } from \"./UserAssets\";\nimport { VesktopSettingsSwitch } from \"./VesktopSettingsSwitch\";\nimport { WindowsTransparencyControls } from \"./WindowsTransparencyControls\";\n\ninterface BooleanSetting {\n    key: keyof typeof Settings.store;\n    title: string;\n    description: string;\n    defaultValue: boolean;\n    disabled?(): boolean;\n    invisible?(): boolean;\n}\n\nexport const cl = classNameFactory(\"vcd-settings-\");\n\nexport type SettingsComponent = ComponentType<{ settings: typeof Settings.store }>;\n\nconst SettingsOptions: Record<string, Array<BooleanSetting | SettingsComponent>> = {\n    \"Discord Branch\": [DiscordBranchPicker],\n    \"System Startup & Performance\": [\n        AutoStartToggle,\n        {\n            key: \"hardwareAcceleration\",\n            title: \"Hardware Acceleration\",\n            description: \"Enable hardware acceleration\",\n            defaultValue: true\n        },\n        {\n            key: \"hardwareVideoAcceleration\",\n            title: \"Video Hardware Acceleration\",\n            description:\n                \"Enable hardware video acceleration. This can improve performance of screenshare and video playback, but may cause graphical glitches and infinitely loading streams.\",\n            defaultValue: false,\n            disabled: () => Settings.store.hardwareAcceleration === false\n        }\n    ],\n    \"User Interface\": [\n        {\n            key: \"customTitleBar\",\n            title: \"Discord Titlebar\",\n            description: \"Use Discord's custom title bar instead of the native system one. Requires a full restart.\",\n            defaultValue: isWindows\n        },\n        {\n            key: \"staticTitle\",\n            title: \"Static Title\",\n            description: 'Makes the window title \"Vesktop\" instead of changing to the current page',\n            defaultValue: false\n        },\n        {\n            key: \"enableMenu\",\n            title: \"Enable Menu Bar\",\n            description: \"Enables the application menu bar. Press ALT to toggle visibility.\",\n            defaultValue: false,\n            disabled: () => Settings.store.customTitleBar ?? isWindows\n        },\n        {\n            key: \"enableSplashScreen\",\n            title: \"Enable Splash Screen\",\n            description:\n                \"Shows a small splash screen while Vesktop is loading. Disabling this option will show the main window earlier while it's still loading.\",\n            defaultValue: true\n        },\n        {\n            key: \"splashTheming\",\n            title: \"Splash theming\",\n            description: \"Adapt the splash window colors to your custom theme\",\n            defaultValue: true\n        },\n        WindowsTransparencyControls,\n        UserAssetsButton\n    ],\n    Behaviour: [\n        {\n            key: \"tray\",\n            title: \"Tray Icon\",\n            description: \"Add a tray icon for Vesktop\",\n            defaultValue: true,\n            invisible: () => isMac\n        },\n        {\n            key: \"minimizeToTray\",\n            title: \"Minimize to tray\",\n            description: \"Hitting X will make Vesktop minimize to the tray instead of closing\",\n            defaultValue: true,\n            invisible: () => isMac,\n            disabled: () => Settings.store.tray === false\n        },\n        {\n            key: \"clickTrayToShowHide\",\n            title: \"Hide/Show on tray click\",\n            description: \"Left clicking tray icon will toggle the vesktop window visibility.\",\n            defaultValue: false\n        },\n        {\n            key: \"disableMinSize\",\n            title: \"Disable minimum window size\",\n            description: \"Allows you to make the window as small as your heart desires\",\n            defaultValue: false\n        },\n        {\n            key: \"disableSmoothScroll\",\n            title: \"Disable smooth scrolling\",\n            description: \"Disables smooth scrolling\",\n            defaultValue: false\n        }\n    ],\n    Notifications: [\n        NotificationBadgeToggle,\n        {\n            key: \"enableTaskbarFlashing\",\n            title: \"Enable Taskbar Flashing\",\n            description: \"Flashes the app in your taskbar when you have new notifications.\",\n            defaultValue: false\n        }\n    ],\n    Miscellaneous: [\n        {\n            key: \"arRPC\",\n            title: \"Rich Presence\",\n            description: \"Enables Rich Presence via arRPC\",\n            defaultValue: false\n        },\n\n        {\n            key: \"openLinksWithElectron\",\n            title: \"Open Links in app (experimental)\",\n            description: \"Opens links in a new Vesktop window instead of your web browser\",\n            defaultValue: false\n        }\n    ],\n    \"Developer Options\": [DeveloperOptionsButton]\n};\n\nfunction SettingsSections() {\n    const Settings = useSettings();\n\n    const sections = Object.entries(SettingsOptions).map(([title, settings], i, arr) => (\n        <div key={title} className={cl(\"category\")}>\n            <BaseText size=\"lg\" weight=\"semibold\" tag=\"h3\" className={cl(\"category-title\")}>\n                {title}\n            </BaseText>\n\n            <div className={cl(\"category-content\")}>\n                {settings.map((Setting, i) => {\n                    if (typeof Setting === \"function\") return <Setting key={`Custom-${i}`} settings={Settings} />;\n\n                    const { defaultValue, title, description, key, disabled, invisible } = Setting;\n                    if (invisible?.()) return null;\n\n                    return (\n                        <VesktopSettingsSwitch\n                            title={title}\n                            description={description}\n                            value={Settings[key as any] ?? defaultValue}\n                            onChange={v => (Settings[key as any] = v)}\n                            disabled={disabled?.()}\n                            key={key}\n                        />\n                    );\n                })}\n            </div>\n\n            {i < arr.length - 1 && <Divider className={cl(\"category-divider\")} />}\n        </div>\n    ));\n\n    return <>{sections}</>;\n}\n\nexport default ErrorBoundary.wrap(\n    function SettingsUI() {\n        return (\n            <section>\n                <OutdatedVesktopWarning />\n                <SettingsSections />\n            </section>\n        );\n    },\n    {\n        message:\n            \"Failed to render the Vesktop Settings tab. If this issue persists, try to right click the Vesktop tray icon, then click 'Repair Vencord'. And make sure your Vesktop is up to date.\"\n    }\n);\n"
  },
  {
    "path": "src/renderer/components/settings/UserAssets.css",
    "content": ".vcd-user-assets {\n    display: flex;\n    margin-block: 1em 2em;\n    flex-direction: column;\n    gap: 1em;\n}\n\n.vcd-user-assets-asset {\n    display: flex;\n    margin-top: 0.5em;\n    align-items: center;\n    gap: 1em;\n}\n\n.vcd-user-assets-actions {\n    display: grid;\n    width: 100%;\n    gap: 0.5em;\n    margin-bottom: auto;\n}\n\n.vcd-user-assets-buttons {\n    display: flex;\n    gap: 0.5em;\n}\n\n.vcd-user-assets-image {\n    height: 7.5em;\n    width: 7.5em;\n    object-fit: contain;\n}"
  },
  {
    "path": "src/renderer/components/settings/UserAssets.tsx",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport \"./UserAssets.css\";\n\nimport { BaseText, Button, FormSwitch } from \"@vencord/types/components\";\nimport {\n    Margins,\n    ModalCloseButton,\n    ModalContent,\n    ModalHeader,\n    ModalRoot,\n    ModalSize,\n    openModal,\n    wordsFromCamel,\n    wordsToTitle\n} from \"@vencord/types/utils\";\nimport { showToast, useState } from \"@vencord/types/webpack/common\";\nimport { UserAssetType } from \"main/userAssets\";\nimport { useSettings } from \"renderer/settings\";\n\nimport { SettingsComponent } from \"./Settings\";\n\nconst CUSTOMIZABLE_ASSETS: UserAssetType[] = [\"splash\", \"tray\", \"trayUnread\"];\n\nexport const UserAssetsButton: SettingsComponent = () => {\n    return <Button onClick={() => openAssetsModal()}>Customize App Assets</Button>;\n};\n\nfunction openAssetsModal() {\n    openModal(props => (\n        <ModalRoot {...props} size={ModalSize.MEDIUM}>\n            <ModalHeader>\n                <BaseText size=\"lg\" weight=\"semibold\" tag=\"h3\" style={{ flexGrow: 1 }}>\n                    User Assets\n                </BaseText>\n                <ModalCloseButton onClick={props.onClose} />\n            </ModalHeader>\n\n            <ModalContent>\n                <div className=\"vcd-user-assets\">\n                    {CUSTOMIZABLE_ASSETS.map(asset => (\n                        <Asset key={asset} asset={asset} />\n                    ))}\n                </div>\n            </ModalContent>\n        </ModalRoot>\n    ));\n}\n\nfunction Asset({ asset }: { asset: UserAssetType }) {\n    // cache busting\n    const [version, setVersion] = useState(Date.now());\n    const settings = useSettings();\n\n    const isSplash = asset === \"splash\";\n    const imageRendering = isSplash && settings.splashPixelated ? \"pixelated\" : \"auto\";\n\n    const onChooseAsset = (value?: null) => async () => {\n        const res = await VesktopNative.fileManager.chooseUserAsset(asset, value);\n        if (res === \"ok\") {\n            setVersion(Date.now());\n            if (isSplash && value === null) {\n                settings.splashPixelated = false;\n            }\n        } else if (res === \"failed\") {\n            showToast(\"Something went wrong. Please try again\");\n        }\n    };\n\n    return (\n        <section>\n            <BaseText size=\"md\" weight=\"medium\" tag=\"h3\">\n                {wordsToTitle(wordsFromCamel(asset))}\n            </BaseText>\n            <div className=\"vcd-user-assets-asset\">\n                <img\n                    className=\"vcd-user-assets-image\"\n                    src={`vesktop://assets/${asset}?v=${version}`}\n                    alt=\"\"\n                    style={{ imageRendering }}\n                />\n                <div className=\"vcd-user-assets-actions\">\n                    <div className=\"vcd-user-assets-buttons\">\n                        <Button onClick={onChooseAsset()}>Customize</Button>\n                        <Button variant=\"secondary\" onClick={onChooseAsset(null)}>\n                            Reset to default\n                        </Button>\n                    </div>\n                    {isSplash && (\n                        <FormSwitch\n                            title=\"Nearest-Neighbor Scaling (for pixel art)\"\n                            value={settings.splashPixelated ?? false}\n                            onChange={val => (settings.splashPixelated = val)}\n                            className={Margins.top16}\n                            hideBorder\n                        />\n                    )}\n                </div>\n            </div>\n        </section>\n    );\n}\n"
  },
  {
    "path": "src/renderer/components/settings/VesktopSettingsSwitch.tsx",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vesktop contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { FormSwitch } from \"@vencord/types/components\";\nimport type { ComponentProps } from \"react\";\n\nimport { cl } from \"./Settings\";\n\nexport function VesktopSettingsSwitch(props: ComponentProps<typeof FormSwitch>) {\n    return <FormSwitch {...props} hideBorder className={cl(\"switch\")} />;\n}\n"
  },
  {
    "path": "src/renderer/components/settings/WindowsTransparencyControls.tsx",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { Heading, Paragraph } from \"@vencord/types/components\";\nimport { Margins } from \"@vencord/types/utils\";\nimport { Select } from \"@vencord/types/webpack/common\";\n\nimport { SimpleErrorBoundary } from \"../SimpleErrorBoundary\";\nimport { SettingsComponent } from \"./Settings\";\n\nexport const WindowsTransparencyControls: SettingsComponent = ({ settings }) => {\n    if (!VesktopNative.app.supportsWindowsTransparency()) return null;\n\n    return (\n        <div>\n            <Heading tag=\"h5\">Transparency Options</Heading>\n            <Paragraph className={Margins.bottom8}>\n                Requires a full restart. You will need a theme that supports transparency for this to work.\n            </Paragraph>\n\n            <SimpleErrorBoundary>\n                <Select\n                    placeholder=\"None\"\n                    options={[\n                        {\n                            label: \"None\",\n                            value: \"none\",\n                            default: true\n                        },\n                        {\n                            label: \"Mica (incorporates system theme + desktop wallpaper to paint the background)\",\n                            value: \"mica\"\n                        },\n                        { label: \"Tabbed (variant of Mica with stronger background tinting)\", value: \"tabbed\" },\n                        {\n                            label: \"Acrylic (blurs the window behind Vesktop for a translucent background)\",\n                            value: \"acrylic\"\n                        }\n                    ]}\n                    closeOnSelect={true}\n                    select={v => (settings.transparencyOption = v)}\n                    isSelected={v => v === settings.transparencyOption}\n                    serialize={s => s}\n                />\n            </SimpleErrorBoundary>\n        </div>\n    );\n};\n"
  },
  {
    "path": "src/renderer/components/settings/settings.css",
    "content": ".vcd-settings-button-grid {\n    display: grid;\n    grid-template-columns: 1fr 1fr;\n    gap: 0.5em;\n    margin-top: 0.5em;\n}\n\n.vcd-settings-title {\n    margin-bottom: 32px;\n}\n\n.vcd-settings-category {\n    display: flex;\n    flex-direction: column;\n}\n\n.vcd-settings-category-title {\n    margin-bottom: 16px;\n}\n\n.vcd-settings-category-content {\n    display: flex;\n    flex-direction: column;\n    gap: 24px;\n}\n\n.vcd-settings-category-divider {\n    margin-top: 32px;\n    margin-bottom: 32px;\n}\n\n.vcd-settings-switch {\n    margin-bottom: 0;\n}\n\n.vcd-settings-updater-card {\n    padding: 1em;\n    margin-bottom: 1em;\n    display: grid;\n    gap: 0.5em;\n}"
  },
  {
    "path": "src/renderer/fixes.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { localStorage } from \"./utils\";\n\n// Make clicking Notifications focus the window\nconst originalSetOnClick = Object.getOwnPropertyDescriptor(Notification.prototype, \"onclick\")!.set!;\nObject.defineProperty(Notification.prototype, \"onclick\", {\n    set(onClick) {\n        originalSetOnClick.call(this, function (this: unknown) {\n            onClick.apply(this, arguments);\n            VesktopNative.win.focus();\n        });\n    },\n    configurable: true\n});\n\n// Hide \"Download Discord Desktop now!!!!\" banner\nlocalStorage.setItem(\"hideNag\", \"true\");\n"
  },
  {
    "path": "src/renderer/index.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport \"./themedSplash\";\nimport \"./ipcCommands\";\nimport \"./appBadge\";\nimport \"./fixes\";\nimport \"./arrpc\";\nimport \"__patches__\"; // auto generated by the build script\n\nexport * as Components from \"./components\";\n\nimport SettingsUi from \"./components/settings/Settings\";\nimport { VesktopLogger } from \"./logger\";\nimport { Settings } from \"./settings\";\nexport { Settings };\n\nimport type SettingsPlugin from \"@vencord/types/plugins/_core/settings\";\n\nVesktopLogger.log(\"read if cute :3\");\nVesktopLogger.log(\"Vesktop v\" + VesktopNative.app.getVersion());\n\n// TODO\nconst customSettingsSections = (Vencord.Plugins.plugins.Settings as typeof SettingsPlugin).customSections;\n\ncustomSettingsSections.push(() => ({\n    section: \"Vesktop\",\n    label: \"Vesktop Settings\",\n    element: SettingsUi,\n    className: \"vc-vesktop-settings\"\n}));\n\n// TODO: remove this legacy workaround once some time has passed\nif (!Vencord.Api.Styles.vencordRootNode) {\n    const style = document.createElement(\"style\");\n    style.id = \"vesktop-css-core\";\n\n    VesktopNative.app.getRendererCss().then(css => (style.textContent = css));\n\n    document.addEventListener(\"DOMContentLoaded\", () => document.documentElement.append(style), { once: true });\n}\n"
  },
  {
    "path": "src/renderer/ipcCommands.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { SettingsRouter } from \"@vencord/types/webpack/common\";\nimport { IpcCommands } from \"shared/IpcEvents\";\n\nimport { openScreenSharePicker } from \"./components/ScreenSharePicker\";\n\ntype IpcCommandHandler = (data: any) => any;\n\nconst handlers = new Map<string, IpcCommandHandler>();\n\nfunction respond(nonce: string, ok: boolean, data: any) {\n    VesktopNative.commands.respond({ nonce, ok, data });\n}\n\nVesktopNative.commands.onCommand(async ({ message, nonce, data }) => {\n    const handler = handlers.get(message);\n    if (!handler) {\n        return respond(nonce, false, `No handler for message: ${message}`);\n    }\n\n    try {\n        const result = await handler(data);\n        respond(nonce, true, result);\n    } catch (err) {\n        respond(nonce, false, String(err));\n    }\n});\n\nexport function onIpcCommand(channel: string, handler: IpcCommandHandler) {\n    if (handlers.has(channel)) {\n        throw new Error(`Handler for message ${channel} already exists`);\n    }\n\n    handlers.set(channel, handler);\n}\n\nexport function offIpcCommand(channel: string) {\n    handlers.delete(channel);\n}\n\n/* Generic Handlers */\n\nonIpcCommand(IpcCommands.NAVIGATE_SETTINGS, () => {\n    SettingsRouter.open(\"My Account\");\n});\n\nonIpcCommand(IpcCommands.GET_LANGUAGES, () => navigator.languages);\n\nonIpcCommand(IpcCommands.SCREEN_SHARE_PICKER, data => openScreenSharePicker(data.screens, data.skipPicker));\n"
  },
  {
    "path": "src/renderer/logger.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { Logger } from \"@vencord/types/utils\";\n\nexport const VesktopLogger = new Logger(\"Vesktop\", \"#d3869b\");\n"
  },
  {
    "path": "src/renderer/patches/devtoolsFixes.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vesktop contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { addPatch } from \"./shared\";\n\naddPatch({\n    patches: [\n        // Discord Web blocks the devtools keybin on mac specifically, disable that\n        {\n            find: '\"mod+alt+i\"',\n            replacement: {\n                match: /\"discord\\.com\"===location\\.host/,\n                replace: \"false\"\n            }\n        },\n\n        // Discord Web uses an incredibly broken devtools detector with false positives.\n        // They \"hide\" (aka remove from storage) your token if it \"detects\" open devtools.\n        // Due to the false positives, this leads to random logouts.\n        // Patch their devtools detection to use proper Electron APIs instead to fix the false positives\n        {\n            find: \".setDevtoolsCallbacks(\",\n            group: true,\n            replacement: [\n                {\n                    match: /if\\(null!=(\\i)\\)(?=.{0,50}\\1\\.window\\.setDevtoolsCallbacks)/,\n                    replace: \"if(true)\"\n                },\n                {\n                    match: /\\b\\i\\.window\\.setDevtoolsCallbacks/g,\n                    replace: \"VesktopNative.win.setDevtoolsCallbacks\"\n                }\n            ]\n        }\n    ]\n});\n"
  },
  {
    "path": "src/renderer/patches/enableNotificationsByDefault.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { addPatch } from \"./shared\";\n\naddPatch({\n    patches: [\n        {\n            find: '\"NotificationSettingsStore',\n            replacement: {\n                match: /\\.isPlatformEmbedded(?=\\?\\i\\.\\i\\.ALL)/g,\n                replace: \"$&||true\"\n            }\n        }\n    ]\n});\n"
  },
  {
    "path": "src/renderer/patches/fixStreamConstraints.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vesktop contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { Logger } from \"@vencord/types/utils\";\nimport { MediaEngineStore } from \"@vencord/types/webpack/common\";\n\nconst logger = new Logger(\"VesktopStreamFixes\");\n\nfunction fixAudioTrackConstraints(constraint: MediaTrackConstraints) {\n    const target = constraint.advanced?.find(opt => Object.hasOwn(opt, \"autoGainControl\")) ?? constraint;\n\n    target.autoGainControl = MediaEngineStore.getAutomaticGainControl();\n}\n\nfunction fixVideoTrackConstraints(constraint: MediaTrackConstraints) {\n    if (typeof constraint.deviceId === \"string\" && constraint.deviceId !== \"default\") {\n        constraint.deviceId = { exact: constraint.deviceId };\n    }\n}\n\nfunction fixStreamConstraints(constraints: MediaStreamConstraints | undefined) {\n    if (!constraints) return;\n\n    if (constraints.audio) {\n        if (typeof constraints.audio !== \"object\") {\n            constraints.audio = {};\n        }\n        fixAudioTrackConstraints(constraints.audio);\n    }\n\n    if (constraints.video) {\n        if (typeof constraints.video !== \"object\") {\n            constraints.video = {};\n        }\n        fixVideoTrackConstraints(constraints.video);\n    }\n}\n\nconst originalGetUserMedia = navigator.mediaDevices.getUserMedia;\nnavigator.mediaDevices.getUserMedia = function (constraints) {\n    try {\n        fixStreamConstraints(constraints);\n    } catch (e) {\n        logger.error(\"Failed to fix getUserMedia constraints\", e);\n    }\n    return originalGetUserMedia.call(this, constraints);\n};\n\nconst originalApplyConstraints = MediaStreamTrack.prototype.applyConstraints;\nMediaStreamTrack.prototype.applyConstraints = function (constraints) {\n    if (constraints) {\n        try {\n            if (this.kind === \"audio\") {\n                fixAudioTrackConstraints(constraints);\n            } else if (this.kind === \"video\") {\n                fixVideoTrackConstraints(constraints);\n            }\n        } catch (e) {\n            logger.error(\"Failed to fix constraints\", e);\n        }\n    }\n    return originalApplyConstraints.call(this, constraints);\n};\n"
  },
  {
    "path": "src/renderer/patches/hideDownloadAppsButton.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { addPatch } from \"./shared\";\n\naddPatch({\n    patches: [\n        {\n            find: '\"app-download-button\"',\n            replacement: {\n                match: /return(?=.{0,50}id:\"app-download-button\")/,\n                replace: \"return null;return\"\n            }\n        }\n    ]\n});\n"
  },
  {
    "path": "src/renderer/patches/hideSwitchDevice.tsx",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { addPatch } from \"./shared\";\n\naddPatch({\n    patches: [\n        {\n            find: \"lastOutputSystemDevice.justChanged\",\n            replacement: {\n                match: /(\\i)\\.\\i\\.getState\\(\\).neverShowModal/,\n                replace: \"$& || $self.shouldIgnoreDevice($1)\"\n            }\n        }\n    ],\n\n    shouldIgnoreDevice(state: any) {\n        return Object.keys(state?.default?.lastDeviceConnected ?? {})?.[0] === \"vencord-screen-share\";\n    }\n});\n"
  },
  {
    "path": "src/renderer/patches/hideVenmicInput.tsx",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { addPatch } from \"./shared\";\n\naddPatch({\n    patches: [\n        {\n            find: 'setSinkId\"in',\n            replacement: {\n                match: /return (\\i)\\?navigator\\.mediaDevices\\.enumerateDevices/,\n                replace: \"return $1 ? $self.filteredDevices\"\n            }\n        }\n    ],\n\n    async filteredDevices() {\n        const original = await navigator.mediaDevices.enumerateDevices();\n        return original.filter(x => x.label !== \"vencord-screen-share\");\n    }\n});\n"
  },
  {
    "path": "src/renderer/patches/platformClass.tsx",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { Settings } from \"renderer/settings\";\nimport { isMac } from \"renderer/utils\";\n\nimport { addPatch } from \"./shared\";\n\naddPatch({\n    patches: [\n        {\n            find: \"platform-web\",\n            replacement: {\n                match: '\"platform-web\"',\n                replace: \"$self.getPlatformClass()\"\n            }\n        }\n    ],\n\n    getPlatformClass() {\n        if (Settings.store.customTitleBar) return \"platform-win\";\n        if (isMac) return \"platform-osx\";\n        return \"platform-web\";\n    }\n});\n"
  },
  {
    "path": "src/renderer/patches/screenShareFixes.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { Logger } from \"@vencord/types/utils\";\nimport { currentSettings } from \"renderer/components/ScreenSharePicker\";\nimport { State } from \"renderer/settings\";\nimport { isLinux } from \"renderer/utils\";\n\nconst logger = new Logger(\"VesktopStreamFixes\");\n\nif (isLinux) {\n    const original = navigator.mediaDevices.getDisplayMedia;\n\n    async function getVirtmic() {\n        try {\n            const devices = await navigator.mediaDevices.enumerateDevices();\n            const audioDevice = devices.find(({ label }) => label === \"vencord-screen-share\");\n            return audioDevice?.deviceId;\n        } catch (error) {\n            return null;\n        }\n    }\n\n    navigator.mediaDevices.getDisplayMedia = async function (opts) {\n        const stream = await original.call(this, opts);\n        const id = await getVirtmic();\n\n        const frameRate = Number(State.store.screenshareQuality?.frameRate ?? 30);\n        const height = Number(State.store.screenshareQuality?.resolution ?? 720);\n        const width = Math.round(height * (16 / 9));\n        const track = stream.getVideoTracks()[0];\n\n        track.contentHint = String(currentSettings?.contentHint);\n\n        const constraints = {\n            ...track.getConstraints(),\n            frameRate: { min: frameRate, ideal: frameRate },\n            width: { min: 640, ideal: width, max: width },\n            height: { min: 480, ideal: height, max: height },\n            advanced: [{ width: width, height: height }],\n            resizeMode: \"none\"\n        };\n\n        track\n            .applyConstraints(constraints)\n            .then(() => {\n                logger.info(\"Applied constraints successfully. New constraints: \", track.getConstraints());\n            })\n            .catch(e => logger.error(\"Failed to apply constraints.\", e));\n\n        if (id) {\n            const audio = await navigator.mediaDevices.getUserMedia({\n                audio: {\n                    deviceId: {\n                        exact: id\n                    },\n                    autoGainControl: false,\n                    echoCancellation: false,\n                    noiseSuppression: false,\n                    channelCount: 2,\n                    sampleRate: 48000,\n                    sampleSize: 16\n                }\n            });\n\n            stream.getAudioTracks().forEach(t => stream.removeTrack(t));\n            stream.addTrack(audio.getAudioTracks()[0]);\n        }\n\n        return stream;\n    };\n}\n"
  },
  {
    "path": "src/renderer/patches/shared.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { Patch } from \"@vencord/types/utils/types\";\n\nwindow.VesktopPatchGlobals = {};\n\ninterface PatchData {\n    patches: Omit<Patch, \"plugin\">[];\n    [key: string]: any;\n}\n\nexport function addPatch<P extends PatchData>(p: P) {\n    const { patches, ...globals } = p;\n\n    for (const patch of patches) {\n        Vencord.Plugins.addPatch(patch, \"Vesktop\", \"VesktopPatchGlobals\");\n    }\n\n    Object.assign(VesktopPatchGlobals, globals);\n}\n"
  },
  {
    "path": "src/renderer/patches/spellCheck.tsx",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { addContextMenuPatch } from \"@vencord/types/api/ContextMenu\";\nimport { FluxDispatcher, Menu, SpellCheckStore, useMemo, useStateFromStores } from \"@vencord/types/webpack/common\";\nimport { useSettings } from \"renderer/settings\";\n\nimport { addPatch } from \"./shared\";\n\nlet word: string;\nlet corrections: string[];\n\n// Make spellcheck suggestions work\naddPatch({\n    patches: [\n        {\n            find: \".enableSpellCheck\",\n            replacement: {\n                // if (settings?.enableSpellCheck && isDesktop) { DiscordNative.onSpellcheck(openMenu(props)) } else { e.preventDefault(); openMenu(props) }\n                match: /else (\\i)\\.preventDefault\\(\\),(\\i\\(\\i\\))(?<=(\\i)\\??\\.enableSpellCheck.+?)/,\n                replace: \"else $self.onSlateContext($1, $3?.enableSpellCheck, () => $2)\"\n            }\n        }\n    ],\n\n    onSlateContext(e: MouseEvent, hasSpellcheck: boolean | undefined, openMenu: () => void) {\n        if (!hasSpellcheck) {\n            e.preventDefault();\n            openMenu();\n            return;\n        }\n\n        const cb = (w: string, c: string[]) => {\n            VesktopNative.spellcheck.offSpellcheckResult(cb);\n            word = w;\n            corrections = c;\n            openMenu();\n        };\n        VesktopNative.spellcheck.onSpellcheckResult(cb);\n    }\n});\n\naddContextMenuPatch(\"textarea-context\", children => {\n    const spellCheckEnabled = useStateFromStores([SpellCheckStore], () => SpellCheckStore.isEnabled());\n    const hasCorrections = Boolean(word && corrections?.length);\n\n    const availableLanguages = useMemo(VesktopNative.spellcheck.getAvailableLanguages, []);\n\n    const settings = useSettings();\n    const spellCheckLanguages = (settings.spellCheckLanguages ??= [...new Set(navigator.languages)]);\n\n    const pasteSectionIndex = children.findIndex(c => c?.props?.children?.some?.(c => c?.props?.id === \"paste\"));\n\n    children.splice(\n        pasteSectionIndex === -1 ? children.length : pasteSectionIndex,\n        0,\n        <Menu.MenuGroup>\n            {hasCorrections && (\n                <>\n                    {corrections.map(c => (\n                        <Menu.MenuItem\n                            key={c}\n                            id={\"vcd-spellcheck-suggestion-\" + c}\n                            label={c}\n                            action={() => VesktopNative.spellcheck.replaceMisspelling(c)}\n                        />\n                    ))}\n                    <Menu.MenuSeparator />\n                    <Menu.MenuItem\n                        id=\"vcd-spellcheck-learn\"\n                        label={`Add ${word} to dictionary`}\n                        action={() => VesktopNative.spellcheck.addToDictionary(word)}\n                    />\n                </>\n            )}\n\n            <Menu.MenuItem id=\"vcd-spellcheck-settings\" label=\"Spellcheck Settings\">\n                <Menu.MenuCheckboxItem\n                    id=\"vcd-spellcheck-enabled\"\n                    label=\"Enable Spellcheck\"\n                    checked={spellCheckEnabled}\n                    action={() => {\n                        FluxDispatcher.dispatch({ type: \"SPELLCHECK_TOGGLE\" });\n                    }}\n                />\n\n                <Menu.MenuItem id=\"vcd-spellcheck-languages\" label=\"Languages\" disabled={!spellCheckEnabled}>\n                    {availableLanguages.map(lang => {\n                        const isEnabled = spellCheckLanguages.includes(lang);\n                        return (\n                            <Menu.MenuCheckboxItem\n                                key={lang}\n                                id={\"vcd-spellcheck-lang-\" + lang}\n                                label={lang}\n                                checked={isEnabled}\n                                disabled={!isEnabled && spellCheckLanguages.length >= 5}\n                                action={() => {\n                                    const newSpellCheckLanguages = spellCheckLanguages.filter(l => l !== lang);\n                                    if (newSpellCheckLanguages.length === spellCheckLanguages.length) {\n                                        newSpellCheckLanguages.push(lang);\n                                    }\n\n                                    settings.spellCheckLanguages = newSpellCheckLanguages;\n                                }}\n                            />\n                        );\n                    })}\n                </Menu.MenuItem>\n            </Menu.MenuItem>\n        </Menu.MenuGroup>\n    );\n});\n"
  },
  {
    "path": "src/renderer/patches/streamerMode.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { addPatch } from \"./shared\";\n\naddPatch({\n    patches: [\n        {\n            find: \".STREAMING_AUTO_STREAMER_MODE,\",\n            replacement: {\n                // remove if (platformEmbedded) check from streamer mode toggle\n                match: /(?<=usePredicate.{0,20}?return )\\i\\.\\i/g,\n                replace: \"true\"\n            }\n        }\n    ]\n});\n"
  },
  {
    "path": "src/renderer/patches/taskBarFlash.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vesktop contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { Settings } from \"renderer/settings\";\n\nimport { addPatch } from \"./shared\";\n\naddPatch({\n    patches: [\n        {\n            find: \".flashFrame(!0)\",\n            replacement: {\n                match: /(\\i)&&\\i\\.\\i\\.taskbarFlash&&\\i\\.\\i\\.flashFrame\\(!0\\)/,\n                replace: \"$self.flashFrame()\"\n            }\n        }\n    ],\n\n    flashFrame() {\n        if (Settings.store.enableTaskbarFlashing) {\n            VesktopNative.win.flashFrame(true);\n        }\n    }\n});\n"
  },
  {
    "path": "src/renderer/patches/windowMethods.tsx",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { addPatch } from \"./shared\";\n\naddPatch({\n    patches: [\n        {\n            find: \",setSystemTrayApplications\",\n            replacement: [\n                {\n                    match: /\\i\\.window\\.(close|minimize|maximize)/g,\n                    replace: `VesktopNative.win.$1`\n                },\n                {\n                    match: /(focus(\\(\\i\\)){).{0,150}?\\.focus\\(\\i,\\i\\)/,\n                    replace: \"$1VesktopNative.win.focus$2\"\n                },\n                {\n                    match: /,getEnableHardwareAcceleration/,\n                    replace: \"$&:VesktopNative.app.getEnableHardwareAcceleration,_oldGetEnableHardwareAcceleration\"\n                }\n            ]\n        }\n    ]\n});\n"
  },
  {
    "path": "src/renderer/patches/windowsTitleBar.tsx",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { Settings } from \"renderer/settings\";\n\nimport { addPatch } from \"./shared\";\n\nif (Settings.store.customTitleBar)\n    addPatch({\n        patches: [\n            {\n                find: \".USE_OSX_NATIVE_TRAFFIC_LIGHTS\",\n                replacement: [\n                    {\n                        match: /case \\i\\.\\i\\.WINDOWS:/,\n                        replace: 'case \"WEB\":'\n                    }\n                ]\n            },\n            // Visual Refresh\n            {\n                find: '\"refresh-title-bar-small\"',\n                replacement: [\n                    {\n                        match: /\\i===\\i\\.PlatformTypes\\.WINDOWS/g,\n                        replace: \"true\"\n                    },\n                    {\n                        match: /\\i===\\i\\.PlatformTypes\\.WEB/g,\n                        replace: \"false\"\n                    }\n                ]\n            }\n        ]\n    });\n"
  },
  {
    "path": "src/renderer/settings.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { useEffect, useReducer } from \"@vencord/types/webpack/common\";\nimport { SettingsStore } from \"shared/utils/SettingsStore\";\n\nimport { VesktopLogger } from \"./logger\";\nimport { localStorage } from \"./utils\";\n\nexport const Settings = new SettingsStore(VesktopNative.settings.get());\nSettings.addGlobalChangeListener((o, p) => VesktopNative.settings.set(o, p));\n\nexport function useSettings() {\n    const [, update] = useReducer(x => x + 1, 0);\n\n    useEffect(() => {\n        Settings.addGlobalChangeListener(update);\n\n        return () => Settings.removeGlobalChangeListener(update);\n    }, []);\n\n    return Settings.store;\n}\n\nexport function getValueAndOnChange(key: keyof typeof Settings.store) {\n    return {\n        value: Settings.store[key] as any,\n        onChange: (value: any) => (Settings.store[key] = value)\n    };\n}\n\ninterface TState {\n    screenshareQuality?: {\n        resolution: string;\n        frameRate: string;\n    };\n}\n\nconst stateKey = \"VesktopState\";\n\nconst currentState: TState = (() => {\n    const stored = localStorage.getItem(stateKey);\n    if (!stored) return {};\n    try {\n        return JSON.parse(stored);\n    } catch (e) {\n        VesktopLogger.error(\"Failed to parse stored state\", e);\n        return {};\n    }\n})();\n\nexport const State = new SettingsStore<TState>(currentState);\nState.addGlobalChangeListener((o, p) => localStorage.setItem(stateKey, JSON.stringify(o)));\n\nexport function useVesktopState() {\n    const [, update] = useReducer(x => x + 1, 0);\n\n    useEffect(() => {\n        State.addGlobalChangeListener(update);\n\n        return () => State.removeGlobalChangeListener(update);\n    }, []);\n\n    return State.store;\n}\n"
  },
  {
    "path": "src/renderer/themedSplash.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { Settings } from \"./settings\";\n\nfunction isValidColor(color: CSSStyleValue | undefined): color is CSSUnparsedValue & { [0]: string } {\n    return color instanceof CSSUnparsedValue && typeof color[0] === \"string\" && CSS.supports(\"color\", color[0]);\n}\n\n// https://gist.github.com/earthbound19/e7fe15fdf8ca3ef814750a61bc75b5ce\nfunction clamp(value: number, min: number, max: number) {\n    return Math.max(Math.min(value, max), min);\n}\nconst linearToGamma = (c: number) => (c >= 0.0031308 ? 1.055 * Math.pow(c, 1 / 2.4) - 0.055 : 12.92 * c);\n\nfunction oklabToSRGB({ L, a, b }: { L: number; a: number; b: number }) {\n    let l = L + a * +0.3963377774 + b * +0.2158037573;\n    let m = L + a * -0.1055613458 + b * -0.0638541728;\n    let s = L + a * -0.0894841775 + b * -1.291485548;\n    l **= 3;\n    m **= 3;\n    s **= 3;\n    let R = l * +4.0767416621 + m * -3.3077115913 + s * +0.2309699292;\n    let G = l * -1.2684380046 + m * +2.6097574011 + s * -0.3413193965;\n    let B = l * -0.0041960863 + m * -0.7034186147 + s * +1.707614701;\n    R = 255 * linearToGamma(R);\n    G = 255 * linearToGamma(G);\n    B = 255 * linearToGamma(B);\n    R = Math.round(clamp(R, 0, 255));\n    G = Math.round(clamp(G, 0, 255));\n    B = Math.round(clamp(B, 0, 255));\n\n    return `rgb(${R}, ${G}, ${B})`;\n}\n\nfunction resolveColor(color: string) {\n    const span = document.createElement(\"span\");\n    span.style.color = color;\n    span.style.display = \"none\";\n\n    document.body.append(span);\n    let rgbColor = getComputedStyle(span).color;\n    span.remove();\n\n    if (rgbColor.startsWith(\"oklab(\")) {\n        // scam\n        const [_, L, a, b] = rgbColor.match(/oklab\\((.+?)[, ]+(.+?)[, ]+(.+?)\\)/) ?? [];\n        if (L && a && b) {\n            rgbColor = oklabToSRGB({ L: parseFloat(L), a: parseFloat(a), b: parseFloat(b) });\n        }\n    }\n\n    return rgbColor;\n}\n\nconst updateSplashColors = () => {\n    const bodyStyles = document.body.computedStyleMap();\n\n    const color = bodyStyles.get(\"--text-default\");\n    const backgroundColor = bodyStyles.get(\"--background-base-lowest\");\n\n    if (isValidColor(color)) {\n        Settings.store.splashColor = resolveColor(color[0]);\n    }\n\n    if (isValidColor(backgroundColor)) {\n        Settings.store.splashBackground = resolveColor(backgroundColor[0]);\n    }\n};\n\nif (document.readyState === \"complete\") {\n    updateSplashColors();\n} else {\n    window.addEventListener(\"load\", updateSplashColors);\n}\n\nwindow.addEventListener(\"beforeunload\", updateSplashColors);\n"
  },
  {
    "path": "src/renderer/utils.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\n// Discord deletes this from the window so we need to capture it in a variable\nexport const { localStorage } = window;\n\nexport const isFirstRun = (() => {\n    const key = \"VCD_FIRST_RUN\";\n    if (localStorage.getItem(key) !== null) return false;\n    localStorage.setItem(key, \"false\");\n    return true;\n})();\n\nconst { platform } = navigator;\n\nexport const isWindows = platform.startsWith(\"Win\");\nexport const isMac = platform.startsWith(\"Mac\");\nexport const isLinux = platform.startsWith(\"Linux\");\n"
  },
  {
    "path": "src/shared/IpcEvents.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nexport const enum IpcEvents {\n    GET_VENCORD_PRELOAD_SCRIPT = \"VCD_GET_VC_PRELOAD_SCRIPT\",\n    DEPRECATED_GET_VENCORD_PRELOAD_SCRIPT_PATH = \"DEPRECATED_GET_VENCORD_PRELOAD_SCRIPT_PATH\",\n    GET_VENCORD_RENDERER_SCRIPT = \"VCD_GET_VC_RENDERER_SCRIPT\",\n\n    GET_VESKTOP_RENDERER_SCRIPT = \"VCD_GET_RENDERER_SCRIPT\",\n    GET_VESKTOP_RENDERER_CSS = \"VCD_GET_RENDERER_CSS\",\n    VESKTOP_RENDERER_CSS_UPDATE = \"VCD_PRELOAD_RENDERER_CSS_UPDATE\",\n\n    GET_VERSION = \"VCD_GET_VERSION\",\n    SUPPORTS_WINDOWS_TRANSPARENCY = \"VCD_SUPPORTS_WINDOWS_TRANSPARENCY\",\n    GET_ENABLE_HARDWARE_ACCELERATION = \"VCD_GET_ENABLE_HARDWARE_ACCELERATION\",\n\n    RELAUNCH = \"VCD_RELAUNCH\",\n    CLOSE = \"VCD_CLOSE\",\n    FOCUS = \"VCD_FOCUS\",\n    MINIMIZE = \"VCD_MINIMIZE\",\n    MAXIMIZE = \"VCD_MAXIMIZE\",\n\n    GET_SETTINGS = \"VCD_GET_SETTINGS\",\n    SET_SETTINGS = \"VCD_SET_SETTINGS\",\n\n    IS_USING_CUSTOM_VENCORD_DIR = \"VCD_IS_USING_CUSTOM_VENCORD_DIR\",\n    SHOW_CUSTOM_VENCORD_DIR = \"VCD_SHOW_CUSTOM_VENCORD_DIR\",\n    SELECT_VENCORD_DIR = \"VCD_SELECT_VENCORD_DIR\",\n\n    UPDATER_IS_OUTDATED = \"VCD_UPDATER_IS_OUTDATED\",\n    UPDATER_OPEN = \"VCD_UPDATER_OPEN\",\n\n    SPELLCHECK_GET_AVAILABLE_LANGUAGES = \"VCD_SPELLCHECK_GET_AVAILABLE_LANGUAGES\",\n    SPELLCHECK_RESULT = \"VCD_SPELLCHECK_RESULT\",\n    SPELLCHECK_REPLACE_MISSPELLING = \"VCD_SPELLCHECK_REPLACE_MISSPELLING\",\n    SPELLCHECK_ADD_TO_DICTIONARY = \"VCD_SPELLCHECK_ADD_TO_DICTIONARY\",\n\n    SET_BADGE_COUNT = \"VCD_SET_BADGE_COUNT\",\n    FLASH_FRAME = \"FLASH_FRAME\",\n\n    CAPTURER_GET_LARGE_THUMBNAIL = \"VCD_CAPTURER_GET_LARGE_THUMBNAIL\",\n\n    AUTOSTART_ENABLED = \"VCD_AUTOSTART_ENABLED\",\n    ENABLE_AUTOSTART = \"VCD_ENABLE_AUTOSTART\",\n    DISABLE_AUTOSTART = \"VCD_DISABLE_AUTOSTART\",\n\n    VIRT_MIC_LIST = \"VCD_VIRT_MIC_LIST\",\n    VIRT_MIC_START = \"VCD_VIRT_MIC_START\",\n    VIRT_MIC_START_SYSTEM = \"VCD_VIRT_MIC_START_ALL\",\n    VIRT_MIC_STOP = \"VCD_VIRT_MIC_STOP\",\n\n    CLIPBOARD_COPY_IMAGE = \"VCD_CLIPBOARD_COPY_IMAGE\",\n\n    DEBUG_LAUNCH_GPU = \"VCD_DEBUG_LAUNCH_GPU\",\n    DEBUG_LAUNCH_WEBRTC_INTERNALS = \"VCD_DEBUG_LAUNCH_WEBRTC\",\n\n    IPC_COMMAND = \"VCD_IPC_COMMAND\",\n\n    DEVTOOLS_OPENED = \"VCD_DEVTOOLS_OPENED\",\n    DEVTOOLS_CLOSED = \"VCD_DEVTOOLS_CLOSED\",\n\n    CHOOSE_USER_ASSET = \"VCD_CHOOSE_USER_ASSET\"\n}\n\nexport const enum UpdaterIpcEvents {\n    GET_DATA = \"VCD_UPDATER_GET_DATA\",\n    INSTALL = \"VCD_UPDATER_INSTALL\",\n    DOWNLOAD_PROGRESS = \"VCD_UPDATER_DOWNLOAD_PROGRESS\",\n    ERROR = \"VCD_UPDATER_ERROR\",\n    SNOOZE_UPDATE = \"VCD_UPDATER_SNOOZE_UPDATE\",\n    IGNORE_UPDATE = \"VCD_UPDATER_IGNORE_UPDATE\"\n}\n\nexport const enum IpcCommands {\n    RPC_ACTIVITY = \"rpc:activity\",\n    RPC_INVITE = \"rpc:invite\",\n    RPC_DEEP_LINK = \"rpc:link\",\n\n    NAVIGATE_SETTINGS = \"navigate:settings\",\n\n    GET_LANGUAGES = \"navigator.languages\",\n\n    SCREEN_SHARE_PICKER = \"screenshare:picker\"\n}\n"
  },
  {
    "path": "src/shared/browserWinProperties.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport type { BrowserWindowConstructorOptions } from \"electron\";\n\nexport const SplashProps: BrowserWindowConstructorOptions = {\n    transparent: true,\n    frame: false,\n    height: 350,\n    width: 300,\n    center: true,\n    resizable: false,\n    maximizable: false,\n    alwaysOnTop: true\n};\n"
  },
  {
    "path": "src/shared/paths.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { join } from \"path\";\n\nexport const STATIC_DIR = /* @__PURE__ */ join(__dirname, \"..\", \"..\", \"static\");\nexport const BADGE_DIR = /* @__PURE__ */ join(STATIC_DIR, \"badges\");\n"
  },
  {
    "path": "src/shared/settings.d.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport type { Rectangle } from \"electron\";\n\nexport interface Settings {\n    discordBranch?: \"stable\" | \"canary\" | \"ptb\";\n    transparencyOption?: \"none\" | \"mica\" | \"tabbed\" | \"acrylic\";\n    tray?: boolean;\n    minimizeToTray?: boolean;\n    autoStartMinimized?: boolean;\n    openLinksWithElectron?: boolean;\n    staticTitle?: boolean;\n    enableMenu?: boolean;\n    disableSmoothScroll?: boolean;\n    hardwareAcceleration?: boolean;\n    hardwareVideoAcceleration?: boolean;\n    arRPC?: boolean;\n    appBadge?: boolean;\n    enableTaskbarFlashing?: boolean;\n    disableMinSize?: boolean;\n    clickTrayToShowHide?: boolean;\n    customTitleBar?: boolean;\n\n    enableSplashScreen?: boolean;\n    splashTheming?: boolean;\n    splashColor?: string;\n    splashBackground?: string;\n    splashPixelated?: boolean;\n\n    spellCheckLanguages?: string[];\n\n    audio?: {\n        workaround?: boolean;\n\n        deviceSelect?: boolean;\n        granularSelect?: boolean;\n\n        ignoreVirtual?: boolean;\n        ignoreDevices?: boolean;\n        ignoreInputMedia?: boolean;\n\n        onlySpeakers?: boolean;\n        onlyDefaultSpeakers?: boolean;\n    };\n}\n\nexport interface State {\n    maximized?: boolean;\n    minimized?: boolean;\n    windowBounds?: Rectangle;\n\n    firstLaunch?: boolean;\n\n    steamOSLayoutVersion?: number;\n    linuxAutoStartEnabled?: boolean;\n\n    vencordDir?: string;\n\n    updater?: {\n        ignoredVersion?: string;\n        snoozeUntil?: number;\n    };\n}\n"
  },
  {
    "path": "src/shared/utils/SettingsStore.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nimport { LiteralUnion } from \"type-fest\";\n\n// Resolves a possibly nested prop in the form of \"some.nested.prop\" to type of T.some.nested.prop\ntype ResolvePropDeep<T, P> = P extends `${infer Pre}.${infer Suf}`\n    ? Pre extends keyof T\n        ? ResolvePropDeep<T[Pre], Suf>\n        : any\n    : P extends keyof T\n      ? T[P]\n      : any;\n\n/**\n * The SettingsStore allows you to easily create a mutable store that\n * has support for global and path-based change listeners.\n */\nexport class SettingsStore<T extends object> {\n    private pathListeners = new Map<string, Set<(newData: any) => void>>();\n    private globalListeners = new Set<(newData: T, path: string) => void>();\n\n    /**\n     * The store object. Making changes to this object will trigger the applicable change listeners\n     */\n    declare public store: T;\n    /**\n     * The plain data. Changes to this object will not trigger any change listeners\n     */\n    declare public plain: T;\n\n    public constructor(plain: T) {\n        this.plain = plain;\n        this.store = this.makeProxy(plain);\n    }\n\n    private makeProxy(object: any, root: T = object, path: string = \"\") {\n        const self = this;\n\n        return new Proxy(object, {\n            get(target, key: string) {\n                const v = target[key];\n\n                if (typeof v === \"object\" && v !== null && !Array.isArray(v))\n                    return self.makeProxy(v, root, `${path}${path && \".\"}${key}`);\n\n                return v;\n            },\n            set(target, key: string, value) {\n                if (target[key] === value) return true;\n\n                Reflect.set(target, key, value);\n                const setPath = `${path}${path && \".\"}${key}`;\n\n                self.globalListeners.forEach(cb => cb(root, setPath));\n                self.pathListeners.get(setPath)?.forEach(cb => cb(value));\n\n                return true;\n            },\n            deleteProperty(target, key: string) {\n                if (!(key in target)) return true;\n\n                const res = Reflect.deleteProperty(target, key);\n                if (!res) return false;\n\n                const setPath = `${path}${path && \".\"}${key}`;\n\n                self.globalListeners.forEach(cb => cb(root, setPath));\n                self.pathListeners.get(setPath)?.forEach(cb => cb(undefined));\n\n                return res;\n            }\n        });\n    }\n\n    /**\n     * Set the data of the store.\n     * This will update this.store and this.plain (and old references to them will be stale! Avoid storing them in variables)\n     *\n     * Additionally, all global listeners (and those for pathToNotify, if specified) will be called with the new data\n     * @param value New data\n     * @param pathToNotify Optional path to notify instead of globally. Used to transfer path via ipc\n     */\n    public setData(value: T, pathToNotify?: string) {\n        this.plain = value;\n        this.store = this.makeProxy(value);\n\n        if (pathToNotify) {\n            let v = value;\n\n            const path = pathToNotify.split(\".\");\n            for (const p of path) {\n                if (!v) {\n                    console.warn(\n                        `Settings#setData: Path ${pathToNotify} does not exist in new data. Not dispatching update`\n                    );\n                    return;\n                }\n                v = v[p];\n            }\n\n            this.pathListeners.get(pathToNotify)?.forEach(cb => cb(v));\n        }\n\n        this.globalListeners.forEach(cb => cb(value, \"\"));\n    }\n\n    /**\n     * Add a global change listener, that will fire whenever any setting is changed\n     */\n    public addGlobalChangeListener(cb: (data: T, path: string) => void) {\n        this.globalListeners.add(cb);\n    }\n\n    /**\n     * Add a scoped change listener that will fire whenever a setting matching the specified path is changed.\n     *\n     * For example if path is `\"foo.bar\"`, the listener will fire on\n     * ```js\n     * Setting.store.foo.bar = \"hi\"\n     * ```\n     * but not on\n     * ```js\n     * Setting.store.foo.baz = \"hi\"\n     * ```\n     * @param path\n     * @param cb\n     */\n    public addChangeListener<P extends LiteralUnion<keyof T, string>>(\n        path: P,\n        cb: (data: ResolvePropDeep<T, P>) => void\n    ) {\n        const listeners = this.pathListeners.get(path as string) ?? new Set();\n        listeners.add(cb);\n        this.pathListeners.set(path as string, listeners);\n    }\n\n    /**\n     * Remove a global listener\n     * @see {@link addGlobalChangeListener}\n     */\n    public removeGlobalChangeListener(cb: (data: T, path: string) => void) {\n        this.globalListeners.delete(cb);\n    }\n\n    /**\n     * Remove a scoped listener\n     * @see {@link addChangeListener}\n     */\n    public removeChangeListener(path: LiteralUnion<keyof T, string>, cb: (data: any) => void) {\n        const listeners = this.pathListeners.get(path as string);\n        if (!listeners) return;\n\n        listeners.delete(cb);\n        if (!listeners.size) this.pathListeners.delete(path as string);\n    }\n\n    /**\n     * Call all global change listeners\n     */\n    public markAsChanged() {\n        this.globalListeners.forEach(cb => cb(this.plain, \"\"));\n    }\n}\n"
  },
  {
    "path": "src/shared/utils/debounce.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\n/**\n * Returns a new function that will only be called after the given delay.\n * Subsequent calls will cancel the previous timeout and start a new one from 0\n *\n * Useful for grouping multiple calls into one\n */\nexport function debounce<T extends Function>(func: T, delay = 300): T {\n    let timeout: NodeJS.Timeout;\n    return function (...args: any[]) {\n        clearTimeout(timeout);\n        timeout = setTimeout(() => {\n            func(...args);\n        }, delay);\n    } as any;\n}\n"
  },
  {
    "path": "src/shared/utils/guards.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nexport function isTruthy<T>(item: T): item is Exclude<T, 0 | \"\" | false | null | undefined> {\n    return Boolean(item);\n}\n\nexport function isNonNullish<T>(item: T): item is Exclude<T, null | undefined> {\n    return item != null;\n}\n"
  },
  {
    "path": "src/shared/utils/millis.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vesktop contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nexport const enum Millis {\n    SECOND = 1000,\n    MINUTE = 60 * SECOND,\n    HOUR = 60 * MINUTE,\n    DAY = 24 * HOUR\n}\n"
  },
  {
    "path": "src/shared/utils/once.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\n/**\n * Wraps the given function so that it can only be called once\n * @param fn Function to wrap\n * @returns New function that can only be called once\n */\nexport function once<T extends Function>(fn: T): T {\n    let called = false;\n    return function (this: any, ...args: any[]) {\n        if (called) return;\n        called = true;\n        return fn.apply(this, args);\n    } as any;\n}\n"
  },
  {
    "path": "src/shared/utils/sleep.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2023 Vendicated and Vencord contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nexport function sleep(ms: number): Promise<void> {\n    return new Promise(r => setTimeout(r, ms));\n}\n"
  },
  {
    "path": "src/shared/utils/text.ts",
    "content": "/*\n * Vesktop, a desktop app aiming to give you a snappier Discord Experience\n * Copyright (c) 2025 Vendicated and Vesktop contributors\n * SPDX-License-Identifier: GPL-3.0-or-later\n */\n\nexport function stripIndent(strings: TemplateStringsArray, ...values: any[]) {\n    const string = String.raw({ raw: strings }, ...values);\n\n    const match = string.match(/^[ \\t]*(?=\\S)/gm);\n    if (!match) return string.trim();\n\n    const minIndent = match.reduce((r, a) => Math.min(r, a.length), Infinity);\n    return string.replace(new RegExp(`^[ \\\\t]{${minIndent}}`, \"gm\"), \"\").trim();\n}\n"
  },
  {
    "path": "static/views/about.html",
    "content": "<!doctype html>\n<meta charset=\"utf-8\" />\n\n<head>\n    <title>About Vesktop</title>\n\n    <link rel=\"stylesheet\" href=\"./common.css\" type=\"text/css\" />\n\n    <style>\n        body {\n            padding: 2em;\n        }\n\n        h1 {\n            text-align: center;\n        }\n\n        ul {\n            display: flex;\n            flex-direction: column;\n            gap: 0.5em;\n        }\n    </style>\n</head>\n\n<body>\n    <h1 id=\"title\">Vesktop v{{APP_VERSION}}</h1>\n    <p>Vesktop is a cross platform Discord Desktop client, aiming to give you a better Discord experience</p>\n\n    <section>\n        <h2>Links</h2>\n        <ul>\n            <li>\n                <a href=\"https://vesktop.dev\" target=\"_blank\">Vesktop Website</a>\n            </li>\n            <li>\n                <a href=\"https://vesktop.dev/wiki\" target=\"_blank\">Vesktop Wiki</a>\n            </li>\n            <li>\n                <a href=\"https://github.com/Vencord/Vesktop\" target=\"_blank\">Source Code</a>\n            </li>\n            <li>\n                <a href=\"https://github.com/Vencord/Vesktop/issues\" target=\"_blank\">Report bugs / Request features</a>\n            </li>\n        </ul>\n    </section>\n\n    <section>\n        <h2>License</h2>\n        <p>\n            Vesktop is licensed under the\n            <a href=\"https://www.gnu.org/licenses/gpl-3.0.txt\" target=\"_blank\">GNU General Public License v3.0</a>.\n            <br />\n            This is free software, and you are welcome to redistribute it under certain conditions; see the license for\n            details.\n        </p>\n    </section>\n\n    <section>\n        <h2>Acknowledgements</h2>\n        <p>These awesome libraries empower Vesktop</p>\n        <ul>\n            <li>\n                <a href=\"https://github.com/electron/electron\" target=\"_blank\">Electron</a>\n                - Build cross-platform desktop apps with JavaScript, HTML, and CSS\n            </li>\n            <li>\n                <a href=\"https://github.com/electron-userland/electron-builder\" target=\"_blank\">Electron Builder</a>\n                - A complete solution to package and build a ready for distribution Electron app with \"auto update\"\n                support out of the box\n            </li>\n            <li>\n                <a href=\"https://github.com/OpenAsar/arrpc\" target=\"_blank\">arrpc</a>\n                - An open implementation of Discord's Rich Presence server\n            </li>\n            <li>\n                <a href=\"https://github.com/Soundux/rohrkabel\" target=\"_blank\">rohrkabel</a>\n                - A C++ RAII Pipewire-API Wrapper\n            </li>\n            <li>\n                And many\n                <a href=\"https://github.com/Vencord/Vesktop/blob/main/pnpm-lock.yaml\" target=\"_blank\">more open source\n                    libraries</a>\n            </li>\n        </ul>\n    </section>\n</body>\n\n<script>\n    const data = new URLSearchParams(location.search);\n\n    // replace all {{FOO}} placeholders in the document with the values from the URL\n\n    /** @param {Node} [node] */\n    function walk(node) {\n        if (node.nodeType === Node.TEXT_NODE) {\n            node.textContent = node.textContent.replace(/{{(\\w+)}}/g, (match, key) => data.get(key) || match);\n            return;\n        }\n\n        if (node.nodeType === Node.ELEMENT_NODE && node.nodeName !== \"SCRIPT\") {\n            for (const child of node.childNodes) {\n                walk(child);\n            }\n        }\n    }\n\n    walk(document.body);\n</script>"
  },
  {
    "path": "static/views/common.css",
    "content": ":root {\n    color-scheme: light dark;\n\n    --bg: light-dark(white, hsl(223 6.7% 20.6%));\n    --fg: light-dark(black, white);\n    --fg-secondary: light-dark(#313338, #b5bac1);\n    --fg-semi-trans: light-dark(rgb(0 0 0 / 0.2), rgb(255 255 255 / 0.2));\n    --link: light-dark(#006ce7, #00a8fc);\n    --link-hover: light-dark(#005bb5, #0086c3);\n}\n\nhtml,\nbody {\n    margin: 0;\n    padding: 0;\n}\n\nbody {\n    font-family: system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen, Ubuntu, Cantarell,\n        \"Open Sans\", \"Helvetica Neue\", sans-serif;\n    background: var(--bg);\n    color: var(--fg);\n}\n\na {\n    color: var(--link);\n    transition: color 0.2s linear;\n}\n\na:hover {\n    color: var(--link-hover);\n}"
  },
  {
    "path": "static/views/first-launch.html",
    "content": "<!doctype html>\n<meta charset=\"utf-8\" />\n\n<head>\n    <title>Vesktop Setup</title>\n\n    <link rel=\"stylesheet\" href=\"./common.css\" type=\"text/css\" />\n\n    <style>\n        body {\n            height: 100vh;\n\n            padding: 1.5em;\n            padding-bottom: 1em;\n\n            border: 1px solid var(--fg-semi-trans);\n            border-top: none;\n            display: flex;\n            flex-direction: column;\n            box-sizing: border-box;\n        }\n\n        select {\n            background: var(--bg);\n            color: var(--fg);\n            padding: 0.3em;\n            margin: -0.3em;\n            border-radius: 6px;\n        }\n\n        h1 {\n            margin: 0.4em 0 0;\n        }\n\n        p {\n            margin: 1em 0 2em;\n        }\n\n        form {\n            display: grid;\n            gap: 1em;\n            margin: 0;\n        }\n\n        label {\n            position: relative;\n            display: flex;\n            justify-content: space-between;\n        }\n\n        label:has(input[type=\"checkbox\"]),\n        select {\n            cursor: pointer;\n        }\n\n        label:not(:last-child)::after {\n            content: \"\";\n            position: absolute;\n            bottom: -10px;\n            width: 100%;\n            height: 1px;\n            background-color: var(--fg-secondary);\n            opacity: 0.5;\n        }\n\n        label div {\n            display: grid;\n            gap: 0.2em;\n        }\n\n        label h2 {\n            margin: 0;\n            font-weight: normal;\n            font-size: 1.1rem;\n            line-height: 1rem;\n        }\n\n        label span {\n            font-size: 0.9rem;\n            font-weight: 400;\n            color: var(--fg-secondary);\n        }\n\n        #buttons {\n            display: flex;\n            justify-content: end;\n            gap: 0.5em;\n            margin-top: auto;\n        }\n\n        button {\n            padding: 0.6em;\n            background: red;\n            color: white;\n            border-radius: 6px;\n            border: none;\n            cursor: pointer;\n            transition: 200ms filter;\n        }\n\n        button:hover {\n            filter: brightness(0.8);\n        }\n\n        #submit {\n            background: green;\n        }\n    </style>\n</head>\n\n<body>\n    <h1>Welcome to Vesktop</h1>\n    <p>Let's customise your experience!</p>\n\n    <form>\n        <label>\n            <h2>Discord Branch</h2>\n            <select name=\"discordBranch\">\n                <option value=\"stable\">stable</option>\n                <option value=\"canary\">canary</option>\n                <option value=\"ptb\">ptb</option>\n            </select>\n        </label>\n\n        <label>\n            <div>\n                <h2>Start with System</h2>\n                <span>Automatically open Vesktop when your computer starts</span>\n            </div>\n            <input type=\"checkbox\" name=\"autoStart\" />\n        </label>\n\n        <label>\n            <div>\n                <h2>Rich Presence</h2>\n                <span>Enable Rich presence (game activity) via\n                    <a href=\"https://github.com/OpenAsar/arrpc\" target=\"_blank\">arRPC</a></span>\n            </div>\n            <input type=\"checkbox\" name=\"richPresence\" checked />\n        </label>\n\n        <label>\n            <div>\n                <h2>Import Settings</h2>\n                <span>Import Settings from existing Vencord install (if found)</span>\n            </div>\n            <input type=\"checkbox\" name=\"importSettings\" checked />\n        </label>\n\n        <label>\n            <div>\n                <h2>Minimise to Tray</h2>\n                <span>Minimise to Tray when closing</span>\n            </div>\n            <input type=\"checkbox\" name=\"minimizeToTray\" checked />\n        </label>\n    </form>\n    <div id=\"buttons\">\n        <button id=\"cancel\">Quit</button>\n        <button id=\"submit\">Submit</button>\n    </div>\n</body>\n\n<script>\n    cancel.onclick = () => console.info(\"cancel\");\n    submit.onclick = e => {\n        const form = document.querySelector(\"form\");\n        const formData = new FormData(form);\n        const data = Object.fromEntries(formData.entries());\n        console.info(\"form:\" + JSON.stringify(data));\n        e.preventDefault();\n    };\n</script>"
  },
  {
    "path": "static/views/splash.html",
    "content": "<!doctype html>\n<meta charset=\"utf-8\" />\n\n<head>\n    <link rel=\"stylesheet\" href=\"./common.css\" type=\"text/css\" />\n\n    <style>\n        html,\n        body {\n            width: 100%;\n            height: 100%;\n        }\n\n        body {\n            background: none;\n            user-select: none;\n            -webkit-app-region: drag;\n            overflow: hidden;\n        }\n\n        .wrapper {\n            width: 100%;\n            height: 100%;\n            box-sizing: border-box;\n            display: flex;\n            flex-direction: column;\n            justify-content: center;\n            align-items: center;\n            border-radius: 8px;\n            border: 1px solid var(--fg-semi-trans);\n            background: var(--bg);\n        }\n\n        .message {\n            top: 70%;\n            word-break: break-word;\n            padding: 0 16px;\n            position: absolute;\n            font-size: 14px\n        }\n\n        p {\n            text-align: center;\n        }\n\n        img {\n            width: 128px;\n            height: 128px;\n            object-fit: contain;\n        }\n    </style>\n</head>\n\n<body>\n    <div class=\"wrapper\">\n        <img draggable=\"false\" src=\"vesktop://assets/splash\" alt=\"\" role=\"presentation\" />\n        <p>Loading Vesktop...</p>\n        <p class=\"message\"></p>\n    </div>\n</body>\n\n<script>\n    document.addEventListener(\"DOMContentLoaded\", () => {\n        const messageElement = document.querySelector('.message');\n        VesktopSplashNative.onUpdateMessage(message => {\n            messageElement.textContent = message;\n        })\n    });\n</script>"
  },
  {
    "path": "static/views/updater/index.html",
    "content": "<!doctype html>\n<meta charset=\"utf-8\" />\n\n<head>\n    <title>Vesktop Updater</title>\n    <meta http-equiv=\"Content-Security-Policy\" content=\"\n        default-src 'none';\n        script-src vesktop:;\n        style-src vesktop:;\n      \">\n\n    <link rel=\"stylesheet\" href=\"../common.css\" type=\"text/css\" />\n    <link rel=\"stylesheet\" href=\"./style.css\" type=\"text/css\" />\n</head>\n\n<body>\n    <header>\n        <h1>An update is available!</h1>\n    </header>\n\n    <main>\n        <p id=\"versions\">\n            <span class=\"label\">Current version:</span> <span id=\"current-version\" class=\"value\"></span>\n            <span class=\"label\">New version:</span> <span id=\"new-version\" class=\"value\"></span>\n        </p>\n        <h2>Release Notes</h2>\n\n        <div id=\"release-notes\"></div>\n    </main>\n\n    <footer>\n        <section id=\"buttons\">\n            <button id=\"update-button\" class=\"green\">Install update & restart</button>\n            <button id=\"later-button\" class=\"grey\">Remind me later</button>\n            <button id=\"ignore-button\" class=\"grey\">Ignore this update</button>\n        </section>\n    </footer>\n\n    <dialog id=\"update-dialog\" closedby=\"none\">\n        <h2>Downloading Update</h2>\n        <p>\n            Please wait while the update is being downloaded. Once the update finished downloading, it will\n            automatically install and Vesktop will restart.\n        </p>\n\n        <p id=\"linux-note\" class=\"hidden\">You will likely be prompted to enter your password. Do so to finish the\n            update.</p>\n\n        <progress id=\"download-progress\" value=\"0\" max=\"100\"></progress>\n\n        <p id=\"error\"></p>\n    </dialog>\n\n    <dialog id=\"installing-dialog\" closedby=\"none\">\n        <h2>Installing Update</h2>\n        <p>Please wait while the update is being installed. Vesktop will restart shortly.</p>\n\n        <div class=\"spinner-wrapper\">\n            <div class=\"spinner\"></div>\n        </div>\n    </dialog>\n</body>\n\n<script type=\"module\" src=\"./script.js\"></script>"
  },
  {
    "path": "static/views/updater/script.js",
    "content": "const { update, version: currentVersion } = await VesktopUpdaterNative.getData();\n\ndocument.getElementById(\"current-version\").textContent = currentVersion;\ndocument.getElementById(\"new-version\").textContent = update.version;\ndocument.getElementById(\"release-notes\").innerHTML = update.releaseNotes\n    .map(\n        ({ version, note: html }) => `\n            <section>\n                <h3>Version ${version}</h3>\n                <div>${html.replace(/<\\/?h([1-3])/g, (m, level) => m.replace(level, Number(level) + 3))}</div>\n            </section>\n        `\n    )\n    .join(\"\\n\");\n\ndocument.querySelectorAll(\"a\").forEach(a => {\n    a.target = \"_blank\";\n});\n\n// remove useless headings\ndocument.querySelectorAll(\"h3, h4, h5, h6\").forEach(h => {\n    if (h.textContent.trim().toLowerCase() === \"what's changed\") {\n        h.remove();\n    }\n});\n\n/** @type {HTMLDialogElement} */\nconst updateDialog = document.getElementById(\"update-dialog\");\n/** @type {HTMLDialogElement} */\nconst installingDialog = document.getElementById(\"installing-dialog\");\n/** @type {HTMLProgressElement} */\nconst downloadProgress = document.getElementById(\"download-progress\");\n/** @type {HTMLElement} */\nconst errorText = document.getElementById(\"error\");\n\ndocument.getElementById(\"update-button\").addEventListener(\"click\", () => {\n    downloadProgress.value = 0;\n    errorText.textContent = \"\";\n\n    if (navigator.platform.startsWith(\"Linux\")) {\n        document.getElementById(\"linux-note\").classList.remove(\"hidden\");\n    }\n\n    updateDialog.showModal();\n\n    VesktopUpdaterNative.installUpdate().then(() => {\n        downloadProgress.value = 100;\n        updateDialog.closedBy = \"any\";\n\n        installingDialog.showModal();\n        updateDialog.classList.add(\"hidden\");\n    });\n});\n\ndocument.getElementById(\"later-button\").addEventListener(\"click\", () => VesktopUpdaterNative.snoozeUpdate());\ndocument.getElementById(\"ignore-button\").addEventListener(\"click\", () => {\n    const confirmed = confirm(\n        \"Are you sure you want to ignore this update? You will not be notified about this update again. Updates are important for security and stability.\"\n    );\n    if (confirmed) VesktopUpdaterNative.ignoreUpdate();\n});\n\nVesktopUpdaterNative.onProgress(percent => (downloadProgress.value = percent));\nVesktopUpdaterNative.onError(message => {\n    updateDialog.closedBy = \"any\";\n    errorText.textContent = `An error occurred while downloading the update: ${message}`;\n    installingDialog.close();\n    updateDialog.classList.remove(\"hidden\");\n});\n"
  },
  {
    "path": "static/views/updater/style.css",
    "content": "html,\nbody {\n    height: 100%;\n    margin: 0;\n    box-sizing: border-box;\n}\n\nbody {\n    padding: 2em;\n    display: flex;\n    flex-direction: column;\n    height: 100vh;\n\n    header,\n    footer {\n        flex: 0 0 auto;\n    }\n\n    main {\n        flex: 1 1 0%;\n        min-height: 0;\n        overflow: auto;\n    }\n\n    footer {\n        margin-top: 1em;\n    }\n}\n\n\n#versions {\n    display: inline-grid;\n    grid-template-columns: auto 1fr;\n    column-gap: 0.5em;\n\n    .label {\n        white-space: nowrap;\n    }\n\n    .value {\n        text-align: left;\n    }\n\n    #current-version {\n        color: #fc8f8a;\n    }\n\n    #new-version {\n        color: #71c07f;\n    }\n}\n\n#release-notes {\n    display: grid;\n    gap: 1em;\n}\n\n#buttons {\n    display: flex;\n    gap: 0.5em;\n    justify-content: end;\n}\n\nbutton {\n    cursor: pointer;\n    padding: 0.5rem 1rem;\n    font-size: 1.2em;\n    color: var(--fg);\n    border: none;\n    border-radius: 3px;\n    font-weight: bold;\n    transition: filter 0.2 ease-in-out;\n}\n\nbutton:hover,\nbutton:active {\n    filter: brightness(0.9);\n}\n\n.green {\n    background-color: #248046;\n}\n\n.grey {\n    background-color: rgba(151, 151, 159, 0.12);\n}\n\n.hidden {\n    display: none;\n}\n\nh1,\nh2,\nh3,\nh4,\nh5,\nh6 {\n    margin: 0 0 0.5em 0;\n}\n\nh1 {\n    text-align: center;\n}\n\nh2 {\n    margin-bottom: 1em;\n}\n\ndialog {\n    width: 80%;\n    padding: 2em;\n}\n\nprogress {\n    width: 100%;\n    height: 1.5em;\n    margin-top: 1em;\n}\n\n#error {\n    color: red;\n    font-weight: bold;\n}\n\n.spinner-wrapper {\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    margin-top: 2em;\n}\n\n.spinner {\n    width: 48px;\n    height: 48px;\n    border: 5px solid var(--fg);\n    border-bottom-color: transparent;\n    border-radius: 50%;\n    display: inline-block;\n    box-sizing: border-box;\n    animation: rotation 1s linear infinite;\n}\n\n@keyframes rotation {\n    to {\n        transform: rotate(360deg);\n    }\n}"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n    \"compilerOptions\": {\n        \"allowSyntheticDefaultImports\": true,\n        \"esModuleInterop\": true,\n        \"lib\": [\"DOM\", \"DOM.Iterable\", \"esnext\", \"esnext.array\", \"esnext.asynciterable\", \"esnext.symbol\"],\n        \"module\": \"commonjs\",\n        \"moduleResolution\": \"node\",\n        \"strict\": true,\n        \"noImplicitAny\": false,\n        \"target\": \"ESNEXT\",\n        \"jsx\": \"preserve\",\n\n        // @vencord/types has some errors for now\n        \"skipLibCheck\": true,\n\n        \"baseUrl\": \"./src/\",\n\n        \"typeRoots\": [\"./node_modules/@types\", \"./node_modules/@vencord\"]\n    },\n    \"include\": [\"src/**/*\"]\n}\n"
  }
]