@atscript/core 0.1.17 → 0.1.19

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/dist/index.d.ts CHANGED
@@ -18,6 +18,30 @@ interface TLexicalToken {
18
18
  };
19
19
  }
20
20
 
21
+ type TPunctuation = '\n' | '&' | '+' | ',' | '\\' | '.' | '/' | ':' | '=' | '?' | '|' | ';';
22
+
23
+ declare enum TSeverity {
24
+ Error = 1,
25
+ Warning = 2,
26
+ Info = 3,
27
+ Hint = 4
28
+ }
29
+ type TMessages = Array<{
30
+ severity: TSeverity;
31
+ message: string;
32
+ range: {
33
+ start: {
34
+ line: number;
35
+ character: number;
36
+ };
37
+ end: {
38
+ line: number;
39
+ character: number;
40
+ };
41
+ };
42
+ tags?: Array<1 | 2>;
43
+ }>;
44
+
21
45
  declare class Token {
22
46
  protected readonly _data: TLexicalToken;
23
47
  constructor(_data: TLexicalToken);
@@ -111,7 +135,7 @@ declare class AtscriptRepo {
111
135
  multiple?: boolean;
112
136
  fromSpec?: boolean;
113
137
  typeSet: Set<string>;
114
- types: ({
138
+ types: Array<{
115
139
  type: "object";
116
140
  props: Record<string, {
117
141
  optional?: boolean;
@@ -120,7 +144,7 @@ declare class AtscriptRepo {
120
144
  } | {
121
145
  optional?: boolean;
122
146
  type: "string" | "number" | "boolean" | "unknown";
123
- })[];
147
+ }>;
124
148
  } | undefined>>;
125
149
  loadPluginManagerFor(id: string): Promise<TPluginManagers>;
126
150
  resolveConfig(id: string): Promise<TPluginManagers>;
@@ -131,30 +155,6 @@ declare class AtscriptRepo {
131
155
  checkImport(atscript: AtscriptDoc, from: Token, imports: Token[], checked?: Set<string>): Promise<AtscriptDoc | undefined>;
132
156
  }
133
157
 
134
- type TPunctuation = '\n' | '&' | '+' | ',' | '\\' | '.' | '/' | ':' | '=' | '?' | '|' | ';';
135
-
136
- declare enum TSeverity {
137
- Error = 1,
138
- Warning = 2,
139
- Info = 3,
140
- Hint = 4
141
- }
142
- type TMessages = Array<{
143
- severity: TSeverity;
144
- message: string;
145
- range: {
146
- start: {
147
- line: number;
148
- character: number;
149
- };
150
- end: {
151
- line: number;
152
- character: number;
153
- };
154
- };
155
- tags?: Array<1 | 2>;
156
- }>;
157
-
158
158
  interface TOutput extends TOutputWithSource {
159
159
  target: string;
160
160
  }
@@ -175,12 +175,31 @@ interface TPluginOutput {
175
175
  content: string;
176
176
  }
177
177
  type TAtscriptRenderFormat = string;
178
+ /**
179
+ * Well-known render format for a plugin's primary output.
180
+ *
181
+ * When a `.as` file is saved in an editor (VSCode, etc.), the editor
182
+ * passes this format to `render()` and `buildEnd()`. Plugins should
183
+ * check for this value alongside their own format strings to produce
184
+ * output that is essential for the development experience — typically
185
+ * type declarations for the host language.
186
+ *
187
+ * @example
188
+ * ```ts
189
+ * render(doc, format) {
190
+ * if (format === 'dts' || format === DEFAULT_FORMAT) {
191
+ * return [{ fileName: `${doc.name}.d.ts`, content: renderTypes(doc) }]
192
+ * }
193
+ * }
194
+ * ```
195
+ */
196
+ declare const DEFAULT_FORMAT: TAtscriptRenderFormat;
178
197
  interface TAtscriptPlugin {
179
198
  name: string;
180
199
  config?: (config: TAtscriptConfig) => Promise<TAtscriptConfig | undefined> | TAtscriptConfig | undefined;
181
200
  resolve?: (id: string) => Promise<string | undefined> | string | undefined;
182
201
  load?: (id: string) => Promise<string | undefined> | string | undefined;
183
- onDocumnet?: (doc: AtscriptDoc) => Promise<void> | void;
202
+ onDocument?: (doc: AtscriptDoc) => Promise<void> | void;
184
203
  render?: (doc: AtscriptDoc, format: TAtscriptRenderFormat) => Promise<TPluginOutput[]> | TPluginOutput[];
185
204
  buildEnd?: (output: TOutput[], format: TAtscriptRenderFormat, repo: AtscriptRepo) => Promise<void> | void;
186
205
  }
@@ -200,7 +219,7 @@ declare class PluginManager {
200
219
  config(config?: TAtscriptConfig): Promise<TAtscriptConfig>;
201
220
  resolve(id: string): Promise<string | undefined>;
202
221
  load(id: string): Promise<string>;
203
- onDocumnet(doc: AtscriptDoc): Promise<void>;
222
+ onDocument(doc: AtscriptDoc): Promise<void>;
204
223
  render(doc: AtscriptDoc, format: TAtscriptRenderFormat): Promise<TOutputWithSource[]>;
205
224
  buildEnd(output: TOutput[], format: TAtscriptRenderFormat, repo: AtscriptRepo): Promise<void>;
206
225
  loopInAnnotationsSpec(cb: (name: string, a: AnnotationSpec) => void): Promise<void>;
@@ -244,9 +263,7 @@ interface TPrimitiveBaseConfig {
244
263
  };
245
264
  }
246
265
  interface TPrimitiveConfig extends TPrimitiveBaseConfig {
247
- extensions?: {
248
- [name: string]: Partial<TPrimitiveConfig>;
249
- };
266
+ extensions?: Record<string, Partial<TPrimitiveConfig>>;
250
267
  }
251
268
  interface TPrimitiveTypeComplex {
252
269
  kind: 'union' | 'intersection' | 'tuple';
@@ -265,11 +282,11 @@ interface TPrimitiveTypeObject {
265
282
  optional?: boolean;
266
283
  }
267
284
  type TPrimitiveTypeFinal = 'string' | 'number' | 'boolean' | 'void' | 'null' | 'phantom';
268
- type TPrimitiveTypeFinalOptional = {
285
+ interface TPrimitiveTypeFinalOptional {
269
286
  kind: 'final';
270
287
  value: TPrimitiveTypeFinal;
271
288
  optional: true;
272
- };
289
+ }
273
290
  type TPrimitiveTypeDef = TPrimitiveTypeComplex | TPrimitiveTypeArray | TPrimitiveTypeObject | TPrimitiveTypeFinal | TPrimitiveTypeFinalOptional;
274
291
 
275
292
  declare class SemanticNode {
@@ -732,7 +749,7 @@ interface TAnnotationSpecConfig {
732
749
  mergeStrategy?: 'append' | 'replace';
733
750
  description?: string;
734
751
  nodeType?: TNodeEntity[];
735
- defType?: SemanticPrimitiveNode['type'][];
752
+ defType?: Array<SemanticPrimitiveNode['type']>;
736
753
  argument?: TAnnotationArgument[] | TAnnotationArgument;
737
754
  validate?: (mainToken: Token, args: Token[], doc: AtscriptDoc) => TMessages | undefined;
738
755
  modify?: (mainToken: Token, args: Token[], doc: AtscriptDoc) => void;
@@ -755,5 +772,5 @@ declare function resolveAnnotation(name: string, annotationsTree?: TAnnotationsT
755
772
  declare function resolveAtscriptFromPath(from: string, id: string): string;
756
773
  declare function getRelPath(fromUri: string, toUri: string): string;
757
774
 
758
- export { $n, AnnotationSpec, AtscriptDoc, AtscriptRepo, BuildRepo, PluginManager, SemanticAnnotateNode, SemanticArrayNode, SemanticConstNode, SemanticGroup, SemanticImportNode, SemanticInterfaceNode, SemanticNode, SemanticPrimitiveNode, SemanticPropNode, SemanticRefNode, SemanticStructureNode, SemanticTupleNode, SemanticTypeNode, Token, build, createAtscriptPlugin, defineConfig, getRelPath, isAnnotate, isAnnotationSpec, isArray, isConst, isGroup, isImport, isInterface, isPrimitive, isProp, isRef, isStructure, isTuple, isType, loadConfig, loadTsConfig, resolveAnnotation, resolveAtscriptFromPath, resolveConfigFile };
775
+ export { $n, AnnotationSpec, AtscriptDoc, AtscriptRepo, BuildRepo, DEFAULT_FORMAT, PluginManager, SemanticAnnotateNode, SemanticArrayNode, SemanticConstNode, SemanticGroup, SemanticImportNode, SemanticInterfaceNode, SemanticNode, SemanticPrimitiveNode, SemanticPropNode, SemanticRefNode, SemanticStructureNode, SemanticTupleNode, SemanticTypeNode, Token, build, createAtscriptPlugin, defineConfig, getRelPath, isAnnotate, isAnnotationSpec, isArray, isConst, isGroup, isImport, isInterface, isPrimitive, isProp, isRef, isStructure, isTuple, isType, loadConfig, loadTsConfig, resolveAnnotation, resolveAtscriptFromPath, resolveConfigFile };
759
776
  export type { TAnnotationArgument, TAnnotationSpecConfig, TAnnotationTokens, TAnnotationsTree, TAtscriptConfig, TAtscriptConfigInput, TAtscriptConfigOutput, TAtscriptDocConfig, TAtscriptPlugin, TAtscriptRenderFormat, TMessages, TNodeEntity, TOutput, TOutputWithSource, TPluginManagers, TPluginOutput, TPrimitiveBaseConfig, TPrimitiveConfig, TPrimitiveTypeArray, TPrimitiveTypeComplex, TPrimitiveTypeDef, TPrimitiveTypeFinal, TPrimitiveTypeFinalOptional, TPrimitiveTypeObject, TSemanticToken };