@bodil/signal 0.3.4 → 0.4.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.
@@ -0,0 +1,200 @@
1
+ import { type Disposifiable } from "@bodil/core/disposable";
2
+ import { Signal as SignalPolyfill } from "signal-polyfill";
3
+ import { ReadonlySignalArray, SignalArray } from "./array";
4
+ import { ReadonlySignalMap, SignalMap } from "./map";
5
+ declare const SystemSignal: typeof SignalPolyfill;
6
+ /** @namespace */
7
+ export declare const subtle: typeof SignalPolyfill.subtle;
8
+ export declare namespace subtle {
9
+ /** @hidden */
10
+ type Watcher = SignalPolyfill.subtle.Watcher;
11
+ }
12
+ export type Options<A> = {
13
+ /** @internal */
14
+ [subtle.unwatched]?: () => void;
15
+ /** @internal */
16
+ [subtle.watched]?: () => void;
17
+ /**
18
+ * A function used to compare the new value of a signal with the previous
19
+ * value when the signal's value updates. If the function returns false,
20
+ * this will cause the signal's dependencies to update themselves with the
21
+ * new value, because the value is considered to have changed. If the
22
+ * function returns true, dependencies will not be updated, because no
23
+ * change is considered to have occurred.
24
+ *
25
+ * This option defaults to using {@link Object.is}.
26
+ */
27
+ equals?: (a: A, b: A) => boolean;
28
+ };
29
+ interface ISignal<A> {
30
+ /**
31
+ * The current value of the signal.
32
+ *
33
+ * When this is read inside a computation function or an effect function,
34
+ * this signal is automatically added to the effect or computed signal as a
35
+ * dependency.
36
+ */
37
+ readonly value: A;
38
+ /**
39
+ * Construct a {@link Signal.Computed} signal using a mapping function over
40
+ * the current value of this signal.
41
+ */
42
+ map<B>(fn: (value: A) => B): Computed<B>;
43
+ /**
44
+ * Subscribe to changes to the value of this signal.
45
+ */
46
+ on(callback: (value: A) => void): Disposable;
47
+ /**
48
+ * Get the current value of the signal.
49
+ *
50
+ * When this is called inside a computation function or an effect function,
51
+ * this signal is automatically added to the effect or computed signal as a
52
+ * dependency.
53
+ */
54
+ get(): A;
55
+ }
56
+ /**
57
+ * A signal which contains a writable value.
58
+ */
59
+ export declare class State<A> extends SystemSignal.State<A> implements ISignal<A> {
60
+ get value(): A;
61
+ set value(value: A);
62
+ get(): A;
63
+ /**
64
+ * Set the current value of the signal.
65
+ *
66
+ * This triggers an update of every dependency of the signal. Computed
67
+ * signals will recompute the next time they're read, and effects will be
68
+ * scheduled to run as soon as possible.
69
+ */
70
+ set(value: A): void;
71
+ /**
72
+ * @internal
73
+ * @hidden
74
+ */
75
+ constructor(value: A, options?: Options<A>);
76
+ /**
77
+ * Update the current value of this signal using a function.
78
+ */
79
+ update(fn: (value: A) => A): void;
80
+ /**
81
+ * Get a read only version of this signal.
82
+ */
83
+ readOnly(): Computed<A>;
84
+ map<B>(fn: (value: A) => B): Computed<B>;
85
+ on(callback: (value: A) => void): Disposable;
86
+ /**
87
+ * Test whether a value is a {@link Signal.State} signal.
88
+ */
89
+ static is(v: unknown): v is State<unknown>;
90
+ }
91
+ /**
92
+ * A signal which contains a reactive computation.
93
+ *
94
+ * @property get
95
+ * Get the current value of the signal.
96
+ *
97
+ * When this is called inside a computation function or an effect function,
98
+ * this signal is automatically added to the effect or computed signal as a
99
+ * dependency.
100
+ */
101
+ export declare class Computed<A> extends SystemSignal.Computed<A> implements ISignal<A> {
102
+ get value(): A;
103
+ get(): A;
104
+ /**
105
+ * @internal
106
+ * @hidden
107
+ */
108
+ constructor(computeFn: () => A, options?: Options<A>);
109
+ map<B>(fn: (value: A) => B): Computed<B>;
110
+ on(callback: (value: A) => void): Disposable;
111
+ /**
112
+ * Test whether a value is a {@link Signal.Computed} signal.
113
+ */
114
+ static is(v: unknown): v is Computed<unknown>;
115
+ }
116
+ /**
117
+ * A type representing any kind of signal, either a {@link Signal.State} or a
118
+ * {@link Signal.Computed}.
119
+ */
120
+ export type Any<A> = State<A> | Computed<A>;
121
+ /**
122
+ * Test whether the given value is a signal.
123
+ *
124
+ * @see {@link Signal.State.is}, {@link Signal.Computed.is}
125
+ */
126
+ export declare function is(v: unknown): v is Any<unknown>;
127
+ /**
128
+ * Construct a new {@link Signal.State} signal containing the provided value.
129
+ *
130
+ * @example
131
+ * const sig = Signal.state("Hello Joe!");
132
+ */
133
+ export declare function from<A>(value: A, options?: Options<A>): State<A>;
134
+ /**
135
+ * {@inheritDoc from}
136
+ * @function
137
+ */
138
+ export declare const state: typeof from;
139
+ /**
140
+ * Construct a new {@link Signal.Computed} signal using the provided
141
+ * computation function.
142
+ *
143
+ * @example
144
+ * const sig1 = Signal.from(2);
145
+ * const sig2 = Signal.from(3);
146
+ * const sum = Signal.computed(() => sig1.get() + sig2.get());
147
+ * assert(sum.get() === 5);
148
+ * sig1.set(4);
149
+ * assert(sum.get() === 7);
150
+ */
151
+ export declare function computed<A>(fn: (this: Computed<A>) => A, options?: Options<A>): Computed<A>;
152
+ /**
153
+ * Suscribe to a signal.
154
+ *
155
+ * The provided callback will be called every time the value of the
156
+ * signal changes.
157
+ */
158
+ export declare function subscribe<A>(signal: Any<A>, callback: (value: A) => void): Disposable;
159
+ /**
160
+ * Create an effect responding to signal changes.
161
+ *
162
+ * The provided function will be called immediately, and again every
163
+ * time a signal that was read by the function changes.
164
+ *
165
+ * @example
166
+ * const sig = Signal.from("Hello Joe!");
167
+ * effect(() => console.log("Signal value is:", sig.get()));
168
+ * // prints "Signal value is: Hello Joe!"
169
+ * sig.set("Hello Mike!");
170
+ * // prints "Signal value is: Hello Mike!"
171
+ */
172
+ export declare function effect(fn: () => Disposifiable | void): Disposable;
173
+ /**
174
+ * Construct a new {@link Signal.Computed} signal using an async
175
+ * computation function.
176
+ *
177
+ * This returns a promise which will resolve to a
178
+ * {@link Signal.Computed} signal once the promise returned by the
179
+ * computation function resolves, and will update itself whenever
180
+ * subsequent calls to the computation function resolve.
181
+ *
182
+ * The function is provided with an {@link AbortSignal} which any async
183
+ * jobs started from it should abide by. If a signal dependency changes
184
+ * while the job is running, the {@link AbortSignal} will be triggered
185
+ * and the job restarted.
186
+ *
187
+ * @experimental
188
+ */
189
+ export declare function asyncComputed<A>(fn: (abort: AbortSignal) => Promise<A>, options?: Options<A>): Promise<Computed<A>>;
190
+ /**
191
+ * Create a new {@link Signal.Array} and optionally populate it from the
192
+ * provided {@link Iterable}.
193
+ */
194
+ export declare function array<A>(values?: Iterable<A>): SignalArray<A>;
195
+ /**
196
+ * Create a new {@link Signal.Map} and optionally populate it from the
197
+ * provided {@link Iterable}.
198
+ */
199
+ export declare function map<K, V>(entries?: Iterable<[K, V]>): SignalMap<K, V>;
200
+ export { SignalArray as Array, ReadonlySignalArray as ReadonlyArray, SignalMap as Map, ReadonlySignalMap as ReadonlyMap, };
package/dist/signal.js ADDED
@@ -0,0 +1,263 @@
1
+ import { AbortablePromise } from "@bodil/core/async";
2
+ import { toDisposable } from "@bodil/core/disposable";
3
+ import { Err, Ok } from "@bodil/opt";
4
+ import { Signal as SignalPolyfill } from "signal-polyfill";
5
+ import { ReadonlySignalArray, SignalArray } from "./array";
6
+ import { ReadonlySignalMap, SignalMap } from "./map";
7
+ const SystemSignal = globalThis.Signal ?? SignalPolyfill;
8
+ /** @namespace */
9
+ export const subtle = SystemSignal.subtle;
10
+ /**
11
+ * A signal which contains a writable value.
12
+ */
13
+ export class State extends SystemSignal.State {
14
+ get value() {
15
+ return this.get();
16
+ }
17
+ set value(value) {
18
+ this.set(value);
19
+ }
20
+ get() {
21
+ return super.get();
22
+ }
23
+ /**
24
+ * Set the current value of the signal.
25
+ *
26
+ * This triggers an update of every dependency of the signal. Computed
27
+ * signals will recompute the next time they're read, and effects will be
28
+ * scheduled to run as soon as possible.
29
+ */
30
+ set(value) {
31
+ super.set(value);
32
+ }
33
+ /**
34
+ * @internal
35
+ * @hidden
36
+ */
37
+ // eslint-disable-next-line @typescript-eslint/no-useless-constructor
38
+ constructor(value, options) {
39
+ super(value, options);
40
+ }
41
+ /**
42
+ * Update the current value of this signal using a function.
43
+ */
44
+ update(fn) {
45
+ this.set(SystemSignal.subtle.untrack(() => fn(this.get())));
46
+ }
47
+ /**
48
+ * Get a read only version of this signal.
49
+ */
50
+ readOnly() {
51
+ return computed(() => this.get());
52
+ }
53
+ map(fn) {
54
+ return computed(() => fn(this.get()));
55
+ }
56
+ on(callback) {
57
+ return subscribe(this, callback);
58
+ }
59
+ /**
60
+ * Test whether a value is a {@link Signal.State} signal.
61
+ */
62
+ static is(v) {
63
+ return v instanceof State;
64
+ }
65
+ }
66
+ /**
67
+ * A signal which contains a reactive computation.
68
+ *
69
+ * @property get
70
+ * Get the current value of the signal.
71
+ *
72
+ * When this is called inside a computation function or an effect function,
73
+ * this signal is automatically added to the effect or computed signal as a
74
+ * dependency.
75
+ */
76
+ export class Computed extends SystemSignal.Computed {
77
+ get value() {
78
+ return this.get();
79
+ }
80
+ get() {
81
+ return super.get();
82
+ }
83
+ /**
84
+ * @internal
85
+ * @hidden
86
+ */
87
+ // eslint-disable-next-line @typescript-eslint/no-useless-constructor
88
+ constructor(computeFn, options) {
89
+ super(computeFn, options);
90
+ }
91
+ map(fn) {
92
+ return computed(() => fn(this.get()));
93
+ }
94
+ on(callback) {
95
+ return subscribe(this, callback);
96
+ }
97
+ /**
98
+ * Test whether a value is a {@link Signal.Computed} signal.
99
+ */
100
+ static is(v) {
101
+ return v instanceof Computed;
102
+ }
103
+ }
104
+ let effectNeedsEnqueue = true;
105
+ const effectWatcher = new SystemSignal.subtle.Watcher(() => {
106
+ if (effectNeedsEnqueue) {
107
+ effectNeedsEnqueue = false;
108
+ queueMicrotask(effectProcess);
109
+ }
110
+ });
111
+ function effectProcess() {
112
+ effectNeedsEnqueue = true;
113
+ for (const sig of effectWatcher.getPending()) {
114
+ sig.get();
115
+ }
116
+ effectWatcher.watch();
117
+ }
118
+ /**
119
+ * Test whether the given value is a signal.
120
+ *
121
+ * @see {@link Signal.State.is}, {@link Signal.Computed.is}
122
+ */
123
+ export function is(v) {
124
+ return State.is(v) || Computed.is(v);
125
+ }
126
+ /**
127
+ * Construct a new {@link Signal.State} signal containing the provided value.
128
+ *
129
+ * @example
130
+ * const sig = Signal.state("Hello Joe!");
131
+ */
132
+ export function from(value, options) {
133
+ return new State(value, options);
134
+ }
135
+ /**
136
+ * {@inheritDoc from}
137
+ * @function
138
+ */
139
+ export const state = from;
140
+ /**
141
+ * Construct a new {@link Signal.Computed} signal using the provided
142
+ * computation function.
143
+ *
144
+ * @example
145
+ * const sig1 = Signal.from(2);
146
+ * const sig2 = Signal.from(3);
147
+ * const sum = Signal.computed(() => sig1.get() + sig2.get());
148
+ * assert(sum.get() === 5);
149
+ * sig1.set(4);
150
+ * assert(sum.get() === 7);
151
+ */
152
+ export function computed(fn, options) {
153
+ return new Computed(fn, options);
154
+ }
155
+ /**
156
+ * Suscribe to a signal.
157
+ *
158
+ * The provided callback will be called every time the value of the
159
+ * signal changes.
160
+ */
161
+ export function subscribe(signal, callback) {
162
+ return effect(() => callback(signal.value));
163
+ }
164
+ /**
165
+ * Create an effect responding to signal changes.
166
+ *
167
+ * The provided function will be called immediately, and again every
168
+ * time a signal that was read by the function changes.
169
+ *
170
+ * @example
171
+ * const sig = Signal.from("Hello Joe!");
172
+ * effect(() => console.log("Signal value is:", sig.get()));
173
+ * // prints "Signal value is: Hello Joe!"
174
+ * sig.set("Hello Mike!");
175
+ * // prints "Signal value is: Hello Mike!"
176
+ */
177
+ export function effect(fn) {
178
+ let cleanup;
179
+ const computed = new Computed(() => {
180
+ if (cleanup !== undefined) {
181
+ cleanup[Symbol.dispose]();
182
+ }
183
+ const result = fn();
184
+ cleanup = result !== undefined ? toDisposable(result) : undefined;
185
+ });
186
+ effectWatcher.watch(computed);
187
+ computed.get();
188
+ return toDisposable(() => {
189
+ effectWatcher.unwatch(computed);
190
+ if (cleanup !== undefined) {
191
+ cleanup[Symbol.dispose]();
192
+ }
193
+ });
194
+ }
195
+ /**
196
+ * Construct a new {@link Signal.Computed} signal using an async
197
+ * computation function.
198
+ *
199
+ * This returns a promise which will resolve to a
200
+ * {@link Signal.Computed} signal once the promise returned by the
201
+ * computation function resolves, and will update itself whenever
202
+ * subsequent calls to the computation function resolve.
203
+ *
204
+ * The function is provided with an {@link AbortSignal} which any async
205
+ * jobs started from it should abide by. If a signal dependency changes
206
+ * while the job is running, the {@link AbortSignal} will be triggered
207
+ * and the job restarted.
208
+ *
209
+ * @experimental
210
+ */
211
+ export function asyncComputed(fn, options) {
212
+ const result = Promise.withResolvers();
213
+ const stream = computed(() => AbortablePromise.run((resolve, reject, abort) => {
214
+ try {
215
+ fn(abort).then(resolve, reject);
216
+ }
217
+ catch (e) {
218
+ reject(e);
219
+ }
220
+ }));
221
+ const sig = new State(Err(new Error()));
222
+ let job = undefined;
223
+ let resolved = false;
224
+ const resolve = () => {
225
+ if (!resolved) {
226
+ resolved = true;
227
+ result.resolve(computed(() => sig.get().unwrapExact(), options));
228
+ }
229
+ };
230
+ effect(() => {
231
+ if (job !== undefined) {
232
+ job.abort();
233
+ }
234
+ job = stream.get();
235
+ job.then((next) => {
236
+ sig.set(Ok(next));
237
+ resolve();
238
+ }, (error) => {
239
+ if (job?.signal.aborted === true) {
240
+ return;
241
+ }
242
+ sig.set(Err(error));
243
+ resolve();
244
+ });
245
+ });
246
+ return result.promise;
247
+ }
248
+ /**
249
+ * Create a new {@link Signal.Array} and optionally populate it from the
250
+ * provided {@link Iterable}.
251
+ */
252
+ export function array(values) {
253
+ return values === undefined ? new SignalArray() : SignalArray.from(values);
254
+ }
255
+ /**
256
+ * Create a new {@link Signal.Map} and optionally populate it from the
257
+ * provided {@link Iterable}.
258
+ */
259
+ export function map(entries) {
260
+ return new SignalMap(entries);
261
+ }
262
+ export { SignalArray as Array, ReadonlySignalArray as ReadonlyArray, SignalMap as Map, ReadonlySignalMap as ReadonlyMap, };
263
+ //# sourceMappingURL=signal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signal.js","sourceRoot":"","sources":["../src/signal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAsB,MAAM,wBAAwB,CAAC;AAC1E,O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AC,CAAC,CAAC;QACrE,CAAC;IACL,CAAC,CAAC;IACF,MAAM,CAAC,GAAG,EAAE;QACR,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACpB,GAAG,CAAC,KAAK,EAAE,CAAC;QAChB,CAAC;QACD,GAAG,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC;QACnB,GAAG,CAAC,IAAI,CACJ,CAAC,IAAI,EAAE,EAAE;YACL,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;YAClB,OAAO,EAAE,CAAC;QACd,CAAC,EACD,CAAC,KAAK,EAAE,EAAE;YACN,IAAI,GAAG,EAAE,MAAM,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;gBAC/B,OAAO;YACX,CAAC;YACD,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;YACpB,OAAO,EAAE,CAAC;QACd,CAAC,CACJ,CAAC;IACN,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,OAAO,CAAC;AAC1B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAI,MAAoB;IACzC,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC/E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,GAAG,CAAO,OAA0B;IAChD,OAAO,IAAI,SAAS,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC;AAED,OAAO,EACH,WAAW,IAAI,KAAK,EACpB,mBAAmB,IAAI,aAAa,EACpC,SAAS,IAAI,GAAG,EAChB,iBAAiB,IAAI,WAAW,GACnC,CAAC"}
@@ -2,7 +2,7 @@ import { sleep } from "@bodil/core/async";
2
2
  import { expect, test } from "vitest";
3
3
  import { Signal } from ".";
4
4
  test("Signal", async () => {
5
- const sig = Signal(0);
5
+ const sig = Signal.state(0);
6
6
  const result = [];
7
7
  Signal.effect(() => void result.push(sig.value));
8
8
  expect(result).toEqual([0]);
@@ -24,7 +24,7 @@ test("Signal", async () => {
24
24
  });
25
25
  test("signal equality", async () => {
26
26
  const result = [];
27
- const sig = Signal(0);
27
+ const sig = Signal.state(0);
28
28
  Signal.effect(() => void result.push(sig.value));
29
29
  expect(result).toEqual([0]);
30
30
  sig.value = 1;
@@ -50,7 +50,7 @@ test("signal equality", async () => {
50
50
  expect(result).toEqual([0, 1, 2, 3, 2]);
51
51
  });
52
52
  test("asyncComputed", async () => {
53
- const s = Signal(1);
53
+ const s = Signal.state(1);
54
54
  const c = await Signal.asyncComputed(() => Promise.resolve(s.value + 1));
55
55
  expect(c.value).toEqual(2);
56
56
  const foo = async () => (await Signal.asyncComputed(() => {
@@ -69,7 +69,7 @@ test("asyncComputed", async () => {
69
69
  expect(c.value).toEqual(4);
70
70
  });
71
71
  test("isSignal", () => {
72
- const s1 = Signal(1);
72
+ const s1 = Signal.state(1);
73
73
  expect(Signal.is(s1)).toBeTruthy();
74
74
  expect(Signal.State.is(s1)).toBeTruthy();
75
75
  expect(Signal.Computed.is(s1)).toBeFalsy();
@@ -80,10 +80,10 @@ test("isSignal", () => {
80
80
  expect(Signal.is("wibble")).toBeFalsy();
81
81
  });
82
82
  test("Signal types", () => {
83
- const s1 = Signal(1);
83
+ const s1 = Signal.state(1);
84
84
  const s2 = Signal.computed(() => s1.get());
85
85
  function foo(_signal) {
86
- // ensure Signal<A> is an accessible type
86
+ // ensure Signal.Any<A> is an accessible type
87
87
  // and that it accepts both concrete signal types.
88
88
  }
89
89
  foo(s1);
@@ -1 +1 @@
1
- {"version":3,"file":"signal.test.js","sourceRoot":"","sources":["../src/signal.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,MAAM,EAAE,MAAM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CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;IACxC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;IAE5C,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;AAC5C,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE;IACtB,MAAM,EAAE,GAAyB,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjD,MAAM,EAAE,GAA4B,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;IAEpE,SAAS,GAAG,CAAC,OAA4B;QACrC,6CAA6C;QAC7C,kDAAkD;IACtD,CAAC;IACD,GAAG,CAAC,EAAE,CAAC,CAAC;IACR,GAAG,CAAC,EAAE,CAAC,CAAC;AAGZ,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bodil/signal",
3
- "version": "0.3.4",
3
+ "version": "0.4.0",
4
4
  "description": "Signal implementation built on the TC39 Signals Proposal",
5
5
  "homepage": "https://codeberg.org/bodil/signal",
6
6
  "repository": {
@@ -36,6 +36,7 @@
36
36
  "@ianvs/prettier-plugin-sort-imports": "^4.7.0",
37
37
  "@typescript-eslint/eslint-plugin": "^8.51.0",
38
38
  "@typescript-eslint/parser": "^8.51.0",
39
+ "@typhonjs-typedoc/ts-lib-docs": "^2024.12.25",
39
40
  "eslint": "^9.39.2",
40
41
  "eslint-config-prettier": "^10.1.8",
41
42
  "eslint-plugin-jsdoc": "^61.5.0",
@@ -45,7 +46,9 @@
45
46
  "typedoc": "^0.28.15",
46
47
  "typedoc-plugin-extras": "^4.0.1",
47
48
  "typedoc-plugin-mdn-links": "^5.0.10",
49
+ "typedoc-theme-fresh": "^0.2.3",
48
50
  "typescript": "^5.9.3",
51
+ "vite-plugin-doctest": "^1.1.1",
49
52
  "vitest": "^4.0.16"
50
53
  },
51
54
  "prettier": {