1 | /// <amd-module name="@angular/compiler-cli/ngcc/src/execution/tasks/api" />
|
---|
2 | /**
|
---|
3 | * @license
|
---|
4 | * Copyright Google LLC All Rights Reserved.
|
---|
5 | *
|
---|
6 | * Use of this source code is governed by an MIT-style license that can be
|
---|
7 | * found in the LICENSE file at https://angular.io/license
|
---|
8 | */
|
---|
9 | import { EntryPoint, EntryPointJsonProperty, JsonObject } from '../../packages/entry_point';
|
---|
10 | import { PartiallyOrderedList } from '../../utils';
|
---|
11 | /**
|
---|
12 | * Represents a unit of work to be undertaken by an `Executor`.
|
---|
13 | *
|
---|
14 | * A task consists of processing a specific format property of an entry-point.
|
---|
15 | * This may or may not also include processing the typings for that entry-point, which only needs to
|
---|
16 | * happen once across all the formats.
|
---|
17 | */
|
---|
18 | export interface Task extends JsonObject {
|
---|
19 | /** The `EntryPoint` which needs to be processed as part of the task. */
|
---|
20 | entryPoint: EntryPoint;
|
---|
21 | /**
|
---|
22 | * The `package.json` format property to process (i.e. the property which points to the file that
|
---|
23 | * is the program entry-point).
|
---|
24 | */
|
---|
25 | formatProperty: EntryPointJsonProperty;
|
---|
26 | /**
|
---|
27 | * The list of all format properties (including `task.formatProperty`) that should be marked as
|
---|
28 | * processed once the task has been completed, because they point to the format-path that will be
|
---|
29 | * processed as part of the task.
|
---|
30 | */
|
---|
31 | formatPropertiesToMarkAsProcessed: EntryPointJsonProperty[];
|
---|
32 | /**
|
---|
33 | * Whether to process typings for this entry-point as part of the task.
|
---|
34 | */
|
---|
35 | processDts: DtsProcessing;
|
---|
36 | }
|
---|
37 | /**
|
---|
38 | * The options for processing Typescript typings (.d.ts) files.
|
---|
39 | */
|
---|
40 | export declare enum DtsProcessing {
|
---|
41 | /**
|
---|
42 | * Yes, process the typings for this entry point as part of the task.
|
---|
43 | */
|
---|
44 | Yes = 0,
|
---|
45 | /**
|
---|
46 | * No, do not process the typings as part of this task - they must have already been processed by
|
---|
47 | * another task or previous ngcc process.
|
---|
48 | */
|
---|
49 | No = 1,
|
---|
50 | /**
|
---|
51 | * Only process the typings for this entry-point; do not render any JavaScript files for the
|
---|
52 | * `formatProperty` of this task.
|
---|
53 | */
|
---|
54 | Only = 2
|
---|
55 | }
|
---|
56 | /**
|
---|
57 | * Represents a partially ordered list of tasks.
|
---|
58 | *
|
---|
59 | * The ordering/precedence of tasks is determined by the inter-dependencies between their associated
|
---|
60 | * entry-points. Specifically, the tasks' order/precedence is such that tasks associated to
|
---|
61 | * dependent entry-points always come after tasks associated with their dependencies.
|
---|
62 | *
|
---|
63 | * As result of this ordering, it is guaranteed that - by processing tasks in the order in which
|
---|
64 | * they appear in the list - a task's dependencies will always have been processed before processing
|
---|
65 | * the task itself.
|
---|
66 | *
|
---|
67 | * See `DependencyResolver#sortEntryPointsByDependency()`.
|
---|
68 | */
|
---|
69 | export declare type PartiallyOrderedTasks = PartiallyOrderedList<Task>;
|
---|
70 | /**
|
---|
71 | * A mapping from Tasks to the Tasks that depend upon them (dependents).
|
---|
72 | */
|
---|
73 | export declare type TaskDependencies = Map<Task, Set<Task>>;
|
---|
74 | export declare const TaskDependencies: MapConstructor;
|
---|
75 | /**
|
---|
76 | * A function to create a TaskCompletedCallback function.
|
---|
77 | */
|
---|
78 | export declare type CreateTaskCompletedCallback = (taskQueue: TaskQueue) => TaskCompletedCallback;
|
---|
79 | /**
|
---|
80 | * A function to be called once a task has been processed.
|
---|
81 | */
|
---|
82 | export declare type TaskCompletedCallback = (task: Task, outcome: TaskProcessingOutcome, message: string | null) => void;
|
---|
83 | /**
|
---|
84 | * Represents the outcome of processing a `Task`.
|
---|
85 | */
|
---|
86 | export declare const enum TaskProcessingOutcome {
|
---|
87 | /** Successfully processed the target format property. */
|
---|
88 | Processed = 0,
|
---|
89 | /** Failed to process the target format. */
|
---|
90 | Failed = 1
|
---|
91 | }
|
---|
92 | /**
|
---|
93 | * A wrapper around a list of tasks and providing utility methods for getting the next task of
|
---|
94 | * interest and determining when all tasks have been completed.
|
---|
95 | *
|
---|
96 | * (This allows different implementations to impose different constraints on when a task's
|
---|
97 | * processing can start.)
|
---|
98 | */
|
---|
99 | export interface TaskQueue {
|
---|
100 | /** Whether all tasks have been completed. */
|
---|
101 | allTasksCompleted: boolean;
|
---|
102 | /**
|
---|
103 | * Get the next task whose processing can start (if any).
|
---|
104 | *
|
---|
105 | * This implicitly marks the task as in-progress.
|
---|
106 | * (This information is used to determine whether all tasks have been completed.)
|
---|
107 | *
|
---|
108 | * @return The next task available for processing or `null`, if no task can be processed at the
|
---|
109 | * moment (including if there are no more unprocessed tasks).
|
---|
110 | */
|
---|
111 | getNextTask(): Task | null;
|
---|
112 | /**
|
---|
113 | * Mark a task as completed.
|
---|
114 | *
|
---|
115 | * This removes the task from the internal list of in-progress tasks.
|
---|
116 | * (This information is used to determine whether all tasks have been completed.)
|
---|
117 | *
|
---|
118 | * @param task The task to mark as completed.
|
---|
119 | */
|
---|
120 | markAsCompleted(task: Task): void;
|
---|
121 | /**
|
---|
122 | * Mark a task as failed.
|
---|
123 | *
|
---|
124 | * Do not process the tasks that depend upon the given task.
|
---|
125 | */
|
---|
126 | markAsFailed(task: Task): void;
|
---|
127 | /**
|
---|
128 | * Mark a task as not processed (i.e. add an in-progress task back to the queue).
|
---|
129 | *
|
---|
130 | * This removes the task from the internal list of in-progress tasks and adds it back to the list
|
---|
131 | * of pending tasks.
|
---|
132 | *
|
---|
133 | * @param task The task to mark as not processed.
|
---|
134 | */
|
---|
135 | markAsUnprocessed(task: Task): void;
|
---|
136 | /**
|
---|
137 | * Return a string representation of the task queue (for debugging purposes).
|
---|
138 | *
|
---|
139 | * @return A string representation of the task queue.
|
---|
140 | */
|
---|
141 | toString(): string;
|
---|
142 | }
|
---|