@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/dist/index.js CHANGED
@@ -1,38 +1,43 @@
1
- function tt(r, t) {
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 N(r, t) {
8
- return tt("Contract", t), Object.freeze({ id: t, kind: r });
7
+ function V(r, t) {
8
+ return rt("Contract", t), Object.freeze({ id: t, kind: r });
9
9
  }
10
- function w(r, t) {
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 y(r, t) {
16
- if (!w(r, t))
17
- throw new TypeError(t ? `Expected ${et(t)}` : "Invalid contract");
15
+ function b(r, t) {
16
+ if (!v(r, t))
17
+ throw new TypeError(t ? `Expected ${nt(t)}` : "Invalid contract");
18
18
  }
19
- function et(r) {
19
+ function nt(r) {
20
20
  return r === "extensionPoint" ? "an ExtensionPoint" : r === "event" ? "an Event" : "a Service";
21
21
  }
22
- function ne(r) {
23
- return N("service", r);
22
+ function de(r) {
23
+ return V("service", r);
24
24
  }
25
- function oe(r) {
26
- return N("event", r);
25
+ function le(r) {
26
+ return V("event", r);
27
27
  }
28
- function ae(r) {
29
- return N("extensionPoint", r);
28
+ function ue(r) {
29
+ return V("extensionPoint", r);
30
30
  }
31
- function he(r) {
32
- if (!w(r, "service"))
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 j extends u {
48
+ class P extends u {
44
49
  }
45
- function A(r, t, e) {
46
- return r instanceof j ? r.code === t ? r : new j(t, e, { cause: r.cause }) : r instanceof Error ? r : new j(t, e, { cause: r });
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 Y(r, t) {
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 it extends u {
58
+ class at extends u {
54
59
  name = "ConfigValidationError";
55
60
  issues;
56
61
  constructor(t) {
57
- const e = st(t);
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 st(r) {
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: rt(i.path, e) }
83
+ ...i.path === void 0 ? {} : { path: ht(i.path, e) }
79
84
  });
80
85
  })
81
86
  );
82
87
  }
83
- function rt(r, t) {
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 (M(e)) return e;
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 (!M(s))
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 M(r) {
107
+ function G(r) {
103
108
  return typeof r == "string" || typeof r == "number" || typeof r == "symbol";
104
109
  }
105
- async function Q(r, t, e) {
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 it(s) : new TypeError(
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 nt {
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
- J(this.#t, t);
134
+ Z(this.#t, t);
130
135
  }
131
136
  remember(t) {
132
- $(this.#t, t);
137
+ T(this.#t, t);
133
138
  }
134
139
  draft(t) {
135
- return new ot(this, t);
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 ot {
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) && $(e.pending, t);
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 $(r, t) {
167
- J(r, t), r.set(t.id, t.kind);
171
+ function T(r, t) {
172
+ Z(r, t), r.set(t.id, t.kind);
168
173
  }
169
- function J(r, t) {
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 x {
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((h, d) => h.index - d.index), s = new Map(e), n = at(i, s), o = ht(i, n, s), { order: a, layers: c } = ct(
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 x(
198
+ return new M(
194
199
  Object.freeze(a),
195
- Object.freeze(c.map((h) => Object.freeze(h))),
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 at(r, t) {
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
- $(t, s);
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 ht(r, t, e) {
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 c = a.kind === "optional" ? a.service : a;
243
- if ($(e, c), c.kind === "extensionPoint") continue;
244
- const h = t.get(c.id);
245
- if (!h) {
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 '${c.id}'`
254
+ `Installation '${o.id}' requires missing Service '${h.id}'`
250
255
  );
251
256
  }
252
- if (h === o)
257
+ if (c === o)
253
258
  throw new u(
254
259
  "SERVICE_CYCLE",
255
- `Installation '${o.id}' cannot require Service '${c.id}' that it provides`
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(c.id, h), i.set(o, d);
259
- const l = s.get(h) ?? /* @__PURE__ */ new Set();
260
- l.has(o) || (l.add(o), s.set(h, l), n.set(o, (n.get(o) ?? 0) + 1));
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 ct(r, t, e) {
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, c) => a.index - c.index);
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 c of t.get(a) ?? []) {
273
- const h = (e.get(c) ?? 0) - 1;
274
- e.set(c, h), h || i.push(c);
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 = dt(r, t);
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 dt(r, t) {
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 h = s.indexOf(a);
292
- return [...s.slice(h), a];
296
+ const c = s.indexOf(a);
297
+ return [...s.slice(c), a];
293
298
  }
294
299
  if (e.has(a)) continue;
295
- const c = n(a);
296
- if (c) return c;
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 O {
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
- const v = /* @__PURE__ */ new WeakMap();
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.#a(t)
372
+ subscribe: (t) => this.#o(t)
354
373
  });
355
374
  invalidate() {
356
- const { report: t } = this.#o();
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
- ut(i);
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) ft(i);
401
+ for (const i of e) mt(i);
383
402
  }
384
403
  }
385
404
  }
386
- [Symbol.dispose]() {
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
- #a(t) {
412
+ #o(t) {
394
413
  if (typeof t != "function") throw new TypeError("Subscriber must be a function");
395
- this.#o();
396
- const e = new lt(t, (i) => {
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
- #o() {
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 lt {
429
+ class vt {
411
430
  constructor(t, e) {
412
- v.set(this, { listener: t, detach: e }), Object.freeze(this);
431
+ m.set(this, { listener: t, detach: e }), Object.freeze(this);
413
432
  }
414
433
  dispose() {
415
- const t = v.get(this);
416
- t && (v.delete(this), t.detach(this));
434
+ const t = m.get(this);
435
+ t && (m.delete(this), t.detach(this));
417
436
  }
418
- [Symbol.dispose]() {
437
+ [g]() {
419
438
  this.dispose();
420
439
  }
421
440
  }
422
- function ut(r) {
423
- v.get(r)?.listener();
441
+ function bt(r) {
442
+ m.get(r)?.listener();
424
443
  }
425
- function ft(r) {
426
- v.delete(r);
444
+ function mt(r) {
445
+ m.delete(r);
427
446
  }
428
- class pt {
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 gt {
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
- [Symbol.dispose]() {
480
+ [g]() {
462
481
  this.dispose();
463
482
  }
464
483
  }
465
- class wt {
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 gt(this);
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
- [Symbol.dispose]() {
518
+ [g]() {
500
519
  this.dispose();
501
520
  }
502
521
  }
503
- class vt {
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
- #a = new O();
528
+ #o = new S();
510
529
  #r = 0;
511
- #o = 0;
512
- #c = !1;
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.#a, e);
534
+ this.#t = t, this.#e = i, this.#n = new q(() => this.#o, e);
515
535
  }
516
536
  stage(t, e, i, s) {
517
- Et(e);
518
- const n = Ct(t, e);
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 wt(this, n, i, s);
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 bt(e, () => {
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.#l();
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.#l(), n;
560
+ throw e.binding = void 0, this.#r--, this.#h(), n;
541
561
  }
542
- return new pt(e);
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.#o++;
575
+ this.#a++;
552
576
  let s;
553
- const n = new mt(i, () => {
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.#o--, this.#l();
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.#f(t, e), this.#s.has(t))
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.#f(t, e), i === "published" && this.#u(t, e);
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.#l();
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.#a.size && t.every(([i, s]) => Object.is(this.#a.get(i), s)) || (this.#a = new O(t), this.#n.invalidate());
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
- #f(t, e) {
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
- #l() {
601
- if (!(this.#c || this.#i.size || this.#s.size || this.#o || this.#r)) {
602
- this.#c = !0;
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 bt {
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
- [Symbol.dispose]() {
644
+ [g]() {
621
645
  this.dispose();
622
646
  }
623
647
  }
624
- class mt {
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
- [Symbol.dispose]() {
664
+ [g]() {
641
665
  this.dispose();
642
666
  }
643
667
  }
644
- class yt {
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 vt(
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 Et(r) {
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 Ct(r, t) {
694
- return `${D(r)}/${D(t)}`;
720
+ function Tt(r, t) {
721
+ return `${B(r)}/${B(t)}`;
695
722
  }
696
- function D(r) {
723
+ function B(r) {
697
724
  return r.replaceAll("%", "%25").replaceAll("/", "%2F");
698
725
  }
699
- class Ot {
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
- [Symbol.dispose]() {
735
+ [g]() {
709
736
  this.dispose();
710
737
  }
711
738
  }
712
- class St {
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 Ot(this);
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
- [Symbol.dispose]() {
761
+ [g]() {
735
762
  this.dispose();
736
763
  }
737
764
  }
738
- class It {
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 St(this, t, e, i);
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 At {
789
+ class Lt {
763
790
  #t;
764
791
  root;
765
792
  view;
766
793
  constructor(t, e) {
767
- this.root = G(t), this.#t = new q(() => X(this.root), e), this.view = this.#t.view;
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 G(t);
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 G(r) {
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 X(r) {
807
- const t = Object.freeze([...r.children].map(X));
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 $t(r) {
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 L = Object.freeze(new DOMException("Resource disposed", "AbortError"));
823
- class g {
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 Tt {
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
- [Symbol.asyncDispose]() {
908
+ [j]() {
882
909
  return this.dispose();
883
910
  }
884
911
  }
885
- class jt {
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
- Y(n.signal, a) || i(a);
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(L), this.#n(), e;
943
+ return this.#i = { phase: "disposing", completion: e }, t.controller.abort(R), this.#n(), e;
917
944
  }
918
- [Symbol.asyncDispose]() {
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 V {
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
- #c;
966
+ #r;
967
+ #a;
968
+ #d;
942
969
  #f;
943
- #u;
944
970
  #l;
971
+ #u;
945
972
  handle;
946
- #d;
973
+ #h;
947
974
  constructor(t, e, i = {}) {
948
- this.#e = e, this.handle = new kt(this);
975
+ this.#e = e, this.handle = new xt(this);
949
976
  const s = new AbortController();
950
- this.#d = {
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.#l = n?.detach, this.#f = n ? "child" : "root";
957
- const o = n?.diagnostics ?? new At(e, (l) => t.report(l)), a = n?.diagnosticNode ?? o.root;
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 c = (l) => ({
986
+ const h = (l) => ({
960
987
  diagnostics: o,
961
988
  node: a,
962
989
  kind: l
963
990
  });
964
- this.#i = new g(c("listeners")), this.#s = new g(c("contributions")), this.#n = new g(c("contributionViews")), this.#a = new g(c("subscriptions")), this.#r = new g(c("tasks")), this.#o = new g(), this.#c = new g(c("cleanups"));
965
- const h = i.parentSignal;
966
- if (!h) return;
967
- const d = () => s.abort(h.reason);
968
- h.addEventListener("abort", d, { once: !0 }), this.#u = () => h.removeEventListener("abort", d), h.aborted && d();
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.#d;
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.#h().diagnostics.view;
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.#h(), typeof t != "function") throw new TypeError("Cleanup must be a function");
979
- const e = new Tt(t, this.#c.release);
980
- return this.#c.add(e), e;
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.#h();
984
- Pt(t);
985
- const n = i.createNode(t), o = new V(e, this.#e, {
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.#o.release(a) && i.detach(s, n);
1029
+ this.#a.release(a) && i.detach(s, n);
993
1030
  }
994
1031
  }
995
1032
  });
996
- return this.#o.add(o), i.attach(s, n), o.handle;
1033
+ return this.#a.add(o), i.attach(s, n), o.handle;
997
1034
  }
998
1035
  spawn(t) {
999
- const { port: e } = this.#h();
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 jt(
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.#h(), s = i.stageOn(this.#e, t, e, this.#i.release);
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
- return this.#h().port.emit(this.#e, t, e);
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.#h(), n = s.stageContribution(
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.#h(), (e === "view" ? this.#n : this.#a).own(t);
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.#u;
1033
- this.#u = void 0, t?.();
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.#d;
1038
- if (t.phase !== "active") throw b();
1039
- if (this.#h(), t.declarations !== "published") {
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.#o) e.publish();
1043
- this.#d = { ...t, declarations: "published" };
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.#d;
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.#a.dispose(s), await this.#n.dispose(s), t.controller.abort(L), this.detachStartupSignal(), await this.#r.dispose(s), await this.#o.dispose(s), await this.#c.dispose(s), s.length === 1) throw s[0];
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.#d = { phase: "disposed", signal: AbortSignal.abort(L) };
1056
- const s = this.#l;
1057
- this.#l = void 0;
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.#d = { phase: "disposing", controller: t.controller, completion: i }, e.diagnostics.beginDisposing(e.diagnosticNode), i;
1102
+ return this.#h = { phase: "disposing", controller: t.controller, completion: i }, e.diagnostics.beginDisposing(e.diagnosticNode), i;
1065
1103
  }
1066
- [Symbol.asyncDispose]() {
1104
+ [j]() {
1067
1105
  return this.dispose();
1068
1106
  }
1069
- #h() {
1107
+ #c() {
1070
1108
  const t = this.#t;
1071
- if (this.#d.phase !== "active" || this.signal.aborted || !t)
1072
- throw b();
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 b();
1115
+ if (!t) throw y();
1078
1116
  return t;
1079
1117
  }
1080
1118
  #g() {
1081
- const t = this.#d;
1082
- if (t.phase !== "active") throw b();
1119
+ const t = this.#h;
1120
+ if (t.phase !== "active") throw y();
1083
1121
  return t.declarations;
1084
1122
  }
1085
1123
  }
1086
- class kt {
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
- [Symbol.asyncDispose]() {
1153
+ [j]() {
1116
1154
  return this.dispose();
1117
1155
  }
1118
1156
  }
1119
- function Pt(r) {
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 b() {
1126
- return new TypeError("Lifetime is disposing or has been disposed");
1163
+ function y() {
1164
+ return new u("LIFETIME_DISPOSED", "Lifetime is disposing or has been disposed");
1127
1165
  }
1128
- class z extends AggregateError {
1166
+ class N extends AggregateError {
1129
1167
  }
1130
- class Lt {
1168
+ class Mt {
1131
1169
  #t;
1132
1170
  #e;
1133
1171
  #i;
1134
1172
  #s;
1135
1173
  #n = /* @__PURE__ */ new Map();
1136
- #a = new It();
1174
+ #o = new Pt();
1137
1175
  #r;
1138
- #o = [];
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 yt(t.report);
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.#o = [];
1196
+ this.#n.clear(), this.#a = [];
1156
1197
  }
1157
1198
  commitActivationOrder(t) {
1158
- this.#o = t.slice();
1199
+ this.#a = t.slice();
1159
1200
  }
1160
1201
  deactivateAll() {
1161
- return this.deactivate(new Set(this.#o));
1202
+ return this.deactivate(new Set(this.#a));
1162
1203
  }
1163
1204
  async activate(t, e, i, s) {
1164
- const n = this.#h(s);
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 c = new AbortController(), h = await Promise.allSettled(
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 Q(
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.#c(
1219
+ return await this.#d(
1179
1220
  t,
1180
1221
  f,
1181
1222
  p,
1182
- c.signal,
1223
+ h.signal,
1183
1224
  n
1184
1225
  );
1185
1226
  } catch (p) {
1186
- throw c.abort(p), p;
1227
+ throw h.abort(p), p;
1187
1228
  }
1188
1229
  })
1189
- ), d = zt(h, c.signal), l = h.filter(
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.#u(l), p = d.length === 1 ? d[0] : new AggregateError(d, "Installation startup layer failed");
1194
- throw f.length ? new z(
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.#o.filter((s) => t.has(s)).reverse();
1204
- this.#o = this.#o.filter(
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 #c(t, e, i, s, n) {
1286
+ async #d(t, e, i, s, n) {
1246
1287
  e.deactivate();
1247
- const o = e.declaration.plugin, a = new V(n, e.id, { parentSignal: s });
1288
+ const o = e.declaration.plugin, a = new D(n, e.id, { parentSignal: s });
1248
1289
  try {
1249
- const c = this.#l(t, e, o, a), h = {
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.#d(a, h, c), l = await o.setup(d, i), f = /* @__PURE__ */ new Map();
1255
- for (const [p, Z] of Object.entries(o.provides ?? {})) {
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(Z.id, l[p]);
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 (c) {
1269
- const h = e.fail(c);
1309
+ } catch (h) {
1310
+ const c = e.fail(h);
1270
1311
  try {
1271
1312
  await a.dispose();
1272
1313
  } catch (d) {
1273
- throw new z(
1274
- [h, d],
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 h;
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.#o.push(e);
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 #u(t) {
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
- #l(t, e, i, s) {
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 c = t.providerFor(e, a.service.id);
1302
- if (!c) {
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 h = this.#n.get(c);
1307
- if (!h?.has(a.service.id))
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] = h.get(a.service.id);
1353
+ n[o] = c.get(a.service.id);
1313
1354
  } else if (a.kind === "service") {
1314
- const c = t.providerFor(e, a.id), h = c ? this.#n.get(c) : void 0;
1315
- if (!c || !h?.has(a.id))
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] = h.get(a.id);
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
- #d(t, e, i) {
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: Object.freeze(e),
1332
- log: this.#e,
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
- #h(t) {
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), y(e, "event"), n.remember(e), this.#a.stage(e.id, i, s);
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), y(e, "event"), s.remember(e), this.#a.emit(e.id, i);
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), y(e, "extensionPoint"), o.remember(e), this.#r.get(e).stage(t, i, s, n);
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 zt(r, t) {
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) : Y(t, s.reason) || e.push(s.reason));
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 Rt {
1374
- #t = new nt();
1415
+ class Dt {
1416
+ #t = new dt();
1375
1417
  #e;
1376
1418
  #i;
1377
1419
  constructor(t) {
1378
- this.#e = new Lt(t);
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
- if (y(t, "service"), this.#t.assertCompatible(t), e === "unavailable") throw B();
1385
- const i = this.#o().provider(t.id);
1386
- if (!i)
1387
- throw new u("SERVICE_UNAVAILABLE", `Service '${t.id}' is not active`);
1388
- const s = this.#e.readService(i, t.id);
1389
- if (!s.found)
1390
- throw new u("SERVICE_UNAVAILABLE", `Service '${t.id}' is not active`);
1391
- return s.value;
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 x.build(t, this.#t.kinds);
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.#o(), n = s.affectedByTransitionTo(t, e);
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 c = this.#e.captureConfigs(n), h = await this.#e.deactivate(n);
1420
- if (h.length)
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
- h,
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 z || l.length ? this.#n(
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.#a(i, s, n, c, [
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 #a(t, e, i, s, n) {
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 (c) {
1462
- const h = await this.#e.deactivateAll();
1511
+ } catch (h) {
1512
+ const c = await this.#e.deactivateAll();
1463
1513
  throw o.discard(), this.#i = void 0, new AggregateError(
1464
- [...n, c, ...h],
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 Q(
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 A(
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
- #o() {
1493
- if (!this.#i) throw B();
1542
+ #a() {
1543
+ if (!this.#i) throw U();
1494
1544
  return this.#i;
1495
1545
  }
1496
1546
  }
1497
- function B() {
1547
+ function U() {
1498
1548
  return new u("SERVICE_UNAVAILABLE", "Host services are not active");
1499
1549
  }
1500
- class Nt {
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((h) => h.kind === "optional" ? h.service.id : h.id)
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((h) => h.id)
1574
+ Object.values(o.declaration.plugin.provides ?? {}).map((c) => c.id)
1525
1575
  ),
1526
1576
  ...o.instance ? { lifetime: o.instance.lifetime.diagnostics } : {}
1527
- }, c = o.error;
1577
+ }, h = o.error;
1528
1578
  s.set(
1529
1579
  o.id,
1530
- Object.freeze(c === void 0 ? a : { ...a, error: c })
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 O(s),
1546
- groups: new O(n)
1595
+ installations: new S(s),
1596
+ groups: new S(n)
1547
1597
  });
1548
1598
  }
1549
1599
  }
1550
- function T(r, t, e = {}) {
1600
+ function k(r, t, e = {}) {
1551
1601
  if (!r || typeof r != "object" || Array.isArray(r))
1552
- throw m(e, `${t} must be a plain record`);
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 m(e, `${t} must be a plain record`);
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 m(e, `${t} keys must be enumerable strings`);
1608
+ throw E(e, `${t} keys must be enumerable strings`);
1559
1609
  if (e.fields && !e.fields.has(s))
1560
- throw m(e, `${t}: unknown field '${s}'`);
1610
+ throw E(e, `${t}: unknown field '${s}'`);
1561
1611
  }
1562
1612
  }
1563
- function m(r, t) {
1613
+ function E(r, t) {
1564
1614
  return r.createError?.(t) ?? new TypeError(t);
1565
1615
  }
1566
- const xt = /* @__PURE__ */ new Set([
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
- ]), qt = /* @__PURE__ */ new Set(["name", "config", "requires", "provides", "setup"]);
1577
- function Vt(r) {
1578
- Mt(r);
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 && !Dt(e))
1639
+ if (e !== void 0 && !_t(e))
1587
1640
  throw new TypeError(`Plugin '${t}' config must implement Standard Schema V1`);
1588
- F(i, t, "requires"), F(s, t, "provides");
1589
- const o = i ? Object.freeze({ ...i }) : void 0, a = s ? Object.freeze({ ...s }) : void 0, c = /* @__PURE__ */ new Map();
1590
- for (const [h, d] of Object.entries(o ?? {})) {
1591
- if (!h.trim()) throw new TypeError("Plugin requirement alias cannot be empty");
1592
- if (h !== h.trim())
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 (xt.has(h))
1595
- throw new TypeError(`Plugin requirement '${h}' conflicts with the context API`);
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 '${h}' is not a contract`);
1650
+ throw new TypeError(`Plugin requirement '${c}' is not a contract`);
1598
1651
  if (d.kind === "optional") {
1599
- if (!w(d.service, "service"))
1600
- throw new TypeError(`Optional requirement '${h}' must wrap a Service`);
1601
- } else if (!w(d, "service") && !w(d, "extensionPoint"))
1602
- throw new TypeError(`Plugin requirement '${h}' must be a Service or ExtensionPoint`);
1603
- U(
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 [h, d] of Object.entries(a ?? {})) {
1612
- if (!h.trim()) throw new TypeError("Plugin provision alias cannot be empty");
1613
- if (h !== h.trim())
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 (!w(d, "service"))
1616
- throw new TypeError(`Plugin provision '${h}' must be a Service`);
1617
- U(t, c, "provision", h, d);
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 Mt(r) {
1628
- T(r, "Plugin declaration", { fields: qt });
1680
+ function Ut(r) {
1681
+ k(r, "Plugin declaration", { fields: Ft });
1629
1682
  }
1630
- function Dt(r) {
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 F(r, t, e) {
1638
- r !== void 0 && T(r, `Plugin '${t}' ${e}`);
1690
+ function _(r, t, e) {
1691
+ r !== void 0 && k(r, `Plugin '${t}' ${e}`);
1639
1692
  }
1640
- function U(r, t, e, i, s) {
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 ${k(n.kind)} and ${k(s.kind)}`
1701
+ `Plugin '${r}' uses Contract '${s.id}' as both ${L(n.kind)} and ${L(s.kind)}`
1649
1702
  );
1650
- const o = k(s.kind);
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 k(r) {
1710
+ function L(r) {
1658
1711
  return r === "extensionPoint" ? "ExtensionPoint" : r === "event" ? "Event" : "Service";
1659
1712
  }
1660
- function _(r) {
1661
- return Vt(r);
1713
+ function K(r) {
1714
+ return it(r);
1662
1715
  }
1663
- const Gt = /* @__PURE__ */ new Set(["plugin", "config"]), R = /* @__PURE__ */ new WeakMap();
1664
- function Bt(r, t) {
1665
- R.get(r)?.(t);
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 Ft {
1720
+ class Wt {
1668
1721
  #t = /* @__PURE__ */ new Map();
1669
1722
  #e;
1670
1723
  constructor(t) {
1671
- this.#e = { phase: "open", port: t }, R.set(this, (e) => this.#i(e)), Object.freeze(this);
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 = _(t), n = i.create(s, e[0]);
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
- T(e, "Installation update", { fields: Gt });
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 = _(d);
1741
+ a = K(d);
1689
1742
  }
1690
- let c;
1691
- a && n ? c = { kind: "plugin-and-config", plugin: a, config: e.config } : a ? c = { kind: "plugin", plugin: a } : c = { kind: "config", config: e.config };
1692
- const h = { kind: "update", installation: o, declaration: c };
1693
- return this.#s(h), this;
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
- return this.#s({ kind: "remove", installation: e.resolve(t) }), this;
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.#a(Promise.reject(n));
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.#a(s);
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
- #a(t) {
1799
+ #o(t) {
1747
1800
  return this.#e = { phase: "submitted", promise: t }, this.#r(), t;
1748
1801
  }
1749
1802
  #r() {
1750
- this.#t.clear(), R.delete(this);
1803
+ this.#t.clear(), x.delete(this);
1751
1804
  }
1752
1805
  }
1753
- class Ut {
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 P();
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 P();
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 P();
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 P() {
1848
+ function z() {
1796
1849
  return new Error("Group configuration has been sealed");
1797
1850
  }
1798
- class S {
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 S("/", t, void 0);
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(), _t(t), this.#t.has(t))
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 S(this.#i(t), t, this);
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 _t(r) {
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 H {
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 = 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 I(r) {
1965
+ function A(r) {
1913
1966
  return new u("GROUP_REMOVED", `Group '${r.id}' has been removed`);
1914
1967
  }
1915
- const E = /* @__PURE__ */ new WeakMap();
1916
- class Ht {
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 }, E.set(this, {
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(I(this.#t)) : t.coordinator.ready(this.#t);
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 I(this.#t);
2023
+ if (t.phase === "revoked") throw A(this.#t);
1971
2024
  return t.coordinator;
1972
2025
  }
1973
2026
  }
1974
- class Kt {
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 = S.root(t), this.#t = e, this.#i.set(
2033
+ this.root = I.root(t), this.#t = e, this.#i.set(
1981
2034
  this.root,
1982
- new H(this.root, "established", () => e.notifyChanged())
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 K(s.commit()), n;
2043
+ return Y(s.commit()), n;
1991
2044
  }
1992
2045
  change(t, e = "immediate") {
1993
- return this.#r(t), new Ft({
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.#a(t, s), s;
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 H(n, "new", () => this.#t.notifyChanged()));
2019
- const o = s === void 0, a = s ?? new Ut(
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
- Bt,
2022
- (h) => A(
2023
- h,
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
- ), c = new Ht(this, n, a);
2028
- this.#e.set(n, c);
2080
+ ), h = new Jt(this, n, a);
2081
+ this.#e.set(n, h);
2029
2082
  try {
2030
- const h = i(c);
2031
- Yt(h) && Wt(h);
2083
+ const c = i(h);
2084
+ te(c) && Zt(c);
2032
2085
  const d = a.failure;
2033
2086
  if (d) throw d;
2034
- } catch (h) {
2035
- const d = a.fail(h), l = n.walk();
2036
- throw n.detach(), this.#o(l), o && a.discard(d), this.#t.notifyChanged(), d;
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 h = a.seal().commit();
2092
+ const c = a.seal().commit();
2040
2093
  for (const d of n.walk()) {
2041
2094
  const l = this.#e.get(d);
2042
- l && E.get(l)?.finishConfiguration(), this.#a(d, h);
2095
+ l && C.get(l)?.finishConfiguration(), this.#o(d, c);
2043
2096
  }
2044
- K(h);
2097
+ Y(c);
2045
2098
  }
2046
- return this.#t.notifyChanged(), c;
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.#o([t]);
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.#o(e), this.#t.notifyChanged();
2068
- }) : (this.#o([t]), Promise.resolve());
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
- #a(t, e) {
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 I(t);
2137
+ if (!t.attached || !e) throw A(t);
2085
2138
  return e;
2086
2139
  }
2087
- #o(t) {
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 && (E.get(i)?.revoke(), E.delete(i)), this.#e.delete(e);
2144
+ i && (C.get(i)?.revoke(), C.delete(i)), this.#e.delete(e);
2092
2145
  }
2093
2146
  }
2094
2147
  }
2095
- function K(r) {
2148
+ function Y(r) {
2096
2149
  Promise.resolve(r).catch(() => {
2097
2150
  });
2098
2151
  }
2099
- function Wt(r) {
2152
+ function Zt(r) {
2100
2153
  throw Promise.resolve(r).catch(() => {
2101
2154
  }), new TypeError("Group configure must be synchronous");
2102
2155
  }
2103
- function Yt(r) {
2156
+ function te(r) {
2104
2157
  return r === null || typeof r != "object" && typeof r != "function" ? !1 : typeof r.then == "function";
2105
2158
  }
2106
- function W(r, t) {
2159
+ function Q(r, t) {
2107
2160
  return Object.freeze({ plugin: r, config: t });
2108
2161
  }
2109
- class Qt {
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.#c();
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 : Xt(t.failure.summary);
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.#c().group;
2197
+ return this.#d().group;
2145
2198
  }
2146
2199
  get declaration() {
2147
- return this.#c().declaration;
2200
+ return this.#d().declaration;
2148
2201
  }
2149
2202
  replaceDeclaration(t) {
2150
- this.#c().declaration = t;
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.#a(t);
2265
+ return this.#o(t);
2213
2266
  }
2214
2267
  discard(t) {
2215
- const e = this.#o(t);
2268
+ const e = this.#a(t);
2216
2269
  this.#r({
2217
2270
  phase: "failed",
2218
- failure: { retention: "summary", summary: Jt(e) },
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
- #a(t) {
2225
- const e = this.#o(t);
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
- #o(t) {
2239
- return A(
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
- #c() {
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 Jt(r) {
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 Xt(r) {
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 C = /* @__PURE__ */ new WeakMap();
2263
- class Zt {
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, C.set(this, {
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 te {
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 Qt(
2385
+ const s = ++this.#n, n = new ee(
2333
2386
  `${e.name}:${s}`,
2334
2387
  s,
2335
2388
  t,
2336
- W(e, i)
2337
- ), o = new Zt(n);
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 = C.get(e);
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(W(s, n));
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.#a(i.installation)) : e || i.installation.deactivate();
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.#a(t);
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
- #a(t) {
2453
+ #o(t) {
2401
2454
  const e = this.#i.get(t);
2402
- e && (C.get(e)?.revoke(), C.delete(e)), this.#i.delete(t);
2455
+ e && (O.get(e)?.revoke(), O.delete(e)), this.#i.delete(t);
2403
2456
  }
2404
2457
  }
2405
- class ee {
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 ie = console, se = /* @__PURE__ */ new Set(["name", "logger", "onError"]);
2423
- class re {
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
- #a;
2484
+ #o;
2432
2485
  #r = "idle";
2433
- #o = new ee();
2486
+ #a = new oe();
2434
2487
  constructor(t = {}) {
2435
- T(t, "Host options", { fields: se });
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 && !$t(i))
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 ?? ie, this.#n = s ?? ((o) => this.#i.error(o)), this.#t = new te({
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, c) => this.#s.change(o.group).update(a, c).commit(),
2448
- remove: (o, a) => this.#s.change(o.group).remove(a).commit()
2449
- }), this.#a = new Rt({
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.#d(o)
2454
- }), this.#s = new Kt(n, {
2512
+ report: (o) => this.#h(o)
2513
+ }), this.#s = new Xt(n, {
2455
2514
  installations: () => this.#t.values(),
2456
- createDraft: (o, a, c) => this.#t.create(o, a, c),
2515
+ createDraft: (o, a, h) => this.#t.create(o, a, h),
2457
2516
  resolveInstallation: (o) => this.#t.resolve(o),
2458
- executeChanges: (o, a) => this.#c(o, a),
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.#o.run(o),
2520
+ runExclusive: (o) => this.#a.run(o),
2462
2521
  removeInstallations: (o) => this.#f(o),
2463
2522
  notifyChanged: () => this.#p()
2464
- }), this.#e = new Nt(
2523
+ }), this.#e = new Gt(
2465
2524
  n,
2466
2525
  this.#s.nodes(),
2467
- (o) => this.#d(o)
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.#a.get(t, e);
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.#o.run(async () => {
2549
+ return this.#a.run(async () => {
2488
2550
  if (this.#r !== "active") {
2489
- this.#h("starting");
2551
+ this.#c("starting");
2490
2552
  try {
2491
- const t = this.#a.buildPlan(this.#t.values());
2492
- await this.#a.start(t), this.#h("active"), this.#t.settleReadiness(t.order);
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.#h("idle");
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.#o.run(async () => {
2565
+ return this.#a.run(async () => {
2504
2566
  if (this.#r === "idle") return;
2505
- this.#h("stopping");
2506
- const t = await this.#a.stop();
2507
- if (this.#h("idle"), t.length === 1) throw t[0];
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
- #c(t, e) {
2573
+ #d(t, e) {
2512
2574
  const i = e.filter((s) => s.kind === "install").map((s) => s.installation);
2513
- return this.#o.run(async () => {
2575
+ return this.#a.run(async () => {
2514
2576
  try {
2515
- if (!t.attached) throw I(t);
2577
+ if (!t.attached) throw A(t);
2516
2578
  if (!e.length) return;
2517
- this.#r === "active" ? await this.#u(e) : (this.#t.apply(e), this.#t.settleChanges(e, !1)), this.#p();
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.#u(t) : (this.#t.apply(t), this.#t.settleChanges(t, !1));
2588
+ t.length && this.#r === "active" ? await this.#l(t) : (this.#t.apply(t), this.#t.settleChanges(t, !1));
2527
2589
  }
2528
- async #u(t) {
2529
- const e = await this.#l(t);
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 #l(t) {
2595
+ async #u(t) {
2534
2596
  const e = this.#t.capture(), i = new Set(t.map((n) => n.installation));
2535
- this.#h("changing");
2597
+ this.#c("changing");
2536
2598
  let s;
2537
2599
  try {
2538
- this.#t.apply(t), s = this.#a.buildPlan(this.#t.values());
2600
+ this.#t.apply(t), s = this.#o.buildPlan(this.#t.values());
2539
2601
  } catch (n) {
2540
- throw this.#t.restore(e), this.#h("active"), n;
2602
+ throw this.#t.restore(e), this.#c("active"), n;
2541
2603
  }
2542
2604
  try {
2543
- const n = await this.#a.transition(
2605
+ const n = await this.#o.transition(
2544
2606
  s,
2545
2607
  i,
2546
2608
  () => this.#t.restore(e)
2547
2609
  );
2548
- return this.#h("active"), n;
2610
+ return this.#c("active"), n;
2549
2611
  } catch (n) {
2550
- throw this.#h(this.#a.hasCommittedPlan ? "active" : "idle"), n;
2612
+ throw this.#c(this.#o.hasCommittedPlan ? "active" : "idle"), n;
2551
2613
  }
2552
2614
  }
2553
- #d(t) {
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
- #h(t) {
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 ce(r) {
2573
- return new re(r);
2634
+ function ge(r) {
2635
+ return new he(r);
2574
2636
  }
2575
2637
  export {
2576
- it as ConfigValidationError,
2638
+ at as ConfigValidationError,
2577
2639
  u as DougongError,
2578
- O as ReadonlyMapSnapshot,
2579
- ee as SerialQueue,
2640
+ S as ReadonlyMapSnapshot,
2641
+ oe as SerialQueue,
2580
2642
  q as SnapshotPublisher,
2581
- T as assertPlainRecord,
2582
- ce as createHost,
2583
- Vt as definePlugin,
2584
- oe as event,
2585
- ae as extensionPoint,
2586
- Y as isCancellationReason,
2587
- $t as isLogger,
2588
- he as optional,
2589
- ne as service
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
  };