@browsercore/contracts 0.2.0 → 0.2.1
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/events.d.ts +38 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +12 -0
- package/dist/events.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/net.d.ts +12 -0
- package/dist/net.d.ts.map +1 -1
- package/dist/platform.d.ts +65 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/platform.js +26 -0
- package/dist/platform.js.map +1 -0
- package/dist/telemetry.d.ts +47 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +12 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/time.d.ts +64 -0
- package/dist/time.d.ts.map +1 -0
- package/dist/time.js +23 -0
- package/dist/time.js.map +1 -0
- package/package.json +1 -1
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform-agnostic event contracts.
|
|
3
|
+
*
|
|
4
|
+
* These interfaces describe what BrowserCore needs from an event system.
|
|
5
|
+
* They are implemented by thin adapters (e.g. `browsersmith/src/events/node/`)
|
|
6
|
+
* and injected so the protocol stack stays runtime-agnostic.
|
|
7
|
+
*
|
|
8
|
+
* Design rule: expose only what transport/protocol packages consume.
|
|
9
|
+
* Don't mirror Node's EventEmitter API.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Minimal event emitter surface — the structural subset of
|
|
13
|
+
* `node:events.EventEmitter` that BrowserCore depends on.
|
|
14
|
+
*
|
|
15
|
+
* Any runtime emitter that satisfies these methods can be injected.
|
|
16
|
+
*/
|
|
17
|
+
export interface EventProvider {
|
|
18
|
+
on(event: string, listener: (...args: unknown[]) => void): void;
|
|
19
|
+
once(event: string, listener: (...args: unknown[]) => void): void;
|
|
20
|
+
off(event: string, listener: (...args: unknown[]) => void): void;
|
|
21
|
+
removeListener(event: string, listener: (...args: unknown[]) => void): void;
|
|
22
|
+
emit(event: string, ...args: unknown[]): boolean;
|
|
23
|
+
listenerCount(event: string): number;
|
|
24
|
+
removeAllListeners(event?: string): void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Typed event emitter — maps event names to their listener signatures.
|
|
28
|
+
*
|
|
29
|
+
* Consumers define a map of event handlers and get compile-time
|
|
30
|
+
* type safety on `emit` arguments and `on` callbacks.
|
|
31
|
+
*/
|
|
32
|
+
export interface TypedEventEmitter<T extends Record<string, (...args: unknown[]) => void>> {
|
|
33
|
+
on<K extends keyof T>(event: K, listener: T[K]): void;
|
|
34
|
+
once<K extends keyof T>(event: K, listener: T[K]): void;
|
|
35
|
+
off<K extends keyof T>(event: K, listener: T[K]): void;
|
|
36
|
+
emit<K extends keyof T>(event: K, ...args: Parameters<T[K]>): boolean;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC1B,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;IAChE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;IAClE,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;IACjE,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;IAC5E,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IACjD,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACrC,kBAAkB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5C;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACrF,EAAE,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACtD,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACxD,GAAG,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACvD,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;CACzE"}
|
package/dist/events.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform-agnostic event contracts.
|
|
3
|
+
*
|
|
4
|
+
* These interfaces describe what BrowserCore needs from an event system.
|
|
5
|
+
* They are implemented by thin adapters (e.g. `browsersmith/src/events/node/`)
|
|
6
|
+
* and injected so the protocol stack stays runtime-agnostic.
|
|
7
|
+
*
|
|
8
|
+
* Design rule: expose only what transport/protocol packages consume.
|
|
9
|
+
* Don't mirror Node's EventEmitter API.
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
|
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,10 @@
|
|
|
25
25
|
export type { CryptoProvider, CompressionProvider, Transport, DatagramTransport, TlsConnection, Http1Connection, Http2Connection, Http3Connection, QuicConnection, QuicStream, FetchClient, CookieJar, Clock, PacketCallback, PacketInspectionOptions, } from "./contracts.js";
|
|
26
26
|
export type { ProfileId, BrowserProfile, TlsProfile, Http1Profile, Http2Profile, Request, Response, FetchOptions, FetchResponse, Headers, Cookie, HashId, EcdhCurve, X25519KeyPair, EcdhKeyPair, UdpAddress, TransportState, CloseReason, DatagramCloseReason, TlsState, ContentEncoding, } from "./models.js";
|
|
27
27
|
export { CIPHER_GREASE_PLACEHOLDER, CIPHER_SUITE_CODES, NAMED_GROUP_CODES, SIGNATURE_SCHEME_CODES, VERSION_CODES, } from "./models.js";
|
|
28
|
-
export type { ConnectOptions, Socket, Net, DnsResolver, IPAddress, } from "./net.js";
|
|
28
|
+
export type { ConnectOptions, Socket, Net, DnsResolver, IPAddress, Network, } from "./net.js";
|
|
29
|
+
export type { EventProvider, TypedEventEmitter, } from "./events.js";
|
|
30
|
+
export type { Logger, Span, Tracer, Metrics, Telemetry, } from "./telemetry.js";
|
|
31
|
+
export type { Duration, Deadline, Scheduler, Time, } from "./time.js";
|
|
32
|
+
export type { Compression, Crypto, Platform, } from "./platform.js";
|
|
29
33
|
export type { TlsOptions, Http1Options, Http2Options, Http3Options, QuicOptions, FetchClientOptions, } from "./options.js";
|
|
30
34
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAMH,YAAY,EAER,cAAc,EACd,mBAAmB,EACnB,SAAS,EACT,iBAAiB,EAEjB,aAAa,EACb,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,UAAU,EAEV,WAAW,EACX,SAAS,EAET,KAAK,EACL,cAAc,EACd,uBAAuB,GAC1B,MAAM,gBAAgB,CAAC;AAMxB,YAAY,EAER,SAAS,EAET,cAAc,EACd,UAAU,EACV,YAAY,EACZ,YAAY,EAEZ,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,aAAa,EAEb,OAAO,EAEP,MAAM,EAEN,MAAM,EACN,SAAS,EACT,aAAa,EACb,WAAW,EAEX,UAAU,EACV,cAAc,EACd,WAAW,EACX,mBAAmB,EACnB,QAAQ,EAER,eAAe,GAClB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACH,yBAAyB,EACzB,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,aAAa,GAChB,MAAM,aAAa,CAAC;AAMrB,YAAY,EACR,cAAc,EACd,MAAM,EACN,GAAG,EACH,WAAW,EACX,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAMH,YAAY,EAER,cAAc,EACd,mBAAmB,EACnB,SAAS,EACT,iBAAiB,EAEjB,aAAa,EACb,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,UAAU,EAEV,WAAW,EACX,SAAS,EAET,KAAK,EACL,cAAc,EACd,uBAAuB,GAC1B,MAAM,gBAAgB,CAAC;AAMxB,YAAY,EAER,SAAS,EAET,cAAc,EACd,UAAU,EACV,YAAY,EACZ,YAAY,EAEZ,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,aAAa,EAEb,OAAO,EAEP,MAAM,EAEN,MAAM,EACN,SAAS,EACT,aAAa,EACb,WAAW,EAEX,UAAU,EACV,cAAc,EACd,WAAW,EACX,mBAAmB,EACnB,QAAQ,EAER,eAAe,GAClB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACH,yBAAyB,EACzB,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,aAAa,GAChB,MAAM,aAAa,CAAC;AAMrB,YAAY,EACR,cAAc,EACd,MAAM,EACN,GAAG,EACH,WAAW,EACX,SAAS,EACT,OAAO,GACV,MAAM,UAAU,CAAC;AAMlB,YAAY,EACR,aAAa,EACb,iBAAiB,GACpB,MAAM,aAAa,CAAC;AAMrB,YAAY,EACR,MAAM,EACN,IAAI,EACJ,MAAM,EACN,OAAO,EACP,SAAS,GACZ,MAAM,gBAAgB,CAAC;AAMxB,YAAY,EACR,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,IAAI,GACP,MAAM,WAAW,CAAC;AAWnB,YAAY,EACR,WAAW,EACX,MAAM,EACN,QAAQ,GACX,MAAM,eAAe,CAAC;AAMvB,YAAY,EACR,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,kBAAkB,GACrB,MAAM,cAAc,CAAC"}
|
package/dist/net.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Design rule: expose only what transport consumes. Don't mirror Node's API.
|
|
10
10
|
*/
|
|
11
|
+
import type { DatagramTransport } from "./contracts.js";
|
|
11
12
|
/** Options for establishing a TCP connection. */
|
|
12
13
|
export interface ConnectOptions {
|
|
13
14
|
/** Target host (IP literal or resolved address). */
|
|
@@ -69,4 +70,15 @@ export interface DnsResolver {
|
|
|
69
70
|
*/
|
|
70
71
|
lookup(hostname: string, family: 4 | 6): Promise<readonly IPAddress[]>;
|
|
71
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Aggregated network bundle — TCP, DNS, and UDP.
|
|
75
|
+
*
|
|
76
|
+
* Passed down from the composition root. Bundles the three network
|
|
77
|
+
* capabilities so consumers receive one object instead of three.
|
|
78
|
+
*/
|
|
79
|
+
export interface Network {
|
|
80
|
+
readonly tcp: Net;
|
|
81
|
+
readonly dns: DnsResolver;
|
|
82
|
+
readonly udp: DatagramTransport;
|
|
83
|
+
}
|
|
72
84
|
//# sourceMappingURL=net.d.ts.map
|
package/dist/net.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"net.d.ts","sourceRoot":"","sources":["../src/net.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"net.d.ts","sourceRoot":"","sources":["../src/net.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAMxD,iDAAiD;AACjD,MAAM,WAAW,cAAc;IAC3B,oDAAoD;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,mBAAmB;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iCAAiC;IACjC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,6BAA6B;IAC7B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,yBAAyB;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;CAC3B;AAED;;;;;GAKG;AACH,MAAM,WAAW,MAAM;IACnB;;;OAGG;IACH,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,GAAG,OAAO,CAAC;IACpE,yCAAyC;IACzC,GAAG,IAAI,IAAI,CAAC;IACZ,gEAAgE;IAChE,OAAO,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IAC7B,yCAAyC;IACzC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,oCAAoC;IACpC,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAC7D,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI,CAAC;IAC3D,sCAAsC;IACtC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,IAAI,CAAC;IAC/D,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IACvD,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI,CAAC;IACzD,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI,CAAC;CACnE;AAED,kCAAkC;AAClC,MAAM,WAAW,GAAG;IAChB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,CAAC;CAC5C;AAMD,6BAA6B;AAC7B,MAAM,WAAW,SAAS;IACtB,+BAA+B;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,8CAA8C;IAC9C,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;CAC1B;AAED,kCAAkC;AAClC,MAAM,WAAW,WAAW;IACxB;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,SAAS,SAAS,EAAE,CAAC,CAAC;CAC1E;AAMD;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACpB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,iBAAiB,CAAC;CACnC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform — the root composition interface.
|
|
3
|
+
*
|
|
4
|
+
* This is the single object that browsersmith assembles and passes down
|
|
5
|
+
* to every protocol package. Each field is a service bundle that groups
|
|
6
|
+
* related platform capabilities (network, crypto, compression, events,
|
|
7
|
+
* telemetry, time).
|
|
8
|
+
*
|
|
9
|
+
* Architecture:
|
|
10
|
+
*
|
|
11
|
+
* browsersmith (composition root)
|
|
12
|
+
* │
|
|
13
|
+
* ▼
|
|
14
|
+
* Platform
|
|
15
|
+
* ├── network (TCP, DNS, UDP)
|
|
16
|
+
* ├── crypto (CryptoProvider)
|
|
17
|
+
* ├── compression (gzip, deflate, brotli, etc.)
|
|
18
|
+
* ├── events (EventProvider)
|
|
19
|
+
* ├── telemetry (logger, tracer, metrics)
|
|
20
|
+
* └── time (Clock + Scheduler)
|
|
21
|
+
*
|
|
22
|
+
* All fields are interfaces — this file has zero runtime behavior
|
|
23
|
+
* and zero node:* imports.
|
|
24
|
+
*/
|
|
25
|
+
import type { Network } from "./net.js";
|
|
26
|
+
import type { CryptoProvider } from "./contracts.js";
|
|
27
|
+
import type { EventProvider } from "./events.js";
|
|
28
|
+
import type { Telemetry } from "./telemetry.js";
|
|
29
|
+
import type { Time } from "./time.js";
|
|
30
|
+
/**
|
|
31
|
+
* Synchronous compression/decompression bundle.
|
|
32
|
+
*
|
|
33
|
+
* Why sync: callers already own the hot path and want predictable latency.
|
|
34
|
+
* Streaming variants belong on the implementation, not the contract.
|
|
35
|
+
*/
|
|
36
|
+
export interface Compression {
|
|
37
|
+
gzipSync(data: Uint8Array): Uint8Array;
|
|
38
|
+
gunzipSync(data: Uint8Array): Uint8Array;
|
|
39
|
+
deflateSync(data: Uint8Array): Uint8Array;
|
|
40
|
+
inflateSync(data: Uint8Array): Uint8Array;
|
|
41
|
+
brotliCompressSync(data: Uint8Array): Uint8Array;
|
|
42
|
+
brotliDecompressSync(data: Uint8Array): Uint8Array;
|
|
43
|
+
decompressSync(data: Uint8Array): Uint8Array;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Aggregated crypto bundle — wraps CryptoProvider.
|
|
47
|
+
*/
|
|
48
|
+
export interface Crypto {
|
|
49
|
+
readonly provider: CryptoProvider;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Platform — the single composition root for all runtime services.
|
|
53
|
+
*
|
|
54
|
+
* Every protocol package receives the fields it needs. No package
|
|
55
|
+
* hardwires node:* imports; all capabilities arrive via this object.
|
|
56
|
+
*/
|
|
57
|
+
export interface Platform {
|
|
58
|
+
readonly network: Network;
|
|
59
|
+
readonly crypto: Crypto;
|
|
60
|
+
readonly compression: Compression;
|
|
61
|
+
readonly events: EventProvider;
|
|
62
|
+
readonly telemetry: Telemetry;
|
|
63
|
+
readonly time: Time;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=platform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAMtC;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IACxB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC;IACvC,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC;IACzC,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC;IAC1C,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC;IAC1C,kBAAkB,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC;IACjD,oBAAoB,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC;IACnD,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC;CAChD;AAMD;;GAEG;AACH,MAAM,WAAW,MAAM;IACnB,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;CACrC;AAMD;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACrB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;CACvB"}
|
package/dist/platform.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform — the root composition interface.
|
|
3
|
+
*
|
|
4
|
+
* This is the single object that browsersmith assembles and passes down
|
|
5
|
+
* to every protocol package. Each field is a service bundle that groups
|
|
6
|
+
* related platform capabilities (network, crypto, compression, events,
|
|
7
|
+
* telemetry, time).
|
|
8
|
+
*
|
|
9
|
+
* Architecture:
|
|
10
|
+
*
|
|
11
|
+
* browsersmith (composition root)
|
|
12
|
+
* │
|
|
13
|
+
* ▼
|
|
14
|
+
* Platform
|
|
15
|
+
* ├── network (TCP, DNS, UDP)
|
|
16
|
+
* ├── crypto (CryptoProvider)
|
|
17
|
+
* ├── compression (gzip, deflate, brotli, etc.)
|
|
18
|
+
* ├── events (EventProvider)
|
|
19
|
+
* ├── telemetry (logger, tracer, metrics)
|
|
20
|
+
* └── time (Clock + Scheduler)
|
|
21
|
+
*
|
|
22
|
+
* All fields are interfaces — this file has zero runtime behavior
|
|
23
|
+
* and zero node:* imports.
|
|
24
|
+
*/
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=platform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform-agnostic telemetry contracts.
|
|
3
|
+
*
|
|
4
|
+
* These interfaces describe the logging, tracing, and metrics surface
|
|
5
|
+
* that BrowserCore needs. They are implemented by thin adapters
|
|
6
|
+
* (e.g. `browsersmith/src/telemetry/node/`) and injected.
|
|
7
|
+
*
|
|
8
|
+
* Design rule: expose only what packages consume. Don't mirror any
|
|
9
|
+
* specific telemetry SDK (OpenTelemetry, pino, etc.).
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Structured logger — the minimal surface protocol packages need.
|
|
13
|
+
*/
|
|
14
|
+
export interface Logger {
|
|
15
|
+
debug(message: string, attrs?: Readonly<Record<string, unknown>>): void;
|
|
16
|
+
info(message: string, attrs?: Readonly<Record<string, unknown>>): void;
|
|
17
|
+
warn(message: string, attrs?: Readonly<Record<string, unknown>>): void;
|
|
18
|
+
error(message: string, attrs?: Readonly<Record<string, unknown>>): void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A single trace span.
|
|
22
|
+
*/
|
|
23
|
+
export interface Span {
|
|
24
|
+
setAttribute(key: string, value: unknown): Span;
|
|
25
|
+
end(): void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Tracer — creates spans.
|
|
29
|
+
*/
|
|
30
|
+
export interface Tracer {
|
|
31
|
+
startSpan(name: string, attrs?: Readonly<Record<string, unknown>>): Span;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Metrics counter/gauge recorder.
|
|
35
|
+
*/
|
|
36
|
+
export interface Metrics {
|
|
37
|
+
add(name: string, value: number, attrs?: Readonly<Record<string, unknown>>): void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Aggregated telemetry bundle — passed down from the composition root.
|
|
41
|
+
*/
|
|
42
|
+
export interface Telemetry {
|
|
43
|
+
readonly logger: Logger;
|
|
44
|
+
readonly tracer: Tracer;
|
|
45
|
+
readonly metrics: Metrics;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;GAEG;AACH,MAAM,WAAW,MAAM;IACnB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IACxE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IACvE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IACvE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;CAC3E;AAED;;GAEG;AACH,MAAM,WAAW,IAAI;IACjB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAChD,GAAG,IAAI,IAAI,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,MAAM;IACnB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;CAC5E;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACpB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;CACrF;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC7B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform-agnostic telemetry contracts.
|
|
3
|
+
*
|
|
4
|
+
* These interfaces describe the logging, tracing, and metrics surface
|
|
5
|
+
* that BrowserCore needs. They are implemented by thin adapters
|
|
6
|
+
* (e.g. `browsersmith/src/telemetry/node/`) and injected.
|
|
7
|
+
*
|
|
8
|
+
* Design rule: expose only what packages consume. Don't mirror any
|
|
9
|
+
* specific telemetry SDK (OpenTelemetry, pino, etc.).
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=telemetry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
|
package/dist/time.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform-agnostic time contracts.
|
|
3
|
+
*
|
|
4
|
+
* These interfaces describe what BrowserCore needs from a runtime's
|
|
5
|
+
* time and scheduling facilities. They are implemented by thin adapters
|
|
6
|
+
* (e.g. `browsersmith/src/time/node/`) and injected so protocol packages
|
|
7
|
+
* can schedule delays, timeouts, and deadlines without hardwiring to
|
|
8
|
+
* `setTimeout` or `performance.now`.
|
|
9
|
+
*
|
|
10
|
+
* Design rule: expose only what transport/protocol packages consume.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Time source — wall clock and monotonic counter.
|
|
14
|
+
*
|
|
15
|
+
* `monotonic()` returns high-resolution nanoseconds and MUST NOT
|
|
16
|
+
* go backwards (unlike wall-clock `now()`).
|
|
17
|
+
*/
|
|
18
|
+
export interface Clock {
|
|
19
|
+
/** Wall-clock time, epoch milliseconds. */
|
|
20
|
+
now(): number;
|
|
21
|
+
/** High-resolution monotonic time, nanoseconds. */
|
|
22
|
+
monotonic(): bigint;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A duration interval.
|
|
26
|
+
*
|
|
27
|
+
* Returned by the `Duration` factory. Both accessors reflect the same
|
|
28
|
+
* interval in different units.
|
|
29
|
+
*/
|
|
30
|
+
export interface Duration {
|
|
31
|
+
readonly milliseconds: number;
|
|
32
|
+
seconds(): number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A deadline bound to an AbortSignal.
|
|
36
|
+
*/
|
|
37
|
+
export interface Deadline {
|
|
38
|
+
readonly signal: AbortSignal;
|
|
39
|
+
readonly expiresAt: bigint;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Scheduler — creates delays, timeouts, and deadlines.
|
|
43
|
+
*/
|
|
44
|
+
export interface Scheduler {
|
|
45
|
+
delay(duration: Duration, signal?: AbortSignal): Promise<void>;
|
|
46
|
+
timeout(duration: Duration): AbortSignal;
|
|
47
|
+
deadline(duration: Duration): Deadline;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Aggregated time bundle — passed down from the composition root.
|
|
51
|
+
*/
|
|
52
|
+
export interface Time {
|
|
53
|
+
readonly clock: Clock;
|
|
54
|
+
readonly scheduler: Scheduler;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Duration factory — pure function object, no runtime deps.
|
|
58
|
+
* Platform implementations use this to build Duration values.
|
|
59
|
+
*/
|
|
60
|
+
export declare const Duration: {
|
|
61
|
+
seconds: (n: number) => Duration;
|
|
62
|
+
milliseconds: (n: number) => Duration;
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=time.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,KAAK;IAClB,2CAA2C;IAC3C,GAAG,IAAI,MAAM,CAAC;IACd,mDAAmD;IACnD,SAAS,IAAI,MAAM,CAAC;CACvB;AAED;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACrB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,OAAO,IAAI,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACrB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACtB,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,OAAO,CAAC,QAAQ,EAAE,QAAQ,GAAG,WAAW,CAAC;IACzC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,IAAI;IACjB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;CACjC;AAMD;;;GAGG;AACH,eAAO,MAAM,QAAQ;IACjB,OAAO,MAAM,MAAM,KAAG,QAAQ;IAC9B,YAAY,MAAM,MAAM,KAAG,QAAQ;CACtC,CAAC"}
|
package/dist/time.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform-agnostic time contracts.
|
|
3
|
+
*
|
|
4
|
+
* These interfaces describe what BrowserCore needs from a runtime's
|
|
5
|
+
* time and scheduling facilities. They are implemented by thin adapters
|
|
6
|
+
* (e.g. `browsersmith/src/time/node/`) and injected so protocol packages
|
|
7
|
+
* can schedule delays, timeouts, and deadlines without hardwiring to
|
|
8
|
+
* `setTimeout` or `performance.now`.
|
|
9
|
+
*
|
|
10
|
+
* Design rule: expose only what transport/protocol packages consume.
|
|
11
|
+
*/
|
|
12
|
+
// ===========================================================================
|
|
13
|
+
// Duration factory
|
|
14
|
+
// ===========================================================================
|
|
15
|
+
/**
|
|
16
|
+
* Duration factory — pure function object, no runtime deps.
|
|
17
|
+
* Platform implementations use this to build Duration values.
|
|
18
|
+
*/
|
|
19
|
+
export const Duration = {
|
|
20
|
+
seconds: (n) => ({ milliseconds: n * 1000, seconds: () => n }),
|
|
21
|
+
milliseconds: (n) => ({ milliseconds: n, seconds: () => n / 1000 }),
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=time.js.map
|
package/dist/time.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time.js","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAmDH,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACpB,OAAO,EAAE,CAAC,CAAS,EAAY,EAAE,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;IAChF,YAAY,EAAE,CAAC,CAAS,EAAY,EAAE,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC;CACxF,CAAC"}
|