@dougongjs/core 0.1.0 → 0.2.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 +2 -2
- package/dist/change-set.d.ts +2 -2
- package/dist/change-set.d.ts.map +1 -1
- package/dist/contracts.d.ts +1 -0
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contribution-store.d.ts +6 -3
- package/dist/contribution-store.d.ts.map +1 -1
- package/dist/engine.d.ts +3 -2
- package/dist/engine.d.ts.map +1 -1
- package/dist/event-hub.d.ts.map +1 -1
- package/dist/host-api.d.ts +12 -9
- package/dist/host-api.d.ts.map +1 -1
- package/dist/host.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +554 -490
- package/dist/lifetime.d.ts +13 -9
- package/dist/lifetime.d.ts.map +1 -1
- package/dist/plugin.d.ts +15 -3
- package/dist/plugin.d.ts.map +1 -1
- package/dist/resource.d.ts +8 -0
- package/dist/resource.d.ts.map +1 -1
- package/dist/runtime.d.ts +3 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/snapshot-view.d.ts +2 -2
- package/dist/snapshot-view.d.ts.map +1 -1
- package/package.json +7 -1
package/dist/index.js
CHANGED
|
@@ -1,38 +1,43 @@
|
|
|
1
|
-
function
|
|
1
|
+
function rt(r, t) {
|
|
2
2
|
if (typeof t != "string" || !t.trim())
|
|
3
3
|
throw new TypeError(`${r} id must be a non-empty string`);
|
|
4
4
|
if (t !== t.trim())
|
|
5
5
|
throw new TypeError(`${r} id cannot start or end with whitespace`);
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
return
|
|
7
|
+
function V(r, t) {
|
|
8
|
+
return rt("Contract", t), Object.freeze({ id: t, kind: r });
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function v(r, t) {
|
|
11
11
|
if (!r || typeof r != "object") return !1;
|
|
12
12
|
const e = r;
|
|
13
13
|
return typeof e.id == "string" && e.id.length > 0 && e.id === e.id.trim() && (e.kind === "service" || e.kind === "extensionPoint" || e.kind === "event") && (t === void 0 || e.kind === t);
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
if (!
|
|
17
|
-
throw new TypeError(t ? `Expected ${
|
|
15
|
+
function b(r, t) {
|
|
16
|
+
if (!v(r, t))
|
|
17
|
+
throw new TypeError(t ? `Expected ${nt(t)}` : "Invalid contract");
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function nt(r) {
|
|
20
20
|
return r === "extensionPoint" ? "an ExtensionPoint" : r === "event" ? "an Event" : "a Service";
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
return
|
|
22
|
+
function de(r) {
|
|
23
|
+
return V("service", r);
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
return
|
|
25
|
+
function le(r) {
|
|
26
|
+
return V("event", r);
|
|
27
27
|
}
|
|
28
|
-
function
|
|
29
|
-
return
|
|
28
|
+
function ue(r) {
|
|
29
|
+
return V("extensionPoint", r);
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
if (!
|
|
31
|
+
function fe(r) {
|
|
32
|
+
if (!v(r, "service"))
|
|
33
33
|
throw new TypeError("optional() expects a Service");
|
|
34
34
|
return Object.freeze({ kind: "optional", service: r });
|
|
35
35
|
}
|
|
36
|
+
function ot(r) {
|
|
37
|
+
if (!r || typeof r != "object") return !1;
|
|
38
|
+
const t = r;
|
|
39
|
+
return t.kind === "optional" && v(t.service, "service");
|
|
40
|
+
}
|
|
36
41
|
class u extends Error {
|
|
37
42
|
constructor(t, e, i) {
|
|
38
43
|
super(e, i), this.code = t;
|
|
@@ -40,21 +45,21 @@ class u extends Error {
|
|
|
40
45
|
code;
|
|
41
46
|
name = "DougongError";
|
|
42
47
|
}
|
|
43
|
-
class
|
|
48
|
+
class P extends u {
|
|
44
49
|
}
|
|
45
|
-
function
|
|
46
|
-
return r instanceof
|
|
50
|
+
function $(r, t, e) {
|
|
51
|
+
return r instanceof P ? r.code === t ? r : new P(t, e, { cause: r.cause }) : r instanceof Error ? r : new P(t, e, { cause: r });
|
|
47
52
|
}
|
|
48
|
-
function
|
|
53
|
+
function J(r, t) {
|
|
49
54
|
if (!r || typeof r != "object" || typeof r.aborted != "boolean" || typeof r.addEventListener != "function" || typeof r.removeEventListener != "function" || typeof r.throwIfAborted != "function")
|
|
50
55
|
throw new TypeError("Cancellation classifier expects an AbortSignal");
|
|
51
56
|
return r.aborted ? Object.is(t, r.reason) ? !0 : t instanceof Error && t.name === "AbortError" : !1;
|
|
52
57
|
}
|
|
53
|
-
class
|
|
58
|
+
class at extends u {
|
|
54
59
|
name = "ConfigValidationError";
|
|
55
60
|
issues;
|
|
56
61
|
constructor(t) {
|
|
57
|
-
const e =
|
|
62
|
+
const e = ct(t);
|
|
58
63
|
super(
|
|
59
64
|
"CONFIG_INVALID",
|
|
60
65
|
`Invalid Plugin config:
|
|
@@ -63,7 +68,7 @@ ${e.map((i) => ` - ${i.message}`).join(`
|
|
|
63
68
|
), this.issues = e;
|
|
64
69
|
}
|
|
65
70
|
}
|
|
66
|
-
function
|
|
71
|
+
function ct(r) {
|
|
67
72
|
if (!Array.isArray(r))
|
|
68
73
|
throw new TypeError("Config validation issues must be an array");
|
|
69
74
|
return Object.freeze(
|
|
@@ -75,23 +80,23 @@ function st(r) {
|
|
|
75
80
|
throw new TypeError(`Config validation issue at index ${e} message must be a string`);
|
|
76
81
|
return Object.freeze({
|
|
77
82
|
message: i.message,
|
|
78
|
-
...i.path === void 0 ? {} : { path:
|
|
83
|
+
...i.path === void 0 ? {} : { path: ht(i.path, e) }
|
|
79
84
|
});
|
|
80
85
|
})
|
|
81
86
|
);
|
|
82
87
|
}
|
|
83
|
-
function
|
|
88
|
+
function ht(r, t) {
|
|
84
89
|
if (!Array.isArray(r))
|
|
85
90
|
throw new TypeError(`Config validation issue at index ${t} path must be an array`);
|
|
86
91
|
return Object.freeze(
|
|
87
92
|
Array.from(r, (e, i) => {
|
|
88
|
-
if (
|
|
93
|
+
if (G(e)) return e;
|
|
89
94
|
if (!e || typeof e != "object")
|
|
90
95
|
throw new TypeError(
|
|
91
96
|
`Config validation issue at index ${t} path segment ${i} must be a property key`
|
|
92
97
|
);
|
|
93
98
|
const s = e.key;
|
|
94
|
-
if (!
|
|
99
|
+
if (!G(s))
|
|
95
100
|
throw new TypeError(
|
|
96
101
|
`Config validation issue at index ${t} path segment ${i} must contain a property key`
|
|
97
102
|
);
|
|
@@ -99,10 +104,10 @@ function rt(r, t) {
|
|
|
99
104
|
})
|
|
100
105
|
);
|
|
101
106
|
}
|
|
102
|
-
function
|
|
107
|
+
function G(r) {
|
|
103
108
|
return typeof r == "string" || typeof r == "number" || typeof r == "symbol";
|
|
104
109
|
}
|
|
105
|
-
async function
|
|
110
|
+
async function X(r, t, e) {
|
|
106
111
|
if (!r) return t;
|
|
107
112
|
const i = await r["~standard"].validate(t);
|
|
108
113
|
if (!i || typeof i != "object")
|
|
@@ -111,7 +116,7 @@ async function Q(r, t, e) {
|
|
|
111
116
|
);
|
|
112
117
|
const s = Object.hasOwn(i, "issues") ? i.issues : void 0;
|
|
113
118
|
if (s !== void 0)
|
|
114
|
-
throw Array.isArray(s) ? new
|
|
119
|
+
throw Array.isArray(s) ? new at(s) : new TypeError(
|
|
115
120
|
`Installation '${e}' config validator returned non-array issues`
|
|
116
121
|
);
|
|
117
122
|
if (!Object.hasOwn(i, "value"))
|
|
@@ -120,26 +125,26 @@ async function Q(r, t, e) {
|
|
|
120
125
|
);
|
|
121
126
|
return i.value;
|
|
122
127
|
}
|
|
123
|
-
class
|
|
128
|
+
class dt {
|
|
124
129
|
#t = /* @__PURE__ */ new Map();
|
|
125
130
|
get kinds() {
|
|
126
131
|
return this.#t;
|
|
127
132
|
}
|
|
128
133
|
assertCompatible(t) {
|
|
129
|
-
|
|
134
|
+
Z(this.#t, t);
|
|
130
135
|
}
|
|
131
136
|
remember(t) {
|
|
132
|
-
|
|
137
|
+
T(this.#t, t);
|
|
133
138
|
}
|
|
134
139
|
draft(t) {
|
|
135
|
-
return new
|
|
140
|
+
return new lt(this, t);
|
|
136
141
|
}
|
|
137
142
|
commit(t) {
|
|
138
143
|
for (const [e, i] of t) this.assertCompatible({ id: e, kind: i });
|
|
139
144
|
for (const [e, i] of t) this.#t.set(e, i);
|
|
140
145
|
}
|
|
141
146
|
}
|
|
142
|
-
class
|
|
147
|
+
class lt {
|
|
143
148
|
#t;
|
|
144
149
|
constructor(t, e) {
|
|
145
150
|
this.#t = { phase: "open", registry: t, pending: /* @__PURE__ */ new Map() };
|
|
@@ -153,7 +158,7 @@ class ot {
|
|
|
153
158
|
}
|
|
154
159
|
if (e.phase === "discarded")
|
|
155
160
|
throw new Error("Contract registry draft has been discarded");
|
|
156
|
-
e.registry.assertCompatible(t), !e.registry.kinds.has(t.id) &&
|
|
161
|
+
e.registry.assertCompatible(t), !e.registry.kinds.has(t.id) && T(e.pending, t);
|
|
157
162
|
}
|
|
158
163
|
commit() {
|
|
159
164
|
const t = this.#t;
|
|
@@ -163,10 +168,10 @@ class ot {
|
|
|
163
168
|
this.#t.phase === "open" && (this.#t = { phase: "discarded" });
|
|
164
169
|
}
|
|
165
170
|
}
|
|
166
|
-
function
|
|
167
|
-
|
|
171
|
+
function T(r, t) {
|
|
172
|
+
Z(r, t), r.set(t.id, t.kind);
|
|
168
173
|
}
|
|
169
|
-
function
|
|
174
|
+
function Z(r, t) {
|
|
170
175
|
const e = r.get(t.id);
|
|
171
176
|
if (e && e !== t.kind)
|
|
172
177
|
throw new u(
|
|
@@ -174,7 +179,7 @@ function J(r, t) {
|
|
|
174
179
|
`Contract '${t.id}' is used as both '${e}' and '${t.kind}'`
|
|
175
180
|
);
|
|
176
181
|
}
|
|
177
|
-
class
|
|
182
|
+
class M {
|
|
178
183
|
constructor(t, e, i, s, n, o) {
|
|
179
184
|
this.order = t, this.layers = e, this.providers = i, this.dependents = s, this.contractKinds = n, this.#t = o;
|
|
180
185
|
}
|
|
@@ -185,14 +190,14 @@ class x {
|
|
|
185
190
|
contractKinds;
|
|
186
191
|
#t;
|
|
187
192
|
static build(t, e) {
|
|
188
|
-
const i = [...t].sort((
|
|
193
|
+
const i = [...t].sort((c, d) => c.index - d.index), s = new Map(e), n = ut(i, s), o = ft(i, n, s), { order: a, layers: h } = pt(
|
|
189
194
|
i,
|
|
190
195
|
o.dependents,
|
|
191
196
|
o.indegree
|
|
192
197
|
);
|
|
193
|
-
return new
|
|
198
|
+
return new M(
|
|
194
199
|
Object.freeze(a),
|
|
195
|
-
Object.freeze(
|
|
200
|
+
Object.freeze(h.map((c) => Object.freeze(c))),
|
|
196
201
|
n,
|
|
197
202
|
o.dependents,
|
|
198
203
|
s,
|
|
@@ -220,11 +225,11 @@ class x {
|
|
|
220
225
|
}
|
|
221
226
|
}
|
|
222
227
|
}
|
|
223
|
-
function
|
|
228
|
+
function ut(r, t) {
|
|
224
229
|
const e = /* @__PURE__ */ new Map();
|
|
225
230
|
for (const i of r)
|
|
226
231
|
for (const s of Object.values(i.declaration.plugin.provides ?? {})) {
|
|
227
|
-
|
|
232
|
+
T(t, s);
|
|
228
233
|
const n = e.get(s.id);
|
|
229
234
|
if (n)
|
|
230
235
|
throw new u(
|
|
@@ -235,47 +240,47 @@ function at(r, t) {
|
|
|
235
240
|
}
|
|
236
241
|
return e;
|
|
237
242
|
}
|
|
238
|
-
function
|
|
243
|
+
function ft(r, t, e) {
|
|
239
244
|
const i = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), n = new Map(r.map((o) => [o, 0]));
|
|
240
245
|
for (const o of r)
|
|
241
246
|
for (const a of Object.values(o.declaration.plugin.requires ?? {})) {
|
|
242
|
-
const
|
|
243
|
-
if (
|
|
244
|
-
const
|
|
245
|
-
if (!
|
|
247
|
+
const h = a.kind === "optional" ? a.service : a;
|
|
248
|
+
if (T(e, h), h.kind === "extensionPoint") continue;
|
|
249
|
+
const c = t.get(h.id);
|
|
250
|
+
if (!c) {
|
|
246
251
|
if (a.kind === "optional") continue;
|
|
247
252
|
throw new u(
|
|
248
253
|
"SERVICE_MISSING",
|
|
249
|
-
`Installation '${o.id}' requires missing Service '${
|
|
254
|
+
`Installation '${o.id}' requires missing Service '${h.id}'`
|
|
250
255
|
);
|
|
251
256
|
}
|
|
252
|
-
if (
|
|
257
|
+
if (c === o)
|
|
253
258
|
throw new u(
|
|
254
259
|
"SERVICE_CYCLE",
|
|
255
|
-
`Installation '${o.id}' cannot require Service '${
|
|
260
|
+
`Installation '${o.id}' cannot require Service '${h.id}' that it provides`
|
|
256
261
|
);
|
|
257
262
|
const d = i.get(o) ?? /* @__PURE__ */ new Map();
|
|
258
|
-
d.set(
|
|
259
|
-
const l = s.get(
|
|
260
|
-
l.has(o) || (l.add(o), s.set(
|
|
263
|
+
d.set(h.id, c), i.set(o, d);
|
|
264
|
+
const l = s.get(c) ?? /* @__PURE__ */ new Set();
|
|
265
|
+
l.has(o) || (l.add(o), s.set(c, l), n.set(o, (n.get(o) ?? 0) + 1));
|
|
261
266
|
}
|
|
262
267
|
return { resolvedProviders: i, dependents: s, indegree: n };
|
|
263
268
|
}
|
|
264
|
-
function
|
|
269
|
+
function pt(r, t, e) {
|
|
265
270
|
let i = r.filter((o) => e.get(o) === 0);
|
|
266
271
|
const s = [], n = [];
|
|
267
272
|
for (; i.length; ) {
|
|
268
|
-
i.sort((a,
|
|
273
|
+
i.sort((a, h) => a.index - h.index);
|
|
269
274
|
const o = i;
|
|
270
275
|
i = [], n.push(o), s.push(...o);
|
|
271
276
|
for (const a of o)
|
|
272
|
-
for (const
|
|
273
|
-
const
|
|
274
|
-
e.set(
|
|
277
|
+
for (const h of t.get(a) ?? []) {
|
|
278
|
+
const c = (e.get(h) ?? 0) - 1;
|
|
279
|
+
e.set(h, c), c || i.push(h);
|
|
275
280
|
}
|
|
276
281
|
}
|
|
277
282
|
if (s.length !== r.length) {
|
|
278
|
-
const o =
|
|
283
|
+
const o = gt(r, t);
|
|
279
284
|
throw new u(
|
|
280
285
|
"SERVICE_CYCLE",
|
|
281
286
|
`Installation dependency cycle: ${o.map((a) => a.id).join(" -> ")}`
|
|
@@ -283,17 +288,17 @@ function ct(r, t, e) {
|
|
|
283
288
|
}
|
|
284
289
|
return { order: s, layers: n };
|
|
285
290
|
}
|
|
286
|
-
function
|
|
291
|
+
function gt(r, t) {
|
|
287
292
|
const e = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), s = [], n = (o) => {
|
|
288
293
|
i.add(o), s.push(o);
|
|
289
294
|
for (const a of t.get(o) ?? []) {
|
|
290
295
|
if (i.has(a)) {
|
|
291
|
-
const
|
|
292
|
-
return [...s.slice(
|
|
296
|
+
const c = s.indexOf(a);
|
|
297
|
+
return [...s.slice(c), a];
|
|
293
298
|
}
|
|
294
299
|
if (e.has(a)) continue;
|
|
295
|
-
const
|
|
296
|
-
if (
|
|
300
|
+
const h = n(a);
|
|
301
|
+
if (h) return h;
|
|
297
302
|
}
|
|
298
303
|
s.pop(), i.delete(o), e.add(o);
|
|
299
304
|
};
|
|
@@ -304,7 +309,7 @@ function dt(r, t) {
|
|
|
304
309
|
}
|
|
305
310
|
throw new Error("Dependency graph is cyclic but no cycle path was found");
|
|
306
311
|
}
|
|
307
|
-
class
|
|
312
|
+
class S {
|
|
308
313
|
#t;
|
|
309
314
|
constructor(t = []) {
|
|
310
315
|
if (!t || typeof t != "object" && typeof t != "function" || typeof t[Symbol.iterator] != "function")
|
|
@@ -336,7 +341,21 @@ class O {
|
|
|
336
341
|
return this.entries();
|
|
337
342
|
}
|
|
338
343
|
}
|
|
339
|
-
|
|
344
|
+
function wt(r) {
|
|
345
|
+
if (typeof r != "function")
|
|
346
|
+
throw new Error("Unsupported JavaScript runtime: Promise.withResolvers is required");
|
|
347
|
+
}
|
|
348
|
+
function tt(r, t) {
|
|
349
|
+
return r ?? Symbol.for(t);
|
|
350
|
+
}
|
|
351
|
+
wt(Promise.withResolvers);
|
|
352
|
+
const g = tt(
|
|
353
|
+
Symbol.dispose,
|
|
354
|
+
"Symbol.dispose"
|
|
355
|
+
), j = tt(
|
|
356
|
+
Symbol.asyncDispose,
|
|
357
|
+
"Symbol.asyncDispose"
|
|
358
|
+
), m = /* @__PURE__ */ new WeakMap();
|
|
340
359
|
class q {
|
|
341
360
|
#t = /* @__PURE__ */ new Set();
|
|
342
361
|
#e;
|
|
@@ -350,15 +369,15 @@ class q {
|
|
|
350
369
|
}
|
|
351
370
|
view = Object.freeze({
|
|
352
371
|
get: () => this.#n(),
|
|
353
|
-
subscribe: (t) => this.#
|
|
372
|
+
subscribe: (t) => this.#o(t)
|
|
354
373
|
});
|
|
355
374
|
invalidate() {
|
|
356
|
-
const { report: t } = this.#
|
|
375
|
+
const { report: t } = this.#a();
|
|
357
376
|
this.#s = !0;
|
|
358
377
|
const e = [];
|
|
359
378
|
for (const i of [...this.#t])
|
|
360
379
|
try {
|
|
361
|
-
|
|
380
|
+
bt(i);
|
|
362
381
|
} catch (s) {
|
|
363
382
|
try {
|
|
364
383
|
t(s);
|
|
@@ -379,21 +398,21 @@ class q {
|
|
|
379
398
|
this.#s = !1;
|
|
380
399
|
const e = [...this.#t];
|
|
381
400
|
this.#t.clear();
|
|
382
|
-
for (const i of e)
|
|
401
|
+
for (const i of e) mt(i);
|
|
383
402
|
}
|
|
384
403
|
}
|
|
385
404
|
}
|
|
386
|
-
[
|
|
405
|
+
[g]() {
|
|
387
406
|
this.dispose();
|
|
388
407
|
}
|
|
389
408
|
#n() {
|
|
390
409
|
const t = this.#e;
|
|
391
410
|
return t.phase === "active" && this.#r(t.read), this.#i;
|
|
392
411
|
}
|
|
393
|
-
#
|
|
412
|
+
#o(t) {
|
|
394
413
|
if (typeof t != "function") throw new TypeError("Subscriber must be a function");
|
|
395
|
-
this.#
|
|
396
|
-
const e = new
|
|
414
|
+
this.#a();
|
|
415
|
+
const e = new vt(t, (i) => {
|
|
397
416
|
this.#t.delete(i);
|
|
398
417
|
});
|
|
399
418
|
return this.#t.add(e), e;
|
|
@@ -401,31 +420,31 @@ class q {
|
|
|
401
420
|
#r(t) {
|
|
402
421
|
this.#s && (this.#i = t(), this.#s = !1);
|
|
403
422
|
}
|
|
404
|
-
#
|
|
423
|
+
#a() {
|
|
405
424
|
const t = this.#e;
|
|
406
425
|
if (t.phase === "disposed") throw new TypeError("Snapshot publisher is disposed");
|
|
407
426
|
return t;
|
|
408
427
|
}
|
|
409
428
|
}
|
|
410
|
-
class
|
|
429
|
+
class vt {
|
|
411
430
|
constructor(t, e) {
|
|
412
|
-
|
|
431
|
+
m.set(this, { listener: t, detach: e }), Object.freeze(this);
|
|
413
432
|
}
|
|
414
433
|
dispose() {
|
|
415
|
-
const t =
|
|
416
|
-
t && (
|
|
434
|
+
const t = m.get(this);
|
|
435
|
+
t && (m.delete(this), t.detach(this));
|
|
417
436
|
}
|
|
418
|
-
[
|
|
437
|
+
[g]() {
|
|
419
438
|
this.dispose();
|
|
420
439
|
}
|
|
421
440
|
}
|
|
422
|
-
function
|
|
423
|
-
|
|
441
|
+
function bt(r) {
|
|
442
|
+
m.get(r)?.listener();
|
|
424
443
|
}
|
|
425
|
-
function
|
|
426
|
-
|
|
444
|
+
function mt(r) {
|
|
445
|
+
m.delete(r);
|
|
427
446
|
}
|
|
428
|
-
class
|
|
447
|
+
class yt {
|
|
429
448
|
#t;
|
|
430
449
|
get;
|
|
431
450
|
subscribe;
|
|
@@ -447,7 +466,7 @@ class pt {
|
|
|
447
466
|
return t;
|
|
448
467
|
}
|
|
449
468
|
}
|
|
450
|
-
class
|
|
469
|
+
class Et {
|
|
451
470
|
#t;
|
|
452
471
|
constructor(t) {
|
|
453
472
|
this.#t = t, Object.freeze(this);
|
|
@@ -458,16 +477,16 @@ class gt {
|
|
|
458
477
|
dispose() {
|
|
459
478
|
this.#t.dispose();
|
|
460
479
|
}
|
|
461
|
-
[
|
|
480
|
+
[g]() {
|
|
462
481
|
this.dispose();
|
|
463
482
|
}
|
|
464
483
|
}
|
|
465
|
-
class
|
|
484
|
+
class Ct {
|
|
466
485
|
#t;
|
|
467
486
|
#e;
|
|
468
487
|
handle;
|
|
469
488
|
constructor(t, e, i, s) {
|
|
470
|
-
this.#e = e, this.#t = { phase: "staged", store: t, value: i, detachFromOwner: s }, this.handle = new
|
|
489
|
+
this.#e = e, this.#t = { phase: "staged", store: t, value: i, detachFromOwner: s }, this.handle = new Et(this);
|
|
471
490
|
}
|
|
472
491
|
publish() {
|
|
473
492
|
const t = this.#t;
|
|
@@ -496,50 +515,55 @@ class wt {
|
|
|
496
515
|
}
|
|
497
516
|
}
|
|
498
517
|
}
|
|
499
|
-
[
|
|
518
|
+
[g]() {
|
|
500
519
|
this.dispose();
|
|
501
520
|
}
|
|
502
521
|
}
|
|
503
|
-
class
|
|
522
|
+
class Ot {
|
|
504
523
|
#t;
|
|
505
524
|
#e;
|
|
506
525
|
#i = /* @__PURE__ */ new Map();
|
|
507
526
|
#s = /* @__PURE__ */ new Map();
|
|
508
527
|
#n;
|
|
509
|
-
#
|
|
528
|
+
#o = new S();
|
|
510
529
|
#r = 0;
|
|
511
|
-
#
|
|
512
|
-
#
|
|
530
|
+
#a = 0;
|
|
531
|
+
#d = !1;
|
|
532
|
+
#f = !1;
|
|
513
533
|
constructor(t, e, i) {
|
|
514
|
-
this.#t = t, this.#e = i, this.#n = new q(() => this.#
|
|
534
|
+
this.#t = t, this.#e = i, this.#n = new q(() => this.#o, e);
|
|
515
535
|
}
|
|
516
536
|
stage(t, e, i, s) {
|
|
517
|
-
|
|
518
|
-
const n =
|
|
537
|
+
$t(e);
|
|
538
|
+
const n = Tt(t, e);
|
|
519
539
|
if (this.#i.has(n))
|
|
520
540
|
throw new TypeError(`Duplicate contribution '${n}'`);
|
|
521
|
-
const o = new
|
|
541
|
+
const o = new Ct(this, n, i, s);
|
|
522
542
|
return this.#i.set(n, o), o;
|
|
523
543
|
}
|
|
524
544
|
view(t) {
|
|
525
545
|
this.#r++;
|
|
526
546
|
const e = { binding: { store: this, own: t } };
|
|
527
547
|
let i;
|
|
528
|
-
const s = new
|
|
548
|
+
const s = new St(e, () => {
|
|
529
549
|
const n = i;
|
|
530
550
|
i = void 0;
|
|
531
551
|
try {
|
|
532
552
|
n?.();
|
|
533
553
|
} finally {
|
|
534
|
-
this.#r--, this.#
|
|
554
|
+
this.#r--, this.#h();
|
|
535
555
|
}
|
|
536
556
|
});
|
|
537
557
|
try {
|
|
538
558
|
i = t(s, "view");
|
|
539
559
|
} catch (n) {
|
|
540
|
-
throw e.binding = void 0, this.#r--, this.#
|
|
560
|
+
throw e.binding = void 0, this.#r--, this.#h(), n;
|
|
541
561
|
}
|
|
542
|
-
return new
|
|
562
|
+
return new yt(e);
|
|
563
|
+
}
|
|
564
|
+
/** A stable view explicitly owned by the Host for graph-external consumers. */
|
|
565
|
+
hostView() {
|
|
566
|
+
return this.#d = !0, this.#n.view;
|
|
543
567
|
}
|
|
544
568
|
snapshot() {
|
|
545
569
|
return this.#n.view.get();
|
|
@@ -548,15 +572,15 @@ class vt {
|
|
|
548
572
|
if (typeof t != "function")
|
|
549
573
|
throw new TypeError("Contribution subscriber must be a function");
|
|
550
574
|
const i = this.#n.view.subscribe(t);
|
|
551
|
-
this.#
|
|
575
|
+
this.#a++;
|
|
552
576
|
let s;
|
|
553
|
-
const n = new
|
|
577
|
+
const n = new It(i, () => {
|
|
554
578
|
const o = s;
|
|
555
579
|
s = void 0;
|
|
556
580
|
try {
|
|
557
581
|
o?.();
|
|
558
582
|
} finally {
|
|
559
|
-
this.#
|
|
583
|
+
this.#a--, this.#h();
|
|
560
584
|
}
|
|
561
585
|
});
|
|
562
586
|
try {
|
|
@@ -567,7 +591,7 @@ class vt {
|
|
|
567
591
|
return n;
|
|
568
592
|
}
|
|
569
593
|
insert(t, e, i) {
|
|
570
|
-
if (this.#
|
|
594
|
+
if (this.#l(t, e), this.#s.has(t))
|
|
571
595
|
throw new Error(`Contribution '${t}' is already published`);
|
|
572
596
|
e.commitPublication(), this.#s.set(t, { contribution: e, value: i }), this.#t(this);
|
|
573
597
|
}
|
|
@@ -576,18 +600,18 @@ class vt {
|
|
|
576
600
|
s.value = i, this.#t(this);
|
|
577
601
|
}
|
|
578
602
|
removeContribution(t, e, i) {
|
|
579
|
-
this.#
|
|
603
|
+
this.#l(t, e), i === "published" && this.#u(t, e);
|
|
580
604
|
try {
|
|
581
605
|
this.#i.delete(t), i === "published" && (this.#s.delete(t), this.#t(this));
|
|
582
606
|
} finally {
|
|
583
|
-
this.#
|
|
607
|
+
this.#h();
|
|
584
608
|
}
|
|
585
609
|
}
|
|
586
610
|
publishSnapshot() {
|
|
587
611
|
const t = [...this.#s].map(([i, s]) => [i, s.value]);
|
|
588
|
-
t.length === this.#
|
|
612
|
+
t.length === this.#o.size && t.every(([i, s]) => Object.is(this.#o.get(i), s)) || (this.#o = new S(t), this.#n.invalidate());
|
|
589
613
|
}
|
|
590
|
-
#
|
|
614
|
+
#l(t, e) {
|
|
591
615
|
if (this.#i.get(t) !== e)
|
|
592
616
|
throw new Error(`Contribution '${t}' is not the current claim`);
|
|
593
617
|
}
|
|
@@ -597,9 +621,9 @@ class vt {
|
|
|
597
621
|
throw new Error(`Contribution '${t}' is not the published entry`);
|
|
598
622
|
return i;
|
|
599
623
|
}
|
|
600
|
-
#
|
|
601
|
-
if (!(this.#
|
|
602
|
-
this.#
|
|
624
|
+
#h() {
|
|
625
|
+
if (!(this.#f || this.#d || this.#i.size || this.#s.size || this.#a || this.#r)) {
|
|
626
|
+
this.#f = !0;
|
|
603
627
|
try {
|
|
604
628
|
this.#n.dispose();
|
|
605
629
|
} finally {
|
|
@@ -608,7 +632,7 @@ class vt {
|
|
|
608
632
|
}
|
|
609
633
|
}
|
|
610
634
|
}
|
|
611
|
-
class
|
|
635
|
+
class St {
|
|
612
636
|
#t;
|
|
613
637
|
constructor(t, e) {
|
|
614
638
|
this.#t = { state: t, release: e }, Object.freeze(this);
|
|
@@ -617,11 +641,11 @@ class bt {
|
|
|
617
641
|
const t = this.#t;
|
|
618
642
|
t && (this.#t = void 0, t.state.binding = void 0, t.release());
|
|
619
643
|
}
|
|
620
|
-
[
|
|
644
|
+
[g]() {
|
|
621
645
|
this.dispose();
|
|
622
646
|
}
|
|
623
647
|
}
|
|
624
|
-
class
|
|
648
|
+
class It {
|
|
625
649
|
#t;
|
|
626
650
|
constructor(t, e) {
|
|
627
651
|
this.#t = { subscription: t, release: e }, Object.freeze(this);
|
|
@@ -637,11 +661,11 @@ class mt {
|
|
|
637
661
|
}
|
|
638
662
|
}
|
|
639
663
|
}
|
|
640
|
-
[
|
|
664
|
+
[g]() {
|
|
641
665
|
this.dispose();
|
|
642
666
|
}
|
|
643
667
|
}
|
|
644
|
-
class
|
|
668
|
+
class At {
|
|
645
669
|
#t = /* @__PURE__ */ new Map();
|
|
646
670
|
#e = /* @__PURE__ */ new Set();
|
|
647
671
|
#i;
|
|
@@ -652,7 +676,7 @@ class yt {
|
|
|
652
676
|
get(t) {
|
|
653
677
|
const e = this.#t.get(t.id);
|
|
654
678
|
if (e) return e;
|
|
655
|
-
const i = new
|
|
679
|
+
const i = new Ot(
|
|
656
680
|
(s) => this.#n(s),
|
|
657
681
|
this.#i,
|
|
658
682
|
(s) => {
|
|
@@ -661,6 +685,9 @@ class yt {
|
|
|
661
685
|
);
|
|
662
686
|
return this.#t.set(t.id, i), i;
|
|
663
687
|
}
|
|
688
|
+
view(t) {
|
|
689
|
+
return this.get(t).hostView();
|
|
690
|
+
}
|
|
664
691
|
beginBatch() {
|
|
665
692
|
this.#s++;
|
|
666
693
|
}
|
|
@@ -684,19 +711,19 @@ class yt {
|
|
|
684
711
|
this.#e.add(t), !this.#s && (this.#e.delete(t), t.publishSnapshot());
|
|
685
712
|
}
|
|
686
713
|
}
|
|
687
|
-
function
|
|
714
|
+
function $t(r) {
|
|
688
715
|
if (typeof r != "string" || !r.trim())
|
|
689
716
|
throw new TypeError("Contribution key must be a non-empty string");
|
|
690
717
|
if (r !== r.trim())
|
|
691
718
|
throw new TypeError("Contribution key cannot start or end with whitespace");
|
|
692
719
|
}
|
|
693
|
-
function
|
|
694
|
-
return `${
|
|
720
|
+
function Tt(r, t) {
|
|
721
|
+
return `${B(r)}/${B(t)}`;
|
|
695
722
|
}
|
|
696
|
-
function
|
|
723
|
+
function B(r) {
|
|
697
724
|
return r.replaceAll("%", "%25").replaceAll("/", "%2F");
|
|
698
725
|
}
|
|
699
|
-
class
|
|
726
|
+
class jt {
|
|
700
727
|
#t;
|
|
701
728
|
constructor(t) {
|
|
702
729
|
this.#t = t, Object.freeze(this);
|
|
@@ -705,16 +732,16 @@ class Ot {
|
|
|
705
732
|
const t = this.#t;
|
|
706
733
|
this.#t = void 0, t?.dispose();
|
|
707
734
|
}
|
|
708
|
-
[
|
|
735
|
+
[g]() {
|
|
709
736
|
this.dispose();
|
|
710
737
|
}
|
|
711
738
|
}
|
|
712
|
-
class
|
|
739
|
+
class kt {
|
|
713
740
|
#t;
|
|
714
741
|
#e;
|
|
715
742
|
handle;
|
|
716
743
|
constructor(t, e, i, s) {
|
|
717
|
-
this.#e = e, this.#t = { phase: "staged", hub: t, slot: { listener: i }, release: s }, this.handle = new
|
|
744
|
+
this.#e = e, this.#t = { phase: "staged", hub: t, slot: { listener: i }, release: s }, this.handle = new jt(this);
|
|
718
745
|
}
|
|
719
746
|
publish() {
|
|
720
747
|
const t = this.#t;
|
|
@@ -731,15 +758,15 @@ class St {
|
|
|
731
758
|
}
|
|
732
759
|
}
|
|
733
760
|
}
|
|
734
|
-
[
|
|
761
|
+
[g]() {
|
|
735
762
|
this.dispose();
|
|
736
763
|
}
|
|
737
764
|
}
|
|
738
|
-
class
|
|
765
|
+
class Pt {
|
|
739
766
|
#t = /* @__PURE__ */ new Map();
|
|
740
767
|
stage(t, e, i) {
|
|
741
768
|
if (typeof e != "function") throw new TypeError("Event listener must be a function");
|
|
742
|
-
return new
|
|
769
|
+
return new kt(this, t, e, i);
|
|
743
770
|
}
|
|
744
771
|
add(t, e) {
|
|
745
772
|
const i = this.#t.get(t) ?? /* @__PURE__ */ new Set();
|
|
@@ -759,15 +786,15 @@ class It {
|
|
|
759
786
|
throw new AggregateError(n, `Event '${t}' listeners failed`);
|
|
760
787
|
}
|
|
761
788
|
}
|
|
762
|
-
class
|
|
789
|
+
class Lt {
|
|
763
790
|
#t;
|
|
764
791
|
root;
|
|
765
792
|
view;
|
|
766
793
|
constructor(t, e) {
|
|
767
|
-
this.root =
|
|
794
|
+
this.root = F(t), this.#t = new q(() => et(this.root), e), this.view = this.#t.view;
|
|
768
795
|
}
|
|
769
796
|
createNode(t) {
|
|
770
|
-
return
|
|
797
|
+
return F(t);
|
|
771
798
|
}
|
|
772
799
|
attach(t, e) {
|
|
773
800
|
if (t.children.has(e)) throw new Error("Lifetime diagnostic node is attached");
|
|
@@ -788,7 +815,7 @@ class At {
|
|
|
788
815
|
this.root.phase !== "disposed" && (this.root.phase = "disposed", this.#t.invalidate(), this.#t.dispose());
|
|
789
816
|
}
|
|
790
817
|
}
|
|
791
|
-
function
|
|
818
|
+
function F(r) {
|
|
792
819
|
return {
|
|
793
820
|
label: r,
|
|
794
821
|
phase: "active",
|
|
@@ -803,8 +830,8 @@ function G(r) {
|
|
|
803
830
|
children: /* @__PURE__ */ new Set()
|
|
804
831
|
};
|
|
805
832
|
}
|
|
806
|
-
function
|
|
807
|
-
const t = Object.freeze([...r.children].map(
|
|
833
|
+
function et(r) {
|
|
834
|
+
const t = Object.freeze([...r.children].map(et));
|
|
808
835
|
return Object.freeze({
|
|
809
836
|
label: r.label,
|
|
810
837
|
phase: r.phase,
|
|
@@ -812,15 +839,15 @@ function X(r) {
|
|
|
812
839
|
children: t
|
|
813
840
|
});
|
|
814
841
|
}
|
|
815
|
-
function
|
|
842
|
+
function zt(r) {
|
|
816
843
|
if (!r || typeof r != "object") return !1;
|
|
817
844
|
const t = r;
|
|
818
845
|
return [t.debug, t.info, t.warn, t.error].every(
|
|
819
846
|
(e) => typeof e == "function"
|
|
820
847
|
);
|
|
821
848
|
}
|
|
822
|
-
const
|
|
823
|
-
class
|
|
849
|
+
const R = Object.freeze(new DOMException("Resource disposed", "AbortError"));
|
|
850
|
+
class w {
|
|
824
851
|
#t = /* @__PURE__ */ new Set();
|
|
825
852
|
#e;
|
|
826
853
|
constructor(t) {
|
|
@@ -858,7 +885,7 @@ class g {
|
|
|
858
885
|
return this.#t[Symbol.iterator]();
|
|
859
886
|
}
|
|
860
887
|
}
|
|
861
|
-
class
|
|
888
|
+
class Rt {
|
|
862
889
|
#t;
|
|
863
890
|
constructor(t, e) {
|
|
864
891
|
this.#t = { phase: "active", cleanup: t, detachFromParent: e }, Object.freeze(this);
|
|
@@ -878,11 +905,11 @@ class Tt {
|
|
|
878
905
|
});
|
|
879
906
|
return this.#t = { phase: "disposing", completion: e }, e;
|
|
880
907
|
}
|
|
881
|
-
[
|
|
908
|
+
[j]() {
|
|
882
909
|
return this.dispose();
|
|
883
910
|
}
|
|
884
911
|
}
|
|
885
|
-
class
|
|
912
|
+
class Nt {
|
|
886
913
|
#t;
|
|
887
914
|
#e;
|
|
888
915
|
#i;
|
|
@@ -895,7 +922,7 @@ class jt {
|
|
|
895
922
|
() => this.#s(),
|
|
896
923
|
(a) => {
|
|
897
924
|
try {
|
|
898
|
-
|
|
925
|
+
J(n.signal, a) || i(a);
|
|
899
926
|
} finally {
|
|
900
927
|
this.#s();
|
|
901
928
|
}
|
|
@@ -913,9 +940,9 @@ class jt {
|
|
|
913
940
|
() => {
|
|
914
941
|
}
|
|
915
942
|
);
|
|
916
|
-
return this.#i = { phase: "disposing", completion: e }, t.controller.abort(
|
|
943
|
+
return this.#i = { phase: "disposing", completion: e }, t.controller.abort(R), this.#n(), e;
|
|
917
944
|
}
|
|
918
|
-
[
|
|
945
|
+
[j]() {
|
|
919
946
|
return this.dispose();
|
|
920
947
|
}
|
|
921
948
|
#s() {
|
|
@@ -929,76 +956,86 @@ class jt {
|
|
|
929
956
|
this.#t = void 0, t?.();
|
|
930
957
|
}
|
|
931
958
|
}
|
|
932
|
-
class
|
|
959
|
+
class D {
|
|
933
960
|
#t;
|
|
934
961
|
#e;
|
|
935
962
|
#i;
|
|
936
963
|
#s;
|
|
937
964
|
#n;
|
|
938
|
-
#a;
|
|
939
|
-
#r;
|
|
940
965
|
#o;
|
|
941
|
-
#
|
|
966
|
+
#r;
|
|
967
|
+
#a;
|
|
968
|
+
#d;
|
|
942
969
|
#f;
|
|
943
|
-
#u;
|
|
944
970
|
#l;
|
|
971
|
+
#u;
|
|
945
972
|
handle;
|
|
946
|
-
#
|
|
973
|
+
#h;
|
|
947
974
|
constructor(t, e, i = {}) {
|
|
948
|
-
this.#e = e, this.handle = new
|
|
975
|
+
this.#e = e, this.handle = new xt(this);
|
|
949
976
|
const s = new AbortController();
|
|
950
|
-
this.#
|
|
977
|
+
this.#h = {
|
|
951
978
|
phase: "active",
|
|
952
979
|
controller: s,
|
|
953
980
|
declarations: i.declarations ?? "staged"
|
|
954
981
|
};
|
|
955
982
|
const n = i.parent;
|
|
956
|
-
this.#
|
|
957
|
-
const o = n?.diagnostics ?? new
|
|
983
|
+
this.#u = n?.detach, this.#f = n ? "child" : "root";
|
|
984
|
+
const o = n?.diagnostics ?? new Lt(e, (l) => t.report(l)), a = n?.diagnosticNode ?? o.root;
|
|
958
985
|
this.#t = { port: t, diagnostics: o, diagnosticNode: a };
|
|
959
|
-
const
|
|
986
|
+
const h = (l) => ({
|
|
960
987
|
diagnostics: o,
|
|
961
988
|
node: a,
|
|
962
989
|
kind: l
|
|
963
990
|
});
|
|
964
|
-
this.#i = new
|
|
965
|
-
const
|
|
966
|
-
if (!
|
|
967
|
-
const d = () => s.abort(
|
|
968
|
-
|
|
991
|
+
this.#i = new w(h("listeners")), this.#s = new w(h("contributions")), this.#n = new w(h("contributionViews")), this.#o = new w(h("subscriptions")), this.#r = new w(h("tasks")), this.#a = new w(), this.#d = new w(h("cleanups"));
|
|
992
|
+
const c = i.parentSignal;
|
|
993
|
+
if (!c) return;
|
|
994
|
+
const d = () => s.abort(c.reason);
|
|
995
|
+
c.addEventListener("abort", d, { once: !0 }), this.#l = () => c.removeEventListener("abort", d), c.aborted && d();
|
|
969
996
|
}
|
|
970
997
|
get signal() {
|
|
971
|
-
const t = this.#
|
|
998
|
+
const t = this.#h;
|
|
972
999
|
return t.phase === "disposed" ? t.signal : t.controller.signal;
|
|
973
1000
|
}
|
|
974
1001
|
get diagnostics() {
|
|
975
|
-
return this.#
|
|
1002
|
+
return this.#c().diagnostics.view;
|
|
1003
|
+
}
|
|
1004
|
+
/** A facade whose only Runtime edge disappears when this Lifetime terminates. */
|
|
1005
|
+
contextLogger(t) {
|
|
1006
|
+
const e = (i) => (s, ...n) => this.#p().port.writeLog(i, s, t, n);
|
|
1007
|
+
return Object.freeze({
|
|
1008
|
+
debug: e("debug"),
|
|
1009
|
+
info: e("info"),
|
|
1010
|
+
warn: e("warn"),
|
|
1011
|
+
error: e("error")
|
|
1012
|
+
});
|
|
976
1013
|
}
|
|
977
1014
|
cleanup(t) {
|
|
978
|
-
if (this.#
|
|
979
|
-
const e = new
|
|
980
|
-
return this.#
|
|
1015
|
+
if (this.#c(), typeof t != "function") throw new TypeError("Cleanup must be a function");
|
|
1016
|
+
const e = new Rt(t, this.#d.release);
|
|
1017
|
+
return this.#d.add(e), e;
|
|
981
1018
|
}
|
|
982
1019
|
lifetime(t) {
|
|
983
|
-
const { port: e, diagnostics: i, diagnosticNode: s } = this.#
|
|
984
|
-
|
|
985
|
-
const n = i.createNode(t), o = new
|
|
1020
|
+
const { port: e, diagnostics: i, diagnosticNode: s } = this.#c();
|
|
1021
|
+
Vt(t);
|
|
1022
|
+
const n = i.createNode(t), o = new D(e, this.#e, {
|
|
986
1023
|
parentSignal: this.signal,
|
|
987
1024
|
declarations: this.#g(),
|
|
988
1025
|
parent: {
|
|
989
1026
|
diagnostics: i,
|
|
990
1027
|
diagnosticNode: n,
|
|
991
1028
|
detach: (a) => {
|
|
992
|
-
this.#
|
|
1029
|
+
this.#a.release(a) && i.detach(s, n);
|
|
993
1030
|
}
|
|
994
1031
|
}
|
|
995
1032
|
});
|
|
996
|
-
return this.#
|
|
1033
|
+
return this.#a.add(o), i.attach(s, n), o.handle;
|
|
997
1034
|
}
|
|
998
1035
|
spawn(t) {
|
|
999
|
-
const { port: e } = this.#
|
|
1036
|
+
const { port: e } = this.#c();
|
|
1000
1037
|
if (typeof t != "function") throw new TypeError("Background task must be a function");
|
|
1001
|
-
const i = new
|
|
1038
|
+
const i = new Nt(
|
|
1002
1039
|
this.signal,
|
|
1003
1040
|
t,
|
|
1004
1041
|
(s) => e.report(s),
|
|
@@ -1007,14 +1044,15 @@ class V {
|
|
|
1007
1044
|
return this.#r.add(i), i;
|
|
1008
1045
|
}
|
|
1009
1046
|
on(t, e) {
|
|
1010
|
-
const { port: i } = this.#
|
|
1047
|
+
const { port: i } = this.#c(), s = i.stageOn(this.#e, t, e, this.#i.release);
|
|
1011
1048
|
return this.#i.add(s), this.#g() === "published" && s.publish(), s.handle;
|
|
1012
1049
|
}
|
|
1013
|
-
emit(t, e) {
|
|
1014
|
-
|
|
1050
|
+
async emit(t, ...e) {
|
|
1051
|
+
const { port: i } = this.#c();
|
|
1052
|
+
await i.emit(this.#e, t, e[0]);
|
|
1015
1053
|
}
|
|
1016
1054
|
contribute(t, e, i) {
|
|
1017
|
-
const { port: s } = this.#
|
|
1055
|
+
const { port: s } = this.#c(), n = s.stageContribution(
|
|
1018
1056
|
this.#e,
|
|
1019
1057
|
t,
|
|
1020
1058
|
e,
|
|
@@ -1025,65 +1063,65 @@ class V {
|
|
|
1025
1063
|
}
|
|
1026
1064
|
/** Owns an internal live capability without exposing a second Context API. */
|
|
1027
1065
|
ownLease(t, e) {
|
|
1028
|
-
return this.#
|
|
1066
|
+
return this.#c(), (e === "view" ? this.#n : this.#o).own(t);
|
|
1029
1067
|
}
|
|
1030
1068
|
/** Releases a temporary startup cancellation edge after its layer commits. */
|
|
1031
1069
|
detachStartupSignal() {
|
|
1032
|
-
const t = this.#
|
|
1033
|
-
this.#
|
|
1070
|
+
const t = this.#l;
|
|
1071
|
+
this.#l = void 0, t?.();
|
|
1034
1072
|
}
|
|
1035
1073
|
/** Atomically makes all declarations staged during setup visible. */
|
|
1036
1074
|
publish() {
|
|
1037
|
-
const t = this.#
|
|
1038
|
-
if (t.phase !== "active") throw
|
|
1039
|
-
if (this.#
|
|
1075
|
+
const t = this.#h;
|
|
1076
|
+
if (t.phase !== "active") throw y();
|
|
1077
|
+
if (this.#c(), t.declarations !== "published") {
|
|
1040
1078
|
for (const e of this.#i) e.publish();
|
|
1041
1079
|
for (const e of this.#s) e.publish();
|
|
1042
|
-
for (const e of this.#
|
|
1043
|
-
this.#
|
|
1080
|
+
for (const e of this.#a) e.publish();
|
|
1081
|
+
this.#h = { ...t, declarations: "published" };
|
|
1044
1082
|
}
|
|
1045
1083
|
}
|
|
1046
1084
|
dispose() {
|
|
1047
|
-
const t = this.#
|
|
1085
|
+
const t = this.#h;
|
|
1048
1086
|
if (t.phase === "disposing") return t.completion;
|
|
1049
1087
|
if (t.phase === "disposed") return Promise.resolve();
|
|
1050
1088
|
const e = this.#p(), i = Promise.resolve().then(async () => {
|
|
1051
1089
|
const s = [];
|
|
1052
|
-
if (await this.#i.dispose(s), await this.#s.dispose(s), await this.#
|
|
1090
|
+
if (await this.#i.dispose(s), await this.#s.dispose(s), await this.#o.dispose(s), await this.#n.dispose(s), t.controller.abort(R), this.detachStartupSignal(), await this.#r.dispose(s), await this.#a.dispose(s), await this.#d.dispose(s), s.length === 1) throw s[0];
|
|
1053
1091
|
if (s.length > 1) throw new AggregateError(s, "Lifetime cleanup failed");
|
|
1054
1092
|
}).finally(() => {
|
|
1055
|
-
this.#
|
|
1056
|
-
const s = this.#
|
|
1057
|
-
this.#
|
|
1093
|
+
this.#h = { phase: "disposed", signal: AbortSignal.abort(R) };
|
|
1094
|
+
const s = this.#u;
|
|
1095
|
+
this.#u = void 0;
|
|
1058
1096
|
try {
|
|
1059
1097
|
s?.(this), this.#f === "root" && e.diagnostics.finishRoot();
|
|
1060
1098
|
} finally {
|
|
1061
1099
|
this.#t = void 0;
|
|
1062
1100
|
}
|
|
1063
1101
|
});
|
|
1064
|
-
return this.#
|
|
1102
|
+
return this.#h = { phase: "disposing", controller: t.controller, completion: i }, e.diagnostics.beginDisposing(e.diagnosticNode), i;
|
|
1065
1103
|
}
|
|
1066
|
-
[
|
|
1104
|
+
[j]() {
|
|
1067
1105
|
return this.dispose();
|
|
1068
1106
|
}
|
|
1069
|
-
#
|
|
1107
|
+
#c() {
|
|
1070
1108
|
const t = this.#t;
|
|
1071
|
-
if (this.#
|
|
1072
|
-
throw
|
|
1109
|
+
if (this.#h.phase !== "active" || this.signal.aborted || !t)
|
|
1110
|
+
throw y();
|
|
1073
1111
|
return t;
|
|
1074
1112
|
}
|
|
1075
1113
|
#p() {
|
|
1076
1114
|
const t = this.#t;
|
|
1077
|
-
if (!t) throw
|
|
1115
|
+
if (!t) throw y();
|
|
1078
1116
|
return t;
|
|
1079
1117
|
}
|
|
1080
1118
|
#g() {
|
|
1081
|
-
const t = this.#
|
|
1082
|
-
if (t.phase !== "active") throw
|
|
1119
|
+
const t = this.#h;
|
|
1120
|
+
if (t.phase !== "active") throw y();
|
|
1083
1121
|
return t.declarations;
|
|
1084
1122
|
}
|
|
1085
1123
|
}
|
|
1086
|
-
class
|
|
1124
|
+
class xt {
|
|
1087
1125
|
#t;
|
|
1088
1126
|
constructor(t) {
|
|
1089
1127
|
this.#t = t, Object.freeze(this);
|
|
@@ -1103,8 +1141,8 @@ class kt {
|
|
|
1103
1141
|
on(t, e) {
|
|
1104
1142
|
return this.#t.on(t, e);
|
|
1105
1143
|
}
|
|
1106
|
-
emit(t, e) {
|
|
1107
|
-
return this.#t.emit(t, e);
|
|
1144
|
+
emit(t, ...e) {
|
|
1145
|
+
return this.#t.emit(t, ...e);
|
|
1108
1146
|
}
|
|
1109
1147
|
contribute(t, e, i) {
|
|
1110
1148
|
return this.#t.contribute(t, e, i);
|
|
@@ -1112,37 +1150,40 @@ class kt {
|
|
|
1112
1150
|
dispose() {
|
|
1113
1151
|
return this.#t.dispose();
|
|
1114
1152
|
}
|
|
1115
|
-
[
|
|
1153
|
+
[j]() {
|
|
1116
1154
|
return this.dispose();
|
|
1117
1155
|
}
|
|
1118
1156
|
}
|
|
1119
|
-
function
|
|
1157
|
+
function Vt(r) {
|
|
1120
1158
|
if (typeof r != "string" || !r.trim())
|
|
1121
1159
|
throw new TypeError("Lifetime label must be a non-empty string");
|
|
1122
1160
|
if (r !== r.trim())
|
|
1123
1161
|
throw new TypeError("Lifetime label cannot start or end with whitespace");
|
|
1124
1162
|
}
|
|
1125
|
-
function
|
|
1126
|
-
return new
|
|
1163
|
+
function y() {
|
|
1164
|
+
return new u("LIFETIME_DISPOSED", "Lifetime is disposing or has been disposed");
|
|
1127
1165
|
}
|
|
1128
|
-
class
|
|
1166
|
+
class N extends AggregateError {
|
|
1129
1167
|
}
|
|
1130
|
-
class
|
|
1168
|
+
class Mt {
|
|
1131
1169
|
#t;
|
|
1132
1170
|
#e;
|
|
1133
1171
|
#i;
|
|
1134
1172
|
#s;
|
|
1135
1173
|
#n = /* @__PURE__ */ new Map();
|
|
1136
|
-
#
|
|
1174
|
+
#o = new Pt();
|
|
1137
1175
|
#r;
|
|
1138
|
-
#
|
|
1176
|
+
#a = [];
|
|
1139
1177
|
constructor(t) {
|
|
1140
|
-
this.#t = t.hostName, this.#e = t.logger, this.#i = t.isInstalled, this.#s = t.report, this.#r = new
|
|
1178
|
+
this.#t = t.hostName, this.#e = t.logger, this.#i = t.isInstalled, this.#s = t.report, this.#r = new At(t.report);
|
|
1141
1179
|
}
|
|
1142
1180
|
readService(t, e) {
|
|
1143
1181
|
const i = this.#n.get(t);
|
|
1144
1182
|
return i?.has(e) ? { found: !0, value: i.get(e) } : { found: !1 };
|
|
1145
1183
|
}
|
|
1184
|
+
contributions(t) {
|
|
1185
|
+
return this.#r.view(t);
|
|
1186
|
+
}
|
|
1146
1187
|
captureConfigs(t) {
|
|
1147
1188
|
const e = /* @__PURE__ */ new Map();
|
|
1148
1189
|
for (const i of t) {
|
|
@@ -1152,46 +1193,46 @@ class Lt {
|
|
|
1152
1193
|
return e;
|
|
1153
1194
|
}
|
|
1154
1195
|
resetActivationState() {
|
|
1155
|
-
this.#n.clear(), this.#
|
|
1196
|
+
this.#n.clear(), this.#a = [];
|
|
1156
1197
|
}
|
|
1157
1198
|
commitActivationOrder(t) {
|
|
1158
|
-
this.#
|
|
1199
|
+
this.#a = t.slice();
|
|
1159
1200
|
}
|
|
1160
1201
|
deactivateAll() {
|
|
1161
|
-
return this.deactivate(new Set(this.#
|
|
1202
|
+
return this.deactivate(new Set(this.#a));
|
|
1162
1203
|
}
|
|
1163
1204
|
async activate(t, e, i, s) {
|
|
1164
|
-
const n = this.#
|
|
1205
|
+
const n = this.#c(s);
|
|
1165
1206
|
for (const o of t.layers) {
|
|
1166
1207
|
const a = o.filter(
|
|
1167
1208
|
(f) => e.has(f) && !f.instance
|
|
1168
1209
|
);
|
|
1169
1210
|
if (!a.length) continue;
|
|
1170
|
-
const
|
|
1211
|
+
const h = new AbortController(), c = await Promise.allSettled(
|
|
1171
1212
|
a.map(async (f) => {
|
|
1172
1213
|
try {
|
|
1173
|
-
const p = i.has(f) ? i.get(f) : await
|
|
1214
|
+
const p = i.has(f) ? i.get(f) : await X(
|
|
1174
1215
|
f.declaration.plugin.config,
|
|
1175
1216
|
f.declaration.config,
|
|
1176
1217
|
f.id
|
|
1177
1218
|
);
|
|
1178
|
-
return await this.#
|
|
1219
|
+
return await this.#d(
|
|
1179
1220
|
t,
|
|
1180
1221
|
f,
|
|
1181
1222
|
p,
|
|
1182
|
-
|
|
1223
|
+
h.signal,
|
|
1183
1224
|
n
|
|
1184
1225
|
);
|
|
1185
1226
|
} catch (p) {
|
|
1186
|
-
throw
|
|
1227
|
+
throw h.abort(p), p;
|
|
1187
1228
|
}
|
|
1188
1229
|
})
|
|
1189
|
-
), d =
|
|
1230
|
+
), d = qt(c, h.signal), l = c.filter(
|
|
1190
1231
|
(f) => f.status === "fulfilled"
|
|
1191
1232
|
).map((f) => f.value);
|
|
1192
1233
|
if (d.length) {
|
|
1193
|
-
const f = await this.#
|
|
1194
|
-
throw f.length ? new
|
|
1234
|
+
const f = await this.#l(l), p = d.length === 1 ? d[0] : new AggregateError(d, "Installation startup layer failed");
|
|
1235
|
+
throw f.length ? new N(
|
|
1195
1236
|
[p, ...f],
|
|
1196
1237
|
"Installation startup layer failed and could not be cleanly disposed"
|
|
1197
1238
|
) : p;
|
|
@@ -1200,8 +1241,8 @@ class Lt {
|
|
|
1200
1241
|
}
|
|
1201
1242
|
}
|
|
1202
1243
|
async deactivate(t) {
|
|
1203
|
-
const e = [], i = this.#
|
|
1204
|
-
this.#
|
|
1244
|
+
const e = [], i = this.#a.filter((s) => t.has(s)).reverse();
|
|
1245
|
+
this.#a = this.#a.filter(
|
|
1205
1246
|
(s) => !t.has(s)
|
|
1206
1247
|
);
|
|
1207
1248
|
for (const s of i) {
|
|
@@ -1242,49 +1283,49 @@ class Lt {
|
|
|
1242
1283
|
if (!i.ok) throw i.error;
|
|
1243
1284
|
return e.value;
|
|
1244
1285
|
}
|
|
1245
|
-
async #
|
|
1286
|
+
async #d(t, e, i, s, n) {
|
|
1246
1287
|
e.deactivate();
|
|
1247
|
-
const o = e.declaration.plugin, a = new
|
|
1288
|
+
const o = e.declaration.plugin, a = new D(n, e.id, { parentSignal: s });
|
|
1248
1289
|
try {
|
|
1249
|
-
const
|
|
1290
|
+
const h = this.#u(t, e, o, a), c = Object.freeze({
|
|
1250
1291
|
hostName: this.#t,
|
|
1251
1292
|
pluginName: o.name,
|
|
1252
1293
|
installationId: e.id,
|
|
1253
1294
|
groupId: e.groupId
|
|
1254
|
-
}, d = this.#
|
|
1255
|
-
for (const [p,
|
|
1295
|
+
}), d = this.#h(a, c, h), l = await o.setup(d, i), f = /* @__PURE__ */ new Map();
|
|
1296
|
+
for (const [p, st] of Object.entries(o.provides ?? {})) {
|
|
1256
1297
|
if (typeof l != "object" || l === null || !Object.hasOwn(l, p))
|
|
1257
1298
|
throw new u(
|
|
1258
1299
|
"SERVICE_NOT_RETURNED",
|
|
1259
1300
|
`Installation '${e.id}' did not return provided Service '${p}'`
|
|
1260
1301
|
);
|
|
1261
|
-
f.set(
|
|
1302
|
+
f.set(st.id, l[p]);
|
|
1262
1303
|
}
|
|
1263
1304
|
return Object.freeze({
|
|
1264
1305
|
installation: e,
|
|
1265
1306
|
instance: Object.freeze({ plugin: o, config: i, lifetime: a }),
|
|
1266
1307
|
services: f
|
|
1267
1308
|
});
|
|
1268
|
-
} catch (
|
|
1269
|
-
const
|
|
1309
|
+
} catch (h) {
|
|
1310
|
+
const c = e.fail(h);
|
|
1270
1311
|
try {
|
|
1271
1312
|
await a.dispose();
|
|
1272
1313
|
} catch (d) {
|
|
1273
|
-
throw new
|
|
1274
|
-
[
|
|
1314
|
+
throw new N(
|
|
1315
|
+
[c, d],
|
|
1275
1316
|
`Installation '${e.id}' failed to start and could not be cleanly disposed`
|
|
1276
1317
|
);
|
|
1277
1318
|
}
|
|
1278
|
-
throw
|
|
1319
|
+
throw c;
|
|
1279
1320
|
}
|
|
1280
1321
|
}
|
|
1281
1322
|
#f(t) {
|
|
1282
1323
|
for (const { installation: e, instance: i, services: s } of t)
|
|
1283
|
-
this.#n.set(e, s), e.activate(i), this.#
|
|
1324
|
+
this.#n.set(e, s), e.activate(i), this.#a.push(e);
|
|
1284
1325
|
for (const { instance: e } of t)
|
|
1285
1326
|
e.lifetime.publish(), e.lifetime.detachStartupSignal();
|
|
1286
1327
|
}
|
|
1287
|
-
async #
|
|
1328
|
+
async #l(t) {
|
|
1288
1329
|
const e = [];
|
|
1289
1330
|
for (const i of [...t].reverse())
|
|
1290
1331
|
try {
|
|
@@ -1294,42 +1335,42 @@ class Lt {
|
|
|
1294
1335
|
}
|
|
1295
1336
|
return e;
|
|
1296
1337
|
}
|
|
1297
|
-
#
|
|
1338
|
+
#u(t, e, i, s) {
|
|
1298
1339
|
const n = /* @__PURE__ */ Object.create(null);
|
|
1299
1340
|
for (const [o, a] of Object.entries(i.requires ?? {}))
|
|
1300
1341
|
if (a.kind === "optional") {
|
|
1301
|
-
const
|
|
1302
|
-
if (!
|
|
1342
|
+
const h = t.providerFor(e, a.service.id);
|
|
1343
|
+
if (!h) {
|
|
1303
1344
|
n[o] = void 0;
|
|
1304
1345
|
continue;
|
|
1305
1346
|
}
|
|
1306
|
-
const
|
|
1307
|
-
if (!
|
|
1347
|
+
const c = this.#n.get(h);
|
|
1348
|
+
if (!c?.has(a.service.id))
|
|
1308
1349
|
throw new u(
|
|
1309
1350
|
"SERVICE_UNAVAILABLE",
|
|
1310
1351
|
`Optional Service '${a.service.id}' is not active for Installation '${e.id}'`
|
|
1311
1352
|
);
|
|
1312
|
-
n[o] =
|
|
1353
|
+
n[o] = c.get(a.service.id);
|
|
1313
1354
|
} else if (a.kind === "service") {
|
|
1314
|
-
const
|
|
1315
|
-
if (!
|
|
1355
|
+
const h = t.providerFor(e, a.id), c = h ? this.#n.get(h) : void 0;
|
|
1356
|
+
if (!h || !c?.has(a.id))
|
|
1316
1357
|
throw new u(
|
|
1317
1358
|
"SERVICE_UNAVAILABLE",
|
|
1318
1359
|
`Service '${a.id}' is not active for Installation '${e.id}'`
|
|
1319
1360
|
);
|
|
1320
|
-
n[o] =
|
|
1361
|
+
n[o] = c.get(a.id);
|
|
1321
1362
|
} else
|
|
1322
1363
|
n[o] = this.#b(a, s);
|
|
1323
1364
|
return n;
|
|
1324
1365
|
}
|
|
1325
|
-
#
|
|
1366
|
+
#h(t, e, i) {
|
|
1326
1367
|
return Object.freeze({
|
|
1327
1368
|
...i,
|
|
1328
1369
|
get signal() {
|
|
1329
1370
|
return t.signal;
|
|
1330
1371
|
},
|
|
1331
|
-
meta:
|
|
1332
|
-
log:
|
|
1372
|
+
meta: e,
|
|
1373
|
+
log: t.contextLogger(e),
|
|
1333
1374
|
cleanup: t.cleanup.bind(t),
|
|
1334
1375
|
lifetime: t.lifetime.bind(t),
|
|
1335
1376
|
spawn: t.spawn.bind(t),
|
|
@@ -1338,22 +1379,23 @@ class Lt {
|
|
|
1338
1379
|
contribute: t.contribute.bind(t)
|
|
1339
1380
|
});
|
|
1340
1381
|
}
|
|
1341
|
-
#
|
|
1382
|
+
#c(t) {
|
|
1342
1383
|
return {
|
|
1343
1384
|
stageOn: (e, i, s, n) => this.#p(e, i, s, n, t),
|
|
1344
1385
|
emit: (e, i, s) => this.#g(e, i, s, t),
|
|
1345
1386
|
stageContribution: (e, i, s, n, o) => this.#v(e, i, s, n, o, t),
|
|
1387
|
+
writeLog: (e, i, s, n) => this.#e[e](i, s, ...n),
|
|
1346
1388
|
report: this.#s
|
|
1347
1389
|
};
|
|
1348
1390
|
}
|
|
1349
1391
|
#p(t, e, i, s, n) {
|
|
1350
|
-
return this.#w(t),
|
|
1392
|
+
return this.#w(t), b(e, "event"), n.remember(e), this.#o.stage(e.id, i, s);
|
|
1351
1393
|
}
|
|
1352
1394
|
#g(t, e, i, s) {
|
|
1353
|
-
return this.#w(t),
|
|
1395
|
+
return this.#w(t), b(e, "event"), s.remember(e), this.#o.emit(e.id, i);
|
|
1354
1396
|
}
|
|
1355
1397
|
#v(t, e, i, s, n, o) {
|
|
1356
|
-
return this.#w(t),
|
|
1398
|
+
return this.#w(t), b(e, "extensionPoint"), o.remember(e), this.#r.get(e).stage(t, i, s, n);
|
|
1357
1399
|
}
|
|
1358
1400
|
#b(t, e) {
|
|
1359
1401
|
return this.#r.get(t).view((i, s) => e.ownLease(i, s));
|
|
@@ -1363,35 +1405,43 @@ class Lt {
|
|
|
1363
1405
|
throw new Error(`Installation '${t}' is not installed`);
|
|
1364
1406
|
}
|
|
1365
1407
|
}
|
|
1366
|
-
function
|
|
1408
|
+
function qt(r, t) {
|
|
1367
1409
|
const e = [];
|
|
1368
1410
|
let i = !1;
|
|
1369
1411
|
for (const s of r)
|
|
1370
|
-
s.status !== "fulfilled" && (Object.is(s.reason, t.reason) ? (i || e.push(s.reason), i = !0) :
|
|
1412
|
+
s.status !== "fulfilled" && (Object.is(s.reason, t.reason) ? (i || e.push(s.reason), i = !0) : J(t, s.reason) || e.push(s.reason));
|
|
1371
1413
|
return e;
|
|
1372
1414
|
}
|
|
1373
|
-
class
|
|
1374
|
-
#t = new
|
|
1415
|
+
class Dt {
|
|
1416
|
+
#t = new dt();
|
|
1375
1417
|
#e;
|
|
1376
1418
|
#i;
|
|
1377
1419
|
constructor(t) {
|
|
1378
|
-
this.#e = new
|
|
1420
|
+
this.#e = new Mt(t);
|
|
1379
1421
|
}
|
|
1380
1422
|
get hasCommittedPlan() {
|
|
1381
1423
|
return this.#i !== void 0;
|
|
1382
1424
|
}
|
|
1383
1425
|
get(t, e) {
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1426
|
+
const i = ot(t), s = i ? t.service : t;
|
|
1427
|
+
if (b(s, "service"), this.#t.assertCompatible(s), e === "unavailable") throw U();
|
|
1428
|
+
const n = this.#a().provider(s.id);
|
|
1429
|
+
if (!n) {
|
|
1430
|
+
if (i) return;
|
|
1431
|
+
throw new u("SERVICE_UNAVAILABLE", `Service '${s.id}' is not active`);
|
|
1432
|
+
}
|
|
1433
|
+
const o = this.#e.readService(n, s.id);
|
|
1434
|
+
if (!o.found) {
|
|
1435
|
+
if (i) return;
|
|
1436
|
+
throw new u("SERVICE_UNAVAILABLE", `Service '${s.id}' is not active`);
|
|
1437
|
+
}
|
|
1438
|
+
return o.value;
|
|
1439
|
+
}
|
|
1440
|
+
contributions(t) {
|
|
1441
|
+
return b(t, "extensionPoint"), this.#t.remember(t), this.#e.contributions(t);
|
|
1392
1442
|
}
|
|
1393
1443
|
buildPlan(t) {
|
|
1394
|
-
return
|
|
1444
|
+
return M.build(t, this.#t.kinds);
|
|
1395
1445
|
}
|
|
1396
1446
|
async start(t) {
|
|
1397
1447
|
const e = this.#t.draft(t.contractKinds);
|
|
@@ -1407,7 +1457,7 @@ class Rt {
|
|
|
1407
1457
|
}
|
|
1408
1458
|
async transition(t, e, i) {
|
|
1409
1459
|
return this.#e.withContributionBatch(async () => {
|
|
1410
|
-
const s = this.#
|
|
1460
|
+
const s = this.#a(), n = s.affectedByTransitionTo(t, e);
|
|
1411
1461
|
let o, a;
|
|
1412
1462
|
try {
|
|
1413
1463
|
o = await this.#r(
|
|
@@ -1416,22 +1466,22 @@ class Rt {
|
|
|
1416
1466
|
} catch (d) {
|
|
1417
1467
|
throw i(), d;
|
|
1418
1468
|
}
|
|
1419
|
-
const
|
|
1420
|
-
if (
|
|
1469
|
+
const h = this.#e.captureConfigs(n), c = await this.#e.deactivate(n);
|
|
1470
|
+
if (c.length)
|
|
1421
1471
|
return a.discard(), this.#n(
|
|
1422
1472
|
i,
|
|
1423
|
-
|
|
1473
|
+
c,
|
|
1424
1474
|
"Installation change could not cleanly stop the affected Instances"
|
|
1425
1475
|
);
|
|
1426
1476
|
try {
|
|
1427
1477
|
return await this.#e.activate(t, n, o, a), a.commit(), this.#e.commitActivationOrder(t.order), this.#i = t, Object.freeze({ kind: "committed", affected: n });
|
|
1428
1478
|
} catch (d) {
|
|
1429
1479
|
const l = await this.#e.deactivate(n);
|
|
1430
|
-
return a.discard(), d instanceof
|
|
1480
|
+
return a.discard(), d instanceof N || l.length ? this.#n(
|
|
1431
1481
|
i,
|
|
1432
1482
|
[d, ...l],
|
|
1433
1483
|
"Installation change failed and its partial activation could not be cleanly disposed"
|
|
1434
|
-
) : this.#
|
|
1484
|
+
) : this.#o(i, s, n, h, [
|
|
1435
1485
|
d,
|
|
1436
1486
|
...l
|
|
1437
1487
|
]);
|
|
@@ -1453,15 +1503,15 @@ class Rt {
|
|
|
1453
1503
|
const s = await this.#e.deactivateAll();
|
|
1454
1504
|
throw this.#i = void 0, new AggregateError([...e, ...s], i);
|
|
1455
1505
|
}
|
|
1456
|
-
async #
|
|
1506
|
+
async #o(t, e, i, s, n) {
|
|
1457
1507
|
t();
|
|
1458
1508
|
const o = this.#t.draft(e.contractKinds);
|
|
1459
1509
|
try {
|
|
1460
1510
|
await this.#e.activate(e, i, s, o), o.commit(), this.#e.commitActivationOrder(e.order), this.#i = e;
|
|
1461
|
-
} catch (
|
|
1462
|
-
const
|
|
1511
|
+
} catch (h) {
|
|
1512
|
+
const c = await this.#e.deactivateAll();
|
|
1463
1513
|
throw o.discard(), this.#i = void 0, new AggregateError(
|
|
1464
|
-
[...n,
|
|
1514
|
+
[...n, h, ...c],
|
|
1465
1515
|
"Installation change failed and the previous Instances could not be restored"
|
|
1466
1516
|
);
|
|
1467
1517
|
}
|
|
@@ -1474,14 +1524,14 @@ class Rt {
|
|
|
1474
1524
|
try {
|
|
1475
1525
|
e.set(
|
|
1476
1526
|
i,
|
|
1477
|
-
await
|
|
1527
|
+
await X(
|
|
1478
1528
|
i.declaration.plugin.config,
|
|
1479
1529
|
i.declaration.config,
|
|
1480
1530
|
i.id
|
|
1481
1531
|
)
|
|
1482
1532
|
);
|
|
1483
1533
|
} catch (s) {
|
|
1484
|
-
throw
|
|
1534
|
+
throw $(
|
|
1485
1535
|
s,
|
|
1486
1536
|
"INSTALLATION_UNAVAILABLE",
|
|
1487
1537
|
`Installation '${i.id}' failed with a non-Error value`
|
|
@@ -1489,15 +1539,15 @@ class Rt {
|
|
|
1489
1539
|
}
|
|
1490
1540
|
return e;
|
|
1491
1541
|
}
|
|
1492
|
-
#
|
|
1493
|
-
if (!this.#i) throw
|
|
1542
|
+
#a() {
|
|
1543
|
+
if (!this.#i) throw U();
|
|
1494
1544
|
return this.#i;
|
|
1495
1545
|
}
|
|
1496
1546
|
}
|
|
1497
|
-
function
|
|
1547
|
+
function U() {
|
|
1498
1548
|
return new u("SERVICE_UNAVAILABLE", "Host services are not active");
|
|
1499
1549
|
}
|
|
1500
|
-
class
|
|
1550
|
+
class Gt {
|
|
1501
1551
|
#t;
|
|
1502
1552
|
#e;
|
|
1503
1553
|
#i;
|
|
@@ -1518,16 +1568,16 @@ class Nt {
|
|
|
1518
1568
|
groupId: o.groupId,
|
|
1519
1569
|
status: o.status,
|
|
1520
1570
|
requires: Object.freeze(
|
|
1521
|
-
Object.values(o.declaration.plugin.requires ?? {}).map((
|
|
1571
|
+
Object.values(o.declaration.plugin.requires ?? {}).map((c) => c.kind === "optional" ? c.service.id : c.id)
|
|
1522
1572
|
),
|
|
1523
1573
|
provides: Object.freeze(
|
|
1524
|
-
Object.values(o.declaration.plugin.provides ?? {}).map((
|
|
1574
|
+
Object.values(o.declaration.plugin.provides ?? {}).map((c) => c.id)
|
|
1525
1575
|
),
|
|
1526
1576
|
...o.instance ? { lifetime: o.instance.lifetime.diagnostics } : {}
|
|
1527
|
-
},
|
|
1577
|
+
}, h = o.error;
|
|
1528
1578
|
s.set(
|
|
1529
1579
|
o.id,
|
|
1530
|
-
Object.freeze(
|
|
1580
|
+
Object.freeze(h === void 0 ? a : { ...a, error: h })
|
|
1531
1581
|
);
|
|
1532
1582
|
}
|
|
1533
1583
|
const n = /* @__PURE__ */ new Map();
|
|
@@ -1542,28 +1592,28 @@ class Nt {
|
|
|
1542
1592
|
name: this.#t,
|
|
1543
1593
|
status: t,
|
|
1544
1594
|
revision: this.#s,
|
|
1545
|
-
installations: new
|
|
1546
|
-
groups: new
|
|
1595
|
+
installations: new S(s),
|
|
1596
|
+
groups: new S(n)
|
|
1547
1597
|
});
|
|
1548
1598
|
}
|
|
1549
1599
|
}
|
|
1550
|
-
function
|
|
1600
|
+
function k(r, t, e = {}) {
|
|
1551
1601
|
if (!r || typeof r != "object" || Array.isArray(r))
|
|
1552
|
-
throw
|
|
1602
|
+
throw E(e, `${t} must be a plain record`);
|
|
1553
1603
|
const i = Object.getPrototypeOf(r);
|
|
1554
1604
|
if (i !== Object.prototype && i !== null)
|
|
1555
|
-
throw
|
|
1605
|
+
throw E(e, `${t} must be a plain record`);
|
|
1556
1606
|
for (const s of Reflect.ownKeys(r)) {
|
|
1557
1607
|
if (typeof s != "string" || !Object.prototype.propertyIsEnumerable.call(r, s))
|
|
1558
|
-
throw
|
|
1608
|
+
throw E(e, `${t} keys must be enumerable strings`);
|
|
1559
1609
|
if (e.fields && !e.fields.has(s))
|
|
1560
|
-
throw
|
|
1610
|
+
throw E(e, `${t}: unknown field '${s}'`);
|
|
1561
1611
|
}
|
|
1562
1612
|
}
|
|
1563
|
-
function
|
|
1613
|
+
function E(r, t) {
|
|
1564
1614
|
return r.createError?.(t) ?? new TypeError(t);
|
|
1565
1615
|
}
|
|
1566
|
-
const
|
|
1616
|
+
const Bt = /* @__PURE__ */ new Set([
|
|
1567
1617
|
"signal",
|
|
1568
1618
|
"meta",
|
|
1569
1619
|
"log",
|
|
@@ -1573,9 +1623,12 @@ const xt = /* @__PURE__ */ new Set([
|
|
|
1573
1623
|
"on",
|
|
1574
1624
|
"emit",
|
|
1575
1625
|
"contribute"
|
|
1576
|
-
]),
|
|
1577
|
-
function
|
|
1578
|
-
|
|
1626
|
+
]), Ft = /* @__PURE__ */ new Set(["name", "config", "requires", "provides", "setup"]);
|
|
1627
|
+
function pe(r) {
|
|
1628
|
+
return it(r);
|
|
1629
|
+
}
|
|
1630
|
+
function it(r) {
|
|
1631
|
+
Ut(r);
|
|
1579
1632
|
const t = Object.hasOwn(r, "name") ? r.name : void 0, e = Object.hasOwn(r, "config") ? r.config : void 0, i = Object.hasOwn(r, "requires") ? r.requires : void 0, s = Object.hasOwn(r, "provides") ? r.provides : void 0, n = Object.hasOwn(r, "setup") ? r.setup : void 0;
|
|
1580
1633
|
if (typeof t != "string" || !t.trim())
|
|
1581
1634
|
throw new TypeError("Plugin name must be a non-empty string");
|
|
@@ -1583,38 +1636,38 @@ function Vt(r) {
|
|
|
1583
1636
|
throw new TypeError("Plugin name cannot start or end with whitespace");
|
|
1584
1637
|
if (typeof n != "function")
|
|
1585
1638
|
throw new TypeError(`Plugin '${t}' must define setup()`);
|
|
1586
|
-
if (e !== void 0 && !
|
|
1639
|
+
if (e !== void 0 && !_t(e))
|
|
1587
1640
|
throw new TypeError(`Plugin '${t}' config must implement Standard Schema V1`);
|
|
1588
|
-
|
|
1589
|
-
const o = i ? Object.freeze({ ...i }) : void 0, a = s ? Object.freeze({ ...s }) : void 0,
|
|
1590
|
-
for (const [
|
|
1591
|
-
if (!
|
|
1592
|
-
if (
|
|
1641
|
+
_(i, t, "requires"), _(s, t, "provides");
|
|
1642
|
+
const o = i ? Object.freeze({ ...i }) : void 0, a = s ? Object.freeze({ ...s }) : void 0, h = /* @__PURE__ */ new Map();
|
|
1643
|
+
for (const [c, d] of Object.entries(o ?? {})) {
|
|
1644
|
+
if (!c.trim()) throw new TypeError("Plugin requirement alias cannot be empty");
|
|
1645
|
+
if (c !== c.trim())
|
|
1593
1646
|
throw new TypeError("Plugin requirement alias cannot start or end with whitespace");
|
|
1594
|
-
if (
|
|
1595
|
-
throw new TypeError(`Plugin requirement '${
|
|
1647
|
+
if (Bt.has(c))
|
|
1648
|
+
throw new TypeError(`Plugin requirement '${c}' conflicts with the context API`);
|
|
1596
1649
|
if (!d || typeof d != "object")
|
|
1597
|
-
throw new TypeError(`Plugin requirement '${
|
|
1650
|
+
throw new TypeError(`Plugin requirement '${c}' is not a contract`);
|
|
1598
1651
|
if (d.kind === "optional") {
|
|
1599
|
-
if (!
|
|
1600
|
-
throw new TypeError(`Optional requirement '${
|
|
1601
|
-
} else if (!
|
|
1602
|
-
throw new TypeError(`Plugin requirement '${
|
|
1603
|
-
|
|
1652
|
+
if (!v(d.service, "service"))
|
|
1653
|
+
throw new TypeError(`Optional requirement '${c}' must wrap a Service`);
|
|
1654
|
+
} else if (!v(d, "service") && !v(d, "extensionPoint"))
|
|
1655
|
+
throw new TypeError(`Plugin requirement '${c}' must be a Service or ExtensionPoint`);
|
|
1656
|
+
H(
|
|
1604
1657
|
t,
|
|
1605
|
-
c,
|
|
1606
|
-
"requirement",
|
|
1607
1658
|
h,
|
|
1659
|
+
"requirement",
|
|
1660
|
+
c,
|
|
1608
1661
|
d.kind === "optional" ? d.service : d
|
|
1609
1662
|
);
|
|
1610
1663
|
}
|
|
1611
|
-
for (const [
|
|
1612
|
-
if (!
|
|
1613
|
-
if (
|
|
1664
|
+
for (const [c, d] of Object.entries(a ?? {})) {
|
|
1665
|
+
if (!c.trim()) throw new TypeError("Plugin provision alias cannot be empty");
|
|
1666
|
+
if (c !== c.trim())
|
|
1614
1667
|
throw new TypeError("Plugin provision alias cannot start or end with whitespace");
|
|
1615
|
-
if (!
|
|
1616
|
-
throw new TypeError(`Plugin provision '${
|
|
1617
|
-
|
|
1668
|
+
if (!v(d, "service"))
|
|
1669
|
+
throw new TypeError(`Plugin provision '${c}' must be a Service`);
|
|
1670
|
+
H(t, h, "provision", c, d);
|
|
1618
1671
|
}
|
|
1619
1672
|
return Object.freeze({
|
|
1620
1673
|
name: t,
|
|
@@ -1624,20 +1677,20 @@ function Vt(r) {
|
|
|
1624
1677
|
setup: n
|
|
1625
1678
|
});
|
|
1626
1679
|
}
|
|
1627
|
-
function
|
|
1628
|
-
|
|
1680
|
+
function Ut(r) {
|
|
1681
|
+
k(r, "Plugin declaration", { fields: Ft });
|
|
1629
1682
|
}
|
|
1630
|
-
function
|
|
1683
|
+
function _t(r) {
|
|
1631
1684
|
if (!r || typeof r != "object" && typeof r != "function") return !1;
|
|
1632
1685
|
const t = r["~standard"];
|
|
1633
1686
|
if (!t || typeof t != "object") return !1;
|
|
1634
1687
|
const e = t;
|
|
1635
1688
|
return e.version === 1 && typeof e.vendor == "string" && typeof e.validate == "function";
|
|
1636
1689
|
}
|
|
1637
|
-
function
|
|
1638
|
-
r !== void 0 &&
|
|
1690
|
+
function _(r, t, e) {
|
|
1691
|
+
r !== void 0 && k(r, `Plugin '${t}' ${e}`);
|
|
1639
1692
|
}
|
|
1640
|
-
function
|
|
1693
|
+
function H(r, t, e, i, s) {
|
|
1641
1694
|
const n = t.get(s.id);
|
|
1642
1695
|
if (!n) {
|
|
1643
1696
|
t.set(s.id, { alias: i, kind: s.kind, role: e });
|
|
@@ -1645,38 +1698,38 @@ function U(r, t, e, i, s) {
|
|
|
1645
1698
|
}
|
|
1646
1699
|
if (n.kind !== s.kind)
|
|
1647
1700
|
throw new TypeError(
|
|
1648
|
-
`Plugin '${r}' uses Contract '${s.id}' as both ${
|
|
1701
|
+
`Plugin '${r}' uses Contract '${s.id}' as both ${L(n.kind)} and ${L(s.kind)}`
|
|
1649
1702
|
);
|
|
1650
|
-
const o =
|
|
1703
|
+
const o = L(s.kind);
|
|
1651
1704
|
throw n.role !== e ? new TypeError(
|
|
1652
1705
|
`Plugin '${r}' cannot both require and provide ${o} '${s.id}'`
|
|
1653
1706
|
) : new TypeError(
|
|
1654
1707
|
`Plugin '${r}' ${e} aliases '${n.alias}' and '${i}' reference the same ${o} '${s.id}'`
|
|
1655
1708
|
);
|
|
1656
1709
|
}
|
|
1657
|
-
function
|
|
1710
|
+
function L(r) {
|
|
1658
1711
|
return r === "extensionPoint" ? "ExtensionPoint" : r === "event" ? "Event" : "Service";
|
|
1659
1712
|
}
|
|
1660
|
-
function
|
|
1661
|
-
return
|
|
1713
|
+
function K(r) {
|
|
1714
|
+
return it(r);
|
|
1662
1715
|
}
|
|
1663
|
-
const
|
|
1664
|
-
function
|
|
1665
|
-
|
|
1716
|
+
const Ht = /* @__PURE__ */ new Set(["plugin", "config"]), x = /* @__PURE__ */ new WeakMap();
|
|
1717
|
+
function Kt(r, t) {
|
|
1718
|
+
x.get(r)?.(t);
|
|
1666
1719
|
}
|
|
1667
|
-
class
|
|
1720
|
+
class Wt {
|
|
1668
1721
|
#t = /* @__PURE__ */ new Map();
|
|
1669
1722
|
#e;
|
|
1670
1723
|
constructor(t) {
|
|
1671
|
-
this.#e = { phase: "open", port: t },
|
|
1724
|
+
this.#e = { phase: "open", port: t }, x.set(this, (e) => this.#i(e)), Object.freeze(this);
|
|
1672
1725
|
}
|
|
1673
1726
|
install(t, ...e) {
|
|
1674
|
-
const i = this.#n(), s =
|
|
1727
|
+
const i = this.#n(), s = K(t), n = i.create(s, e[0]);
|
|
1675
1728
|
return this.#s({ kind: "install", installation: n.record }), n.publicInstallation;
|
|
1676
1729
|
}
|
|
1677
1730
|
update(t, e) {
|
|
1678
1731
|
const i = this.#n();
|
|
1679
|
-
|
|
1732
|
+
k(e, "Installation update", { fields: Ht });
|
|
1680
1733
|
const s = Object.hasOwn(e, "plugin"), n = Object.hasOwn(e, "config");
|
|
1681
1734
|
if (!s && !n)
|
|
1682
1735
|
throw new TypeError("Installation update must include 'plugin' or 'config'");
|
|
@@ -1685,16 +1738,16 @@ class Ft {
|
|
|
1685
1738
|
if (s) {
|
|
1686
1739
|
const d = e.plugin;
|
|
1687
1740
|
if (!d) throw new TypeError("Installation update 'plugin' must be a Plugin");
|
|
1688
|
-
a =
|
|
1741
|
+
a = K(d);
|
|
1689
1742
|
}
|
|
1690
|
-
let
|
|
1691
|
-
a && n ?
|
|
1692
|
-
const
|
|
1693
|
-
|
|
1743
|
+
let h;
|
|
1744
|
+
a && n ? h = { kind: "plugin-and-config", plugin: a, config: e.config } : a ? h = { kind: "plugin", plugin: a } : h = { kind: "config", config: e.config };
|
|
1745
|
+
const c = { kind: "update", installation: o, declaration: h };
|
|
1746
|
+
this.#s(c);
|
|
1694
1747
|
}
|
|
1695
1748
|
remove(t) {
|
|
1696
1749
|
const e = this.#n();
|
|
1697
|
-
|
|
1750
|
+
this.#s({ kind: "remove", installation: e.resolve(t) });
|
|
1698
1751
|
}
|
|
1699
1752
|
commit() {
|
|
1700
1753
|
const t = this.#e;
|
|
@@ -1711,7 +1764,7 @@ class Ft {
|
|
|
1711
1764
|
} catch (n) {
|
|
1712
1765
|
for (const o of e)
|
|
1713
1766
|
o.kind === "install" && i.discard(o.installation, n);
|
|
1714
|
-
return this.#
|
|
1767
|
+
return this.#o(Promise.reject(n));
|
|
1715
1768
|
}
|
|
1716
1769
|
let s;
|
|
1717
1770
|
try {
|
|
@@ -1719,7 +1772,7 @@ class Ft {
|
|
|
1719
1772
|
} catch (n) {
|
|
1720
1773
|
s = Promise.reject(n);
|
|
1721
1774
|
}
|
|
1722
|
-
return this.#
|
|
1775
|
+
return this.#o(s);
|
|
1723
1776
|
}
|
|
1724
1777
|
#i(t) {
|
|
1725
1778
|
const e = this.#e;
|
|
@@ -1743,14 +1796,14 @@ class Ft {
|
|
|
1743
1796
|
throw new TypeError(`Cannot modify a ${t.phase} ChangeSet`);
|
|
1744
1797
|
return t.port;
|
|
1745
1798
|
}
|
|
1746
|
-
#
|
|
1799
|
+
#o(t) {
|
|
1747
1800
|
return this.#e = { phase: "submitted", promise: t }, this.#r(), t;
|
|
1748
1801
|
}
|
|
1749
1802
|
#r() {
|
|
1750
|
-
this.#t.clear(),
|
|
1803
|
+
this.#t.clear(), x.delete(this);
|
|
1751
1804
|
}
|
|
1752
1805
|
}
|
|
1753
|
-
class
|
|
1806
|
+
class Yt {
|
|
1754
1807
|
#t;
|
|
1755
1808
|
constructor(t, e, i) {
|
|
1756
1809
|
this.#t = { phase: "open", draft: t, discard: e, normalize: i };
|
|
@@ -1761,7 +1814,7 @@ class Ut {
|
|
|
1761
1814
|
requireDraft() {
|
|
1762
1815
|
const t = this.#t;
|
|
1763
1816
|
if (t.phase === "failed") throw t.error;
|
|
1764
|
-
if (t.phase === "sealed") throw
|
|
1817
|
+
if (t.phase === "sealed") throw z();
|
|
1765
1818
|
return t.draft;
|
|
1766
1819
|
}
|
|
1767
1820
|
assertOpen() {
|
|
@@ -1770,7 +1823,7 @@ class Ut {
|
|
|
1770
1823
|
fail(t) {
|
|
1771
1824
|
const e = this.#t;
|
|
1772
1825
|
if (e.phase === "failed") return e.error;
|
|
1773
|
-
if (e.phase === "sealed") throw
|
|
1826
|
+
if (e.phase === "sealed") throw z();
|
|
1774
1827
|
const i = e.normalize(t);
|
|
1775
1828
|
return this.#t = {
|
|
1776
1829
|
phase: "failed",
|
|
@@ -1782,7 +1835,7 @@ class Ut {
|
|
|
1782
1835
|
seal() {
|
|
1783
1836
|
const t = this.#t;
|
|
1784
1837
|
if (t.phase === "failed") throw t.error;
|
|
1785
|
-
if (t.phase === "sealed") throw
|
|
1838
|
+
if (t.phase === "sealed") throw z();
|
|
1786
1839
|
return this.#t = { phase: "sealed" }, t.draft;
|
|
1787
1840
|
}
|
|
1788
1841
|
discard(t) {
|
|
@@ -1792,10 +1845,10 @@ class Ut {
|
|
|
1792
1845
|
this.#t = { phase: "sealed" }, e.discard(e.draft, i);
|
|
1793
1846
|
}
|
|
1794
1847
|
}
|
|
1795
|
-
function
|
|
1848
|
+
function z() {
|
|
1796
1849
|
return new Error("Group configuration has been sealed");
|
|
1797
1850
|
}
|
|
1798
|
-
class
|
|
1851
|
+
class I {
|
|
1799
1852
|
constructor(t, e, i) {
|
|
1800
1853
|
this.id = t, this.name = e, this.#e = { phase: "attached", parent: i };
|
|
1801
1854
|
}
|
|
@@ -1804,7 +1857,7 @@ class S {
|
|
|
1804
1857
|
#t = /* @__PURE__ */ new Map();
|
|
1805
1858
|
#e;
|
|
1806
1859
|
static root(t) {
|
|
1807
|
-
return new
|
|
1860
|
+
return new I("/", t, void 0);
|
|
1808
1861
|
}
|
|
1809
1862
|
get attached() {
|
|
1810
1863
|
return this.#e.phase !== "detached";
|
|
@@ -1817,9 +1870,9 @@ class S {
|
|
|
1817
1870
|
return t.phase === "detached" ? void 0 : t.parent;
|
|
1818
1871
|
}
|
|
1819
1872
|
create(t) {
|
|
1820
|
-
if (this.assertAttached(),
|
|
1873
|
+
if (this.assertAttached(), Qt(t), this.#t.has(t))
|
|
1821
1874
|
throw new TypeError(`Group '${this.#i(t)}' already exists`);
|
|
1822
|
-
const e = new
|
|
1875
|
+
const e = new I(this.#i(t), t, this);
|
|
1823
1876
|
return this.#t.set(t, e), e;
|
|
1824
1877
|
}
|
|
1825
1878
|
contains(t) {
|
|
@@ -1851,14 +1904,14 @@ class S {
|
|
|
1851
1904
|
return this.id === "/" ? `/${t}` : `${this.id}/${t}`;
|
|
1852
1905
|
}
|
|
1853
1906
|
}
|
|
1854
|
-
function
|
|
1907
|
+
function Qt(r) {
|
|
1855
1908
|
if (typeof r != "string" || !r.trim())
|
|
1856
1909
|
throw new TypeError("Group name must be a non-empty string");
|
|
1857
1910
|
if (r !== r.trim())
|
|
1858
1911
|
throw new TypeError("Group name cannot start or end with whitespace");
|
|
1859
1912
|
if (r.includes("/")) throw new TypeError("Group name cannot contain '/'");
|
|
1860
1913
|
}
|
|
1861
|
-
class
|
|
1914
|
+
class W {
|
|
1862
1915
|
constructor(t, e, i) {
|
|
1863
1916
|
this.node = t, this.#t = { phase: e }, this.#e = i;
|
|
1864
1917
|
}
|
|
@@ -1885,7 +1938,7 @@ class H {
|
|
|
1885
1938
|
this.#i(s) && (this.#t = { phase: "established" }, this.#e?.());
|
|
1886
1939
|
},
|
|
1887
1940
|
(o) => {
|
|
1888
|
-
const a =
|
|
1941
|
+
const a = $(
|
|
1889
1942
|
o,
|
|
1890
1943
|
"GROUP_UNAVAILABLE",
|
|
1891
1944
|
`Group '${this.node.id}' operation failed with a non-Error value`
|
|
@@ -1909,15 +1962,15 @@ class H {
|
|
|
1909
1962
|
return e.phase === "pending" && e.attempt === t;
|
|
1910
1963
|
}
|
|
1911
1964
|
}
|
|
1912
|
-
function
|
|
1965
|
+
function A(r) {
|
|
1913
1966
|
return new u("GROUP_REMOVED", `Group '${r.id}' has been removed`);
|
|
1914
1967
|
}
|
|
1915
|
-
const
|
|
1916
|
-
class
|
|
1968
|
+
const C = /* @__PURE__ */ new WeakMap();
|
|
1969
|
+
class Jt {
|
|
1917
1970
|
#t;
|
|
1918
1971
|
#e;
|
|
1919
1972
|
constructor(t, e, i) {
|
|
1920
|
-
this.#t = e, this.#e = i ? { phase: "configuring", coordinator: t, configuration: i } : { phase: "attached", coordinator: t },
|
|
1973
|
+
this.#t = e, this.#e = i ? { phase: "configuring", coordinator: t, configuration: i } : { phase: "attached", coordinator: t }, C.set(this, {
|
|
1921
1974
|
finishConfiguration: () => {
|
|
1922
1975
|
const s = this.#e;
|
|
1923
1976
|
s.phase === "configuring" && (this.#e = { phase: "attached", coordinator: s.coordinator });
|
|
@@ -1939,7 +1992,7 @@ class Ht {
|
|
|
1939
1992
|
}
|
|
1940
1993
|
ready() {
|
|
1941
1994
|
const t = this.#e;
|
|
1942
|
-
return t.phase === "revoked" ? Promise.reject(
|
|
1995
|
+
return t.phase === "revoked" ? Promise.reject(A(this.#t)) : t.coordinator.ready(this.#t);
|
|
1943
1996
|
}
|
|
1944
1997
|
install(t, ...e) {
|
|
1945
1998
|
const i = this.#e;
|
|
@@ -1967,19 +2020,19 @@ class Ht {
|
|
|
1967
2020
|
}
|
|
1968
2021
|
#i() {
|
|
1969
2022
|
const t = this.#e;
|
|
1970
|
-
if (t.phase === "revoked") throw
|
|
2023
|
+
if (t.phase === "revoked") throw A(this.#t);
|
|
1971
2024
|
return t.coordinator;
|
|
1972
2025
|
}
|
|
1973
2026
|
}
|
|
1974
|
-
class
|
|
2027
|
+
class Xt {
|
|
1975
2028
|
root;
|
|
1976
2029
|
#t;
|
|
1977
2030
|
#e = /* @__PURE__ */ new WeakMap();
|
|
1978
2031
|
#i = /* @__PURE__ */ new WeakMap();
|
|
1979
2032
|
constructor(t, e) {
|
|
1980
|
-
this.root =
|
|
2033
|
+
this.root = I.root(t), this.#t = e, this.#i.set(
|
|
1981
2034
|
this.root,
|
|
1982
|
-
new
|
|
2035
|
+
new W(this.root, "established", () => e.notifyChanged())
|
|
1983
2036
|
);
|
|
1984
2037
|
}
|
|
1985
2038
|
nodes() {
|
|
@@ -1987,10 +2040,10 @@ class Kt {
|
|
|
1987
2040
|
}
|
|
1988
2041
|
install(t, e, ...i) {
|
|
1989
2042
|
const s = this.change(t), n = s.install(e, ...i);
|
|
1990
|
-
return
|
|
2043
|
+
return Y(s.commit()), n;
|
|
1991
2044
|
}
|
|
1992
2045
|
change(t, e = "immediate") {
|
|
1993
|
-
return this.#r(t), new
|
|
2046
|
+
return this.#r(t), new Wt({
|
|
1994
2047
|
create: (i, s) => (this.#r(t), this.#t.createDraft(t, i, s)),
|
|
1995
2048
|
resolve: (i) => {
|
|
1996
2049
|
this.#r(t);
|
|
@@ -2004,7 +2057,7 @@ class Kt {
|
|
|
2004
2057
|
this.#r(t);
|
|
2005
2058
|
const s = this.#t.executeChanges(t, i);
|
|
2006
2059
|
for (const n of i) n.installation.trackReadiness(s);
|
|
2007
|
-
return i.length && e === "immediate" && this.#
|
|
2060
|
+
return i.length && e === "immediate" && this.#o(t, s), s;
|
|
2008
2061
|
},
|
|
2009
2062
|
attach: (i) => {
|
|
2010
2063
|
this.#r(t), this.#t.attachInstallation(i);
|
|
@@ -2015,35 +2068,35 @@ class Kt {
|
|
|
2015
2068
|
create(t, e, i, s) {
|
|
2016
2069
|
if (typeof i != "function") throw new TypeError("Group configure must be a function");
|
|
2017
2070
|
const n = t.create(e);
|
|
2018
|
-
this.#i.set(n, new
|
|
2019
|
-
const o = s === void 0, a = s ?? new
|
|
2071
|
+
this.#i.set(n, new W(n, "new", () => this.#t.notifyChanged()));
|
|
2072
|
+
const o = s === void 0, a = s ?? new Yt(
|
|
2020
2073
|
this.change(n, "deferred"),
|
|
2021
|
-
|
|
2022
|
-
(
|
|
2023
|
-
|
|
2074
|
+
Kt,
|
|
2075
|
+
(c) => $(
|
|
2076
|
+
c,
|
|
2024
2077
|
"GROUP_UNAVAILABLE",
|
|
2025
2078
|
`Group '${n.id}' configuration failed with a non-Error value`
|
|
2026
2079
|
)
|
|
2027
|
-
),
|
|
2028
|
-
this.#e.set(n,
|
|
2080
|
+
), h = new Jt(this, n, a);
|
|
2081
|
+
this.#e.set(n, h);
|
|
2029
2082
|
try {
|
|
2030
|
-
const
|
|
2031
|
-
|
|
2083
|
+
const c = i(h);
|
|
2084
|
+
te(c) && Zt(c);
|
|
2032
2085
|
const d = a.failure;
|
|
2033
2086
|
if (d) throw d;
|
|
2034
|
-
} catch (
|
|
2035
|
-
const d = a.fail(
|
|
2036
|
-
throw n.detach(), this.#
|
|
2087
|
+
} catch (c) {
|
|
2088
|
+
const d = a.fail(c), l = n.walk();
|
|
2089
|
+
throw n.detach(), this.#a(l), o && a.discard(d), this.#t.notifyChanged(), d;
|
|
2037
2090
|
}
|
|
2038
2091
|
if (o) {
|
|
2039
|
-
const
|
|
2092
|
+
const c = a.seal().commit();
|
|
2040
2093
|
for (const d of n.walk()) {
|
|
2041
2094
|
const l = this.#e.get(d);
|
|
2042
|
-
l &&
|
|
2095
|
+
l && C.get(l)?.finishConfiguration(), this.#o(d, c);
|
|
2043
2096
|
}
|
|
2044
|
-
|
|
2097
|
+
Y(c);
|
|
2045
2098
|
}
|
|
2046
|
-
return this.#t.notifyChanged(),
|
|
2099
|
+
return this.#t.notifyChanged(), h;
|
|
2047
2100
|
}
|
|
2048
2101
|
async ready(t) {
|
|
2049
2102
|
await this.#r(t).ready(async () => {
|
|
@@ -2057,15 +2110,15 @@ class Kt {
|
|
|
2057
2110
|
if (t === this.root) throw new TypeError("The root Group cannot be removed");
|
|
2058
2111
|
return t.attached ? this.#t.runExclusive(async () => {
|
|
2059
2112
|
if (!t.attached) {
|
|
2060
|
-
this.#
|
|
2113
|
+
this.#a([t]);
|
|
2061
2114
|
return;
|
|
2062
2115
|
}
|
|
2063
2116
|
const e = t.walk(), i = this.#s(t).map((s) => ({
|
|
2064
2117
|
kind: "remove",
|
|
2065
2118
|
installation: s
|
|
2066
2119
|
}));
|
|
2067
|
-
await this.#t.removeInstallations(i), t.detach(), this.#
|
|
2068
|
-
}) : (this.#
|
|
2120
|
+
await this.#t.removeInstallations(i), t.detach(), this.#a(e), this.#t.notifyChanged();
|
|
2121
|
+
}) : (this.#a([t]), Promise.resolve());
|
|
2069
2122
|
}
|
|
2070
2123
|
#s(t) {
|
|
2071
2124
|
return [...this.#t.installations()].filter(
|
|
@@ -2076,37 +2129,37 @@ class Kt {
|
|
|
2076
2129
|
const e = this.#s(t);
|
|
2077
2130
|
return e.some((i) => i.status === "failed") ? "failed" : e.some((i) => i.status === "stopping") ? "stopping" : e.length && e.every((i) => i.status === "active") ? "active" : e.length ? "pending" : "active";
|
|
2078
2131
|
}
|
|
2079
|
-
#
|
|
2132
|
+
#o(t, e) {
|
|
2080
2133
|
this.#r(t).track(e);
|
|
2081
2134
|
}
|
|
2082
2135
|
#r(t) {
|
|
2083
2136
|
const e = this.#i.get(t);
|
|
2084
|
-
if (!t.attached || !e) throw
|
|
2137
|
+
if (!t.attached || !e) throw A(t);
|
|
2085
2138
|
return e;
|
|
2086
2139
|
}
|
|
2087
|
-
#
|
|
2140
|
+
#a(t) {
|
|
2088
2141
|
for (const e of t) {
|
|
2089
2142
|
this.#i.get(e)?.release(), this.#i.delete(e);
|
|
2090
2143
|
const i = this.#e.get(e);
|
|
2091
|
-
i && (
|
|
2144
|
+
i && (C.get(i)?.revoke(), C.delete(i)), this.#e.delete(e);
|
|
2092
2145
|
}
|
|
2093
2146
|
}
|
|
2094
2147
|
}
|
|
2095
|
-
function
|
|
2148
|
+
function Y(r) {
|
|
2096
2149
|
Promise.resolve(r).catch(() => {
|
|
2097
2150
|
});
|
|
2098
2151
|
}
|
|
2099
|
-
function
|
|
2152
|
+
function Zt(r) {
|
|
2100
2153
|
throw Promise.resolve(r).catch(() => {
|
|
2101
2154
|
}), new TypeError("Group configure must be synchronous");
|
|
2102
2155
|
}
|
|
2103
|
-
function
|
|
2156
|
+
function te(r) {
|
|
2104
2157
|
return r === null || typeof r != "object" && typeof r != "function" ? !1 : typeof r.then == "function";
|
|
2105
2158
|
}
|
|
2106
|
-
function
|
|
2159
|
+
function Q(r, t) {
|
|
2107
2160
|
return Object.freeze({ plugin: r, config: t });
|
|
2108
2161
|
}
|
|
2109
|
-
class
|
|
2162
|
+
class ee {
|
|
2110
2163
|
constructor(t, e, i, s) {
|
|
2111
2164
|
this.id = t, this.index = e, this.groupId = i.id, this.#i = { declaration: s, group: i, notifyChanged: void 0 };
|
|
2112
2165
|
}
|
|
@@ -2118,7 +2171,7 @@ class Qt {
|
|
|
2118
2171
|
groupId;
|
|
2119
2172
|
#s = /* @__PURE__ */ new Set();
|
|
2120
2173
|
attach(t) {
|
|
2121
|
-
const e = this.#
|
|
2174
|
+
const e = this.#d();
|
|
2122
2175
|
if (e.notifyChanged) throw new Error(`Installation '${this.id}' is already attached`);
|
|
2123
2176
|
e.notifyChanged = t;
|
|
2124
2177
|
}
|
|
@@ -2136,18 +2189,18 @@ class Qt {
|
|
|
2136
2189
|
get error() {
|
|
2137
2190
|
const t = this.#t;
|
|
2138
2191
|
if (t.phase === "failed")
|
|
2139
|
-
return t.failure.retention === "live" ? t.failure.error :
|
|
2192
|
+
return t.failure.retention === "live" ? t.failure.error : se(t.failure.summary);
|
|
2140
2193
|
if (t.phase === "removed")
|
|
2141
2194
|
return new u("INSTALLATION_REMOVED", `Installation '${this.id}' has been removed`);
|
|
2142
2195
|
}
|
|
2143
2196
|
get group() {
|
|
2144
|
-
return this.#
|
|
2197
|
+
return this.#d().group;
|
|
2145
2198
|
}
|
|
2146
2199
|
get declaration() {
|
|
2147
|
-
return this.#
|
|
2200
|
+
return this.#d().declaration;
|
|
2148
2201
|
}
|
|
2149
2202
|
replaceDeclaration(t) {
|
|
2150
|
-
this.#
|
|
2203
|
+
this.#d().declaration = t;
|
|
2151
2204
|
}
|
|
2152
2205
|
ready() {
|
|
2153
2206
|
const t = this.#e;
|
|
@@ -2209,20 +2262,20 @@ class Qt {
|
|
|
2209
2262
|
this.#r({ phase: "pending" });
|
|
2210
2263
|
}
|
|
2211
2264
|
fail(t) {
|
|
2212
|
-
return this.#
|
|
2265
|
+
return this.#o(t);
|
|
2213
2266
|
}
|
|
2214
2267
|
discard(t) {
|
|
2215
|
-
const e = this.#
|
|
2268
|
+
const e = this.#a(t);
|
|
2216
2269
|
this.#r({
|
|
2217
2270
|
phase: "failed",
|
|
2218
|
-
failure: { retention: "summary", summary:
|
|
2271
|
+
failure: { retention: "summary", summary: ie(e) },
|
|
2219
2272
|
readiness: "settled"
|
|
2220
2273
|
});
|
|
2221
2274
|
for (const i of this.#s) i.reject(e);
|
|
2222
2275
|
this.#s.clear(), this.#e = void 0, this.#i = void 0;
|
|
2223
2276
|
}
|
|
2224
|
-
#
|
|
2225
|
-
const e = this.#
|
|
2277
|
+
#o(t) {
|
|
2278
|
+
const e = this.#a(t);
|
|
2226
2279
|
return this.#r({
|
|
2227
2280
|
phase: "failed",
|
|
2228
2281
|
failure: { retention: "live", error: e },
|
|
@@ -2235,36 +2288,36 @@ class Qt {
|
|
|
2235
2288
|
#r(t) {
|
|
2236
2289
|
this.#t = t, this.#i?.notifyChanged?.();
|
|
2237
2290
|
}
|
|
2238
|
-
#
|
|
2239
|
-
return
|
|
2291
|
+
#a(t) {
|
|
2292
|
+
return $(
|
|
2240
2293
|
t,
|
|
2241
2294
|
"INSTALLATION_UNAVAILABLE",
|
|
2242
2295
|
`Installation '${this.id}' failed with a non-Error value`
|
|
2243
2296
|
);
|
|
2244
2297
|
}
|
|
2245
|
-
#
|
|
2298
|
+
#d() {
|
|
2246
2299
|
const t = this.#i;
|
|
2247
2300
|
if (!t) throw new Error(`Installation '${this.id}' is no longer installed`);
|
|
2248
2301
|
return t;
|
|
2249
2302
|
}
|
|
2250
2303
|
}
|
|
2251
|
-
function
|
|
2304
|
+
function ie(r) {
|
|
2252
2305
|
return r instanceof u ? { category: "dougong", name: r.name, message: r.message, code: r.code } : {
|
|
2253
2306
|
category: r instanceof TypeError ? "typeError" : "error",
|
|
2254
2307
|
name: r.name,
|
|
2255
2308
|
message: r.message
|
|
2256
2309
|
};
|
|
2257
2310
|
}
|
|
2258
|
-
function
|
|
2311
|
+
function se(r) {
|
|
2259
2312
|
const t = r.category === "dougong" ? new u(r.code, r.message) : r.category === "typeError" ? new TypeError(r.message) : new Error(r.message);
|
|
2260
2313
|
return t.name = r.name, t;
|
|
2261
2314
|
}
|
|
2262
|
-
const
|
|
2263
|
-
class
|
|
2315
|
+
const O = /* @__PURE__ */ new WeakMap();
|
|
2316
|
+
class re {
|
|
2264
2317
|
#t;
|
|
2265
2318
|
#e = { phase: "draft" };
|
|
2266
2319
|
constructor(t) {
|
|
2267
|
-
this.#t = t,
|
|
2320
|
+
this.#t = t, O.set(this, {
|
|
2268
2321
|
attach: (e, i) => {
|
|
2269
2322
|
if (this.#e.phase !== "draft")
|
|
2270
2323
|
throw new Error(`Installation '${this.#t.id}' control is already sealed`);
|
|
@@ -2309,7 +2362,7 @@ class Zt {
|
|
|
2309
2362
|
);
|
|
2310
2363
|
}
|
|
2311
2364
|
}
|
|
2312
|
-
class
|
|
2365
|
+
class ne {
|
|
2313
2366
|
#t = /* @__PURE__ */ new Map();
|
|
2314
2367
|
#e = /* @__PURE__ */ new WeakMap();
|
|
2315
2368
|
#i = /* @__PURE__ */ new WeakMap();
|
|
@@ -2329,12 +2382,12 @@ class te {
|
|
|
2329
2382
|
}
|
|
2330
2383
|
create(t, e, i) {
|
|
2331
2384
|
t.assertAttached();
|
|
2332
|
-
const s = ++this.#n, n = new
|
|
2385
|
+
const s = ++this.#n, n = new ee(
|
|
2333
2386
|
`${e.name}:${s}`,
|
|
2334
2387
|
s,
|
|
2335
2388
|
t,
|
|
2336
|
-
|
|
2337
|
-
), o = new
|
|
2389
|
+
Q(e, i)
|
|
2390
|
+
), o = new re(n);
|
|
2338
2391
|
return this.#e.set(o, n), this.#i.set(n, o), { record: n, publicInstallation: o };
|
|
2339
2392
|
}
|
|
2340
2393
|
resolve(t) {
|
|
@@ -2345,7 +2398,7 @@ class te {
|
|
|
2345
2398
|
attach(t) {
|
|
2346
2399
|
const e = this.#i.get(t);
|
|
2347
2400
|
if (!e) throw new Error(`Installation '${t.id}' has no public facade`);
|
|
2348
|
-
const i =
|
|
2401
|
+
const i = O.get(e);
|
|
2349
2402
|
if (!i) throw new Error(`Installation '${t.id}' has no draft control`);
|
|
2350
2403
|
t.attach(this.#s.notifyChanged), i.attach(
|
|
2351
2404
|
(s) => this.#s.update(t, e, s),
|
|
@@ -2372,18 +2425,18 @@ class te {
|
|
|
2372
2425
|
this.#t.set(e.installation.id, e.installation);
|
|
2373
2426
|
else if (e.kind === "update") {
|
|
2374
2427
|
const i = e.installation.declaration, s = e.declaration.kind === "config" ? i.plugin : e.declaration.plugin, n = e.declaration.kind === "plugin" ? i.config : e.declaration.config;
|
|
2375
|
-
e.installation.replaceDeclaration(
|
|
2428
|
+
e.installation.replaceDeclaration(Q(s, n));
|
|
2376
2429
|
} else this.contains(e.installation) && this.#t.delete(e.installation.id);
|
|
2377
2430
|
}
|
|
2378
2431
|
settleChanges(t, e) {
|
|
2379
2432
|
for (const i of t)
|
|
2380
|
-
i.kind === "remove" ? (i.installation.remove(), i.installation.settleReady(), this.#
|
|
2433
|
+
i.kind === "remove" ? (i.installation.remove(), i.installation.settleReady(), this.#o(i.installation)) : e || i.installation.deactivate();
|
|
2381
2434
|
}
|
|
2382
2435
|
settleReadiness(t) {
|
|
2383
2436
|
for (const e of t) e.settleReady();
|
|
2384
2437
|
}
|
|
2385
2438
|
discard(t, e) {
|
|
2386
|
-
t.discard(e), this.#
|
|
2439
|
+
t.discard(e), this.#o(t);
|
|
2387
2440
|
}
|
|
2388
2441
|
capture() {
|
|
2389
2442
|
return [...this.#t].map(([t, e]) => ({
|
|
@@ -2397,12 +2450,12 @@ class te {
|
|
|
2397
2450
|
for (const e of t)
|
|
2398
2451
|
e.installation.replaceDeclaration(e.declaration), this.#t.set(e.id, e.installation);
|
|
2399
2452
|
}
|
|
2400
|
-
#
|
|
2453
|
+
#o(t) {
|
|
2401
2454
|
const e = this.#i.get(t);
|
|
2402
|
-
e && (
|
|
2455
|
+
e && (O.get(e)?.revoke(), O.delete(e)), this.#i.delete(t);
|
|
2403
2456
|
}
|
|
2404
2457
|
}
|
|
2405
|
-
class
|
|
2458
|
+
class oe {
|
|
2406
2459
|
#t = Promise.resolve();
|
|
2407
2460
|
get settled() {
|
|
2408
2461
|
return this.#t;
|
|
@@ -2419,8 +2472,8 @@ class ee {
|
|
|
2419
2472
|
), e;
|
|
2420
2473
|
}
|
|
2421
2474
|
}
|
|
2422
|
-
const
|
|
2423
|
-
class
|
|
2475
|
+
const ae = console, ce = /* @__PURE__ */ new Set(["name", "logger", "onError"]);
|
|
2476
|
+
class he {
|
|
2424
2477
|
name;
|
|
2425
2478
|
diagnostics;
|
|
2426
2479
|
#t;
|
|
@@ -2428,11 +2481,11 @@ class re {
|
|
|
2428
2481
|
#i;
|
|
2429
2482
|
#s;
|
|
2430
2483
|
#n;
|
|
2431
|
-
#
|
|
2484
|
+
#o;
|
|
2432
2485
|
#r = "idle";
|
|
2433
|
-
#
|
|
2486
|
+
#a = new oe();
|
|
2434
2487
|
constructor(t = {}) {
|
|
2435
|
-
|
|
2488
|
+
k(t, "Host options", { fields: ce });
|
|
2436
2489
|
const e = Object.hasOwn(t, "name") ? t.name : void 0, i = Object.hasOwn(t, "logger") ? t.logger : void 0, s = Object.hasOwn(t, "onError") ? t.onError : void 0, n = e ?? "host";
|
|
2437
2490
|
if (typeof n != "string" || !n.trim())
|
|
2438
2491
|
throw new TypeError("Host name must be a non-empty string");
|
|
@@ -2440,31 +2493,37 @@ class re {
|
|
|
2440
2493
|
throw new TypeError("Host name cannot start or end with whitespace");
|
|
2441
2494
|
if (s !== void 0 && typeof s != "function")
|
|
2442
2495
|
throw new TypeError("Host onError must be a function");
|
|
2443
|
-
if (i !== void 0 &&
|
|
2496
|
+
if (i !== void 0 && !zt(i))
|
|
2444
2497
|
throw new TypeError("Host logger must implement debug/info/warn/error");
|
|
2445
|
-
this.name = n, this.#i = i ??
|
|
2498
|
+
this.name = n, this.#i = i ?? ae, this.#n = s ?? ((o) => this.#i.error(o)), this.#t = new ne({
|
|
2446
2499
|
notifyChanged: () => this.#p(),
|
|
2447
|
-
update: (o, a,
|
|
2448
|
-
|
|
2449
|
-
|
|
2500
|
+
update: (o, a, h) => {
|
|
2501
|
+
const c = this.#s.change(o.group);
|
|
2502
|
+
return c.update(a, h), c.commit();
|
|
2503
|
+
},
|
|
2504
|
+
remove: (o, a) => {
|
|
2505
|
+
const h = this.#s.change(o.group);
|
|
2506
|
+
return h.remove(a), h.commit();
|
|
2507
|
+
}
|
|
2508
|
+
}), this.#o = new Dt({
|
|
2450
2509
|
hostName: n,
|
|
2451
2510
|
logger: this.#i,
|
|
2452
2511
|
isInstalled: (o) => this.#t.has(o),
|
|
2453
|
-
report: (o) => this.#
|
|
2454
|
-
}), this.#s = new
|
|
2512
|
+
report: (o) => this.#h(o)
|
|
2513
|
+
}), this.#s = new Xt(n, {
|
|
2455
2514
|
installations: () => this.#t.values(),
|
|
2456
|
-
createDraft: (o, a,
|
|
2515
|
+
createDraft: (o, a, h) => this.#t.create(o, a, h),
|
|
2457
2516
|
resolveInstallation: (o) => this.#t.resolve(o),
|
|
2458
|
-
executeChanges: (o, a) => this.#
|
|
2517
|
+
executeChanges: (o, a) => this.#d(o, a),
|
|
2459
2518
|
attachInstallation: (o) => this.#t.attach(o),
|
|
2460
2519
|
discardInstallation: (o, a) => this.#t.discard(o, a),
|
|
2461
|
-
runExclusive: (o) => this.#
|
|
2520
|
+
runExclusive: (o) => this.#a.run(o),
|
|
2462
2521
|
removeInstallations: (o) => this.#f(o),
|
|
2463
2522
|
notifyChanged: () => this.#p()
|
|
2464
|
-
}), this.#e = new
|
|
2523
|
+
}), this.#e = new Gt(
|
|
2465
2524
|
n,
|
|
2466
2525
|
this.#s.nodes(),
|
|
2467
|
-
(o) => this.#
|
|
2526
|
+
(o) => this.#h(o)
|
|
2468
2527
|
), this.diagnostics = this.#e.view, Object.freeze(this);
|
|
2469
2528
|
}
|
|
2470
2529
|
get status() {
|
|
@@ -2472,7 +2531,10 @@ class re {
|
|
|
2472
2531
|
}
|
|
2473
2532
|
get(t) {
|
|
2474
2533
|
const e = this.#r === "active" ? "available" : "unavailable";
|
|
2475
|
-
return this.#
|
|
2534
|
+
return this.#o.get(t, e);
|
|
2535
|
+
}
|
|
2536
|
+
contributions(t) {
|
|
2537
|
+
return this.#o.contributions(t);
|
|
2476
2538
|
}
|
|
2477
2539
|
install(t, ...e) {
|
|
2478
2540
|
return this.#s.install(this.#s.root, t, ...e);
|
|
@@ -2484,14 +2546,14 @@ class re {
|
|
|
2484
2546
|
return this.#s.create(this.#s.root, t, e);
|
|
2485
2547
|
}
|
|
2486
2548
|
start() {
|
|
2487
|
-
return this.#
|
|
2549
|
+
return this.#a.run(async () => {
|
|
2488
2550
|
if (this.#r !== "active") {
|
|
2489
|
-
this.#
|
|
2551
|
+
this.#c("starting");
|
|
2490
2552
|
try {
|
|
2491
|
-
const t = this.#
|
|
2492
|
-
await this.#
|
|
2553
|
+
const t = this.#o.buildPlan(this.#t.values());
|
|
2554
|
+
await this.#o.start(t), this.#c("active"), this.#t.settleReadiness(t.order);
|
|
2493
2555
|
} catch (t) {
|
|
2494
|
-
this.#
|
|
2556
|
+
this.#c("idle");
|
|
2495
2557
|
for (const e of this.#t.values())
|
|
2496
2558
|
e.status !== "active" && e.fail(t);
|
|
2497
2559
|
throw this.#t.settleReadiness(this.#t.values()), t;
|
|
@@ -2500,21 +2562,21 @@ class re {
|
|
|
2500
2562
|
});
|
|
2501
2563
|
}
|
|
2502
2564
|
stop() {
|
|
2503
|
-
return this.#
|
|
2565
|
+
return this.#a.run(async () => {
|
|
2504
2566
|
if (this.#r === "idle") return;
|
|
2505
|
-
this.#
|
|
2506
|
-
const t = await this.#
|
|
2507
|
-
if (this.#
|
|
2567
|
+
this.#c("stopping");
|
|
2568
|
+
const t = await this.#o.stop();
|
|
2569
|
+
if (this.#c("idle"), t.length === 1) throw t[0];
|
|
2508
2570
|
if (t.length > 1) throw new AggregateError(t, "Host shutdown failed");
|
|
2509
2571
|
});
|
|
2510
2572
|
}
|
|
2511
|
-
#
|
|
2573
|
+
#d(t, e) {
|
|
2512
2574
|
const i = e.filter((s) => s.kind === "install").map((s) => s.installation);
|
|
2513
|
-
return this.#
|
|
2575
|
+
return this.#a.run(async () => {
|
|
2514
2576
|
try {
|
|
2515
|
-
if (!t.attached) throw
|
|
2577
|
+
if (!t.attached) throw A(t);
|
|
2516
2578
|
if (!e.length) return;
|
|
2517
|
-
this.#r === "active" ? await this.#
|
|
2579
|
+
this.#r === "active" ? await this.#l(e) : (this.#t.apply(e), this.#t.settleChanges(e, !1)), this.#p();
|
|
2518
2580
|
} catch (s) {
|
|
2519
2581
|
for (const n of i)
|
|
2520
2582
|
this.#t.contains(n) || this.#t.discard(n, s);
|
|
@@ -2523,34 +2585,34 @@ class re {
|
|
|
2523
2585
|
});
|
|
2524
2586
|
}
|
|
2525
2587
|
async #f(t) {
|
|
2526
|
-
t.length && this.#r === "active" ? await this.#
|
|
2588
|
+
t.length && this.#r === "active" ? await this.#l(t) : (this.#t.apply(t), this.#t.settleChanges(t, !1));
|
|
2527
2589
|
}
|
|
2528
|
-
async #
|
|
2529
|
-
const e = await this.#
|
|
2590
|
+
async #l(t) {
|
|
2591
|
+
const e = await this.#u(t);
|
|
2530
2592
|
if (this.#t.settleReadiness(e.affected), e.kind === "rolled-back") throw e.error;
|
|
2531
2593
|
this.#t.settleChanges(t, !0);
|
|
2532
2594
|
}
|
|
2533
|
-
async #
|
|
2595
|
+
async #u(t) {
|
|
2534
2596
|
const e = this.#t.capture(), i = new Set(t.map((n) => n.installation));
|
|
2535
|
-
this.#
|
|
2597
|
+
this.#c("changing");
|
|
2536
2598
|
let s;
|
|
2537
2599
|
try {
|
|
2538
|
-
this.#t.apply(t), s = this.#
|
|
2600
|
+
this.#t.apply(t), s = this.#o.buildPlan(this.#t.values());
|
|
2539
2601
|
} catch (n) {
|
|
2540
|
-
throw this.#t.restore(e), this.#
|
|
2602
|
+
throw this.#t.restore(e), this.#c("active"), n;
|
|
2541
2603
|
}
|
|
2542
2604
|
try {
|
|
2543
|
-
const n = await this.#
|
|
2605
|
+
const n = await this.#o.transition(
|
|
2544
2606
|
s,
|
|
2545
2607
|
i,
|
|
2546
2608
|
() => this.#t.restore(e)
|
|
2547
2609
|
);
|
|
2548
|
-
return this.#
|
|
2610
|
+
return this.#c("active"), n;
|
|
2549
2611
|
} catch (n) {
|
|
2550
|
-
throw this.#
|
|
2612
|
+
throw this.#c(this.#o.hasCommittedPlan ? "active" : "idle"), n;
|
|
2551
2613
|
}
|
|
2552
2614
|
}
|
|
2553
|
-
#
|
|
2615
|
+
#h(t) {
|
|
2554
2616
|
try {
|
|
2555
2617
|
this.#n(t);
|
|
2556
2618
|
} catch (e) {
|
|
@@ -2562,29 +2624,31 @@ class re {
|
|
|
2562
2624
|
}
|
|
2563
2625
|
}
|
|
2564
2626
|
}
|
|
2565
|
-
#
|
|
2627
|
+
#c(t) {
|
|
2566
2628
|
this.#r = t, this.#p();
|
|
2567
2629
|
}
|
|
2568
2630
|
#p() {
|
|
2569
2631
|
this.#e.publish(this.#r, this.#t.values(), this.#s.nodes());
|
|
2570
2632
|
}
|
|
2571
2633
|
}
|
|
2572
|
-
function
|
|
2573
|
-
return new
|
|
2634
|
+
function ge(r) {
|
|
2635
|
+
return new he(r);
|
|
2574
2636
|
}
|
|
2575
2637
|
export {
|
|
2576
|
-
|
|
2638
|
+
at as ConfigValidationError,
|
|
2577
2639
|
u as DougongError,
|
|
2578
|
-
|
|
2579
|
-
|
|
2640
|
+
S as ReadonlyMapSnapshot,
|
|
2641
|
+
oe as SerialQueue,
|
|
2580
2642
|
q as SnapshotPublisher,
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2643
|
+
k as assertPlainRecord,
|
|
2644
|
+
j as asyncDisposeSymbol,
|
|
2645
|
+
ge as createHost,
|
|
2646
|
+
pe as definePlugin,
|
|
2647
|
+
g as disposeSymbol,
|
|
2648
|
+
le as event,
|
|
2649
|
+
ue as extensionPoint,
|
|
2650
|
+
J as isCancellationReason,
|
|
2651
|
+
zt as isLogger,
|
|
2652
|
+
fe as optional,
|
|
2653
|
+
de as service
|
|
2590
2654
|
};
|