@cedarjs/structure 2.8.1-next.116 → 2.8.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/README.md +1 -1
- package/dist/errors.js +15 -9
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +67 -40
- package/dist/model/RWCell.d.ts +4 -4
- package/dist/model/RWCell.d.ts.map +1 -1
- package/dist/model/RWCell.js +103 -111
- package/dist/model/RWComponent.d.ts +2 -2
- package/dist/model/RWComponent.d.ts.map +1 -1
- package/dist/model/RWComponent.js +41 -46
- package/dist/model/RWEnvHelper.d.ts +4 -4
- package/dist/model/RWEnvHelper.d.ts.map +1 -1
- package/dist/model/RWEnvHelper.js +205 -212
- package/dist/model/RWFunction.d.ts +2 -2
- package/dist/model/RWFunction.d.ts.map +1 -1
- package/dist/model/RWFunction.js +15 -10
- package/dist/model/RWLayout.d.ts +2 -2
- package/dist/model/RWLayout.d.ts.map +1 -1
- package/dist/model/RWLayout.js +15 -10
- package/dist/model/RWPage.d.ts +3 -3
- package/dist/model/RWPage.d.ts.map +1 -1
- package/dist/model/RWPage.js +57 -61
- package/dist/model/RWProject.d.ts +17 -11
- package/dist/model/RWProject.d.ts.map +1 -1
- package/dist/model/RWProject.js +164 -218
- package/dist/model/RWRoute.d.ts +5 -5
- package/dist/model/RWRoute.d.ts.map +1 -1
- package/dist/model/RWRoute.js +262 -312
- package/dist/model/RWRouter.d.ts +4 -4
- package/dist/model/RWRouter.d.ts.map +1 -1
- package/dist/model/RWRouter.js +126 -130
- package/dist/model/RWSDL.d.ts +5 -5
- package/dist/model/RWSDL.d.ts.map +1 -1
- package/dist/model/RWSDL.js +84 -96
- package/dist/model/RWSDLField.d.ts +6 -6
- package/dist/model/RWSDLField.d.ts.map +1 -1
- package/dist/model/RWSDLField.js +81 -79
- 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/RWServiceFunction.d.ts +4 -4
- package/dist/model/RWServiceFunction.d.ts.map +1 -1
- package/dist/model/RWServiceFunction.js +97 -95
- package/dist/model/RWTOML.d.ts +3 -3
- package/dist/model/RWTOML.d.ts.map +1 -1
- package/dist/model/RWTOML.js +55 -53
- package/dist/model/index.d.ts +2 -2
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +20 -3
- package/dist/model/util/process_env.js +62 -44
- package/dist/nodes.d.ts +2 -2
- package/dist/nodes.d.ts.map +1 -1
- package/dist/nodes.js +164 -171
- package/dist/util.js +33 -23
- package/dist/x/Array.js +25 -15
- package/dist/x/Location.d.ts +1 -1
- package/dist/x/Location.d.ts.map +1 -1
- package/dist/x/Location.js +17 -11
- package/dist/x/Position.js +29 -18
- package/dist/x/Range.d.ts +1 -1
- package/dist/x/Range.d.ts.map +1 -1
- package/dist/x/Range.js +22 -17
- package/dist/x/URL.js +75 -59
- 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 +49 -35
- package/dist/x/decorators.d.ts +2 -2
- package/dist/x/decorators.d.ts.map +1 -1
- package/dist/x/decorators.js +26 -46
- package/dist/x/diagnostics.d.ts +3 -3
- package/dist/x/diagnostics.d.ts.map +1 -1
- package/dist/x/diagnostics.js +259 -163
- package/dist/x/path.js +55 -36
- package/dist/x/prisma.d.ts +2 -2
- package/dist/x/prisma.d.ts.map +1 -1
- package/dist/x/prisma.js +55 -32
- package/dist/x/ts-morph.js +45 -34
- package/package.json +17 -38
- package/dist/errors.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/model/RWCell.js.map +0 -1
- package/dist/model/RWComponent.js.map +0 -1
- package/dist/model/RWEnvHelper.js.map +0 -1
- package/dist/model/RWFunction.js.map +0 -1
- package/dist/model/RWLayout.js.map +0 -1
- package/dist/model/RWPage.js.map +0 -1
- package/dist/model/RWProject.js.map +0 -1
- package/dist/model/RWRoute.js.map +0 -1
- package/dist/model/RWRouter.js.map +0 -1
- package/dist/model/RWSDL.js.map +0 -1
- package/dist/model/RWSDLField.js.map +0 -1
- package/dist/model/RWService.js.map +0 -1
- package/dist/model/RWServiceFunction.js.map +0 -1
- package/dist/model/RWTOML.js.map +0 -1
- package/dist/model/index.js.map +0 -1
- package/dist/model/util/process_env.js.map +0 -1
- package/dist/nodes.js.map +0 -1
- package/dist/util.js.map +0 -1
- package/dist/x/Array.js.map +0 -1
- package/dist/x/Location.js.map +0 -1
- package/dist/x/Position.js.map +0 -1
- package/dist/x/Range.js.map +0 -1
- package/dist/x/URL.js.map +0 -1
- package/dist/x/child_process.js.map +0 -1
- package/dist/x/decorators.js.map +0 -1
- package/dist/x/diagnostics.js.map +0 -1
- package/dist/x/path.js.map +0 -1
- package/dist/x/prisma.js.map +0 -1
- package/dist/x/ts-morph.js.map +0 -1
package/dist/model/RWTOML.js
CHANGED
|
@@ -1,54 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js/object/define-property");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard").default;
|
|
6
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.RWTOML = void 0;
|
|
10
|
+
var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/object/get-own-property-descriptor"));
|
|
11
|
+
var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/applyDecoratedDescriptor"));
|
|
12
|
+
var toml = _interopRequireWildcard(require("smol-toml"));
|
|
13
|
+
var _nodes = require("../nodes");
|
|
14
|
+
var _decorators = require("../x/decorators");
|
|
15
|
+
var _diagnostics = require("../x/diagnostics");
|
|
16
|
+
var _Range = require("../x/Range");
|
|
17
|
+
var _dec, _dec2, _class;
|
|
18
|
+
let RWTOML = exports.RWTOML = (_dec = (0, _decorators.lazy)(), _dec2 = (0, _decorators.lazy)(), _class = class RWTOML extends _nodes.FileNode {
|
|
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;
|
|
19
50
|
}
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
// TODO:
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
51
|
+
// at this point we know that the TOML was parsed successfully
|
|
52
|
+
//this.parsedTOML //?
|
|
53
|
+
//const allowedTopElements = ['web', 'api']
|
|
54
|
+
// TODO: check that schema is correct
|
|
55
|
+
}
|
|
56
|
+
}, (0, _applyDecoratedDescriptor2.default)(_class.prototype, "parsedTOML", [_dec], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "parsedTOML"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "web_includeEnvironmentVariables", [_dec2], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "web_includeEnvironmentVariables"), _class.prototype), _class);
|
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';
|
|
2
|
+
export { RWRoute } from './RWRoute';
|
|
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,aAAa,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA"}
|
package/dist/model/index.js
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js/object/define-property");
|
|
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,49 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js/object/define-property");
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard").default;
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
6
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
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()));
|
|
9
25
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
26
|
+
function process_env_findInFile(filePath, text) {
|
|
27
|
+
if (!(0, _includes.default)(text).call(text, 'process.env')) {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
return process_env_findInFile2((0, _tsMorph2.createTSMSourceFile_cached)(filePath, text));
|
|
32
|
+
} catch {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
20
35
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
}
|
|
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;
|
|
40
44
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
if (tsm.Node.isPropertyAccessExpression(node)) {
|
|
46
|
+
results.push({
|
|
47
|
+
key: node.getName(),
|
|
48
|
+
node
|
|
49
|
+
});
|
|
50
|
+
} else if (tsm.Node.isElementAccessExpression(node)) {
|
|
51
|
+
const arg = node.getArgumentExpression();
|
|
52
|
+
if (arg && tsm.Node.isStringLiteral(arg)) {
|
|
53
|
+
results.push({
|
|
54
|
+
key: arg.getLiteralText(),
|
|
55
|
+
node
|
|
56
|
+
});
|
|
57
|
+
}
|
|
46
58
|
}
|
|
47
|
-
|
|
59
|
+
}
|
|
60
|
+
return results;
|
|
48
61
|
}
|
|
49
|
-
|
|
62
|
+
function is_process_env(n) {
|
|
63
|
+
if (!tsm.Node.isPropertyAccessExpression(n)) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
return n.getExpression().getText() === 'process' && n.getName() === 'env';
|
|
67
|
+
}
|
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';
|
|
3
|
+
import type { ExtendedDiagnostic } from './x/diagnostics';
|
|
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,WAAW,CAAA;AAE1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAMzD,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,182 +1,175 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js/object/define-property");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.FileNode = exports.BaseNode = void 0;
|
|
9
|
+
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/json/stringify"));
|
|
10
|
+
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/promise"));
|
|
11
|
+
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/map"));
|
|
12
|
+
var _flat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/flat"));
|
|
13
|
+
var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/filter"));
|
|
14
|
+
var _startsWith = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/starts-with"));
|
|
15
|
+
var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/object/get-own-property-descriptor"));
|
|
16
|
+
var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/applyDecoratedDescriptor"));
|
|
17
|
+
var _nodeFs = require("node:fs");
|
|
18
|
+
var _nodePath = require("node:path");
|
|
19
|
+
var _Array = require("./x/Array");
|
|
20
|
+
var _decorators = require("./x/decorators");
|
|
21
|
+
var _path = require("./x/path");
|
|
22
|
+
var _Range = require("./x/Range");
|
|
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 [];
|
|
23
70
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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;
|
|
71
|
+
try {
|
|
72
|
+
var _context;
|
|
73
|
+
const d1 = await this._diagnostics();
|
|
74
|
+
const dd = await _promise.default.all((0, _map.default)(_context = await this._children()).call(_context, c => c.collectDiagnostics(uri)));
|
|
75
|
+
const d2 = (0, _flat.default)(dd).call(dd);
|
|
76
|
+
let all = [...d1, ...d2];
|
|
77
|
+
if (uri) {
|
|
78
|
+
all = (0, _filter.default)(all).call(all, x => x.uri === uri);
|
|
79
|
+
}
|
|
80
|
+
return all;
|
|
81
|
+
} catch (e) {
|
|
82
|
+
const uri = this.closestContainingUri;
|
|
83
|
+
if (!uri) {
|
|
84
|
+
throw e;
|
|
85
|
+
}
|
|
86
|
+
const range = (0, _Range.Range_create)(0, 0, 0, 0);
|
|
87
|
+
return [{
|
|
88
|
+
uri,
|
|
89
|
+
diagnostic: {
|
|
90
|
+
message: e + '',
|
|
91
|
+
range
|
|
74
92
|
}
|
|
75
|
-
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
return true;
|
|
93
|
+
}];
|
|
79
94
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
if (this.parent) {
|
|
86
|
-
return this.parent.closestContainingUri;
|
|
87
|
-
}
|
|
88
|
-
return undefined;
|
|
95
|
+
}
|
|
96
|
+
bailOutOnCollection(uri) {
|
|
97
|
+
if (this.id === uri) {
|
|
98
|
+
return false;
|
|
89
99
|
}
|
|
90
|
-
|
|
91
|
-
|
|
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);
|
|
100
|
+
if ((0, _startsWith.default)(uri).call(uri, this.id)) {
|
|
101
|
+
return false;
|
|
132
102
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
get closestContainingUri() {
|
|
106
|
+
const {
|
|
107
|
+
uri
|
|
108
|
+
} = this;
|
|
109
|
+
if (uri) {
|
|
110
|
+
return uri;
|
|
138
111
|
}
|
|
139
|
-
|
|
140
|
-
|
|
112
|
+
if (this.parent) {
|
|
113
|
+
return this.parent.closestContainingUri;
|
|
141
114
|
}
|
|
142
|
-
|
|
143
|
-
|
|
115
|
+
return undefined;
|
|
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;
|
|
144
129
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if (
|
|
150
|
-
|
|
130
|
+
if ((0, _startsWith.default)(id).call(id, this.id)) {
|
|
131
|
+
for (const c of await this._children()) {
|
|
132
|
+
// depth first search by default
|
|
133
|
+
const cc = await c.findNode(id);
|
|
134
|
+
if (cc) {
|
|
135
|
+
return cc;
|
|
151
136
|
}
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
get basenameNoExt() {
|
|
155
|
-
return basenameNoExt(this.filePath);
|
|
137
|
+
}
|
|
156
138
|
}
|
|
157
|
-
|
|
158
|
-
|
|
139
|
+
return undefined;
|
|
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);
|
|
159
166
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
|
167
|
+
return (0, _tsMorph.createTSMSourceFile_cached)(this.filePath, this.text);
|
|
168
|
+
}
|
|
169
|
+
get basenameNoExt() {
|
|
170
|
+
return (0, _path.basenameNoExt)(this.filePath);
|
|
171
|
+
}
|
|
172
|
+
get basename() {
|
|
173
|
+
return (0, _nodePath.basename)(this.filePath);
|
|
174
|
+
}
|
|
175
|
+
}, (0, _applyDecoratedDescriptor2.default)(_class2.prototype, "uri", [_dec6], (0, _getOwnPropertyDescriptor.default)(_class2.prototype, "uri"), _class2.prototype), (0, _applyDecoratedDescriptor2.default)(_class2.prototype, "id", [_dec7], (0, _getOwnPropertyDescriptor.default)(_class2.prototype, "id"), _class2.prototype), (0, _applyDecoratedDescriptor2.default)(_class2.prototype, "text", [_dec8], (0, _getOwnPropertyDescriptor.default)(_class2.prototype, "text"), _class2.prototype), (0, _applyDecoratedDescriptor2.default)(_class2.prototype, "fileExists", [_dec9], (0, _getOwnPropertyDescriptor.default)(_class2.prototype, "fileExists"), _class2.prototype), (0, _applyDecoratedDescriptor2.default)(_class2.prototype, "sf", [_dec0], (0, _getOwnPropertyDescriptor.default)(_class2.prototype, "sf"), _class2.prototype), (0, _applyDecoratedDescriptor2.default)(_class2.prototype, "basenameNoExt", [_dec1], (0, _getOwnPropertyDescriptor.default)(_class2.prototype, "basenameNoExt"), _class2.prototype), (0, _applyDecoratedDescriptor2.default)(_class2.prototype, "basename", [_dec10], (0, _getOwnPropertyDescriptor.default)(_class2.prototype, "basename"), _class2.prototype), _class2);
|