From 0ea0bbb69ba95e4b48fdd67b75c9219c8d9fe54f Mon Sep 17 00:00:00 2001 From: amsyarasyiq <82711525+amsyarasyiq@users.noreply.github.com> Date: Fri, 23 Feb 2024 16:38:55 +0800 Subject: [PATCH] Setup `@uwu/treetype` --- .gitignore | 1 + packages/bunny-types/LICENSE | 29 ++++++++++++++++ packages/bunny-types/def.tt | 24 +++++++++++++ packages/bunny-types/package.json | 19 ++++++++++ packages/bunny-types/pnpm-lock.yaml | 30 ++++++++++++++++ src/lib/windowObject.ts | 54 ++++++++++++++++++++++++++++- tsconfig.json | 3 ++ 7 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 packages/bunny-types/LICENSE create mode 100644 packages/bunny-types/def.tt create mode 100644 packages/bunny-types/package.json create mode 100644 packages/bunny-types/pnpm-lock.yaml diff --git a/.gitignore b/.gitignore index c9a8182..8d5633e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ dist/ package-lock.json yarn.lock .DS_Store +lib-dist/ diff --git a/packages/bunny-types/LICENSE b/packages/bunny-types/LICENSE new file mode 100644 index 0000000..22c00c1 --- /dev/null +++ b/packages/bunny-types/LICENSE @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2023, Team Vendetta +Copyright (c) 2024, pylixonly + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/packages/bunny-types/def.tt b/packages/bunny-types/def.tt new file mode 100644 index 0000000..79390cc --- /dev/null +++ b/packages/bunny-types/def.tt @@ -0,0 +1,24 @@ +\source ../../src/lib/windowObject.ts +\import ./src/lib/windowObject + +@bunny from BunnyObject { + patcher + metro { + common + } + constants + utils + debug + ui { + components + toasts + alerts + assets + } + plugins + themes + commands + storage + settings + loader +} \ No newline at end of file diff --git a/packages/bunny-types/package.json b/packages/bunny-types/package.json new file mode 100644 index 0000000..f96ee56 --- /dev/null +++ b/packages/bunny-types/package.json @@ -0,0 +1,19 @@ +{ + "name": "bunny-types", + "version": "0.0.1", + "description": "Types for Bunny, a mod for Discord's mobile apps", + "author": "pylixonly", + "publishConfig": { + "directory": "dist", + "typings": "treetype.d.ts" + }, + "scripts": { + "prepublishOnly": "if [ -d dist ]; then rm -r dist; fi && tsc --project ../../tsconfig.json --outDir ./dist/src && cp package.json ./dist && cp LICENSE dist && pnpm treetype def.tt dist/treetype.d.ts" + }, + "keywords": ["bunny-mod", "discord"], + "license": "BSD-3-Clause", + "dependencies": { + "@uwu/treetype": "^1.1.0", + "typescript": "^5.3.3" + } +} diff --git a/packages/bunny-types/pnpm-lock.yaml b/packages/bunny-types/pnpm-lock.yaml new file mode 100644 index 0000000..f9c90ac --- /dev/null +++ b/packages/bunny-types/pnpm-lock.yaml @@ -0,0 +1,30 @@ +lockfileVersion: '6.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +dependencies: + '@uwu/treetype': + specifier: ^1.1.0 + version: 1.1.0(typescript@5.3.3) + typescript: + specifier: ^5.3.3 + version: 5.3.3 + +packages: + + /@uwu/treetype@1.1.0(typescript@5.3.3): + resolution: {integrity: sha512-de9T/2E/ZhLihxfyZHnBrLEi05tw2YJL++gqGV3p4Y7D6HyuQum31qHsYODsXmx2p8LFCil7g3Dq9RO0oBphBQ==} + hasBin: true + peerDependencies: + typescript: ^5.0.0 + dependencies: + typescript: 5.3.3 + dev: false + + /typescript@5.3.3: + resolution: {integrity: sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==} + engines: {node: '>=14.17'} + hasBin: true + dev: false diff --git a/src/lib/windowObject.ts b/src/lib/windowObject.ts index cf309ce..6bec165 100644 --- a/src/lib/windowObject.ts +++ b/src/lib/windowObject.ts @@ -1,5 +1,57 @@ import { createVendettaObject } from "./vendettaObject"; +import * as constants from "@lib/constants"; +import * as debug from "@lib/debug"; +import * as plugins from "@lib/plugins"; +import * as themes from "@lib/themes"; +import * as commands from "@lib/commands"; +import * as storage from "@lib/storage"; +import * as metro from "@metro/filters"; +import * as common from "@metro/common"; +import * as components from "@ui/components"; +import * as toasts from "@ui/toasts"; +import * as alerts from "@ui/alerts"; +import * as assets from "@ui/assets"; +import * as color from "@ui/color"; +import * as utils from "@lib/utils"; +import logger from "./logger"; +import patcher from "./patcher"; +import settings, { loaderConfig } from "./settings"; export default function initWindowObject(unloads: any[]) { window.vendetta = createVendettaObject(unloads); -} \ No newline at end of file + window.bunny = createBunnyObject(unloads); +} + +function createBunnyObject(unloads: any[]) { + return { + patcher: utils.without(patcher, "unpatchAll"), + metro: { ...metro, common: { ...common } }, + constants, + utils, + debug: utils.without(debug, "versionHash", "patchLogHook", "toggleSafeMode"), + ui: { + components, + toasts, + alerts, + assets, + ...color, + }, + plugins: utils.without(plugins, "initPlugins", "evalPlugin"), + themes: utils.without(themes, "initThemes"), + commands: utils.without(commands, "patchCommands"), + storage, + settings, + loader: { + identity: window.__vendetta_loader, + config: loaderConfig, + }, + logger, + version: debug.versionHash, + unload: () => { + unloads.filter(i => typeof i === "function").forEach(p => p()); + delete window.vendetta; + }, + } +} + +export type BunnyObject = ReturnType; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index d4a6b86..fcc4a9c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,12 +6,15 @@ "sourceMap": true, "module": "ESNext", "target": "ESNext", + "declaration": true, + "emitDeclarationOnly": true, "moduleResolution": "node", "esModuleInterop": true, "jsx": "react", "strict": true, "forceConsistentCasingInFileNames": true, "resolveJsonModule": true, + "skipLibCheck": true, "paths": { "@*": ["src*"], "@lib/*": ["src/lib/*"],