aboutsummaryrefslogtreecommitdiff
path: root/src/typings/type_decls.d
blob: 1a93bbe591badce59dfea449c2a9dad5a496f2a0 (plain)
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
216
217
218
219
220
221
222
223
224
//@ts-ignore
declare type PropertyKey = string | number | symbol;
interface Array<T> {
    length: number;
    toString(): string;
    toLocaleString(): string;
    pop(): T | undefined;
    push(...items: T[]): number;
    concat(...items: ConcatArray<T>[]): T[];
    concat(...items: (T | ConcatArray<T>)[]): T[];
    join(separator?: string): string;
    reverse(): T[];
    shift(): T | undefined;
    slice(start?: number, end?: number): T[];
    sort(compareFn?: (a: T, b: T) => number): this;
    splice(start: number, deleteCount?: number): T[];
    splice(start: number, deleteCount: number, ...items: T[]): T[];
    unshift(...items: T[]): number;
    indexOf(searchElement: T, fromIndex?: number): number;
    lastIndexOf(searchElement: T, fromIndex?: number): number;
    every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean;
    some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean;
    forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void;
    map<U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[];
    filter<S extends T>(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[];
    filter(callbackfn: (value: T, index: number, array: T[]) => any, thisArg?: any): T[];
    reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T;
    reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T;
    reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U;
    reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T;
    reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T;
    reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U;

    [n: number]: T;
}

interface Function {
    apply(this: Function, thisArg: any, argArray?: any): any;
    call(this: Function, thisArg: any, ...argArray: any[]): any;
    bind(this: Function, thisArg: any, ...argArray: any[]): any;
    toString(): string;

    prototype: any;
    readonly length: number;

    // Non-standard extensions
    arguments: any;
    caller: Function;
}
interface Boolean {
    valueOf(): boolean;
}
interface Number {
    toString(radix?: number): string;
    toFixed(fractionDigits?: number): string;
    toExponential(fractionDigits?: number): string;
    toPrecision(precision?: number): string;
    valueOf(): number;
}
interface IArguments {
    [index: number]: any;
    length: number;
    callee: Function;
}
interface RegExp {
    readonly flags: string;
    readonly sticky: boolean;
    readonly unicode: boolean;
}
interface Date {
    now() : string;
}
interface String {
    codePointAt(pos: number): number | undefined;
    includes(searchString: string, position?: number): boolean;
    endsWith(searchString: string, endPosition?: number): boolean;
    normalize(form: "NFC" | "NFD" | "NFKC" | "NFKD"): string;
    normalize(form?: string): string;
    repeat(count: number): string;
    replace(a:any, b:any):string; // bcz: fix this
    startsWith(searchString: string, position?: number): boolean;
    anchor(name: string): string;
    big(): string;
    blink(): string;
    bold(): string;
    fixed(): string;
    fontcolor(color: string): string;
    fontsize(size: number): string;
    fontsize(size: string): string;
    italics(): string;
    link(url: string): string;
    small(): string;
    strike(): string;
    sub(): string;
    sup(): string;
}
interface Object {
    constructor: Function;
    toString(): string;
    toLocaleString(): string;
    valueOf(): Object;
    hasOwnProperty(v: PropertyKey): boolean;
    isPrototypeOf(v: Object): boolean;
    propertyIsEnumerable(v: PropertyKey): boolean;
}
interface ConcatArray<T> {
    readonly length: number;
    readonly [n: number]: T;
    join(separator?: string): string;
    slice(start?: number, end?: number): T[];
}
interface URL {
    hash: string;
    host: string;
    hostname: string;
    href: string;
    readonly origin: string;
    password: string;
    pathname: string;
    port: string;
    protocol: string;
    search: string;
    username: string;
    toJSON(): string;
}
interface PromiseLike<T> {
    then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): PromiseLike<TResult1 | TResult2>;
}
interface Promise<T> {
    then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
    catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
}

declare const Update: unique symbol;
declare const Self: unique symbol;
declare const SelfProxy: unique symbol;
declare const DataSym: unique symbol;
declare const HandleUpdate: unique symbol;
declare const Id: unique symbol;
declare const OnUpdate: unique symbol;
declare const Parent: unique symbol;
declare const Copy: unique symbol;
declare const ToScriptString: unique symbol;

declare abstract class RefField {
    readonly [Id]: FieldId;

    constructor();
}

declare type FieldId = string;

declare abstract class ObjectField {
    abstract [Copy](): ObjectField;
}

declare abstract class URLField extends ObjectField {
    readonly url: URL;

    constructor(url: string);
    constructor(url: URL);
}

declare class RichTextField extends URLField { 
    [Copy](): ObjectField; 
    constructor(data:string, text: string);
}
declare class AudioField extends URLField { [Copy](): ObjectField; }
declare class VideoField extends URLField { [Copy](): ObjectField; }
declare class ImageField extends URLField { [Copy](): ObjectField; }
declare class WebField extends URLField { [Copy](): ObjectField; }
declare class PdfField extends URLField { [Copy](): ObjectField; }

declare const ComputedField: any;
declare const CompileScript: any;

// @ts-ignore
declare type Extract<T, U> = T extends U ? T : never;
declare type Field = number | string | boolean | ObjectField | RefField;
declare type FieldWaiting<T extends RefField = RefField> = T extends undefined ? never : Promise<T | undefined>;
declare type FieldResult<T extends Field = Field> = Opt<T> | FieldWaiting<Extract<T, RefField>>;

declare type Opt<T> = T | undefined;
declare class Doc extends RefField {
    constructor();

    [key: string]: FieldResult;
    // [ToScriptString](): string;
}

declare class List<T extends Field> extends ObjectField {
    constructor(fields?: T[]);
    [index: number]: T | (T extends RefField ? Promise<T> : never);
    [Copy](): ObjectField;
}

declare class InkField extends ObjectField {
    constructor(data:Array<{X:number, Y:number}>);
    [Copy](): ObjectField;
}

// @ts-ignore
declare const console: any;

interface DocumentOptions { }

declare const Docs: {
    ImageDocument(url: string, options?: DocumentOptions): Doc;
    VideoDocument(url: string, options?: DocumentOptions): Doc;
    TextDocument(options?: DocumentOptions): Doc;
    PdfDocument(url: string, options?: DocumentOptions): Doc;
    WebDocument(url: string, options?: DocumentOptions): Doc;
    HtmlDocument(html: string, options?: DocumentOptions): Doc;
    MapDocument(url: string, options?: DocumentOptions): Doc;
    KVPDocument(document: Doc, options?: DocumentOptions): Doc;
    FreeformDocument(documents: Doc[], options?: DocumentOptions): Doc;
    SchemaDocument(columns: string[], documents: Doc[], options?: DocumentOptions): Doc;
    TreeDocument(documents: Doc[], options?: DocumentOptions): Doc;
    StackingDocument(documents: Doc[], options?: DocumentOptions): Doc;
};

declare function idToDoc(id:string):any;
declare function assignDoc(doc:Doc, field:any, id:any):string;
declare function d(...args:any[]):any;