@cedarjs/structure 2.8.1-next.109 → 2.8.1-rc.3

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 +15 -9
  3. package/dist/index.d.ts +7 -7
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +67 -40
  6. package/dist/model/RWCell.d.ts +4 -4
  7. package/dist/model/RWCell.d.ts.map +1 -1
  8. package/dist/model/RWCell.js +103 -111
  9. package/dist/model/RWComponent.d.ts +2 -2
  10. package/dist/model/RWComponent.d.ts.map +1 -1
  11. package/dist/model/RWComponent.js +41 -46
  12. package/dist/model/RWEnvHelper.d.ts +4 -4
  13. package/dist/model/RWEnvHelper.d.ts.map +1 -1
  14. package/dist/model/RWEnvHelper.js +205 -212
  15. package/dist/model/RWFunction.d.ts +2 -2
  16. package/dist/model/RWFunction.d.ts.map +1 -1
  17. package/dist/model/RWFunction.js +15 -10
  18. package/dist/model/RWLayout.d.ts +2 -2
  19. package/dist/model/RWLayout.d.ts.map +1 -1
  20. package/dist/model/RWLayout.js +15 -10
  21. package/dist/model/RWPage.d.ts +3 -3
  22. package/dist/model/RWPage.d.ts.map +1 -1
  23. package/dist/model/RWPage.js +57 -61
  24. package/dist/model/RWProject.d.ts +17 -11
  25. package/dist/model/RWProject.d.ts.map +1 -1
  26. package/dist/model/RWProject.js +164 -218
  27. package/dist/model/RWRoute.d.ts +5 -5
  28. package/dist/model/RWRoute.d.ts.map +1 -1
  29. package/dist/model/RWRoute.js +262 -312
  30. package/dist/model/RWRouter.d.ts +4 -4
  31. package/dist/model/RWRouter.d.ts.map +1 -1
  32. package/dist/model/RWRouter.js +126 -130
  33. package/dist/model/RWSDL.d.ts +5 -5
  34. package/dist/model/RWSDL.d.ts.map +1 -1
  35. package/dist/model/RWSDL.js +84 -96
  36. package/dist/model/RWSDLField.d.ts +6 -6
  37. package/dist/model/RWSDLField.d.ts.map +1 -1
  38. package/dist/model/RWSDLField.js +81 -79
  39. package/dist/model/RWService.d.ts +4 -4
  40. package/dist/model/RWService.d.ts.map +1 -1
  41. package/dist/model/RWService.js +76 -76
  42. package/dist/model/RWServiceFunction.d.ts +4 -4
  43. package/dist/model/RWServiceFunction.d.ts.map +1 -1
  44. package/dist/model/RWServiceFunction.js +97 -95
  45. package/dist/model/RWTOML.d.ts +3 -3
  46. package/dist/model/RWTOML.d.ts.map +1 -1
  47. package/dist/model/RWTOML.js +55 -53
  48. package/dist/model/index.d.ts +2 -2
  49. package/dist/model/index.d.ts.map +1 -1
  50. package/dist/model/index.js +20 -3
  51. package/dist/model/util/process_env.js +62 -44
  52. package/dist/nodes.d.ts +2 -2
  53. package/dist/nodes.d.ts.map +1 -1
  54. package/dist/nodes.js +164 -171
  55. package/dist/util.js +33 -23
  56. package/dist/x/Array.js +25 -15
  57. package/dist/x/Location.d.ts +1 -1
  58. package/dist/x/Location.d.ts.map +1 -1
  59. package/dist/x/Location.js +17 -11
  60. package/dist/x/Position.js +29 -18
  61. package/dist/x/Range.d.ts +1 -1
  62. package/dist/x/Range.d.ts.map +1 -1
  63. package/dist/x/Range.js +22 -17
  64. package/dist/x/URL.js +75 -59
  65. package/dist/x/child_process.d.ts +1 -1
  66. package/dist/x/child_process.d.ts.map +1 -1
  67. package/dist/x/child_process.js +49 -35
  68. package/dist/x/decorators.d.ts +2 -2
  69. package/dist/x/decorators.d.ts.map +1 -1
  70. package/dist/x/decorators.js +26 -46
  71. package/dist/x/diagnostics.d.ts +3 -3
  72. package/dist/x/diagnostics.d.ts.map +1 -1
  73. package/dist/x/diagnostics.js +259 -163
  74. package/dist/x/path.js +55 -36
  75. package/dist/x/prisma.d.ts +2 -2
  76. package/dist/x/prisma.d.ts.map +1 -1
  77. package/dist/x/prisma.js +55 -32
  78. package/dist/x/ts-morph.js +45 -34
  79. package/package.json +17 -38
  80. package/dist/errors.js.map +0 -1
  81. package/dist/index.js.map +0 -1
  82. package/dist/model/RWCell.js.map +0 -1
  83. package/dist/model/RWComponent.js.map +0 -1
  84. package/dist/model/RWEnvHelper.js.map +0 -1
  85. package/dist/model/RWFunction.js.map +0 -1
  86. package/dist/model/RWLayout.js.map +0 -1
  87. package/dist/model/RWPage.js.map +0 -1
  88. package/dist/model/RWProject.js.map +0 -1
  89. package/dist/model/RWRoute.js.map +0 -1
  90. package/dist/model/RWRouter.js.map +0 -1
  91. package/dist/model/RWSDL.js.map +0 -1
  92. package/dist/model/RWSDLField.js.map +0 -1
  93. package/dist/model/RWService.js.map +0 -1
  94. package/dist/model/RWServiceFunction.js.map +0 -1
  95. package/dist/model/RWTOML.js.map +0 -1
  96. package/dist/model/index.js.map +0 -1
  97. package/dist/model/util/process_env.js.map +0 -1
  98. package/dist/nodes.js.map +0 -1
  99. package/dist/util.js.map +0 -1
  100. package/dist/x/Array.js.map +0 -1
  101. package/dist/x/Location.js.map +0 -1
  102. package/dist/x/Position.js.map +0 -1
  103. package/dist/x/Range.js.map +0 -1
  104. package/dist/x/URL.js.map +0 -1
  105. package/dist/x/child_process.js.map +0 -1
  106. package/dist/x/decorators.js.map +0 -1
  107. package/dist/x/diagnostics.js.map +0 -1
  108. package/dist/x/path.js.map +0 -1
  109. package/dist/x/prisma.js.map +0 -1
  110. package/dist/x/ts-morph.js.map +0 -1
@@ -1,340 +1,290 @@
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 tsm from 'ts-morph';
8
- import { RWError } from '../errors.js';
9
- import { BaseNode } from '../nodes.js';
10
- import { validateRoutePath } from '../util.js';
11
- import { lazy } from '../x/decorators.js';
12
- import { err, LocationLike_toLocation } from '../x/diagnostics.js';
13
- export class RWRoute extends BaseNode {
14
- jsxNode;
15
- parent;
16
- constructor(
17
- /**
18
- * the <Route> tag
19
- */
20
- jsxNode, parent) {
21
- super();
22
- this.jsxNode = jsxNode;
23
- this.parent = parent;
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.RWRoute = void 0;
10
+ require("core-js/modules/es.json.parse.js");
11
+ var _startsWith = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/starts-with"));
12
+ var _endsWith = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/ends-with"));
13
+ var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/array/is-array"));
14
+ var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/filter"));
15
+ var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/map"));
16
+ var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/includes"));
17
+ var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/find"));
18
+ var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/object/get-own-property-descriptor"));
19
+ var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/applyDecoratedDescriptor"));
20
+ var tsm = _interopRequireWildcard(require("ts-morph"));
21
+ var _errors = require("../errors");
22
+ var _nodes = require("../nodes");
23
+ var _util = require("../util");
24
+ var _decorators = require("../x/decorators");
25
+ var _diagnostics = require("../x/diagnostics");
26
+ var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec0, _dec1, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _dec16, _dec17, _class;
27
+ let RWRoute = exports.RWRoute = (_dec = (0, _decorators.lazy)(), _dec2 = (0, _decorators.lazy)(), _dec3 = (0, _decorators.lazy)(), _dec4 = (0, _decorators.lazy)(), _dec5 = (0, _decorators.lazy)(), _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)(), _dec11 = (0, _decorators.lazy)(), _dec12 = (0, _decorators.lazy)(), _dec13 = (0, _decorators.lazy)(), _dec14 = (0, _decorators.lazy)(), _dec15 = (0, _decorators.lazy)(), _dec16 = (0, _decorators.lazy)(), _dec17 = (0, _decorators.lazy)(), _class = class RWRoute extends _nodes.BaseNode {
28
+ constructor(
29
+ /**
30
+ * the <Route> tag
31
+ */
32
+ jsxNode, parent) {
33
+ super();
34
+ this.jsxNode = jsxNode;
35
+ this.parent = parent;
36
+ }
37
+ get id() {
38
+ // we cannot rely on the "path" attribute of the node
39
+ // it might not be unique (which is an error state, but valid while editing)
40
+ return this.parent.id + ' ' + this.jsxNode.getStart();
41
+ }
42
+ get location() {
43
+ return (0, _diagnostics.LocationLike_toLocation)(this.jsxNode);
44
+ }
45
+ get isPrivate() {
46
+ const tagText = this.jsxNode.getParentIfKind(tsm.SyntaxKind.JsxElement)?.getOpeningElement()?.getTagNameNode()?.getText();
47
+ return tagText === 'Private' || tagText === 'PrivateSet';
48
+ }
49
+ get unauthenticated() {
50
+ if (!this.isPrivate) {
51
+ return undefined;
24
52
  }
25
- get id() {
26
- // we cannot rely on the "path" attribute of the node
27
- // it might not be unique (which is an error state, but valid while editing)
28
- return this.parent.id + ' ' + this.jsxNode.getStart();
53
+ const a = this.jsxNode.getParentIfKind(tsm.SyntaxKind.JsxElement)?.getOpeningElement().getAttribute('unauthenticated');
54
+ if (!a) {
55
+ return undefined;
29
56
  }
30
- get location() {
31
- return LocationLike_toLocation(this.jsxNode);
57
+ if (tsm.Node.isJsxAttribute(a)) {
58
+ const init = a.getInitializer();
59
+ if (tsm.Node.isStringLiteral(init)) {
60
+ return init.getLiteralValue();
61
+ }
32
62
  }
33
- get isPrivate() {
34
- const tagText = this.jsxNode
35
- .getParentIfKind(tsm.SyntaxKind.JsxElement)
36
- ?.getOpeningElement()
37
- ?.getTagNameNode()
38
- ?.getText();
39
- return tagText === 'Private' || tagText === 'PrivateSet';
63
+ return undefined;
64
+ }
65
+ get roles() {
66
+ if (!this.isPrivate) {
67
+ return undefined;
40
68
  }
41
- get unauthenticated() {
42
- if (!this.isPrivate) {
43
- return undefined;
44
- }
45
- const a = this.jsxNode
46
- .getParentIfKind(tsm.SyntaxKind.JsxElement)
47
- ?.getOpeningElement()
48
- .getAttribute('unauthenticated');
49
- if (!a) {
50
- return undefined;
51
- }
52
- if (tsm.Node.isJsxAttribute(a)) {
53
- const init = a.getInitializer();
54
- if (tsm.Node.isStringLiteral(init)) {
55
- return init.getLiteralValue();
56
- }
57
- }
58
- return undefined;
69
+ const a = this.jsxNode.getParentIfKind(tsm.SyntaxKind.JsxElement)?.getOpeningElement().getAttribute('roles');
70
+ if (!a) {
71
+ return undefined;
59
72
  }
60
- get roles() {
61
- if (!this.isPrivate) {
62
- return undefined;
63
- }
64
- const a = this.jsxNode
65
- .getParentIfKind(tsm.SyntaxKind.JsxElement)
66
- ?.getOpeningElement()
67
- .getAttribute('roles');
68
- if (!a) {
73
+ if (tsm.Node.isJsxAttribute(a)) {
74
+ const init = a.getInitializer();
75
+
76
+ // Handle string literals
77
+ if (tsm.Node.isStringLiteral(init)) {
78
+ const literalValue = init.getLiteralValue();
79
+
80
+ // Check if the string looks like an array with single quotes
81
+ if ((0, _startsWith.default)(literalValue).call(literalValue, '[') && (0, _endsWith.default)(literalValue).call(literalValue, ']')) {
82
+ try {
83
+ // Unescape the string by replacing single quotes with double quotes
84
+ const correctedLiteralValue = literalValue.replace(/'/g, '"');
85
+ // Attempt to parse as JSON array
86
+ const parsedValue = JSON.parse(correctedLiteralValue);
87
+ if ((0, _isArray.default)(parsedValue)) {
88
+ return parsedValue;
89
+ }
90
+ } catch {
91
+ // If parsing fails, return undefined
69
92
  return undefined;
93
+ }
70
94
  }
71
- if (tsm.Node.isJsxAttribute(a)) {
72
- const init = a.getInitializer();
73
- // Handle string literals
74
- if (tsm.Node.isStringLiteral(init)) {
75
- const literalValue = init.getLiteralValue();
76
- // Check if the string looks like an array with single quotes
77
- if (literalValue.startsWith('[') && literalValue.endsWith(']')) {
78
- try {
79
- // Unescape the string by replacing single quotes with double quotes
80
- const correctedLiteralValue = literalValue.replace(/'/g, '"');
81
- // Attempt to parse as JSON array
82
- const parsedValue = JSON.parse(correctedLiteralValue);
83
- if (Array.isArray(parsedValue)) {
84
- return parsedValue;
85
- }
86
- }
87
- catch {
88
- // If parsing fails, return undefined
89
- return undefined;
90
- }
91
- }
92
- // If not an array, return the string value
93
- return literalValue;
94
- }
95
- // Handle JSX expressions with array literals
96
- if (tsm.Node.isJsxExpression(init)) {
97
- const expr = init.getExpression();
98
- if (tsm.Node.isArrayLiteralExpression(expr)) {
99
- return expr
100
- .getElements()
101
- .map((element) => {
102
- if (tsm.Node.isStringLiteral(element)) {
103
- return element.getLiteralValue();
104
- }
105
- return undefined;
106
- })
107
- .filter((val) => val !== undefined);
108
- }
95
+
96
+ // If not an array, return the string value
97
+ return literalValue;
98
+ }
99
+
100
+ // Handle JSX expressions with array literals
101
+ if (tsm.Node.isJsxExpression(init)) {
102
+ const expr = init.getExpression();
103
+ if (tsm.Node.isArrayLiteralExpression(expr)) {
104
+ var _context, _context2;
105
+ return (0, _filter.default)(_context = (0, _map.default)(_context2 = expr.getElements()).call(_context2, element => {
106
+ if (tsm.Node.isStringLiteral(element)) {
107
+ return element.getLiteralValue();
109
108
  }
109
+ return undefined;
110
+ })).call(_context, val => val !== undefined);
110
111
  }
111
- return undefined;
112
+ }
112
113
  }
113
- get hasParameters() {
114
- if (!this.path) {
115
- return false;
116
- }
117
- // KLUDGE: we need a good path parsing library here
118
- return this.path.includes('{');
114
+ return undefined;
115
+ }
116
+ get hasParameters() {
117
+ var _context3;
118
+ if (!this.path) {
119
+ return false;
119
120
  }
120
- get hasPrerender() {
121
- return this.prerender;
121
+ // KLUDGE: we need a good path parsing library here
122
+ return (0, _includes.default)(_context3 = this.path).call(_context3, '{');
123
+ }
124
+ get hasPrerender() {
125
+ return this.prerender;
126
+ }
127
+
128
+ /**
129
+ * The associated Redwood Page node, if any
130
+ */
131
+
132
+ get page() {
133
+ var _context4;
134
+ if (!this.page_identifier_str) {
135
+ return undefined;
122
136
  }
123
- /**
124
- * The associated Redwood Page node, if any
125
- */
126
- get page() {
127
- if (!this.page_identifier_str) {
128
- return undefined;
129
- }
130
- return this.parent.parent.pages.find((p) => p.constName === this.page_identifier_str);
137
+ return (0, _find.default)(_context4 = this.parent.parent.pages).call(_context4, p => p.constName === this.page_identifier_str);
138
+ }
139
+ /**
140
+ * <Route path="" page={THIS_IDENTIFIER}/>
141
+ */
142
+ get page_identifier() {
143
+ const a = this.jsxNode.getAttribute('page');
144
+ if (!a) {
145
+ return undefined;
131
146
  }
132
- /**
133
- * <Route path="" page={THIS_IDENTIFIER}/>
134
- */
135
- get page_identifier() {
136
- const a = this.jsxNode.getAttribute('page');
137
- if (!a) {
138
- return undefined;
139
- }
140
- if (tsm.Node.isJsxAttribute(a)) {
141
- const init = a.getInitializer();
142
- if (tsm.Node.isJsxExpression(init)) {
143
- const expr = init.getExpression();
144
- if (tsm.Node.isIdentifier(expr)) {
145
- return expr;
146
- }
147
- }
147
+ if (tsm.Node.isJsxAttribute(a)) {
148
+ const init = a.getInitializer();
149
+ if (tsm.Node.isJsxExpression(init)) {
150
+ const expr = init.getExpression();
151
+ if (tsm.Node.isIdentifier(expr)) {
152
+ return expr;
148
153
  }
149
- return undefined;
154
+ }
150
155
  }
151
- get page_identifier_str() {
152
- return this.page_identifier?.getText();
156
+ return undefined;
157
+ }
158
+ get page_identifier_str() {
159
+ return this.page_identifier?.getText();
160
+ }
161
+ get name() {
162
+ return this.getStringAttr('name');
163
+ }
164
+ get path_errorMessage() {
165
+ // TODO: path validation is not strong enough
166
+ if (typeof this.path === 'undefined') {
167
+ return undefined;
153
168
  }
154
- get name() {
155
- return this.getStringAttr('name');
169
+ try {
170
+ (0, _util.validateRoutePath)(this.path);
171
+ return undefined;
172
+ } catch (e) {
173
+ return e.toString();
156
174
  }
157
- get path_errorMessage() {
158
- // TODO: path validation is not strong enough
159
- if (typeof this.path === 'undefined') {
160
- return undefined;
161
- }
162
- try {
163
- validateRoutePath(this.path);
164
- return undefined;
165
- }
166
- catch (e) {
167
- return e.toString();
168
- }
175
+ }
176
+ get path() {
177
+ return this.getStringAttr('path');
178
+ }
179
+ get prerender() {
180
+ return this.getBoolAttr('prerender');
181
+ }
182
+
183
+ // TODO (STREAMING) Remove this once we're sure we don't want to do Render Modes
184
+ get renderMode() {
185
+ return this.getStringAttr('renderMode') || 'stream';
186
+ }
187
+ get path_literal_node() {
188
+ const a = this.jsxNode.getAttribute('path');
189
+ if (!a) {
190
+ return undefined;
169
191
  }
170
- get path() {
171
- return this.getStringAttr('path');
192
+ if (tsm.Node.isJsxAttribute(a)) {
193
+ const init = a.getInitializer();
194
+ if (tsm.Node.isStringLiteral(init)) {
195
+ return init;
196
+ }
172
197
  }
173
- get prerender() {
174
- return this.getBoolAttr('prerender');
198
+ return undefined;
199
+ }
200
+ get isNotFound() {
201
+ return typeof this.jsxNode.getAttribute('notfound') !== 'undefined';
202
+ }
203
+ get redirect() {
204
+ return this.getStringAttr('redirect');
205
+ }
206
+ *diagnostics() {
207
+ if (this.page_identifier && !this.page) {
208
+ // normally this would be caught by TypeScript
209
+ // but Redwood has some "magic" import behavior going on
210
+ yield (0, _diagnostics.err)(this.page_identifier, 'Page component not found');
175
211
  }
176
- // TODO (STREAMING) Remove this once we're sure we don't want to do Render Modes
177
- get renderMode() {
178
- return this.getStringAttr('renderMode') || 'stream';
212
+ if (this.path_errorMessage && this.path_literal_node) {
213
+ yield (0, _diagnostics.err)(this.path_literal_node, this.path_errorMessage, _errors.RWError.INVALID_ROUTE_PATH_SYNTAX);
179
214
  }
180
- get path_literal_node() {
181
- const a = this.jsxNode.getAttribute('path');
182
- if (!a) {
183
- return undefined;
184
- }
185
- if (tsm.Node.isJsxAttribute(a)) {
186
- const init = a.getInitializer();
187
- if (tsm.Node.isStringLiteral(init)) {
188
- return init;
189
- }
190
- }
191
- return undefined;
215
+ if (this.hasPathCollision) {
216
+ yield (0, _diagnostics.err)(this.path_literal_node, 'Duplicate Path');
192
217
  }
193
- get isNotFound() {
194
- return typeof this.jsxNode.getAttribute('notfound') !== 'undefined';
218
+ if (this.isPrivate && this.isNotFound) {
219
+ yield (0, _diagnostics.err)(this.jsxNode, "The 'Not Found' page cannot be within a <PrivateSet> or a <Private> tag");
195
220
  }
196
- get redirect() {
197
- return this.getStringAttr('redirect');
221
+ if (this.isNotFound && this.path) {
222
+ yield (0, _diagnostics.err)(this.path_literal_node, "The 'Not Found' page cannot have a path");
198
223
  }
199
- *diagnostics() {
200
- if (this.page_identifier && !this.page) {
201
- // normally this would be caught by TypeScript
202
- // but Redwood has some "magic" import behavior going on
203
- yield err(this.page_identifier, 'Page component not found');
204
- }
205
- if (this.path_errorMessage && this.path_literal_node) {
206
- yield err(this.path_literal_node, this.path_errorMessage, RWError.INVALID_ROUTE_PATH_SYNTAX);
207
- }
208
- if (this.hasPathCollision) {
209
- yield err(this.path_literal_node, 'Duplicate Path');
210
- }
211
- if (this.isPrivate && this.isNotFound) {
212
- yield err(this.jsxNode, "The 'Not Found' page cannot be within a <PrivateSet> or a <Private> tag");
213
- }
214
- if (this.isNotFound && this.path) {
215
- yield err(this.path_literal_node, "The 'Not Found' page cannot have a path");
216
- }
224
+ }
225
+ get hasPathCollision() {
226
+ if (!this.path) {
227
+ return false;
217
228
  }
218
- get hasPathCollision() {
219
- if (!this.path) {
220
- return false;
221
- }
222
- const pathWithNoParamNames = removeParamNames(this.path);
223
- for (const route2 of this.parent.routes) {
224
- if (route2 === this) {
225
- continue;
226
- }
227
- if (!route2.path) {
228
- continue;
229
- }
230
- if (removeParamNames(route2.path) === pathWithNoParamNames) {
231
- return true;
232
- }
233
- }
234
- return false;
235
- function removeParamNames(p) {
236
- // TODO: implement
237
- // foo/{bar}/baz --> foo/{}/baz
238
- return p;
239
- }
229
+ const pathWithNoParamNames = removeParamNames(this.path);
230
+ for (const route2 of this.parent.routes) {
231
+ if (route2 === this) {
232
+ continue;
233
+ }
234
+ if (!route2.path) {
235
+ continue;
236
+ }
237
+ if (removeParamNames(route2.path) === pathWithNoParamNames) {
238
+ return true;
239
+ }
240
240
  }
241
- getBoolAttr(name) {
242
- const attr = this.jsxNode.getAttribute(name);
243
- // No attribute
244
- if (!attr) {
245
- return false;
246
- }
247
- // Attribute exists
248
- if (tsm.Node.isJsxAttribute(attr)) {
249
- const init = attr.getInitializer();
250
- // Bool attributes with no initializer are true
251
- // e.g. <Route prerender />
252
- if (!init) {
253
- return true;
254
- }
255
- if (tsm.Node.isJsxExpression(init)) {
256
- // If it is explicitly set to true
257
- // e.g. <Route prerender={true} />
258
- return tsm.Node.isTrueLiteral(init.getExpression());
259
- }
260
- else if (tsm.Node.isStringLiteral(init)) {
261
- // If its using the incorrect string form, we're accepting it as true
262
- // e.g. <Route prerender="true" />
263
- const literalValue = init.getLiteralValue();
264
- return literalValue === 'true';
265
- }
266
- }
267
- return false;
241
+ return false;
242
+ function removeParamNames(p) {
243
+ // TODO: implement
244
+ // foo/{bar}/baz --> foo/{}/baz
245
+ return p;
268
246
  }
269
- getStringAttr(name) {
270
- const a = this.jsxNode.getAttribute(name);
271
- if (!a) {
272
- return undefined;
273
- }
274
- if (tsm.Node.isJsxAttribute(a)) {
275
- const init = a.getInitializer();
276
- if (tsm.Node.isStringLiteral(init)) {
277
- return init.getLiteralValue();
278
- }
279
- }
280
- return undefined;
247
+ }
248
+ getBoolAttr(name) {
249
+ const attr = this.jsxNode.getAttribute(name);
250
+ // No attribute
251
+ if (!attr) {
252
+ return false;
253
+ }
254
+
255
+ // Attribute exists
256
+ if (tsm.Node.isJsxAttribute(attr)) {
257
+ const init = attr.getInitializer();
258
+
259
+ // Bool attributes with no initializer are true
260
+ // e.g. <Route prerender />
261
+ if (!init) {
262
+ return true;
263
+ }
264
+ if (tsm.Node.isJsxExpression(init)) {
265
+ // If it is explicitly set to true
266
+ // e.g. <Route prerender={true} />
267
+ return tsm.Node.isTrueLiteral(init.getExpression());
268
+ } else if (tsm.Node.isStringLiteral(init)) {
269
+ // If its using the incorrect string form, we're accepting it as true
270
+ // e.g. <Route prerender="true" />
271
+ const literalValue = init.getLiteralValue();
272
+ return literalValue === 'true';
273
+ }
274
+ }
275
+ return false;
276
+ }
277
+ getStringAttr(name) {
278
+ const a = this.jsxNode.getAttribute(name);
279
+ if (!a) {
280
+ return undefined;
281
+ }
282
+ if (tsm.Node.isJsxAttribute(a)) {
283
+ const init = a.getInitializer();
284
+ if (tsm.Node.isStringLiteral(init)) {
285
+ return init.getLiteralValue();
286
+ }
281
287
  }
282
- }
283
- __decorate([
284
- lazy()
285
- ], RWRoute.prototype, "id", null);
286
- __decorate([
287
- lazy()
288
- ], RWRoute.prototype, "location", null);
289
- __decorate([
290
- lazy()
291
- ], RWRoute.prototype, "isPrivate", null);
292
- __decorate([
293
- lazy()
294
- ], RWRoute.prototype, "unauthenticated", null);
295
- __decorate([
296
- lazy()
297
- ], RWRoute.prototype, "roles", null);
298
- __decorate([
299
- lazy()
300
- ], RWRoute.prototype, "hasParameters", null);
301
- __decorate([
302
- lazy()
303
- ], RWRoute.prototype, "hasPrerender", null);
304
- __decorate([
305
- lazy()
306
- ], RWRoute.prototype, "page", null);
307
- __decorate([
308
- lazy()
309
- ], RWRoute.prototype, "page_identifier", null);
310
- __decorate([
311
- lazy()
312
- ], RWRoute.prototype, "page_identifier_str", null);
313
- __decorate([
314
- lazy()
315
- ], RWRoute.prototype, "name", null);
316
- __decorate([
317
- lazy()
318
- ], RWRoute.prototype, "path_errorMessage", null);
319
- __decorate([
320
- lazy()
321
- ], RWRoute.prototype, "path", null);
322
- __decorate([
323
- lazy()
324
- ], RWRoute.prototype, "prerender", null);
325
- __decorate([
326
- lazy()
327
- ], RWRoute.prototype, "renderMode", null);
328
- __decorate([
329
- lazy()
330
- ], RWRoute.prototype, "path_literal_node", null);
331
- __decorate([
332
- lazy()
333
- ], RWRoute.prototype, "isNotFound", null);
334
- __decorate([
335
- lazy()
336
- ], RWRoute.prototype, "redirect", null);
337
- __decorate([
338
- lazy()
339
- ], RWRoute.prototype, "hasPathCollision", null);
340
- //# sourceMappingURL=RWRoute.js.map
288
+ return undefined;
289
+ }
290
+ }, (0, _applyDecoratedDescriptor2.default)(_class.prototype, "id", [_dec], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "id"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "location", [_dec2], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "location"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "isPrivate", [_dec3], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "isPrivate"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "unauthenticated", [_dec4], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "unauthenticated"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "roles", [_dec5], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "roles"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "hasParameters", [_dec6], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "hasParameters"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "hasPrerender", [_dec7], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "hasPrerender"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "page", [_dec8], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "page"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "page_identifier", [_dec9], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "page_identifier"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "page_identifier_str", [_dec0], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "page_identifier_str"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "name", [_dec1], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "name"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "path_errorMessage", [_dec10], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "path_errorMessage"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "path", [_dec11], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "path"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "prerender", [_dec12], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "prerender"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "renderMode", [_dec13], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "renderMode"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "path_literal_node", [_dec14], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "path_literal_node"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "isNotFound", [_dec15], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "isNotFound"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "redirect", [_dec16], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "redirect"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "hasPathCollision", [_dec17], (0, _getOwnPropertyDescriptor.default)(_class.prototype, "hasPathCollision"), _class.prototype), _class);
@@ -1,7 +1,7 @@
1
- import { FileNode } from '../nodes.js';
2
- import type { ExtendedDiagnostic } from '../x/diagnostics.js';
3
- import type { RWProject } from './RWProject.js';
4
- import { RWRoute } from './RWRoute.js';
1
+ import { FileNode } from '../nodes';
2
+ import type { ExtendedDiagnostic } from '../x/diagnostics';
3
+ import type { RWProject } from './RWProject';
4
+ import { RWRoute } from './RWRoute';
5
5
  /**
6
6
  * one per Routes.js
7
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"RWRouter.d.ts","sourceRoot":"","sources":["../../src/model/RWRouter.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAGtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAK7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC;;GAEG;AACH,qBAAa,QAAS,SAAQ,QAAQ;IAE3B,QAAQ,EAAE,MAAM;IAChB,MAAM,EAAE,SAAS;gBADjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,SAAS;IAKlB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAK9D,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAUrE;;OAEG;IACK,OAAO,KAAK,OAAO,GAI1B;IAED;;OAEG;IACH,IAAY,MAAM,cA+CjB;IAEO,OAAO,KAAK,gBAAgB,GAEnC;IAEA,WAAW;IAiCZ,QAAQ;CAGT"}
1
+ {"version":3,"file":"RWRouter.d.ts","sourceRoot":"","sources":["../../src/model/RWRouter.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAGnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAK1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC;;GAEG;AACH,qBAAa,QAAS,SAAQ,QAAQ;IAE3B,QAAQ,EAAE,MAAM;IAChB,MAAM,EAAE,SAAS;gBADjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,SAAS;IAKlB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAK9D,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAUrE;;OAEG;IACK,OAAO,KAAK,OAAO,GAI1B;IAED;;OAEG;IACH,IAAY,MAAM,cA+CjB;IAEO,OAAO,KAAK,gBAAgB,GAEnC;IAEA,WAAW;IAiCZ,QAAQ;CAGT"}