@rangular-framework/cli 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/src/cli.js +1217 -0
- package/dist/compiler/src/catalog.js +198 -0
- package/dist/compiler/src/class/formInit.js +370 -0
- package/dist/compiler/src/class/parseComponent.js +430 -0
- package/dist/compiler/src/class/parseDirective.js +227 -0
- package/dist/compiler/src/class/parseRoutes.js +163 -0
- package/dist/compiler/src/codegen/generate.js +3466 -0
- package/dist/compiler/src/codegen/methods.js +975 -0
- package/dist/compiler/src/codegen/sourceMap.js +77 -0
- package/dist/compiler/src/compile.js +775 -0
- package/dist/compiler/src/diagnostics.js +113 -0
- package/dist/compiler/src/doctor.js +144 -0
- package/dist/compiler/src/fix.js +44 -0
- package/dist/compiler/src/index.js +38 -0
- package/dist/compiler/src/preview/renderPreview.js +7158 -0
- package/dist/compiler/src/preview/styleSnapshot.js +268 -0
- package/dist/compiler/src/propTable.js +107 -0
- package/dist/compiler/src/style/css.js +161 -0
- package/dist/compiler/src/template/ast.js +19 -0
- package/dist/compiler/src/template/evaluate.js +151 -0
- package/dist/compiler/src/template/expr.js +360 -0
- package/dist/compiler/src/template/forms.js +80 -0
- package/dist/compiler/src/template/literal.js +248 -0
- package/dist/compiler/src/template/parser.js +230 -0
- package/dist/compiler/src/template/pipes.js +225 -0
- package/dist/compiler/src/template/printAst.js +38 -0
- package/dist/compiler/src/template/structural.js +51 -0
- package/dist/runtime/src/index.js +1197 -0
- package/dist/ui/src/chart.js +196 -0
- package/dist/ui/src/datetime.js +240 -0
- package/dist/ui/src/icons.js +310 -0
- package/dist/ui/src/mask.js +103 -0
- package/dist/ui/src/palette.js +141 -0
- package/dist/ui/src/tokens.js +173 -0
- package/package.json +28 -4
- package/README.md +0 -3
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.parseRoutesFile = parseRoutesFile;
|
|
37
|
+
const ts = __importStar(require("typescript"));
|
|
38
|
+
const diagnostics_1 = require("../diagnostics");
|
|
39
|
+
/** Route entry keys whose Angular feature is not in Rangular v1. */
|
|
40
|
+
const UNSUPPORTED_KEYS = {
|
|
41
|
+
children: 'child routes (nested outlets)',
|
|
42
|
+
canActivate: 'route guards (canActivate)',
|
|
43
|
+
canActivateChild: 'route guards (canActivateChild)',
|
|
44
|
+
canDeactivate: 'route guards (canDeactivate)',
|
|
45
|
+
canMatch: 'route guards (canMatch)',
|
|
46
|
+
resolve: 'resolvers (resolve)',
|
|
47
|
+
loadComponent: 'lazy loading (loadComponent)',
|
|
48
|
+
loadChildren: 'lazy loading (loadChildren)',
|
|
49
|
+
};
|
|
50
|
+
const KNOWN_KEYS = new Set(['path', 'component', 'redirectTo', 'pathMatch', 'data', 'title']);
|
|
51
|
+
const FIX_UNSUPPORTED = 'Remove the unsupported key for now; the feature is on the roadmap in docs/ROADMAP.md (Stage 9 supports flat routes with components and full-path redirects only)';
|
|
52
|
+
const FIX_SHAPE = "Write each entry as an object literal: { path: 'mail/:id', component: MailDetailComponent } or { path: '', redirectTo: 'inbox', pathMatch: 'full' }";
|
|
53
|
+
function stringOf(node) {
|
|
54
|
+
if (!node)
|
|
55
|
+
return undefined;
|
|
56
|
+
if (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node))
|
|
57
|
+
return node.text;
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
/** Unwrap `[...] as Routes` / `<Routes>[...]` to the array literal. */
|
|
61
|
+
function arrayOf(node) {
|
|
62
|
+
if (ts.isArrayLiteralExpression(node))
|
|
63
|
+
return node;
|
|
64
|
+
if (ts.isAsExpression(node) || ts.isTypeAssertionExpression(node))
|
|
65
|
+
return arrayOf(node.expression);
|
|
66
|
+
if (ts.isParenthesizedExpression(node))
|
|
67
|
+
return arrayOf(node.expression);
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
function readEntry(node, diagnostics) {
|
|
71
|
+
if (!ts.isObjectLiteralExpression(node)) {
|
|
72
|
+
diagnostics.push((0, diagnostics_1.error)('GEN_ROUTE_UNSUPPORTED', 'A route entry is not an object literal; route entries must be written out in full', undefined, undefined, FIX_SHAPE));
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
let path;
|
|
76
|
+
let componentName;
|
|
77
|
+
let redirectTo;
|
|
78
|
+
let pathMatch;
|
|
79
|
+
const ignoredKeys = [];
|
|
80
|
+
for (const prop of node.properties) {
|
|
81
|
+
if (ts.isSpreadAssignment(prop)) {
|
|
82
|
+
diagnostics.push((0, diagnostics_1.error)('GEN_ROUTE_UNSUPPORTED', 'A route entry uses a spread; spread entries cannot be read statically', undefined, undefined, FIX_SHAPE));
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (!ts.isPropertyAssignment(prop)) {
|
|
86
|
+
diagnostics.push((0, diagnostics_1.error)('GEN_ROUTE_UNSUPPORTED', 'A route entry uses a shorthand or computed property; entries must be plain key: value pairs', undefined, undefined, FIX_SHAPE));
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const key = prop.name.getText().replace(/^['"]|['"]$/g, '');
|
|
90
|
+
const unsupported = UNSUPPORTED_KEYS[key];
|
|
91
|
+
if (unsupported) {
|
|
92
|
+
diagnostics.push((0, diagnostics_1.error)('GEN_ROUTE_UNSUPPORTED', `Route entry uses '${key}', which is ${unsupported}; Rangular routing does not support it yet`, undefined, undefined, FIX_UNSUPPORTED));
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (!KNOWN_KEYS.has(key)) {
|
|
96
|
+
ignoredKeys.push(key);
|
|
97
|
+
diagnostics.push((0, diagnostics_1.warning)('GEN_ROUTE_UNSUPPORTED', `Route entry key '${key}' is not a supported route key and was ignored`, undefined, undefined, "Supported keys are path, component, redirectTo and pathMatch (data and title are accepted and ignored); remove the key or see docs/ROADMAP.md for what is planned"));
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (key === 'path')
|
|
101
|
+
path = stringOf(prop.initializer);
|
|
102
|
+
else if (key === 'redirectTo')
|
|
103
|
+
redirectTo = stringOf(prop.initializer);
|
|
104
|
+
else if (key === 'pathMatch')
|
|
105
|
+
pathMatch = stringOf(prop.initializer);
|
|
106
|
+
else if (key === 'component') {
|
|
107
|
+
componentName = ts.isIdentifier(prop.initializer) ? prop.initializer.text : undefined;
|
|
108
|
+
if (componentName === undefined) {
|
|
109
|
+
diagnostics.push((0, diagnostics_1.error)('GEN_ROUTE_UNSUPPORTED', 'A route\'s component is not a plain class reference; lazy or computed components are not supported', undefined, undefined, 'Name the component class directly and import it in the routes file: { path: \'inbox\', component: InboxComponent }'));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// data / title: accepted, no runtime effect in this version; they
|
|
113
|
+
// are recorded in ignoredKeys so nothing is silently dropped.
|
|
114
|
+
else if (key === 'data' || key === 'title')
|
|
115
|
+
ignoredKeys.push(key);
|
|
116
|
+
}
|
|
117
|
+
if (path === undefined) {
|
|
118
|
+
diagnostics.push((0, diagnostics_1.error)('GEN_ROUTE_UNSUPPORTED', 'A route entry has no string \'path\'; every entry needs one', undefined, undefined, FIX_SHAPE));
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
if (componentName !== undefined && redirectTo !== undefined) {
|
|
122
|
+
diagnostics.push((0, diagnostics_1.error)('GEN_ROUTE_UNSUPPORTED', `Route '${path}' declares both a component and a redirectTo; Angular forbids the combination and so does Rangular`, undefined, undefined, 'Keep one: a component route renders, a redirect route forwards. Split them into two entries if both paths are needed'));
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
if (componentName === undefined && redirectTo === undefined) {
|
|
126
|
+
diagnostics.push((0, diagnostics_1.error)('GEN_ROUTE_UNSUPPORTED', `Route '${path}' declares neither a component nor a redirectTo; there is nothing for it to do`, undefined, undefined, FIX_SHAPE));
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
return { path, componentName, redirectTo, pathMatch, ignoredKeys };
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Read the Routes array of a routes file. Emits diagnostics for
|
|
133
|
+
* unsupported shapes; a file with no Routes array reports found: false
|
|
134
|
+
* and no diagnostics (compile.ts decides what that means).
|
|
135
|
+
*/
|
|
136
|
+
function parseRoutesFile(tsSource, fileName = 'app.routes.ts') {
|
|
137
|
+
const diagnostics = [];
|
|
138
|
+
const sf = ts.createSourceFile(fileName, tsSource, ts.ScriptTarget.Latest, /* setParentNodes */ true);
|
|
139
|
+
let array;
|
|
140
|
+
const visit = (node) => {
|
|
141
|
+
if (array)
|
|
142
|
+
return;
|
|
143
|
+
if (ts.isVariableDeclaration(node) && node.initializer && ts.isIdentifier(node.name)) {
|
|
144
|
+
const name = node.name.text;
|
|
145
|
+
const typeText = node.type ? node.type.getText(sf) : '';
|
|
146
|
+
if (/routes$/i.test(name) || /\bRoutes\b/.test(typeText)) {
|
|
147
|
+
array = arrayOf(node.initializer);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (!array)
|
|
151
|
+
ts.forEachChild(node, visit);
|
|
152
|
+
};
|
|
153
|
+
visit(sf);
|
|
154
|
+
if (!array)
|
|
155
|
+
return { routes: [], diagnostics, found: false };
|
|
156
|
+
const routes = [];
|
|
157
|
+
for (const element of array.elements) {
|
|
158
|
+
const def = readEntry(element, diagnostics);
|
|
159
|
+
if (def)
|
|
160
|
+
routes.push(def);
|
|
161
|
+
}
|
|
162
|
+
return { routes, diagnostics, found: true };
|
|
163
|
+
}
|