skir 1.2.5 → 1.2.7
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/casing.d.ts +5 -0
- package/dist/casing.js +23 -0
- package/dist/casing.js.map +1 -0
- package/dist/command_line_parser.d.ts +36 -0
- package/dist/command_line_parser.d.ts.map +1 -0
- package/dist/command_line_parser.js +240 -0
- package/dist/command_line_parser.js.map +1 -0
- package/dist/compatibility_checker.d.ts +74 -0
- package/dist/compatibility_checker.js +331 -0
- package/dist/compatibility_checker.js.map +1 -0
- package/dist/compiler.d.ts +3 -0
- package/dist/compiler.js +406 -0
- package/dist/compiler.js.map +1 -0
- package/dist/completion_helper.d.ts +27 -0
- package/dist/completion_helper.js +101 -0
- package/dist/completion_helper.js.map +1 -0
- package/dist/config.d.ts +18 -0
- package/dist/config.js +19 -0
- package/dist/config.js.map +1 -0
- package/dist/config_parser.d.ts +34 -0
- package/dist/config_parser.js +217 -0
- package/dist/config_parser.js.map +1 -0
- package/dist/definition_finder.d.ts +16 -0
- package/dist/definition_finder.js +375 -0
- package/dist/definition_finder.js.map +1 -0
- package/dist/dependency_manager.d.ts +14 -0
- package/dist/dependency_manager.js +109 -0
- package/dist/dependency_manager.js.map +1 -0
- package/dist/doc_comment_parser.d.ts +6 -0
- package/dist/doc_comment_parser.js +269 -0
- package/dist/doc_comment_parser.js.map +1 -0
- package/dist/doc_reference_resolver.d.ts +5 -0
- package/dist/doc_reference_resolver.js +232 -0
- package/dist/doc_reference_resolver.js.map +1 -0
- package/dist/error_renderer.d.ts +24 -0
- package/dist/error_renderer.js +326 -0
- package/dist/error_renderer.js.map +1 -0
- package/dist/exit_error.d.ts +8 -0
- package/dist/exit_error.d.ts.map +1 -0
- package/dist/exit_error.js +8 -0
- package/dist/exit_error.js.map +1 -0
- package/dist/expected_names.d.ts +11 -0
- package/dist/expected_names.js +34 -0
- package/dist/expected_names.js.map +1 -0
- package/dist/formatter.d.ts +28 -0
- package/dist/formatter.js +338 -0
- package/dist/formatter.js.map +1 -0
- package/dist/get_dependencies_flow.d.ts +40 -0
- package/dist/get_dependencies_flow.js +177 -0
- package/dist/get_dependencies_flow.js.map +1 -0
- package/dist/import_block_formatter.d.ts +3 -0
- package/dist/import_block_formatter.js +36 -0
- package/dist/import_block_formatter.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/io.d.ts +23 -0
- package/dist/io.d.ts.map +1 -0
- package/dist/io.js +58 -0
- package/dist/io.js.map +1 -0
- package/dist/literals.d.ts +12 -0
- package/dist/literals.js +96 -0
- package/dist/literals.js.map +1 -0
- package/dist/module_collector.d.ts +9 -0
- package/dist/module_collector.js +73 -0
- package/dist/module_collector.js.map +1 -0
- package/dist/module_set.d.ts +51 -0
- package/dist/module_set.js +1331 -0
- package/dist/module_set.js.map +1 -0
- package/dist/package_downloader.d.ts +4 -0
- package/dist/package_downloader.js +256 -0
- package/dist/package_downloader.js.map +1 -0
- package/dist/package_types.d.ts +30 -0
- package/dist/package_types.d.ts.map +1 -0
- package/dist/package_types.js +2 -0
- package/dist/package_types.js.map +1 -0
- package/dist/parser.d.ts +7 -0
- package/dist/parser.js +1335 -0
- package/dist/parser.js.map +1 -0
- package/dist/project_initializer.d.ts +2 -0
- package/dist/project_initializer.d.ts.map +1 -0
- package/dist/project_initializer.js +207 -0
- package/dist/project_initializer.js.map +1 -0
- package/dist/snapshotter.d.ts +16 -0
- package/dist/snapshotter.js +263 -0
- package/dist/snapshotter.js.map +1 -0
- package/dist/tokenizer.d.ts +18 -0
- package/dist/tokenizer.js +244 -0
- package/dist/tokenizer.js.map +1 -0
- package/package.json +2 -2
package/dist/io.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface FileReader {
|
|
2
|
+
readTextFile(path: string): string | undefined;
|
|
3
|
+
}
|
|
4
|
+
export interface FileWriter {
|
|
5
|
+
writeTextFile(path: string, contents: string): void;
|
|
6
|
+
}
|
|
7
|
+
export interface AsyncFileReader {
|
|
8
|
+
readTextFileAsync(path: string): Promise<string | undefined>;
|
|
9
|
+
}
|
|
10
|
+
export interface AsyncFileWriter {
|
|
11
|
+
writeTextFileAsync(path: string, contents: string): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
declare class RealFileSystem implements FileReader, FileWriter, AsyncFileReader, AsyncFileWriter {
|
|
14
|
+
readTextFile(path: string): string | undefined;
|
|
15
|
+
writeTextFile(path: string, contents: string): void;
|
|
16
|
+
readTextFileAsync(path: string): Promise<string | undefined>;
|
|
17
|
+
writeTextFileAsync(path: string, contents: string): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export declare const REAL_FILE_SYSTEM: RealFileSystem;
|
|
20
|
+
export declare function isDirectory(path: string): Promise<boolean>;
|
|
21
|
+
export declare function rewritePathForRendering(path: string): string;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=io.d.ts.map
|
package/dist/io.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"io.d.ts","sourceRoot":"","sources":["../src/io.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,UAAU;IACzB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CAChD;AAED,MAAM,WAAW,UAAU;IACzB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACrD;AAED,MAAM,WAAW,eAAe;IAC9B,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CAC9D;AAED,MAAM,WAAW,eAAe;IAC9B,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnE;AAED,cAAM,cACJ,YAAW,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,eAAe;IAEnE,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAgB9C,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAI7C,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAgB5D,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGxE;AAED,eAAO,MAAM,gBAAgB,gBAAuB,CAAC;AAErD,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAMhE;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO5D"}
|
package/dist/io.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as FileSystem from "fs";
|
|
2
|
+
import * as FileSystemPromises from "fs/promises";
|
|
3
|
+
import * as Paths from "path";
|
|
4
|
+
class RealFileSystem {
|
|
5
|
+
readTextFile(path) {
|
|
6
|
+
try {
|
|
7
|
+
return FileSystem.readFileSync(path, "utf-8");
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
if (error &&
|
|
11
|
+
typeof error === "object" &&
|
|
12
|
+
"code" in error &&
|
|
13
|
+
error.code === "ENOENT") {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
writeTextFile(path, contents) {
|
|
20
|
+
FileSystem.writeFileSync(path, contents, "utf-8");
|
|
21
|
+
}
|
|
22
|
+
async readTextFileAsync(path) {
|
|
23
|
+
try {
|
|
24
|
+
return await FileSystemPromises.readFile(path, "utf-8");
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
if (error &&
|
|
28
|
+
typeof error === "object" &&
|
|
29
|
+
"code" in error &&
|
|
30
|
+
error.code === "ENOENT") {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async writeTextFileAsync(path, contents) {
|
|
37
|
+
await FileSystemPromises.writeFile(path, contents, "utf-8");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export const REAL_FILE_SYSTEM = new RealFileSystem();
|
|
41
|
+
export async function isDirectory(path) {
|
|
42
|
+
try {
|
|
43
|
+
return (await FileSystemPromises.lstat(path)).isDirectory();
|
|
44
|
+
}
|
|
45
|
+
catch (_e) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export function rewritePathForRendering(path) {
|
|
50
|
+
if (Paths.isAbsolute(path) || /^\.{1,2}[/\\]$/.test(path)) {
|
|
51
|
+
return path;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
// To make it clear that it's a path, prepend "./"
|
|
55
|
+
return `.${Paths.sep}${path}`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=io.js.map
|
package/dist/io.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"io.js","sourceRoot":"","sources":["../src/io.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,IAAI,CAAC;AACjC,OAAO,KAAK,kBAAkB,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,KAAK,MAAM,MAAM,CAAC;AAkB9B,MAAM,cAAc;IAGlB,YAAY,CAAC,IAAY;QACvB,IAAI,CAAC;YACH,OAAO,UAAU,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAChD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IACE,KAAK;gBACL,OAAO,KAAK,KAAK,QAAQ;gBACzB,MAAM,IAAI,KAAK;gBACf,KAAK,CAAC,IAAI,KAAK,QAAQ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AAM,CAAC;QACN,kDAAkD;QAClD,OAAO,IAAI,KAAK,CAAC,GAAG,GAAG,IAAI,EAAE,CAAC;IAChC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type DenseJson, type Primitive } from "skir-internal";
|
|
2
|
+
export declare function valueHasPrimitiveType(token: string, expectedType: Primitive): boolean;
|
|
3
|
+
export declare function isStringLiteral(token: string): boolean;
|
|
4
|
+
export declare function literalValueToDenseJson(token: string, type: Primitive): DenseJson;
|
|
5
|
+
/**
|
|
6
|
+
* Assuming `token` is a literal value of primitive type, returns a string which
|
|
7
|
+
* uniquely identifies the value within the primitive type. The behavior is
|
|
8
|
+
* undefined if `token` does not match `type`.
|
|
9
|
+
* Use this function to check if two literal values are actually equal.
|
|
10
|
+
*/
|
|
11
|
+
export declare function literalValueToIdentity(token: string, type: Primitive): string;
|
|
12
|
+
//# sourceMappingURL=literals.d.ts.map
|
package/dist/literals.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { unquoteAndUnescape, } from "skir-internal";
|
|
2
|
+
export function valueHasPrimitiveType(token, expectedType) {
|
|
3
|
+
switch (expectedType) {
|
|
4
|
+
case "bool":
|
|
5
|
+
return token === "false" || token === "true";
|
|
6
|
+
case "bytes":
|
|
7
|
+
return (isStringLiteral(token) &&
|
|
8
|
+
/^hex:([0-9A-Fa-f]{2})*$/.test(unquoteAndUnescape(token)));
|
|
9
|
+
case "timestamp": {
|
|
10
|
+
if (!isStringLiteral(token)) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
const dateTime = unquoteAndUnescape(token);
|
|
14
|
+
const timestamp = Date.parse(dateTime).valueOf();
|
|
15
|
+
return (
|
|
16
|
+
// A timezone is required.
|
|
17
|
+
/(Z|[+-]\d\d:\d\d)$/.test(dateTime) &&
|
|
18
|
+
-8640000000000000 <= timestamp &&
|
|
19
|
+
timestamp <= 8640000000000000 &&
|
|
20
|
+
timestamp === Math.round(timestamp));
|
|
21
|
+
}
|
|
22
|
+
case "int32":
|
|
23
|
+
return isIntLiteral(token, BigInt(-2147483648), BigInt(2147483647));
|
|
24
|
+
case "int64":
|
|
25
|
+
return isIntLiteral(token, BigInt("-9223372036854775808"), BigInt("9223372036854775807"));
|
|
26
|
+
case "hash64":
|
|
27
|
+
return isIntLiteral(token, BigInt(0), BigInt("18446744073709551615"));
|
|
28
|
+
case "float32":
|
|
29
|
+
case "float64": {
|
|
30
|
+
if (isStringLiteral(token)) {
|
|
31
|
+
const stringLiteral = unquoteAndUnescape(token);
|
|
32
|
+
return (stringLiteral === "NaN" ||
|
|
33
|
+
stringLiteral === "Infinity" ||
|
|
34
|
+
stringLiteral === "-Infinity");
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
return /^[-0-9]/.test(token);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
case "string":
|
|
41
|
+
return isStringLiteral(token);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export function isStringLiteral(token) {
|
|
45
|
+
return /^['"]/.test(token);
|
|
46
|
+
}
|
|
47
|
+
function isIntLiteral(token, min, max) {
|
|
48
|
+
if (!/^-?[0-9]+$/.test(token)) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
const value = BigInt(token);
|
|
52
|
+
return min <= value && value <= max;
|
|
53
|
+
}
|
|
54
|
+
export function literalValueToDenseJson(token, type) {
|
|
55
|
+
switch (type) {
|
|
56
|
+
case "bool":
|
|
57
|
+
return token === "true" ? 1 : 0;
|
|
58
|
+
case "bytes": {
|
|
59
|
+
const string = unquoteAndUnescape(token);
|
|
60
|
+
return hexToBase64(string.substring(4));
|
|
61
|
+
}
|
|
62
|
+
case "timestamp": {
|
|
63
|
+
const dateTime = unquoteAndUnescape(token);
|
|
64
|
+
return Math.round(new Date(dateTime).valueOf());
|
|
65
|
+
}
|
|
66
|
+
case "int32":
|
|
67
|
+
case "float32":
|
|
68
|
+
case "float64": {
|
|
69
|
+
return isStringLiteral(token) ? unquoteAndUnescape(token) : Number(token);
|
|
70
|
+
}
|
|
71
|
+
case "int64":
|
|
72
|
+
case "hash64":
|
|
73
|
+
return String(BigInt(token));
|
|
74
|
+
case "string":
|
|
75
|
+
return unquoteAndUnescape(token);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Assuming `token` is a literal value of primitive type, returns a string which
|
|
80
|
+
* uniquely identifies the value within the primitive type. The behavior is
|
|
81
|
+
* undefined if `token` does not match `type`.
|
|
82
|
+
* Use this function to check if two literal values are actually equal.
|
|
83
|
+
*/
|
|
84
|
+
export function literalValueToIdentity(token, type) {
|
|
85
|
+
const denseJson = literalValueToDenseJson(token, type);
|
|
86
|
+
return typeof denseJson === "string" ? denseJson : JSON.stringify(denseJson);
|
|
87
|
+
}
|
|
88
|
+
function hexToBase64(hex) {
|
|
89
|
+
const bytes = new Uint8Array(hex.length / 2);
|
|
90
|
+
for (let i = 0; i < hex.length; i += 2) {
|
|
91
|
+
bytes[i / 2] = parseInt(hex.slice(i, i + 2), 16);
|
|
92
|
+
}
|
|
93
|
+
const binaryString = Array.from(bytes, (byte) => String.fromCharCode(byte)).join("");
|
|
94
|
+
return btoa(binaryString);
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=literals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"literals.js","sourceRoot":"","sources":["../src/literals.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,GAGnB,MAAM,eAAe,CAAC;AAEvB,MAAM,UAAU,qBAAqB,CACnC,KAAa,EACb,YAAuB;IAEvB,QAAQ,YAAY,EAAE,CAAC;QACrB,KAAK,MAAM;YACT,OAAO,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,MAAM,CAAC;QAC/C,KAAK,OAAO;YACV,OAAO,CACL,eAAe,CAAC,KAAK,CAAC;gBACtB,yBAAyB,CAAC,IAAI,CAAC,kBAAkB,CAAC,K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AAM,CAAC,KAAK,CAAC,CAAC;QAC5E,CAAC;QACD,KAAK,OAAO,CAAC;QACb,KAAK,QAAQ;YACX,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAC/B,KAAK,QAAQ;YACX,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAa,EAAE,IAAe;IACnE,MAAM,SAAS,GAAG,uBAAuB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACvD,OAAO,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;AAC/E,CAAC;AAED,SAAS,WAAW,CAAC,GAAW;IAC9B,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC7C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACvC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACnD,CAAC;IACD,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAC9C,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAC1B,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACX,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ModuleSet } from "./module_set.js";
|
|
2
|
+
export declare function collectModules(srcDir: string, dependencies: ModuleSet, cache?: ModuleSet): Promise<ModuleSet>;
|
|
3
|
+
export interface EditableModule {
|
|
4
|
+
readonly fullPath: string;
|
|
5
|
+
readonly modulePath: string;
|
|
6
|
+
readonly content: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function collectEditableModules(srcDir: string): Promise<ReadonlyArray<EditableModule>>;
|
|
9
|
+
//# sourceMappingURL=module_collector.d.ts.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { glob } from "glob";
|
|
2
|
+
import * as Paths from "path";
|
|
3
|
+
import { ExitError } from "./exit_error.js";
|
|
4
|
+
import { isDirectory, REAL_FILE_SYSTEM, rewritePathForRendering, } from "./io.js";
|
|
5
|
+
import { ModuleSet } from "./module_set.js";
|
|
6
|
+
export async function collectModules(srcDir, dependencies, cache) {
|
|
7
|
+
const modulePathToContent = new Map();
|
|
8
|
+
for (const [modulePath, module] of dependencies.modules) {
|
|
9
|
+
modulePathToContent.set(modulePath, module.result.sourceCode);
|
|
10
|
+
}
|
|
11
|
+
const editableModules = await collectEditableModules(srcDir);
|
|
12
|
+
for (const { modulePath, content } of editableModules) {
|
|
13
|
+
modulePathToContent.set(modulePath, content);
|
|
14
|
+
}
|
|
15
|
+
return ModuleSet.compile(modulePathToContent, cache ?? dependencies);
|
|
16
|
+
}
|
|
17
|
+
export async function collectEditableModules(srcDir) {
|
|
18
|
+
const skirFiles = await glob(Paths.join(srcDir, "**/*.skir"), {
|
|
19
|
+
withFileTypes: true,
|
|
20
|
+
});
|
|
21
|
+
if (skirFiles.length === 0) {
|
|
22
|
+
const isDir = await isDirectory(srcDir);
|
|
23
|
+
if (!isDir) {
|
|
24
|
+
throw new ExitError("Source directory does not exist: " + rewritePathForRendering(srcDir));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const modules = skirFiles
|
|
28
|
+
.filter((skirFile) => skirFile.isFile)
|
|
29
|
+
.map(async (skirFile) => {
|
|
30
|
+
const fullPath = skirFile.fullpath();
|
|
31
|
+
const relativePath = Paths.relative(srcDir, fullPath).replace(/\\/g, "/");
|
|
32
|
+
validate(relativePath);
|
|
33
|
+
const content = await REAL_FILE_SYSTEM.readTextFileAsync(fullPath);
|
|
34
|
+
if (content === undefined) {
|
|
35
|
+
throw new ExitError("Cannot read " + rewritePathForRendering(fullPath));
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
fullPath: fullPath,
|
|
39
|
+
modulePath: relativePath,
|
|
40
|
+
content: content,
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
return Promise.all(modules);
|
|
44
|
+
}
|
|
45
|
+
function validate(relativePath) {
|
|
46
|
+
const parts = relativePath.split("/");
|
|
47
|
+
for (let i = 0; i < parts.length; i++) {
|
|
48
|
+
const part = parts[i];
|
|
49
|
+
const path = parts.slice(0, i + 1).join("/");
|
|
50
|
+
if (i < parts.length - 1) {
|
|
51
|
+
if (i === 0 && part === "external") {
|
|
52
|
+
throw makeInvalidPathError(path, "directory", "cannot be 'external'");
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
const regex = /^[a-z_][a-z0-9_-]+$/;
|
|
56
|
+
if (!regex.test(part)) {
|
|
57
|
+
throw makeInvalidPathError(path, "directory", `must match ${regex.source}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const regex = /^[a-z_][a-z0-9_-]+\.skir$/;
|
|
63
|
+
if (!regex.test(part)) {
|
|
64
|
+
throw makeInvalidPathError(path, "file", `must match ${regex.source}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function makeInvalidPathError(path, kind, info) {
|
|
70
|
+
const message = `Invalid ${kind} name: skir-src/${path}; ${info}`;
|
|
71
|
+
return new ExitError(message);
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=module_collector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module_collector.js","sourceRoot":"","sources":["../src/module_collector.ts"],"names":[],"m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AAC,GAAG,CAAC,CAAC;QAC7C,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;gBACnC,MAAM,oBAAoB,CAAC,IAAI,EAAE,WAAW,EAAE,sBAAsB,CAAC,CAAC;YACxE,CAAC;iBAAM,CAAC;gBACN,MAAM,KAAK,GAAG,qBAAqB,CAAC;gBACpC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;oBACtB,MAAM,oBAAoB,CACxB,IAAI,EACJ,WAAW,EACX,cAAc,KAAK,CAAC,MAAM,EAAE,CAC7B,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,KAAK,GAAG,2BAA2B,CAAC;YAC1C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACtB,MAAM,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;YACzE,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,oBAAoB,CAC3B,IAAY,EACZ,IAA0B,EAC1B,IAAY;IAEZ,MAAM,OAAO,GAAG,WAAW,IAAI,mBAAmB,IAAI,KAAK,IAAI,EAAE,CAAC;IAClE,OAAO,IAAI,SAAS,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type Method, type Module, type RecordKey, type RecordLocation, type Result, type SkirError } from "skir-internal";
|
|
2
|
+
/**
|
|
3
|
+
* Result of compiling a set of modules. Immutable.
|
|
4
|
+
*
|
|
5
|
+
* Support incremental compilation by accepting an optional cache of the previous
|
|
6
|
+
* module set. This cache can be used to avoid re-parsing and re-resolving
|
|
7
|
+
* modules that haven't changed since the last compilation.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ModuleSet {
|
|
10
|
+
private readonly modulePathToContent;
|
|
11
|
+
private readonly parseMode;
|
|
12
|
+
private readonly completionMode?;
|
|
13
|
+
static compile(modulePathToContent: ReadonlyMap<string, string>, cache?: ModuleSet, parseMode?: "strict" | "lenient"): ModuleSet;
|
|
14
|
+
static compileForCompletion(currentModulePath: string, currentPosition: number, modulePathToContent: ReadonlyMap<string, string>, cache?: ModuleSet): Result<Module>;
|
|
15
|
+
constructor(modulePathToContent: ReadonlyMap<string, string>, cache: ModuleSet | undefined, parseMode: "strict" | "lenient", completionMode?: {
|
|
16
|
+
readonly modulePath: string;
|
|
17
|
+
readonly position: number;
|
|
18
|
+
} | undefined);
|
|
19
|
+
private parseAndResolve;
|
|
20
|
+
/** Called by `parseAndResolve` when the module is not in the map already. */
|
|
21
|
+
private doParseAndResolve;
|
|
22
|
+
private storeResolvedFieldTypes;
|
|
23
|
+
private storeFieldRecursivity;
|
|
24
|
+
private collectTypeDeps;
|
|
25
|
+
/**
|
|
26
|
+
* Verifies that the `key` field of every array type found in `topLevelType`
|
|
27
|
+
* is valid. Populates the `keyType` field of every field path.
|
|
28
|
+
*/
|
|
29
|
+
private validateArrayKeys;
|
|
30
|
+
private valueToDenseJson;
|
|
31
|
+
private structValueToDenseJson;
|
|
32
|
+
private enumValueToDenseJson;
|
|
33
|
+
private getDefaultJson;
|
|
34
|
+
finalize(): FinalizationResult;
|
|
35
|
+
private cache;
|
|
36
|
+
private readonly moduleBundles;
|
|
37
|
+
private readonly registry;
|
|
38
|
+
private readonly finalizationResult;
|
|
39
|
+
findRecordByNumber(recordNumber: number): RecordLocation | undefined;
|
|
40
|
+
findMethodByNumber(methodNumber: number): Method | undefined;
|
|
41
|
+
get recordMap(): ReadonlyMap<RecordKey, RecordLocation>;
|
|
42
|
+
get errors(): readonly SkirError[];
|
|
43
|
+
get modules(): ReadonlyMap<string, Result<Module>>;
|
|
44
|
+
}
|
|
45
|
+
interface FinalizationResult {
|
|
46
|
+
readonly modules: ReadonlyMap<string, Result<Module>>;
|
|
47
|
+
/** Errors aggregated across all modules. */
|
|
48
|
+
readonly errors: readonly SkirError[];
|
|
49
|
+
}
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=module_set.d.ts.map
|