@hamur/adapter-angular 0.0.1 → 0.0.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.
- package/dist/src/adapter.js +88 -37
- package/dist/types/src/app.d.ts +3 -0
- package/dist/types/src/client-parts.d.ts +3 -0
- package/dist/types/src/compile.d.ts +13 -3
- package/dist/types/src/data.d.ts +3 -3
- package/dist/types/src/error-page.d.ts +5 -2
- package/dist/types/src/form.d.ts +16 -13
- package/dist/types/src/hmr.d.ts +1 -1
- package/dist/types/src/indicators.d.ts +15 -8
- package/dist/types/src/island.d.ts +9 -6
- package/dist/types/src/link.d.ts +25 -22
- package/dist/types/src/markdown.d.ts +6 -3
- package/dist/types/src/navigate.d.ts +6 -3
- package/dist/types/src/outlet.d.ts +10 -5
- package/dist/types/src/server-island.d.ts +6 -3
- package/dist/types/src/time.d.ts +28 -25
- package/package.json +30 -9
- package/src/app.ts +11 -5
- package/src/client-parts.ts +83 -103
- package/src/compile.ts +123 -60
- package/src/data.ts +3 -3
- package/src/error-page.ts +23 -10
- package/src/form.ts +166 -237
- package/src/hmr.ts +3 -2
- package/src/indicators.ts +198 -229
- package/src/island.ts +78 -84
- package/src/link.ts +204 -241
- package/src/markdown.ts +129 -159
- package/src/navigate.ts +20 -17
- package/src/outlet.ts +297 -325
- package/src/server-island.ts +62 -49
- package/src/time.ts +108 -101
package/src/compile.ts
CHANGED
|
@@ -8,8 +8,11 @@ import type { AdapterBuildContext, AdapterTransform } from "hamur/adapter"
|
|
|
8
8
|
import { readDefinition, selectorOf } from "./definition.ts"
|
|
9
9
|
|
|
10
10
|
const COMPILE_ID = /^(?!.*[\\/]node_modules[\\/]).*\.[cm]?ts$/
|
|
11
|
-
|
|
11
|
+
/** Packages of the `@hamur` scope ship their partial-compiled components under the name of the source, `src/<name>.ts`. */
|
|
12
|
+
const LINK_ID = /[\\/]node_modules[\\/](?:.+\.m?js|(?:.+[\\/])?@hamur[\\/][^\\/]+[\\/]src[\\/].+\.ts)$/
|
|
12
13
|
|
|
14
|
+
/** The generated types reach the sources of installed packages, which are not the program's to emit. */
|
|
15
|
+
const INSTALLED = /[\\/]node_modules[\\/]/
|
|
13
16
|
const SCRIPT = /\.[cm]?ts$/
|
|
14
17
|
const DECORATED = /^\s*@(?:Component|Directive|Pipe|NgModule|Injectable)\s*\(/m
|
|
15
18
|
const ENTRY = /^(?:(pages|layouts)\/.+|(app|error))\.[cm]?ts$/
|
|
@@ -40,6 +43,8 @@ interface Angular {
|
|
|
40
43
|
export interface AngularEmit {
|
|
41
44
|
code: string
|
|
42
45
|
map?: string
|
|
46
|
+
/** The declarations, emitted by `compilePartial` only. */
|
|
47
|
+
types?: string
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
/** One error line of the program, with the real path of the file it names. */
|
|
@@ -152,10 +157,21 @@ function workspaceRoot(rootDir: string, base: ts.CompilerOptions): ts.CompilerOp
|
|
|
152
157
|
return { rootDir: root, ...(base.rootDirs ? { rootDirs: [...base.rootDirs, root] } : {}) }
|
|
153
158
|
}
|
|
154
159
|
|
|
155
|
-
/**
|
|
156
|
-
function
|
|
160
|
+
/** The generated file that references every other one, so `Route.Name` and the other registered types mean in a build what they mean in `hamur typecheck`. */
|
|
161
|
+
function generatedTypes(buildDir: string): string[] {
|
|
162
|
+
const file = join(buildDir, "types/hamur.d.ts")
|
|
163
|
+
return existsSync(file) ? [file] : []
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Every `.ts` file under `app/`, the package's own components, then the generated types; `server/` is never a root. */
|
|
167
|
+
function rootNames({ rootDir, buildDir }: AdapterBuildContext): string[] {
|
|
157
168
|
const app = join(rootDir, "app")
|
|
158
|
-
return [
|
|
169
|
+
return [
|
|
170
|
+
...(existsSync(app) ? scripts(app) : []),
|
|
171
|
+
...ownComponents(),
|
|
172
|
+
...moduleComponents(rootDir),
|
|
173
|
+
...generatedTypes(buildDir),
|
|
174
|
+
]
|
|
159
175
|
}
|
|
160
176
|
|
|
161
177
|
const shown = (rootDir: string, file: string): string => relative(rootDir, file).split(sep).join("/")
|
|
@@ -259,6 +275,7 @@ function compilerHost(ng: Angular, options: AngularCli.CompilerOptions, setup: H
|
|
|
259
275
|
const key = real(source.fileName)
|
|
260
276
|
const entry = setup.files.get(key) ?? { code: "" }
|
|
261
277
|
if (fileName.endsWith(".map")) entry.map = text
|
|
278
|
+
else if (fileName.endsWith(".d.ts")) entry.types = text
|
|
262
279
|
else if (/\.[cm]?js$/.test(fileName)) entry.code = text.replace(MAP_COMMENT, "")
|
|
263
280
|
else return
|
|
264
281
|
setup.files.set(key, entry)
|
|
@@ -284,23 +301,15 @@ function compilerHost(ng: Angular, options: AngularCli.CompilerOptions, setup: H
|
|
|
284
301
|
return host
|
|
285
302
|
}
|
|
286
303
|
|
|
287
|
-
/** The errors
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
program: AngularCli.NgtscProgram,
|
|
291
|
-
rootDir: string,
|
|
292
|
-
check?: (program: ts.Program) => Problem[],
|
|
293
|
-
): Problem[] {
|
|
294
|
-
const problems = [
|
|
295
|
-
...program.getNgOptionDiagnostics(),
|
|
296
|
-
...program.getNgStructuralDiagnostics(),
|
|
297
|
-
...program.getNgSemanticDiagnostics(),
|
|
298
|
-
]
|
|
304
|
+
/** The errors among `diagnostics`; warnings are not printed. */
|
|
305
|
+
const errorsOf = (ng: Angular, diagnostics: readonly ts.Diagnostic[], rootDir: string): Problem[] =>
|
|
306
|
+
diagnostics
|
|
299
307
|
.filter((diagnostic) => diagnostic.category === ng.ts.DiagnosticCategory.Error)
|
|
300
308
|
.map((diagnostic) => diagnosticProblem(ng.ts, diagnostic, rootDir))
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
309
|
+
|
|
310
|
+
/** The errors that belong to no file's own check. */
|
|
311
|
+
const programErrors = (ng: Angular, program: AngularCli.NgtscProgram, rootDir: string): Problem[] =>
|
|
312
|
+
errorsOf(ng, [...program.getNgOptionDiagnostics(), ...program.getNgStructuralDiagnostics()], rootDir)
|
|
304
313
|
|
|
305
314
|
/**
|
|
306
315
|
* Emits the source files whose real path `emits` keeps. TypeScript type-checks each file it emits in full, and in the
|
|
@@ -322,6 +331,48 @@ function emitOnly(program: AngularCli.NgtscProgram, emits: (file: string) => boo
|
|
|
322
331
|
})
|
|
323
332
|
}
|
|
324
333
|
|
|
334
|
+
interface ParsedFile {
|
|
335
|
+
stamp: string
|
|
336
|
+
file: ts.SourceFile
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Reads a source file from `parsed` while its stamp or its text stays the same; `stamp` is empty for a file that does not
|
|
341
|
+
* change. A declaration file parsed again makes Angular compile and emit the whole program again, and `hamur dev` writes
|
|
342
|
+
* its types again, often with the same text, whenever a file is added or removed.
|
|
343
|
+
*/
|
|
344
|
+
function reuseSourceFiles(
|
|
345
|
+
host: AngularCli.CompilerHost,
|
|
346
|
+
parsed: Map<string, ParsedFile>,
|
|
347
|
+
stampOfFile: (file: string) => string,
|
|
348
|
+
): void {
|
|
349
|
+
const read = host.getSourceFile.bind(host)
|
|
350
|
+
host.getSourceFile = (fileName, language, onError, fresh) => {
|
|
351
|
+
const stamp = stampOfFile(fileName)
|
|
352
|
+
const hit = parsed.get(fileName)
|
|
353
|
+
if (hit && hit.stamp === stamp && !fresh) return hit.file
|
|
354
|
+
const file = read(fileName, language, onError, fresh)
|
|
355
|
+
if (!file) return file
|
|
356
|
+
const same = hit && !fresh && hit.file.text === file.text
|
|
357
|
+
parsed.set(fileName, { stamp, file: same ? hit.file : file })
|
|
358
|
+
return same ? hit.file : file
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/** What the programs of the builds parsed, per compiler: the app's program and one per generated module read the same thousands of files. */
|
|
363
|
+
let buildSources = new WeakMap<Angular, Map<string, ParsedFile>>()
|
|
364
|
+
|
|
365
|
+
/** Drops the parsed files, which hold hundreds of megabytes, at the end of a build. */
|
|
366
|
+
export function releaseBuildSources(): void {
|
|
367
|
+
buildSources = new WeakMap()
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function sourcesOf(ng: Angular): Map<string, ParsedFile> {
|
|
371
|
+
let parsed = buildSources.get(ng)
|
|
372
|
+
if (!parsed) buildSources.set(ng, (parsed = new Map()))
|
|
373
|
+
return parsed
|
|
374
|
+
}
|
|
375
|
+
|
|
325
376
|
/** One `NgtscProgram` over `roots`, emitted into memory for the files `emits` keeps: real source path to its JavaScript and, with `sourceMap`, its map. */
|
|
326
377
|
async function emitProgram(
|
|
327
378
|
ng: Angular,
|
|
@@ -330,16 +381,19 @@ async function emitProgram(
|
|
|
330
381
|
options: AngularCli.CompilerOptions,
|
|
331
382
|
preprocessStyle: AdapterBuildContext["preprocessStyle"],
|
|
332
383
|
emits: (file: string) => boolean,
|
|
384
|
+
parsed?: Map<string, ParsedFile>,
|
|
333
385
|
check?: (program: ts.Program) => Problem[],
|
|
334
386
|
): Promise<Map<string, AngularEmit>> {
|
|
335
387
|
const files = new Map<string, AngularEmit>()
|
|
336
|
-
const
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
compilerHost(ng, options, { rootDir, preprocessStyle, files }),
|
|
340
|
-
)
|
|
388
|
+
const host = compilerHost(ng, options, { rootDir, preprocessStyle, files })
|
|
389
|
+
if (parsed) reuseSourceFiles(host, parsed, stampOf)
|
|
390
|
+
const program = new ng.cli.NgtscProgram(roots, options, host)
|
|
341
391
|
await program.loadNgStructureAsync()
|
|
342
|
-
const problems =
|
|
392
|
+
const problems = [
|
|
393
|
+
...programErrors(ng, program, rootDir),
|
|
394
|
+
...errorsOf(ng, program.getNgSemanticDiagnostics(), rootDir),
|
|
395
|
+
...(check?.(program.getTsProgram()) ?? []),
|
|
396
|
+
]
|
|
343
397
|
if (problems.length) throw new Error(problems.map((problem) => problem.line).join("\n"))
|
|
344
398
|
// A load file's `#server` pulls `server/` into the program; its emit must not replace the server files in the client build.
|
|
345
399
|
const server = `${real(join(rootDir, "server"))}${sep}`
|
|
@@ -397,7 +451,7 @@ const programs = new Map<string, { stamp: string; files: Promise<Map<string, Ang
|
|
|
397
451
|
* find the same roots unchanged and take the same emit; a later build in the process whose roots changed compiles again.
|
|
398
452
|
*/
|
|
399
453
|
export function angularProgram(ctx: AdapterBuildContext): Promise<Map<string, AngularEmit>> {
|
|
400
|
-
const roots = rootNames(ctx
|
|
454
|
+
const roots = rootNames(ctx)
|
|
401
455
|
const stamp = roots
|
|
402
456
|
.map((file) => {
|
|
403
457
|
const stat = statSync(file)
|
|
@@ -416,7 +470,8 @@ export function angularProgram(ctx: AdapterBuildContext): Promise<Map<string, An
|
|
|
416
470
|
roots,
|
|
417
471
|
compilerOptions(ng.ts, ctx),
|
|
418
472
|
ctx.preprocessStyle,
|
|
419
|
-
(path) => path.startsWith(app) || own.has(path),
|
|
473
|
+
(path) => (path.startsWith(app) && !INSTALLED.test(path)) || own.has(path),
|
|
474
|
+
ctx.dev ? undefined : sourcesOf(ng),
|
|
420
475
|
(program) => defaultExportErrors(ng.ts, program, ctx.rootDir, roots),
|
|
421
476
|
),
|
|
422
477
|
)
|
|
@@ -486,7 +541,8 @@ export interface AngularHotUpdate {
|
|
|
486
541
|
/**
|
|
487
542
|
* Built on the first load, then built again with the last good `NgtscProgram` as `oldProgram` when a load finds a
|
|
488
543
|
* root whose text, or a resource whose stamp, changed. Unchanged source files keep their `ts.SourceFile`, so Angular reuses
|
|
489
|
-
* their analysis and emits only the files the change reaches.
|
|
544
|
+
* their analysis and emits only the files the change reaches. A file is type-checked when it is loaded: checking the whole
|
|
545
|
+
* program takes over a second, and an error only shows on the file that has it.
|
|
490
546
|
*/
|
|
491
547
|
export class AngularDevProgram {
|
|
492
548
|
/** The real paths the last build emitted. */
|
|
@@ -499,13 +555,17 @@ export class AngularDevProgram {
|
|
|
499
555
|
private readonly files = new Map<string, AngularEmit>()
|
|
500
556
|
/** Real path of each source file of the program to the text it compiled. */
|
|
501
557
|
private readonly texts = new Map<string, string>()
|
|
558
|
+
/** Real path of each source file of the program to its name there. */
|
|
559
|
+
private readonly fileNames = new Map<string, string>()
|
|
502
560
|
/** Each resource the program read (templates, style files, a style file's imports) to its stamp when read. */
|
|
503
561
|
private readonly resources = new Map<string, string>()
|
|
504
562
|
/** A style file's import to the style files that import it: Angular tracks the style file, not its imports. */
|
|
505
563
|
private readonly importers = new Map<string, Set<string>>()
|
|
506
|
-
private readonly sourceFiles = new Map<string,
|
|
564
|
+
private readonly sourceFiles = new Map<string, ParsedFile>()
|
|
507
565
|
/** Real path of each component file to the real paths of the resources it reads (`getResourceDependencies`). */
|
|
508
566
|
private readonly resourcesOf = new Map<string, Set<string>>()
|
|
567
|
+
/** Real path of each file checked since the last build to its errors. */
|
|
568
|
+
private readonly checked = new Map<string, Problem[]>()
|
|
509
569
|
/** Component files a hot update left with errors. */
|
|
510
570
|
private readonly broken = new Set<string>()
|
|
511
571
|
private options: AngularCli.CompilerOptions | undefined
|
|
@@ -525,7 +585,7 @@ export class AngularDevProgram {
|
|
|
525
585
|
|
|
526
586
|
/** As in a build: a load file's `#server` pulls `server/` into the program, whose emit must not replace the server files in the client. */
|
|
527
587
|
private emits(path: string): boolean {
|
|
528
|
-
return (path.startsWith(this.root) && !path.startsWith(this.server)) || this.own.has(path)
|
|
588
|
+
return (path.startsWith(this.root) && !path.startsWith(this.server) && !INSTALLED.test(path)) || this.own.has(path)
|
|
529
589
|
}
|
|
530
590
|
|
|
531
591
|
/** The emit of `path` (a real path) after any build its load calls for; throws the program's errors for that file. */
|
|
@@ -541,13 +601,23 @@ export class AngularDevProgram {
|
|
|
541
601
|
await next
|
|
542
602
|
if (this.failure) throw this.failure
|
|
543
603
|
if (!this.texts.has(path)) return undefined
|
|
544
|
-
const problems = this.
|
|
545
|
-
(problem) => problem.file === undefined || problem.file === path || this.reads(path, problem.file),
|
|
546
|
-
)
|
|
604
|
+
const problems = await this.problemsOf(path)
|
|
547
605
|
if (problems.length) throw new Error(problems.map((problem) => problem.line).join("\n"))
|
|
548
606
|
return this.files.get(path)
|
|
549
607
|
}
|
|
550
608
|
|
|
609
|
+
private async problemsOf(path: string): Promise<Problem[]> {
|
|
610
|
+
const { program } = this
|
|
611
|
+
const fileName = this.fileNames.get(path)
|
|
612
|
+
let own = this.checked.get(path)
|
|
613
|
+
if (!own && program && fileName !== undefined) {
|
|
614
|
+
const ng = await loadAngular(this.ctx.rootDir)
|
|
615
|
+
own = errorsOf(ng, program.getNgSemanticDiagnostics(fileName), this.ctx.rootDir)
|
|
616
|
+
if (program === this.program) this.checked.set(path, own)
|
|
617
|
+
}
|
|
618
|
+
return [...this.problems.filter((problem) => problem.file === undefined || problem.file === path), ...(own ?? [])]
|
|
619
|
+
}
|
|
620
|
+
|
|
551
621
|
private stale(path: string, text: string | undefined): boolean {
|
|
552
622
|
const compiled = this.texts.get(path)
|
|
553
623
|
if (compiled !== undefined) return compiled !== text
|
|
@@ -587,14 +657,9 @@ export class AngularDevProgram {
|
|
|
587
657
|
await next
|
|
588
658
|
const components = this.dependentsOf(path)
|
|
589
659
|
const program = this.program
|
|
590
|
-
const failing =
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
: components.filter((component) =>
|
|
594
|
-
this.problems.some(
|
|
595
|
-
(problem) => problem.file === component || (!!problem.file && this.reads(component, problem.file)),
|
|
596
|
-
),
|
|
597
|
-
)
|
|
660
|
+
const failing: string[] = []
|
|
661
|
+
for (const component of components)
|
|
662
|
+
if (this.failure || !program || (await this.problemsOf(component)).length) failing.push(component)
|
|
598
663
|
if (failing.length || !program) {
|
|
599
664
|
for (const component of failing) this.broken.add(component)
|
|
600
665
|
return { updates: [], reload: failing }
|
|
@@ -646,7 +711,7 @@ export class AngularDevProgram {
|
|
|
646
711
|
private async build(modified: string[]): Promise<void> {
|
|
647
712
|
const ng = await loadAngular(this.ctx.rootDir)
|
|
648
713
|
const options = (this.options ??= compilerOptions(ng.ts, this.ctx))
|
|
649
|
-
const roots = rootNames(this.ctx
|
|
714
|
+
const roots = rootNames(this.ctx)
|
|
650
715
|
const written = new Map<string, AngularEmit>()
|
|
651
716
|
const host = compilerHost(ng, options, {
|
|
652
717
|
rootDir: this.ctx.rootDir,
|
|
@@ -661,15 +726,7 @@ export class AngularDevProgram {
|
|
|
661
726
|
},
|
|
662
727
|
})
|
|
663
728
|
host.getModifiedResourceFiles = () => new Set(modified)
|
|
664
|
-
|
|
665
|
-
host.getSourceFile = (fileName, language, onError, fresh) => {
|
|
666
|
-
const stamp = /[\\/]node_modules[\\/]/.test(fileName) ? "" : stampOf(fileName)
|
|
667
|
-
const hit = this.sourceFiles.get(fileName)
|
|
668
|
-
if (hit && hit.stamp === stamp && !fresh) return hit.file
|
|
669
|
-
const file = read(fileName, language, onError, fresh)
|
|
670
|
-
if (file) this.sourceFiles.set(fileName, { stamp, file })
|
|
671
|
-
return file
|
|
672
|
-
}
|
|
729
|
+
reuseSourceFiles(host, this.sourceFiles, (file) => (INSTALLED.test(file) ? "" : stampOf(file)))
|
|
673
730
|
for (const file of modified) this.resources.set(file, stampOf(file))
|
|
674
731
|
const program = new ng.cli.NgtscProgram(roots, options, host, this.program)
|
|
675
732
|
this.built = true
|
|
@@ -687,9 +744,11 @@ export class AngularDevProgram {
|
|
|
687
744
|
const resources = program.compiler.getResourceDependencies(source)
|
|
688
745
|
if (resources.length) this.resourcesOf.set(real(source.fileName), new Set(resources.map(real)))
|
|
689
746
|
}
|
|
690
|
-
this.
|
|
691
|
-
|
|
692
|
-
|
|
747
|
+
this.checked.clear()
|
|
748
|
+
this.problems = [
|
|
749
|
+
...programErrors(ng, program, this.ctx.rootDir),
|
|
750
|
+
...defaultExportErrors(ng.ts, program.getTsProgram(), this.ctx.rootDir, roots),
|
|
751
|
+
]
|
|
693
752
|
emitOnly(program, (path) => this.emits(path))
|
|
694
753
|
this.program = program
|
|
695
754
|
this.emitted = [...written.keys()].filter((file) => this.texts.has(file))
|
|
@@ -699,10 +758,13 @@ export class AngularDevProgram {
|
|
|
699
758
|
/** The texts the program compiled, so a load of an unchanged file does not build again, even when the build fails. */
|
|
700
759
|
private record(program: AngularCli.NgtscProgram): void {
|
|
701
760
|
this.texts.clear()
|
|
761
|
+
this.fileNames.clear()
|
|
702
762
|
for (const source of program.getTsProgram().getSourceFiles()) {
|
|
703
763
|
if (source.isDeclarationFile) continue
|
|
704
764
|
const path = real(source.fileName)
|
|
705
|
-
if (path.startsWith(this.root)
|
|
765
|
+
if (!path.startsWith(this.root) && !this.own.has(path)) continue
|
|
766
|
+
this.texts.set(path, source.text)
|
|
767
|
+
this.fileNames.set(path, source.fileName)
|
|
706
768
|
}
|
|
707
769
|
}
|
|
708
770
|
}
|
|
@@ -731,10 +793,11 @@ function compileGenerated(ctx: AdapterBuildContext, id: string, code: string): P
|
|
|
731
793
|
const files = await emitProgram(
|
|
732
794
|
ng,
|
|
733
795
|
ctx.rootDir,
|
|
734
|
-
[path],
|
|
796
|
+
[path, ...generatedTypes(ctx.buildDir)],
|
|
735
797
|
{ ...compilerOptions(ng.ts, ctx), _enableHmr: false },
|
|
736
798
|
ctx.preprocessStyle,
|
|
737
799
|
(file) => file === path,
|
|
800
|
+
ctx.dev ? undefined : sourcesOf(ng),
|
|
738
801
|
)
|
|
739
802
|
const emitted = files.get(path)
|
|
740
803
|
if (!emitted)
|
|
@@ -922,8 +985,8 @@ export function linkStep(ctx: AdapterBuildContext): AdapterTransform {
|
|
|
922
985
|
}
|
|
923
986
|
}
|
|
924
987
|
|
|
925
|
-
/** The package's own components in `compilationMode: "partial"`, as `scripts/release.ts` publishes them: real source path to JavaScript. */
|
|
926
|
-
export async function compilePartial(packageDir: string, from = packageDir): Promise<Map<string,
|
|
988
|
+
/** The package's own components in `compilationMode: "partial"`, as `scripts/release.ts` publishes them: real source path to JavaScript and declarations. */
|
|
989
|
+
export async function compilePartial(packageDir: string, from = packageDir): Promise<Map<string, AngularEmit>> {
|
|
927
990
|
const ng = await loadAngular(from)
|
|
928
991
|
const roots = scripts(join(packageDir, "src")).filter(
|
|
929
992
|
(file) => !file.endsWith(".test.ts") && DECORATED.test(readFileSync(file, "utf8")),
|
|
@@ -944,7 +1007,7 @@ export async function compilePartial(packageDir: string, from = packageDir): Pro
|
|
|
944
1007
|
strictTemplates: true,
|
|
945
1008
|
skipLibCheck: true,
|
|
946
1009
|
allowImportingTsExtensions: true,
|
|
947
|
-
declaration:
|
|
1010
|
+
declaration: true,
|
|
948
1011
|
noEmit: false,
|
|
949
1012
|
},
|
|
950
1013
|
undefined,
|
|
@@ -953,7 +1016,7 @@ export async function compilePartial(packageDir: string, from = packageDir): Pro
|
|
|
953
1016
|
return new Map(
|
|
954
1017
|
roots.flatMap((file) => {
|
|
955
1018
|
const emitted = files.get(real(file))
|
|
956
|
-
return emitted ? [[real(file), emitted
|
|
1019
|
+
return emitted ? [[real(file), emitted] as const] : []
|
|
957
1020
|
}),
|
|
958
1021
|
)
|
|
959
1022
|
}
|
package/src/data.ts
CHANGED
|
@@ -54,7 +54,7 @@ export interface InjectAsyncDataOptions<T = unknown, R = T, K extends keyof T &
|
|
|
54
54
|
> {
|
|
55
55
|
/** Signals (or any getters) whose change runs the handler again. `false` is accepted and does nothing: nothing watches implicitly. */
|
|
56
56
|
watch?: ReadonlyArray<() => unknown> | false
|
|
57
|
-
getCachedData?: GetCachedData<T
|
|
57
|
+
getCachedData?: GetCachedData<NoInfer<T>>
|
|
58
58
|
/** Top-level keys of an object result to keep. */
|
|
59
59
|
pick?: readonly K[]
|
|
60
60
|
}
|
|
@@ -215,12 +215,12 @@ export function injectAsyncData<I, R, T = R, K extends keyof T & string = never>
|
|
|
215
215
|
input?: NoInfer<I> | (() => NoInfer<I>),
|
|
216
216
|
options?: InjectAsyncDataOptions<T, R, K, undefined>,
|
|
217
217
|
): AsyncDataResource<PickFrom<T, K>>
|
|
218
|
-
export function injectAsyncData<T =
|
|
218
|
+
export function injectAsyncData<R, T = R, K extends keyof T & string = never, D = T>(
|
|
219
219
|
key: string | (() => string),
|
|
220
220
|
handler: AsyncDataHandler<R>,
|
|
221
221
|
options: InjectAsyncDataOptions<T, R, K, D> & { default: () => D },
|
|
222
222
|
): AsyncDataResource<PickFrom<T, K>, D>
|
|
223
|
-
export function injectAsyncData<T =
|
|
223
|
+
export function injectAsyncData<R, T = R, K extends keyof T & string = never>(
|
|
224
224
|
key: string | (() => string),
|
|
225
225
|
handler: AsyncDataHandler<R>,
|
|
226
226
|
options?: InjectAsyncDataOptions<T, R, K, undefined>,
|
package/src/error-page.ts
CHANGED
|
@@ -1,17 +1,30 @@
|
|
|
1
|
-
import { Component, input } from "@angular/core"
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
@
|
|
5
|
-
|
|
1
|
+
import { Component, input } from "@angular/core";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export default class DefaultErrorPage {
|
|
4
|
+
error = input.required(/* @ts-ignore */
|
|
5
|
+
...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
6
|
+
clearError = input(/* @ts-ignore */
|
|
7
|
+
...(ngDevMode ? [undefined, { debugName: "clearError" }] : /* istanbul ignore next */ []));
|
|
8
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.2", ngImport: i0, type: DefaultErrorPage, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
9
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.3.2", type: DefaultErrorPage, isStandalone: true, selector: "ng-component", inputs: { error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: true, transformFunction: null }, clearError: { classPropertyName: "clearError", publicName: "clearError", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `<main style="font-family: system-ui, sans-serif; text-align: center; padding: 4rem 1rem">
|
|
6
10
|
<h1 style="font-size: 4rem; margin: 0">{{ error().status }}</h1>
|
|
7
11
|
<p>{{ error().message }}</p>
|
|
8
12
|
@if (error().stack) {
|
|
9
13
|
<pre>{{ error().stack }}</pre>
|
|
10
14
|
}
|
|
11
15
|
<a href="/">Back home</a>
|
|
12
|
-
</main>`,
|
|
13
|
-
})
|
|
14
|
-
export default class DefaultErrorPage {
|
|
15
|
-
readonly error = input.required<ErrorPageProps>()
|
|
16
|
-
readonly clearError = input<() => void>()
|
|
16
|
+
</main>`, isInline: true });
|
|
17
17
|
}
|
|
18
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.2", ngImport: i0, type: DefaultErrorPage, decorators: [{
|
|
19
|
+
type: Component,
|
|
20
|
+
args: [{
|
|
21
|
+
template: `<main style="font-family: system-ui, sans-serif; text-align: center; padding: 4rem 1rem">
|
|
22
|
+
<h1 style="font-size: 4rem; margin: 0">{{ error().status }}</h1>
|
|
23
|
+
<p>{{ error().message }}</p>
|
|
24
|
+
@if (error().stack) {
|
|
25
|
+
<pre>{{ error().stack }}</pre>
|
|
26
|
+
}
|
|
27
|
+
<a href="/">Back home</a>
|
|
28
|
+
</main>`,
|
|
29
|
+
}]
|
|
30
|
+
}], propDecorators: { error: [{ type: i0.Input, args: [{ isSignal: true, alias: "error", required: true }] }], clearError: [{ type: i0.Input, args: [{ isSignal: true, alias: "clearError", required: false }] }] } });
|