Setup @uwu/treetype

This commit is contained in:
amsyarasyiq 2024-02-23 16:38:55 +08:00
parent 00b5be7130
commit 0ea0bbb69b
7 changed files with 159 additions and 1 deletions

1
.gitignore vendored
View file

@ -3,3 +3,4 @@ dist/
package-lock.json
yarn.lock
.DS_Store
lib-dist/

View file

@ -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.

View file

@ -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
}

View file

@ -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"
}
}

30
packages/bunny-types/pnpm-lock.yaml generated Normal file
View file

@ -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

View file

@ -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);
}
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<typeof createBunnyObject>;

View file

@ -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/*"],