dougong 0.9.0 → 0.10.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/README.md +4 -4
- package/dist/advanced.d.ts +2 -1
- package/dist/advanced.d.ts.map +1 -1
- package/dist/advanced.js +3 -3
- package/dist/composition/change-set.d.ts +12 -5
- package/dist/composition/change-set.d.ts.map +1 -1
- package/dist/composition/configuration.d.ts +2 -3
- package/dist/composition/configuration.d.ts.map +1 -1
- package/dist/composition/declarations.d.ts +22 -15
- package/dist/composition/declarations.d.ts.map +1 -1
- package/dist/composition/installation-graph.d.ts.map +1 -1
- package/dist/composition/installation.d.ts +1 -2
- package/dist/composition/installation.d.ts.map +1 -1
- package/dist/composition/plan.d.ts +42 -15
- package/dist/composition/plan.d.ts.map +1 -1
- package/dist/composition/planner.d.ts.map +1 -1
- package/dist/composition/plugin.d.ts +4 -7
- package/dist/composition/plugin.d.ts.map +1 -1
- package/dist/contracts/contracts.d.ts.map +1 -1
- package/dist/contracts/errors.d.ts +49 -9
- package/dist/contracts/errors.d.ts.map +1 -1
- package/dist/contracts/logging.d.ts +12 -8
- package/dist/contracts/logging.d.ts.map +1 -1
- package/dist/contracts/resource.d.ts +2 -0
- package/dist/contracts/resource.d.ts.map +1 -1
- package/dist/contributions/contribution-store.d.ts +4 -3
- package/dist/contributions/contribution-store.d.ts.map +1 -1
- package/dist/events/event-hub.d.ts.map +1 -1
- package/dist/execution/engine.d.ts +2 -1
- package/dist/execution/engine.d.ts.map +1 -1
- package/dist/execution/host-api.d.ts +10 -4
- package/dist/execution/host-api.d.ts.map +1 -1
- package/dist/execution/host.d.ts +2 -1
- package/dist/execution/host.d.ts.map +1 -1
- package/dist/execution/instance.d.ts +4 -3
- package/dist/execution/instance.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +773 -709
- package/dist/internal/async-result.d.ts +10 -0
- package/dist/internal/async-result.d.ts.map +1 -0
- package/dist/internal/record.d.ts +3 -0
- package/dist/internal/record.d.ts.map +1 -1
- package/dist/internal/serial-queue.d.ts +2 -1
- package/dist/internal/serial-queue.d.ts.map +1 -1
- package/dist/lifetime/lifetime.d.ts +16 -9
- package/dist/lifetime/lifetime.d.ts.map +1 -1
- package/dist/observation/snapshot-view.d.ts +6 -3
- package/dist/observation/snapshot-view.d.ts.map +1 -1
- package/dist/serial-queue-DjEs2KFf.js +559 -0
- package/package.json +3 -4
- package/runtime/abort-listener.mjs +27 -0
- package/dist/internal/synchronous-result.d.ts +0 -3
- package/dist/internal/synchronous-result.d.ts.map +0 -1
- package/dist/record-CZVpq8vk.js +0 -493
- package/runtime/abort-listener.node.mjs +0 -26
- package/runtime/abort-listener.web.mjs +0 -7
package/dist/index.js
CHANGED
|
@@ -1,78 +1,96 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as e, B as t, C as n, D as r, E as i, F as a, G as o, H as s, I as c, J as l, K as u, L as d, M as f, N as p, O as m, P as ee, R as te, S as ne, T as re, U as ie, V as ae, W as h, Y as g, _, a as oe, b as v, c as y, d as b, f as x, g as se, h as S, i as ce, j as le, k as ue, l as C, m as de, n as fe, o as w, p as pe, q as T, r as me, s as E, t as he, u as D, v as ge, w as _e, x as ve, y as ye, z as O } from "./serial-queue-DjEs2KFf.js";
|
|
2
2
|
// src/contracts/contracts.ts
|
|
3
|
-
function
|
|
4
|
-
if (!
|
|
3
|
+
function be(e, t) {
|
|
4
|
+
if (!xe(t)) throw TypeError(typeof t == "string" && t.trim() ? `${e} id cannot start or end with whitespace` : `${e} id must be a non-empty string`);
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function xe(e) {
|
|
7
7
|
return typeof e == "string" && e.length > 0 && e === e.trim();
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
return
|
|
9
|
+
function k(e, t) {
|
|
10
|
+
return be("Contract", t), Object.freeze({
|
|
11
11
|
id: t,
|
|
12
12
|
kind: e
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function A(e, t) {
|
|
16
16
|
let n = Object.getOwnPropertyDescriptor(e, t);
|
|
17
|
-
|
|
17
|
+
if (n && !("value" in n)) throw TypeError(`Contract field '${t}' must be a data property`);
|
|
18
|
+
return n?.value;
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
-
let n =
|
|
21
|
-
if (
|
|
20
|
+
function j(e, t) {
|
|
21
|
+
let n = A(e, "id");
|
|
22
|
+
if (xe(n) && (t === "service" || t === "extensionPoint" || t === "event")) return {
|
|
22
23
|
id: n,
|
|
23
24
|
kind: t
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
|
-
function
|
|
27
|
-
let r = e && typeof e == "object" ?
|
|
28
|
-
if (!r || t !== void 0 && r.kind !== t) throw TypeError(n ?? (t ? `Expected ${
|
|
27
|
+
function M(e, t, n) {
|
|
28
|
+
let r = e && typeof e == "object" ? j(e, A(e, "kind")) : void 0;
|
|
29
|
+
if (!r || t !== void 0 && r.kind !== t) throw TypeError(n ?? (t ? `Expected ${Se(t)}` : "Invalid contract"));
|
|
29
30
|
return Object.freeze(r);
|
|
30
31
|
}
|
|
31
|
-
function
|
|
32
|
+
function Se(e) {
|
|
32
33
|
return e === "extensionPoint" ? "an ExtensionPoint" : e === "event" ? "an Event" : "a Service";
|
|
33
34
|
}
|
|
34
|
-
function
|
|
35
|
-
return
|
|
35
|
+
function Ce(e) {
|
|
36
|
+
return k("service", e);
|
|
36
37
|
}
|
|
37
|
-
function
|
|
38
|
-
return
|
|
38
|
+
function we(e) {
|
|
39
|
+
return k("event", e);
|
|
39
40
|
}
|
|
40
|
-
function
|
|
41
|
-
return
|
|
41
|
+
function Te(e) {
|
|
42
|
+
return k("extensionPoint", e);
|
|
42
43
|
}
|
|
43
|
-
function
|
|
44
|
+
function Ee(e) {
|
|
44
45
|
return Object.freeze({
|
|
45
46
|
kind: "optional",
|
|
46
|
-
service:
|
|
47
|
+
service: M(e, "service", "optional() expects a Service")
|
|
47
48
|
});
|
|
48
49
|
}
|
|
49
|
-
function
|
|
50
|
+
function De(e, t = "Expected a Service or ExtensionPoint", n = "Expected a Service") {
|
|
50
51
|
if (!e || typeof e != "object") throw TypeError(t);
|
|
51
|
-
let r =
|
|
52
|
+
let r = A(e, "kind");
|
|
52
53
|
if (r === "optional") return Object.freeze({
|
|
53
54
|
kind: r,
|
|
54
|
-
service:
|
|
55
|
+
service: M(A(e, "service"), "service", n)
|
|
55
56
|
});
|
|
56
|
-
let i =
|
|
57
|
+
let i = j(e, r);
|
|
57
58
|
if (!i || i.kind === "event") throw TypeError(t);
|
|
58
59
|
return Object.freeze(i);
|
|
59
60
|
}
|
|
60
61
|
// src/contracts/resource.ts
|
|
61
|
-
|
|
62
|
+
var N = /* @__PURE__ */ new WeakMap(), Oe = Object.freeze({ kind: "control" });
|
|
63
|
+
function P(e) {
|
|
64
|
+
return N.set(e, Oe), e;
|
|
65
|
+
}
|
|
66
|
+
function ke(e) {
|
|
67
|
+
let t = N.get(e);
|
|
68
|
+
if (t) throw TypeError(t.kind === "control" ? "Owned control handles cannot be adopted as resources" : "Resource already has a Lifetime owner");
|
|
69
|
+
let n = { kind: "claim" };
|
|
70
|
+
return N.set(e, n), () => {
|
|
71
|
+
N.get(e) === n && N.delete(e);
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function Ae(e) {
|
|
62
75
|
if (typeof e != "object" && typeof e != "function" || e === null) throw TypeError("Resource must implement Symbol.dispose or Symbol.asyncDispose");
|
|
63
|
-
let t = e[
|
|
76
|
+
let t = e[l];
|
|
64
77
|
if (t != null) {
|
|
65
78
|
if (typeof t != "function") throw TypeError("Symbol.asyncDispose must be a function");
|
|
66
79
|
return () => Reflect.apply(t, e, []);
|
|
67
80
|
}
|
|
68
|
-
let
|
|
69
|
-
if (typeof
|
|
70
|
-
return () =>
|
|
81
|
+
let n = e[g];
|
|
82
|
+
if (typeof n != "function") throw TypeError("Resource must implement Symbol.dispose or Symbol.asyncDispose");
|
|
83
|
+
return () => u(Reflect.apply(n, e, []), "Symbol.dispose must be synchronous");
|
|
71
84
|
}
|
|
72
85
|
// src/lifetime/lifetime.ts
|
|
73
|
-
var
|
|
86
|
+
var je = y()("lifetime"), F = /* @__PURE__ */ new WeakMap(), Me = class {
|
|
74
87
|
published = !1;
|
|
75
|
-
}
|
|
88
|
+
};
|
|
89
|
+
function I() {
|
|
90
|
+
let e = new DOMException("Resource disposed", "AbortError");
|
|
91
|
+
return Reflect.set(e, "stack", void 0), Object.freeze(e);
|
|
92
|
+
}
|
|
93
|
+
var Ne = class {
|
|
76
94
|
id;
|
|
77
95
|
kind;
|
|
78
96
|
#e;
|
|
@@ -80,8 +98,9 @@ var D = /* @__PURE__ */ new WeakMap(), oe = class {
|
|
|
80
98
|
#n;
|
|
81
99
|
#r;
|
|
82
100
|
#i;
|
|
83
|
-
|
|
84
|
-
|
|
101
|
+
#a;
|
|
102
|
+
constructor(e, t, n, r, i, a) {
|
|
103
|
+
this.#i = i, this.#a = a, this.id = e, this.kind = t, this.#e = n, this.#t = r;
|
|
85
104
|
}
|
|
86
105
|
get failure() {
|
|
87
106
|
return this.#r;
|
|
@@ -91,71 +110,66 @@ var D = /* @__PURE__ */ new WeakMap(), oe = class {
|
|
|
91
110
|
let e = this.#e;
|
|
92
111
|
if (!e) return Promise.resolve();
|
|
93
112
|
let t = Promise.withResolvers();
|
|
94
|
-
return this.#n = Object.freeze(t.promise), Promise.resolve().then(e).then(() => {
|
|
113
|
+
return this.#n = Object.freeze(t.promise), Promise.resolve().then(() => T(e())).then(() => {
|
|
95
114
|
this.#e = void 0;
|
|
96
115
|
let e = this.#t;
|
|
97
|
-
this.#t = void 0, this.#i = void 0, e?.(), t.resolve();
|
|
116
|
+
this.#t = void 0, this.#i = void 0, this.#a = void 0, e?.(), t.resolve();
|
|
98
117
|
}, (e) => {
|
|
99
|
-
this.#r = new
|
|
118
|
+
this.#i?.(e), this.#r = new b(e), this.#a?.(), t.reject(e);
|
|
100
119
|
}), t.promise;
|
|
101
120
|
}
|
|
102
121
|
forget() {
|
|
103
122
|
if (this.#n) return;
|
|
104
|
-
this.#e = void 0, this.#i = void 0;
|
|
123
|
+
this.#e = void 0, this.#i = void 0, this.#a = void 0;
|
|
105
124
|
let e = this.#t;
|
|
106
125
|
this.#t = void 0, e?.();
|
|
107
126
|
}
|
|
108
|
-
},
|
|
127
|
+
}, Pe = class {
|
|
109
128
|
id;
|
|
110
129
|
publication;
|
|
111
130
|
failure;
|
|
112
|
-
|
|
113
|
-
|
|
131
|
+
#e;
|
|
132
|
+
constructor(e, t, n) {
|
|
133
|
+
this.id = e, this.publication = t, this.#e = n;
|
|
114
134
|
}
|
|
115
135
|
withdraw() {
|
|
116
136
|
if (this.failure) return !1;
|
|
117
137
|
try {
|
|
118
|
-
|
|
138
|
+
u(this.publication[g](), "Publication withdrawal must be synchronous");
|
|
119
139
|
} catch (e) {
|
|
120
140
|
return this.failure = {
|
|
121
141
|
reason: e,
|
|
122
|
-
recorded:
|
|
123
|
-
}, !1;
|
|
142
|
+
recorded: void 0
|
|
143
|
+
}, this.#e?.(e), this.failure.recorded = new b(e), !1;
|
|
124
144
|
}
|
|
125
|
-
return !0;
|
|
145
|
+
return this.#e = void 0, !0;
|
|
126
146
|
}
|
|
127
|
-
},
|
|
147
|
+
}, Fe = class {
|
|
128
148
|
handle;
|
|
129
149
|
#e;
|
|
130
150
|
#t;
|
|
131
151
|
settled;
|
|
132
152
|
constructor(e, t, n) {
|
|
133
|
-
let
|
|
134
|
-
this.#e =
|
|
153
|
+
let i = new AbortController();
|
|
154
|
+
this.#e = i, this.#t = n;
|
|
135
155
|
let a = t, o = (e) => {
|
|
136
156
|
if (!a) return;
|
|
137
157
|
let t = a;
|
|
138
158
|
a = void 0;
|
|
139
159
|
try {
|
|
140
|
-
i
|
|
160
|
+
r(i.signal, e) || t(e);
|
|
141
161
|
} catch (e) {
|
|
142
162
|
queueMicrotask(() => {
|
|
143
163
|
throw e;
|
|
144
164
|
});
|
|
145
165
|
}
|
|
146
|
-
}, s = Promise.resolve().then(() =>
|
|
147
|
-
try {
|
|
148
|
-
return e(r.signal);
|
|
149
|
-
} catch (e) {
|
|
150
|
-
throw o(e), e;
|
|
151
|
-
}
|
|
152
|
-
});
|
|
166
|
+
}, s = Promise.resolve().then(() => T(e(i.signal)));
|
|
153
167
|
this.settled = Object.freeze(s.then(() => this.#n(), (e) => {
|
|
154
168
|
o(e), this.#n();
|
|
155
|
-
})), this.handle = Object.freeze({
|
|
169
|
+
})), this.handle = P(Object.freeze({
|
|
156
170
|
result: s,
|
|
157
|
-
[
|
|
158
|
-
});
|
|
171
|
+
[l]: this.#r.bind(this)
|
|
172
|
+
}));
|
|
159
173
|
}
|
|
160
174
|
#n() {
|
|
161
175
|
this.#e = void 0;
|
|
@@ -163,13 +177,13 @@ var D = /* @__PURE__ */ new WeakMap(), oe = class {
|
|
|
163
177
|
this.#t = void 0, e?.();
|
|
164
178
|
}
|
|
165
179
|
#r() {
|
|
166
|
-
return this.cancel(
|
|
180
|
+
return this.cancel(I()), this.settled;
|
|
167
181
|
}
|
|
168
182
|
cancel(e) {
|
|
169
183
|
let t = this.#e;
|
|
170
184
|
this.#e = void 0, t?.abort(e);
|
|
171
185
|
}
|
|
172
|
-
},
|
|
186
|
+
}, Ie = class n {
|
|
173
187
|
#e;
|
|
174
188
|
#t = new AbortController();
|
|
175
189
|
#n;
|
|
@@ -182,25 +196,26 @@ var D = /* @__PURE__ */ new WeakMap(), oe = class {
|
|
|
182
196
|
#l;
|
|
183
197
|
#u;
|
|
184
198
|
#d;
|
|
185
|
-
#f
|
|
186
|
-
#p =
|
|
199
|
+
#f;
|
|
200
|
+
#p = "active";
|
|
187
201
|
#m = 0;
|
|
188
|
-
#h;
|
|
202
|
+
#h = 0;
|
|
189
203
|
#g;
|
|
190
204
|
#_;
|
|
191
205
|
#v;
|
|
192
206
|
#y;
|
|
193
207
|
#b;
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
208
|
+
#x;
|
|
209
|
+
constructor(e, t) {
|
|
210
|
+
if (Re(e.label), typeof e.report != "function") throw TypeError("Lifetime error reporter must be a function");
|
|
211
|
+
this.#e = e.label, this.#u = e.report, this.#d = e.releaseFailed, this.#f = e.changed, this.#l = L(e.shutdownTimeoutMilliseconds), this.#n = t?.visibility ?? new Me(), this.#_ = t?.detach, e.parentSignal && (this.#g = o(e.parentSignal, (e) => {
|
|
212
|
+
this.block(), this.#O(e);
|
|
198
213
|
}));
|
|
199
214
|
}
|
|
200
215
|
get handle() {
|
|
201
|
-
return this.#
|
|
216
|
+
return this.#x ??= this.#S({});
|
|
202
217
|
}
|
|
203
|
-
#
|
|
218
|
+
#S(e) {
|
|
204
219
|
let t = this, n = Object.freeze({
|
|
205
220
|
...e,
|
|
206
221
|
get signal() {
|
|
@@ -213,15 +228,16 @@ var D = /* @__PURE__ */ new WeakMap(), oe = class {
|
|
|
213
228
|
acquire: (e) => this.acquire(e),
|
|
214
229
|
interrupt: (e) => this.interrupt(e)
|
|
215
230
|
});
|
|
216
|
-
return
|
|
231
|
+
return F.set(n, this), n;
|
|
217
232
|
}
|
|
218
233
|
resolveOwner(e) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
234
|
+
let t = e === void 0 ? void 0 : E(e, "Lifetime ownership", { fields: je }).lifetime;
|
|
235
|
+
if (this.#F(), t === void 0) return this;
|
|
236
|
+
let n = F.get(t);
|
|
237
|
+
if (!n || !this.#w(n)) throw TypeError("Lifetime owner must belong to the current scope tree");
|
|
238
|
+
return n.#F(), n;
|
|
223
239
|
}
|
|
224
|
-
*#
|
|
240
|
+
*#C() {
|
|
225
241
|
let e = [this];
|
|
226
242
|
for (; e.length;) {
|
|
227
243
|
let t = e.pop();
|
|
@@ -229,32 +245,32 @@ var D = /* @__PURE__ */ new WeakMap(), oe = class {
|
|
|
229
245
|
for (let n of [...t.#r].reverse()) e.push(n);
|
|
230
246
|
}
|
|
231
247
|
}
|
|
232
|
-
#
|
|
233
|
-
for (let t of this.#
|
|
248
|
+
#w(e) {
|
|
249
|
+
for (let t of this.#C()) if (t === e) return !0;
|
|
234
250
|
return !1;
|
|
235
251
|
}
|
|
236
252
|
get signal() {
|
|
237
253
|
return this.#t.signal;
|
|
238
254
|
}
|
|
239
255
|
get phase() {
|
|
240
|
-
return this.#
|
|
256
|
+
return this.#p;
|
|
241
257
|
}
|
|
242
258
|
get acceptsWork() {
|
|
243
|
-
return this.#
|
|
259
|
+
return this.#p === "active" && !h(this.signal);
|
|
244
260
|
}
|
|
245
261
|
get published() {
|
|
246
262
|
return this.#n.published;
|
|
247
263
|
}
|
|
248
264
|
get busy() {
|
|
249
|
-
for (let e of this.#
|
|
265
|
+
for (let e of this.#C()) if (e.#m > 0) return !0;
|
|
250
266
|
return !1;
|
|
251
267
|
}
|
|
252
268
|
snapshot() {
|
|
253
269
|
let e = /* @__PURE__ */ new Map();
|
|
254
|
-
for (let t of [...this.#
|
|
270
|
+
for (let t of [...this.#C()].reverse()) e.set(t, t.#T([...t.#r].map((t) => e.get(t))));
|
|
255
271
|
return e.get(this);
|
|
256
272
|
}
|
|
257
|
-
#
|
|
273
|
+
#T(e) {
|
|
258
274
|
let t = [], n = (e, n, r) => {
|
|
259
275
|
r && t.push(Object.freeze({
|
|
260
276
|
id: e,
|
|
@@ -265,173 +281,179 @@ var D = /* @__PURE__ */ new WeakMap(), oe = class {
|
|
|
265
281
|
for (let e of this.#i) n(e.id, e.kind, e.failure);
|
|
266
282
|
for (let e of this.#a) n(e.id, e.kind, e.failure);
|
|
267
283
|
for (let e of this.#o) n(e.id, "publication", e.failure?.recorded);
|
|
268
|
-
return n(0, "shutdown", this.#
|
|
284
|
+
return n(0, "shutdown", this.#b), Object.freeze({
|
|
269
285
|
label: this.#e,
|
|
270
|
-
phase: this.#
|
|
286
|
+
phase: this.#p,
|
|
271
287
|
cleanups: this.#i.size,
|
|
272
288
|
interrupts: this.#a.size,
|
|
273
289
|
tasks: this.#s.size,
|
|
274
290
|
acquisitions: this.#c.size,
|
|
275
291
|
publications: this.#o.size,
|
|
276
|
-
foreground: this.#
|
|
292
|
+
foreground: this.#m,
|
|
277
293
|
unresolved: Object.freeze(t),
|
|
278
294
|
children: Object.freeze(e)
|
|
279
295
|
});
|
|
280
296
|
}
|
|
281
297
|
use(e) {
|
|
282
|
-
return this.#
|
|
298
|
+
return this.#E(e), e;
|
|
283
299
|
}
|
|
284
300
|
own(e) {
|
|
285
|
-
let t = this.#
|
|
301
|
+
let t = this.#E(e);
|
|
286
302
|
return () => t.forget();
|
|
287
303
|
}
|
|
288
|
-
#
|
|
289
|
-
this.#
|
|
290
|
-
let
|
|
291
|
-
|
|
304
|
+
#E(e, t = !1) {
|
|
305
|
+
if (t || this.#F(), F.has(e)) throw TypeError("Lifetime handles cannot be adopted as resources");
|
|
306
|
+
let n = ke(e), r;
|
|
307
|
+
try {
|
|
308
|
+
r = Ae(e), t || this.#F();
|
|
309
|
+
} catch (e) {
|
|
310
|
+
throw n(), e;
|
|
311
|
+
}
|
|
312
|
+
return this.#M(r, "cleanup", n);
|
|
292
313
|
}
|
|
293
314
|
defer(e) {
|
|
294
|
-
if (this.#
|
|
295
|
-
let t = this.#
|
|
296
|
-
return Object.freeze({ [
|
|
315
|
+
if (this.#F(), typeof e != "function") throw TypeError("Cleanup must be a function");
|
|
316
|
+
let t = this.#M(e, "cleanup");
|
|
317
|
+
return P(Object.freeze({ [l]: () => t.dispose() }));
|
|
297
318
|
}
|
|
298
319
|
interrupt(e) {
|
|
299
|
-
if (this.#
|
|
300
|
-
let t = this.#
|
|
301
|
-
return Object.freeze({ [
|
|
320
|
+
if (this.#F(), typeof e != "function") throw TypeError("Interrupt must be a function");
|
|
321
|
+
let t = this.#M(e, "interrupt");
|
|
322
|
+
return P(Object.freeze({ [g]: () => t.forget() }));
|
|
302
323
|
}
|
|
303
324
|
child(e) {
|
|
304
|
-
this.#
|
|
305
|
-
let
|
|
325
|
+
this.#F();
|
|
326
|
+
let t = new n({
|
|
306
327
|
label: e,
|
|
307
328
|
report: this.#u,
|
|
308
|
-
...this.#d && {
|
|
329
|
+
...this.#d && { releaseFailed: this.#d },
|
|
330
|
+
...this.#f && { changed: this.#f },
|
|
309
331
|
...this.#l === void 0 ? {} : { shutdownTimeoutMilliseconds: this.#l }
|
|
310
332
|
}, {
|
|
311
333
|
visibility: this.#n,
|
|
312
|
-
detach: (e) =>
|
|
313
|
-
this.#r.delete(e), this.#d?.();
|
|
314
|
-
}
|
|
334
|
+
detach: (e) => this.#r.delete(e)
|
|
315
335
|
});
|
|
316
|
-
this.#r.add(
|
|
317
|
-
let r =
|
|
318
|
-
return
|
|
336
|
+
this.#r.add(t), this.#f?.();
|
|
337
|
+
let r = t.#S({ [l]: t.dispose.bind(t) });
|
|
338
|
+
return t.#x = r, r;
|
|
319
339
|
}
|
|
320
340
|
spawn(e) {
|
|
321
|
-
return this.#
|
|
341
|
+
return this.#D(e, (e) => this.#N(e));
|
|
322
342
|
}
|
|
323
343
|
prepare(e) {
|
|
324
|
-
return this.#
|
|
344
|
+
return this.#D(e).result;
|
|
325
345
|
}
|
|
326
|
-
#
|
|
327
|
-
if (this.#
|
|
328
|
-
let n = new
|
|
329
|
-
this.#s.delete(n), this.#
|
|
346
|
+
#D(e, t) {
|
|
347
|
+
if (this.#F(), typeof e != "function") throw TypeError("Task must be a function");
|
|
348
|
+
let n = new Fe(e, t, () => {
|
|
349
|
+
this.#s.delete(n), this.#f?.();
|
|
330
350
|
});
|
|
331
|
-
return this.#s.add(n), this.#
|
|
351
|
+
return this.#s.add(n), this.#f?.(), n.handle;
|
|
332
352
|
}
|
|
333
353
|
acquire(e) {
|
|
334
|
-
if (this.#
|
|
335
|
-
let t = Promise.resolve().then(() => e(this.signal)).then(async (e) => {
|
|
336
|
-
let t = this.#
|
|
337
|
-
if (
|
|
338
|
-
let e =
|
|
354
|
+
if (this.#F(), typeof e != "function") throw TypeError("Acquisition must be a function");
|
|
355
|
+
let t = Promise.resolve().then(() => T(e(this.signal))).then(async ({ value: e }) => {
|
|
356
|
+
let t = this.#E(e, !0);
|
|
357
|
+
if (h(this.signal)) {
|
|
358
|
+
let e = ie(this.signal);
|
|
339
359
|
throw await t.dispose(), e;
|
|
340
360
|
}
|
|
341
361
|
return Object.freeze({ resource: e });
|
|
342
362
|
}), n = () => {
|
|
343
|
-
this.#c.delete(r), this.#
|
|
363
|
+
this.#c.delete(r), this.#f?.();
|
|
344
364
|
}, r = t.then(n, n);
|
|
345
|
-
return this.#c.add(r), this.#
|
|
365
|
+
return this.#c.add(r), this.#f?.(), t;
|
|
346
366
|
}
|
|
347
367
|
stage(e) {
|
|
348
|
-
this.#
|
|
368
|
+
this.#F();
|
|
349
369
|
let t, n = e(() => {
|
|
350
|
-
t && !t.failure && this.#o.delete(t), this.#
|
|
370
|
+
t && !t.failure && this.#o.delete(t), this.#f?.();
|
|
351
371
|
});
|
|
352
|
-
return t = new
|
|
372
|
+
return t = new Pe(++this.#h, n, (e) => this.#P(e, "publication")), this.#o.add(t), w(() => {
|
|
373
|
+
this.#f?.(), this.published && n.publish();
|
|
374
|
+
}), n;
|
|
353
375
|
}
|
|
354
376
|
borrow(e) {
|
|
355
|
-
if (this.#
|
|
356
|
-
this.#
|
|
377
|
+
if (this.#F(), typeof e != "function") throw TypeError("Borrow callback must be a function");
|
|
378
|
+
this.#m++, this.#f?.();
|
|
357
379
|
let t = () => {
|
|
358
|
-
this.#
|
|
380
|
+
this.#m--, this.#f?.();
|
|
359
381
|
};
|
|
360
382
|
try {
|
|
361
|
-
let n =
|
|
362
|
-
return
|
|
383
|
+
let n = T(e());
|
|
384
|
+
return n.then(t, t), n;
|
|
363
385
|
} catch (e) {
|
|
364
386
|
return t(), Promise.reject(e);
|
|
365
387
|
}
|
|
366
388
|
}
|
|
367
389
|
seal() {
|
|
368
|
-
if (this.busy) throw new
|
|
390
|
+
if (this.busy) throw new D(ue, "Lifetime has in-flight foreground work");
|
|
369
391
|
this.block();
|
|
370
392
|
}
|
|
371
393
|
block() {
|
|
372
|
-
for (let e of this.#
|
|
394
|
+
for (let e of this.#C()) e.#p === "active" && (e.#p = "sealed");
|
|
373
395
|
}
|
|
374
|
-
#
|
|
375
|
-
for (let t of this.#
|
|
396
|
+
#O(e) {
|
|
397
|
+
for (let t of this.#C()) {
|
|
376
398
|
t.#t.abort?.(e);
|
|
377
399
|
for (let n of t.#s) n.cancel(e);
|
|
378
400
|
}
|
|
379
401
|
}
|
|
380
402
|
publish() {
|
|
381
|
-
if (this.#
|
|
403
|
+
if (this.#F(), this.#_) throw TypeError("Only the root Lifetime may publish declarations");
|
|
382
404
|
if (!this.#n.published) {
|
|
383
405
|
this.#n.published = !0;
|
|
384
|
-
for (let e of this.#
|
|
406
|
+
for (let e of this.#C()) for (let t of e.#o) t.publication.publish();
|
|
385
407
|
}
|
|
386
408
|
}
|
|
387
409
|
detachStartupSignal() {
|
|
388
|
-
this.#
|
|
410
|
+
this.#g?.(), this.#g = void 0;
|
|
389
411
|
}
|
|
390
412
|
dispose() {
|
|
391
|
-
if (this.#
|
|
392
|
-
if (this.#
|
|
413
|
+
if (this.#v) return this.#v;
|
|
414
|
+
if (this.#p === "disposed") return Promise.resolve();
|
|
393
415
|
try {
|
|
394
416
|
this.seal();
|
|
395
417
|
} catch (e) {
|
|
396
418
|
return Promise.reject(e);
|
|
397
419
|
}
|
|
398
|
-
let e = [...this.#
|
|
420
|
+
let e = [...this.#C()].filter((e) => !e.#v), t = [];
|
|
399
421
|
for (let n = e.length - 1; n >= 0; n--) {
|
|
400
422
|
let r = e[n];
|
|
401
|
-
r.#
|
|
423
|
+
r.#k(r === this ? t : []);
|
|
402
424
|
}
|
|
403
425
|
try {
|
|
404
|
-
|
|
405
|
-
for (let t of e) t.#
|
|
406
|
-
this.#
|
|
426
|
+
w(() => {
|
|
427
|
+
for (let t of e) t.#j();
|
|
428
|
+
this.#f?.();
|
|
407
429
|
});
|
|
408
430
|
} catch (e) {
|
|
409
431
|
t.push(e);
|
|
410
432
|
}
|
|
411
|
-
return this.#
|
|
433
|
+
return this.#O(I()), this.#v;
|
|
412
434
|
}
|
|
413
|
-
#
|
|
414
|
-
this.#
|
|
415
|
-
let
|
|
416
|
-
if (this.#
|
|
417
|
-
this.#
|
|
435
|
+
#k(e) {
|
|
436
|
+
this.#p = "disposing", this.detachStartupSignal();
|
|
437
|
+
let n = Promise.resolve().then(() => this.#A(e));
|
|
438
|
+
if (this.#y = n, this.#l === void 0) {
|
|
439
|
+
this.#v = Object.freeze(n);
|
|
418
440
|
return;
|
|
419
441
|
}
|
|
420
|
-
let
|
|
421
|
-
this.#
|
|
422
|
-
let
|
|
423
|
-
let e = new
|
|
424
|
-
this.#
|
|
442
|
+
let r = Promise.withResolvers();
|
|
443
|
+
this.#v = Object.freeze(r.promise), r.promise.catch(() => void 0);
|
|
444
|
+
let i = setTimeout(() => {
|
|
445
|
+
let e = new D(t, "Lifetime shutdown did not complete before its deadline");
|
|
446
|
+
this.#p = "quarantined", this.#P(e, "shutdown"), this.#b = new b(e), this.#f?.(), r.reject(e);
|
|
425
447
|
}, this.#l);
|
|
426
|
-
|
|
427
|
-
clearTimeout(
|
|
448
|
+
n.then(() => {
|
|
449
|
+
clearTimeout(i), r.resolve();
|
|
428
450
|
}, (e) => {
|
|
429
|
-
clearTimeout(
|
|
451
|
+
clearTimeout(i), r.reject(e);
|
|
430
452
|
});
|
|
431
453
|
}
|
|
432
|
-
async #
|
|
454
|
+
async #A(e) {
|
|
433
455
|
for (let t of this.#o) t.failure && e.push(t.failure.reason);
|
|
434
|
-
let t = Promise.allSettled([...this.#r].map((e) => e.#
|
|
456
|
+
let t = Promise.allSettled([...this.#r].map((e) => e.#y)), n = [...this.#a].reverse().map((e) => e.dispose());
|
|
435
457
|
for (let t of await Promise.allSettled(n)) t.status === "rejected" && e.push(t.reason);
|
|
436
458
|
let r = [...this.#s].map((e) => e.settled);
|
|
437
459
|
await Promise.all(r), await Promise.allSettled([...this.#c]);
|
|
@@ -442,39 +464,46 @@ var D = /* @__PURE__ */ new WeakMap(), oe = class {
|
|
|
442
464
|
} catch (t) {
|
|
443
465
|
e.push(t);
|
|
444
466
|
}
|
|
445
|
-
if (this.#
|
|
446
|
-
this.#
|
|
447
|
-
let a = this.#
|
|
448
|
-
this.#
|
|
467
|
+
if (this.#b = void 0, e.length) throw this.#p = "quarantined", this.#f?.(), AggregateError(e, "Lifetime has unresolved cleanup obligations");
|
|
468
|
+
this.#p = "disposed", this.#t = { signal: AbortSignal.abort(I()) };
|
|
469
|
+
let a = this.#_;
|
|
470
|
+
this.#_ = void 0, a?.(this), this.#u = void 0, this.#d = void 0, this.#f?.(), this.#f = void 0;
|
|
449
471
|
}
|
|
450
|
-
#
|
|
472
|
+
#j() {
|
|
451
473
|
for (let e of [...this.#o].reverse()) e.withdraw() ? this.#o.delete(e) : this.#o.add(e);
|
|
452
474
|
}
|
|
453
|
-
#
|
|
454
|
-
let
|
|
455
|
-
return
|
|
456
|
-
|
|
457
|
-
}, () => this.#
|
|
475
|
+
#M(e, t, n) {
|
|
476
|
+
let r = t === "cleanup" ? this.#i : this.#a, i;
|
|
477
|
+
return i = new Ne(++this.#h, t, e, () => {
|
|
478
|
+
r.delete(i), n?.(), this.#f?.();
|
|
479
|
+
}, (e) => this.#P(e, t), () => this.#f?.()), r.add(i), this.#f?.(), i;
|
|
458
480
|
}
|
|
459
|
-
#
|
|
481
|
+
#N(e) {
|
|
460
482
|
let t = this.#u;
|
|
461
|
-
t &&
|
|
483
|
+
t && u(t(e), "Lifetime error reporters must be synchronous");
|
|
462
484
|
}
|
|
463
|
-
#
|
|
464
|
-
|
|
485
|
+
#P(e, t) {
|
|
486
|
+
this.#d?.(Object.freeze({
|
|
487
|
+
owner: this,
|
|
488
|
+
kind: t,
|
|
489
|
+
error: e
|
|
490
|
+
}));
|
|
491
|
+
}
|
|
492
|
+
#F() {
|
|
493
|
+
if (!this.acceptsWork) throw new D(e, "Lifetime is closed to new work");
|
|
465
494
|
}
|
|
466
|
-
},
|
|
467
|
-
function
|
|
495
|
+
}, Le = 2 ** 31 - 1;
|
|
496
|
+
function L(e) {
|
|
468
497
|
if (e !== void 0) {
|
|
469
|
-
if (typeof e != "number" || !Number.isFinite(e) || e <= 0 || e >
|
|
498
|
+
if (typeof e != "number" || !Number.isFinite(e) || e <= 0 || e > Le) throw TypeError(`shutdownTimeoutMilliseconds must be a positive finite number no greater than ${Le}`);
|
|
470
499
|
return e;
|
|
471
500
|
}
|
|
472
501
|
}
|
|
473
|
-
function
|
|
502
|
+
function Re(e) {
|
|
474
503
|
if (typeof e != "string" || !e.trim() || e !== e.trim()) throw TypeError("Lifetime label must be a non-empty trimmed string");
|
|
475
504
|
}
|
|
476
505
|
// src/contracts/contract-registry.ts
|
|
477
|
-
var
|
|
506
|
+
var ze = class {
|
|
478
507
|
#e = /* @__PURE__ */ new Map();
|
|
479
508
|
assertKinds(e) {
|
|
480
509
|
for (let [t, n] of e) this.assertCompatible({
|
|
@@ -483,19 +512,19 @@ var fe = class {
|
|
|
483
512
|
});
|
|
484
513
|
}
|
|
485
514
|
assertCompatible(e) {
|
|
486
|
-
|
|
515
|
+
z(this.#e, e);
|
|
487
516
|
}
|
|
488
517
|
remember(e) {
|
|
489
|
-
|
|
518
|
+
R(this.#e, e);
|
|
490
519
|
}
|
|
491
520
|
writer(e) {
|
|
492
|
-
return new
|
|
521
|
+
return new Be(this, e);
|
|
493
522
|
}
|
|
494
523
|
commit(e) {
|
|
495
524
|
this.assertKinds(e);
|
|
496
525
|
for (let [t, n] of e) this.#e.set(t, n);
|
|
497
526
|
}
|
|
498
|
-
},
|
|
527
|
+
}, Be = class {
|
|
499
528
|
#e;
|
|
500
529
|
constructor(e, t) {
|
|
501
530
|
this.#e = {
|
|
@@ -513,7 +542,7 @@ var fe = class {
|
|
|
513
542
|
if (t.phase === "committed") t.registry.remember(e);
|
|
514
543
|
else {
|
|
515
544
|
if (t.phase === "discarded") throw Error("Contract registry writer has been discarded");
|
|
516
|
-
t.registry.assertCompatible(e),
|
|
545
|
+
t.registry.assertCompatible(e), R(t.pending, e);
|
|
517
546
|
}
|
|
518
547
|
}
|
|
519
548
|
commit() {
|
|
@@ -527,25 +556,25 @@ var fe = class {
|
|
|
527
556
|
this.#e.phase === "staged" && (this.#e = { phase: "discarded" });
|
|
528
557
|
}
|
|
529
558
|
};
|
|
530
|
-
function
|
|
531
|
-
|
|
559
|
+
function R(e, t) {
|
|
560
|
+
z(e, t), e.set(t.id, t.kind);
|
|
532
561
|
}
|
|
533
|
-
function
|
|
562
|
+
function z(e, t) {
|
|
534
563
|
let n = e.get(t.id);
|
|
535
|
-
if (n && n !== t.kind) throw new
|
|
564
|
+
if (n && n !== t.kind) throw new D(de, `Contract '${t.id}' is used as both '${n}' and '${t.kind}'`);
|
|
536
565
|
}
|
|
537
566
|
// src/events/event-hub.ts
|
|
538
|
-
var
|
|
567
|
+
var Ve = class {
|
|
539
568
|
#e;
|
|
540
569
|
#t;
|
|
541
570
|
handle;
|
|
542
|
-
constructor(e, t, r, i
|
|
571
|
+
constructor(e, t, n, r, i) {
|
|
543
572
|
this.#e = t, this.#t = {
|
|
544
573
|
hub: e,
|
|
545
|
-
listener:
|
|
546
|
-
owner:
|
|
547
|
-
detach:
|
|
548
|
-
}, this.handle = Object.freeze({ [
|
|
574
|
+
listener: n,
|
|
575
|
+
owner: r,
|
|
576
|
+
detach: i
|
|
577
|
+
}, this.handle = P(Object.freeze({ [g]: () => this[g]() }));
|
|
549
578
|
}
|
|
550
579
|
publish() {
|
|
551
580
|
let e = this.#t;
|
|
@@ -553,15 +582,15 @@ var me = class {
|
|
|
553
582
|
}
|
|
554
583
|
invoke(e) {
|
|
555
584
|
let t = this.#t;
|
|
556
|
-
if (!t) return Promise.resolve();
|
|
585
|
+
if (!t?.owner.acceptsWork) return Promise.resolve();
|
|
557
586
|
let { owner: n, listener: r } = t;
|
|
558
587
|
return n.borrow(() => r(e));
|
|
559
588
|
}
|
|
560
|
-
[
|
|
589
|
+
[g]() {
|
|
561
590
|
let e = this.#t;
|
|
562
591
|
e && (this.#t = void 0, e.hub.delete(this.#e, this), e.detach());
|
|
563
592
|
}
|
|
564
|
-
},
|
|
593
|
+
}, He = class {
|
|
565
594
|
#e;
|
|
566
595
|
constructor(e, t, n) {
|
|
567
596
|
this.#e = {
|
|
@@ -575,27 +604,27 @@ var me = class {
|
|
|
575
604
|
on(e, t, n) {
|
|
576
605
|
let r = this.#t();
|
|
577
606
|
if (typeof t != "function") throw TypeError("Event listener must be a function");
|
|
578
|
-
let i =
|
|
607
|
+
let i = M(e, "event"), a = r.owner.resolveOwner(n);
|
|
579
608
|
return r.remember(i), r.hub.stage(i.id, t, a);
|
|
580
609
|
}
|
|
581
610
|
async emit(e, ...t) {
|
|
582
611
|
let n = this.#t();
|
|
583
|
-
if (!n.owner.published) throw new
|
|
584
|
-
let r =
|
|
612
|
+
if (!n.owner.published) throw new D(se, "Candidate setup cannot emit into the committed event graph");
|
|
613
|
+
let r = M(e, "event");
|
|
585
614
|
this.#t(), n.remember(r), await n.hub.emit(r.id, t[0]);
|
|
586
615
|
}
|
|
587
616
|
#t() {
|
|
588
|
-
let
|
|
589
|
-
if (!
|
|
590
|
-
return
|
|
617
|
+
let t = this.#e;
|
|
618
|
+
if (!t || !t.owner.acceptsWork) throw new D(e, "Event scope is closed");
|
|
619
|
+
return t;
|
|
591
620
|
}
|
|
592
|
-
},
|
|
621
|
+
}, Ue = class {
|
|
593
622
|
#e = /* @__PURE__ */ new Map();
|
|
594
623
|
scope(e, t) {
|
|
595
|
-
return new
|
|
624
|
+
return new He(this, e, t);
|
|
596
625
|
}
|
|
597
626
|
stage(e, t, n) {
|
|
598
|
-
return n.stage((r) => new
|
|
627
|
+
return n.stage((r) => new Ve(this, e, t, n, r)).handle;
|
|
599
628
|
}
|
|
600
629
|
add(e, t) {
|
|
601
630
|
let n = this.#e.get(e) ?? /* @__PURE__ */ new Set();
|
|
@@ -615,7 +644,7 @@ var me = class {
|
|
|
615
644
|
}))).flatMap((e) => e.status === "rejected" ? [e.reason] : []);
|
|
616
645
|
if (r.length) throw AggregateError(r, `Event '${e}' listeners failed`);
|
|
617
646
|
}
|
|
618
|
-
},
|
|
647
|
+
}, B = class {
|
|
619
648
|
#e;
|
|
620
649
|
get;
|
|
621
650
|
subscribe;
|
|
@@ -640,21 +669,21 @@ var me = class {
|
|
|
640
669
|
}, t.own);
|
|
641
670
|
}
|
|
642
671
|
#r() {
|
|
643
|
-
let
|
|
644
|
-
if (!
|
|
645
|
-
if (
|
|
646
|
-
return
|
|
672
|
+
let t = this.#e.binding;
|
|
673
|
+
if (!t) throw new D(e, "Contribution view has been disposed");
|
|
674
|
+
if (t.owner && !t.owner.acceptsWork) throw new D(e, "Contribution view owner is closed");
|
|
675
|
+
return t;
|
|
647
676
|
}
|
|
648
|
-
},
|
|
677
|
+
}, We = class {
|
|
649
678
|
#e;
|
|
650
679
|
constructor(e) {
|
|
651
680
|
this.#e = e, Object.freeze(this);
|
|
652
681
|
}
|
|
653
682
|
update = (e) => this.#e.update(e);
|
|
654
|
-
[
|
|
655
|
-
this.#e[
|
|
683
|
+
[g]() {
|
|
684
|
+
this.#e[g]();
|
|
656
685
|
}
|
|
657
|
-
},
|
|
686
|
+
}, Ge = class {
|
|
658
687
|
#e;
|
|
659
688
|
#t;
|
|
660
689
|
handle;
|
|
@@ -665,7 +694,7 @@ var me = class {
|
|
|
665
694
|
value: n,
|
|
666
695
|
owner: r,
|
|
667
696
|
detachFromOwner: i
|
|
668
|
-
}, this.handle = new
|
|
697
|
+
}, this.handle = P(new We(this));
|
|
669
698
|
}
|
|
670
699
|
publish() {
|
|
671
700
|
let e = this.#e;
|
|
@@ -673,28 +702,27 @@ var me = class {
|
|
|
673
702
|
}
|
|
674
703
|
use(e) {
|
|
675
704
|
let t = this.#e;
|
|
676
|
-
if (t.phase === "disposed") throw new
|
|
705
|
+
if (t.phase === "disposed") throw new D(S, "Contribution is no longer available");
|
|
677
706
|
let { owner: n, value: r } = t;
|
|
678
707
|
return n.borrow(() => e(r));
|
|
679
708
|
}
|
|
680
|
-
update(
|
|
681
|
-
let
|
|
682
|
-
if (
|
|
683
|
-
if (!
|
|
684
|
-
Object.is(
|
|
709
|
+
update(t) {
|
|
710
|
+
let n = this.#e;
|
|
711
|
+
if (n.phase === "disposed") throw TypeError(`Contribution '${this.#t}' has been disposed`);
|
|
712
|
+
if (!n.owner.acceptsWork) throw new D(e, "Contribution owner is closed");
|
|
713
|
+
Object.is(n.value, t) || (n.value = t, n.store.valueChanged(this.#t, this));
|
|
685
714
|
}
|
|
686
|
-
[
|
|
715
|
+
[g]() {
|
|
687
716
|
let e = this.#e;
|
|
688
|
-
|
|
689
|
-
this.#e = { phase: "disposed" };
|
|
717
|
+
e.phase !== "disposed" && (this.#e = { phase: "disposed" }, w(() => {
|
|
690
718
|
try {
|
|
691
719
|
e.store.removeContribution(this.#t, this);
|
|
692
720
|
} finally {
|
|
693
721
|
e.detachFromOwner();
|
|
694
722
|
}
|
|
695
|
-
}
|
|
723
|
+
}));
|
|
696
724
|
}
|
|
697
|
-
},
|
|
725
|
+
}, Ke = class {
|
|
698
726
|
#e;
|
|
699
727
|
#t;
|
|
700
728
|
#n = /* @__PURE__ */ new Map();
|
|
@@ -705,16 +733,16 @@ var me = class {
|
|
|
705
733
|
#s;
|
|
706
734
|
#c = !1;
|
|
707
735
|
constructor(e, t, n) {
|
|
708
|
-
this.#e = e, this.#t = n, this.#r = new
|
|
736
|
+
this.#e = e, this.#t = n, this.#r = new oe(() => this.#i, t);
|
|
709
737
|
}
|
|
710
738
|
stage(e, t, n, r, i) {
|
|
711
739
|
try {
|
|
712
|
-
|
|
713
|
-
let a =
|
|
740
|
+
Xe(t);
|
|
741
|
+
let a = Ze(e, t);
|
|
714
742
|
if (this.#n.has(a)) throw TypeError(`Duplicate contribution '${a}'`);
|
|
715
743
|
return r.stage((e) => {
|
|
716
744
|
i?.();
|
|
717
|
-
let t = new
|
|
745
|
+
let t = new Ge(this, a, n, r, e);
|
|
718
746
|
return this.#n.set(a, {
|
|
719
747
|
contribution: t,
|
|
720
748
|
phase: "staged"
|
|
@@ -730,7 +758,7 @@ var me = class {
|
|
|
730
758
|
store: this,
|
|
731
759
|
own: e,
|
|
732
760
|
...t && { owner: t }
|
|
733
|
-
} }, r, i = new
|
|
761
|
+
} }, r, i = new qe(n, () => {
|
|
734
762
|
let e = r;
|
|
735
763
|
r = void 0;
|
|
736
764
|
try {
|
|
@@ -744,14 +772,14 @@ var me = class {
|
|
|
744
772
|
} catch (e) {
|
|
745
773
|
throw n.binding = void 0, this.#a--, this.#u(), e;
|
|
746
774
|
}
|
|
747
|
-
return new
|
|
775
|
+
return new B(n);
|
|
748
776
|
}
|
|
749
777
|
hostView() {
|
|
750
|
-
return this.#s ??= new
|
|
778
|
+
return this.#s ??= new B({ binding: { store: this } });
|
|
751
779
|
}
|
|
752
780
|
use(e, t) {
|
|
753
781
|
let n = this.#n.get(e);
|
|
754
|
-
if (n?.phase !== "published") throw new
|
|
782
|
+
if (n?.phase !== "published") throw new D(S, `Contribution '${e}' is not available`);
|
|
755
783
|
if (typeof t != "function") throw TypeError("Contribution callback must be a function");
|
|
756
784
|
return n.contribution.use(t);
|
|
757
785
|
}
|
|
@@ -760,12 +788,12 @@ var me = class {
|
|
|
760
788
|
}
|
|
761
789
|
subscribe(e, t) {
|
|
762
790
|
if (typeof e != "function") throw TypeError("Contribution subscriber must be a function");
|
|
763
|
-
let
|
|
764
|
-
if (!t) return
|
|
791
|
+
let n = this.#r.view.subscribe(e);
|
|
792
|
+
if (!t) return n;
|
|
765
793
|
this.#o++;
|
|
766
|
-
let
|
|
767
|
-
let e =
|
|
768
|
-
|
|
794
|
+
let r, i = new Je(n, () => {
|
|
795
|
+
let e = r;
|
|
796
|
+
r = void 0;
|
|
769
797
|
try {
|
|
770
798
|
e?.();
|
|
771
799
|
} finally {
|
|
@@ -773,11 +801,11 @@ var me = class {
|
|
|
773
801
|
}
|
|
774
802
|
});
|
|
775
803
|
try {
|
|
776
|
-
|
|
804
|
+
r = t(i), P(i);
|
|
777
805
|
} catch (e) {
|
|
778
|
-
throw
|
|
806
|
+
throw i[g](), e;
|
|
779
807
|
}
|
|
780
|
-
return
|
|
808
|
+
return i;
|
|
781
809
|
}
|
|
782
810
|
publishClaim(e, t) {
|
|
783
811
|
let n = this.#l(e, t);
|
|
@@ -809,13 +837,13 @@ var me = class {
|
|
|
809
837
|
if (!(this.#c || this.#s || this.#n.size || this.#o || this.#a)) {
|
|
810
838
|
this.#c = !0;
|
|
811
839
|
try {
|
|
812
|
-
this.#r[
|
|
840
|
+
this.#r[g]();
|
|
813
841
|
} finally {
|
|
814
842
|
this.#t(this);
|
|
815
843
|
}
|
|
816
844
|
}
|
|
817
845
|
}
|
|
818
|
-
},
|
|
846
|
+
}, qe = class {
|
|
819
847
|
#e;
|
|
820
848
|
constructor(e, t) {
|
|
821
849
|
this.#e = {
|
|
@@ -823,11 +851,11 @@ var me = class {
|
|
|
823
851
|
release: t
|
|
824
852
|
}, Object.freeze(this);
|
|
825
853
|
}
|
|
826
|
-
[
|
|
854
|
+
[g]() {
|
|
827
855
|
let e = this.#e;
|
|
828
856
|
e && (this.#e = void 0, e.state.binding = void 0, e.release());
|
|
829
857
|
}
|
|
830
|
-
},
|
|
858
|
+
}, Je = class {
|
|
831
859
|
#e;
|
|
832
860
|
constructor(e, t) {
|
|
833
861
|
this.#e = {
|
|
@@ -835,18 +863,18 @@ var me = class {
|
|
|
835
863
|
release: t
|
|
836
864
|
}, Object.freeze(this);
|
|
837
865
|
}
|
|
838
|
-
[
|
|
866
|
+
[g]() {
|
|
839
867
|
let e = this.#e;
|
|
840
868
|
if (e) {
|
|
841
869
|
this.#e = void 0;
|
|
842
870
|
try {
|
|
843
|
-
e.subscription[
|
|
871
|
+
e.subscription[g]();
|
|
844
872
|
} finally {
|
|
845
873
|
e.release();
|
|
846
874
|
}
|
|
847
875
|
}
|
|
848
876
|
}
|
|
849
|
-
},
|
|
877
|
+
}, Ye = class {
|
|
850
878
|
#e = /* @__PURE__ */ new Map();
|
|
851
879
|
#t = /* @__PURE__ */ new Set();
|
|
852
880
|
#n;
|
|
@@ -857,7 +885,7 @@ var me = class {
|
|
|
857
885
|
get(e) {
|
|
858
886
|
let t = e.id, n = this.#e.get(t);
|
|
859
887
|
if (n) return n;
|
|
860
|
-
let r = new
|
|
888
|
+
let r = new Ke((e) => this.#i(e), this.#n, (e) => {
|
|
861
889
|
this.#e.get(t) === e && (this.#t.delete(e), this.#e.delete(t));
|
|
862
890
|
});
|
|
863
891
|
return this.#e.set(t, r), r;
|
|
@@ -867,7 +895,7 @@ var me = class {
|
|
|
867
895
|
return t ? n.view((e) => t.own(e), t) : n.hostView();
|
|
868
896
|
}
|
|
869
897
|
scope(e, t, n) {
|
|
870
|
-
return new
|
|
898
|
+
return new Qe(this, e, t, n);
|
|
871
899
|
}
|
|
872
900
|
beginBatch() {
|
|
873
901
|
this.#r++;
|
|
@@ -876,7 +904,7 @@ var me = class {
|
|
|
876
904
|
if (!this.#r) throw Error("Contribution batch is not active");
|
|
877
905
|
if (this.#r--, this.#r) return;
|
|
878
906
|
let e = [...this.#t];
|
|
879
|
-
this.#t.clear(),
|
|
907
|
+
this.#t.clear(), w(() => {
|
|
880
908
|
let t = [];
|
|
881
909
|
for (let n of e) try {
|
|
882
910
|
n.publishSnapshot();
|
|
@@ -891,17 +919,17 @@ var me = class {
|
|
|
891
919
|
this.#t.add(e), !this.#r && (this.#t.delete(e), e.publishSnapshot());
|
|
892
920
|
}
|
|
893
921
|
};
|
|
894
|
-
function
|
|
922
|
+
function Xe(e) {
|
|
895
923
|
if (typeof e != "string" || !e.trim()) throw TypeError("Contribution key must be a non-empty string");
|
|
896
924
|
if (e !== e.trim()) throw TypeError("Contribution key cannot start or end with whitespace");
|
|
897
925
|
}
|
|
898
|
-
function
|
|
899
|
-
return `${
|
|
926
|
+
function Ze(e, t) {
|
|
927
|
+
return `${V(e)}/${V(t)}`;
|
|
900
928
|
}
|
|
901
|
-
function
|
|
929
|
+
function V(e) {
|
|
902
930
|
return e.replaceAll("%", "%25").replaceAll("/", "%2F");
|
|
903
931
|
}
|
|
904
|
-
var
|
|
932
|
+
var Qe = class {
|
|
905
933
|
#e;
|
|
906
934
|
constructor(e, t, n, r) {
|
|
907
935
|
this.#e = {
|
|
@@ -913,14 +941,14 @@ var we = class {
|
|
|
913
941
|
this.#e = void 0;
|
|
914
942
|
}), Object.freeze(this);
|
|
915
943
|
}
|
|
916
|
-
add(
|
|
917
|
-
let
|
|
918
|
-
if (!
|
|
919
|
-
let
|
|
920
|
-
return
|
|
944
|
+
add(t, n, r, i) {
|
|
945
|
+
let a = this.#e;
|
|
946
|
+
if (!a || !a.owner.acceptsWork) throw new D(e, "Contribution scope is closed");
|
|
947
|
+
let o = M(t, "extensionPoint"), s = a.owner.resolveOwner(i);
|
|
948
|
+
return a.registry.get(o).stage(a.installationId, n, r, s, () => a.remember(o));
|
|
921
949
|
}
|
|
922
|
-
},
|
|
923
|
-
function
|
|
950
|
+
}, $e = 64;
|
|
951
|
+
function H(e) {
|
|
924
952
|
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Map(), r = (e, i) => {
|
|
925
953
|
if (e === null || typeof e == "string" || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e)) return {
|
|
926
954
|
value: e,
|
|
@@ -929,105 +957,91 @@ function I(e) {
|
|
|
929
957
|
if (typeof e != "object" || !e) throw TypeError(`Unsupported configuration value at ${i}`);
|
|
930
958
|
if (t.has(e)) throw TypeError(`Circular configuration at ${i}`);
|
|
931
959
|
let a = n.get(e);
|
|
932
|
-
if (t.size + (a?.height ?? 1) >
|
|
960
|
+
if (t.size + (a?.height ?? 1) > $e) throw TypeError("Configuration exceeds the supported nesting depth");
|
|
933
961
|
if (a) return a;
|
|
934
962
|
t.add(e);
|
|
935
|
-
let o = 1,
|
|
963
|
+
let o = 1, c = (e, t) => {
|
|
936
964
|
let n = r(e, t);
|
|
937
965
|
return o = Math.max(o, n.height + 1), n.value;
|
|
938
|
-
},
|
|
966
|
+
}, l;
|
|
939
967
|
if (Array.isArray(e)) {
|
|
940
|
-
let t =
|
|
941
|
-
|
|
968
|
+
let t = s(e, `Configuration array at ${i}`);
|
|
969
|
+
l = Object.freeze(t.map((e, t) => c(e, `${i}[${t}]`)));
|
|
942
970
|
} else {
|
|
943
|
-
let t = Object.
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
for (let t of Reflect.ownKeys(e)) {
|
|
947
|
-
if (typeof t != "string") throw TypeError(`Configuration keys must be strings at ${i}`);
|
|
948
|
-
let r = Object.getOwnPropertyDescriptor(e, t);
|
|
949
|
-
if (!r || !("value" in r) || !r.enumerable) throw TypeError(`Configuration must contain enumerable data properties at ${i}.${t}`);
|
|
950
|
-
r.value !== void 0 && (n[t] = s(r.value, `${i}.${t}`));
|
|
951
|
-
}
|
|
952
|
-
c = Object.freeze(n);
|
|
971
|
+
let t = E(e, i), n = Object.create(null);
|
|
972
|
+
for (let [e, r] of Object.entries(t)) r !== void 0 && (n[e] = c(r, `${i}.${e}`));
|
|
973
|
+
l = Object.freeze(n);
|
|
953
974
|
}
|
|
954
975
|
t.delete(e);
|
|
955
|
-
let
|
|
956
|
-
value:
|
|
976
|
+
let u = {
|
|
977
|
+
value: l,
|
|
957
978
|
height: o
|
|
958
979
|
};
|
|
959
|
-
return n.set(e,
|
|
980
|
+
return n.set(e, u), u;
|
|
960
981
|
};
|
|
961
982
|
return e === void 0 ? void 0 : r(e, "configuration").value;
|
|
962
983
|
}
|
|
963
|
-
async function
|
|
964
|
-
if (
|
|
965
|
-
let
|
|
966
|
-
if (
|
|
967
|
-
let
|
|
968
|
-
if (
|
|
984
|
+
async function et(e, t, n, r) {
|
|
985
|
+
if (r?.throwIfAborted(), !e) return Object.freeze({ value: t });
|
|
986
|
+
let i = e["~standard"].validate(t), a = r ? (await tt(i, r)).value : (await T(i)).value;
|
|
987
|
+
if (r?.throwIfAborted(), !a || typeof a != "object" && typeof a != "function") throw TypeError(`Installation '${n}' configuration validator returned a non-object result`);
|
|
988
|
+
let o = a.issues;
|
|
989
|
+
if (o !== void 0) throw Array.isArray(o) ? new C(o, { details: {
|
|
969
990
|
installation: n,
|
|
970
991
|
phase: "configuration",
|
|
971
992
|
outcome: "rejected"
|
|
972
993
|
} }) : TypeError(`Installation '${n}' configuration validator returned non-array issues`);
|
|
973
|
-
if (!
|
|
974
|
-
let
|
|
975
|
-
return Object.freeze({ value: Object.is(
|
|
994
|
+
if (!("value" in a)) throw TypeError(`Installation '${n}' configuration validator returned neither value nor issues`);
|
|
995
|
+
let s = a.value;
|
|
996
|
+
return Object.freeze({ value: Object.is(s, t) ? t : H(s) });
|
|
976
997
|
}
|
|
977
|
-
function
|
|
978
|
-
let
|
|
979
|
-
|
|
998
|
+
function tt(e, t) {
|
|
999
|
+
let n = Promise.withResolvers(), { promise: r } = n, i = o(t, (e) => {
|
|
1000
|
+
n?.reject(e), n = void 0;
|
|
980
1001
|
});
|
|
981
|
-
return
|
|
982
|
-
|
|
1002
|
+
return T(e).then((e) => n?.resolve(e), (e) => n?.reject(e)), r.finally(() => {
|
|
1003
|
+
n = void 0, i();
|
|
983
1004
|
});
|
|
984
1005
|
}
|
|
985
|
-
async function Oe(e) {
|
|
986
|
-
return { result: await e };
|
|
987
|
-
}
|
|
988
1006
|
// src/composition/plugin.ts
|
|
989
|
-
var
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
"requires",
|
|
993
|
-
"provides",
|
|
994
|
-
"setup"
|
|
995
|
-
]);
|
|
996
|
-
function Ae(e) {
|
|
997
|
-
return L(e);
|
|
1007
|
+
var nt = y()("name", "configuration", "requires", "provides", "setup");
|
|
1008
|
+
function rt(e) {
|
|
1009
|
+
return W(e);
|
|
998
1010
|
}
|
|
999
|
-
|
|
1000
|
-
|
|
1011
|
+
var U = /* @__PURE__ */ new WeakSet();
|
|
1012
|
+
function W(e) {
|
|
1013
|
+
if (U.has(e)) return e;
|
|
1014
|
+
let t = E(e, "Plugin declaration", { fields: nt }), { name: n, configuration: r, setup: i } = t;
|
|
1001
1015
|
if (typeof n != "string" || !n.trim()) throw TypeError("Plugin name must be a non-empty string");
|
|
1002
1016
|
if (n !== n.trim()) throw TypeError("Plugin name cannot start or end with whitespace");
|
|
1003
1017
|
if (typeof i != "function") throw TypeError(`Plugin '${n}' must define setup()`);
|
|
1004
|
-
let a = r === void 0 ? void 0 :
|
|
1005
|
-
return Object.freeze({
|
|
1018
|
+
let a = r === void 0 ? void 0 : it(r, n), o = t.requires === void 0 ? void 0 : E(t.requires, `Plugin '${n}' requires`), s = t.provides === void 0 ? void 0 : E(t.provides, `Plugin '${n}' provides`), c = new ot(n), l = c.normalizeRequirements(o ?? {}), u = c.normalizeProvisions(s ?? {}), d = Object.freeze({
|
|
1006
1019
|
name: n,
|
|
1007
1020
|
...a === void 0 ? {} : { configuration: a },
|
|
1008
1021
|
requires: l,
|
|
1009
1022
|
provides: u,
|
|
1010
1023
|
setup: i
|
|
1011
1024
|
});
|
|
1025
|
+
return U.add(d), d;
|
|
1012
1026
|
}
|
|
1013
|
-
var
|
|
1014
|
-
function
|
|
1027
|
+
var G = /* @__PURE__ */ new WeakSet();
|
|
1028
|
+
function it(e, t) {
|
|
1015
1029
|
let n = () => /* @__PURE__ */ TypeError("Plugin '" + t + "' configuration must implement Standard Schema V1");
|
|
1016
1030
|
if (!e || typeof e != "object" && typeof e != "function") throw n();
|
|
1017
|
-
if (
|
|
1031
|
+
if (G.has(e)) return e;
|
|
1018
1032
|
let r = e["~standard"];
|
|
1019
1033
|
if (!r || typeof r != "object") throw n();
|
|
1020
1034
|
let { version: i, vendor: a, validate: o, jsonSchema: s } = r;
|
|
1021
1035
|
if (i !== 1 || typeof a != "string" || typeof o != "function") throw n();
|
|
1022
|
-
let c = (...e) => Reflect.apply(o, r, e), l = s === void 0 ? void 0 :
|
|
1036
|
+
let c = (...e) => Reflect.apply(o, r, e), l = s === void 0 ? void 0 : at(s, t), u = Object.freeze({ "~standard": Object.freeze({
|
|
1023
1037
|
version: 1,
|
|
1024
1038
|
vendor: a,
|
|
1025
1039
|
validate: c,
|
|
1026
1040
|
...l === void 0 ? {} : { jsonSchema: l }
|
|
1027
1041
|
}) });
|
|
1028
|
-
return
|
|
1042
|
+
return G.add(u), u;
|
|
1029
1043
|
}
|
|
1030
|
-
function
|
|
1044
|
+
function at(e, t) {
|
|
1031
1045
|
let n = () => /* @__PURE__ */ TypeError("Plugin '" + t + "' jsonSchema must implement Standard JSON Schema input/output exporters");
|
|
1032
1046
|
if (!e || typeof e != "object" && typeof e != "function") throw n();
|
|
1033
1047
|
let { input: r, output: i } = e;
|
|
@@ -1037,7 +1051,7 @@ function Me(e, t) {
|
|
|
1037
1051
|
output: (t) => Reflect.apply(i, e, [t])
|
|
1038
1052
|
});
|
|
1039
1053
|
}
|
|
1040
|
-
var
|
|
1054
|
+
var ot = class {
|
|
1041
1055
|
pluginName;
|
|
1042
1056
|
#e = /* @__PURE__ */ new Map();
|
|
1043
1057
|
constructor(e) {
|
|
@@ -1046,8 +1060,8 @@ var Ne = class {
|
|
|
1046
1060
|
normalizeRequirements(e) {
|
|
1047
1061
|
let t = Object.create(null);
|
|
1048
1062
|
for (let [n, r] of Object.entries(e)) {
|
|
1049
|
-
|
|
1050
|
-
let e =
|
|
1063
|
+
this.#t(n, "requirement");
|
|
1064
|
+
let e = De(r, `Plugin requirement '${n}' must be a Service or ExtensionPoint`, `Optional requirement '${n}' must wrap a Service`);
|
|
1051
1065
|
this.#n("requirement", n, e.kind === "optional" ? e.service : e), t[n] = e;
|
|
1052
1066
|
}
|
|
1053
1067
|
return Object.freeze(t);
|
|
@@ -1056,7 +1070,7 @@ var Ne = class {
|
|
|
1056
1070
|
let t = Object.create(null);
|
|
1057
1071
|
for (let [n, r] of Object.entries(e)) {
|
|
1058
1072
|
if (this.#t(n, "provision"), n === "then") throw TypeError("Plugin provision alias 'then' conflicts with the Promise protocol");
|
|
1059
|
-
let e =
|
|
1073
|
+
let e = M(r, "service", `Plugin provision '${n}' must be a Service`);
|
|
1060
1074
|
this.#n("provision", n, e), t[n] = e;
|
|
1061
1075
|
}
|
|
1062
1076
|
return Object.freeze(t);
|
|
@@ -1075,37 +1089,37 @@ var Ne = class {
|
|
|
1075
1089
|
});
|
|
1076
1090
|
return;
|
|
1077
1091
|
}
|
|
1078
|
-
if (r.kind !== n.kind) throw TypeError(`Plugin '${this.pluginName}' uses Contract '${n.id}' as both ${
|
|
1079
|
-
let i =
|
|
1092
|
+
if (r.kind !== n.kind) throw TypeError(`Plugin '${this.pluginName}' uses Contract '${n.id}' as both ${K(r.kind)} and ${K(n.kind)}`);
|
|
1093
|
+
let i = K(n.kind);
|
|
1080
1094
|
throw r.role === e ? TypeError(`Plugin '${this.pluginName}' ${e} aliases '${r.alias}' and '${t}' reference the same ${i} '${n.id}'`) : TypeError(`Plugin '${this.pluginName}' cannot both require and provide ${i} '${n.id}'`);
|
|
1081
1095
|
}
|
|
1082
1096
|
};
|
|
1083
|
-
function
|
|
1097
|
+
function K(e) {
|
|
1084
1098
|
return e === "extensionPoint" ? "ExtensionPoint" : e === "event" ? "Event" : "Service";
|
|
1085
1099
|
}
|
|
1086
|
-
function
|
|
1087
|
-
return
|
|
1100
|
+
function q(e) {
|
|
1101
|
+
return W(e);
|
|
1088
1102
|
}
|
|
1089
1103
|
// src/composition/installation.ts
|
|
1090
|
-
function
|
|
1091
|
-
if (e.has(t)) throw new
|
|
1104
|
+
function J(e, t) {
|
|
1105
|
+
if (e.has(t)) throw new D(_e, "Installation id is already installed: " + t);
|
|
1092
1106
|
e.add(t);
|
|
1093
1107
|
}
|
|
1094
|
-
function
|
|
1108
|
+
function st(e, t, n) {
|
|
1095
1109
|
return Object.freeze({
|
|
1096
|
-
plugin:
|
|
1097
|
-
configuration:
|
|
1098
|
-
origin:
|
|
1110
|
+
plugin: q(e),
|
|
1111
|
+
configuration: H(t),
|
|
1112
|
+
origin: ct(n)
|
|
1099
1113
|
});
|
|
1100
1114
|
}
|
|
1101
|
-
function
|
|
1102
|
-
let t =
|
|
1115
|
+
function ct(e) {
|
|
1116
|
+
let t = H(e);
|
|
1103
1117
|
if (t !== void 0) {
|
|
1104
1118
|
if (t === null || Array.isArray(t) || typeof t != "object") throw TypeError("Installation origin must be a data record");
|
|
1105
1119
|
return t;
|
|
1106
1120
|
}
|
|
1107
1121
|
}
|
|
1108
|
-
var
|
|
1122
|
+
var Y = class {
|
|
1109
1123
|
#e = {
|
|
1110
1124
|
status: "pending",
|
|
1111
1125
|
origin: void 0
|
|
@@ -1117,9 +1131,8 @@ var W = class {
|
|
|
1117
1131
|
retire() {
|
|
1118
1132
|
this.#e.status = "removed";
|
|
1119
1133
|
}
|
|
1120
|
-
},
|
|
1134
|
+
}, lt = class {
|
|
1121
1135
|
id;
|
|
1122
|
-
index;
|
|
1123
1136
|
group;
|
|
1124
1137
|
facade;
|
|
1125
1138
|
#e;
|
|
@@ -1127,17 +1140,17 @@ var W = class {
|
|
|
1127
1140
|
status: "pending",
|
|
1128
1141
|
origin: void 0
|
|
1129
1142
|
});
|
|
1130
|
-
constructor(e, t
|
|
1131
|
-
this.id = e, this.
|
|
1132
|
-
let
|
|
1143
|
+
constructor(e, t) {
|
|
1144
|
+
this.id = e, this.group = t;
|
|
1145
|
+
let n = this;
|
|
1133
1146
|
this.facade = Object.freeze({
|
|
1134
1147
|
id: e,
|
|
1135
|
-
groupId:
|
|
1148
|
+
groupId: t?.id,
|
|
1136
1149
|
get status() {
|
|
1137
|
-
return
|
|
1150
|
+
return n.#n().status;
|
|
1138
1151
|
},
|
|
1139
1152
|
get origin() {
|
|
1140
|
-
return
|
|
1153
|
+
return n.#n().origin;
|
|
1141
1154
|
}
|
|
1142
1155
|
});
|
|
1143
1156
|
}
|
|
@@ -1153,16 +1166,15 @@ var W = class {
|
|
|
1153
1166
|
#n() {
|
|
1154
1167
|
return this.#e?.() ?? this.#t;
|
|
1155
1168
|
}
|
|
1156
|
-
};
|
|
1157
|
-
|
|
1158
|
-
function G(e, t) {
|
|
1169
|
+
}, ut = y()("id", "configuration", "origin", "group"), dt = y()("plugin", "configuration", "origin");
|
|
1170
|
+
function X(e, t) {
|
|
1159
1171
|
if (typeof e != "string" || !e.trim() || e.trim() !== e) throw TypeError(t + " must be a non-empty trimmed string");
|
|
1160
1172
|
}
|
|
1161
|
-
var
|
|
1173
|
+
var ft = class {
|
|
1162
1174
|
#e = /* @__PURE__ */ new WeakMap();
|
|
1163
|
-
#t = new
|
|
1175
|
+
#t = new Y();
|
|
1164
1176
|
create(e) {
|
|
1165
|
-
let t = new
|
|
1177
|
+
let t = new pt(this);
|
|
1166
1178
|
return this.#n().set(t.handle, {
|
|
1167
1179
|
port: e,
|
|
1168
1180
|
operations: [],
|
|
@@ -1171,7 +1183,7 @@ var Fe = class {
|
|
|
1171
1183
|
}
|
|
1172
1184
|
take(e) {
|
|
1173
1185
|
let t = this.#n(), n = t.get(e);
|
|
1174
|
-
if (!n) throw new
|
|
1186
|
+
if (!n) throw new D(pe, "ChangeSet belongs to another Host or was already planned");
|
|
1175
1187
|
return t.delete(e), Object.freeze(n.operations);
|
|
1176
1188
|
}
|
|
1177
1189
|
requireOpen(e) {
|
|
@@ -1186,10 +1198,10 @@ var Fe = class {
|
|
|
1186
1198
|
this.#e = e, this.#t.retire();
|
|
1187
1199
|
}
|
|
1188
1200
|
#n() {
|
|
1189
|
-
if (typeof this.#e == "number") throw
|
|
1201
|
+
if (typeof this.#e == "number") throw a(this.#e);
|
|
1190
1202
|
return this.#e;
|
|
1191
1203
|
}
|
|
1192
|
-
},
|
|
1204
|
+
}, pt = class {
|
|
1193
1205
|
authority;
|
|
1194
1206
|
handle = Object.freeze({
|
|
1195
1207
|
install: this.install.bind(this),
|
|
@@ -1201,15 +1213,10 @@ var Fe = class {
|
|
|
1201
1213
|
constructor(e) {
|
|
1202
1214
|
this.authority = e, Object.freeze(this);
|
|
1203
1215
|
}
|
|
1204
|
-
install(e, t) {
|
|
1205
|
-
let { port: n } = this.#t(), r =
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
"origin",
|
|
1209
|
-
"group"
|
|
1210
|
-
]) });
|
|
1211
|
-
G(r.id, "Installation id");
|
|
1212
|
-
let i = r.group === void 0 ? void 0 : n.resolveGroup(r.group), a = H(e, r.configuration, r.origin);
|
|
1216
|
+
install(...[e, t]) {
|
|
1217
|
+
let { port: n } = this.#t(), r = E(t, "Installation options", { fields: ut });
|
|
1218
|
+
X(r.id, "Installation id");
|
|
1219
|
+
let i = r.group === void 0 ? void 0 : n.resolveGroup(r.group), a = st(e, r.configuration, r.origin);
|
|
1213
1220
|
this.#t();
|
|
1214
1221
|
let o = n.create(r.id, i);
|
|
1215
1222
|
return this.#e(o, {
|
|
@@ -1219,19 +1226,17 @@ var Fe = class {
|
|
|
1219
1226
|
}), o.facade;
|
|
1220
1227
|
}
|
|
1221
1228
|
update(e, t) {
|
|
1222
|
-
let { port: n } = this.#t(), r =
|
|
1223
|
-
"plugin",
|
|
1224
|
-
"configuration",
|
|
1225
|
-
"origin"
|
|
1226
|
-
]) }), i = Object.hasOwn(r, "plugin"), a = Object.hasOwn(r, "configuration");
|
|
1229
|
+
let { port: n } = this.#t(), r = E(t, "Installation update", { fields: dt }), i = Object.hasOwn(r, "plugin"), a = Object.hasOwn(r, "configuration");
|
|
1227
1230
|
if (!i && !a) throw TypeError("Installation update requires plugin or configuration");
|
|
1228
1231
|
if (!i && Object.hasOwn(r, "origin")) throw TypeError("Origin can only change with its Plugin");
|
|
1229
|
-
let o = {
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
} : {}
|
|
1234
|
-
|
|
1232
|
+
let o = i ? {
|
|
1233
|
+
kind: "replace",
|
|
1234
|
+
plugin: q(r.plugin),
|
|
1235
|
+
origin: ct(r.origin),
|
|
1236
|
+
...a ? { configuration: H(r.configuration) } : {}
|
|
1237
|
+
} : {
|
|
1238
|
+
kind: "configure",
|
|
1239
|
+
configuration: H(r.configuration)
|
|
1235
1240
|
}, s = n.resolve(e);
|
|
1236
1241
|
this.#e(s, {
|
|
1237
1242
|
kind: "update",
|
|
@@ -1248,7 +1253,7 @@ var Fe = class {
|
|
|
1248
1253
|
}
|
|
1249
1254
|
group(e, t) {
|
|
1250
1255
|
let { port: n } = this.#t();
|
|
1251
|
-
|
|
1256
|
+
X(e, "Group id");
|
|
1252
1257
|
let r = n.createGroup(e, t === void 0 ? void 0 : n.resolveGroup(t));
|
|
1253
1258
|
return this.#e(r, {
|
|
1254
1259
|
kind: "group",
|
|
@@ -1270,7 +1275,7 @@ var Fe = class {
|
|
|
1270
1275
|
#t() {
|
|
1271
1276
|
return this.authority.requireOpen(this.handle);
|
|
1272
1277
|
}
|
|
1273
|
-
},
|
|
1278
|
+
}, mt = class e {
|
|
1274
1279
|
declarations;
|
|
1275
1280
|
byId;
|
|
1276
1281
|
order;
|
|
@@ -1282,7 +1287,7 @@ var Fe = class {
|
|
|
1282
1287
|
this.declarations = e, this.byId = t, this.order = n, this.layers = r, this.providers = i, this.dependents = a, this.contractKinds = o;
|
|
1283
1288
|
}
|
|
1284
1289
|
static build(t) {
|
|
1285
|
-
let n = [...t.keys()]
|
|
1290
|
+
let n = [...t.keys()], r = /* @__PURE__ */ new Map(), i = ht(t, r), a = gt(t, i, r), { order: o, layers: s } = _t(n, a.dependents, a.indegree);
|
|
1286
1291
|
return new e(t, new Map(n.map((e) => [e.id, e])), Object.freeze(o), Object.freeze(s.map((e) => Object.freeze(e))), i, a.dependents, r);
|
|
1287
1292
|
}
|
|
1288
1293
|
declarationFor(e) {
|
|
@@ -1305,12 +1310,12 @@ var Fe = class {
|
|
|
1305
1310
|
}
|
|
1306
1311
|
}
|
|
1307
1312
|
};
|
|
1308
|
-
function
|
|
1313
|
+
function ht(e, t) {
|
|
1309
1314
|
let n = /* @__PURE__ */ new Map();
|
|
1310
1315
|
for (let [r, i] of e) for (let e of Object.values(i.plugin.provides)) {
|
|
1311
|
-
|
|
1316
|
+
R(t, e);
|
|
1312
1317
|
let i = n.get(e.id);
|
|
1313
|
-
if (i) throw new
|
|
1318
|
+
if (i) throw new D(c, `Service '${e.id}' is provided by both '${i.id}' and '${r.id}'`, { details: {
|
|
1314
1319
|
outcome: "rejected",
|
|
1315
1320
|
contract: e.id,
|
|
1316
1321
|
affectedInstallations: [i.id, r.id]
|
|
@@ -1319,21 +1324,21 @@ function Le(e, t) {
|
|
|
1319
1324
|
}
|
|
1320
1325
|
return n;
|
|
1321
1326
|
}
|
|
1322
|
-
function
|
|
1327
|
+
function gt(e, t, n) {
|
|
1323
1328
|
let r = /* @__PURE__ */ new Map(), i = new Map([...e.keys()].map((e) => [e, 0]));
|
|
1324
1329
|
for (let [a, o] of e) for (let e of Object.values(o.plugin.requires)) {
|
|
1325
1330
|
let o = e.kind === "optional" ? e.service : e;
|
|
1326
|
-
if (
|
|
1331
|
+
if (R(n, o), o.kind === "extensionPoint") continue;
|
|
1327
1332
|
let s = t.get(o.id);
|
|
1328
1333
|
if (!s) {
|
|
1329
1334
|
if (e.kind === "optional") continue;
|
|
1330
|
-
throw new
|
|
1335
|
+
throw new D(te, `Installation '${a.id}' requires missing Service '${o.id}'`, { details: {
|
|
1331
1336
|
outcome: "rejected",
|
|
1332
1337
|
installation: a.id,
|
|
1333
1338
|
contract: o.id
|
|
1334
1339
|
} });
|
|
1335
1340
|
}
|
|
1336
|
-
if (s === a) throw new
|
|
1341
|
+
if (s === a) throw new D(d, `Installation '${a.id}' cannot require Service '${o.id}' that it provides`, { details: {
|
|
1337
1342
|
outcome: "rejected",
|
|
1338
1343
|
installation: a.id,
|
|
1339
1344
|
contract: o.id,
|
|
@@ -1347,33 +1352,33 @@ function Re(e, t, n) {
|
|
|
1347
1352
|
indegree: i
|
|
1348
1353
|
};
|
|
1349
1354
|
}
|
|
1350
|
-
function
|
|
1351
|
-
let r = e.filter((e) => n.get(e) === 0),
|
|
1352
|
-
for (;
|
|
1353
|
-
|
|
1354
|
-
let e =
|
|
1355
|
-
|
|
1356
|
-
for (let
|
|
1357
|
-
|
|
1358
|
-
for (let e of t.get(
|
|
1355
|
+
function _t(e, t, n) {
|
|
1356
|
+
let r = new Map(e.map((e, t) => [e, t])), i = e.filter((e) => n.get(e) === 0), a = [], o = [];
|
|
1357
|
+
for (; i.length;) {
|
|
1358
|
+
i.sort((e, t) => r.get(e) - r.get(t));
|
|
1359
|
+
let e = i;
|
|
1360
|
+
i = [], o.push(e);
|
|
1361
|
+
for (let r of e) {
|
|
1362
|
+
a.push(r);
|
|
1363
|
+
for (let e of t.get(r) ?? []) {
|
|
1359
1364
|
let t = (n.get(e) ?? 0) - 1;
|
|
1360
|
-
n.set(e, t), t ||
|
|
1365
|
+
n.set(e, t), t || i.push(e);
|
|
1361
1366
|
}
|
|
1362
1367
|
}
|
|
1363
1368
|
}
|
|
1364
|
-
if (
|
|
1365
|
-
let e =
|
|
1366
|
-
throw new
|
|
1369
|
+
if (a.length !== e.length) {
|
|
1370
|
+
let e = vt(t, n);
|
|
1371
|
+
throw new D(d, `Installation dependency cycle: ${e.map((e) => e.id).join(" -> ")}`, { details: {
|
|
1367
1372
|
outcome: "rejected",
|
|
1368
1373
|
dependencyPath: e.map((e) => e.id)
|
|
1369
1374
|
} });
|
|
1370
1375
|
}
|
|
1371
1376
|
return {
|
|
1372
|
-
order:
|
|
1373
|
-
layers:
|
|
1377
|
+
order: a,
|
|
1378
|
+
layers: o
|
|
1374
1379
|
};
|
|
1375
1380
|
}
|
|
1376
|
-
function
|
|
1381
|
+
function vt(e, t) {
|
|
1377
1382
|
let n = /* @__PURE__ */ new Map();
|
|
1378
1383
|
for (let [r, i] of e) if (t.get(r)) for (let e of i) n.set(e, r);
|
|
1379
1384
|
let r = n.keys().next().value, i = /* @__PURE__ */ new Map();
|
|
@@ -1381,7 +1386,7 @@ function Be(e, t) {
|
|
|
1381
1386
|
return [...Array.from(i.keys()).slice(i.get(r)), r].reverse();
|
|
1382
1387
|
}
|
|
1383
1388
|
// src/composition/group.ts
|
|
1384
|
-
var
|
|
1389
|
+
var yt = class {
|
|
1385
1390
|
id;
|
|
1386
1391
|
parent;
|
|
1387
1392
|
facade;
|
|
@@ -1395,13 +1400,13 @@ var Ve = class {
|
|
|
1395
1400
|
return this.parent?.id;
|
|
1396
1401
|
}
|
|
1397
1402
|
};
|
|
1398
|
-
function
|
|
1403
|
+
function bt(e, t) {
|
|
1399
1404
|
let n = /* @__PURE__ */ new Map();
|
|
1400
1405
|
for (let r of e.keys()) {
|
|
1401
1406
|
let i = /* @__PURE__ */ new Set(), a = r;
|
|
1402
1407
|
for (; a !== void 0 && !n.has(a);) {
|
|
1403
|
-
if (!e.has(a)) throw new
|
|
1404
|
-
if (i.has(a)) throw new
|
|
1408
|
+
if (!e.has(a)) throw new D(v, "Initial Group is missing: " + a);
|
|
1409
|
+
if (i.has(a)) throw new D(ge, "Group ownership must be acyclic");
|
|
1405
1410
|
i.add(a), a = e.get(a);
|
|
1406
1411
|
}
|
|
1407
1412
|
let o = a === void 0 ? void 0 : n.get(a);
|
|
@@ -1410,56 +1415,91 @@ function He(e, t) {
|
|
|
1410
1415
|
return n;
|
|
1411
1416
|
}
|
|
1412
1417
|
// src/composition/plan.ts
|
|
1413
|
-
function
|
|
1414
|
-
return new
|
|
1418
|
+
function Z(e, t) {
|
|
1419
|
+
return new D(p, "Host state changed during or after planning", { details: {
|
|
1415
1420
|
outcome: "rejected",
|
|
1416
1421
|
expectedRevision: e,
|
|
1417
1422
|
stateRevision: t
|
|
1418
1423
|
} });
|
|
1419
1424
|
}
|
|
1420
|
-
var
|
|
1425
|
+
var xt = class {
|
|
1421
1426
|
#e = /* @__PURE__ */ new WeakMap();
|
|
1422
1427
|
#t = /* @__PURE__ */ new WeakMap();
|
|
1423
|
-
#n = new
|
|
1428
|
+
#n = new Y();
|
|
1424
1429
|
#r;
|
|
1425
1430
|
get validationSignal() {
|
|
1426
1431
|
return (this.#r ??= new AbortController()).signal;
|
|
1427
1432
|
}
|
|
1428
1433
|
issue(e, t) {
|
|
1429
1434
|
let { report: n } = e;
|
|
1430
|
-
if (n.baseStateRevision !== t.revision) throw
|
|
1435
|
+
if (n.baseStateRevision !== t.revision) throw Z(n.baseStateRevision, t.revision);
|
|
1431
1436
|
let r = Object.freeze({ report: n });
|
|
1432
1437
|
for (let n of e.graph.declarations.keys()) t.graph.declarations.has(n) || this.#n.attach(n);
|
|
1433
1438
|
return this.#e.set(r, "issued"), this.#t.set(r, e), r;
|
|
1434
1439
|
}
|
|
1435
1440
|
read(e, t) {
|
|
1436
1441
|
let n = this.#e.get(e);
|
|
1437
|
-
if (n === void 0) throw new
|
|
1438
|
-
if (n === "consumed") throw new
|
|
1442
|
+
if (n === void 0) throw new D(f, "Plan was not issued by this Host");
|
|
1443
|
+
if (n === "consumed") throw new D(le, "Plan has already been executed");
|
|
1439
1444
|
let r = this.#t.get(e);
|
|
1440
|
-
if (!r) throw this.consume(e),
|
|
1445
|
+
if (!r) throw this.consume(e), Z(e.report.baseStateRevision, t);
|
|
1441
1446
|
return r;
|
|
1442
1447
|
}
|
|
1443
1448
|
consume(e) {
|
|
1444
1449
|
this.#e.set(e, "consumed"), this.#t.delete(e);
|
|
1445
1450
|
}
|
|
1446
1451
|
invalidate(e, t) {
|
|
1447
|
-
this.#r?.abort(t ?
|
|
1452
|
+
this.#r?.abort(Object.freeze(t ? a(e) : Z(e - 1, e))), this.#r = void 0, this.#n.retire(), this.#n = new Y(), this.#t = /* @__PURE__ */ new WeakMap();
|
|
1448
1453
|
}
|
|
1449
1454
|
};
|
|
1450
|
-
function
|
|
1455
|
+
function St(e, t, n) {
|
|
1456
|
+
return Object.freeze(e.map((e) => {
|
|
1457
|
+
switch (e.kind) {
|
|
1458
|
+
case "install": return Object.freeze({
|
|
1459
|
+
kind: e.kind,
|
|
1460
|
+
id: e.installation.id,
|
|
1461
|
+
before: void 0,
|
|
1462
|
+
after: $(n.declarationFor(e.installation))
|
|
1463
|
+
});
|
|
1464
|
+
case "update": return Object.freeze({
|
|
1465
|
+
kind: e.kind,
|
|
1466
|
+
id: e.installation.id,
|
|
1467
|
+
before: $(t.declarationFor(e.installation)),
|
|
1468
|
+
after: $(n.declarationFor(e.installation))
|
|
1469
|
+
});
|
|
1470
|
+
case "remove": return Object.freeze({
|
|
1471
|
+
kind: e.kind,
|
|
1472
|
+
id: e.installation.id,
|
|
1473
|
+
before: $(t.declarationFor(e.installation)),
|
|
1474
|
+
after: void 0
|
|
1475
|
+
});
|
|
1476
|
+
case "group":
|
|
1477
|
+
case "remove-group": return Object.freeze({
|
|
1478
|
+
kind: e.kind,
|
|
1479
|
+
id: e.group.id,
|
|
1480
|
+
parentId: e.group.parentId
|
|
1481
|
+
});
|
|
1482
|
+
}
|
|
1483
|
+
}));
|
|
1484
|
+
}
|
|
1485
|
+
function Q(e, t = e.order) {
|
|
1451
1486
|
return Object.freeze(t.flatMap((t) => Object.values(e.declarationFor(t).plugin.requires).flatMap((n) => {
|
|
1452
1487
|
if (n.kind === "extensionPoint") return [];
|
|
1453
|
-
let r = n.kind === "optional" ? n.service : n;
|
|
1488
|
+
let r = n.kind === "optional" ? n.service : n, i = e.providers.get(r.id);
|
|
1454
1489
|
return [Object.freeze({
|
|
1455
1490
|
installation: t.id,
|
|
1456
1491
|
contract: r.id,
|
|
1457
|
-
|
|
1458
|
-
|
|
1492
|
+
...n.kind === "optional" ? {
|
|
1493
|
+
optional: !0,
|
|
1494
|
+
provider: i?.id
|
|
1495
|
+
} : {
|
|
1496
|
+
optional: !1,
|
|
1497
|
+
provider: i.id
|
|
1498
|
+
}
|
|
1459
1499
|
})];
|
|
1460
1500
|
})));
|
|
1461
1501
|
}
|
|
1462
|
-
function
|
|
1502
|
+
function Ct(e, t, n, r) {
|
|
1463
1503
|
let i = [];
|
|
1464
1504
|
for (let a of n) {
|
|
1465
1505
|
let o = r.get(a);
|
|
@@ -1469,120 +1509,121 @@ function We(e, t, n, r) {
|
|
|
1469
1509
|
}));
|
|
1470
1510
|
else for (let r of Object.values(t.declarationFor(a).plugin.requires)) {
|
|
1471
1511
|
if (r.kind === "extensionPoint") continue;
|
|
1472
|
-
let o = (r.kind === "optional" ? r.service : r).id, s = e.providers.get(o), c = t.providers.get(o);
|
|
1473
|
-
|
|
1512
|
+
let o = (r.kind === "optional" ? r.service : r).id, s = e.providers.get(o), c = t.providers.get(o), l;
|
|
1513
|
+
if (c && n.has(c)) l = {
|
|
1514
|
+
provider: c.id,
|
|
1515
|
+
...s && { previousProvider: s.id }
|
|
1516
|
+
};
|
|
1517
|
+
else if (s && n.has(s)) l = {
|
|
1518
|
+
previousProvider: s.id,
|
|
1519
|
+
...c && { provider: c.id }
|
|
1520
|
+
};
|
|
1521
|
+
else continue;
|
|
1522
|
+
i.push(Object.freeze({
|
|
1474
1523
|
installation: a.id,
|
|
1475
1524
|
kind: "provider_changed",
|
|
1476
1525
|
contract: o,
|
|
1477
|
-
...
|
|
1478
|
-
...c === void 0 ? {} : { provider: c.id }
|
|
1526
|
+
...l
|
|
1479
1527
|
}));
|
|
1480
1528
|
}
|
|
1481
1529
|
}
|
|
1482
1530
|
return Object.freeze(i);
|
|
1483
1531
|
}
|
|
1484
|
-
function
|
|
1485
|
-
return
|
|
1532
|
+
function $(e) {
|
|
1533
|
+
return Object.freeze({
|
|
1486
1534
|
pluginName: e.plugin.name,
|
|
1487
1535
|
origin: e.origin
|
|
1488
1536
|
});
|
|
1489
1537
|
}
|
|
1490
1538
|
// src/composition/planner.ts
|
|
1491
|
-
async function
|
|
1492
|
-
let
|
|
1493
|
-
for (let
|
|
1494
|
-
if (
|
|
1495
|
-
if (
|
|
1496
|
-
|
|
1539
|
+
async function wt(e, t, n, r, a) {
|
|
1540
|
+
let o = new Map(e.graph.declarations), s = new Map(e.groups), c = new Set(e.graph.byId.keys()), l = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Set();
|
|
1541
|
+
for (let n of t) {
|
|
1542
|
+
if (n.kind === "group") {
|
|
1543
|
+
if (s.has(n.group.id)) throw new D(_, "Group id is already installed: " + n.group.id);
|
|
1544
|
+
s.set(n.group.id, n.group);
|
|
1497
1545
|
continue;
|
|
1498
1546
|
}
|
|
1499
|
-
if (
|
|
1500
|
-
|
|
1501
|
-
|
|
1547
|
+
if (n.kind === "remove-group") {
|
|
1548
|
+
if (e.groups.get(n.group.id) !== n.group) throw new D(ve, "Group is not committed: " + n.group.id);
|
|
1549
|
+
u.add(n.group);
|
|
1550
|
+
continue;
|
|
1551
|
+
}
|
|
1552
|
+
let t = n.installation;
|
|
1553
|
+
if (n.kind === "install") J(c, t.id), o.set(t, n.declaration), l.set(t, "installed");
|
|
1502
1554
|
else {
|
|
1503
|
-
let
|
|
1504
|
-
if (!
|
|
1505
|
-
if (
|
|
1555
|
+
let e = o.get(t);
|
|
1556
|
+
if (!e) throw new D(i, "Installation is not committed: " + t.id);
|
|
1557
|
+
if (n.kind === "remove") o.delete(t), l.set(t, "removed");
|
|
1506
1558
|
else {
|
|
1507
|
-
let r =
|
|
1508
|
-
|
|
1509
|
-
plugin: r.plugin
|
|
1510
|
-
configuration: Object.hasOwn(r, "configuration") ? r.configuration :
|
|
1511
|
-
origin:
|
|
1512
|
-
}
|
|
1559
|
+
let r = n.update;
|
|
1560
|
+
o.set(t, Object.freeze(r.kind === "replace" ? {
|
|
1561
|
+
plugin: r.plugin,
|
|
1562
|
+
configuration: Object.hasOwn(r, "configuration") ? r.configuration : e.configuration,
|
|
1563
|
+
origin: r.origin
|
|
1564
|
+
} : {
|
|
1565
|
+
...e,
|
|
1566
|
+
configuration: r.configuration
|
|
1567
|
+
})), l.set(t, "updated");
|
|
1513
1568
|
}
|
|
1514
1569
|
}
|
|
1515
1570
|
}
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
for (let e of o.values()) e.parentId && t.has(e.parentId) && !t.has(e.id) && (t.add(e.id), r = !0);
|
|
1571
|
+
if (u.size) {
|
|
1572
|
+
let t = Map.groupBy(s.values(), (e) => e.parent);
|
|
1573
|
+
for (let n of u) {
|
|
1574
|
+
if (e.groups.get(n.id) !== n) throw new D(x, "Group creation conflicts with ancestor removal: " + n.id);
|
|
1575
|
+
s.delete(n.id);
|
|
1576
|
+
for (let e of t.get(n) ?? []) u.add(e);
|
|
1523
1577
|
}
|
|
1524
|
-
for (let
|
|
1525
|
-
if (
|
|
1526
|
-
|
|
1527
|
-
}
|
|
1528
|
-
for (let n of t) {
|
|
1529
|
-
if (!e.groups.has(n)) throw new l("CHANGE_CONFLICT", "Group creation conflicts with ancestor removal: " + n);
|
|
1530
|
-
o.delete(n);
|
|
1578
|
+
for (let e of o.keys()) if (e.group && u.has(e.group)) {
|
|
1579
|
+
if (l.has(e)) throw new D(x, "Installation change conflicts with Group removal: " + e.id);
|
|
1580
|
+
o.delete(e), l.set(e, "removed");
|
|
1531
1581
|
}
|
|
1532
1582
|
}
|
|
1533
|
-
|
|
1534
|
-
let
|
|
1535
|
-
r.assertKinds(
|
|
1536
|
-
let
|
|
1537
|
-
for (let [t, r] of
|
|
1538
|
-
let
|
|
1539
|
-
|
|
1583
|
+
Tt(s, o);
|
|
1584
|
+
let d = mt.build(o);
|
|
1585
|
+
r.assertKinds(d.contractKinds);
|
|
1586
|
+
let f = n === "change" ? e.graph.affectedByTransitionTo(d, [...l.keys()]) : new Set(d.order), p = /* @__PURE__ */ new Map();
|
|
1587
|
+
for (let [t, r] of o) {
|
|
1588
|
+
let i = e.graph.declarations.get(t) === r ? e.configurations.get(t) : void 0;
|
|
1589
|
+
i ? p.set(t, i) : (n === "start" || l.has(t)) && p.set(t, await et(r.plugin.configuration, r.configuration, t.id, a));
|
|
1540
1590
|
}
|
|
1541
|
-
if (n !== "change") for (let e of
|
|
1542
|
-
let
|
|
1591
|
+
if (n !== "change") for (let e of f) l.set(e, n);
|
|
1592
|
+
let m = Object.freeze(n === "stop" || n === "change" && e.phase === "stopped" ? [] : d.order.filter((e) => f.has(e)).map((e) => e.id)), ee = Object.freeze({
|
|
1543
1593
|
baseStateRevision: e.revision,
|
|
1544
1594
|
intent: n,
|
|
1545
|
-
operations:
|
|
1546
|
-
kind: t.kind,
|
|
1547
|
-
id: t.installation.id,
|
|
1548
|
-
before: Y(e.graph.declarations.get(t.installation)),
|
|
1549
|
-
after: Y(a.get(t.installation))
|
|
1550
|
-
}) : Object.freeze({
|
|
1551
|
-
kind: t.kind,
|
|
1552
|
-
id: t.group.id,
|
|
1553
|
-
parentId: t.group.parentId
|
|
1554
|
-
}))),
|
|
1595
|
+
operations: St(t, e.graph, d),
|
|
1555
1596
|
bindings: Object.freeze({
|
|
1556
|
-
before:
|
|
1557
|
-
after:
|
|
1597
|
+
before: Q(e.graph),
|
|
1598
|
+
after: Q(d)
|
|
1558
1599
|
}),
|
|
1559
|
-
affectedInstallations: Object.freeze([...
|
|
1560
|
-
reasons:
|
|
1561
|
-
stopOrder: Object.freeze(e.phase === "running" ? e.graph.order.filter((e) =>
|
|
1562
|
-
prepareOrder:
|
|
1563
|
-
publishOrder:
|
|
1600
|
+
affectedInstallations: Object.freeze([...f].map((e) => e.id)),
|
|
1601
|
+
reasons: Ct(e.graph, d, f, l),
|
|
1602
|
+
stopOrder: Object.freeze(e.phase === "running" ? e.graph.order.filter((e) => f.has(e)).reverse().map((e) => e.id) : []),
|
|
1603
|
+
prepareOrder: m,
|
|
1604
|
+
publishOrder: m,
|
|
1564
1605
|
execution: Object.freeze({
|
|
1565
1606
|
atomicPublication: !0,
|
|
1566
1607
|
externalEffectsRollback: !1
|
|
1567
1608
|
})
|
|
1568
1609
|
});
|
|
1569
1610
|
return Object.freeze({
|
|
1570
|
-
groups:
|
|
1571
|
-
graph:
|
|
1572
|
-
affected:
|
|
1573
|
-
configurations:
|
|
1574
|
-
report:
|
|
1611
|
+
groups: s,
|
|
1612
|
+
graph: d,
|
|
1613
|
+
affected: f,
|
|
1614
|
+
configurations: p,
|
|
1615
|
+
report: ee
|
|
1575
1616
|
});
|
|
1576
1617
|
}
|
|
1577
|
-
function
|
|
1618
|
+
function Tt(e, t) {
|
|
1578
1619
|
for (let t of e.values()) {
|
|
1579
1620
|
let n = t.parent;
|
|
1580
|
-
if (n && e.get(n.id) !== n) throw new
|
|
1621
|
+
if (n && e.get(n.id) !== n) throw new D(v, "Group parent is not committed: " + n.id);
|
|
1581
1622
|
}
|
|
1582
|
-
for (let n of t.keys()) if (n.group && e.get(n.group.id) !== n.group) throw new
|
|
1623
|
+
for (let n of t.keys()) if (n.group && e.get(n.group.id) !== n.group) throw new D(v, "Installation Group is not committed: " + n.group.id);
|
|
1583
1624
|
}
|
|
1584
1625
|
// src/execution/instance.ts
|
|
1585
|
-
var
|
|
1626
|
+
var Et = class {
|
|
1586
1627
|
installation;
|
|
1587
1628
|
declaration;
|
|
1588
1629
|
generation;
|
|
@@ -1590,44 +1631,53 @@ var Ke = class {
|
|
|
1590
1631
|
lifetime;
|
|
1591
1632
|
#e = /* @__PURE__ */ new Map();
|
|
1592
1633
|
constructor(e, t, n, r) {
|
|
1593
|
-
this.installation = e, this.declaration = t, this.generation = n, this.environment = r, this.lifetime = new
|
|
1634
|
+
this.installation = e, this.declaration = t, this.generation = n, this.environment = r, this.lifetime = new Ie({
|
|
1594
1635
|
label: e.id + "@" + n,
|
|
1595
1636
|
report: r.report,
|
|
1637
|
+
releaseFailed: r.releaseFailed,
|
|
1596
1638
|
changed: r.changed,
|
|
1597
1639
|
parentSignal: r.startupSignal,
|
|
1598
1640
|
...r.shutdownTimeoutMilliseconds === void 0 ? {} : { shutdownTimeoutMilliseconds: r.shutdownTimeoutMilliseconds }
|
|
1599
1641
|
});
|
|
1600
1642
|
}
|
|
1601
1643
|
async prepare(e, t) {
|
|
1602
|
-
let n = this.
|
|
1603
|
-
hostName:
|
|
1644
|
+
let n = this.lifetime.signal, r = this.environment, i = Object.freeze({
|
|
1645
|
+
hostName: r.hostName,
|
|
1604
1646
|
installationId: this.installation.id,
|
|
1605
1647
|
pluginName: this.declaration.plugin.name,
|
|
1606
1648
|
generation: this.generation,
|
|
1607
1649
|
groupId: this.installation.groupId
|
|
1608
|
-
}),
|
|
1650
|
+
}), a = Object.freeze({
|
|
1609
1651
|
dependencies: e,
|
|
1610
1652
|
lifetime: this.lifetime.handle,
|
|
1611
|
-
events:
|
|
1612
|
-
contributions:
|
|
1613
|
-
metadata:
|
|
1614
|
-
logger: this.lifetime.use(new
|
|
1615
|
-
}), { setup:
|
|
1616
|
-
AbortSignal.prototype.throwIfAborted.call(
|
|
1617
|
-
let
|
|
1618
|
-
|
|
1619
|
-
|
|
1653
|
+
events: r.events.scope(this.lifetime, (e) => r.contracts.remember(e)),
|
|
1654
|
+
contributions: r.contributions.scope(this.lifetime, this.installation.id, (e) => r.contracts.remember(e)),
|
|
1655
|
+
metadata: i,
|
|
1656
|
+
logger: this.lifetime.use(new fe(r.logger, i)).handle
|
|
1657
|
+
}), { setup: o } = this.declaration.plugin, { value: s } = await this.lifetime.prepare(() => o(a, t));
|
|
1658
|
+
AbortSignal.prototype.throwIfAborted.call(n);
|
|
1659
|
+
let c = Object.entries(this.declaration.plugin.provides), l = (e, t) => new D(ee, e, {
|
|
1660
|
+
...t,
|
|
1661
|
+
details: { installation: this.installation.id }
|
|
1662
|
+
});
|
|
1663
|
+
if (!c.length) {
|
|
1664
|
+
if (s !== void 0) throw l("Plugin without provisions must return undefined");
|
|
1620
1665
|
return;
|
|
1621
1666
|
}
|
|
1622
|
-
let
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1667
|
+
let u;
|
|
1668
|
+
try {
|
|
1669
|
+
u = E(s, "Provided Services", { fields: new Set(c.map(([e]) => e)) });
|
|
1670
|
+
} catch (e) {
|
|
1671
|
+
throw l("Plugin returned invalid or unreadable provided Services", { cause: e });
|
|
1672
|
+
}
|
|
1673
|
+
AbortSignal.prototype.throwIfAborted.call(n);
|
|
1674
|
+
for (let [e, t] of c) {
|
|
1675
|
+
if (!Object.hasOwn(u, e)) throw l("Plugin did not provide " + e);
|
|
1676
|
+
this.#e.set(t.id, u[e]);
|
|
1627
1677
|
}
|
|
1628
1678
|
}
|
|
1629
1679
|
read(e) {
|
|
1630
|
-
if (!this.#e.has(e)) throw new
|
|
1680
|
+
if (!this.#e.has(e)) throw new D(O, "Service has not been prepared: " + e);
|
|
1631
1681
|
return this.#e.get(e);
|
|
1632
1682
|
}
|
|
1633
1683
|
use(e, t) {
|
|
@@ -1643,7 +1693,7 @@ var Ke = class {
|
|
|
1643
1693
|
this.lifetime.phase === "disposed" && this.#e.clear();
|
|
1644
1694
|
}
|
|
1645
1695
|
}
|
|
1646
|
-
},
|
|
1696
|
+
}, Dt = y()("name", "installations", "groups", "logger", "onError", "shutdownTimeoutMilliseconds"), Ot = y()("id", "parentId"), kt = y()("id", "plugin", "configuration", "origin", "groupId"), At = class {
|
|
1647
1697
|
#e = [];
|
|
1648
1698
|
#t;
|
|
1649
1699
|
constructor(e) {
|
|
@@ -1656,71 +1706,58 @@ var Ke = class {
|
|
|
1656
1706
|
let t = this.#e;
|
|
1657
1707
|
return this.#e = void 0, t?.length ? t.length === 1 ? t[0] : AggregateError(t, "Plugin preparation failed") : e;
|
|
1658
1708
|
}
|
|
1659
|
-
},
|
|
1709
|
+
}, jt = class {
|
|
1660
1710
|
name;
|
|
1661
1711
|
#e;
|
|
1662
1712
|
#t;
|
|
1663
1713
|
#n;
|
|
1664
|
-
#r = new
|
|
1665
|
-
#i = new
|
|
1714
|
+
#r = new ze();
|
|
1715
|
+
#i = new Ue();
|
|
1666
1716
|
#a;
|
|
1667
|
-
#o = new
|
|
1668
|
-
#s = new
|
|
1669
|
-
#c = new
|
|
1717
|
+
#o = new he();
|
|
1718
|
+
#s = new xt();
|
|
1719
|
+
#c = new ft();
|
|
1670
1720
|
#l = /* @__PURE__ */ new WeakMap();
|
|
1671
1721
|
#u = /* @__PURE__ */ new WeakMap();
|
|
1672
1722
|
#d;
|
|
1673
1723
|
#f;
|
|
1674
1724
|
#p;
|
|
1675
|
-
#m
|
|
1725
|
+
#m;
|
|
1676
1726
|
#h = 0;
|
|
1677
1727
|
constructor(e = {}) {
|
|
1678
|
-
let t =
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
"logger",
|
|
1683
|
-
"onError",
|
|
1684
|
-
"shutdownTimeoutMilliseconds"
|
|
1685
|
-
]) }), n = t.name === void 0 ? "host" : t.name;
|
|
1686
|
-
if (G(n, "Host name"), this.name = n, t.onError !== void 0 && typeof t.onError != "function") throw TypeError("Host onError must be a function");
|
|
1687
|
-
this.#e = c(t.logger === void 0 ? console : t.logger), this.#t = t.onError ?? ((e) => this.#e.error(e)), this.#n = A(t.shutdownTimeoutMilliseconds), this.#a = new xe((e) => this.#L(e));
|
|
1688
|
-
let r = /* @__PURE__ */ new Map(), i = u(t.groups === void 0 ? [] : t.groups, "Initial Groups"), a = u(t.installations === void 0 ? [] : t.installations, "Initial Installations"), o = /* @__PURE__ */ new Map();
|
|
1728
|
+
let t = E(e, "Host options", { fields: Dt }), n = t.name === void 0 ? "host" : t.name;
|
|
1729
|
+
if (X(n, "Host name"), this.name = n, t.onError !== void 0 && typeof t.onError != "function") throw TypeError("Host onError must be a function");
|
|
1730
|
+
this.#e = me(t.logger === void 0 ? console : t.logger), this.#t = t.onError ?? ((e) => this.#e.error(e)), this.#n = L(t.shutdownTimeoutMilliseconds), this.#a = new Ye((e) => this.#z(e));
|
|
1731
|
+
let r = /* @__PURE__ */ new Map(), i = s(t.groups === void 0 ? [] : t.groups, "Initial Groups"), a = s(t.installations === void 0 ? [] : t.installations, "Initial Installations"), o = /* @__PURE__ */ new Map();
|
|
1689
1732
|
for (let e of i) {
|
|
1690
|
-
let t =
|
|
1691
|
-
if (
|
|
1733
|
+
let t = E(e, "Initial Group", { fields: Ot });
|
|
1734
|
+
if (X(t.id, "Group id"), t.parentId !== void 0 && X(t.parentId, "Parent Group id"), o.has(t.id)) throw new D(_, "Duplicate initial Group: " + t.id);
|
|
1692
1735
|
o.set(t.id, t.parentId);
|
|
1693
1736
|
}
|
|
1694
|
-
let
|
|
1737
|
+
let c = bt(o, (e, t) => this.#N(e, t)), l = /* @__PURE__ */ new Set();
|
|
1695
1738
|
for (let e of a) {
|
|
1696
|
-
let t =
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
]) });
|
|
1703
|
-
G(t.id, "Installation id"), t.groupId !== void 0 && G(t.groupId, "Installation Group id"), V(d, t.id);
|
|
1704
|
-
let n = t.groupId === void 0 ? void 0 : s.get(t.groupId);
|
|
1705
|
-
if (t.groupId !== void 0 && !n) throw new l("GROUP_MISSING", "Initial Group is missing: " + t.groupId);
|
|
1706
|
-
let i = this.#O(t.id, n);
|
|
1707
|
-
r.set(i, H(t.plugin, t.configuration, t.origin));
|
|
1739
|
+
let t = E(e, "Initial Installation", { fields: kt });
|
|
1740
|
+
X(t.id, "Installation id"), t.groupId !== void 0 && X(t.groupId, "Installation Group id"), J(l, t.id);
|
|
1741
|
+
let n = t.groupId === void 0 ? void 0 : c.get(t.groupId);
|
|
1742
|
+
if (t.groupId !== void 0 && !n) throw new D(v, "Initial Group is missing: " + t.groupId);
|
|
1743
|
+
let i = this.#A(t.id, n);
|
|
1744
|
+
r.set(i, st(t.plugin, t.configuration, t.origin));
|
|
1708
1745
|
}
|
|
1709
1746
|
this.#f = Object.freeze({
|
|
1710
1747
|
revision: 0,
|
|
1711
|
-
groups:
|
|
1712
|
-
graph:
|
|
1748
|
+
groups: c,
|
|
1749
|
+
graph: mt.build(r),
|
|
1713
1750
|
configurations: /* @__PURE__ */ new Map(),
|
|
1714
1751
|
phase: "stopped",
|
|
1715
1752
|
instances: /* @__PURE__ */ new Map(),
|
|
1716
1753
|
unresolved: Object.freeze([]),
|
|
1717
1754
|
error: void 0
|
|
1718
|
-
}), this.#d = new
|
|
1719
|
-
for (let e of r.keys()) this.#
|
|
1755
|
+
}), this.#d = new oe(() => this.#L(), (e) => this.#z(e)), this.#r.commit(this.#f.graph.contractKinds);
|
|
1756
|
+
for (let e of r.keys()) this.#j(e);
|
|
1720
1757
|
Object.freeze(this);
|
|
1721
1758
|
}
|
|
1722
1759
|
get status() {
|
|
1723
|
-
return this.#p?.phase ?? this.#f.phase;
|
|
1760
|
+
return this.#D() ? "quarantined" : this.#p?.phase ?? this.#f.phase;
|
|
1724
1761
|
}
|
|
1725
1762
|
get stateRevision() {
|
|
1726
1763
|
return this.#f.revision;
|
|
@@ -1736,38 +1773,38 @@ var Ke = class {
|
|
|
1736
1773
|
}
|
|
1737
1774
|
explain(e) {
|
|
1738
1775
|
let { graph: t } = this.#f, n = t.byId.get(e);
|
|
1739
|
-
return
|
|
1776
|
+
return Q(t, n ? [n] : []);
|
|
1740
1777
|
}
|
|
1741
1778
|
change() {
|
|
1742
|
-
return this.#
|
|
1743
|
-
create: (e, t) => this.#
|
|
1744
|
-
resolve: (e) => this.#
|
|
1745
|
-
createGroup: (e, t) => this.#
|
|
1779
|
+
return this.#O(), this.#c.create({
|
|
1780
|
+
create: (e, t) => this.#A(e, t),
|
|
1781
|
+
resolve: (e) => this.#P(e),
|
|
1782
|
+
createGroup: (e, t) => this.#N(e, t),
|
|
1746
1783
|
resolveGroup: (e) => {
|
|
1747
1784
|
let t = this.#u.get(e);
|
|
1748
|
-
if (!t) throw new
|
|
1785
|
+
if (!t) throw new D(ye, "Group belongs to another Host");
|
|
1749
1786
|
return t;
|
|
1750
1787
|
}
|
|
1751
1788
|
});
|
|
1752
1789
|
}
|
|
1753
|
-
async plan(
|
|
1754
|
-
this.#
|
|
1755
|
-
let
|
|
1790
|
+
async plan(e, t) {
|
|
1791
|
+
this.#O();
|
|
1792
|
+
let n = this.#c.take(e), r = this.#s.validationSignal, i, a;
|
|
1756
1793
|
try {
|
|
1757
|
-
if (
|
|
1758
|
-
let
|
|
1759
|
-
|
|
1794
|
+
if (t !== void 0) {
|
|
1795
|
+
let e = new AbortController(), n = (t) => e.abort(t);
|
|
1796
|
+
a = o(r, n), i = o(t, n), r = e.signal, r.throwIfAborted();
|
|
1760
1797
|
}
|
|
1761
|
-
let
|
|
1762
|
-
return
|
|
1798
|
+
let e = await wt(this.#f, n, "change", this.#r, r);
|
|
1799
|
+
return r.throwIfAborted(), this.#r.assertKinds(e.graph.contractKinds), this.#s.issue(e, this.#f);
|
|
1763
1800
|
} catch (e) {
|
|
1764
|
-
throw this.#
|
|
1801
|
+
throw this.#F(n), e;
|
|
1765
1802
|
} finally {
|
|
1766
|
-
|
|
1803
|
+
a?.(), i?.();
|
|
1767
1804
|
}
|
|
1768
1805
|
}
|
|
1769
1806
|
apply(e) {
|
|
1770
|
-
return this.#p ? Promise.reject(this.#
|
|
1807
|
+
return this.#D() ? Promise.reject(a(this.#f.revision)) : this.#p ? Promise.reject(this.#k()) : this.#o.run(() => this.#_(e)).then(({ value: e }) => e);
|
|
1771
1808
|
}
|
|
1772
1809
|
start() {
|
|
1773
1810
|
return this.#g("start");
|
|
@@ -1778,48 +1815,49 @@ var Ke = class {
|
|
|
1778
1815
|
use(e, t) {
|
|
1779
1816
|
try {
|
|
1780
1817
|
if (typeof t != "function") throw TypeError("Service callback must be a function");
|
|
1781
|
-
let n =
|
|
1818
|
+
let n = De(e);
|
|
1782
1819
|
if (n.kind === "extensionPoint") throw TypeError("Expected a Service");
|
|
1783
1820
|
let r = n.kind === "optional" ? n.service : n;
|
|
1784
|
-
if (this.#r.assertCompatible(r), this.#
|
|
1821
|
+
if (this.#r.assertCompatible(r), this.#O(), this.#f.phase !== "running") throw new D(O, "Host is not running");
|
|
1785
1822
|
let i = this.#f.graph.providers.get(r.id);
|
|
1786
1823
|
if (!i) {
|
|
1787
|
-
if (n.kind === "optional") return
|
|
1788
|
-
throw new
|
|
1824
|
+
if (n.kind === "optional") return T(t(void 0));
|
|
1825
|
+
throw new D(O, "No provider for " + r.id);
|
|
1789
1826
|
}
|
|
1790
|
-
if (this.#p?.affected.has(i)) throw new
|
|
1827
|
+
if (this.#p?.affected.has(i)) throw new D(O, "Service is changing: " + r.id);
|
|
1791
1828
|
let a = this.#f.instances.get(i);
|
|
1792
|
-
if (!a) throw new
|
|
1829
|
+
if (!a) throw new D(O, "Service is not running: " + r.id);
|
|
1793
1830
|
return a.use(r.id, t);
|
|
1794
1831
|
} catch (e) {
|
|
1795
1832
|
return Promise.reject(e);
|
|
1796
1833
|
}
|
|
1797
1834
|
}
|
|
1798
1835
|
contributions(e) {
|
|
1799
|
-
let t =
|
|
1836
|
+
let t = M(e, "extensionPoint");
|
|
1800
1837
|
return this.#r.remember(t), this.#a.view(t);
|
|
1801
1838
|
}
|
|
1802
1839
|
#g(e) {
|
|
1803
|
-
return this.#p ? Promise.reject(this.#
|
|
1804
|
-
if (this.#
|
|
1840
|
+
return this.#D() ? Promise.reject(a(this.#f.revision)) : this.#p ? Promise.reject(this.#k()) : this.#o.run(async () => {
|
|
1841
|
+
if (this.#O(), e === "start" && this.#f.phase === "running" || e === "stop" && this.#f.phase === "stopped") return this.#E([]);
|
|
1805
1842
|
e === "start" && (this.#p = {
|
|
1806
1843
|
phase: "starting",
|
|
1807
|
-
affected: new Set(this.#f.graph.declarations.keys())
|
|
1808
|
-
|
|
1844
|
+
affected: new Set(this.#f.graph.declarations.keys()),
|
|
1845
|
+
scopes: []
|
|
1846
|
+
}, this.#R());
|
|
1809
1847
|
try {
|
|
1810
|
-
let t = await
|
|
1848
|
+
let t = await wt(this.#f, [], e, this.#r);
|
|
1811
1849
|
return await this.#_(this.#s.issue(t, this.#f));
|
|
1812
1850
|
} finally {
|
|
1813
|
-
this.#p && (this.#p = void 0, this.#
|
|
1851
|
+
this.#p && (this.#p = void 0, this.#R());
|
|
1814
1852
|
}
|
|
1815
|
-
});
|
|
1853
|
+
}).then(({ value: e }) => e);
|
|
1816
1854
|
}
|
|
1817
1855
|
async #_(e) {
|
|
1818
|
-
this.#
|
|
1856
|
+
this.#O();
|
|
1819
1857
|
let t = this.#s.read(e, this.#f.revision);
|
|
1820
|
-
if (t.report.intent === "change" && t.report.operations.length === 0) return this.#s.consume(e), this.#
|
|
1858
|
+
if (t.report.intent === "change" && t.report.operations.length === 0) return this.#s.consume(e), this.#E([]);
|
|
1821
1859
|
let n = this.#f, r = n.graph.order.filter((e) => t.affected.has(e)).flatMap((e) => n.instances.get(e) ?? []);
|
|
1822
|
-
for (let e of r) if (e.lifetime.busy) throw new
|
|
1860
|
+
for (let e of r) if (e.lifetime.busy) throw new D(ne, "Affected work is still in flight", { details: {
|
|
1823
1861
|
outcome: "rejected",
|
|
1824
1862
|
installation: e.installation.id,
|
|
1825
1863
|
stateRevision: n.revision
|
|
@@ -1829,125 +1867,127 @@ var Ke = class {
|
|
|
1829
1867
|
try {
|
|
1830
1868
|
i = this.#r.writer(t.graph.contractKinds);
|
|
1831
1869
|
} catch (e) {
|
|
1832
|
-
throw this.#
|
|
1870
|
+
throw this.#M(t.graph.declarations.keys()), e;
|
|
1833
1871
|
}
|
|
1834
1872
|
for (let e of r) e.lifetime.seal();
|
|
1835
|
-
this.#p
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1873
|
+
let a = this.#p;
|
|
1874
|
+
this.#p = a ?? {
|
|
1875
|
+
phase: t.report.intent === "stop" ? "stopping" : "changing",
|
|
1876
|
+
affected: t.affected,
|
|
1877
|
+
scopes: []
|
|
1878
|
+
}, this.#p.scopes.push(n), this.#a.beginBatch(), a || this.#R();
|
|
1839
1879
|
try {
|
|
1840
|
-
if (n.phase === "stopped" && t.report.intent !== "start") return i.commit(), this.#b(t, /* @__PURE__ */ new Map(), "stopped"), this.#
|
|
1841
|
-
let e = await this.#
|
|
1842
|
-
if (e.length || r.some((e) => e.lifetime.phase !== "disposed")) throw i.discard(), await this.#
|
|
1843
|
-
if (t.report.intent === "stop") return i.commit(), this.#b(t, /* @__PURE__ */ new Map(), "stopped"), this.#
|
|
1880
|
+
if (n.phase === "stopped" && t.report.intent !== "start") return i.commit(), this.#b(t, /* @__PURE__ */ new Map(), "stopped"), this.#E(t.report.affectedInstallations);
|
|
1881
|
+
let e = await this.#w([n], new Set(r));
|
|
1882
|
+
if (this.#D() || e.length || r.some((e) => e.lifetime.phase !== "disposed")) throw i.discard(), await this.#C(n, e, t, "stop");
|
|
1883
|
+
if (t.report.intent === "stop") return i.commit(), this.#b(t, /* @__PURE__ */ new Map(), "stopped"), this.#E(t.report.affectedInstallations);
|
|
1844
1884
|
let a = new Map(n.instances);
|
|
1845
1885
|
for (let e of t.affected) a.delete(e);
|
|
1846
|
-
let o =
|
|
1886
|
+
let o = new Map(a), s = {
|
|
1887
|
+
graph: t.graph,
|
|
1888
|
+
instances: o
|
|
1889
|
+
};
|
|
1890
|
+
this.#p.scopes.push(s);
|
|
1891
|
+
let c = new At((e) => this.#z(e));
|
|
1847
1892
|
try {
|
|
1848
|
-
await this.#v(t,
|
|
1849
|
-
for (let e of o.values()) AbortSignal.prototype.throwIfAborted.call(e.lifetime.signal);
|
|
1850
|
-
i.commit(), s.seal();
|
|
1893
|
+
await this.#v(t, o, i, c), i.commit(), c.seal();
|
|
1851
1894
|
} catch (e) {
|
|
1852
1895
|
i.discard();
|
|
1853
|
-
let r =
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
throw c.length || [...o.values()].some((e) => e.lifetime.phase !== "disposed") ? await this.#S(n, [r], [l, ...c], t, "prepare") : n.phase === "stopped" ? (this.#x({
|
|
1896
|
+
let r = c.seal(e);
|
|
1897
|
+
if (this.#D()) throw await this.#C(n, [r], t, "prepare");
|
|
1898
|
+
let l = new Set([...o.values()].filter((e) => t.affected.has(e.installation))), u = await this.#w([s], l);
|
|
1899
|
+
throw this.#D() || u.length || [...l].some((e) => e.lifetime.phase !== "disposed") ? await this.#C(n, [r, ...u], t, "prepare") : n.phase === "stopped" ? (this.#x({
|
|
1858
1900
|
...n,
|
|
1859
|
-
error: new
|
|
1860
|
-
}), this.#
|
|
1901
|
+
error: new b(r).snapshot
|
|
1902
|
+
}), this.#T("Startup failed", r, "restored", t.report.affectedInstallations, "prepare")) : (await this.#y(n, a, t, r), this.#T("Change failed; previous declarations were restored", r, "restored", t.report.affectedInstallations, "prepare"));
|
|
1861
1903
|
}
|
|
1862
|
-
for (let [e, t] of o) a.set(e, t);
|
|
1863
1904
|
try {
|
|
1864
|
-
this.#b(t,
|
|
1905
|
+
this.#b(t, o, "running");
|
|
1865
1906
|
} catch (e) {
|
|
1866
|
-
throw i.discard(), await this.#
|
|
1867
|
-
graph: t.graph,
|
|
1868
|
-
instances: new Map(a)
|
|
1869
|
-
}], [e], t, "publish");
|
|
1907
|
+
throw i.discard(), await this.#C(this.#f, [e], t, "publish");
|
|
1870
1908
|
}
|
|
1871
|
-
return this.#
|
|
1909
|
+
return this.#E(t.report.affectedInstallations);
|
|
1872
1910
|
} finally {
|
|
1873
|
-
this.#p = void 0, this.#
|
|
1874
|
-
this.#a.endBatch(), this.#
|
|
1911
|
+
this.#p = void 0, this.#M(t.graph.declarations.keys()), w(() => {
|
|
1912
|
+
this.#a.endBatch(), this.#R();
|
|
1875
1913
|
});
|
|
1876
1914
|
}
|
|
1877
1915
|
}
|
|
1878
|
-
async #v(e, t, n,
|
|
1916
|
+
async #v(e, t, n, i) {
|
|
1879
1917
|
let a = new AbortController(), o = ++this.#h;
|
|
1880
1918
|
for (let s of e.graph.layers) {
|
|
1881
|
-
|
|
1882
|
-
|
|
1919
|
+
this.#O();
|
|
1920
|
+
let c = s.filter((t) => e.affected.has(t)).map((r) => {
|
|
1921
|
+
let i = new Et(r, e.graph.declarationFor(r), o, {
|
|
1883
1922
|
hostName: this.name,
|
|
1884
1923
|
logger: this.#e,
|
|
1885
|
-
report: (e) => this.#
|
|
1924
|
+
report: (e) => this.#z(e),
|
|
1925
|
+
releaseFailed: (e) => this.#S(i, e),
|
|
1886
1926
|
changed: () => {
|
|
1887
|
-
(this.#f.instances.get(
|
|
1927
|
+
(this.#f.instances.get(r) === i || this.#f.unresolved.includes(i)) && this.#R();
|
|
1888
1928
|
},
|
|
1889
1929
|
events: this.#i,
|
|
1890
1930
|
contributions: this.#a,
|
|
1891
|
-
contracts:
|
|
1931
|
+
contracts: n,
|
|
1892
1932
|
startupSignal: a.signal,
|
|
1893
1933
|
shutdownTimeoutMilliseconds: this.#n
|
|
1894
1934
|
});
|
|
1895
|
-
return
|
|
1935
|
+
return t.set(r, i), i;
|
|
1896
1936
|
});
|
|
1897
1937
|
try {
|
|
1898
|
-
await Promise.all(c.map(async (
|
|
1899
|
-
let o = Object.create(null);
|
|
1900
|
-
for (let [
|
|
1901
|
-
if (
|
|
1902
|
-
|
|
1938
|
+
await Promise.all(c.map(async (n) => {
|
|
1939
|
+
let o = n.lifetime.signal, s = Object.create(null);
|
|
1940
|
+
for (let [r, i] of Object.entries(n.declaration.plugin.requires)) {
|
|
1941
|
+
if (i.kind === "extensionPoint") {
|
|
1942
|
+
s[r] = this.#a.view(i, n.lifetime);
|
|
1903
1943
|
continue;
|
|
1904
1944
|
}
|
|
1905
|
-
let
|
|
1906
|
-
|
|
1945
|
+
let a = i.kind === "optional" ? i.service : i, o = e.graph.providers.get(a.id);
|
|
1946
|
+
s[r] = o ? t.get(o)?.read(a.id) : void 0;
|
|
1907
1947
|
}
|
|
1908
1948
|
try {
|
|
1909
|
-
await
|
|
1949
|
+
await n.prepare(Object.freeze(s), e.configurations.get(n.installation)?.value);
|
|
1910
1950
|
} catch (e) {
|
|
1911
|
-
throw
|
|
1951
|
+
throw r(o, e) || i.add(e), a.abort(e), e;
|
|
1912
1952
|
}
|
|
1913
|
-
}));
|
|
1953
|
+
})), this.#O();
|
|
1954
|
+
for (let e of c) AbortSignal.prototype.throwIfAborted.call(e.lifetime.signal);
|
|
1914
1955
|
} catch (e) {
|
|
1915
1956
|
throw a.abort(e), e;
|
|
1916
1957
|
}
|
|
1917
1958
|
}
|
|
1918
1959
|
}
|
|
1919
1960
|
async #y(e, t, n, r) {
|
|
1920
|
-
|
|
1961
|
+
this.#O();
|
|
1962
|
+
let i = new Map(t), a = {
|
|
1963
|
+
graph: e.graph,
|
|
1964
|
+
instances: i
|
|
1965
|
+
};
|
|
1966
|
+
this.#p.scopes.push(a);
|
|
1967
|
+
let o = new At((e) => this.#z(e)), s = this.#r.writer(e.graph.contractKinds);
|
|
1921
1968
|
try {
|
|
1922
1969
|
await this.#v({
|
|
1923
1970
|
graph: e.graph,
|
|
1924
1971
|
affected: n.affected,
|
|
1925
1972
|
configurations: e.configurations
|
|
1926
|
-
},
|
|
1927
|
-
for (let e of i.values()) AbortSignal.prototype.throwIfAborted.call(e.lifetime.signal);
|
|
1928
|
-
a.seal();
|
|
1929
|
-
for (let [e, n] of i) t.set(e, n);
|
|
1930
|
-
o.commit(), this.#x({
|
|
1973
|
+
}, i, s, o), o.seal(), s.commit(), this.#x({
|
|
1931
1974
|
...e,
|
|
1932
|
-
instances:
|
|
1933
|
-
error: new
|
|
1975
|
+
instances: i,
|
|
1976
|
+
error: new b(r).snapshot
|
|
1934
1977
|
});
|
|
1935
|
-
for (let e of i.
|
|
1936
|
-
} catch (
|
|
1937
|
-
|
|
1938
|
-
let c =
|
|
1939
|
-
|
|
1940
|
-
instances: new Map([...t, ...i])
|
|
1941
|
-
}, l = await this.#C([c], new Set(i.values()));
|
|
1942
|
-
throw await this.#S(e, [c], [
|
|
1978
|
+
for (let [e, t] of i) n.affected.has(e) && t.publish(), this.#O();
|
|
1979
|
+
} catch (t) {
|
|
1980
|
+
s.discard();
|
|
1981
|
+
let c = this.#D() ? [] : await this.#w([a], new Set([...i.values()].filter((e) => n.affected.has(e.installation))));
|
|
1982
|
+
throw await this.#C(e, [
|
|
1943
1983
|
r,
|
|
1944
|
-
|
|
1945
|
-
...
|
|
1984
|
+
o.seal(t),
|
|
1985
|
+
...c
|
|
1946
1986
|
], n, "restore");
|
|
1947
1987
|
}
|
|
1948
1988
|
}
|
|
1949
|
-
#b(e, t, n
|
|
1950
|
-
let
|
|
1989
|
+
#b(e, t, n) {
|
|
1990
|
+
let r = this.#f;
|
|
1951
1991
|
this.#x({
|
|
1952
1992
|
groups: e.groups,
|
|
1953
1993
|
graph: e.graph,
|
|
@@ -1956,16 +1996,16 @@ var Ke = class {
|
|
|
1956
1996
|
instances: t,
|
|
1957
1997
|
unresolved: Object.freeze([]),
|
|
1958
1998
|
error: void 0
|
|
1959
|
-
});
|
|
1960
|
-
for (let t of e.graph.declarations.keys())
|
|
1961
|
-
for (let t of
|
|
1999
|
+
}), this.#O();
|
|
2000
|
+
for (let t of e.graph.declarations.keys()) r.graph.declarations.has(t) || this.#j(t);
|
|
2001
|
+
for (let t of r.graph.declarations.keys()) e.graph.declarations.has(t) || t.detach({
|
|
1962
2002
|
status: "removed",
|
|
1963
2003
|
origin: void 0
|
|
1964
2004
|
});
|
|
1965
|
-
for (let
|
|
2005
|
+
for (let [n, r] of t) e.affected.has(n) && r.publish(), this.#O();
|
|
1966
2006
|
}
|
|
1967
2007
|
#x(e) {
|
|
1968
|
-
this.#f = Object.freeze({
|
|
2008
|
+
this.#O(), this.#f = Object.freeze({
|
|
1969
2009
|
...e,
|
|
1970
2010
|
revision: this.#f.revision + 1
|
|
1971
2011
|
});
|
|
@@ -1978,23 +2018,44 @@ var Ke = class {
|
|
|
1978
2018
|
});
|
|
1979
2019
|
}
|
|
1980
2020
|
}
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
2021
|
+
#S(e, t) {
|
|
2022
|
+
if (this.#D()) return;
|
|
2023
|
+
let n = e.lifetime;
|
|
2024
|
+
if ((t.kind !== "shutdown" || t.owner === n) && n.phase !== "active" && n.phase !== "sealed") return;
|
|
2025
|
+
let r = e.installation;
|
|
2026
|
+
(this.#f.instances.get(r) === e || this.#p?.scopes.some((t) => t.instances.get(r) === e)) && this.#C(this.#f, [t.error], void 0, "release").then((e) => this.#z(e), (e) => this.#z(e));
|
|
2027
|
+
}
|
|
2028
|
+
#C(e, t, n, r) {
|
|
2029
|
+
if (this.#m || this.#D()) {
|
|
2030
|
+
let e = this.#m ?? Promise.resolve(a(this.#f.revision));
|
|
2031
|
+
return t.length ? e.then((e) => this.#T("Operation failed while Host was quarantined", AggregateError([...t, e], "Execution failed during quarantine"), "quarantined", n?.report.affectedInstallations ?? [], r)) : e;
|
|
2032
|
+
}
|
|
2033
|
+
let i = [e, ...this.#p?.scopes ?? []], o = [...new Set(i.flatMap((e) => [...e.instances.values()]))].filter((e) => e.lifetime.phase !== "disposed"), s = n?.report.affectedInstallations ?? [...new Set(o.map((e) => e.installation.id))], c = "Execution could not establish a healthy state", l = Promise.resolve().then(async () => {
|
|
2034
|
+
let e = await this.#w(i, new Set(o)), n = AggregateError([...t, ...e], c);
|
|
2035
|
+
return this.#f = Object.freeze({
|
|
2036
|
+
...this.#f,
|
|
2037
|
+
unresolved: Object.freeze(o.filter((e) => e.lifetime.phase !== "disposed")),
|
|
2038
|
+
error: new b(n).snapshot
|
|
2039
|
+
}), this.#R(), this.#T("Host is quarantined after execution could not establish a healthy state", n, "quarantined", s, r);
|
|
2040
|
+
});
|
|
2041
|
+
this.#m = l;
|
|
2042
|
+
let u = () => {
|
|
2043
|
+
this.#m = void 0;
|
|
1987
2044
|
};
|
|
1988
|
-
|
|
2045
|
+
l.then(u, u);
|
|
2046
|
+
for (let e of o) e.lifetime.block();
|
|
1989
2047
|
return this.#x({
|
|
1990
2048
|
...e,
|
|
1991
2049
|
phase: "quarantined",
|
|
1992
2050
|
instances: /* @__PURE__ */ new Map(),
|
|
1993
|
-
unresolved: Object.freeze(
|
|
1994
|
-
error:
|
|
1995
|
-
}), this.#
|
|
2051
|
+
unresolved: Object.freeze(o),
|
|
2052
|
+
error: void 0
|
|
2053
|
+
}), this.#R(), this.#f = Object.freeze({
|
|
2054
|
+
...this.#f,
|
|
2055
|
+
error: new b(AggregateError(t, c)).snapshot
|
|
2056
|
+
}), this.#R(), l;
|
|
1996
2057
|
}
|
|
1997
|
-
async #
|
|
2058
|
+
async #w(e, t) {
|
|
1998
2059
|
let n = /* @__PURE__ */ new Map();
|
|
1999
2060
|
for (let { graph: t, instances: r } of e) for (let [e, i] of t.dependents) {
|
|
2000
2061
|
let t = r.get(e);
|
|
@@ -2013,71 +2074,74 @@ var Ke = class {
|
|
|
2013
2074
|
}));
|
|
2014
2075
|
return (await Promise.allSettled(r.values())).flatMap((e) => e.status === "rejected" ? [e.reason] : []);
|
|
2015
2076
|
}
|
|
2016
|
-
#
|
|
2017
|
-
return new
|
|
2018
|
-
cause:
|
|
2077
|
+
#T(e, t, r, i, a) {
|
|
2078
|
+
return new D(r === "restored" ? ae : n, e, {
|
|
2079
|
+
cause: t,
|
|
2019
2080
|
details: {
|
|
2020
2081
|
outcome: r,
|
|
2021
2082
|
phase: a,
|
|
2022
2083
|
stateRevision: this.#f.revision,
|
|
2023
|
-
affectedInstallations: i
|
|
2084
|
+
affectedInstallations: i
|
|
2024
2085
|
}
|
|
2025
2086
|
});
|
|
2026
2087
|
}
|
|
2027
|
-
#
|
|
2088
|
+
#E(e) {
|
|
2028
2089
|
return Object.freeze({
|
|
2029
2090
|
stateRevision: this.#f.revision,
|
|
2030
2091
|
affectedInstallations: Object.freeze([...e])
|
|
2031
2092
|
});
|
|
2032
2093
|
}
|
|
2033
|
-
#E() {
|
|
2034
|
-
if (this.#f.phase === "quarantined") throw p(this.#f.revision);
|
|
2035
|
-
}
|
|
2036
2094
|
#D() {
|
|
2037
|
-
return
|
|
2095
|
+
return this.#f.phase === "quarantined";
|
|
2096
|
+
}
|
|
2097
|
+
#O() {
|
|
2098
|
+
if (this.#D()) throw a(this.#f.revision);
|
|
2099
|
+
}
|
|
2100
|
+
#k() {
|
|
2101
|
+
return new D(ne, "Another Host transition is in progress", { details: {
|
|
2038
2102
|
outcome: "rejected",
|
|
2039
2103
|
stateRevision: this.#f.revision
|
|
2040
2104
|
} });
|
|
2041
2105
|
}
|
|
2042
|
-
#
|
|
2043
|
-
let n = new
|
|
2106
|
+
#A(e, t) {
|
|
2107
|
+
let n = new lt(e, t);
|
|
2044
2108
|
return this.#l.set(n.facade, n), n;
|
|
2045
2109
|
}
|
|
2046
|
-
#
|
|
2110
|
+
#j(e) {
|
|
2047
2111
|
e.attach(() => ({
|
|
2048
|
-
status: this.#
|
|
2112
|
+
status: this.#I(e),
|
|
2049
2113
|
origin: this.#f.graph.declarations.get(e)?.origin
|
|
2050
2114
|
}));
|
|
2051
2115
|
}
|
|
2052
|
-
#
|
|
2116
|
+
#M(e) {
|
|
2053
2117
|
for (let t of e) this.#f.graph.declarations.has(t) || t.detach({
|
|
2054
2118
|
status: "removed",
|
|
2055
2119
|
origin: void 0
|
|
2056
2120
|
});
|
|
2057
2121
|
}
|
|
2058
|
-
#
|
|
2059
|
-
let n = new
|
|
2122
|
+
#N(e, t) {
|
|
2123
|
+
let n = new yt(e, t);
|
|
2060
2124
|
return this.#u.set(n.facade, n), n;
|
|
2061
2125
|
}
|
|
2062
|
-
#
|
|
2126
|
+
#P(e) {
|
|
2063
2127
|
let t = this.#l.get(e);
|
|
2064
|
-
if (!t) throw new
|
|
2128
|
+
if (!t) throw new D(re, "Installation belongs to another Host");
|
|
2065
2129
|
return t;
|
|
2066
2130
|
}
|
|
2067
|
-
#
|
|
2068
|
-
this.#
|
|
2131
|
+
#F(e) {
|
|
2132
|
+
this.#M(e.flatMap((e) => e.kind === "install" ? [e.installation] : []));
|
|
2069
2133
|
}
|
|
2070
|
-
#
|
|
2071
|
-
return this.#f.graph.declarations.has(e) ? this.#
|
|
2134
|
+
#I(e) {
|
|
2135
|
+
return this.#f.graph.declarations.has(e) ? this.#D() ? "quarantined" : this.#p?.affected.has(e) ? "changing" : this.#f.instances.has(e) ? "running" : "stopped" : "pending";
|
|
2072
2136
|
}
|
|
2073
|
-
#
|
|
2137
|
+
#L() {
|
|
2074
2138
|
let e = [...this.#f.graph.declarations].map(([e, t]) => {
|
|
2075
2139
|
let n = this.#f.instances.get(e);
|
|
2076
2140
|
return Object.freeze({
|
|
2077
2141
|
id: e.id,
|
|
2078
2142
|
groupId: e.groupId,
|
|
2079
2143
|
pluginName: t.plugin.name,
|
|
2080
|
-
status: this.#
|
|
2144
|
+
status: this.#I(e),
|
|
2081
2145
|
origin: t.origin,
|
|
2082
2146
|
generation: n?.generation,
|
|
2083
2147
|
requires: Object.freeze(Object.values(t.plugin.requires).map((e) => e.kind === "optional" ? e.service.id : e.id)),
|
|
@@ -2095,7 +2159,7 @@ var Ke = class {
|
|
|
2095
2159
|
parentId: e.parentId,
|
|
2096
2160
|
installations: Object.freeze((t.get(e.id) ?? []).map((e) => e.id))
|
|
2097
2161
|
}))),
|
|
2098
|
-
bindings:
|
|
2162
|
+
bindings: Q(this.#f.graph),
|
|
2099
2163
|
unresolved: Object.freeze(this.#f.unresolved.map((e) => Object.freeze({
|
|
2100
2164
|
installation: e.installation.id,
|
|
2101
2165
|
generation: e.generation,
|
|
@@ -2104,7 +2168,7 @@ var Ke = class {
|
|
|
2104
2168
|
error: this.#f.error
|
|
2105
2169
|
});
|
|
2106
2170
|
}
|
|
2107
|
-
#
|
|
2171
|
+
#R() {
|
|
2108
2172
|
this.#f.unresolved.some((e) => e.lifetime.phase === "disposed") && (this.#f = Object.freeze({
|
|
2109
2173
|
...this.#f,
|
|
2110
2174
|
unresolved: Object.freeze(this.#f.unresolved.filter((e) => e.lifetime.phase !== "disposed"))
|
|
@@ -2112,26 +2176,26 @@ var Ke = class {
|
|
|
2112
2176
|
try {
|
|
2113
2177
|
this.#d.invalidate();
|
|
2114
2178
|
} catch (e) {
|
|
2115
|
-
this.#
|
|
2179
|
+
this.#z(e);
|
|
2116
2180
|
}
|
|
2117
2181
|
}
|
|
2118
|
-
#
|
|
2182
|
+
#z(e) {
|
|
2119
2183
|
let t = this.#e, n = (n) => {
|
|
2120
2184
|
try {
|
|
2121
|
-
|
|
2185
|
+
T(t.error(AggregateError([e, n], "Host error reporter failed"))).catch(() => void 0);
|
|
2122
2186
|
} catch {}
|
|
2123
2187
|
};
|
|
2124
2188
|
try {
|
|
2125
2189
|
let t = this.#t;
|
|
2126
|
-
|
|
2190
|
+
T(t(e)).catch(n);
|
|
2127
2191
|
} catch (e) {
|
|
2128
2192
|
n(e);
|
|
2129
2193
|
}
|
|
2130
2194
|
}
|
|
2131
2195
|
};
|
|
2132
2196
|
// src/execution/host.ts
|
|
2133
|
-
function
|
|
2134
|
-
let t = new
|
|
2197
|
+
function Mt(e) {
|
|
2198
|
+
let t = new jt(e);
|
|
2135
2199
|
return Object.freeze({
|
|
2136
2200
|
get name() {
|
|
2137
2201
|
return t.name;
|
|
@@ -2155,17 +2219,17 @@ function Je(e) {
|
|
|
2155
2219
|
installation: t.installation.bind(t),
|
|
2156
2220
|
group: t.group.bind(t),
|
|
2157
2221
|
explain: t.explain.bind(t),
|
|
2158
|
-
[
|
|
2222
|
+
[l]: async () => {
|
|
2159
2223
|
await t.stop();
|
|
2160
2224
|
}
|
|
2161
2225
|
});
|
|
2162
2226
|
}
|
|
2163
2227
|
// src/composition/plugin-description.ts
|
|
2164
|
-
var
|
|
2165
|
-
function
|
|
2166
|
-
let n =
|
|
2228
|
+
var Nt = y()("jsonSchemaTarget");
|
|
2229
|
+
function Pt(e, t = {}) {
|
|
2230
|
+
let n = E(t, "Plugin description options", { fields: Nt }), r = n.jsonSchemaTarget === void 0 ? "draft-2020-12" : n.jsonSchemaTarget;
|
|
2167
2231
|
if (typeof r != "string" || !r || r.trim() !== r) throw TypeError("JSON Schema target must be a non-empty trimmed string");
|
|
2168
|
-
let i =
|
|
2232
|
+
let i = q(e), a = i.configuration?.["~standard"], o;
|
|
2169
2233
|
if (!a) o = Object.freeze({ status: "none" });
|
|
2170
2234
|
else if (!a.jsonSchema) o = Object.freeze({
|
|
2171
2235
|
status: "unavailable",
|
|
@@ -2177,8 +2241,8 @@ function Q(e, t = {}) {
|
|
|
2177
2241
|
status: "available",
|
|
2178
2242
|
vendor: a.vendor,
|
|
2179
2243
|
target: r,
|
|
2180
|
-
input:
|
|
2181
|
-
output:
|
|
2244
|
+
input: Ft(a.jsonSchema.input(e)),
|
|
2245
|
+
output: Ft(a.jsonSchema.output(e))
|
|
2182
2246
|
});
|
|
2183
2247
|
}
|
|
2184
2248
|
return Object.freeze({
|
|
@@ -2199,10 +2263,10 @@ function Q(e, t = {}) {
|
|
|
2199
2263
|
configuration: o
|
|
2200
2264
|
});
|
|
2201
2265
|
}
|
|
2202
|
-
function
|
|
2203
|
-
|
|
2204
|
-
let t =
|
|
2266
|
+
function Ft(e) {
|
|
2267
|
+
u(e, "JSON Schema exporters must be synchronous");
|
|
2268
|
+
let t = H(e);
|
|
2205
2269
|
if (typeof t != "object" || !t || Array.isArray(t)) throw TypeError("JSON Schema exporters must return a plain data record");
|
|
2206
2270
|
return t;
|
|
2207
2271
|
}
|
|
2208
|
-
export {
|
|
2272
|
+
export { C as ConfigurationValidationError, D as DougongError, b as RecordedFailure, l as asyncDisposeSymbol, H as captureConfiguration, Mt as createHost, rt as definePlugin, Pt as describePlugin, g as disposeSymbol, we as event, Te as extensionPoint, r as isCancellationReason, m as isError, ce as isLogger, Ee as optional, Ce as service };
|