@angular-devkit/architect 0.1702.0-next.0 → 0.1702.0-rc.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/package.json +2 -2
- package/src/jobs/index.d.ts +2 -1
- package/src/jobs/index.js +15 -1
- package/src/jobs/strategy.d.ts +17 -19
- package/src/jobs/strategy.js +78 -82
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/architect",
|
|
3
|
-
"version": "0.1702.0-
|
|
3
|
+
"version": "0.1702.0-rc.0",
|
|
4
4
|
"description": "Angular Build Facade",
|
|
5
5
|
"experimental": true,
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"typings": "src/index.d.ts",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@angular-devkit/core": "17.2.0-
|
|
9
|
+
"@angular-devkit/core": "17.2.0-rc.0",
|
|
10
10
|
"rxjs": "7.8.1"
|
|
11
11
|
},
|
|
12
12
|
"builders": "./builders/builders.json",
|
package/src/jobs/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
+
import * as strategy from './strategy';
|
|
8
9
|
export * from './api';
|
|
9
10
|
export * from './create-job-handler';
|
|
10
11
|
export * from './exception';
|
|
@@ -12,4 +13,4 @@ export * from './dispatcher';
|
|
|
12
13
|
export * from './fallback-registry';
|
|
13
14
|
export * from './simple-registry';
|
|
14
15
|
export * from './simple-scheduler';
|
|
15
|
-
export
|
|
16
|
+
export { strategy };
|
package/src/jobs/index.js
CHANGED
|
@@ -17,10 +17,25 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
17
17
|
if (k2 === undefined) k2 = k;
|
|
18
18
|
o[k2] = m[k];
|
|
19
19
|
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
+
if (mod && mod.__esModule) return mod;
|
|
27
|
+
var result = {};
|
|
28
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
+
__setModuleDefault(result, mod);
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
20
32
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
21
33
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
22
34
|
};
|
|
23
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.strategy = void 0;
|
|
37
|
+
const strategy = __importStar(require("./strategy"));
|
|
38
|
+
exports.strategy = strategy;
|
|
24
39
|
__exportStar(require("./api"), exports);
|
|
25
40
|
__exportStar(require("./create-job-handler"), exports);
|
|
26
41
|
__exportStar(require("./exception"), exports);
|
|
@@ -28,4 +43,3 @@ __exportStar(require("./dispatcher"), exports);
|
|
|
28
43
|
__exportStar(require("./fallback-registry"), exports);
|
|
29
44
|
__exportStar(require("./simple-registry"), exports);
|
|
30
45
|
__exportStar(require("./simple-scheduler"), exports);
|
|
31
|
-
__exportStar(require("./strategy"), exports);
|
package/src/jobs/strategy.d.ts
CHANGED
|
@@ -7,22 +7,20 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { JsonValue } from '@angular-devkit/core';
|
|
9
9
|
import { JobDescription, JobHandler } from './api';
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
function memoize<A extends JsonValue = JsonValue, I extends JsonValue = JsonValue, O extends JsonValue = JsonValue>(replayMessages?: boolean): JobStrategy<A, I, O>;
|
|
28
|
-
}
|
|
10
|
+
export type JobStrategy<A extends JsonValue = JsonValue, I extends JsonValue = JsonValue, O extends JsonValue = JsonValue> = (handler: JobHandler<A, I, O>, options?: Partial<Readonly<JobDescription>>) => JobHandler<A, I, O>;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a JobStrategy that serializes every call. This strategy can be mixed between jobs.
|
|
13
|
+
*/
|
|
14
|
+
export declare function serialize<A extends JsonValue = JsonValue, I extends JsonValue = JsonValue, O extends JsonValue = JsonValue>(): JobStrategy<A, I, O>;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a JobStrategy that will always reuse a running job, and restart it if the job ended.
|
|
17
|
+
* @param replayMessages Replay ALL messages if a job is reused, otherwise just hook up where it
|
|
18
|
+
* is.
|
|
19
|
+
*/
|
|
20
|
+
export declare function reuse<A extends JsonValue = JsonValue, I extends JsonValue = JsonValue, O extends JsonValue = JsonValue>(replayMessages?: boolean): JobStrategy<A, I, O>;
|
|
21
|
+
/**
|
|
22
|
+
* Creates a JobStrategy that will reuse a running job if the argument matches.
|
|
23
|
+
* @param replayMessages Replay ALL messages if a job is reused, otherwise just hook up where it
|
|
24
|
+
* is.
|
|
25
|
+
*/
|
|
26
|
+
export declare function memoize<A extends JsonValue = JsonValue, I extends JsonValue = JsonValue, O extends JsonValue = JsonValue>(replayMessages?: boolean): JobStrategy<A, I, O>;
|
package/src/jobs/strategy.js
CHANGED
|
@@ -7,92 +7,88 @@
|
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.
|
|
10
|
+
exports.memoize = exports.reuse = exports.serialize = void 0;
|
|
11
11
|
const core_1 = require("@angular-devkit/core");
|
|
12
12
|
const rxjs_1 = require("rxjs");
|
|
13
13
|
const api_1 = require("./api");
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const previous = latest;
|
|
25
|
-
latest = (0, rxjs_1.concat)(previous.pipe((0, rxjs_1.ignoreElements)()), new rxjs_1.Observable((o) => handler(argument, context).subscribe(o))).pipe((0, rxjs_1.shareReplay)(0));
|
|
26
|
-
return latest;
|
|
27
|
-
};
|
|
28
|
-
return Object.assign(newHandler, {
|
|
29
|
-
jobDescription: Object.assign({}, handler.jobDescription, options),
|
|
30
|
-
});
|
|
14
|
+
/**
|
|
15
|
+
* Creates a JobStrategy that serializes every call. This strategy can be mixed between jobs.
|
|
16
|
+
*/
|
|
17
|
+
function serialize() {
|
|
18
|
+
let latest = (0, rxjs_1.of)();
|
|
19
|
+
return (handler, options) => {
|
|
20
|
+
const newHandler = (argument, context) => {
|
|
21
|
+
const previous = latest;
|
|
22
|
+
latest = (0, rxjs_1.concat)(previous.pipe((0, rxjs_1.ignoreElements)()), new rxjs_1.Observable((o) => handler(argument, context).subscribe(o))).pipe((0, rxjs_1.shareReplay)(0));
|
|
23
|
+
return latest;
|
|
31
24
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
25
|
+
return Object.assign(newHandler, {
|
|
26
|
+
jobDescription: Object.assign({}, handler.jobDescription, options),
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.serialize = serialize;
|
|
31
|
+
/**
|
|
32
|
+
* Creates a JobStrategy that will always reuse a running job, and restart it if the job ended.
|
|
33
|
+
* @param replayMessages Replay ALL messages if a job is reused, otherwise just hook up where it
|
|
34
|
+
* is.
|
|
35
|
+
*/
|
|
36
|
+
function reuse(replayMessages = false) {
|
|
37
|
+
let inboundBus = new rxjs_1.Subject();
|
|
38
|
+
let run = null;
|
|
39
|
+
let state = null;
|
|
40
|
+
return (handler, options) => {
|
|
41
|
+
const newHandler = (argument, context) => {
|
|
42
|
+
// Forward inputs.
|
|
43
|
+
const subscription = context.inboundBus.subscribe(inboundBus);
|
|
44
|
+
if (run) {
|
|
45
|
+
return (0, rxjs_1.concat)(
|
|
46
|
+
// Update state.
|
|
47
|
+
(0, rxjs_1.of)(state), run).pipe((0, rxjs_1.finalize)(() => subscription.unsubscribe()));
|
|
48
|
+
}
|
|
49
|
+
run = handler(argument, { ...context, inboundBus: inboundBus.asObservable() }).pipe((0, rxjs_1.tap)((message) => {
|
|
50
|
+
if (message.kind == api_1.JobOutboundMessageKind.Start ||
|
|
51
|
+
message.kind == api_1.JobOutboundMessageKind.OnReady ||
|
|
52
|
+
message.kind == api_1.JobOutboundMessageKind.End) {
|
|
53
|
+
state = message;
|
|
51
54
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}, undefined, () => {
|
|
59
|
-
subscription.unsubscribe();
|
|
60
|
-
inboundBus = new rxjs_1.Subject();
|
|
61
|
-
run = null;
|
|
62
|
-
}), replayMessages ? (0, rxjs_1.shareReplay)() : (0, rxjs_1.share)());
|
|
63
|
-
return run;
|
|
64
|
-
};
|
|
65
|
-
return Object.assign(newHandler, handler, options || {});
|
|
55
|
+
}, undefined, () => {
|
|
56
|
+
subscription.unsubscribe();
|
|
57
|
+
inboundBus = new rxjs_1.Subject();
|
|
58
|
+
run = null;
|
|
59
|
+
}), replayMessages ? (0, rxjs_1.shareReplay)() : (0, rxjs_1.share)());
|
|
60
|
+
return run;
|
|
66
61
|
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return
|
|
62
|
+
return Object.assign(newHandler, handler, options || {});
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
exports.reuse = reuse;
|
|
66
|
+
/**
|
|
67
|
+
* Creates a JobStrategy that will reuse a running job if the argument matches.
|
|
68
|
+
* @param replayMessages Replay ALL messages if a job is reused, otherwise just hook up where it
|
|
69
|
+
* is.
|
|
70
|
+
*/
|
|
71
|
+
function memoize(replayMessages = false) {
|
|
72
|
+
const runs = new Map();
|
|
73
|
+
return (handler, options) => {
|
|
74
|
+
const newHandler = (argument, context) => {
|
|
75
|
+
const argumentJson = JSON.stringify((0, core_1.isJsonObject)(argument)
|
|
76
|
+
? Object.keys(argument)
|
|
77
|
+
.sort()
|
|
78
|
+
.reduce((result, key) => {
|
|
79
|
+
result[key] = argument[key];
|
|
80
|
+
return result;
|
|
81
|
+
}, {})
|
|
82
|
+
: argument);
|
|
83
|
+
const maybeJob = runs.get(argumentJson);
|
|
84
|
+
if (maybeJob) {
|
|
85
|
+
return maybeJob;
|
|
86
|
+
}
|
|
87
|
+
const run = handler(argument, context).pipe(replayMessages ? (0, rxjs_1.shareReplay)() : (0, rxjs_1.share)());
|
|
88
|
+
runs.set(argumentJson, run);
|
|
89
|
+
return run;
|
|
95
90
|
};
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
91
|
+
return Object.assign(newHandler, handler, options || {});
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
exports.memoize = memoize;
|