bc-deeplib 1.0.5 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CREDITS.md +13 -0
- package/LICENSE +21 -21
- package/README.md +2 -2
- package/dist/3rd_party_types/bcmodsdk.d.ts +184 -0
- package/dist/3rd_party_types/declarations.d.ts +4 -0
- package/dist/deeplib.d.ts +538 -0
- package/dist/deeplib.js +2582 -0
- package/dist/deeplib.js.map +7 -0
- package/dist/index.js +2556 -0
- package/dist/index.js.map +7 -0
- package/dist/public/dl_images/arrow_left.svg +1 -0
- package/dist/public/dl_images/arrow_right.svg +1 -0
- package/dist/public/dl_images/bug.svg +1 -0
- package/dist/public/dl_images/clipboard_export.svg +19 -0
- package/dist/public/dl_images/clipboard_import.svg +19 -0
- package/dist/public/dl_images/cog.svg +1 -0
- package/dist/public/dl_images/exit.svg +1 -0
- package/dist/public/dl_images/file_export.svg +12 -0
- package/dist/public/dl_images/file_import.svg +12 -0
- package/dist/public/dl_images/git.svg +10 -0
- package/dist/public/dl_images/notebook.svg +1 -0
- package/dist/public/dl_images/round_arrow_left.svg +1 -0
- package/dist/public/dl_images/round_arrow_right.svg +1 -0
- package/dist/public/dl_images/round_transfer.svg +7 -0
- package/dist/public/dl_images/transfer.svg +1 -0
- package/dist/public/dl_images/trash_bin.svg +1 -0
- package/dist/public/dl_translations/en.lang +17 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/vendored_types/bcmodsdk.d.ts +184 -0
- package/dist/vendored_types/declarations.d.ts +5 -0
- package/lib/build.d.ts +32 -0
- package/lib/build.js +236 -0
- package/package.json +41 -24
- package/.types/declarations.d.ts +0 -15
- package/.types/elements.d.ts +0 -38
- package/.types/type-override.d.ts +0 -3
- package/public/styles/DeepLib.css +0 -206
- package/public/styles/Gratitude.css +0 -23
package/CREDITS.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
## Assets
|
|
2
|
+
|
|
3
|
+
- Git Logo by [Jason Long](https://bsky.app/profile/jasonlong.me) is licensed under the [Creative Commons Attribution 3.0 Unported License](https://creativecommons.org/licenses/by/3.0/).
|
|
4
|
+
- Changes: Added padding
|
|
5
|
+
- Source: https://git-scm.com/images/logos/downloads/Git-Icon-White.svg
|
|
6
|
+
|
|
7
|
+
- [Transfer Vertical, Notebook, Trash Bin Trash, Bug, Login 2, Alt Arrow Right, Alt Arrow Left, File Download, File Send] by [Solar Icons](https://www.figma.com/community/file/1166831539721848736?ref=svgrepo.com), in [CC Attribution License](https://creativecommons.org/licenses/by/4.0/)
|
|
8
|
+
- Changes: Color adjusted
|
|
9
|
+
- Source: https://www.svgrepo.com/collection/solar-outline-icons/
|
|
10
|
+
|
|
11
|
+
- [Clipboard Add] by [Solar Icons](https://www.figma.com/community/file/1166831539721848736?ref=svgrepo.com), in [CC Attribution License](https://creativecommons.org/licenses/by/4.0/)
|
|
12
|
+
- Changes: Color adjusted, plus symbol replaced with an arrow
|
|
13
|
+
- Source: https://www.svgrepo.com/collection/solar-outline-icons/
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 dDeepLb
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 dDeepLb
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
## Deep Lib
|
|
2
|
-
Package for easier development of BC mods.
|
|
1
|
+
## Deep Lib
|
|
2
|
+
Package for easier development of BC mods.
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A type signifying any unknown function.
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
declare type AnyFunction = (...args: any) => any;
|
|
6
|
+
|
|
7
|
+
/** @public */
|
|
8
|
+
declare const bcModSdk: ModSDKGlobalAPI;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
* A helper to resolve dotted property path to the target type
|
|
13
|
+
* @example
|
|
14
|
+
* typeof window["a"]["b"]["c"] === GetDotedPathType\<typeof window, "a.b.c"\>
|
|
15
|
+
*/
|
|
16
|
+
declare type GetDotedPathType<Base, DotedKey extends string> = DotedKey extends `${infer Key1}.${infer Key2}`
|
|
17
|
+
? GetDotedPathType<GetDotedPathType<Base, Key1>, Key2>
|
|
18
|
+
: DotedKey extends keyof Base
|
|
19
|
+
? Base[DotedKey]
|
|
20
|
+
: never;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The global API of the SDK
|
|
24
|
+
*
|
|
25
|
+
* Accessible using the exported value or as `window.bcModSdk`
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
declare interface ModSDKGlobalAPI {
|
|
29
|
+
/** The version of the SDK itself. Attempting to load two different SDK versions will warn, but work as long as `apiVersion` is same. */
|
|
30
|
+
readonly version: string;
|
|
31
|
+
/** The API version of the SDK itself. Attempting to load two different SDK versions will fail. */
|
|
32
|
+
readonly apiVersion: number;
|
|
33
|
+
/**
|
|
34
|
+
* Register a mod, receiving access to the mod API
|
|
35
|
+
* @param info - Info about the mod, necessary to register the mod
|
|
36
|
+
* @param options - [OPTIONAL] Options the mod can specify for ModSDK
|
|
37
|
+
* @returns The API usable by mod. @see ModSDKModAPI
|
|
38
|
+
* @see ModSDKModInfo
|
|
39
|
+
*/
|
|
40
|
+
registerMod(info: ModSDKModInfo, options?: ModSDKModOptions): ModSDKModAPI;
|
|
41
|
+
/** Get info about all registered mods */
|
|
42
|
+
getModsInfo(): ModSDKModInfo[];
|
|
43
|
+
/** Get info about all modified functions */
|
|
44
|
+
getPatchingInfo(): Map<string, PatchedFunctionInfo>;
|
|
45
|
+
/** Internal API, please **DO NOT USE** */
|
|
46
|
+
readonly errorReporterHooks: {
|
|
47
|
+
apiEndpointEnter: ((fn: string, mod: string) => () => void) | null;
|
|
48
|
+
hookEnter: ((fn: string, mod: string) => () => void) | null;
|
|
49
|
+
hookChainExit: ((fn: string, patchMods: ReadonlySet<string>) => () => void) | null;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** @public */
|
|
54
|
+
declare interface ModSDKModAPI {
|
|
55
|
+
/** Unload this mod, removing any hooks or patches by it. To continue using SDK another call to `registerMod` is required */
|
|
56
|
+
unload(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Hook a BC function
|
|
59
|
+
* @template TFunctionName - The name of the hooked function, _e.g._ `"Player.CanChange"`
|
|
60
|
+
* @param functionName - Name of function to hook. Can contain dots to change methods in objects (e.g. `Player.CanChange`)
|
|
61
|
+
* @param priority - Number used to determinate order hooks will be called in. Higher number is called first
|
|
62
|
+
* @param hook - The hook itself to use, @see PatchHook
|
|
63
|
+
* @returns Function that can be called to remove this hook
|
|
64
|
+
*/
|
|
65
|
+
hookFunction<TFunctionName extends string>(
|
|
66
|
+
functionName: TFunctionName,
|
|
67
|
+
priority: number,
|
|
68
|
+
hook: PatchHook<GetDotedPathType<typeof globalThis, TFunctionName>>
|
|
69
|
+
): () => void;
|
|
70
|
+
/**
|
|
71
|
+
* Call original function, bypassing any hooks and ignoring any patches applied by ALL mods.
|
|
72
|
+
* @template TFunctionName - The name of the called function, _e.g._ `"Player.CanChange"`
|
|
73
|
+
* @param functionName - Name of function to call. Can contain dots to change methods in objects (e.g. `Player.CanChange`)
|
|
74
|
+
* @param args - Arguments to use for the call
|
|
75
|
+
* @param context - `this` context to use. Defaults to `window`. If calling method of object, then set this to the object itself (e.g. `functionName` = `Player.CanChange` then `context` = `Player`)
|
|
76
|
+
*/
|
|
77
|
+
callOriginal<TFunctionName extends string>(
|
|
78
|
+
functionName: TFunctionName,
|
|
79
|
+
args: [...Parameters<GetDotedPathType<typeof globalThis, TFunctionName>>],
|
|
80
|
+
context?: any
|
|
81
|
+
): ReturnType<GetDotedPathType<typeof globalThis, TFunctionName>>;
|
|
82
|
+
/**
|
|
83
|
+
* Patch a BC function
|
|
84
|
+
*
|
|
85
|
+
* **This method is DANGEROUS** to use and has high potential to conflict with other mods.
|
|
86
|
+
*
|
|
87
|
+
* Only use it if what you are trying to accomplish can't be done easily with `hookFunction`.
|
|
88
|
+
*
|
|
89
|
+
* This function tranforms BC function to string, replaces patches as pure text and then `eval`uates it.
|
|
90
|
+
* If you don't know what this means, please avoid this function.
|
|
91
|
+
* @template TFunctionName - The name of the patched function, _e.g._ `"Player.CanChange"`
|
|
92
|
+
* @param functionName - Name of function to patch. Can contain dots to change methods in objects (e.g. `Player.CanChange`)
|
|
93
|
+
* @param patches - Object in key: value format, where keys are chunks to replace and values are result.
|
|
94
|
+
*
|
|
95
|
+
* Patches from multiple calls are merged; where key matches the older one is replaced.
|
|
96
|
+
* Specifying value of `null` removes patch with this key.
|
|
97
|
+
*/
|
|
98
|
+
patchFunction<TFunctionName extends string>(
|
|
99
|
+
functionName: TFunctionName,
|
|
100
|
+
patches: GetDotedPathType<typeof globalThis, TFunctionName> extends AnyFunction ? Record<string, string | null> : never
|
|
101
|
+
): void;
|
|
102
|
+
/**
|
|
103
|
+
* Remove all patches by `patchFunction` from specified function.
|
|
104
|
+
* @param functionName - Name of function to patch. Can contain dots to change methods in objects (e.g. `Player.CanChange`)
|
|
105
|
+
*/
|
|
106
|
+
removePatches(functionName: string): void;
|
|
107
|
+
/**
|
|
108
|
+
* Get hash of original function in CRC32.
|
|
109
|
+
*
|
|
110
|
+
* The hash is computed from source obtained using `toString` with line endings normalized to LF
|
|
111
|
+
* @param functionName - Name of function. Can contain dots to change methods in objects (e.g. `Player.CanChange`)
|
|
112
|
+
*/
|
|
113
|
+
getOriginalHash(functionName: string): string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Info about a mod registered within the Mod SDK
|
|
118
|
+
* @public
|
|
119
|
+
*/
|
|
120
|
+
declare interface ModSDKModInfo {
|
|
121
|
+
/** Short name or abbreviation of the mod */
|
|
122
|
+
name: string;
|
|
123
|
+
/** Full name of the mod */
|
|
124
|
+
fullName: string;
|
|
125
|
+
/** Version or other metadata for the mod, visible by other mods */
|
|
126
|
+
version: string;
|
|
127
|
+
/** Link to public repository with source code for this mod */
|
|
128
|
+
repository?: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Additional options mods can optionally give when registering
|
|
133
|
+
* @public
|
|
134
|
+
*/
|
|
135
|
+
declare interface ModSDKModOptions {
|
|
136
|
+
/**
|
|
137
|
+
* [OPTIONAL]
|
|
138
|
+
*
|
|
139
|
+
* If `true` subsequent calls to `registerMod` will unload old one, replacing it.
|
|
140
|
+
*
|
|
141
|
+
* If `false` any attempt to register a new mod with same name will fail.
|
|
142
|
+
* @default false
|
|
143
|
+
*/
|
|
144
|
+
allowReplace?: boolean;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Info about a function modified using the API
|
|
149
|
+
* @public
|
|
150
|
+
*/
|
|
151
|
+
declare interface PatchedFunctionInfo {
|
|
152
|
+
name: string;
|
|
153
|
+
/** The original function */
|
|
154
|
+
original?: (...args: any[]) => any;
|
|
155
|
+
/** CRC32 has of the original function */
|
|
156
|
+
originalHash: string;
|
|
157
|
+
/** SDK-generated entrypoint that the global function was replaced with */
|
|
158
|
+
sdkEntrypoint?: (...args: any[]) => any;
|
|
159
|
+
/**
|
|
160
|
+
* Entrypoint that SDK collected at the time of calling of the `getPatchingInfo` method.
|
|
161
|
+
*
|
|
162
|
+
* If the function wasn't overwritten, it should equal `sdkEntrypoint`
|
|
163
|
+
*/
|
|
164
|
+
currentEntrypoint?: (...args: any[]) => any;
|
|
165
|
+
/** List of names of mods that hooked this function */
|
|
166
|
+
hookedByMods: string[];
|
|
167
|
+
/** List of names of mods that patched this function */
|
|
168
|
+
patchedByMods: string[];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* This is how hook from mod looks like.
|
|
173
|
+
*
|
|
174
|
+
* As first argument it receives all arguments the original function received.
|
|
175
|
+
*
|
|
176
|
+
* As second argument special `next` function that should be used to call original function (or next function in the hook chain).
|
|
177
|
+
*
|
|
178
|
+
* The return value is then used as return value instead of original one.
|
|
179
|
+
* @public
|
|
180
|
+
*/
|
|
181
|
+
declare type PatchHook<TFunction extends AnyFunction = AnyFunction> = (
|
|
182
|
+
args: [...Parameters<TFunction>],
|
|
183
|
+
next: (args: [...Parameters<TFunction>]) => ReturnType<TFunction>
|
|
184
|
+
) => ReturnType<TFunction>;
|