@atscript/core 0.0.1
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/LICENSE +21 -0
- package/dist/index.cjs +3460 -0
- package/dist/index.d.ts +566 -0
- package/dist/index.mjs +3397 -0
- package/package.json +51 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,566 @@
|
|
|
1
|
+
interface TLexicalToken {
|
|
2
|
+
type: 'annotation' | 'comment' | 'punctuation' | 'identifier' | 'text' | 'number' | 'block' | 'unknown';
|
|
3
|
+
text: string;
|
|
4
|
+
children?: TLexicalToken[];
|
|
5
|
+
startOffset?: number;
|
|
6
|
+
endOffset?: number;
|
|
7
|
+
accepted?: boolean;
|
|
8
|
+
multiline?: boolean;
|
|
9
|
+
getRange: () => {
|
|
10
|
+
start: {
|
|
11
|
+
line: number;
|
|
12
|
+
character: number;
|
|
13
|
+
};
|
|
14
|
+
end: {
|
|
15
|
+
line: number;
|
|
16
|
+
character: number;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare class Token {
|
|
22
|
+
protected readonly _data: TLexicalToken;
|
|
23
|
+
constructor(_data: TLexicalToken);
|
|
24
|
+
toString(): string;
|
|
25
|
+
clone(replace: Partial<TLexicalToken>): Token;
|
|
26
|
+
get text(): string;
|
|
27
|
+
get type(): "number" | "annotation" | "comment" | "punctuation" | "identifier" | "text" | "block" | "unknown";
|
|
28
|
+
get range(): {
|
|
29
|
+
start: {
|
|
30
|
+
line: number;
|
|
31
|
+
character: number;
|
|
32
|
+
};
|
|
33
|
+
end: {
|
|
34
|
+
line: number;
|
|
35
|
+
character: number;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
get children(): TLexicalToken[];
|
|
39
|
+
get hasChildren(): boolean;
|
|
40
|
+
get multiline(): boolean | undefined;
|
|
41
|
+
fromPath?: string;
|
|
42
|
+
exported?: boolean;
|
|
43
|
+
isDefinition?: boolean;
|
|
44
|
+
isReference?: boolean;
|
|
45
|
+
imported?: boolean;
|
|
46
|
+
isProp?: boolean;
|
|
47
|
+
isChain?: boolean;
|
|
48
|
+
parentNode?: SemanticNode;
|
|
49
|
+
get isAnnotation(): boolean;
|
|
50
|
+
annotationRef?: Token;
|
|
51
|
+
index?: number;
|
|
52
|
+
blockType?: 'structure' | 'type' | 'import';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
interface TPluginManagers {
|
|
56
|
+
manager: PluginManager;
|
|
57
|
+
file?: string;
|
|
58
|
+
dependants: Set<string>;
|
|
59
|
+
}
|
|
60
|
+
declare class AtscriptRepo {
|
|
61
|
+
readonly root: string;
|
|
62
|
+
readonly sharedConfig?: TAtscriptConfigInput | undefined;
|
|
63
|
+
constructor(root?: string, sharedConfig?: TAtscriptConfigInput | undefined);
|
|
64
|
+
protected configFormat?: 'esm' | 'cjs';
|
|
65
|
+
protected readonly configs: Map<string, Promise<TPluginManagers>>;
|
|
66
|
+
protected readonly atscripts: Map<string, Promise<AtscriptDoc>>;
|
|
67
|
+
sharedPluginManager: TPluginManagers | undefined;
|
|
68
|
+
protected configFiles: Map<string, Promise<Partial<TAtscriptConfigInput & TAtscriptConfigOutput>>>;
|
|
69
|
+
getSharedPluginManager(): PluginManager | undefined;
|
|
70
|
+
getPrimitivesTags(): Promise<Set<string> | undefined>;
|
|
71
|
+
getUsedAnnotations(): Promise<Record<string, {
|
|
72
|
+
multiple?: boolean;
|
|
73
|
+
fromSpec?: boolean;
|
|
74
|
+
typeSet: Set<string>;
|
|
75
|
+
types: ({
|
|
76
|
+
type: "object";
|
|
77
|
+
props: Record<string, {
|
|
78
|
+
optional?: boolean;
|
|
79
|
+
type: "string" | "number" | "boolean" | "unknown";
|
|
80
|
+
}>;
|
|
81
|
+
} | {
|
|
82
|
+
optional?: boolean;
|
|
83
|
+
type: "string" | "number" | "boolean" | "unknown";
|
|
84
|
+
})[];
|
|
85
|
+
} | undefined>>;
|
|
86
|
+
loadPluginManagerFor(id: string): Promise<TPluginManagers>;
|
|
87
|
+
resolveConfig(id: string): Promise<TPluginManagers>;
|
|
88
|
+
openDocument(id: string, text?: string): Promise<AtscriptDoc>;
|
|
89
|
+
protected _openDocument(id: string, text?: string): Promise<AtscriptDoc>;
|
|
90
|
+
checkDoc(atscript: AtscriptDoc): Promise<void>;
|
|
91
|
+
checkImports(atscript: AtscriptDoc): Promise<void>;
|
|
92
|
+
checkImport(atscript: AtscriptDoc, from: Token, imports: Token[]): Promise<AtscriptDoc | undefined>;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
type TPunctuation = '\n' | '&' | '+' | ',' | '\\' | '-' | '.' | '/' | ':' | '=' | '?' | '|' | ';';
|
|
96
|
+
|
|
97
|
+
declare enum TSeverity {
|
|
98
|
+
Error = 1,
|
|
99
|
+
Warning = 2,
|
|
100
|
+
Info = 3,
|
|
101
|
+
Hint = 4
|
|
102
|
+
}
|
|
103
|
+
type TMessages = Array<{
|
|
104
|
+
severity: TSeverity;
|
|
105
|
+
message: string;
|
|
106
|
+
range: {
|
|
107
|
+
start: {
|
|
108
|
+
line: number;
|
|
109
|
+
character: number;
|
|
110
|
+
};
|
|
111
|
+
end: {
|
|
112
|
+
line: number;
|
|
113
|
+
character: number;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
tags?: Array<1 | 2>;
|
|
117
|
+
}>;
|
|
118
|
+
|
|
119
|
+
interface TOutput extends TOutputWithSource {
|
|
120
|
+
target: string;
|
|
121
|
+
}
|
|
122
|
+
declare function build(config: Partial<TAtscriptConfigInput>): Promise<BuildRepo>;
|
|
123
|
+
declare class BuildRepo {
|
|
124
|
+
private readonly rootDir;
|
|
125
|
+
private readonly repo;
|
|
126
|
+
private readonly docs;
|
|
127
|
+
constructor(rootDir: string, repo: AtscriptRepo, docs: AtscriptDoc[]);
|
|
128
|
+
diagnostics(): Promise<Map<string, TMessages>>;
|
|
129
|
+
generate(config: TAtscriptConfigOutput, docs?: AtscriptDoc[]): Promise<TOutput[]>;
|
|
130
|
+
write(config: TAtscriptConfigOutput, docs?: AtscriptDoc[]): Promise<TOutput[]>;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
interface TPluginOutput {
|
|
134
|
+
fileName: string;
|
|
135
|
+
content: string;
|
|
136
|
+
}
|
|
137
|
+
type TAtscriptRenderFormat = string;
|
|
138
|
+
interface TAtscriptPlugin {
|
|
139
|
+
name: string;
|
|
140
|
+
config?: (config: TAtscriptConfig) => Promise<TAtscriptConfig | undefined> | TAtscriptConfig | undefined;
|
|
141
|
+
resolve?: (id: string) => Promise<string | undefined> | string | undefined;
|
|
142
|
+
load?: (id: string) => Promise<string | undefined> | string | undefined;
|
|
143
|
+
onDocumnet?: (doc: AtscriptDoc) => Promise<void> | void;
|
|
144
|
+
render?: (doc: AtscriptDoc, format: TAtscriptRenderFormat) => Promise<TPluginOutput[]> | TPluginOutput[];
|
|
145
|
+
buildEnd?: (output: TOutput[], format: TAtscriptRenderFormat, repo: AtscriptRepo) => Promise<void> | void;
|
|
146
|
+
}
|
|
147
|
+
declare const createAtscriptPlugin: (plugin: TAtscriptPlugin) => TAtscriptPlugin;
|
|
148
|
+
|
|
149
|
+
interface TOutputWithSource extends TPluginOutput {
|
|
150
|
+
source: string;
|
|
151
|
+
}
|
|
152
|
+
declare class PluginManager {
|
|
153
|
+
private readonly cfg;
|
|
154
|
+
constructor(cfg: TAtscriptConfig);
|
|
155
|
+
private _config;
|
|
156
|
+
name: string;
|
|
157
|
+
protected _docConfig: TAtscriptDocConfig | undefined;
|
|
158
|
+
get plugins(): TAtscriptPlugin[];
|
|
159
|
+
getDocConfig(): Promise<TAtscriptDocConfig>;
|
|
160
|
+
config(config?: TAtscriptConfig): Promise<TAtscriptConfig>;
|
|
161
|
+
resolve(id: string): Promise<string | undefined>;
|
|
162
|
+
load(id: string): Promise<string>;
|
|
163
|
+
onDocumnet(doc: AtscriptDoc): Promise<void>;
|
|
164
|
+
render(doc: AtscriptDoc, format: TAtscriptRenderFormat): Promise<TOutputWithSource[]>;
|
|
165
|
+
buildEnd(output: TOutput[], format: TAtscriptRenderFormat, repo: AtscriptRepo): Promise<void>;
|
|
166
|
+
loopInAnnotationsSpec(cb: (name: string, a: AnnotationSpec) => void): Promise<void>;
|
|
167
|
+
private _loopInAnnotationsSpec;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
declare class IdRegistry {
|
|
171
|
+
readonly reserved: Set<string>;
|
|
172
|
+
readonly globalTypes: Set<string>;
|
|
173
|
+
readonly definitions: Map<string, Token>;
|
|
174
|
+
readonly duplicates: Set<Token>;
|
|
175
|
+
readonly forbidden: Set<Token>;
|
|
176
|
+
constructor(globalTypes?: string[]);
|
|
177
|
+
clear(): void;
|
|
178
|
+
registerDefinition(token?: Token): void;
|
|
179
|
+
isDefined(t: string | Token): boolean;
|
|
180
|
+
getErrors(): TMessages;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
type TSemanticToken = 'type' | 'identifier' | 'array' | 'export' | 'optional' | 'inner' | 'path' | 'from';
|
|
184
|
+
type TNodeEntity = 'interface' | 'type' | 'ref' | 'const' | 'prop' | 'structure' | 'tuple' | 'group' | 'array' | 'import' | 'primitive';
|
|
185
|
+
interface TAnnotationTokens {
|
|
186
|
+
name: string;
|
|
187
|
+
token: Token;
|
|
188
|
+
args: Token[];
|
|
189
|
+
}
|
|
190
|
+
interface TPrimitiveBaseConfig {
|
|
191
|
+
type?: TPrimitiveTypeDef;
|
|
192
|
+
documentation?: string;
|
|
193
|
+
tags?: string[];
|
|
194
|
+
expect?: {
|
|
195
|
+
min?: number;
|
|
196
|
+
max?: number;
|
|
197
|
+
int?: boolean;
|
|
198
|
+
minLength?: number;
|
|
199
|
+
maxLength?: number;
|
|
200
|
+
pattern?: string | RegExp | (string | RegExp)[];
|
|
201
|
+
message?: string;
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
interface TPrimitiveConfig extends TPrimitiveBaseConfig {
|
|
205
|
+
extensions?: {
|
|
206
|
+
[name: string]: Partial<TPrimitiveConfig>;
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
interface TPrimitiveTypeComplex {
|
|
210
|
+
kind: 'union' | 'intersection' | 'tuple';
|
|
211
|
+
items: TPrimitiveTypeDef[];
|
|
212
|
+
optional?: boolean;
|
|
213
|
+
}
|
|
214
|
+
interface TPrimitiveTypeArray {
|
|
215
|
+
kind: 'array';
|
|
216
|
+
of: TPrimitiveTypeDef;
|
|
217
|
+
optional?: boolean;
|
|
218
|
+
}
|
|
219
|
+
interface TPrimitiveTypeObject {
|
|
220
|
+
kind: 'object';
|
|
221
|
+
props: Record<string, TPrimitiveTypeDef>;
|
|
222
|
+
optional?: boolean;
|
|
223
|
+
}
|
|
224
|
+
type TPrimitiveTypeFinal = 'string' | 'number' | 'boolean' | 'void' | 'null';
|
|
225
|
+
type TPrimitiveTypeFinalOptional = {
|
|
226
|
+
kind: 'final';
|
|
227
|
+
value: TPrimitiveTypeFinal;
|
|
228
|
+
optional: true;
|
|
229
|
+
};
|
|
230
|
+
type TPrimitiveTypeDef = TPrimitiveTypeComplex | TPrimitiveTypeArray | TPrimitiveTypeObject | TPrimitiveTypeFinal | TPrimitiveTypeFinalOptional;
|
|
231
|
+
|
|
232
|
+
declare class SemanticPrimitiveNode extends SemanticNode {
|
|
233
|
+
private readonly _id;
|
|
234
|
+
readonly config: TPrimitiveConfig;
|
|
235
|
+
private readonly parentKey;
|
|
236
|
+
constructor(_id: string, config: TPrimitiveConfig, parentKey?: string);
|
|
237
|
+
protected applyAnnotations(): void;
|
|
238
|
+
readonly type?: 'union' | 'intersection' | 'tuple' | 'array' | 'object' | 'string' | 'number' | 'boolean' | 'void' | 'null';
|
|
239
|
+
get key(): string;
|
|
240
|
+
getAllTags(_processed?: Set<SemanticPrimitiveNode>): string[];
|
|
241
|
+
get id(): string;
|
|
242
|
+
get documentation(): string;
|
|
243
|
+
readonly props: Map<string, SemanticPrimitiveNode>;
|
|
244
|
+
readonly tags: Set<string>;
|
|
245
|
+
toString(level?: number, prefix?: string): string;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
interface ITokensIndex {
|
|
249
|
+
add: (token: Token) => void;
|
|
250
|
+
at: (line: number, character: number) => Token | undefined;
|
|
251
|
+
before: (line: number, character: number) => Token | undefined;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
interface TAtscriptDocConfig {
|
|
255
|
+
primitives?: Map<string, SemanticPrimitiveNode>;
|
|
256
|
+
annotations?: TAnnotationsTree;
|
|
257
|
+
unknownAnnotation?: 'allow' | 'warn' | 'error';
|
|
258
|
+
plugins?: TAtscriptPlugin[];
|
|
259
|
+
}
|
|
260
|
+
declare class AtscriptDoc {
|
|
261
|
+
readonly id: string;
|
|
262
|
+
readonly config: TAtscriptDocConfig;
|
|
263
|
+
private readonly manager?;
|
|
264
|
+
constructor(id: string, config: TAtscriptDocConfig, manager?: PluginManager | undefined);
|
|
265
|
+
get name(): string | undefined;
|
|
266
|
+
readonly registry: IdRegistry;
|
|
267
|
+
semanticMessages: TMessages;
|
|
268
|
+
messages: TMessages;
|
|
269
|
+
tokensIndex: ITokensIndex;
|
|
270
|
+
blocksIndex: ITokensIndex;
|
|
271
|
+
imports: Map<string, {
|
|
272
|
+
from: Token;
|
|
273
|
+
imports: Token[];
|
|
274
|
+
}>;
|
|
275
|
+
importedDefs: Map<string, Token>;
|
|
276
|
+
readonly exports: Map<string, SemanticNode>;
|
|
277
|
+
readonly dependencies: Set<AtscriptDoc>;
|
|
278
|
+
readonly dependants: Set<AtscriptDoc>;
|
|
279
|
+
referred: Token[];
|
|
280
|
+
readonly dependenciesMap: Map<string, AtscriptDoc>;
|
|
281
|
+
get primitives(): SemanticPrimitiveNode[];
|
|
282
|
+
render(format: TAtscriptRenderFormat): Promise<TOutputWithSource[] | undefined>;
|
|
283
|
+
resolveAnnotation(name: string): AnnotationSpec | undefined;
|
|
284
|
+
updateDependencies(docs: AtscriptDoc[]): void;
|
|
285
|
+
nodes: SemanticNode[];
|
|
286
|
+
private _text;
|
|
287
|
+
get text(): string;
|
|
288
|
+
update(text: string, debug?: boolean): void;
|
|
289
|
+
cleanup(): void;
|
|
290
|
+
private registerNodes;
|
|
291
|
+
resolvedAnnotations: Token[];
|
|
292
|
+
annotations: TAnnotationTokens[];
|
|
293
|
+
registerAnnotation(annotationTokens: TAnnotationTokens): void;
|
|
294
|
+
unwindType(name: string, chain?: string[] | Token[], watchCb?: (def: SemanticNode) => void, _tracked?: Set<SemanticNode>): {
|
|
295
|
+
doc: AtscriptDoc;
|
|
296
|
+
node?: SemanticNode;
|
|
297
|
+
def: SemanticNode;
|
|
298
|
+
} | undefined;
|
|
299
|
+
getUsageListAt(line: number, character: number): {
|
|
300
|
+
uri: string;
|
|
301
|
+
range: Token["range"];
|
|
302
|
+
token: Token;
|
|
303
|
+
}[] | undefined;
|
|
304
|
+
evalAnnotationsForNode(givenNode: SemanticNode): TAnnotationTokens[] | undefined;
|
|
305
|
+
usageListFor(token: Token): Array<{
|
|
306
|
+
uri: string;
|
|
307
|
+
range: Token['range'];
|
|
308
|
+
token: Token;
|
|
309
|
+
}> | undefined;
|
|
310
|
+
getDefinitionFor(token: Token): {
|
|
311
|
+
uri: string;
|
|
312
|
+
doc?: AtscriptDoc;
|
|
313
|
+
token?: Token;
|
|
314
|
+
} | undefined;
|
|
315
|
+
getToDefinitionAt(line: number, character: number): {
|
|
316
|
+
targetUri: string;
|
|
317
|
+
targetRange: {
|
|
318
|
+
start: {
|
|
319
|
+
line: number;
|
|
320
|
+
character: number;
|
|
321
|
+
};
|
|
322
|
+
end: {
|
|
323
|
+
line: number;
|
|
324
|
+
character: number;
|
|
325
|
+
};
|
|
326
|
+
};
|
|
327
|
+
targetSelectionRange: {
|
|
328
|
+
start: {
|
|
329
|
+
line: number;
|
|
330
|
+
character: number;
|
|
331
|
+
};
|
|
332
|
+
end: {
|
|
333
|
+
line: number;
|
|
334
|
+
character: number;
|
|
335
|
+
};
|
|
336
|
+
};
|
|
337
|
+
originSelectionRange: {
|
|
338
|
+
start: {
|
|
339
|
+
line: number;
|
|
340
|
+
character: number;
|
|
341
|
+
};
|
|
342
|
+
end: {
|
|
343
|
+
line: number;
|
|
344
|
+
character: number;
|
|
345
|
+
};
|
|
346
|
+
};
|
|
347
|
+
}[] | undefined;
|
|
348
|
+
registerImport({ from, imports, block }: {
|
|
349
|
+
from: Token;
|
|
350
|
+
imports: Token[];
|
|
351
|
+
block: Token;
|
|
352
|
+
}): void;
|
|
353
|
+
registerDefinition(token?: Token, asImport?: boolean): void;
|
|
354
|
+
getDeclarationOwnerNode(identifier: string): {
|
|
355
|
+
doc: AtscriptDoc;
|
|
356
|
+
node?: SemanticNode;
|
|
357
|
+
token?: Token;
|
|
358
|
+
} | undefined;
|
|
359
|
+
registerExport(node: SemanticNode): void;
|
|
360
|
+
registerMessage(token: Token, message: string, severity?: TSeverity, tag?: 'dim' | 'crossed'): void;
|
|
361
|
+
registerMessages(messages?: TMessages): void;
|
|
362
|
+
private _allMessages;
|
|
363
|
+
clearMessages(): void;
|
|
364
|
+
getUnusedTokens(): Token[];
|
|
365
|
+
getDiagMessages(): TMessages;
|
|
366
|
+
mergeIntersection(node: SemanticNode): SemanticNode;
|
|
367
|
+
mergeDefs(_left: SemanticNode, _right: SemanticNode): [SemanticNode] | [SemanticNode, SemanticNode];
|
|
368
|
+
mergeNodesAnnotations(left?: TAnnotationTokens[], right?: TAnnotationTokens[]): TAnnotationTokens[];
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
declare class SemanticNode {
|
|
372
|
+
entity: TNodeEntity;
|
|
373
|
+
constructor(entity: TNodeEntity);
|
|
374
|
+
protected tokens?: Map<TSemanticToken, Token>;
|
|
375
|
+
protected isGroup: boolean;
|
|
376
|
+
protected definition?: SemanticNode;
|
|
377
|
+
annotations?: TAnnotationTokens[];
|
|
378
|
+
annotationsCounter?: Map<string, number>;
|
|
379
|
+
registerAtDocument(doc: AtscriptDoc): void;
|
|
380
|
+
protected _documentation?: string;
|
|
381
|
+
setDocumentation(s: string): void;
|
|
382
|
+
get documentation(): string | undefined;
|
|
383
|
+
get id(): string | undefined;
|
|
384
|
+
get referredIdentifiers(): Token[];
|
|
385
|
+
getIdentifiersRecursive(node: SemanticNode): Token[];
|
|
386
|
+
countAnnotations(name: string): number;
|
|
387
|
+
annotate(name: string, token: Token): (arg: Token) => void;
|
|
388
|
+
get length(): number;
|
|
389
|
+
define(node: SemanticNode): this;
|
|
390
|
+
get def(): SemanticNode | undefined;
|
|
391
|
+
get identifier(): string | undefined;
|
|
392
|
+
saveToken(token: Token, semantic: TSemanticToken): this;
|
|
393
|
+
wrap(node: SemanticNode, token: Token): this;
|
|
394
|
+
token(s: TSemanticToken): Token | undefined;
|
|
395
|
+
has(s: TSemanticToken): boolean | undefined;
|
|
396
|
+
toString(level?: number, prefix?: string): string;
|
|
397
|
+
renderAnnotations(): string;
|
|
398
|
+
protected renderChildren(): string;
|
|
399
|
+
getDefinition(): SemanticNode | undefined;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
declare class SemanticArrayNode extends SemanticNode {
|
|
403
|
+
constructor();
|
|
404
|
+
get props(): Map<string, SemanticNode>;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
declare class SemanticConstNode extends SemanticNode {
|
|
408
|
+
constructor();
|
|
409
|
+
registerAtDocument(doc: AtscriptDoc): void;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
declare class SemanticGroup extends SemanticNode {
|
|
413
|
+
protected nodes: SemanticNode[];
|
|
414
|
+
private operator?;
|
|
415
|
+
isGroup: boolean;
|
|
416
|
+
constructor(nodes?: SemanticNode[], operator?: TPunctuation | undefined);
|
|
417
|
+
registerAtDocument(doc: AtscriptDoc): void;
|
|
418
|
+
get length(): number;
|
|
419
|
+
get first(): SemanticNode;
|
|
420
|
+
get op(): TPunctuation | undefined;
|
|
421
|
+
define(node: SemanticNode): this;
|
|
422
|
+
wrap(node: SemanticNode, token: Token): this;
|
|
423
|
+
unwrap(): SemanticNode[];
|
|
424
|
+
protected renderChildren(): string;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
declare class SemanticImportNode extends SemanticNode {
|
|
428
|
+
constructor();
|
|
429
|
+
registerAtDocument(doc: AtscriptDoc): void;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
declare class SemanticRefNode extends SemanticNode {
|
|
433
|
+
constructor();
|
|
434
|
+
get referredIdentifiers(): Token[];
|
|
435
|
+
protected _chain: Token[];
|
|
436
|
+
protected _dots: Token[];
|
|
437
|
+
registerAtDocument(doc: AtscriptDoc): void;
|
|
438
|
+
addChain(token: Token): void;
|
|
439
|
+
addDot(token: Token): void;
|
|
440
|
+
get chain(): Token[];
|
|
441
|
+
get hasChain(): boolean;
|
|
442
|
+
toString(level?: number, prefix?: string): string;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
declare class SemanticPropNode extends SemanticNode {
|
|
446
|
+
constructor();
|
|
447
|
+
registerAtDocument(doc: AtscriptDoc): void;
|
|
448
|
+
get nestedProps(): Map<string, SemanticPropNode> | undefined;
|
|
449
|
+
get nestedType(): SemanticRefNode | undefined;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
declare class SemanticInterfaceNode extends SemanticNode {
|
|
453
|
+
constructor();
|
|
454
|
+
registerAtDocument(doc: AtscriptDoc): void;
|
|
455
|
+
get props(): Map<string, SemanticPropNode>;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
declare class SemanticStructureNode extends SemanticGroup {
|
|
459
|
+
constructor();
|
|
460
|
+
readonly props: Map<string, SemanticPropNode>;
|
|
461
|
+
setProps(props: SemanticPropNode[]): void;
|
|
462
|
+
registerAtDocument(doc: AtscriptDoc): void;
|
|
463
|
+
addVirtualProp(opts: {
|
|
464
|
+
name: string;
|
|
465
|
+
type: string | SemanticNode;
|
|
466
|
+
documentation?: string;
|
|
467
|
+
refToken?: Token;
|
|
468
|
+
}): void;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
declare class SemanticTupleNode extends SemanticGroup {
|
|
472
|
+
constructor();
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
declare class SemanticTypeNode extends SemanticNode {
|
|
476
|
+
constructor();
|
|
477
|
+
registerAtDocument(doc: AtscriptDoc): void;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
declare const $n: {
|
|
481
|
+
SemanticGroup: typeof SemanticGroup;
|
|
482
|
+
SemanticInterfaceNode: typeof SemanticInterfaceNode;
|
|
483
|
+
SemanticTypeNode: typeof SemanticTypeNode;
|
|
484
|
+
SemanticRefNode: typeof SemanticRefNode;
|
|
485
|
+
SemanticConstNode: typeof SemanticConstNode;
|
|
486
|
+
SemanticPropNode: typeof SemanticPropNode;
|
|
487
|
+
SemanticStructureNode: typeof SemanticStructureNode;
|
|
488
|
+
SemanticTupleNode: typeof SemanticTupleNode;
|
|
489
|
+
SemanticArrayNode: typeof SemanticArrayNode;
|
|
490
|
+
SemanticImportNode: typeof SemanticImportNode;
|
|
491
|
+
SemanticPrimitiveNode: typeof SemanticPrimitiveNode;
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
declare function isGroup(node?: SemanticNode): node is SemanticGroup;
|
|
495
|
+
declare function isInterface(node?: SemanticNode): node is SemanticInterfaceNode;
|
|
496
|
+
declare function isType(node?: SemanticNode): node is SemanticTypeNode;
|
|
497
|
+
declare function isRef(node?: SemanticNode): node is SemanticRefNode;
|
|
498
|
+
declare function isConst(node?: SemanticNode): node is SemanticConstNode;
|
|
499
|
+
declare function isProp(node?: SemanticNode): node is SemanticPropNode;
|
|
500
|
+
declare function isStructure(node?: SemanticNode): node is SemanticStructureNode;
|
|
501
|
+
declare function isTuple(node?: SemanticNode): node is SemanticTupleNode;
|
|
502
|
+
declare function isArray(node?: SemanticNode): node is SemanticArrayNode;
|
|
503
|
+
declare function isImport(node?: SemanticNode): node is SemanticImportNode;
|
|
504
|
+
declare function isPrimitive(node?: SemanticNode): node is SemanticPrimitiveNode;
|
|
505
|
+
|
|
506
|
+
interface TAtscriptConfigInput {
|
|
507
|
+
rootDir: string;
|
|
508
|
+
entries?: string[];
|
|
509
|
+
primitives?: Record<string, TPrimitiveConfig>;
|
|
510
|
+
annotations?: TAnnotationsTree;
|
|
511
|
+
unknownAnnotation?: 'allow' | 'warn' | 'error';
|
|
512
|
+
plugins?: TAtscriptPlugin[];
|
|
513
|
+
include?: string[];
|
|
514
|
+
exclude?: string[];
|
|
515
|
+
}
|
|
516
|
+
interface TAtscriptConfigOutput {
|
|
517
|
+
format: TAtscriptRenderFormat;
|
|
518
|
+
outDir?: string;
|
|
519
|
+
}
|
|
520
|
+
type TAtscriptConfig = Partial<TAtscriptConfigInput & TAtscriptConfigOutput>;
|
|
521
|
+
interface TAnnotationsTree {
|
|
522
|
+
[key: string]: AnnotationSpec | TAnnotationsTree;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
declare function defineConfig(config: TAtscriptConfig): TAtscriptConfig;
|
|
526
|
+
|
|
527
|
+
declare function resolveConfigFile(docUri: string, _root?: string): Promise<string | undefined>;
|
|
528
|
+
declare function loadTsConfig(configFile: string, forceFormat?: 'cjs' | 'esm'): Promise<TAtscriptConfig>;
|
|
529
|
+
declare function loadConfig(configPath: string, forceFormat?: 'cjs' | 'esm'): Promise<TAtscriptConfig>;
|
|
530
|
+
|
|
531
|
+
interface TAnnotationArgument {
|
|
532
|
+
optional?: boolean;
|
|
533
|
+
name: string;
|
|
534
|
+
type: 'string' | 'number' | 'boolean';
|
|
535
|
+
description?: string;
|
|
536
|
+
values?: string[];
|
|
537
|
+
}
|
|
538
|
+
interface TAnnotationSpecConfig {
|
|
539
|
+
multiple?: boolean;
|
|
540
|
+
mergeStrategy?: 'append' | 'replace';
|
|
541
|
+
description?: string;
|
|
542
|
+
nodeType?: TNodeEntity[];
|
|
543
|
+
defType?: SemanticPrimitiveNode['type'][];
|
|
544
|
+
argument?: TAnnotationArgument[] | TAnnotationArgument;
|
|
545
|
+
validate?: (mainToken: Token, args: Token[], doc: AtscriptDoc) => TMessages | undefined;
|
|
546
|
+
modify?: (mainToken: Token, args: Token[], doc: AtscriptDoc) => void;
|
|
547
|
+
}
|
|
548
|
+
declare class AnnotationSpec {
|
|
549
|
+
readonly config: TAnnotationSpecConfig;
|
|
550
|
+
readonly __is_annotation_spec = true;
|
|
551
|
+
constructor(config: TAnnotationSpecConfig);
|
|
552
|
+
get arguments(): TAnnotationArgument[];
|
|
553
|
+
get argumentsSnippet(): string;
|
|
554
|
+
private validateType;
|
|
555
|
+
modify(mainToken: Token, args: Token[], doc: AtscriptDoc): void;
|
|
556
|
+
validate(mainToken: Token, args: Token[], doc: AtscriptDoc): TMessages | undefined;
|
|
557
|
+
renderDocs(index: number | string): string | undefined;
|
|
558
|
+
protected getDefaultValueForType(name: string, type: 'string' | 'number' | 'boolean'): string;
|
|
559
|
+
}
|
|
560
|
+
declare function isAnnotationSpec(a?: TAnnotationsTree | AnnotationSpec): a is AnnotationSpec;
|
|
561
|
+
declare function resolveAnnotation(name: string, annotationsTree?: TAnnotationsTree): AnnotationSpec | undefined;
|
|
562
|
+
|
|
563
|
+
declare function resolveAtscriptFromPath(from: string, id: string): string;
|
|
564
|
+
declare function getRelPath(fromUri: string, toUri: string): string;
|
|
565
|
+
|
|
566
|
+
export { $n, AnnotationSpec, AtscriptDoc, AtscriptRepo, BuildRepo, PluginManager, SemanticArrayNode, SemanticConstNode, SemanticGroup, SemanticImportNode, SemanticInterfaceNode, SemanticNode, SemanticPrimitiveNode, SemanticPropNode, SemanticRefNode, SemanticStructureNode, SemanticTupleNode, SemanticTypeNode, type TAnnotationArgument, type TAnnotationSpecConfig, type TAnnotationTokens, type TAnnotationsTree, type TAtscriptConfig, type TAtscriptConfigInput, type TAtscriptConfigOutput, type TAtscriptDocConfig, type TAtscriptPlugin, type TAtscriptRenderFormat, type TMessages, type TNodeEntity, type TOutput, type TOutputWithSource, type TPluginOutput, type TPrimitiveBaseConfig, type TPrimitiveConfig, type TPrimitiveTypeArray, type TPrimitiveTypeComplex, type TPrimitiveTypeDef, type TPrimitiveTypeFinal, type TPrimitiveTypeFinalOptional, type TPrimitiveTypeObject, type TSemanticToken, Token, build, createAtscriptPlugin, defineConfig, getRelPath, isAnnotationSpec, isArray, isConst, isGroup, isImport, isInterface, isPrimitive, isProp, isRef, isStructure, isTuple, isType, loadConfig, loadTsConfig, resolveAnnotation, resolveAtscriptFromPath, resolveConfigFile };
|