@unbound-app/api 0.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/package.json +51 -0
- package/src/_internal.d.ts +622 -0
- package/src/assets.d.ts +49 -0
- package/src/fs.d.ts +52 -0
- package/src/global.d.ts +147 -0
- package/src/i18n.d.ts +42 -0
- package/src/index.d.ts +11 -0
- package/src/metro/api.d.ts +7 -0
- package/src/metro/common.d.ts +23 -0
- package/src/metro/components.d.ts +22 -0
- package/src/metro/filters.d.ts +55 -0
- package/src/metro/index.d.ts +228 -0
- package/src/metro/stores.d.ts +4 -0
- package/src/native.d.ts +95 -0
- package/src/patcher.d.ts +92 -0
- package/src/settings.d.ts +28 -0
- package/src/storage.d.ts +155 -0
- package/src/toasts.d.ts +18 -0
- package/src/tseep.d.ts +175 -0
- package/src/utils.d.ts +35 -0
package/src/native.d.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Auto-generated by generate-plugin-sdk.ts - DO NOT EDIT
|
|
2
|
+
|
|
3
|
+
import type { Fn, PromiseFn } from './utils';
|
|
4
|
+
/** The raw `UnboundNative` JSI bridge installed on the global by the platform loader. */
|
|
5
|
+
declare const UnboundNative$1: UnboundNativeModule | undefined;
|
|
6
|
+
/** The resolved native client info module, exposing build and release metadata. */
|
|
7
|
+
export declare const BundleInfo: BundleInfoType;
|
|
8
|
+
/** The resolved native bundle updater module, used to check for updates and reload the bundle. */
|
|
9
|
+
export declare const BundleManager: DCDBundleManagerType;
|
|
10
|
+
/** The resolved native device module, exposing hardware and OS details. */
|
|
11
|
+
export declare const DeviceInfo: DeviceInfoType;
|
|
12
|
+
/**
|
|
13
|
+
* @description Resolves the first available native module matching any of the given names, checking both `NativeModules` and the `TurboModuleRegistry`.
|
|
14
|
+
* @template T The type of the resolved native module.
|
|
15
|
+
* @param names The candidate native module names to look up, in priority order.
|
|
16
|
+
* @returns The first matching native module.
|
|
17
|
+
*/
|
|
18
|
+
export declare function getNativeModule<T = any>(...names: string[]): T;
|
|
19
|
+
/**
|
|
20
|
+
* @description Reads Hermes' runtime metadata, such as the bytecode version, GC, and build channel.
|
|
21
|
+
* React Native types the global `HermesInternal` as `null | {}`, so this reads it via
|
|
22
|
+
* `window.HermesInternal` where our own typing wins.
|
|
23
|
+
* @returns The runtime property map, or an empty object when Hermes internals are unavailable.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getRuntimeProperties(): Record<string, any>;
|
|
26
|
+
/**
|
|
27
|
+
* @description Persists pending settings to storage, then reloads the native bundle.
|
|
28
|
+
*/
|
|
29
|
+
export declare function reload(): Promise<void>;
|
|
30
|
+
/** Build and release metadata reported by the native client info module. */
|
|
31
|
+
export interface BundleInfoType {
|
|
32
|
+
Version: string;
|
|
33
|
+
ReleaseChannel: string;
|
|
34
|
+
Manifest: string;
|
|
35
|
+
Build: string;
|
|
36
|
+
SentryDsn: string;
|
|
37
|
+
DeviceVendorID: string;
|
|
38
|
+
OTABuild: string;
|
|
39
|
+
SentryStaffDsn: string;
|
|
40
|
+
Identifier: string;
|
|
41
|
+
SentryAlphaBetaDsn: string;
|
|
42
|
+
}
|
|
43
|
+
/** The native `BundleUpdaterManager` module surface for OTA updates and reloading the bundle. */
|
|
44
|
+
export interface DCDBundleManagerType {
|
|
45
|
+
getInitialBundleDownloaded: PromiseFn;
|
|
46
|
+
getInitialOtaUpdateChecked: PromiseFn;
|
|
47
|
+
checkForUpdateAndReload: Fn;
|
|
48
|
+
reload: Fn;
|
|
49
|
+
getOtaRootPath: PromiseFn;
|
|
50
|
+
getBuildOverrideCookieContents: PromiseFn;
|
|
51
|
+
setBuildOverrideCookieHeader: PromiseFn;
|
|
52
|
+
getManifestInfo: PromiseFn;
|
|
53
|
+
addListener: Fn;
|
|
54
|
+
removeListeners: Fn;
|
|
55
|
+
}
|
|
56
|
+
/** The constant directory paths exposed by the native `DCDFileManager`. */
|
|
57
|
+
export interface DCDFileManagerConstants {
|
|
58
|
+
CacheDirPath: string;
|
|
59
|
+
DocumentsDirPath: string;
|
|
60
|
+
}
|
|
61
|
+
/** The native `DCDFileManager` module surface for reading, writing, and inspecting files. */
|
|
62
|
+
export interface DCDFileManagerType extends DCDFileManagerConstants {
|
|
63
|
+
readFile(path: string, encoding: DCDFileManagerEncoding): Promise<string>;
|
|
64
|
+
writeFile(
|
|
65
|
+
type: 'documents' | 'cache',
|
|
66
|
+
path: string,
|
|
67
|
+
data: string,
|
|
68
|
+
encoding: DCDFileManagerEncoding,
|
|
69
|
+
): Promise<string>;
|
|
70
|
+
removeFile(type: 'documents' | 'cache', path: string): Promise<any>;
|
|
71
|
+
readAsset(): Promise<unknown>;
|
|
72
|
+
getSize(): Promise<unknown>;
|
|
73
|
+
getVideoDimensions(): Promise<unknown>;
|
|
74
|
+
fileExists(path: string): Promise<boolean>;
|
|
75
|
+
saveFileToGallery(): Promise<unknown>;
|
|
76
|
+
getConstants(): DCDFileManagerConstants;
|
|
77
|
+
}
|
|
78
|
+
/** Hardware and OS details reported by the native device module. */
|
|
79
|
+
export interface DeviceInfoType {
|
|
80
|
+
isTaskBarEnabled: boolean;
|
|
81
|
+
maxCpuFreq: string;
|
|
82
|
+
socName: string;
|
|
83
|
+
deviceModel: string;
|
|
84
|
+
isTablet: boolean;
|
|
85
|
+
isGestureNavigationEnabled: boolean;
|
|
86
|
+
deviceProduct: string;
|
|
87
|
+
systemVersion: string;
|
|
88
|
+
deviceManufacturer: string;
|
|
89
|
+
deviceBrand: string;
|
|
90
|
+
ramSize: string;
|
|
91
|
+
device: string;
|
|
92
|
+
}
|
|
93
|
+
/** The text encodings accepted by the native `DCDFileManager` read/write operations. */
|
|
94
|
+
export type DCDFileManagerEncoding = 'utf-8' | 'utf8' | 'base64';
|
|
95
|
+
export { UnboundNative$1 as UnboundNative };
|
package/src/patcher.d.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Auto-generated by generate-plugin-sdk.ts - DO NOT EDIT
|
|
2
|
+
|
|
3
|
+
//#region src/patcher.d.ts
|
|
4
|
+
export declare const PATCH_SYMBOL: unique symbol;
|
|
5
|
+
export declare const patches: PatchedModule[];
|
|
6
|
+
export declare enum PatchType {
|
|
7
|
+
Before = 0,
|
|
8
|
+
Instead = 1,
|
|
9
|
+
After = 2,
|
|
10
|
+
}
|
|
11
|
+
export declare function after<M extends PatchParent, P extends PropOf<M>>(
|
|
12
|
+
parent: M,
|
|
13
|
+
method: P,
|
|
14
|
+
callback: PatchCallback<
|
|
15
|
+
M[P] extends (...args: infer Args) => any ? Args : any[],
|
|
16
|
+
M[P] extends (...args: any[]) => infer Res ? Res : any,
|
|
17
|
+
unknown extends ThisParameterType<M[P]> ? M : ThisParameterType<M[P]>
|
|
18
|
+
>,
|
|
19
|
+
options?: PatchOptions,
|
|
20
|
+
): () => void;
|
|
21
|
+
export declare function before<M extends PatchParent, P extends PropOf<M>>(
|
|
22
|
+
parent: M,
|
|
23
|
+
method: P,
|
|
24
|
+
callback: PatchCallback<
|
|
25
|
+
M[P] extends (...args: infer Args) => any ? Args : any[],
|
|
26
|
+
M[P] extends (...args: any[]) => infer Res ? Res : any,
|
|
27
|
+
unknown extends ThisParameterType<M[P]> ? M : ThisParameterType<M[P]>
|
|
28
|
+
>,
|
|
29
|
+
options?: PatchOptions,
|
|
30
|
+
): () => void;
|
|
31
|
+
export declare function createPatcher(defaultOptions: string | PatchOptions): PatcherInstance;
|
|
32
|
+
export declare function instead<M extends PatchParent, P extends PropOf<M>>(
|
|
33
|
+
parent: M,
|
|
34
|
+
method: P,
|
|
35
|
+
callback: PatchCallback<
|
|
36
|
+
M[P] extends (...args: infer Args) => any ? Args : any[],
|
|
37
|
+
M[P] extends (...args: any[]) => infer Res ? Res : any,
|
|
38
|
+
unknown extends ThisParameterType<M[P]> ? M : ThisParameterType<M[P]>
|
|
39
|
+
>,
|
|
40
|
+
options?: PatchOptions,
|
|
41
|
+
): () => void;
|
|
42
|
+
export declare function unpatchAll(): void;
|
|
43
|
+
export declare function unpatchAllByCaller(caller: string): void;
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/env.d.ts
|
|
46
|
+
/**
|
|
47
|
+
* A reference to a {@link PatchParent} that does not, by itself, prevent the parent from being
|
|
48
|
+
* garbage collected. Mirrors the subset of the global {@link WeakRef} API that the patcher uses.
|
|
49
|
+
*/
|
|
50
|
+
export interface ParentRef {
|
|
51
|
+
deref(): PatchParent | undefined;
|
|
52
|
+
}
|
|
53
|
+
export interface Patch<Args extends any[] = any[], Res = any, Self = any> extends PatchOptions {
|
|
54
|
+
callback: PatchCallback<Args, Res, Self>;
|
|
55
|
+
}
|
|
56
|
+
export interface PatchCallback<Args extends any[] = any[], Res = any, Self = any> {
|
|
57
|
+
(ctx: PatchContext<Args, Res, Self>): any;
|
|
58
|
+
}
|
|
59
|
+
export interface PatchContext<Args extends any = any[], Res = any, Self = any> {
|
|
60
|
+
original: (...args: any[]) => Res;
|
|
61
|
+
this: Self;
|
|
62
|
+
result: Res | null;
|
|
63
|
+
args: Args;
|
|
64
|
+
}
|
|
65
|
+
export interface PatchOptions {
|
|
66
|
+
once?: boolean;
|
|
67
|
+
caller?: string;
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/types.d.ts
|
|
71
|
+
export interface PatchedModule {
|
|
72
|
+
parent: ParentRef;
|
|
73
|
+
method: PatchMethod;
|
|
74
|
+
original: AnyFunction & AnyConstructor;
|
|
75
|
+
patches: Record<PatchType, Set<Patch<any, any, any>>>;
|
|
76
|
+
}
|
|
77
|
+
export interface PatcherInstance {
|
|
78
|
+
instead: typeof instead;
|
|
79
|
+
before: typeof before;
|
|
80
|
+
after: typeof after;
|
|
81
|
+
unpatchAll: () => void;
|
|
82
|
+
}
|
|
83
|
+
export type AnyConstructor = {
|
|
84
|
+
new (...args: any): any;
|
|
85
|
+
};
|
|
86
|
+
export type AnyFunction = (...args: any[]) => any;
|
|
87
|
+
export type AnyObject = Record<any, any>;
|
|
88
|
+
export type PatchMethod = string;
|
|
89
|
+
export type PatchParent = AnyFunction | AnyObject;
|
|
90
|
+
export type PropOf<M> = {
|
|
91
|
+
[K in keyof M]: M[K] extends AnyFunction | AnyConstructor ? Extract<K, string> : never;
|
|
92
|
+
}[keyof M];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Auto-generated by generate-plugin-sdk.ts - DO NOT EDIT
|
|
2
|
+
|
|
3
|
+
export type { SettingsEntry } from './_internal';
|
|
4
|
+
import { ComponentType } from 'react';
|
|
5
|
+
|
|
6
|
+
import type { SettingsEntry } from './_internal';
|
|
7
|
+
|
|
8
|
+
declare const _default: {
|
|
9
|
+
registerSettings: typeof registerSettings;
|
|
10
|
+
removeSettings: typeof removeSettings;
|
|
11
|
+
sections: typeof sections;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* @description Registers one or more settings entries into the section registry, warning on key collisions.
|
|
15
|
+
* @param entries The settings entries to register.
|
|
16
|
+
*/
|
|
17
|
+
export declare function registerSettings(...entries: SettingsEntry[]): void;
|
|
18
|
+
/**
|
|
19
|
+
* @description Removes one or more settings entries from the section registry by key.
|
|
20
|
+
* @param keys The entry keys to remove.
|
|
21
|
+
*/
|
|
22
|
+
export declare function removeSettings(...keys: string[]): void;
|
|
23
|
+
/**
|
|
24
|
+
* @description Returns the current registry of settings entries.
|
|
25
|
+
* @returns A record of entry key to its {@link SettingsEntry}.
|
|
26
|
+
*/
|
|
27
|
+
export declare function sections(): Record<string, SettingsEntry>;
|
|
28
|
+
export { _default as default };
|
package/src/storage.d.ts
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// Auto-generated by generate-plugin-sdk.ts - DO NOT EDIT
|
|
2
|
+
|
|
3
|
+
import type { PredicateResult, Widen } from './utils';
|
|
4
|
+
import type { EventEmitter } from './tseep';
|
|
5
|
+
declare const _default: {
|
|
6
|
+
addListener: typeof addListener;
|
|
7
|
+
get: typeof get;
|
|
8
|
+
getStore: typeof getStore;
|
|
9
|
+
off: <EventKey extends keyof EventMap = string>(
|
|
10
|
+
event: EventKey,
|
|
11
|
+
listener: EventMap[EventKey],
|
|
12
|
+
) => EventEmitter<EventMap>;
|
|
13
|
+
on: <EventKey extends keyof EventMap = string>(
|
|
14
|
+
event: EventKey,
|
|
15
|
+
listener: EventMap[EventKey],
|
|
16
|
+
) => EventEmitter<EventMap>;
|
|
17
|
+
persist: typeof persist;
|
|
18
|
+
remove: typeof remove;
|
|
19
|
+
removeListener: typeof removeListener;
|
|
20
|
+
set: typeof set;
|
|
21
|
+
useSettingsStore: typeof useSettingsStore;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* @description Removes an entire store and all of its keys, and emits `changed` and `cleared`.
|
|
25
|
+
* @param store The store to clear.
|
|
26
|
+
*/
|
|
27
|
+
declare function clear$1(store: string): void;
|
|
28
|
+
export declare const off: <EventKey extends keyof EventMap = string>(
|
|
29
|
+
event: EventKey,
|
|
30
|
+
listener: EventMap[EventKey],
|
|
31
|
+
) => EventEmitter<EventMap>;
|
|
32
|
+
export declare const on: <EventKey extends keyof EventMap = string>(
|
|
33
|
+
event: EventKey,
|
|
34
|
+
listener: EventMap[EventKey],
|
|
35
|
+
) => EventEmitter<EventMap>;
|
|
36
|
+
/**
|
|
37
|
+
* @description Registers a callback invoked on every settings change matching the predicate.
|
|
38
|
+
* @param predicate Decides whether a given change should fire the callback.
|
|
39
|
+
* @param callback Invoked with the payload of each matching change.
|
|
40
|
+
* @returns A function that removes the listener.
|
|
41
|
+
*/
|
|
42
|
+
export declare function addListener(
|
|
43
|
+
predicate: (payload: SettingsPayload) => PredicateResult,
|
|
44
|
+
callback: (payload: SettingsPayload) => void,
|
|
45
|
+
): () => void;
|
|
46
|
+
/**
|
|
47
|
+
* @description Reads a value from a store by dot-separated key path, falling back to a default when absent.
|
|
48
|
+
* @template T The type of the default value.
|
|
49
|
+
* @param store The store to read from.
|
|
50
|
+
* @param key The dot-separated key path within the store.
|
|
51
|
+
* @param def The value to return when the key is not set.
|
|
52
|
+
* @returns The stored value, or `def` if the key path is not present.
|
|
53
|
+
*/
|
|
54
|
+
export declare function get<T>(store: string, key: string, def: T): Widen<T>;
|
|
55
|
+
/**
|
|
56
|
+
* @description Builds a store-scoped facade binding every settings operation to a single store name.
|
|
57
|
+
* @param store The store name to scope every operation to.
|
|
58
|
+
* @returns An object exposing `get`, `set`, `toggle`, `remove`, `clear`, `useSettingsStore`, and `addListener` bound to the store.
|
|
59
|
+
*/
|
|
60
|
+
export declare function getStore(store: string): {
|
|
61
|
+
set: (key: string, value: any) => void;
|
|
62
|
+
get: <T>(key: string, def: T) => Widen<T>;
|
|
63
|
+
toggle: (key: string, def: any) => void;
|
|
64
|
+
remove: (key: string) => void;
|
|
65
|
+
clear: () => void;
|
|
66
|
+
useSettingsStore: (predicate?: (payload: SettingsPayload) => PredicateResult) => {
|
|
67
|
+
set: (key: string, value: any) => void;
|
|
68
|
+
get: <T>(key: string, def: T) => Widen<T>;
|
|
69
|
+
toggle: (key: string, def: any) => void;
|
|
70
|
+
remove: (key: string) => void;
|
|
71
|
+
};
|
|
72
|
+
addListener: (
|
|
73
|
+
predicate: (payload: SettingsPayload) => PredicateResult,
|
|
74
|
+
callback: (payload: SettingsPayload) => void,
|
|
75
|
+
) => () => EventEmitter<EventMap>;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* @description Serialises the current settings and writes them to disk.
|
|
79
|
+
* @returns A promise that resolves once the settings file has been written.
|
|
80
|
+
*/
|
|
81
|
+
export declare function persist(): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* @description Deletes a top-level key from a store, dropping the store entirely if it becomes empty, and emits `changed` and `removed`.
|
|
84
|
+
* @param store The store to remove the key from.
|
|
85
|
+
* @param key The key to delete.
|
|
86
|
+
*/
|
|
87
|
+
export declare function remove(store: string, key: string): void;
|
|
88
|
+
/**
|
|
89
|
+
* @description Removes a previously registered settings change listener.
|
|
90
|
+
* @param callback The listener to remove.
|
|
91
|
+
*/
|
|
92
|
+
export declare function removeListener(callback: (payload: SettingsPayload) => void): void;
|
|
93
|
+
/**
|
|
94
|
+
* @description Writes a value into a store at a dot-separated key path, creating intermediate objects, and emits `changed` and `set`.
|
|
95
|
+
* @param store The store to write to.
|
|
96
|
+
* @param key The dot-separated key path within the store.
|
|
97
|
+
* @param value The value to store.
|
|
98
|
+
*/
|
|
99
|
+
export declare function set(store: string, key: string, value: any): void;
|
|
100
|
+
/**
|
|
101
|
+
* @description Flips a boolean value at a key path against its current (or default) value, and emits `toggled`.
|
|
102
|
+
* @param store The store to write to.
|
|
103
|
+
* @param key The dot-separated key path within the store.
|
|
104
|
+
* @param def The value to assume when the key is not yet set.
|
|
105
|
+
*/
|
|
106
|
+
export declare function toggle(store: string, key: string, def: any): void;
|
|
107
|
+
/**
|
|
108
|
+
* @description React hook that re-renders the component whenever a matching change occurs in the store.
|
|
109
|
+
* @param store The store to subscribe to.
|
|
110
|
+
* @param predicate Optional filter deciding which changes trigger a re-render.
|
|
111
|
+
* @returns An object exposing `get`, `set`, `toggle`, and `remove` bound to the store.
|
|
112
|
+
*/
|
|
113
|
+
export declare function useSettingsStore(
|
|
114
|
+
store: string,
|
|
115
|
+
predicate?: (payload: SettingsPayload) => PredicateResult,
|
|
116
|
+
): {
|
|
117
|
+
set: (key: string, value: any) => void;
|
|
118
|
+
get: <T>(key: string, def: T) => Widen<T>;
|
|
119
|
+
toggle: (key: string, def: any) => void;
|
|
120
|
+
remove: (key: string) => void;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/** Payload describing a settings change, passed to `changed` listeners and predicates. */
|
|
124
|
+
export interface SettingsPayload {
|
|
125
|
+
store: string;
|
|
126
|
+
key: string | null;
|
|
127
|
+
value: any;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export type ClearedPayload = {
|
|
131
|
+
store: string;
|
|
132
|
+
};
|
|
133
|
+
export type EventMap = {
|
|
134
|
+
set: (payload: SetPayload) => void;
|
|
135
|
+
changed: (payload: SettingsPayload) => void;
|
|
136
|
+
cleared: (payload: ClearedPayload) => void;
|
|
137
|
+
removed: (payload: RemovedPayload) => void;
|
|
138
|
+
toggled: (payload: ToggledPayload) => void;
|
|
139
|
+
};
|
|
140
|
+
export type RemovedPayload = {
|
|
141
|
+
store: string;
|
|
142
|
+
key: string;
|
|
143
|
+
};
|
|
144
|
+
export type SetPayload = {
|
|
145
|
+
store: string;
|
|
146
|
+
key: string;
|
|
147
|
+
value: any;
|
|
148
|
+
};
|
|
149
|
+
export type ToggledPayload = {
|
|
150
|
+
store: string;
|
|
151
|
+
key: string;
|
|
152
|
+
prev: any;
|
|
153
|
+
value: any;
|
|
154
|
+
};
|
|
155
|
+
export { _default as default, clear$1 as clear };
|
package/src/toasts.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Auto-generated by generate-plugin-sdk.ts - DO NOT EDIT
|
|
2
|
+
|
|
3
|
+
export type { ToastHandle, ToastOptions } from './_internal';
|
|
4
|
+
import { ImageSourcePropType } from 'react-native';
|
|
5
|
+
import { ComponentType } from 'react';
|
|
6
|
+
|
|
7
|
+
import type { ToastHandle, ToastOptions } from './_internal';
|
|
8
|
+
|
|
9
|
+
declare const _default: {
|
|
10
|
+
showToast: typeof showToast;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* @description Shows a toast, generating an id when one is not supplied.
|
|
14
|
+
* @param options The toast options, optionally including a custom `id`.
|
|
15
|
+
* @returns A {@link ToastHandle} for controlling the shown toast.
|
|
16
|
+
*/
|
|
17
|
+
export declare function showToast(options: ToastOptions): ToastHandle;
|
|
18
|
+
export { _default as default };
|
package/src/tseep.d.ts
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// Auto-generated by generate-plugin-sdk.ts - DO NOT EDIT
|
|
2
|
+
|
|
3
|
+
declare class TaskCollection<
|
|
4
|
+
Func extends (...args: any) => void,
|
|
5
|
+
AwaitTasks extends true | false = false,
|
|
6
|
+
> {
|
|
7
|
+
readonly awaitTasks: AwaitTasks;
|
|
8
|
+
constructor(
|
|
9
|
+
argsNum: ArgsNum<Func>,
|
|
10
|
+
autoRebuild?: boolean,
|
|
11
|
+
initialTasks?: Func[] | Func | null,
|
|
12
|
+
awaitTasks?: AwaitTasks,
|
|
13
|
+
);
|
|
14
|
+
/** DO NOT CHANGE DIRECTLY */
|
|
15
|
+
_tasks: Func[] | Func | null;
|
|
16
|
+
/** cached */
|
|
17
|
+
length: number;
|
|
18
|
+
/** auto rebuild on first emit call; otherwise autorebuild on every change */
|
|
19
|
+
firstEmitBuildStrategy: boolean;
|
|
20
|
+
readonly argsNum: ArgsNum<Func>;
|
|
21
|
+
autoRebuild: boolean;
|
|
22
|
+
readonly growArgsNum: typeof growArgsNum;
|
|
23
|
+
setAutoRebuild: typeof setAutoRebuild;
|
|
24
|
+
call: (...args: Parameters<Func>) => AwaitTasks extends true ? Promise<void> : void;
|
|
25
|
+
rebuild: () => void;
|
|
26
|
+
push: (...func: Func[]) => void;
|
|
27
|
+
/** remove last matched task from tasks */
|
|
28
|
+
removeLast: (func: Func) => void;
|
|
29
|
+
insert: (index: number, ...func: Func[]) => void;
|
|
30
|
+
setTasks: (tasks: Func[]) => void;
|
|
31
|
+
tasksAsArray: () => Func[];
|
|
32
|
+
/** this autorebuilds */
|
|
33
|
+
readonly clear: typeof clear;
|
|
34
|
+
/** this autorebuilds */
|
|
35
|
+
readonly fastClear: typeof fastClear;
|
|
36
|
+
}
|
|
37
|
+
declare function clear<
|
|
38
|
+
Func extends (...args: any) => void,
|
|
39
|
+
AwaitTasks extends true | false = false,
|
|
40
|
+
>(this: TaskCollection<Func, AwaitTasks>): void;
|
|
41
|
+
declare function fastClear<
|
|
42
|
+
Func extends (...args: any) => void,
|
|
43
|
+
AwaitTasks extends true | false = false,
|
|
44
|
+
>(this: TaskCollection<Func, AwaitTasks>): void;
|
|
45
|
+
declare function growArgsNum<
|
|
46
|
+
Func extends (...args: any) => void,
|
|
47
|
+
AwaitTasks extends true | false = false,
|
|
48
|
+
>(this: TaskCollection<Func, AwaitTasks>, argsNum: number): void;
|
|
49
|
+
declare function setAutoRebuild<
|
|
50
|
+
Func extends (...args: any) => void,
|
|
51
|
+
AwaitTasks extends true | false = false,
|
|
52
|
+
>(this: TaskCollection<Func, AwaitTasks>, newVal: boolean): void;
|
|
53
|
+
|
|
54
|
+
/** Implemented event emitter */
|
|
55
|
+
export declare class EventEmitter<
|
|
56
|
+
EventMap extends DefaultEventMap = DefaultEventMap,
|
|
57
|
+
> implements IEventEmitter<EventMap> {
|
|
58
|
+
events: {
|
|
59
|
+
[eventName in keyof EventMap]?: TaskCollection<EventMap[eventName]>;
|
|
60
|
+
};
|
|
61
|
+
onceEvents: {
|
|
62
|
+
[eventName in keyof EventMap]?: EventMap[eventName][] | EventMap[eventName];
|
|
63
|
+
};
|
|
64
|
+
boundFuncs: undefined | Map<Function, Function>;
|
|
65
|
+
_symbolKeys: Set<symbol>;
|
|
66
|
+
maxListeners: number;
|
|
67
|
+
get _eventsCount(): number;
|
|
68
|
+
emit: <EventKey extends keyof EventMap>(
|
|
69
|
+
event: EventKey,
|
|
70
|
+
...args: Parameters<EventMap[EventKey]>
|
|
71
|
+
) => boolean;
|
|
72
|
+
on: <EventKey extends keyof EventMap = string>(
|
|
73
|
+
event: EventKey,
|
|
74
|
+
listener: EventMap[EventKey],
|
|
75
|
+
) => this;
|
|
76
|
+
once: <EventKey extends keyof EventMap = string>(
|
|
77
|
+
event: EventKey,
|
|
78
|
+
listener: EventMap[EventKey],
|
|
79
|
+
) => this;
|
|
80
|
+
addListener: <EventKey extends keyof EventMap = string>(
|
|
81
|
+
event: EventKey,
|
|
82
|
+
listener: EventMap[EventKey],
|
|
83
|
+
argsNum?: ArgsNum<EventMap[EventKey]>,
|
|
84
|
+
) => this;
|
|
85
|
+
removeListener: <EventKey extends keyof EventMap = string>(
|
|
86
|
+
event: EventKey,
|
|
87
|
+
listener: EventMap[EventKey],
|
|
88
|
+
) => this;
|
|
89
|
+
hasListeners: <EventKey extends keyof EventMap = string>(event: EventKey) => boolean;
|
|
90
|
+
prependListener: <EventKey extends keyof EventMap = string>(
|
|
91
|
+
event: EventKey,
|
|
92
|
+
listener: EventMap[EventKey],
|
|
93
|
+
) => this;
|
|
94
|
+
prependOnceListener: <EventKey extends keyof EventMap = string>(
|
|
95
|
+
event: EventKey,
|
|
96
|
+
listener: EventMap[EventKey],
|
|
97
|
+
) => this;
|
|
98
|
+
off: <EventKey extends keyof EventMap = string>(
|
|
99
|
+
event: EventKey,
|
|
100
|
+
listener: EventMap[EventKey],
|
|
101
|
+
) => this;
|
|
102
|
+
removeAllListeners: <EventKey extends keyof EventMap = string>(event?: EventKey) => this;
|
|
103
|
+
setMaxListeners: (n: number) => this;
|
|
104
|
+
getMaxListeners: () => number;
|
|
105
|
+
listeners: <EventKey extends keyof EventMap = string>(event: EventKey) => EventMap[EventKey][];
|
|
106
|
+
rawListeners: <EventKey extends keyof EventMap = string>(
|
|
107
|
+
event: EventKey,
|
|
108
|
+
) => EventMap[EventKey][];
|
|
109
|
+
eventNames: () => Array<string | symbol>;
|
|
110
|
+
listenerCount: <EventKey extends keyof EventMap = string>(type: EventKey) => number;
|
|
111
|
+
addListenerBound: <EventKey extends keyof EventMap = string>(
|
|
112
|
+
event: EventKey,
|
|
113
|
+
listener: EventMap[EventKey],
|
|
114
|
+
bindTo?: any,
|
|
115
|
+
argsNum?: ArgsNum<EventMap[EventKey]>,
|
|
116
|
+
) => this;
|
|
117
|
+
removeListenerBound: <EventKey extends keyof EventMap = string>(
|
|
118
|
+
event: EventKey,
|
|
119
|
+
listener: EventMap[EventKey],
|
|
120
|
+
) => this;
|
|
121
|
+
}
|
|
122
|
+
export interface IEventEmitter<EventMap extends DefaultEventMap = DefaultEventMap> {
|
|
123
|
+
emit<EventKey extends keyof EventMap>(
|
|
124
|
+
event: EventKey,
|
|
125
|
+
...args: Parameters<EventMap[EventKey]>
|
|
126
|
+
): boolean;
|
|
127
|
+
on<EventKey extends keyof EventMap = string>(
|
|
128
|
+
event: EventKey,
|
|
129
|
+
listener: EventMap[EventKey],
|
|
130
|
+
): this;
|
|
131
|
+
once<EventKey extends keyof EventMap = string>(
|
|
132
|
+
event: EventKey,
|
|
133
|
+
listener: EventMap[EventKey],
|
|
134
|
+
): this;
|
|
135
|
+
addListener<EventKey extends keyof EventMap = string>(
|
|
136
|
+
event: EventKey,
|
|
137
|
+
listener: EventMap[EventKey],
|
|
138
|
+
): this;
|
|
139
|
+
removeListener<EventKey extends keyof EventMap = string>(
|
|
140
|
+
event: EventKey,
|
|
141
|
+
listener: EventMap[EventKey],
|
|
142
|
+
): this;
|
|
143
|
+
prependListener<EventKey extends keyof EventMap = string>(
|
|
144
|
+
event: EventKey,
|
|
145
|
+
listener: EventMap[EventKey],
|
|
146
|
+
): this;
|
|
147
|
+
prependOnceListener<EventKey extends keyof EventMap = string>(
|
|
148
|
+
event: EventKey,
|
|
149
|
+
listener: EventMap[EventKey],
|
|
150
|
+
): this;
|
|
151
|
+
off<EventKey extends keyof EventMap = string>(
|
|
152
|
+
event: EventKey,
|
|
153
|
+
listener: EventMap[EventKey],
|
|
154
|
+
): this;
|
|
155
|
+
removeAllListeners<EventKey extends keyof EventMap = string>(event?: EventKey): this;
|
|
156
|
+
setMaxListeners(n: number): this;
|
|
157
|
+
getMaxListeners(): number;
|
|
158
|
+
listeners<EventKey extends keyof EventMap = string>(event: EventKey): EventMap[EventKey][];
|
|
159
|
+
rawListeners<EventKey extends keyof EventMap = string>(event: EventKey): EventMap[EventKey][];
|
|
160
|
+
eventNames(): Array<string | symbol>;
|
|
161
|
+
listenerCount<EventKey extends keyof EventMap = string>(type: EventKey): number;
|
|
162
|
+
}
|
|
163
|
+
export type ArgsNum<T extends (...args: any[]) => any> = T extends (...args: infer K) => any
|
|
164
|
+
? K['length']
|
|
165
|
+
: never;
|
|
166
|
+
export type DefaultEventMap = {
|
|
167
|
+
[event in string | symbol]: Listener;
|
|
168
|
+
} & {
|
|
169
|
+
/**
|
|
170
|
+
* __proto__ key not allowed due to implementation
|
|
171
|
+
* add prefix, if you want to use this keyword
|
|
172
|
+
*/
|
|
173
|
+
__proto__?: never;
|
|
174
|
+
};
|
|
175
|
+
export type Listener = (...args: any[]) => Promise<any> | void;
|
package/src/utils.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Auto-generated by generate-plugin-sdk.ts - DO NOT EDIT
|
|
2
|
+
|
|
3
|
+
/** An object of shape `T` widened with an arbitrary string/number/symbol index. */
|
|
4
|
+
export type AnyProps<T extends Record<PropertyKey, any> = Record<PropertyKey, any>> = T &
|
|
5
|
+
Record<PropertyKey, any>;
|
|
6
|
+
/** Any supported colour string: a {@link HexColor} or {@link RgbaColor}. */
|
|
7
|
+
export type ColorString = HexColor | RgbaColor;
|
|
8
|
+
/** The set of all falsy values. */
|
|
9
|
+
export type Falsy = false | 0 | '' | null | undefined;
|
|
10
|
+
/** Any function: accepts any arguments and returns `T`. */
|
|
11
|
+
export type Fn<T = any> = (...args: any) => T;
|
|
12
|
+
/** A hexadecimal colour string prefixed with `#`. */
|
|
13
|
+
export type HexColor = `#${string}`;
|
|
14
|
+
/**
|
|
15
|
+
* A string union that keeps `T`'s literals for autocomplete while still accepting any other string.
|
|
16
|
+
* Use this for Discord's open-ended enums (typography variants, colour tokens, sizes) so newly added
|
|
17
|
+
* values keep type-checking without an update here.
|
|
18
|
+
*/
|
|
19
|
+
export type LiteralUnion<T extends string> = T | (string & {});
|
|
20
|
+
/** The result of a predicate: any {@link Truthy} or {@link Falsy} value. */
|
|
21
|
+
export type PredicateResult = Truthy | Falsy;
|
|
22
|
+
/** Any function returning a promise (`T` defaults to `Promise<any>`). */
|
|
23
|
+
export type PromiseFn<T = Promise<any>> = (...args: any) => T;
|
|
24
|
+
/** An `rgba(...)` colour string. */
|
|
25
|
+
export type RgbaColor = `rgba(${string})`;
|
|
26
|
+
/** The set of all truthy values. */
|
|
27
|
+
export type Truthy = true | number | string | object | symbol | bigint;
|
|
28
|
+
/** Widens a literal type to its primitive base (e.g. `'a'` to `string`, `1` to `number`). */
|
|
29
|
+
export type Widen<T> = T extends number
|
|
30
|
+
? number
|
|
31
|
+
: T extends string
|
|
32
|
+
? string
|
|
33
|
+
: T extends boolean
|
|
34
|
+
? boolean
|
|
35
|
+
: T;
|