This repository has been archived by the owner on Jul 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
215 lines (215 loc) · 8.82 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/// <reference path="env.d.ts" />
import { types } from './types';
import { jiFile, jiInputStream, jnHttpURLConnection } from '@grakkit/core-classes';
/** A pending task. */
export declare type future = {
tick: number;
args: any[];
script: Function;
};
/** File system utilities for a specific path. */
export declare type record = {
/** Returns an array of modifiers for the contents of the folder (if any) at the current path. */
readonly children: record[];
/** Creates a folder at the current path if no file or folder already exists there. */
directory(): record;
/** Creates a file at the current path if no file or folder already exists there. */
entry(): record;
/** Whether a file or folder exists at the current path or not. */
readonly exists: boolean;
/** Joins the current path and the given sub-path, and returns a new modifier for it. */
file(...sub: string[]): record;
/** Starting from the current path, removes parent folders upstream until a parent folder is non-empty. */
flush(): record;
/** The java file for the current path. */
io: jiFile;
/** Synchronously parses the JSON content (if any) of the file at the current path. */
json(async?: false): any;
/** Parses the JSON content (if any) of the file at the current path. */
json(async: true): Promise<any>;
/** The name of the current path. */
readonly name: string;
/** The current path. */
readonly path: string;
/** The record for the parent folder of the current path. */
readonly parent: record;
/** Synchronously returns the content (if any) of the file at the current path. */
read(async?: false): string;
/** Returns the content (if any) of the file at the current path. */
read(async: true): Promise<string>;
/** Removes and flushes the file or folder (if any) at the current path. */
remove(): record;
/** Whether the current path represents a folder, a file, or none of the above. */
readonly type: 'folder' | 'file' | 'none';
/** Synchronously writes the given content to the file (if any) at the current path. */
write(content: string, async?: false): record;
/** Writes the given content to the file (if any) at the current path. */
write(content: string, async: true): Promise<record>;
};
/** A web response. */
export declare type response = {
/** The connection instance used to make this request. */
net: jnHttpURLConnection;
/** Synchronously parses the JSON content (if any) of the response. */
json(async?: false): any;
/** Parses the JSON content (if any) of the response. */
json(async: true): Promise<any>;
/** Synchronously returns the content (if any) of the response. */
read(async?: false): string;
/** Returns the content (if any) of the response. */
read(async: true): Promise<string>;
/** Synchronously returns the response stream. */
stream(async?: false): jiInputStream;
/** Returns the response stream. */
stream(async: true): Promise<jiInputStream>;
};
/** A session container for this module. */
export declare const session: {
data: Map<string, any>;
load: Map<string, any>;
poly: {
index: number;
list: Map<number, future>;
};
task: {
list: Set<future>;
tick: number;
};
type: Map<keyof types, any>;
};
/** Imports the specified type from java. */
export declare function type<X extends keyof types>(name: X): types[X];
/** Converts array-like objects or iterators into arrays. */
export declare function array(object: any): any[];
/** Takes 2 arguments, an initial value and a chain method. Creates a callback function which takes 1 argument. The
* callback function passes its argument as well as a reference to the callback function itself into the chain
* method. Finally, the callback function is called with the initial value. */
export declare function chain<X, Y extends (input: X, chain: (object: X) => ReturnType<Y>) => any>(base: X, modifier: Y): void;
/** Stores data on a per-path basis. */
export declare function data(path: string, ...more: string[]): any;
/** Tools for creating a single-input developer tools terminal. */
export declare const dev: {
/** Executes the given code and returns the result. */
execute(context: any, ...args: string[]): string;
/** Returns a set of completions for the given input. */
complete(context: any, ...args: string[]): string[];
};
/** Sends a GET request to the given URL. */
export declare function fetch(link: string): response;
/** A utility wrapper for paths and files. */
export declare function file(path: string | record | jiFile, ...more: string[]): record;
/** Formatting tools for script feedback. */
export declare const format: {
/** Reformats complex error messages into layman-friendly ones. */
error(error: any): string;
/** A pretty-printer for JavaScript objects. */
output(object: any, condense?: boolean): string;
};
/** Imports classes from external files. */
export declare function load(path: string | record | jiFile, name: string): any;
export declare const regex: {
test(input: string, expression: string): any;
replace(input: string, expression: string, replacement: string): string;
};
/** Reloads the JS environment. */
export declare function reload(): void;
/** The root folder of the environment. */
export declare const root: record;
/** Recursively removes or replaces the circular references in an object. */
export declare function simplify(object: any, placeholder?: any, objects?: Set<any>): any;
/** Runs an async function in another thread. */
export declare function sync<X>(script: (...args: any[]) => Promise<X>): Promise<X>;
/** A simple task scheduler. */
export declare const task: {
/** Cancels a previously scheduled task. */
cancel(handle: future): void;
/** Schedules a task to run infinitely at a set interval. */
interval(script: Function, period?: number, ...args: any[]): {
tick: number;
args: any[];
script: Function;
};
/** Schedules a task to run after a set timeout. */
timeout(script: Function, period?: number, ...args: any[]): {
tick: number;
args: any[];
script: Function;
};
};
/** Moves or copies a file or folder to a new destination. */
export declare function transfer(from: string | record | jiFile, to: string | record | jiFile, operation: 'move' | 'copy'): Promise<void>;
/** Unzips the input stream's archive (if any) to a new destination. */
export declare function unzip(from: jiInputStream, to: string | record | jiFile): Promise<void>;
/** @deprecated */
export declare const core: {
array: typeof array;
chain: typeof chain;
console: {
/** Executes the given code and returns the result. */
execute(context: any, ...args: string[]): string;
/** Returns a set of completions for the given input. */
complete(context: any, ...args: string[]): string[];
};
data: typeof data;
dev: {
/** Executes the given code and returns the result. */
execute(context: any, ...args: string[]): string;
/** Returns a set of completions for the given input. */
complete(context: any, ...args: string[]): string[];
};
fetch: typeof fetch;
file: typeof file;
format: {
/** Reformats complex error messages into layman-friendly ones. */
error(error: any): string;
/** A pretty-printer for JavaScript objects. */
output(object: any, condense?: boolean): string;
};
meta: {
hook(script: Function): void;
load(path: string | record | jiFile, name: string): any;
push(script: Function): void;
root: record;
sync: typeof sync;
};
reload: typeof reload;
regex: {
test(input: string, expression: string): any;
replace(input: string, expression: string, replacement: string): string;
};
root: record;
simplify: typeof simplify;
session: {
data: Map<string, any>;
load: Map<string, any>;
poly: {
index: number;
list: Map<number, future>;
};
task: {
list: Set<future>;
tick: number;
};
type: Map<keyof types, any>;
};
sync: typeof sync;
task: {
/** Cancels a previously scheduled task. */
cancel(handle: future): void;
/** Schedules a task to run infinitely at a set interval. */
interval(script: Function, period?: number, ...args: any[]): {
tick: number;
args: any[];
script: Function;
};
/** Schedules a task to run after a set timeout. */
timeout(script: Function, period?: number, ...args: any[]): {
tick: number;
args: any[];
script: Function;
};
};
transfer: typeof transfer;
type: typeof type;
unzip: typeof unzip;
};