dougong 0.8.2 → 0.9.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.
Files changed (78) hide show
  1. package/README.md +22 -97
  2. package/dist/advanced.d.ts +8 -0
  3. package/dist/advanced.d.ts.map +1 -0
  4. package/dist/advanced.js +39 -0
  5. package/dist/composition/change-set.d.ts +49 -0
  6. package/dist/composition/change-set.d.ts.map +1 -0
  7. package/dist/composition/configuration.d.ts +9 -0
  8. package/dist/composition/configuration.d.ts.map +1 -0
  9. package/dist/composition/declarations.d.ts +53 -0
  10. package/dist/composition/declarations.d.ts.map +1 -0
  11. package/dist/composition/group.d.ts +10 -0
  12. package/dist/composition/group.d.ts.map +1 -0
  13. package/dist/composition/installation-graph.d.ts +17 -0
  14. package/dist/composition/installation-graph.d.ts.map +1 -0
  15. package/dist/composition/installation.d.ts +34 -0
  16. package/dist/composition/installation.d.ts.map +1 -0
  17. package/dist/composition/plan.d.ts +82 -0
  18. package/dist/composition/plan.d.ts.map +1 -0
  19. package/dist/composition/planner.d.ts +18 -0
  20. package/dist/composition/planner.d.ts.map +1 -0
  21. package/dist/composition/plugin-description.d.ts +34 -0
  22. package/dist/composition/plugin-description.d.ts.map +1 -0
  23. package/dist/composition/plugin.d.ts +68 -0
  24. package/dist/composition/plugin.d.ts.map +1 -0
  25. package/dist/contracts/contract-registry.d.ts +18 -0
  26. package/dist/contracts/contract-registry.d.ts.map +1 -0
  27. package/dist/contracts/contracts.d.ts +51 -0
  28. package/dist/contracts/contracts.d.ts.map +1 -0
  29. package/dist/contracts/errors.d.ts +53 -0
  30. package/dist/contracts/errors.d.ts.map +1 -0
  31. package/dist/contracts/logging.d.ts +16 -0
  32. package/dist/contracts/logging.d.ts.map +1 -0
  33. package/dist/contracts/resource.d.ts +14 -0
  34. package/dist/contracts/resource.d.ts.map +1 -0
  35. package/dist/contracts/status.d.ts +3 -0
  36. package/dist/contracts/status.d.ts.map +1 -0
  37. package/dist/contributions/contribution-store.d.ts +50 -0
  38. package/dist/contributions/contribution-store.d.ts.map +1 -0
  39. package/dist/events/event-hub.d.ts +27 -0
  40. package/dist/events/event-hub.d.ts.map +1 -0
  41. package/dist/execution/engine.d.ts +26 -0
  42. package/dist/execution/engine.d.ts.map +1 -0
  43. package/dist/execution/host-api.d.ts +43 -0
  44. package/dist/execution/host-api.d.ts.map +1 -0
  45. package/dist/execution/host.d.ts +3 -0
  46. package/dist/execution/host.d.ts.map +1 -0
  47. package/dist/execution/instance.d.ts +33 -0
  48. package/dist/execution/instance.d.ts.map +1 -0
  49. package/dist/index.d.ts +17 -3
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +2207 -8
  52. package/dist/inspection/diagnostics.d.ts +36 -0
  53. package/dist/inspection/diagnostics.d.ts.map +1 -0
  54. package/dist/internal/abort.d.ts +4 -0
  55. package/dist/internal/abort.d.ts.map +1 -0
  56. package/dist/internal/data-array.d.ts +3 -0
  57. package/dist/internal/data-array.d.ts.map +1 -0
  58. package/dist/internal/disposal-runtime.d.ts +5 -0
  59. package/dist/internal/disposal-runtime.d.ts.map +1 -0
  60. package/dist/internal/record.d.ts +8 -0
  61. package/dist/internal/record.d.ts.map +1 -0
  62. package/dist/internal/serial-queue.d.ts +6 -0
  63. package/dist/internal/serial-queue.d.ts.map +1 -0
  64. package/dist/internal/synchronous-result.d.ts +3 -0
  65. package/dist/internal/synchronous-result.d.ts.map +1 -0
  66. package/dist/lifetime/lifetime-diagnostics.d.ts +21 -0
  67. package/dist/lifetime/lifetime-diagnostics.d.ts.map +1 -0
  68. package/dist/lifetime/lifetime.d.ts +71 -0
  69. package/dist/lifetime/lifetime.d.ts.map +1 -0
  70. package/dist/observation/readonly-map.d.ts +13 -0
  71. package/dist/observation/readonly-map.d.ts.map +1 -0
  72. package/dist/observation/snapshot-view.d.ts +14 -0
  73. package/dist/observation/snapshot-view.d.ts.map +1 -0
  74. package/dist/record-CZVpq8vk.js +493 -0
  75. package/package.json +17 -7
  76. package/runtime/abort-listener.d.mts +2 -0
  77. package/runtime/abort-listener.node.mjs +26 -0
  78. package/runtime/abort-listener.web.mjs +7 -0
@@ -0,0 +1,493 @@
1
+ import { listenForAbort as e } from "#abort-listener";
2
+ // src/internal/disposal-runtime.ts
3
+ function t(e) {
4
+ if (typeof e != "function") throw Error("Unsupported JavaScript runtime: Promise.withResolvers is required");
5
+ }
6
+ function n(e, t) {
7
+ return e ?? Symbol.for(t);
8
+ }
9
+ t(Promise.withResolvers);
10
+ var r = n(Symbol.dispose, "Symbol.dispose"), i = n(Symbol.asyncDispose, "Symbol.asyncDispose");
11
+ // src/internal/synchronous-result.ts
12
+ function a(e, t) {
13
+ let n = o(e);
14
+ if (n) throw n.then(() => void 0, () => void 0), TypeError(t);
15
+ }
16
+ function o(e) {
17
+ if (e === null || typeof e != "object" && typeof e != "function") return;
18
+ let t = e.then;
19
+ if (typeof t != "function") return;
20
+ let n = Promise.withResolvers();
21
+ return queueMicrotask(() => {
22
+ try {
23
+ Reflect.apply(t, e, [n.resolve, n.reject]);
24
+ } catch (e) {
25
+ n.reject(e);
26
+ }
27
+ }), n.promise;
28
+ }
29
+ // src/internal/abort.ts
30
+ function s(e) {
31
+ return Reflect.get(AbortSignal.prototype, "aborted", e);
32
+ }
33
+ function c(e) {
34
+ return Reflect.get(AbortSignal.prototype, "reason", e);
35
+ }
36
+ function l(t, n) {
37
+ if (typeof n != "function") throw TypeError("Abort listener must be a function");
38
+ if (s(t)) return n(c(t)), () => {};
39
+ let r = {
40
+ signal: t,
41
+ callback: n
42
+ }, i;
43
+ function a() {
44
+ r = void 0, i?.(), i = void 0;
45
+ }
46
+ function o() {
47
+ if (!r || !s(r.signal)) return;
48
+ let { signal: e, callback: t } = r, n = c(e);
49
+ a(), t(n);
50
+ }
51
+ return i = e(t, o), r ? o() : a(), a;
52
+ }
53
+ // src/internal/data-array.ts
54
+ function u(e, t) {
55
+ if (!Array.isArray(e)) throw TypeError(`${t} must be an array`);
56
+ let n = Reflect.ownKeys(e), r = n.length - 1;
57
+ if (r !== Reflect.getOwnPropertyDescriptor(e, "length")?.value) throw TypeError(`${t} must be a dense array`);
58
+ let i = [];
59
+ for (let a of n) {
60
+ if (a === "length") continue;
61
+ let n = typeof a == "string" ? Number(a) : NaN;
62
+ if (!Number.isInteger(n) || n < 0 || n >= r || String(n) !== a) throw TypeError(`${t} must contain only dense array indices`);
63
+ let o = Reflect.getOwnPropertyDescriptor(e, a);
64
+ if (!o || !("value" in o)) throw TypeError(`${t} must contain data properties`);
65
+ i[n] = o.value;
66
+ }
67
+ return Object.freeze(i);
68
+ }
69
+ // src/contracts/errors.ts
70
+ var d = class extends Error {
71
+ name = "DougongError";
72
+ code;
73
+ details;
74
+ constructor(e, t, n) {
75
+ if (typeof e != "string" || e.trim() !== e || e.length === 0) throw TypeError("DougongError code must be a non-empty trimmed string");
76
+ if (typeof t != "string") throw TypeError("DougongError message must be a string");
77
+ super(t, n), this.code = e;
78
+ let r = { ...n?.details };
79
+ r.dependencyPath !== void 0 && (r.dependencyPath = u(r.dependencyPath, "Dependency path")), r.affectedInstallations !== void 0 && (r.affectedInstallations = u(r.affectedInstallations, "Affected Installations")), this.details = Object.freeze(r);
80
+ }
81
+ };
82
+ function f(e) {
83
+ return new d("HOST_QUARANTINED", "Host execution is permanently quarantined", { details: {
84
+ outcome: "quarantined",
85
+ stateRevision: e
86
+ } });
87
+ }
88
+ var p = class e extends Error {
89
+ name = "RecordedFailure";
90
+ code;
91
+ #e;
92
+ get snapshot() {
93
+ return this.#e;
94
+ }
95
+ static #t(e) {
96
+ return typeof e == "object" && e && #e in e ? e.#e : void 0;
97
+ }
98
+ constructor(t, n = []) {
99
+ let r = u(n, "Diagnostic field names");
100
+ if (r.length > 8 || r.some((e) => typeof e != "string" || !e || e.length > 256)) throw TypeError("Select at most eight diagnostic field names of 1–256 characters each");
101
+ let i = e.#t(t) ?? m(t, e.#t, new Set(r));
102
+ super(i.message), this.code = i.code, this.#e = i, this.stack = i.stack ?? `${this.name}: ${i.message}`, Object.freeze(this);
103
+ }
104
+ };
105
+ function m(e, t, n) {
106
+ let r = /* @__PURE__ */ new Set(), i = 32, a = (e, o, s = !1) => {
107
+ let c = s ? e : t(e), l = c ?? e;
108
+ if (o > 4 || i-- <= 0 || r.has(l)) return Object.freeze({
109
+ name: "TruncatedError",
110
+ message: "Error chain truncated",
111
+ truncated: !0
112
+ });
113
+ if (!c && !h(l)) {
114
+ let e = l === null || [
115
+ "string",
116
+ "number",
117
+ "boolean",
118
+ "undefined",
119
+ "bigint",
120
+ "symbol"
121
+ ].includes(typeof l) ? String(l) : "Non-Error object omitted";
122
+ return Object.freeze({
123
+ name: "NonError",
124
+ message: e.slice(0, 4096),
125
+ ...e.length > 4096 ? { truncated: !0 } : {}
126
+ });
127
+ }
128
+ r.add(l);
129
+ let u = c?.truncated ?? !1, d = (e, t) => (e.length > t && (u = !0), e.slice(0, t)), f = (e, t) => {
130
+ let n = v(l, e);
131
+ return typeof n == "string" ? d(n, t) : void 0;
132
+ }, p = (e, t) => {
133
+ if (!g(e)) return;
134
+ let n = v(e, "length");
135
+ if (!(typeof n != "number" || !Number.isSafeInteger(n) || n < 0)) return n > t && (u = !0), Array.from({ length: Math.min(n, t) }, (t, n) => v(e, n));
136
+ }, m = f("name", 256) ?? "Error", y = f("message", 4096) ?? "", b = f("stack", 16384), x = f("code", 256), S = v(l, "cause"), C = p(v(l, "errors"), 8), w = (e, t) => {
137
+ let n = p(e, t);
138
+ return n && Object.freeze(n.filter((e) => typeof e == "string").map((e) => d(e, 256)));
139
+ }, T = c?.fields;
140
+ if (!c && n.size) {
141
+ let e = [];
142
+ for (let t of n) {
143
+ let n = _(l, t), r = typeof n == "string" ? d(n, 256) : w(n, 8);
144
+ r !== void 0 && e.push([t, r]);
145
+ }
146
+ e.length && (T = Object.freeze(Object.fromEntries(e)));
147
+ }
148
+ let E = p(v(l, "issues"), 8)?.map((e) => {
149
+ let t = v(e, "message"), n = p(v(e, "path"), 16)?.map((e) => {
150
+ let t = e && typeof e == "object" ? v(e, "key") : e;
151
+ return typeof t == "number" ? t : typeof t == "string" || typeof t == "symbol" ? d(String(t), 256) : "[omitted]";
152
+ });
153
+ return Object.freeze({
154
+ message: typeof t == "string" ? d(t, 4096) : "",
155
+ ...n ? { path: Object.freeze(n) } : {}
156
+ });
157
+ }), D = v(l, "details"), O;
158
+ if (typeof D == "object" && D) {
159
+ let e = {}, t = v(D, "outcome");
160
+ (t === "rejected" || t === "restored" || t === "quarantined") && (e.outcome = t);
161
+ for (let t of [
162
+ "phase",
163
+ "installation",
164
+ "contract"
165
+ ]) {
166
+ let n = v(D, t);
167
+ typeof n == "string" && (e[t] = d(n, 256));
168
+ }
169
+ for (let t of ["stateRevision", "expectedRevision"]) {
170
+ let n = v(D, t);
171
+ typeof n == "number" && Number.isSafeInteger(n) && n >= 0 && (e[t] = n);
172
+ }
173
+ for (let t of ["dependencyPath", "affectedInstallations"]) {
174
+ let n = w(v(D, t), 32);
175
+ n && (e[t] = n);
176
+ }
177
+ O = Object.freeze(e);
178
+ }
179
+ return Object.freeze({
180
+ name: m,
181
+ message: y,
182
+ ...x === void 0 ? {} : { code: x },
183
+ ...b === void 0 ? {} : { stack: b },
184
+ ...S === void 0 ? {} : { cause: a(S, o + 1, !!c) },
185
+ ...C === void 0 ? {} : { errors: Object.freeze(C.map((e) => a(e, o + 1, !!c))) },
186
+ ...T === void 0 ? {} : { fields: T },
187
+ ...E === void 0 ? {} : { issues: Object.freeze(E) },
188
+ ...O === void 0 ? {} : { details: O },
189
+ ...u ? { truncated: !0 } : {}
190
+ });
191
+ };
192
+ return a(e, 0);
193
+ }
194
+ function h(e) {
195
+ try {
196
+ return e instanceof Error;
197
+ } catch {
198
+ return !1;
199
+ }
200
+ }
201
+ function g(e) {
202
+ try {
203
+ return Array.isArray(e);
204
+ } catch {
205
+ return !1;
206
+ }
207
+ }
208
+ function _(e, t) {
209
+ try {
210
+ return Object.getOwnPropertyDescriptor(e, t)?.value;
211
+ } catch {
212
+ return;
213
+ }
214
+ }
215
+ function v(e, t) {
216
+ try {
217
+ return e && typeof e == "object" ? e[t] : void 0;
218
+ } catch {
219
+ return;
220
+ }
221
+ }
222
+ function y(e, t) {
223
+ try {
224
+ if (!s(e)) return !1;
225
+ } catch (e) {
226
+ throw TypeError("Cancellation classifier expects an AbortSignal", { cause: e });
227
+ }
228
+ return Object.is(t, c(e)) ? !0 : h(t) && v(t, "name") === "AbortError";
229
+ }
230
+ var b = class extends d {
231
+ name = "ConfigurationValidationError";
232
+ issues;
233
+ constructor(e, t) {
234
+ let n = x(e);
235
+ super("CONFIGURATION_INVALID", `Invalid Plugin configuration:\n${n.map((e) => ` - ${e.message}`).join("\n")}`, t), this.issues = n;
236
+ }
237
+ };
238
+ function x(e) {
239
+ return Object.freeze(u(e, "Configuration validation issues").map((e, t) => {
240
+ if (!e || typeof e != "object") throw TypeError(`Configuration validation issue at index ${t} must be an object`);
241
+ let n = e, r = n.message;
242
+ if (typeof r != "string") throw TypeError(`Configuration validation issue at index ${t} message must be a string`);
243
+ let i = n.path;
244
+ return Object.freeze({
245
+ message: r,
246
+ ...i === void 0 ? {} : { path: S(i, t) }
247
+ });
248
+ }));
249
+ }
250
+ function S(e, t) {
251
+ return Object.freeze(u(e, `Configuration validation issue at index ${t} path`).map((e, n) => {
252
+ if (C(e)) return e;
253
+ if (!e || typeof e != "object") throw TypeError(`Configuration validation issue at index ${t} path segment ${n} must be a property key`);
254
+ let r = e.key;
255
+ if (!C(r)) throw TypeError(`Configuration validation issue at index ${t} path segment ${n} must contain a property key`);
256
+ return Object.freeze({ key: r });
257
+ }));
258
+ }
259
+ function C(e) {
260
+ return typeof e == "string" || typeof e == "number" || typeof e == "symbol";
261
+ }
262
+ // src/observation/snapshot-view.ts
263
+ var w = /* @__PURE__ */ new WeakMap(), T = /* @__PURE__ */ new Set(), E = 0, D = !1;
264
+ function O(e) {
265
+ E++;
266
+ let t = [];
267
+ try {
268
+ a(e(), "Snapshot notification batches must be synchronous");
269
+ } catch (e) {
270
+ t.push(e);
271
+ } finally {
272
+ if (E--, !E) try {
273
+ k();
274
+ } catch (e) {
275
+ t.push(e);
276
+ }
277
+ }
278
+ if (t.length === 1) throw t[0];
279
+ if (t.length > 1) throw AggregateError(t, "Snapshot batch failed");
280
+ }
281
+ function k() {
282
+ if (D) return;
283
+ D = !0;
284
+ let e = [];
285
+ try {
286
+ for (; T.size;) {
287
+ let t = T.values().next().value;
288
+ T.delete(t), M(t, e);
289
+ }
290
+ } finally {
291
+ D = !1, T.clear();
292
+ }
293
+ if (e.length) throw AggregateError(e, "Snapshot error reporting failed");
294
+ }
295
+ var A = class {
296
+ #e = /* @__PURE__ */ new Set();
297
+ #t;
298
+ #n;
299
+ #r = !1;
300
+ #i = !1;
301
+ constructor(e, t) {
302
+ if (typeof e != "function") throw TypeError("Snapshot reader must be a function");
303
+ if (typeof t != "function") throw TypeError("Snapshot error reporter must be a function");
304
+ this.#t = {
305
+ phase: "active",
306
+ read: e,
307
+ report: t
308
+ }, this.#n = {
309
+ phase: "value",
310
+ value: e()
311
+ }, Object.freeze(this);
312
+ }
313
+ view = Object.freeze({
314
+ get: () => this.#a(),
315
+ subscribe: (e) => this.#o(e)
316
+ });
317
+ invalidate() {
318
+ this.#c(), this.#r = !0;
319
+ for (let e of this.#e) T.add(e);
320
+ E || k();
321
+ }
322
+ [r]() {
323
+ let e = this.#t;
324
+ if (e.phase !== "disposed") {
325
+ if (this.#i) throw TypeError("Cannot dispose a snapshot publisher while its reader is running");
326
+ this.#t = { phase: "disposed" };
327
+ try {
328
+ this.#s(e.read);
329
+ } finally {
330
+ this.#r = !1;
331
+ let e = [...this.#e];
332
+ this.#e.clear();
333
+ for (let t of e) N(t);
334
+ }
335
+ }
336
+ }
337
+ #a() {
338
+ if (this.#i) throw TypeError("Circular snapshot read");
339
+ let e = this.#t;
340
+ e.phase === "active" && this.#s(e.read);
341
+ let t = this.#n;
342
+ if (t.phase === "error") throw t.error;
343
+ return t.value;
344
+ }
345
+ #o(e) {
346
+ if (typeof e != "function") throw TypeError("Subscriber must be a function");
347
+ let { report: t } = this.#c(), n = new j(e, t, (e) => {
348
+ this.#e.delete(e);
349
+ });
350
+ return this.#e.add(n), n;
351
+ }
352
+ #s(e) {
353
+ this.#r && O(() => {
354
+ this.#r = !1, this.#i = !0;
355
+ try {
356
+ this.#n = {
357
+ phase: "value",
358
+ value: e()
359
+ };
360
+ } catch (e) {
361
+ throw this.#r = !0, this.#t.phase === "disposed" && (this.#n = {
362
+ phase: "error",
363
+ error: new p(e)
364
+ }), e;
365
+ } finally {
366
+ this.#i = !1;
367
+ }
368
+ });
369
+ }
370
+ #c() {
371
+ let e = this.#t;
372
+ if (e.phase === "disposed") throw TypeError("Snapshot publisher is disposed");
373
+ return e;
374
+ }
375
+ }, j = class {
376
+ constructor(e, t, n) {
377
+ w.set(this, {
378
+ listener: e,
379
+ report: t,
380
+ detach: n
381
+ }), Object.freeze(this);
382
+ }
383
+ [r]() {
384
+ let e = w.get(this);
385
+ e && (N(this), e.detach(this));
386
+ }
387
+ };
388
+ function M(e, t) {
389
+ let n = w.get(e);
390
+ if (n) try {
391
+ let { listener: e } = n;
392
+ a(e(), "Snapshot subscribers must be synchronous");
393
+ } catch (e) {
394
+ try {
395
+ let { report: t } = n;
396
+ a(t(e), "Snapshot error reporters must be synchronous");
397
+ } catch (n) {
398
+ t.push(e, n);
399
+ }
400
+ }
401
+ }
402
+ function N(e) {
403
+ T.delete(e), w.delete(e);
404
+ }
405
+ // src/contracts/logging.ts
406
+ function P(e) {
407
+ if (!e || typeof e != "object" && typeof e != "function") throw TypeError("Logger must implement debug/info/warn/error");
408
+ let t = (t) => {
409
+ let n = e[t];
410
+ if (typeof n != "function") throw TypeError("Logger must implement debug/info/warn/error");
411
+ return (...t) => Reflect.apply(n, e, t);
412
+ };
413
+ return Object.freeze({
414
+ debug: t("debug"),
415
+ info: t("info"),
416
+ warn: t("warn"),
417
+ error: t("error")
418
+ });
419
+ }
420
+ function F(e) {
421
+ try {
422
+ return P(e), !0;
423
+ } catch {
424
+ return !1;
425
+ }
426
+ }
427
+ var I = class {
428
+ handle = Object.freeze({
429
+ debug: (e, ...t) => this.#t("debug", e, t),
430
+ info: (e, ...t) => this.#t("info", e, t),
431
+ warn: (e, ...t) => this.#t("warn", e, t),
432
+ error: (e, ...t) => this.#t("error", e, t)
433
+ });
434
+ #e;
435
+ constructor(e, t) {
436
+ this.#e = {
437
+ logger: e,
438
+ metadata: t
439
+ };
440
+ }
441
+ [r]() {
442
+ this.#e = void 0;
443
+ }
444
+ #t(e, t, n) {
445
+ let r = this.#e;
446
+ if (!r) throw new d("LIFETIME_DISPOSED", "Logger scope has ended");
447
+ a(r.logger[e](t, r.metadata, ...n), "Logger methods must be synchronous");
448
+ }
449
+ }, L = class {
450
+ #e = /* @__PURE__ */ new Set();
451
+ #t = !1;
452
+ get settled() {
453
+ return this.run(() => void 0);
454
+ }
455
+ run(e, t) {
456
+ if (typeof e != "function") throw TypeError("SerialQueue operation must be a function");
457
+ let n = Promise.withResolvers(), r = n.promise.then(() => void 0, () => void 0), i = () => {
458
+ a?.();
459
+ try {
460
+ n.resolve(e());
461
+ } catch (e) {
462
+ n.reject(e);
463
+ }
464
+ return r;
465
+ }, a = t === void 0 ? void 0 : l(t, (e) => {
466
+ this.#e.delete(i), n.reject(e);
467
+ });
468
+ return t !== void 0 && s(t) || (this.#e.add(i), this.#t || (this.#t = !0, queueMicrotask(() => void this.#n()))), n.promise;
469
+ }
470
+ async #n() {
471
+ for (let e of this.#e) this.#e.delete(e), await e();
472
+ this.#t = !1;
473
+ }
474
+ };
475
+ // src/internal/record.ts
476
+ function R(e, t, n = {}) {
477
+ if (!e || typeof e != "object" || Array.isArray(e)) throw z(n, `${t} must be a plain record`);
478
+ let r = Object.getPrototypeOf(e);
479
+ if (r !== Object.prototype && r !== null) throw z(n, `${t} must be a plain record`);
480
+ let i = Object.create(null);
481
+ for (let r of Reflect.ownKeys(e)) {
482
+ let a = Reflect.getOwnPropertyDescriptor(e, r);
483
+ if (typeof r != "string" || !a?.enumerable) throw z(n, `${t} keys must be enumerable strings`);
484
+ if (!("value" in a)) throw z(n, `${t} field '${r}' must be a data property`);
485
+ if (n.fields && !n.fields.has(r)) throw z(n, `${t}: unknown field '${r}'`);
486
+ i[r] = a.value;
487
+ }
488
+ return Object.freeze(i);
489
+ }
490
+ function z(e, t) {
491
+ return e.createError?.(t) ?? TypeError(t);
492
+ }
493
+ export { l as _, F as a, r as b, b as c, y as d, h as f, s as g, c as h, P as i, d as l, u as m, L as n, A as o, f as p, I as r, O as s, R as t, p as u, a as v, i as y };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dougong",
3
- "version": "0.8.2",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=22"
@@ -8,12 +8,13 @@
8
8
  "browserslist": [
9
9
  "Chrome >= 119",
10
10
  "Edge >= 119",
11
- "Firefox >= 121",
11
+ "Firefox >= 124",
12
12
  "Safari >= 17.4"
13
13
  ],
14
14
  "sideEffects": false,
15
15
  "files": [
16
16
  "dist",
17
+ "runtime",
17
18
  "README.md",
18
19
  "LICENSE"
19
20
  ],
@@ -21,14 +22,23 @@
21
22
  ".": {
22
23
  "types": "./dist/index.d.ts",
23
24
  "import": "./dist/index.js"
25
+ },
26
+ "./advanced": {
27
+ "types": "./dist/advanced.d.ts",
28
+ "import": "./dist/advanced.js"
29
+ }
30
+ },
31
+ "imports": {
32
+ "#abort-listener": {
33
+ "types": "./runtime/abort-listener.d.mts",
34
+ "node": "./runtime/abort-listener.node.mjs",
35
+ "default": "./runtime/abort-listener.web.mjs"
24
36
  }
25
37
  },
26
38
  "dependencies": {
27
- "@dougongjs/platform": "0.8.2",
28
- "@dougongjs/core": "0.8.2",
29
- "@dougongjs/reactive": "0.8.2"
39
+ "@standard-schema/spec": "^1.1.0"
30
40
  },
31
- "description": "Capability composition and structured lifetime kernel, plus its plugin distribution layer.",
41
+ "description": "Capability composition and structured lifetime kernel for JavaScript/TypeScript.",
32
42
  "license": "MIT",
33
43
  "author": "Dougong contributors",
34
44
  "homepage": "https://tangerg.github.io/dougong/",
@@ -52,6 +62,6 @@
52
62
  "access": "public"
53
63
  },
54
64
  "scripts": {
55
- "build": "vite build"
65
+ "build": "node ../../tooling/generate-internal.mjs && vite build"
56
66
  }
57
67
  }
@@ -0,0 +1,2 @@
1
+ // Generated from tooling/internal/abort-listener.d.mts. Run pnpm generate:internal.
2
+ export function listenForAbort(signal: AbortSignal, notify: () => void): () => void;
@@ -0,0 +1,26 @@
1
+ // Generated from tooling/internal/abort-listener.node.mjs. Run pnpm generate:internal.
2
+ import { addAbortListener } from "node:events";
3
+
4
+ export function listenForAbort(signal, notify) {
5
+ // Node supplies stop-resistant listener options to this private registration signal.
6
+ // The caller's genuine EventTarget owns the actual listener and its native GC bookkeeping.
7
+ const registration = new AbortController().signal;
8
+ let detach;
9
+ registration.addEventListener = (type, listener, options) => {
10
+ detach = () => EventTarget.prototype.removeEventListener.call(signal, type, listener);
11
+ try {
12
+ // Only native cancellation may consume the listener. Synthetic abort events can arrive first.
13
+ EventTarget.prototype.addEventListener.call(signal, type, listener, {
14
+ ...options,
15
+ once: false,
16
+ });
17
+ } catch (error) {
18
+ // A native listener hook may throw before or after insertion.
19
+ detach();
20
+ throw error;
21
+ }
22
+ };
23
+ addAbortListener(registration, notify);
24
+ if (!detach) throw new Error("Node did not attach the protected abort listener");
25
+ return detach;
26
+ }
@@ -0,0 +1,7 @@
1
+ // Generated from tooling/internal/abort-listener.web.mjs. Run pnpm generate:internal.
2
+ // Only the controller can abort this private dependent; other listeners can stop propagation on the source.
3
+ export function listenForAbort(signal, notify) {
4
+ const dependent = AbortSignal.any([signal]);
5
+ dependent.addEventListener("abort", notify);
6
+ return () => dependent.removeEventListener("abort", notify);
7
+ }