@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.
Files changed (110) hide show
  1. package/README.md +1 -1
  2. package/dist/errors.js +9 -15
  3. package/dist/errors.js.map +1 -0
  4. package/dist/index.d.ts +7 -7
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +40 -67
  7. package/dist/index.js.map +1 -0
  8. package/dist/model/RWCell.d.ts +4 -4
  9. package/dist/model/RWCell.d.ts.map +1 -1
  10. package/dist/model/RWCell.js +111 -103
  11. package/dist/model/RWCell.js.map +1 -0
  12. package/dist/model/RWComponent.d.ts +2 -2
  13. package/dist/model/RWComponent.d.ts.map +1 -1
  14. package/dist/model/RWComponent.js +46 -41
  15. package/dist/model/RWComponent.js.map +1 -0
  16. package/dist/model/RWEnvHelper.d.ts +4 -4
  17. package/dist/model/RWEnvHelper.d.ts.map +1 -1
  18. package/dist/model/RWEnvHelper.js +212 -205
  19. package/dist/model/RWEnvHelper.js.map +1 -0
  20. package/dist/model/RWFunction.d.ts +2 -2
  21. package/dist/model/RWFunction.d.ts.map +1 -1
  22. package/dist/model/RWFunction.js +10 -15
  23. package/dist/model/RWFunction.js.map +1 -0
  24. package/dist/model/RWLayout.d.ts +2 -2
  25. package/dist/model/RWLayout.d.ts.map +1 -1
  26. package/dist/model/RWLayout.js +10 -15
  27. package/dist/model/RWLayout.js.map +1 -0
  28. package/dist/model/RWPage.d.ts +3 -3
  29. package/dist/model/RWPage.d.ts.map +1 -1
  30. package/dist/model/RWPage.js +61 -57
  31. package/dist/model/RWPage.js.map +1 -0
  32. package/dist/model/RWProject.d.ts +11 -17
  33. package/dist/model/RWProject.d.ts.map +1 -1
  34. package/dist/model/RWProject.js +218 -164
  35. package/dist/model/RWProject.js.map +1 -0
  36. package/dist/model/RWRoute.d.ts +5 -5
  37. package/dist/model/RWRoute.d.ts.map +1 -1
  38. package/dist/model/RWRoute.js +312 -262
  39. package/dist/model/RWRoute.js.map +1 -0
  40. package/dist/model/RWRouter.d.ts +4 -4
  41. package/dist/model/RWRouter.d.ts.map +1 -1
  42. package/dist/model/RWRouter.js +130 -126
  43. package/dist/model/RWRouter.js.map +1 -0
  44. package/dist/model/RWSDL.d.ts +5 -5
  45. package/dist/model/RWSDL.d.ts.map +1 -1
  46. package/dist/model/RWSDL.js +96 -84
  47. package/dist/model/RWSDL.js.map +1 -0
  48. package/dist/model/RWSDLField.d.ts +6 -6
  49. package/dist/model/RWSDLField.d.ts.map +1 -1
  50. package/dist/model/RWSDLField.js +79 -81
  51. package/dist/model/RWSDLField.js.map +1 -0
  52. package/dist/model/RWService.d.ts +4 -4
  53. package/dist/model/RWService.d.ts.map +1 -1
  54. package/dist/model/RWService.js +76 -76
  55. package/dist/model/RWService.js.map +1 -0
  56. package/dist/model/RWServiceFunction.d.ts +4 -4
  57. package/dist/model/RWServiceFunction.d.ts.map +1 -1
  58. package/dist/model/RWServiceFunction.js +95 -97
  59. package/dist/model/RWServiceFunction.js.map +1 -0
  60. package/dist/model/RWTOML.d.ts +3 -3
  61. package/dist/model/RWTOML.d.ts.map +1 -1
  62. package/dist/model/RWTOML.js +53 -55
  63. package/dist/model/RWTOML.js.map +1 -0
  64. package/dist/model/index.d.ts +2 -2
  65. package/dist/model/index.d.ts.map +1 -1
  66. package/dist/model/index.js +3 -20
  67. package/dist/model/index.js.map +1 -0
  68. package/dist/model/util/process_env.js +44 -62
  69. package/dist/model/util/process_env.js.map +1 -0
  70. package/dist/nodes.d.ts +2 -2
  71. package/dist/nodes.d.ts.map +1 -1
  72. package/dist/nodes.js +171 -164
  73. package/dist/nodes.js.map +1 -0
  74. package/dist/util.js +23 -33
  75. package/dist/util.js.map +1 -0
  76. package/dist/x/Array.js +15 -25
  77. package/dist/x/Array.js.map +1 -0
  78. package/dist/x/Location.d.ts +1 -1
  79. package/dist/x/Location.d.ts.map +1 -1
  80. package/dist/x/Location.js +11 -17
  81. package/dist/x/Location.js.map +1 -0
  82. package/dist/x/Position.js +18 -29
  83. package/dist/x/Position.js.map +1 -0
  84. package/dist/x/Range.d.ts +1 -1
  85. package/dist/x/Range.d.ts.map +1 -1
  86. package/dist/x/Range.js +17 -22
  87. package/dist/x/Range.js.map +1 -0
  88. package/dist/x/URL.js +59 -75
  89. package/dist/x/URL.js.map +1 -0
  90. package/dist/x/child_process.d.ts +1 -1
  91. package/dist/x/child_process.d.ts.map +1 -1
  92. package/dist/x/child_process.js +35 -49
  93. package/dist/x/child_process.js.map +1 -0
  94. package/dist/x/decorators.d.ts +2 -2
  95. package/dist/x/decorators.d.ts.map +1 -1
  96. package/dist/x/decorators.js +46 -26
  97. package/dist/x/decorators.js.map +1 -0
  98. package/dist/x/diagnostics.d.ts +3 -3
  99. package/dist/x/diagnostics.d.ts.map +1 -1
  100. package/dist/x/diagnostics.js +163 -259
  101. package/dist/x/diagnostics.js.map +1 -0
  102. package/dist/x/path.js +36 -55
  103. package/dist/x/path.js.map +1 -0
  104. package/dist/x/prisma.d.ts +2 -2
  105. package/dist/x/prisma.d.ts.map +1 -1
  106. package/dist/x/prisma.js +32 -55
  107. package/dist/x/prisma.js.map +1 -0
  108. package/dist/x/ts-morph.js +34 -45
  109. package/dist/x/ts-morph.js.map +1 -0
  110. package/package.json +38 -17
@@ -1,56 +1,54 @@
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;
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
- // 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);
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,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IACvC,CAAC;CACF;AAtBS;IAAP,IAAI,EAAE;wCAEN;AACO;IAAP,IAAI,EAAE;6DAEN"}
@@ -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,aAAa,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA"}
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"}
@@ -1,20 +1,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
+ 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
- "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()));
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
- 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
- }
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
- 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
- }
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
- if (!tsm.Node.isPropertyAccessExpression(n)) {
64
- return false;
65
- }
66
- return n.getExpression().getText() === 'process' && n.getName() === 'env';
67
- }
44
+ if (!tsm.Node.isPropertyAccessExpression(n)) {
45
+ return false;
46
+ }
47
+ return n.getExpression().getText() === 'process' && n.getName() === 'env';
48
+ }
49
+ //# sourceMappingURL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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
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"n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/dist/nodes.js CHANGED
@@ -1,175 +1,182 @@
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 [];
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
- 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
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
- bailOutOnCollection(uri) {
97
- if (this.id === uri) {
98
- return false;
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
- if ((0, _startsWith.default)(uri).call(uri, this.id)) {
101
- return false;
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
- return true;
104
- }
105
- get closestContainingUri() {
106
- const {
107
- uri
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
- if (this.parent) {
113
- return this.parent.closestContainingUri;
139
+ get text() {
140
+ return readFileSync(this.filePath, { encoding: 'utf8' }).toString();
114
141
  }
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;
142
+ get fileExists() {
143
+ return existsSync(this.filePath);
129
144
  }
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;
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
- 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);
157
+ get basename() {
158
+ return basename(this.filePath);
166
159
  }
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);
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