@nstudio/nativescript-compiler-angular 9.2.0-alpha.10 → 9.2.0-alpha.11
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/angular-libraries.js +225 -12
- package/dist/angular.js +1453 -202
- package/dist/component-bases.js +144 -37
- package/dist/entry.js +32 -2
- package/dist/index.js +93 -25
- package/dist/kotlin.js +9 -7
- package/dist/modules.js +100 -20
- package/dist/refusals.js +0 -1
- package/dist/semantics.js +16 -4
- package/dist/swift.js +9 -9
- package/kit-android/fromcore/AngularAPI.kt +3 -1
- package/kit-android/fromcore/AngularRouter.kt +105 -2
- package/kit-android/main/AngularCore.kt +121 -8
- package/kit-android/main/AngularRx.kt +4 -0
- package/kit-apple/AngularAPI.swift +6 -2
- package/kit-apple/AngularCore.swift +119 -5
- package/kit-apple/AngularRouter.swift +105 -0
- package/kit-apple/AngularRx.swift +4 -0
- package/kit-apple/kit-index.json +103 -5
- package/package.json +2 -2
- package/runtime/angular-cdk.ts +673 -0
- package/runtime/angular-rx.ts +38 -2
package/dist/component-bases.js
CHANGED
|
@@ -17,28 +17,33 @@ const decoratorsOf = (m) => (ts.canHaveDecorators(m) ? ts.getDecorators(m) ?? []
|
|
|
17
17
|
const memberName = (m) => (m.name && (ts.isIdentifier(m.name) || ts.isPrivateIdentifier(m.name) || ts.isStringLiteral(m.name)) ? m.name.text : undefined);
|
|
18
18
|
const lineOf = (n) => n.getSourceFile().getLineAndCharacterOfPosition(n.getStart()).line + 1;
|
|
19
19
|
const withoutExt = (f) => f.replace(/\.tsx?$/, '').replace(/\/index$/, '');
|
|
20
|
-
/** An import's file: relative,
|
|
21
|
-
export function resolveClassImport(fromFile, spec) {
|
|
20
|
+
/** An import's file: relative, under the app's `~/` or `@/` alias, or resolved by tsconfig `paths` (`aliased`). */
|
|
21
|
+
export function resolveClassImport(fromFile, spec, aliased) {
|
|
22
22
|
const candidates = [];
|
|
23
23
|
if (spec.startsWith('.')) {
|
|
24
24
|
const base = join(dirname(fromFile), spec);
|
|
25
25
|
candidates.push(base + '.ts', join(base, 'index.ts'));
|
|
26
26
|
}
|
|
27
|
-
else
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
else {
|
|
28
|
+
const mapped = aliased?.(spec);
|
|
29
|
+
if (mapped)
|
|
30
|
+
candidates.push(mapped, mapped + '.ts', join(mapped, 'index.ts'));
|
|
31
|
+
if (spec.startsWith('~/') || spec.startsWith('@/')) {
|
|
32
|
+
const sub = spec.slice(2);
|
|
33
|
+
for (let dir = dirname(fromFile); dirname(dir) !== dir; dir = dirname(dir)) {
|
|
34
|
+
if (!existsSync(join(dir, 'package.json')))
|
|
35
|
+
continue;
|
|
36
|
+
for (const appDir of ['src', 'app'])
|
|
37
|
+
candidates.push(join(dir, appDir, sub + '.ts'), join(dir, appDir, sub, 'index.ts'));
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
35
40
|
}
|
|
36
41
|
}
|
|
37
42
|
return candidates.find((c) => existsSync(c));
|
|
38
43
|
}
|
|
39
44
|
const readFile = (f) => readFileSync(f, 'utf8');
|
|
40
45
|
/** The class a module exports as `name`, followed through re-exports (`export * from`, `export { X as name } from`). */
|
|
41
|
-
function exportedClass(file, name, read, seen = new Set()) {
|
|
46
|
+
function exportedClass(file, name, read, seen = new Set(), aliased) {
|
|
42
47
|
if (seen.has(`${file}#${name}`))
|
|
43
48
|
return undefined;
|
|
44
49
|
seen.add(`${file}#${name}`);
|
|
@@ -47,18 +52,18 @@ function exportedClass(file, name, read, seen = new Set()) {
|
|
|
47
52
|
return { file, name };
|
|
48
53
|
for (const st of sf.statements) {
|
|
49
54
|
if (ts.isExportDeclaration(st) && st.moduleSpecifier && ts.isStringLiteral(st.moduleSpecifier)) {
|
|
50
|
-
const target = resolveClassImport(file, st.moduleSpecifier.text);
|
|
55
|
+
const target = resolveClassImport(file, st.moduleSpecifier.text, aliased);
|
|
51
56
|
if (!target)
|
|
52
57
|
continue;
|
|
53
58
|
if (!st.exportClause) {
|
|
54
|
-
const found = exportedClass(target, name, read, seen);
|
|
59
|
+
const found = exportedClass(target, name, read, seen, aliased);
|
|
55
60
|
if (found)
|
|
56
61
|
return found;
|
|
57
62
|
}
|
|
58
63
|
else if (ts.isNamedExports(st.exportClause)) {
|
|
59
64
|
const el = st.exportClause.elements.find((e) => e.name.text === name);
|
|
60
65
|
if (el)
|
|
61
|
-
return exportedClass(target, (el.propertyName ?? el.name).text, read, seen);
|
|
66
|
+
return exportedClass(target, (el.propertyName ?? el.name).text, read, seen, aliased);
|
|
62
67
|
}
|
|
63
68
|
}
|
|
64
69
|
else if (ts.isExportDeclaration(st) && st.exportClause && ts.isNamedExports(st.exportClause)) {
|
|
@@ -66,13 +71,13 @@ function exportedClass(file, name, read, seen = new Set()) {
|
|
|
66
71
|
const el = st.exportClause.elements.find((e) => e.name.text === name);
|
|
67
72
|
const local = el ? (el.propertyName ?? el.name).text : undefined;
|
|
68
73
|
if (local)
|
|
69
|
-
return classOfName(file, sf, local, read, seen);
|
|
74
|
+
return classOfName(file, sf, local, read, seen, aliased);
|
|
70
75
|
}
|
|
71
76
|
}
|
|
72
77
|
return undefined;
|
|
73
78
|
}
|
|
74
79
|
/** The class a file's own name refers to: declared there, or imported. */
|
|
75
|
-
function classOfName(file, sf, name, read, seen = new Set()) {
|
|
80
|
+
function classOfName(file, sf, name, read, seen = new Set(), aliased) {
|
|
76
81
|
if (classIn(sf, name))
|
|
77
82
|
return { file, name };
|
|
78
83
|
for (const st of sf.statements) {
|
|
@@ -82,25 +87,25 @@ function classOfName(file, sf, name, read, seen = new Set()) {
|
|
|
82
87
|
const el = bindings && ts.isNamedImports(bindings) ? bindings.elements.find((e) => e.name.text === name) : undefined;
|
|
83
88
|
if (!el)
|
|
84
89
|
continue;
|
|
85
|
-
const target = resolveClassImport(file, st.moduleSpecifier.text);
|
|
86
|
-
return target ? exportedClass(target, (el.propertyName ?? el.name).text, read, seen) : undefined;
|
|
90
|
+
const target = resolveClassImport(file, st.moduleSpecifier.text, aliased);
|
|
91
|
+
return target ? exportedClass(target, (el.propertyName ?? el.name).text, read, seen, aliased) : undefined;
|
|
87
92
|
}
|
|
88
93
|
return undefined;
|
|
89
94
|
}
|
|
90
95
|
function extendsOf(cls) {
|
|
91
96
|
return cls.heritageClauses?.find((h) => h.token === ts.SyntaxKind.ExtendsKeyword)?.types[0];
|
|
92
97
|
}
|
|
93
|
-
function baseOf(file, sf, cls, read) {
|
|
98
|
+
function baseOf(file, sf, cls, read, aliased) {
|
|
94
99
|
const ext = extendsOf(cls);
|
|
95
100
|
const where = `${file}:${lineOf(ext)}`;
|
|
96
101
|
if (!ts.isIdentifier(ext.expression))
|
|
97
102
|
throw unsupported(where, `the component ${cls.name.text} extending ${ext.expression.getText()}`);
|
|
98
|
-
const found = classOfName(file, sf, ext.expression.text, read);
|
|
103
|
+
const found = classOfName(file, sf, ext.expression.text, read, new Set(), aliased);
|
|
99
104
|
if (!found)
|
|
100
105
|
throw unsupported(where, `the component ${cls.name.text} extending ${ext.expression.text}, a class the build finds no source of in the app`);
|
|
101
106
|
return found;
|
|
102
107
|
}
|
|
103
|
-
function bindingsOf(file, sf) {
|
|
108
|
+
function bindingsOf(file, sf, aliased) {
|
|
104
109
|
const out = new Map();
|
|
105
110
|
const exportsAs = new Map();
|
|
106
111
|
for (const st of sf.statements) {
|
|
@@ -117,7 +122,7 @@ function bindingsOf(file, sf) {
|
|
|
117
122
|
for (const st of sf.statements) {
|
|
118
123
|
if (ts.isImportDeclaration(st) && st.importClause && ts.isStringLiteral(st.moduleSpecifier)) {
|
|
119
124
|
const spec = st.moduleSpecifier.text;
|
|
120
|
-
const target = resolveClassImport(file, spec);
|
|
125
|
+
const target = resolveClassImport(file, spec, aliased);
|
|
121
126
|
const module = target ? withoutExt(target) : spec;
|
|
122
127
|
const clause = st.importClause;
|
|
123
128
|
if (clause.name)
|
|
@@ -217,23 +222,83 @@ function usesThis(n) {
|
|
|
217
222
|
const REACTIVE = /^(input|input\.required|model|model\.required|output|signal|computed|linkedSignal|toSignal|viewChild|viewChildren|contentChild|contentChildren|inject)$/;
|
|
218
223
|
const reactive = (e) => !!e && ((ts.isCallExpression(e) && REACTIVE.test(e.expression.getText())) || (ts.isNewExpression(e) && e.expression.getText() === 'EventEmitter'));
|
|
219
224
|
const BASE_META = new Set(['providers', 'viewProviders', 'host', 'inputs', 'outputs', 'queries', 'hostDirectives']);
|
|
225
|
+
/**
|
|
226
|
+
* Whether `cls` extends a chain of concrete `@Directive` classes (none `@Component`, none `abstract`, none with
|
|
227
|
+
* required constructor parameters): those keep real Swift/Kotlin inheritance so `inject(Base)`, `useExisting`, and
|
|
228
|
+
* `instanceof Base` work natively at runtime without flattening.
|
|
229
|
+
*/
|
|
230
|
+
export function isRealDirectiveBaseChain(file, sf, cls, read = readFile, aliased) {
|
|
231
|
+
if (!extendsOf(cls))
|
|
232
|
+
return false;
|
|
233
|
+
let curFile = file, curSf = sf, curCls = cls;
|
|
234
|
+
const seen = new Set();
|
|
235
|
+
while (curCls && extendsOf(curCls)) {
|
|
236
|
+
const ext = extendsOf(curCls);
|
|
237
|
+
if (!ts.isIdentifier(ext.expression))
|
|
238
|
+
return false;
|
|
239
|
+
const b = classOfName(curFile, curSf, ext.expression.text, read, new Set(), aliased);
|
|
240
|
+
if (!b || seen.has(`${b.file}#${b.name}`))
|
|
241
|
+
return false;
|
|
242
|
+
seen.add(`${b.file}#${b.name}`);
|
|
243
|
+
const bSf = b.file === curFile ? curSf : parse(b.file, read(b.file));
|
|
244
|
+
const bCls = classIn(bSf, b.name);
|
|
245
|
+
if (!bCls || isAbstract(bCls))
|
|
246
|
+
return false;
|
|
247
|
+
const decs = decoratorsOf(bCls).map((d) => (ts.isCallExpression(d.expression) ? d.expression.expression.getText() : d.expression.getText()));
|
|
248
|
+
if (!decs.includes('Directive') || decs.includes('Component'))
|
|
249
|
+
return false;
|
|
250
|
+
const ctor = bCls.members.find((m) => ts.isConstructorDeclaration(m) && !!m.body);
|
|
251
|
+
if (ctor && ctor.parameters.length > 0)
|
|
252
|
+
return false;
|
|
253
|
+
curFile = b.file;
|
|
254
|
+
curSf = bSf;
|
|
255
|
+
curCls = bCls;
|
|
256
|
+
}
|
|
257
|
+
return seen.size > 0;
|
|
258
|
+
}
|
|
259
|
+
/** Ancestor `@Directive` classes of `cls` (nearest base first) when `isRealDirectiveBaseChain` holds. */
|
|
260
|
+
export function inheritedDirectiveClasses(file, sf, cls, read = readFile, aliased) {
|
|
261
|
+
const out = [];
|
|
262
|
+
let curFile = file, curSf = sf, curCls = cls;
|
|
263
|
+
const seen = new Set();
|
|
264
|
+
while (curCls && extendsOf(curCls)) {
|
|
265
|
+
const ext = extendsOf(curCls);
|
|
266
|
+
if (!ts.isIdentifier(ext.expression))
|
|
267
|
+
break;
|
|
268
|
+
const b = classOfName(curFile, curSf, ext.expression.text, read, new Set(), aliased);
|
|
269
|
+
if (!b || seen.has(`${b.file}#${b.name}`))
|
|
270
|
+
break;
|
|
271
|
+
seen.add(`${b.file}#${b.name}`);
|
|
272
|
+
const bSf = b.file === curFile ? curSf : parse(b.file, read(b.file));
|
|
273
|
+
const bCls = classIn(bSf, b.name);
|
|
274
|
+
if (!bCls)
|
|
275
|
+
break;
|
|
276
|
+
out.push({ file: b.file, cls: bCls });
|
|
277
|
+
curFile = b.file;
|
|
278
|
+
curSf = bSf;
|
|
279
|
+
curCls = bCls;
|
|
280
|
+
}
|
|
281
|
+
return out;
|
|
282
|
+
}
|
|
220
283
|
/**
|
|
221
284
|
* The file's text with the class `name` flattened: no `extends`, its bases' members its own. `null` when the class
|
|
222
|
-
* extends nothing.
|
|
285
|
+
* extends nothing or extends a concrete `@Directive` chain that keeps real inheritance.
|
|
223
286
|
*/
|
|
224
|
-
export function flattenComponent(path, text, name, read = readFile, seen = new Set()) {
|
|
287
|
+
export function flattenComponent(path, text, name, read = readFile, seen = new Set(), aliased) {
|
|
225
288
|
let sf = parse(path, text);
|
|
226
289
|
let cls = classIn(sf, name);
|
|
227
290
|
if (!extendsOf(cls))
|
|
228
291
|
return null;
|
|
292
|
+
if (isRealDirectiveBaseChain(path, sf, cls, read, aliased))
|
|
293
|
+
return null;
|
|
229
294
|
if (seen.has(`${path}#${name}`))
|
|
230
295
|
throw unsupported(path, `the class ${name} extending itself through its bases`);
|
|
231
296
|
seen.add(`${path}#${name}`);
|
|
232
|
-
const base = baseOf(path, sf, cls, read);
|
|
297
|
+
const base = baseOf(path, sf, cls, read, aliased);
|
|
233
298
|
let baseSf;
|
|
234
299
|
if (base.file === path) {
|
|
235
300
|
// A base in the same file is flattened there first, and the component read again from that text.
|
|
236
|
-
const flat = flattenComponent(path, text, base.name, read, seen);
|
|
301
|
+
const flat = flattenComponent(path, text, base.name, read, seen, aliased);
|
|
237
302
|
if (flat !== null) {
|
|
238
303
|
text = flat;
|
|
239
304
|
sf = parse(path, text);
|
|
@@ -243,16 +308,22 @@ export function flattenComponent(path, text, name, read = readFile, seen = new S
|
|
|
243
308
|
}
|
|
244
309
|
else {
|
|
245
310
|
const original = read(base.file);
|
|
246
|
-
baseSf = parse(base.file, flattenComponent(base.file, original, base.name, read, seen) ?? original);
|
|
311
|
+
baseSf = parse(base.file, flattenComponent(base.file, original, base.name, read, seen, aliased) ?? original);
|
|
247
312
|
}
|
|
248
313
|
const B = classIn(baseSf, base.name);
|
|
249
314
|
const C = name;
|
|
250
315
|
const where = (n) => `${path}:${lineOf(n)}`;
|
|
251
316
|
const bwhere = (n) => `${base.file}:${lineOf(n)}`;
|
|
317
|
+
const ownHasProviders = decoratorsOf(cls).some((d) => {
|
|
318
|
+
const meta = ts.isCallExpression(d.expression) ? d.expression.arguments[0] : undefined;
|
|
319
|
+
return !!meta && ts.isObjectLiteralExpression(meta) && meta.properties.some((p) => p.name && (ts.isIdentifier(p.name) || ts.isStringLiteral(p.name)) && p.name.text === 'providers');
|
|
320
|
+
});
|
|
252
321
|
for (const d of decoratorsOf(B)) {
|
|
253
322
|
const meta = ts.isCallExpression(d.expression) ? d.expression.arguments[0] : undefined;
|
|
254
323
|
for (const p of meta && ts.isObjectLiteralExpression(meta) ? meta.properties : []) {
|
|
255
324
|
const key = p.name && (ts.isIdentifier(p.name) || ts.isStringLiteral(p.name)) ? p.name.text : '';
|
|
325
|
+
if (key === 'providers' && ownHasProviders)
|
|
326
|
+
continue;
|
|
256
327
|
if (BASE_META.has(key))
|
|
257
328
|
throw unsupported(bwhere(p), `the ${key} of ${base.name}, a class the component ${C} extends,`);
|
|
258
329
|
}
|
|
@@ -275,19 +346,52 @@ export function flattenComponent(path, text, name, read = readFile, seen = new S
|
|
|
275
346
|
const kind = (m) => (ts.isPropertyDeclaration(m) ? 'field' : ts.isMethodDeclaration(m) ? 'method' : ts.isAccessor(m) ? 'accessor' : 'other');
|
|
276
347
|
// ---- Names: the base's text reads its own file's imports and declarations; the component's file binds them too.
|
|
277
348
|
const sameFile = base.file === path;
|
|
278
|
-
const mine = bindingsOf(path, sf);
|
|
279
|
-
const theirs = bindingsOf(base.file, baseSf);
|
|
349
|
+
const mine = bindingsOf(path, sf, aliased);
|
|
350
|
+
const theirs = bindingsOf(base.file, baseSf, aliased);
|
|
280
351
|
const imports = [];
|
|
352
|
+
const localDecls = [];
|
|
353
|
+
const copiedLocals = new Set();
|
|
281
354
|
const mapped = new Map();
|
|
355
|
+
const findLocalDecl = (n) => {
|
|
356
|
+
for (const st of baseSf.statements) {
|
|
357
|
+
if ((ts.isTypeAliasDeclaration(st) || ts.isInterfaceDeclaration(st) || ts.isEnumDeclaration(st) || ts.isFunctionDeclaration(st)) && st.name?.text === n)
|
|
358
|
+
return st;
|
|
359
|
+
if (ts.isVariableStatement(st) && st.declarationList.declarations.some((d) => ts.isIdentifier(d.name) && d.name.text === n))
|
|
360
|
+
return st;
|
|
361
|
+
}
|
|
362
|
+
return undefined;
|
|
363
|
+
};
|
|
282
364
|
const nameFor = (n, at) => {
|
|
283
365
|
if (sameFile)
|
|
284
366
|
return n;
|
|
285
367
|
if (mapped.has(n))
|
|
286
368
|
return mapped.get(n);
|
|
287
369
|
const b = theirs.get(n);
|
|
288
|
-
if (!b.exported)
|
|
289
|
-
|
|
290
|
-
|
|
370
|
+
if (!b.exported) {
|
|
371
|
+
const decl = findLocalDecl(n);
|
|
372
|
+
if (!decl)
|
|
373
|
+
throw unsupported(bwhere(at), `${base.name}'s members naming ${n}, which ${base.file} does not export, in the component ${C} that extends it,`);
|
|
374
|
+
const local = mine.has(n) ? `${n}__${base.name}` : n;
|
|
375
|
+
mapped.set(n, local);
|
|
376
|
+
if (!copiedLocals.has(local)) {
|
|
377
|
+
copiedLocals.add(local);
|
|
378
|
+
mine.set(local, { ...b, name: local });
|
|
379
|
+
const nameEdits = [];
|
|
380
|
+
if (local !== n) {
|
|
381
|
+
if (ts.isVariableStatement(decl)) {
|
|
382
|
+
for (const d of decl.declarationList.declarations)
|
|
383
|
+
if (ts.isIdentifier(d.name) && d.name.text === n)
|
|
384
|
+
nameEdits.push({ start: d.name.getStart(), end: d.name.getEnd(), text: local });
|
|
385
|
+
}
|
|
386
|
+
else if ((ts.isTypeAliasDeclaration(decl) || ts.isInterfaceDeclaration(decl) || ts.isEnumDeclaration(decl) || ts.isFunctionDeclaration(decl)) && decl.name) {
|
|
387
|
+
nameEdits.push({ start: decl.name.getStart(), end: decl.name.getEnd(), text: local });
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
localDecls.push(fromBase(decl, nameEdits, false));
|
|
391
|
+
}
|
|
392
|
+
return local;
|
|
393
|
+
}
|
|
394
|
+
const same = (x) => x.module === b.module && x.name === b.name && (!x.typeOnly || b.typeOnly);
|
|
291
395
|
let local = mine.get(n) && same(mine.get(n)) ? n : [...mine].find(([, x]) => same(x))?.[0];
|
|
292
396
|
if (!local) {
|
|
293
397
|
local = mine.has(n) || mapped.has(n) ? `${n}__${base.name}` : n;
|
|
@@ -586,7 +690,8 @@ export function flattenComponent(path, text, name, read = readFile, seen = new S
|
|
|
586
690
|
const others = cls.heritageClauses.filter((h) => h !== ext);
|
|
587
691
|
const head = text.slice(cls.getStart(), ext.getFullStart()) + (others.length ? ' ' + others.map((h) => h.getText()).join(' ') : '') + ' {';
|
|
588
692
|
const flat = head + out.join('') + '\n}';
|
|
589
|
-
|
|
693
|
+
const preamble = [...imports, ...localDecls];
|
|
694
|
+
return (preamble.length ? preamble.join('\n') + '\n' : '') + text.slice(0, cls.getStart()) + flat + text.slice(cls.getEnd());
|
|
590
695
|
}
|
|
591
696
|
const QUERIES = /^(ViewChild|ViewChildren|ContentChild|ContentChildren|viewChild|viewChildren|contentChild|contentChildren)(\.required)?$/;
|
|
592
697
|
const PROVIDER_KEYS = new Set(['provide', 'useClass', 'useExisting', 'providers', 'viewProviders']);
|
|
@@ -618,7 +723,7 @@ function needsBase(id, name) {
|
|
|
618
723
|
* A class that a component extends is copied into it (`flattenComponent`), so the component is no instance of it: an
|
|
619
724
|
* app file reading one as such (`instanceof`, injection or a query by it, a provider of it, a type) stops the build.
|
|
620
725
|
*/
|
|
621
|
-
export function refuseBaseUses(files, read = readFile) {
|
|
726
|
+
export function refuseBaseUses(files, read = readFile, aliased) {
|
|
622
727
|
const bases = new Map();
|
|
623
728
|
const derived = new Map();
|
|
624
729
|
for (const f of files) {
|
|
@@ -629,12 +734,14 @@ export function refuseBaseUses(files, read = readFile) {
|
|
|
629
734
|
for (const st of sf.statements) {
|
|
630
735
|
if (!ts.isClassDeclaration(st) || !st.name || !decoratorsOf(st).some((d) => /^Component\b/.test(d.expression.getText())))
|
|
631
736
|
continue;
|
|
737
|
+
if (isRealDirectiveBaseChain(f, sf, st, read, aliased))
|
|
738
|
+
continue;
|
|
632
739
|
let file = f, at = sf, cls = st;
|
|
633
740
|
const seen = new Set();
|
|
634
741
|
const statics = new Map();
|
|
635
742
|
const declared = new Set(st.members.filter(isStatic).map(memberName));
|
|
636
743
|
while (cls && extendsOf(cls) && ts.isIdentifier(extendsOf(cls).expression)) {
|
|
637
|
-
const b = classOfName(file, at, extendsOf(cls).expression.text, read);
|
|
744
|
+
const b = classOfName(file, at, extendsOf(cls).expression.text, read, new Set(), aliased);
|
|
638
745
|
if (!b || seen.has(`${b.file}#${b.name}`))
|
|
639
746
|
break;
|
|
640
747
|
seen.add(`${b.file}#${b.name}`);
|
|
@@ -666,7 +773,7 @@ export function refuseBaseUses(files, read = readFile) {
|
|
|
666
773
|
const resolve = (f, sf, among) => {
|
|
667
774
|
const local = new Map();
|
|
668
775
|
for (const n of names) {
|
|
669
|
-
const found = sf.text.includes(n) ? classOfName(f, sf, n, read) : undefined;
|
|
776
|
+
const found = sf.text.includes(n) ? classOfName(f, sf, n, read, new Set(), aliased) : undefined;
|
|
670
777
|
const b = found && among.get(`${found.file}#${found.name}`);
|
|
671
778
|
if (b)
|
|
672
779
|
local.set(n, b);
|
|
@@ -677,7 +784,7 @@ export function refuseBaseUses(files, read = readFile) {
|
|
|
677
784
|
for (const e of st.importClause.namedBindings.elements) {
|
|
678
785
|
if (local.has(e.name.text) || !e.propertyName)
|
|
679
786
|
continue;
|
|
680
|
-
const found = classOfName(f, sf, e.name.text, read);
|
|
787
|
+
const found = classOfName(f, sf, e.name.text, read, new Set(), aliased);
|
|
681
788
|
const b = found && among.get(`${found.file}#${found.name}`);
|
|
682
789
|
if (b)
|
|
683
790
|
local.set(e.name.text, b);
|
package/dist/entry.js
CHANGED
|
@@ -47,7 +47,7 @@ export function angularEntryModule(file, text, routeFiles, components, aliased)
|
|
|
47
47
|
if (!ts.isCallExpression(e))
|
|
48
48
|
return false;
|
|
49
49
|
const fn = e.expression.getText();
|
|
50
|
-
if (/^(provideNativeScriptRouter|provideRouter|provideZoneChangeDetection|provideZonelessChangeDetection|provideExperimentalZonelessChangeDetection|provideNativeScriptNgZone)$/.test(fn))
|
|
50
|
+
if (/^(provideNativeScriptRouter|provideRouter|provideFileRouter|provideZoneChangeDetection|provideZonelessChangeDetection|provideExperimentalZonelessChangeDetection|provideNativeScriptNgZone)$/.test(fn))
|
|
51
51
|
return true;
|
|
52
52
|
if (/^(provideNativeScriptHttpClient|provideHttpClient)$/.test(fn) && e.arguments.every((a) => ts.isCallExpression(a) && /^(withInterceptorsFromDi|withFetch|withJsonpSupport|withNoXsrfProtection)$/.test(a.expression.getText())))
|
|
53
53
|
return true;
|
|
@@ -92,15 +92,42 @@ export function angularEntryModule(file, text, routeFiles, components, aliased)
|
|
|
92
92
|
if (!rest.length && !hasCustomProviders)
|
|
93
93
|
return null;
|
|
94
94
|
const componentFiles = new Set(components.map((c) => c.file.replace(/\.release\.ts$/, '.ts')));
|
|
95
|
+
const rewriteSpecRanges = [];
|
|
95
96
|
for (const st of sf.statements) {
|
|
96
97
|
if (ts.isImportDeclaration(st) && ts.isStringLiteral(st.moduleSpecifier)) {
|
|
97
98
|
const spec = st.moduleSpecifier.text;
|
|
98
99
|
const base = aliased(spec) ?? (spec.startsWith('.') ? resolve(dirname(file), spec) : undefined);
|
|
99
100
|
if (base) {
|
|
100
101
|
const candidates = [base, base + '.ts', join(base, 'index.ts')];
|
|
101
|
-
if (candidates.some((c) => routeFiles.has(c)
|
|
102
|
+
if (candidates.some((c) => routeFiles.has(c))) {
|
|
102
103
|
blankRanges.push([st.getStart(), st.getEnd()]);
|
|
103
104
|
}
|
|
105
|
+
else if (candidates.some((c) => componentFiles.has(c))) {
|
|
106
|
+
const importedNames = [];
|
|
107
|
+
const clause = st.importClause;
|
|
108
|
+
if (clause?.name)
|
|
109
|
+
importedNames.push(clause.name.text);
|
|
110
|
+
if (clause?.namedBindings && ts.isNamedImports(clause.namedBindings)) {
|
|
111
|
+
for (const el of clause.namedBindings.elements)
|
|
112
|
+
importedNames.push(el.name.text);
|
|
113
|
+
}
|
|
114
|
+
const maskedText = (() => {
|
|
115
|
+
let t = text;
|
|
116
|
+
for (const [s, e] of nullFirstArgRanges)
|
|
117
|
+
t = t.slice(0, s) + ' '.repeat(e - s) + t.slice(e);
|
|
118
|
+
for (const [s, e] of blankRanges)
|
|
119
|
+
t = t.slice(0, s) + ' '.repeat(e - s) + t.slice(e);
|
|
120
|
+
return t.slice(0, st.getStart()) + ' '.repeat(st.getEnd() - st.getStart()) + t.slice(st.getEnd());
|
|
121
|
+
})();
|
|
122
|
+
const stillUsed = importedNames.some((n) => new RegExp(`\\b${n}\\b`).test(maskedText));
|
|
123
|
+
if (stillUsed) {
|
|
124
|
+
const targetFile = candidates.find((c) => componentFiles.has(c));
|
|
125
|
+
rewriteSpecRanges.push([st.moduleSpecifier.getStart(), st.moduleSpecifier.getEnd(), JSON.stringify(targetFile.replace(/\.ts$/, '.release.ts'))]);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
blankRanges.push([st.getStart(), st.getEnd()]);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
104
131
|
}
|
|
105
132
|
}
|
|
106
133
|
else if (isBootstrap(st) && !hasCustomProviders) {
|
|
@@ -116,5 +143,8 @@ export function angularEntryModule(file, text, routeFiles, components, aliased)
|
|
|
116
143
|
for (const [s, e] of blankRanges) {
|
|
117
144
|
out = out.slice(0, s) + out.slice(s, e).replace(/[^\n]/g, ' ') + out.slice(e);
|
|
118
145
|
}
|
|
146
|
+
for (const [s, e, rep] of rewriteSpecRanges.sort((a, b) => b[0] - a[0])) {
|
|
147
|
+
out = out.slice(0, s) + rep + out.slice(e);
|
|
148
|
+
}
|
|
119
149
|
return out;
|
|
120
150
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
-
import {
|
|
3
|
+
import { angularComponents, angularDirectives, angularPipes, angularRoutes, angularRouteTree, componentsOf, declarableSource, declarablesIn, hostedComponents, routedComponents, selectorElements } from "./angular.js";
|
|
4
4
|
import { angularLibraries, registeredElements } from "./angular-libraries.js";
|
|
5
5
|
import { refuseBaseUses } from "./component-bases.js";
|
|
6
6
|
import { useCore } from "./core-api.js";
|
|
@@ -33,6 +33,9 @@ const behaviour = {
|
|
|
33
33
|
inputChanged: 'Zone.inputChanged',
|
|
34
34
|
directiveHost: 'ElementRef.hosting',
|
|
35
35
|
routerOutlet: { call: 'Router.shared.outlet', primary: 'primary' },
|
|
36
|
+
componentOutlet: 'ComponentOutlet.mount',
|
|
37
|
+
templateOutlet: 'TemplateOutlet.mount',
|
|
38
|
+
structuralScope: 'StructuralDirective.scope',
|
|
36
39
|
embedded: { collect: 'EmbeddedViews.collect', later: 'EmbeddedViews.later' },
|
|
37
40
|
everyCheck: { check: 'EveryCheck', content: 'ContentChecked', view: 'ViewChecked' },
|
|
38
41
|
letSlot: 'LetSlot',
|
|
@@ -65,14 +68,21 @@ export default function adapter(core) {
|
|
|
65
68
|
sources.push(...libraries);
|
|
66
69
|
const selectors = new Map();
|
|
67
70
|
const hosts = [];
|
|
71
|
+
const componentSlots = new Map();
|
|
72
|
+
const componentContentQueries = new Map();
|
|
68
73
|
for (const f of sources) {
|
|
69
74
|
const text = read(f);
|
|
70
|
-
const
|
|
71
|
-
for (const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
const found = componentsOf(f, text);
|
|
76
|
+
for (const c of found) {
|
|
77
|
+
for (const tag of c.selector ? selectorElements(c.selector) : [])
|
|
78
|
+
selectors.set(tag, c.name);
|
|
79
|
+
if (c.slots?.length)
|
|
80
|
+
componentSlots.set(c.name, c.slots);
|
|
81
|
+
if (c.contentQueries?.length)
|
|
82
|
+
componentContentQueries.set(c.name, { file: f, queries: c.contentQueries });
|
|
83
|
+
}
|
|
84
|
+
if (found.length)
|
|
85
|
+
hosts.push(...hostedComponents(f, text));
|
|
76
86
|
}
|
|
77
87
|
// The configuration the entry provides, lazy routes followed into their files; else one routes file read flat.
|
|
78
88
|
const tree = angularRouteTree(entry, read, app.aliased);
|
|
@@ -85,15 +95,15 @@ export default function adapter(core) {
|
|
|
85
95
|
// `provideNativeScriptNgZone`, which is `_internalProvideZoneChangeDetection` with its own NgZone) and not `provideZonelessChangeDetection`.
|
|
86
96
|
const texts = [entryText, ...sources.map(read)];
|
|
87
97
|
const zone = texts.some((t) => /\bprovide(ZoneChangeDetection|NativeScriptNgZone)\(/.test(t)) && !texts.some((t) => /\bprovideZonelessChangeDetection\(/.test(t));
|
|
88
|
-
// The pipes templates name: the app's and its libraries' `@Pipe` classes, and @angular/common's
|
|
89
|
-
const pipes = angularPipes(sources, read);
|
|
98
|
+
// The pipes templates name: the app's and its libraries' `@Pipe` classes, published Angular library pipes (`ɵɵPipeDeclaration`), and @angular/common's.
|
|
99
|
+
const pipes = angularPipes([...(entry && !sources.includes(entry) ? [entry] : []), ...sources], read, app.nodeModules);
|
|
90
100
|
// The app's own directives: a library's are written against the view internals a compiled template replaces.
|
|
91
101
|
const directives = angularDirectives(sources.filter((f) => !libraries.includes(f)), read);
|
|
92
102
|
// What each NgModule declares, imports and exports: a component's directives are those in its scope.
|
|
93
103
|
const ngModuleNames = new Map(sources.flatMap((f) => [...declarablesIn(f, read(f), !libraries.includes(f)).modules]));
|
|
94
104
|
const runtimeModule = join(appDir, COMMON_MODULE);
|
|
95
|
-
refuseBaseUses(sources);
|
|
96
|
-
const components = sources.
|
|
105
|
+
refuseBaseUses(sources, undefined, app.aliased);
|
|
106
|
+
const components = sources.flatMap((f) => angularComponents(f, read(f), selectors, { platform, pipes, runtimeModule, directives, ngModules: ngModuleNames, hosts, componentSlots, componentContentQueries, aliased: app.aliased, elements: new Map([...elements].map(([tag, e]) => [tag, e.name])), elementMeta: new Map([...elements].flatMap(([tag, e]) => (e.meta === undefined || (e.meta === null && e.fromApp) ? [] : [[tag, e.meta]]))) }));
|
|
97
107
|
const routed = new Set(tree ? routedComponents(tree.routes) : routes.map((r) => r.component));
|
|
98
108
|
for (const c of components)
|
|
99
109
|
c.page = routed.has(c.name);
|
|
@@ -101,8 +111,31 @@ export default function adapter(core) {
|
|
|
101
111
|
// The classes of registered tags, imported where the build can reach them: route files, which only configure, are not compiled.
|
|
102
112
|
if (elements.size) {
|
|
103
113
|
const file = join(appDir, '__elements.release.ts');
|
|
104
|
-
const
|
|
105
|
-
|
|
114
|
+
const entries = [...elements.entries()];
|
|
115
|
+
const unique = new Map();
|
|
116
|
+
const usedAliases = new Set();
|
|
117
|
+
const aliasOf = (e) => {
|
|
118
|
+
const key = `${e.from}\0${e.name}`;
|
|
119
|
+
const existing = unique.get(key);
|
|
120
|
+
if (existing)
|
|
121
|
+
return existing.alias;
|
|
122
|
+
let alias = e.name;
|
|
123
|
+
let i = 2;
|
|
124
|
+
while (usedAliases.has(alias))
|
|
125
|
+
alias = `${e.name}$${i++}`;
|
|
126
|
+
usedAliases.add(alias);
|
|
127
|
+
unique.set(key, { name: e.name, alias, from: e.from });
|
|
128
|
+
return alias;
|
|
129
|
+
};
|
|
130
|
+
for (const [, e] of entries)
|
|
131
|
+
aliasOf(e);
|
|
132
|
+
const withMeta = entries.filter(([, e]) => !!e.metaCode);
|
|
133
|
+
const imports = [
|
|
134
|
+
...(withMeta.length ? ["import { registerElement } from '@nativescript/angular';"] : []),
|
|
135
|
+
...[...unique.values()].map((u) => `import { ${u.alias === u.name ? u.name : `${u.name} as ${u.alias}`} } from '${u.from}';`),
|
|
136
|
+
].join('\n');
|
|
137
|
+
const registrations = withMeta.map(([tag, e]) => `registerElement(${JSON.stringify(tag)}, () => ${aliasOf(e)}, ${e.metaCode});`).join('\n');
|
|
138
|
+
overrides.set(file, `${imports}\n${registrations ? registrations + '\n' : ''}export function $elements(): any[] { return [${[...unique.values()].map((u) => `new ${u.alias}()`).join(', ')}]; }\n`);
|
|
106
139
|
}
|
|
107
140
|
const modules = [...sources.filter((f) => !routeFiles.has(f) && !components.some((c) => c.file === f.replace(/\.ts$/, '.release.ts'))), ...(elements.size ? [join(appDir, '__elements.release.ts')] : [])];
|
|
108
141
|
// Route files only configure and are not compiled; their guards are, each file's in a module of its own.
|
|
@@ -137,6 +170,15 @@ export default function adapter(core) {
|
|
|
137
170
|
}
|
|
138
171
|
if (!root)
|
|
139
172
|
throw new Error(`${entry}: no bootstrapApplication(Component) or bootstrapModule(AppModule) with a bootstrap component`);
|
|
173
|
+
const hasComponentOutlet = (() => {
|
|
174
|
+
const visit = (nodes) => nodes.some((n) => n.kind === 'componentOutlet'
|
|
175
|
+
|| (Array.isArray(n.children) && visit(n.children))
|
|
176
|
+
|| (Array.isArray(n.body) && visit(n.body))
|
|
177
|
+
|| (Array.isArray(n.branches) && n.branches.some((b) => visit(b.body)))
|
|
178
|
+
|| (Array.isArray(n.fallback) && visit(n.fallback))
|
|
179
|
+
|| (!!n.slots && Object.values(n.slots).some((s) => visit(s))));
|
|
180
|
+
return components.some((c) => visit(c.template));
|
|
181
|
+
})();
|
|
140
182
|
const zoneEnabled = zone ? ' Zone.enabled = true\n' : '';
|
|
141
183
|
return {
|
|
142
184
|
components,
|
|
@@ -146,18 +188,44 @@ export default function adapter(core) {
|
|
|
146
188
|
behaviour,
|
|
147
189
|
elementClasses: new Set([...elements.values()].map((e) => e.name)),
|
|
148
190
|
entry: {
|
|
149
|
-
swift: (ctx) =>
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
191
|
+
swift: (ctx) => {
|
|
192
|
+
const outlets = hasComponentOutlet
|
|
193
|
+
? [...ctx.components.entries()]
|
|
194
|
+
.filter(([, info]) => !(info.props ?? []).some((p) => !(info.optional ?? []).includes(p)))
|
|
195
|
+
.map(([name, info]) => {
|
|
196
|
+
const cls = ctx.className(name);
|
|
197
|
+
const make = `try AngularView.construct { ${info.initThrows ? 'try ' : ''}${cls}() }`;
|
|
198
|
+
const body = info.fragment ? `try ${make}.${info.members.render}(into: region)` : `region.set([try ${make}.${info.members.render}()])`;
|
|
199
|
+
return ` ComponentOutlet.register(${cls}.self) { region, _ in ${body} }\n`;
|
|
200
|
+
})
|
|
201
|
+
.join('')
|
|
202
|
+
: '';
|
|
203
|
+
return {
|
|
204
|
+
setup: zoneEnabled,
|
|
205
|
+
beforeRoot: outlets + (tree
|
|
206
|
+
? ` Router.shared.config = ${swiftRouteConfig(tree.routes, ' ', ctx)}\n`
|
|
207
|
+
: ` Router.shared.routes = [${routes.map((r) => `Route(${JSON.stringify(r.path)}) { ${ctx.rootView(r.component, `try AngularView.construct { ${ctx.components.get(r.component)?.initThrows ? 'try ' : ''}${ctx.className(r.component)}() }.${ctx.components.get(r.component).members.render}()`)} }`).join(', ')}]\n Router.shared.initial = ${JSON.stringify(initial)}\n`),
|
|
208
|
+
};
|
|
209
|
+
},
|
|
210
|
+
kotlin: (ctx) => {
|
|
211
|
+
const outlets = hasComponentOutlet
|
|
212
|
+
? [...ctx.components.entries()]
|
|
213
|
+
.filter(([, info]) => !(info.props ?? []).some((p) => !(info.optional ?? []).includes(p)))
|
|
214
|
+
.map(([name, info]) => {
|
|
215
|
+
const cls = ctx.className(name);
|
|
216
|
+
const make = `AngularView.construct { ${cls}() }`;
|
|
217
|
+
const body = info.fragment ? `${make}.${info.members.render}(region)` : `region.set(listOf(${make}.${info.members.render}()))`;
|
|
218
|
+
return ` ComponentOutlet.register(${cls}::class.java) { region, _ -> ${body} }\n`;
|
|
219
|
+
})
|
|
220
|
+
.join('')
|
|
221
|
+
: '';
|
|
222
|
+
return {
|
|
223
|
+
setup: zoneEnabled,
|
|
224
|
+
beforeRoot: outlets + (tree
|
|
225
|
+
? ` Router.shared.config = ${kotlinRouteConfig(tree.routes, ' ', ctx)}\n`
|
|
226
|
+
: ` Router.shared.routes = listOf(${routes.map((r) => `Route(${ctx.string(r.path)}) { ${ctx.rootView(r.component, `AngularView.construct { ${r.component}() }.${ctx.components.get(r.component).members.render}()`)} }`).join(', ')})\n Router.shared.initial = ${ctx.string(initial)}\n`),
|
|
227
|
+
};
|
|
228
|
+
},
|
|
161
229
|
},
|
|
162
230
|
};
|
|
163
231
|
},
|
package/dist/kotlin.js
CHANGED
|
@@ -12,10 +12,8 @@ function tokenName(t, e) {
|
|
|
12
12
|
// A program's class by its Kotlin name, whatever the import calls it (`RouterExtensions as $RouterExtensions`).
|
|
13
13
|
return file.isDeclarationFile ? e.getText() : t.topName(decl, decl.name.text);
|
|
14
14
|
}
|
|
15
|
-
/** What `inject(token)` gives at `at
|
|
15
|
+
/** What `inject(token)` gives at `at`. */
|
|
16
16
|
function injectedToken(t, token, at, decl) {
|
|
17
|
-
if (token === 'ViewContainerRef')
|
|
18
|
-
throw t.error(at, 'an injected ViewContainerRef', 'view-container-ref');
|
|
19
17
|
const code = injected('kotlin', token, at, decl && ts.isClassDeclaration(decl) ? injectableShared(decl, t.pluginFiles, t.checker) : undefined);
|
|
20
18
|
// A `shared` the module's statements initialize is held nullable until they run, which they have by injection.
|
|
21
19
|
const shared = decl && ts.isClassDeclaration(decl) ? decl.members.find((m) => ts.isPropertyDeclaration(m) && isStatic(m) && m.name.getText() === 'shared') : undefined;
|
|
@@ -187,6 +185,11 @@ function globalCall(t, name, e, decl, lib) {
|
|
|
187
185
|
}
|
|
188
186
|
if (name === 'firstValueFrom' && lib)
|
|
189
187
|
return `rxFirstValueFrom(${t.expr(arg(0))})`;
|
|
188
|
+
if (name === 'registerElement' && (lib || core.adapterRuntimeFile(decl?.getSourceFile().fileName) === 'runtime/angular-rx.ts')) {
|
|
189
|
+
return e.arguments.length >= 3 && arg(2)
|
|
190
|
+
? `kitRegisterViewMeta(${t.str(arg(0))}, ${t.coerce(arg(1), 'Any?')}, ${t.coerce(arg(2), 'Any?')})`
|
|
191
|
+
: 'Unit';
|
|
192
|
+
}
|
|
190
193
|
return undefined;
|
|
191
194
|
}
|
|
192
195
|
function methodCall(t, owner, method, e) {
|
|
@@ -198,8 +201,6 @@ function methodCall(t, owner, method, e) {
|
|
|
198
201
|
}
|
|
199
202
|
if (owner === 'Injector' && method === 'get' && e.arguments[0]) {
|
|
200
203
|
const rawArg0 = forwardRefTarget(e.arguments[0]);
|
|
201
|
-
if (tokenName(t, ts.isExpressionWithTypeArguments(rawArg0) ? rawArg0.expression : rawArg0) === 'ViewContainerRef')
|
|
202
|
-
throw t.error(e, 'an injected ViewContainerRef', 'view-container-ref');
|
|
203
204
|
const raw = `${t.expr(target)}.get(${t.coerce(rawArg0, 'Any?')}${e.arguments[1] ? `, ${t.coerce(e.arguments[1], 'Any?')}` : ''}${e.arguments[2] ? `, ${t.coerce(e.arguments[2], 'Any?')}` : ''})`;
|
|
204
205
|
const type = t.typeOf(e);
|
|
205
206
|
return type === 'Any?' ? raw : t.fromAny(raw, type);
|
|
@@ -230,7 +231,7 @@ export const kotlinHooks = {
|
|
|
230
231
|
'TeardownHandle', 'NavigationEnd', 'NavigationStart', 'NavigationCancel', 'NavigationError', 'RoutesRecognized', 'ResolveStart', 'ResolveEnd',
|
|
231
232
|
'HttpParams', 'HttpHeaders', 'HttpResponse', 'HttpErrorResponse', 'HttpRequest', 'HttpContext', 'HttpContextToken',
|
|
232
233
|
'ParamMap', 'UrlSegment', 'UrlTree', 'DefaultUrlSerializer', 'ActivatedRouteSnapshot',
|
|
233
|
-
'ViewContainerRef', 'TemplateRef', 'ComponentRef', 'EmbeddedViewRef', 'ApplicationRef', 'Location'].map((n) => [n, { type: n, shim: true }])),
|
|
234
|
+
'ViewContainerRef', 'TemplateRef', 'ComponentRef', 'EmbeddedViewRef', 'ApplicationRef', 'Location', 'PendingTasks', 'Renderer2', 'RendererFactory2'].map((n) => [n, { type: n, shim: true }])),
|
|
234
235
|
},
|
|
235
236
|
globalCall,
|
|
236
237
|
methodCall,
|
|
@@ -263,9 +264,10 @@ export const kotlinHooks = {
|
|
|
263
264
|
const ngImports = standaloneImports(cls, t.checker, t.compiles);
|
|
264
265
|
return ngImports ? [` val jsNgImports: Any? by lazy { jsArrayOf<Any?>(${ngImports.map((e) => t.coerce(e, 'Any?')).join(', ')}) }`] : [];
|
|
265
266
|
},
|
|
266
|
-
componentAsValue: (t, cls, type) => `ComponentFactory { ${t.rootView(cls, type, `AngularView.construct { ${type}() }.${t.components.get(cls.name.text)
|
|
267
|
+
componentAsValue: (t, cls, type) => `ComponentFactory(${type}::class.java) { ${t.rootView(cls, type, `AngularView.construct { ${type}() }.${t.components.get(cls.name.text)?.members?.render ?? 'render'}()`)} }`,
|
|
267
268
|
/** A component created as a root view (bootstrap, route, dialog): made and rendered in its standalone injector. */
|
|
268
269
|
wrapRootView: (t, cls, type, make) => (standaloneImports(cls, t.checker, t.compiles) ? `Injector.standalone(${type}::class.java, ${type}.jsNgImports) { ${make} }` : make),
|
|
270
|
+
dynamicImport: (specifier) => specifier === '@angular/compiler' ? 'JSPromise.reject<Any?>(JSError("Dynamic import(\'@angular/compiler\') is not available in AOT release builds"))' : undefined,
|
|
269
271
|
serviceClass(t, cls, name) {
|
|
270
272
|
const { params, lines, statics } = t.componentMembers(cls, [], true);
|
|
271
273
|
return [`class ${name}(${params.join(', ')}) {`, ...lines, '', ' companion object {', ` val shared: ${name} get() = AppInjector.service(${name}::class.java) { ${name}() }`, ...statics, ' }', '}'].join('\n');
|