Skip to content

Commit b513102

Browse files
fix: use both .d.cts and .d.mts extensions for all type files
1 parent fdb302a commit b513102

14 files changed

+740
-20
lines changed

index.d.cts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type {TestFn} from './types/test-fn.cjs';
2+
3+
/** Call to declare a test, or chain to declare hooks or test modifiers */
4+
declare const test: TestFn;
5+
6+
/** Call to declare a test, or chain to declare hooks or test modifiers */
7+
export = test;

index.d.mts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type {TestFn} from './types/test-fn.mjs';
2+
3+
export * from './types/assertions.mjs';
4+
export * from './types/try-fn.mjs';
5+
export * from './types/test-fn.mjs';
6+
export * from './types/subscribable.mjs';
7+
8+
/** Call to declare a test, or chain to declare hooks or test modifiers */
9+
declare const test: TestFn;
10+
11+
/** Call to declare a test, or chain to declare hooks or test modifiers */
12+
export default test;

index.d.ts

-12
This file was deleted.

package.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"exports": {
1212
".": {
1313
"import": {
14-
"types": "./index.d.ts",
14+
"types": "./index.d.mts",
1515
"default": "./entrypoints/main.mjs"
1616
},
1717
"require": {
@@ -22,7 +22,7 @@
2222
"./eslint-plugin-helper": "./entrypoints/eslint-plugin-helper.cjs",
2323
"./plugin": {
2424
"import": {
25-
"types": "./plugin.d.ts",
25+
"types": "./plugin.d.mts",
2626
"default": "./entrypoints/plugin.mjs"
2727
},
2828
"require": {
@@ -43,8 +43,10 @@
4343
"entrypoints",
4444
"lib",
4545
"types",
46-
"index.d.ts",
47-
"plugin.d.ts"
46+
"index.d.cts",
47+
"index.d.mts",
48+
"plugin.d.cts",
49+
"plugin.d.mts"
4850
],
4951
"keywords": [
5052
"🦄",
File renamed without changes.

plugin.d.mts

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import {URL} from 'node:url';
2+
3+
export namespace SharedWorker {
4+
export type ProtocolIdentifier = 'ava-4';
5+
6+
export type FactoryOptions = {
7+
negotiateProtocol <Data = unknown>(supported: readonly ['ava-4']): Protocol<Data>;
8+
// Add overloads for additional protocols.
9+
};
10+
11+
export type Factory = (options: FactoryOptions) => void;
12+
13+
export type Protocol<Data = unknown> = {
14+
readonly initialData: Data;
15+
readonly protocol: 'ava-4';
16+
broadcast: (data: Data) => BroadcastMessage<Data>;
17+
ready: () => Protocol<Data>;
18+
subscribe: () => AsyncIterableIterator<ReceivedMessage<Data>>;
19+
testWorkers: () => AsyncIterableIterator<TestWorker<Data>>;
20+
};
21+
22+
export type BroadcastMessage<Data = unknown> = {
23+
readonly id: string;
24+
replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
25+
};
26+
27+
export type PublishedMessage<Data = unknown> = {
28+
readonly id: string;
29+
replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
30+
};
31+
32+
export type ReceivedMessage<Data = unknown> = {
33+
readonly data: Data;
34+
readonly id: string;
35+
readonly testWorker: TestWorker;
36+
reply: (data: Data) => PublishedMessage<Data>;
37+
};
38+
39+
export type TestWorker<Data = unknown> = {
40+
readonly id: string;
41+
readonly file: string;
42+
publish: (data: Data) => PublishedMessage<Data>;
43+
subscribe: () => AsyncIterableIterator<ReceivedMessage<Data>>;
44+
teardown: (fn: (() => Promise<void>) | (() => void)) => () => Promise<void>;
45+
};
46+
47+
export namespace Plugin {
48+
export type RegistrationOptions<Identifier extends ProtocolIdentifier, Data = unknown> = {
49+
readonly filename: string | URL;
50+
readonly initialData?: Data;
51+
readonly supportedProtocols: readonly Identifier[];
52+
readonly teardown?: () => void;
53+
};
54+
55+
export type Protocol<Data = unknown> = {
56+
readonly available: Promise<void>;
57+
readonly currentlyAvailable: boolean;
58+
readonly protocol: 'ava-4';
59+
publish: (data: Data) => PublishedMessage<Data>;
60+
subscribe: () => AsyncIterableIterator<ReceivedMessage<Data>>;
61+
};
62+
63+
export type PublishedMessage<Data = unknown> = {
64+
readonly id: string;
65+
replies: () => AsyncIterableIterator<ReceivedMessage<Data>>;
66+
};
67+
68+
export type ReceivedMessage<Data = unknown> = {
69+
readonly data: Data;
70+
readonly id: string;
71+
reply: (data: Data) => PublishedMessage<Data>;
72+
};
73+
}
74+
}
75+
76+
export function registerSharedWorker<Data = unknown>(options: SharedWorker.Plugin.RegistrationOptions<'ava-4', Data>): SharedWorker.Plugin.Protocol<Data>;
77+
// Add overloads for additional protocols.
File renamed without changes.

0 commit comments

Comments
 (0)