duh
This commit is contained in:
parent
51262dae00
commit
dd6bb0b753
8 changed files with 45 additions and 116 deletions
|
|
@ -1,5 +1,5 @@
|
|||
\source ./dist/index.d.ts
|
||||
\import ./index
|
||||
\source ./dist/wrap.ts
|
||||
\import ./wrap
|
||||
|
||||
@bunny from BunnyObject {
|
||||
api {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import * as childProcess from "node:child_process";
|
||||
import { existsSync } from "node:fs";
|
||||
import * as fs from "node:fs/promises";
|
||||
import * as util from "node:util";
|
||||
import * as childProcess from "node:child_process";
|
||||
|
||||
if (existsSync("dist")) {
|
||||
await fs.rm("dist", { recursive: true });
|
||||
|
|
@ -12,5 +12,8 @@ const exec = util.promisify(childProcess.exec);
|
|||
await fs.copyFile("package.json", "./dist/package.json");
|
||||
await fs.copyFile("LICENSE", "./dist/LICENSE");
|
||||
|
||||
await exec("pnpm dts-bundle-generator -o dist/index.d.ts --project ../../tsconfig.json --inline-declare-global ../../src/global.d.ts --no-check --sort --no-banner")
|
||||
await exec('pnpm treetype def.tt dist/treetype.d.ts');
|
||||
await exec("pnpm dts-bundle-generator -o dist/index.d.ts --project ../../tsconfig.json ../../src/lib/index.ts --no-check --sort --no-banner");
|
||||
|
||||
await fs.writeFile("./dist/wrap.ts", "export type BunnyObject = typeof import(\".\")");
|
||||
|
||||
await exec("pnpm treetype def.tt dist/treetype.d.ts");
|
||||
|
|
|
|||
2
src/global.d.ts
vendored
2
src/global.d.ts
vendored
|
|
@ -13,4 +13,4 @@ declare global {
|
|||
}
|
||||
}
|
||||
|
||||
export {};
|
||||
export { };
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
import * as _spitroast from "spitroast";
|
||||
|
||||
export * from "spitroast";
|
||||
export default { ..._spitroast };
|
||||
export {
|
||||
after,
|
||||
before,
|
||||
instead
|
||||
} from "spitroast";
|
||||
export * as default from "spitroast";
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { createEmitter, Emitter } from "@lib/utils/emitter";
|
|||
const emitterSymbol = Symbol.for("vendetta.storage.emitter");
|
||||
const syncAwaitSymbol = Symbol.for("vendetta.storage.accessor");
|
||||
|
||||
export function createProxy(target: any = {}): { proxy: any; emitter: Emitter } {
|
||||
export function createProxy(target: any = {}): { proxy: any; emitter: Emitter; } {
|
||||
const emitter = createEmitter();
|
||||
|
||||
function createProxy(target: any, path: string[]): any {
|
||||
|
|
@ -113,4 +113,8 @@ export function wrapSync<T extends Promise<any>>(store: T): Awaited<T> {
|
|||
|
||||
export const awaitSyncWrapper = (store: any) => new Promise<void>(res => store[syncAwaitSymbol](res));
|
||||
|
||||
export * from "@lib/api/storage/backends";
|
||||
export {
|
||||
createFileBackend,
|
||||
createMMKVBackend,
|
||||
purgeStorage
|
||||
} from "@lib/api/storage/backends";
|
||||
|
|
|
|||
9
src/lib/index.ts
Normal file
9
src/lib/index.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import "../global.d.ts";
|
||||
|
||||
export * as api from "./api";
|
||||
export * as debug from "./debug";
|
||||
export * as managers from "./managers";
|
||||
export * as metro from "./metro";
|
||||
export * as settings from "./settings";
|
||||
export * as ui from "./ui";
|
||||
export * as utils from "./utils";
|
||||
|
|
@ -1,3 +1,16 @@
|
|||
export * as common from "./common";
|
||||
export * from "./filters";
|
||||
export {
|
||||
find,
|
||||
findAll,
|
||||
findByDisplayName,
|
||||
findByDisplayNameAll,
|
||||
findByName,
|
||||
findByNameAll,
|
||||
findByProps,
|
||||
findByPropsAll,
|
||||
findByStoreName,
|
||||
findByTypeName,
|
||||
findByTypeNameAll,
|
||||
modules
|
||||
} from "./filters";
|
||||
export * as filters from "./filters";
|
||||
|
|
|
|||
|
|
@ -1,108 +1,6 @@
|
|||
import { createVendettaObject } from "@core/vendettaObject";
|
||||
import * as api from "@lib/api";
|
||||
import patcher from "@lib/api/patcher";
|
||||
import * as debug from "@lib/debug";
|
||||
import * as managers from "@lib/managers";
|
||||
import * as metro from "@lib/metro";
|
||||
import * as settings from "@lib/settings";
|
||||
import * as ui from "@lib/ui";
|
||||
import * as utils from "@lib/utils";
|
||||
import { ExcludeInternalProperties } from "@lib/utils/types";
|
||||
|
||||
function createBunnyObject(unloads: any[]): BunnyObject {
|
||||
return {
|
||||
api: {
|
||||
...api,
|
||||
patcher
|
||||
},
|
||||
managers,
|
||||
metro,
|
||||
ui,
|
||||
utils,
|
||||
settings,
|
||||
debug,
|
||||
version: debug._versionHash,
|
||||
unload: () => {
|
||||
unloads.filter(i => typeof i === "function").forEach(p => p());
|
||||
// @ts-expect-error
|
||||
delete window.bunny;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export default function initWindowObject(unloads: any[]) {
|
||||
window.vendetta = createVendettaObject(unloads);
|
||||
window.bunny = createBunnyObject(unloads);
|
||||
window.bunny = require(".");
|
||||
}
|
||||
|
||||
/*
|
||||
(You may now worry about my mental state.)
|
||||
This is a hack, apparently when you destruct a star-imported module, its type is deferenced
|
||||
We need to do this for every module because the types bundler apparently does not support referencing star-imported modules(?)
|
||||
I only have realized this after getting everything set up, thinking it'd go well :)
|
||||
The API should be the same (or easy to migrate) even if we got alternatives in the future
|
||||
Another cons: JSDocs are stripped and a lot of declaration duplicates
|
||||
|
||||
See: https://github.com/timocov/dts-bundle-generator/issues/304
|
||||
*/
|
||||
export type BunnyObject = ExcludeInternalProperties<ReturnType<typeof _bunnyObject>>;
|
||||
const _bunnyObject = () => ({ // this function is never used, only exists for typings
|
||||
api: {
|
||||
...api,
|
||||
flux: { ...api.flux },
|
||||
commands: { ...api.commands },
|
||||
native: {
|
||||
...api.native,
|
||||
fs: { ...api.native.fs },
|
||||
modules: { ...api.native.modules },
|
||||
loader: { ...api.native.loader }
|
||||
},
|
||||
storage: { ...api.storage },
|
||||
assets: { ...api.assets },
|
||||
patcher: utils.without({
|
||||
...patcher,
|
||||
unpatchAll: () => { }
|
||||
}, "unpatchAll")
|
||||
},
|
||||
managers: {
|
||||
...managers,
|
||||
plugins: { ...managers.plugins },
|
||||
themes: { ...managers.themes }
|
||||
},
|
||||
metro: {
|
||||
...metro,
|
||||
common: { ...metro.common },
|
||||
filters: { ...metro.filters },
|
||||
...metro.filters
|
||||
},
|
||||
ui: {
|
||||
...ui,
|
||||
components: {
|
||||
...ui.components,
|
||||
discord: {
|
||||
...ui.components.discord,
|
||||
Forms: { ...ui.components.discord.Forms },
|
||||
Redesign: { ...ui.components.discord.Redesign }
|
||||
}
|
||||
},
|
||||
alerts: { ...ui.alerts },
|
||||
color: { ...ui.color },
|
||||
toasts: { ...ui.toasts },
|
||||
styles: { ...ui.styles },
|
||||
settings: { ...ui.settings }
|
||||
},
|
||||
utils: {
|
||||
...utils,
|
||||
constants: { ...utils.constants },
|
||||
types: { ...utils.types },
|
||||
logger: { ...utils.logger },
|
||||
},
|
||||
settings: {
|
||||
...settings,
|
||||
settings: settings.settings,
|
||||
loaderConfig: { ...settings.loaderConfig }
|
||||
},
|
||||
debug: { ...debug },
|
||||
version: debug._versionHash,
|
||||
unload: () => { },
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue