@cedarjs/structure 2.8.1-next.0 → 2.8.1-next.116
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/README.md +1 -1
- package/dist/errors.js +9 -15
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -67
- package/dist/index.js.map +1 -0
- package/dist/model/RWCell.d.ts +4 -4
- package/dist/model/RWCell.d.ts.map +1 -1
- package/dist/model/RWCell.js +111 -103
- package/dist/model/RWCell.js.map +1 -0
- package/dist/model/RWComponent.d.ts +2 -2
- package/dist/model/RWComponent.d.ts.map +1 -1
- package/dist/model/RWComponent.js +46 -41
- package/dist/model/RWComponent.js.map +1 -0
- package/dist/model/RWEnvHelper.d.ts +4 -4
- package/dist/model/RWEnvHelper.d.ts.map +1 -1
- package/dist/model/RWEnvHelper.js +212 -205
- package/dist/model/RWEnvHelper.js.map +1 -0
- package/dist/model/RWFunction.d.ts +2 -2
- package/dist/model/RWFunction.d.ts.map +1 -1
- package/dist/model/RWFunction.js +10 -15
- package/dist/model/RWFunction.js.map +1 -0
- package/dist/model/RWLayout.d.ts +2 -2
- package/dist/model/RWLayout.d.ts.map +1 -1
- package/dist/model/RWLayout.js +10 -15
- package/dist/model/RWLayout.js.map +1 -0
- package/dist/model/RWPage.d.ts +3 -3
- package/dist/model/RWPage.d.ts.map +1 -1
- package/dist/model/RWPage.js +61 -57
- package/dist/model/RWPage.js.map +1 -0
- package/dist/model/RWProject.d.ts +11 -17
- package/dist/model/RWProject.d.ts.map +1 -1
- package/dist/model/RWProject.js +218 -164
- package/dist/model/RWProject.js.map +1 -0
- package/dist/model/RWRoute.d.ts +5 -5
- package/dist/model/RWRoute.d.ts.map +1 -1
- package/dist/model/RWRoute.js +312 -262
- package/dist/model/RWRoute.js.map +1 -0
- package/dist/model/RWRouter.d.ts +4 -4
- package/dist/model/RWRouter.d.ts.map +1 -1
- package/dist/model/RWRouter.js +130 -126
- package/dist/model/RWRouter.js.map +1 -0
- package/dist/model/RWSDL.d.ts +5 -5
- package/dist/model/RWSDL.d.ts.map +1 -1
- package/dist/model/RWSDL.js +96 -84
- package/dist/model/RWSDL.js.map +1 -0
- package/dist/model/RWSDLField.d.ts +6 -6
- package/dist/model/RWSDLField.d.ts.map +1 -1
- package/dist/model/RWSDLField.js +79 -81
- package/dist/model/RWSDLField.js.map +1 -0
- package/dist/model/RWService.d.ts +4 -4
- package/dist/model/RWService.d.ts.map +1 -1
- package/dist/model/RWService.js +76 -76
- package/dist/model/RWService.js.map +1 -0
- package/dist/model/RWServiceFunction.d.ts +4 -4
- package/dist/model/RWServiceFunction.d.ts.map +1 -1
- package/dist/model/RWServiceFunction.js +95 -97
- package/dist/model/RWServiceFunction.js.map +1 -0
- package/dist/model/RWTOML.d.ts +3 -3
- package/dist/model/RWTOML.d.ts.map +1 -1
- package/dist/model/RWTOML.js +53 -55
- package/dist/model/RWTOML.js.map +1 -0
- package/dist/model/index.d.ts +2 -2
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +3 -20
- package/dist/model/index.js.map +1 -0
- package/dist/model/util/process_env.js +44 -62
- package/dist/model/util/process_env.js.map +1 -0
- package/dist/nodes.d.ts +2 -2
- package/dist/nodes.d.ts.map +1 -1
- package/dist/nodes.js +171 -164
- package/dist/nodes.js.map +1 -0
- package/dist/util.js +23 -33
- package/dist/util.js.map +1 -0
- package/dist/x/Array.js +15 -25
- package/dist/x/Array.js.map +1 -0
- package/dist/x/Location.d.ts +1 -1
- package/dist/x/Location.d.ts.map +1 -1
- package/dist/x/Location.js +11 -17
- package/dist/x/Location.js.map +1 -0
- package/dist/x/Position.js +18 -29
- package/dist/x/Position.js.map +1 -0
- package/dist/x/Range.d.ts +1 -1
- package/dist/x/Range.d.ts.map +1 -1
- package/dist/x/Range.js +17 -22
- package/dist/x/Range.js.map +1 -0
- package/dist/x/URL.js +59 -75
- package/dist/x/URL.js.map +1 -0
- package/dist/x/child_process.d.ts +1 -1
- package/dist/x/child_process.d.ts.map +1 -1
- package/dist/x/child_process.js +35 -49
- package/dist/x/child_process.js.map +1 -0
- package/dist/x/decorators.d.ts +2 -2
- package/dist/x/decorators.d.ts.map +1 -1
- package/dist/x/decorators.js +46 -26
- package/dist/x/decorators.js.map +1 -0
- package/dist/x/diagnostics.d.ts +3 -3
- package/dist/x/diagnostics.d.ts.map +1 -1
- package/dist/x/diagnostics.js +163 -259
- package/dist/x/diagnostics.js.map +1 -0
- package/dist/x/path.js +36 -55
- package/dist/x/path.js.map +1 -0
- package/dist/x/prisma.d.ts +2 -2
- package/dist/x/prisma.d.ts.map +1 -1
- package/dist/x/prisma.js +32 -55
- package/dist/x/prisma.js.map +1 -0
- package/dist/x/ts-morph.js +34 -45
- package/dist/x/ts-morph.js.map +1 -0
- package/package.json +38 -17
package/dist/model/RWTOML.js
CHANGED
|
@@ -1,56 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
constructor(filePath, parent) {
|
|
20
|
-
super();
|
|
21
|
-
this.filePath = filePath;
|
|
22
|
-
this.parent = parent;
|
|
23
|
-
}
|
|
24
|
-
// @lazy() get content(): TOML.JsonMap {
|
|
25
|
-
// return TOML.parse(this.text)
|
|
26
|
-
// }
|
|
27
|
-
// TODO: diagnostics
|
|
28
|
-
get parsedTOML() {
|
|
29
|
-
return toml.parse(this.text);
|
|
30
|
-
}
|
|
31
|
-
get web_includeEnvironmentVariables() {
|
|
32
|
-
return this.parsedTOML?.web?.['includeEnvironmentVariables'] ?? [];
|
|
33
|
-
}
|
|
34
|
-
*diagnostics() {
|
|
35
|
-
try {
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
37
|
-
this.parsedTOML;
|
|
38
|
-
} catch (e) {
|
|
39
|
-
const pos = {
|
|
40
|
-
line: e.line - 1,
|
|
41
|
-
character: e.column - 1
|
|
42
|
-
};
|
|
43
|
-
const range = (0, _Range.Range_create)(pos, pos);
|
|
44
|
-
// Forward the TOML parse error with correct location information
|
|
45
|
-
yield (0, _diagnostics.err)({
|
|
46
|
-
uri: this.uri,
|
|
47
|
-
range
|
|
48
|
-
}, 'TOML Parser Error: ' + e.message);
|
|
49
|
-
return;
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import * as toml from 'smol-toml';
|
|
8
|
+
import { FileNode } from '../nodes.js';
|
|
9
|
+
import { lazy } from '../x/decorators.js';
|
|
10
|
+
import { err } from '../x/diagnostics.js';
|
|
11
|
+
import { Range_create } from '../x/Range.js';
|
|
12
|
+
export class RWTOML extends FileNode {
|
|
13
|
+
filePath;
|
|
14
|
+
parent;
|
|
15
|
+
constructor(filePath, parent) {
|
|
16
|
+
super();
|
|
17
|
+
this.filePath = filePath;
|
|
18
|
+
this.parent = parent;
|
|
50
19
|
}
|
|
51
|
-
//
|
|
52
|
-
//this.
|
|
53
|
-
//
|
|
54
|
-
// TODO:
|
|
55
|
-
|
|
56
|
-
|
|
20
|
+
// @lazy() get content(): TOML.JsonMap {
|
|
21
|
+
// return TOML.parse(this.text)
|
|
22
|
+
// }
|
|
23
|
+
// TODO: diagnostics
|
|
24
|
+
get parsedTOML() {
|
|
25
|
+
return toml.parse(this.text);
|
|
26
|
+
}
|
|
27
|
+
get web_includeEnvironmentVariables() {
|
|
28
|
+
return this.parsedTOML?.web?.['includeEnvironmentVariables'] ?? [];
|
|
29
|
+
}
|
|
30
|
+
*diagnostics() {
|
|
31
|
+
try {
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
33
|
+
this.parsedTOML;
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
const pos = { line: e.line - 1, character: e.column - 1 };
|
|
37
|
+
const range = Range_create(pos, pos);
|
|
38
|
+
// Forward the TOML parse error with correct location information
|
|
39
|
+
yield err({ uri: this.uri, range }, 'TOML Parser Error: ' + e.message);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
// at this point we know that the TOML was parsed successfully
|
|
43
|
+
//this.parsedTOML //?
|
|
44
|
+
//const allowedTopElements = ['web', 'api']
|
|
45
|
+
// TODO: check that schema is correct
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
__decorate([
|
|
49
|
+
lazy()
|
|
50
|
+
], RWTOML.prototype, "parsedTOML", null);
|
|
51
|
+
__decorate([
|
|
52
|
+
lazy()
|
|
53
|
+
], RWTOML.prototype, "web_includeEnvironmentVariables", null);
|
|
54
|
+
//# sourceMappingURL=RWTOML.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RWTOML.js","sourceRoot":"","sources":["../../src/model/RWTOML.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAA;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAI5C,MAAM,OAAO,MAAO,SAAQ,QAAQ;IAEzB;IACA;IAFT,YACS,QAAgB,EAChB,MAAiB;QAExB,KAAK,EAAE,CAAA;QAHA,aAAQ,GAAR,QAAQ,CAAQ;QAChB,WAAM,GAAN,MAAM,CAAW;IAG1B,CAAC;IACD,wCAAwC;IACxC,iCAAiC;IACjC,IAAI;IACJ,oBAAoB;IACZ,IAAI,UAAU;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC9B,CAAC;IACO,IAAI,+BAA+B;QACzC,OAAO,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,6BAA6B,CAAC,IAAI,EAAE,CAAA;IACpE,CAAC;IACD,CAAC,WAAW;QACV,IAAI,CAAC;YACH,oEAAoE;YACpE,IAAI,CAAC,UAAU,CAAA;QACjB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,GAAG,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,GAAG,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAA;YACzD,MAAM,KAAK,GAAG,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;YACpC,iEAAiE;YACjE,MAAM,GAAG,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,qBAAqB,GAAG,CAAC,CAAC,OAAO,CAAC,CAAA;YACtE,OAAM;QACR,CAAC;QACD,8DAA8D;QAC9D,qBAAqB;QACrB,2CAA2C;QAC3C,qCAAqC;IACvC,CAAC;CACF;AAtBS;IAAP,IAAI,EAAE;wCAEN;AACO;IAAP,IAAI,EAAE;6DAEN"}
|
package/dist/model/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { RWProject } from './RWProject';
|
|
2
|
-
export { RWRoute } from './RWRoute';
|
|
1
|
+
export { RWProject } from './RWProject.js';
|
|
2
|
+
export { RWRoute } from './RWRoute.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA"}
|
package/dist/model/index.js
CHANGED
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
_Object$defineProperty(exports, "RWProject", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () {
|
|
10
|
-
return _RWProject.RWProject;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
_Object$defineProperty(exports, "RWRoute", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () {
|
|
16
|
-
return _RWRoute.RWRoute;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
var _RWProject = require("./RWProject");
|
|
20
|
-
var _RWRoute = require("./RWRoute");
|
|
1
|
+
export { RWProject } from './RWProject.js';
|
|
2
|
+
export { RWRoute } from './RWRoute.js';
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -1,67 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.process_env_findAll = process_env_findAll;
|
|
10
|
-
exports.process_env_findInFile = process_env_findInFile;
|
|
11
|
-
exports.process_env_findInFile2 = process_env_findInFile2;
|
|
12
|
-
require("core-js/modules/es.array.push.js");
|
|
13
|
-
var _flatMap = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/flat-map"));
|
|
14
|
-
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/includes"));
|
|
15
|
-
var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/filter"));
|
|
16
|
-
var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
17
|
-
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
18
|
-
var tsm = _interopRequireWildcard(require("ts-morph"));
|
|
19
|
-
var _path = require("../../x/path");
|
|
20
|
-
var _tsMorph2 = require("../../x/ts-morph");
|
|
21
|
-
function process_env_findAll(dir) {
|
|
22
|
-
var _context;
|
|
23
|
-
const globPath = _nodePath.default.join(dir, 'src/**/*.{js,ts,jsx,tsx}');
|
|
24
|
-
return (0, _flatMap.default)(_context = (0, _path.globSync)(globPath)).call(_context, file => process_env_findInFile(file, _nodeFs.default.readFileSync(file).toString()));
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import * as tsm from 'ts-morph';
|
|
4
|
+
import { globSync } from '../../x/path.js';
|
|
5
|
+
import { createTSMSourceFile_cached } from '../../x/ts-morph.js';
|
|
6
|
+
export function process_env_findAll(dir) {
|
|
7
|
+
const globPath = path.join(dir, 'src/**/*.{js,ts,jsx,tsx}');
|
|
8
|
+
return globSync(globPath).flatMap((file) => process_env_findInFile(file, fs.readFileSync(file).toString()));
|
|
25
9
|
}
|
|
26
|
-
function process_env_findInFile(filePath, text) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
function process_env_findInFile2(sf) {
|
|
37
|
-
var _context2;
|
|
38
|
-
const penvs = (0, _filter.default)(_context2 = sf.getDescendantsOfKind(tsm.SyntaxKind.PropertyAccessExpression)).call(_context2, is_process_env);
|
|
39
|
-
const results = [];
|
|
40
|
-
for (const penv of penvs) {
|
|
41
|
-
const node = penv.getParent();
|
|
42
|
-
if (!node) {
|
|
43
|
-
continue;
|
|
10
|
+
export function process_env_findInFile(filePath, text) {
|
|
11
|
+
if (!text.includes('process.env')) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
return process_env_findInFile2(createTSMSourceFile_cached(filePath, text));
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return [];
|
|
44
19
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
20
|
+
}
|
|
21
|
+
export function process_env_findInFile2(sf) {
|
|
22
|
+
const penvs = sf
|
|
23
|
+
.getDescendantsOfKind(tsm.SyntaxKind.PropertyAccessExpression)
|
|
24
|
+
.filter(is_process_env);
|
|
25
|
+
const results = [];
|
|
26
|
+
for (const penv of penvs) {
|
|
27
|
+
const node = penv.getParent();
|
|
28
|
+
if (!node) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (tsm.Node.isPropertyAccessExpression(node)) {
|
|
32
|
+
results.push({ key: node.getName(), node });
|
|
33
|
+
}
|
|
34
|
+
else if (tsm.Node.isElementAccessExpression(node)) {
|
|
35
|
+
const arg = node.getArgumentExpression();
|
|
36
|
+
if (arg && tsm.Node.isStringLiteral(arg)) {
|
|
37
|
+
results.push({ key: arg.getLiteralText(), node });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
58
40
|
}
|
|
59
|
-
|
|
60
|
-
return results;
|
|
41
|
+
return results;
|
|
61
42
|
}
|
|
62
43
|
function is_process_env(n) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
44
|
+
if (!tsm.Node.isPropertyAccessExpression(n)) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return n.getExpression().getText() === 'process' && n.getName() === 'env';
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=process_env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process_env.js","sourceRoot":"","sources":["../../../src/model/util/process_env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAE/B,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAA;AAEhE,MAAM,UAAU,mBAAmB,CAAC,GAAW;IAC7C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,0BAA0B,CAAC,CAAA;IAC3D,OAAO,QAAQ,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CACzC,sBAAsB,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC,CAC/D,CAAA;AACH,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,QAAgB,EAChB,IAAY;IAEZ,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;QAClC,OAAO,EAAE,CAAA;IACX,CAAC;IACD,IAAI,CAAC;QACH,OAAO,uBAAuB,CAAC,0BAA0B,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAA;IAC5E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAA;IACX,CAAC;AACH,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,EAAkB;IAElB,MAAM,KAAK,GAAG,EAAE;SACb,oBAAoB,CAAC,GAAG,CAAC,UAAU,CAAC,wBAAwB,CAAC;SAC7D,MAAM,CAAC,cAAc,CAAC,CAAA;IAEzB,MAAM,OAAO,GAAsC,EAAE,CAAA;IAErD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,EAAE,CAAA;QAC7B,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,SAAQ;QACV,CAAC;QACD,IAAI,GAAG,CAAC,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9C,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;QAC7C,CAAC;aAAM,IAAI,GAAG,CAAC,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,EAAE,CAAC;YACpD,MAAM,GAAG,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAA;YACxC,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC;gBACzC,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;YACnD,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,SAAS,cAAc,CAAC,CAAW;IACjC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5C,OAAO,KAAK,CAAA;IACd,CAAC;IACD,OAAO,CAAC,CAAC,aAAa,EAAE,CAAC,OAAO,EAAE,KAAK,SAAS,IAAI,CAAC,CAAC,OAAO,EAAE,KAAK,KAAK,CAAA;AAC3E,CAAC"}
|
package/dist/nodes.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as tsm from 'ts-morph';
|
|
2
|
-
import type { ArrayLike } from './x/Array';
|
|
3
|
-
import type { ExtendedDiagnostic } from './x/diagnostics';
|
|
2
|
+
import type { ArrayLike } from './x/Array.js';
|
|
3
|
+
import type { ExtendedDiagnostic } from './x/diagnostics.js';
|
|
4
4
|
export type NodeID = string;
|
|
5
5
|
export declare abstract class BaseNode {
|
|
6
6
|
/**
|
package/dist/nodes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../src/nodes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,GAAG,MAAM,UAAU,CAAA;AAGpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../src/nodes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,GAAG,MAAM,UAAU,CAAA;AAGpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAM5D,MAAM,MAAM,MAAM,GAAG,MAAM,CAAA;AAE3B,8BAAsB,QAAQ;IAC5B;;;;;;;;OAQG;IACH,QAAQ,KAAK,EAAE,IAAI,MAAM,CAAA;IACzB,QAAQ,KAAK,MAAM,IAAI,QAAQ,GAAG,SAAS,CAAA;IAE3C,MAAM,UAAO;IACb;;;OAGG;IACH,QAAQ,IAAI,SAAS,CAAC,QAAQ,CAAC;IAGvB,OAAO,CAAC,SAAS;IAIzB;;;OAGG;IACH,WAAW,IAAI,SAAS,CAAC,kBAAkB,CAAC;IAGpC,OAAO,CAAC,YAAY;IAI5B;;;OAGG;IAEG,kBAAkB,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAgCrE,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAUzC,IAAY,oBAAoB,IAAI,MAAM,GAAG,SAAS,CASrD;IAED;;;;;;OAMG;IAEG,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC;CAgB1D;AAED,8BAAsB,QAAS,SAAQ,QAAQ;IAC7C,QAAQ,KAAK,QAAQ,IAAI,MAAM,CAAA;IAC/B,IAAY,GAAG,IAAI,MAAM,CAExB;IACD;;OAEG;IACH,IAAY,EAAE,WAEb;IACD,IAAY,IAAI,WAEf;IACD,IAAY,UAAU,IAAI,OAAO,CAEhC;IACD;;OAEG;IACH,IAAY,EAAE,IAAI,GAAG,CAAC,UAAU,CAK/B;IACD,IAAY,aAAa,WAExB;IACD,IAAY,QAAQ,WAEnB;CACF"}
|
package/dist/nodes.js
CHANGED
|
@@ -1,175 +1,182 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var _tsMorph = require("./x/ts-morph");
|
|
24
|
-
var _URL = require("./x/URL");
|
|
25
|
-
var _dec, _dec2, _dec3, _dec4, _dec5, _class, _dec6, _dec7, _dec8, _dec9, _dec0, _dec1, _dec10, _class2;
|
|
26
|
-
let BaseNode = exports.BaseNode = (_dec = (0, _decorators.memo)(), _dec2 = (0, _decorators.memo)(), _dec3 = (0, _decorators.memo)(_stringify.default), _dec4 = (0, _decorators.lazy)(), _dec5 = (0, _decorators.memo)(), _class = class BaseNode {
|
|
27
|
-
constructor() {
|
|
28
|
-
this.exists = true;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Each node MUST have a unique ID.
|
|
32
|
-
* IDs have meaningful information.
|
|
33
|
-
*
|
|
34
|
-
* examples:
|
|
35
|
-
* - /path/to/project
|
|
36
|
-
* - /path/to/project/web/src/Routes.js
|
|
37
|
-
* - /path/to/project/web/src/Routes.js /route1
|
|
38
|
-
*/
|
|
39
|
-
/**
|
|
40
|
-
* Returns the children of this node.
|
|
41
|
-
* Override this.
|
|
42
|
-
*/
|
|
43
|
-
children() {
|
|
44
|
-
return [];
|
|
45
|
-
}
|
|
46
|
-
_children() {
|
|
47
|
-
return (0, _Array.ArrayLike_normalize)(this.children());
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Diagnostics for this node (must not include children's diagnostics).
|
|
52
|
-
* Override this.
|
|
53
|
-
*/
|
|
54
|
-
diagnostics() {
|
|
55
|
-
return [];
|
|
56
|
-
}
|
|
57
|
-
_diagnostics() {
|
|
58
|
-
return (0, _Array.ArrayLike_normalize)(this.diagnostics());
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Collects diagnostics for this node and all descendants.
|
|
63
|
-
* This is what you'll use to gather all the project diagnostics.
|
|
64
|
-
*/
|
|
65
|
-
async collectDiagnostics(uri) {
|
|
66
|
-
// TODO: catch runtime errors and add them as diagnostics
|
|
67
|
-
// TODO: we can parallelize this further
|
|
68
|
-
if (uri && this.bailOutOnCollection(uri)) {
|
|
69
|
-
return [];
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
8
|
+
import { basename } from 'node:path';
|
|
9
|
+
import { ArrayLike_normalize } from './x/Array.js';
|
|
10
|
+
import { lazy, memo } from './x/decorators.js';
|
|
11
|
+
import { basenameNoExt } from './x/path.js';
|
|
12
|
+
import { Range_create } from './x/Range.js';
|
|
13
|
+
import { createTSMSourceFile_cached } from './x/ts-morph.js';
|
|
14
|
+
import { URL_file } from './x/URL.js';
|
|
15
|
+
export class BaseNode {
|
|
16
|
+
exists = true;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the children of this node.
|
|
19
|
+
* Override this.
|
|
20
|
+
*/
|
|
21
|
+
children() {
|
|
22
|
+
return [];
|
|
70
23
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
24
|
+
_children() {
|
|
25
|
+
return ArrayLike_normalize(this.children());
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Diagnostics for this node (must not include children's diagnostics).
|
|
29
|
+
* Override this.
|
|
30
|
+
*/
|
|
31
|
+
diagnostics() {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
_diagnostics() {
|
|
35
|
+
return ArrayLike_normalize(this.diagnostics());
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Collects diagnostics for this node and all descendants.
|
|
39
|
+
* This is what you'll use to gather all the project diagnostics.
|
|
40
|
+
*/
|
|
41
|
+
async collectDiagnostics(uri) {
|
|
42
|
+
// TODO: catch runtime errors and add them as diagnostics
|
|
43
|
+
// TODO: we can parallelize this further
|
|
44
|
+
if (uri && this.bailOutOnCollection(uri)) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const d1 = await this._diagnostics();
|
|
49
|
+
const dd = await Promise.all((await this._children()).map((c) => c.collectDiagnostics(uri)));
|
|
50
|
+
const d2 = dd.flat();
|
|
51
|
+
let all = [...d1, ...d2];
|
|
52
|
+
if (uri) {
|
|
53
|
+
all = all.filter((x) => x.uri === uri);
|
|
54
|
+
}
|
|
55
|
+
return all;
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
const uri = this.closestContainingUri;
|
|
59
|
+
if (!uri) {
|
|
60
|
+
throw e;
|
|
61
|
+
}
|
|
62
|
+
const range = Range_create(0, 0, 0, 0);
|
|
63
|
+
return [
|
|
64
|
+
{
|
|
65
|
+
uri,
|
|
66
|
+
diagnostic: { message: e + '', range },
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
bailOutOnCollection(uri) {
|
|
72
|
+
if (this.id === uri) {
|
|
73
|
+
return false;
|
|
92
74
|
}
|
|
93
|
-
|
|
75
|
+
if (uri.startsWith(this.id)) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
return true;
|
|
94
79
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
80
|
+
get closestContainingUri() {
|
|
81
|
+
const { uri } = this;
|
|
82
|
+
if (uri) {
|
|
83
|
+
return uri;
|
|
84
|
+
}
|
|
85
|
+
if (this.parent) {
|
|
86
|
+
return this.parent.closestContainingUri;
|
|
87
|
+
}
|
|
88
|
+
return undefined;
|
|
99
89
|
}
|
|
100
|
-
|
|
101
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Finds a node by ID.
|
|
92
|
+
* The default algorithm tries to be economic and only create the necessary
|
|
93
|
+
* intermediate nodes.
|
|
94
|
+
* Subclasses can override this to add further optimizations.
|
|
95
|
+
* @param id
|
|
96
|
+
*/
|
|
97
|
+
async findNode(id) {
|
|
98
|
+
id = URL_file(id);
|
|
99
|
+
if (this.id === id) {
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
if (id.startsWith(this.id)) {
|
|
103
|
+
for (const c of await this._children()) {
|
|
104
|
+
// depth first search by default
|
|
105
|
+
const cc = await c.findNode(id);
|
|
106
|
+
if (cc) {
|
|
107
|
+
return cc;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
__decorate([
|
|
115
|
+
memo()
|
|
116
|
+
], BaseNode.prototype, "_children", null);
|
|
117
|
+
__decorate([
|
|
118
|
+
memo()
|
|
119
|
+
], BaseNode.prototype, "_diagnostics", null);
|
|
120
|
+
__decorate([
|
|
121
|
+
memo((...args) => JSON.stringify(args))
|
|
122
|
+
], BaseNode.prototype, "collectDiagnostics", null);
|
|
123
|
+
__decorate([
|
|
124
|
+
lazy()
|
|
125
|
+
], BaseNode.prototype, "closestContainingUri", null);
|
|
126
|
+
__decorate([
|
|
127
|
+
memo()
|
|
128
|
+
], BaseNode.prototype, "findNode", null);
|
|
129
|
+
export class FileNode extends BaseNode {
|
|
130
|
+
get uri() {
|
|
131
|
+
return URL_file(this.filePath);
|
|
102
132
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
} = this;
|
|
109
|
-
if (uri) {
|
|
110
|
-
return uri;
|
|
133
|
+
/**
|
|
134
|
+
* the ID of a FileNode is its file:// uri.
|
|
135
|
+
*/
|
|
136
|
+
get id() {
|
|
137
|
+
return this.uri;
|
|
111
138
|
}
|
|
112
|
-
|
|
113
|
-
|
|
139
|
+
get text() {
|
|
140
|
+
return readFileSync(this.filePath, { encoding: 'utf8' }).toString();
|
|
114
141
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Finds a node by ID.
|
|
120
|
-
* The default algorithm tries to be economic and only create the necessary
|
|
121
|
-
* intermediate nodes.
|
|
122
|
-
* Subclasses can override this to add further optimizations.
|
|
123
|
-
* @param id
|
|
124
|
-
*/
|
|
125
|
-
async findNode(id) {
|
|
126
|
-
id = (0, _URL.URL_file)(id);
|
|
127
|
-
if (this.id === id) {
|
|
128
|
-
return this;
|
|
142
|
+
get fileExists() {
|
|
143
|
+
return existsSync(this.filePath);
|
|
129
144
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if (
|
|
135
|
-
|
|
145
|
+
/**
|
|
146
|
+
* parsed ts-morph source file
|
|
147
|
+
*/
|
|
148
|
+
get sf() {
|
|
149
|
+
if (typeof this.text === 'undefined') {
|
|
150
|
+
throw new Error('undefined file ' + this.filePath);
|
|
136
151
|
}
|
|
137
|
-
|
|
152
|
+
return createTSMSourceFile_cached(this.filePath, this.text);
|
|
153
|
+
}
|
|
154
|
+
get basenameNoExt() {
|
|
155
|
+
return basenameNoExt(this.filePath);
|
|
138
156
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}, (0, _applyDecoratedDescriptor2.default)(_class.prototype, "_children", [_dec], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "_children"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "_diagnostics", [_dec2], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "_diagnostics"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "collectDiagnostics", [_dec3], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "collectDiagnostics"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "closestContainingUri", [_dec4], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "closestContainingUri"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "findNode", [_dec5], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "findNode"), _class.prototype), _class);
|
|
142
|
-
let FileNode = exports.FileNode = (_dec6 = (0, _decorators.lazy)(), _dec7 = (0, _decorators.lazy)(), _dec8 = (0, _decorators.lazy)(), _dec9 = (0, _decorators.lazy)(), _dec0 = (0, _decorators.lazy)(), _dec1 = (0, _decorators.lazy)(), _dec10 = (0, _decorators.lazy)(), _class2 = class FileNode extends BaseNode {
|
|
143
|
-
get uri() {
|
|
144
|
-
return (0, _URL.URL_file)(this.filePath);
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* the ID of a FileNode is its file:// uri.
|
|
148
|
-
*/
|
|
149
|
-
get id() {
|
|
150
|
-
return this.uri;
|
|
151
|
-
}
|
|
152
|
-
get text() {
|
|
153
|
-
return (0, _nodeFs.readFileSync)(this.filePath, {
|
|
154
|
-
encoding: 'utf8'
|
|
155
|
-
}).toString();
|
|
156
|
-
}
|
|
157
|
-
get fileExists() {
|
|
158
|
-
return (0, _nodeFs.existsSync)(this.filePath);
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* parsed ts-morph source file
|
|
162
|
-
*/
|
|
163
|
-
get sf() {
|
|
164
|
-
if (typeof this.text === 'undefined') {
|
|
165
|
-
throw new Error('undefined file ' + this.filePath);
|
|
157
|
+
get basename() {
|
|
158
|
+
return basename(this.filePath);
|
|
166
159
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
160
|
+
}
|
|
161
|
+
__decorate([
|
|
162
|
+
lazy()
|
|
163
|
+
], FileNode.prototype, "uri", null);
|
|
164
|
+
__decorate([
|
|
165
|
+
lazy()
|
|
166
|
+
], FileNode.prototype, "id", null);
|
|
167
|
+
__decorate([
|
|
168
|
+
lazy()
|
|
169
|
+
], FileNode.prototype, "text", null);
|
|
170
|
+
__decorate([
|
|
171
|
+
lazy()
|
|
172
|
+
], FileNode.prototype, "fileExists", null);
|
|
173
|
+
__decorate([
|
|
174
|
+
lazy()
|
|
175
|
+
], FileNode.prototype, "sf", null);
|
|
176
|
+
__decorate([
|
|
177
|
+
lazy()
|
|
178
|
+
], FileNode.prototype, "basenameNoExt", null);
|
|
179
|
+
__decorate([
|
|
180
|
+
lazy()
|
|
181
|
+
], FileNode.prototype, "basename", null);
|
|
182
|
+
//# sourceMappingURL=nodes.js.map
|