socket-function 0.155.0 → 0.157.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/SetProcessVariables.d.ts +1 -0
- package/SocketFunction.d.ts +104 -0
- package/SocketFunction.ts +1 -1
- package/SocketFunctionTypes.d.ts +86 -0
- package/generateIndexDts.js +52 -0
- package/hot/HotReloadController.d.ts +34 -0
- package/hot/HotReloadController.ts +2 -0
- package/index.d.ts +1196 -31
- package/mobx/UrlParam.d.ts +13 -0
- package/mobx/observer.d.ts +18 -0
- package/mobx/promiseToObservable.d.ts +8 -0
- package/package.json +4 -1
- package/require/CSSShim.d.ts +2 -0
- package/require/compileFlags.d.ts +11 -0
- package/require/extMapper.d.ts +4 -0
- package/require/require.d.ts +14 -0
- package/src/CallFactory.d.ts +37 -0
- package/src/JSONLACKS/JSONLACKS.d.ts +28 -0
- package/src/args.d.ts +9 -0
- package/src/batching.d.ts +31 -0
- package/src/caching.d.ts +59 -0
- package/src/callHTTPHandler.d.ts +26 -0
- package/src/callManager.d.ts +21 -0
- package/src/certStore.d.ts +6 -0
- package/src/corsCheck.d.ts +0 -0
- package/src/fixLargeNetworkCalls.d.ts +2 -0
- package/src/formatting/colors.d.ts +42 -0
- package/src/formatting/format.d.ts +24 -0
- package/src/formatting/logColors.d.ts +7 -0
- package/src/forwardPort.d.ts +5 -0
- package/src/https.d.ts +8 -0
- package/src/misc.d.ts +98 -0
- package/src/networking.d.ts +11 -0
- package/src/nodeCache.d.ts +24 -0
- package/src/nodeProxy.d.ts +7 -0
- package/src/profiling/getOwnTime.d.ts +12 -0
- package/src/profiling/measure.d.ts +59 -0
- package/src/profiling/stats.d.ts +54 -0
- package/src/profiling/statsFormat.d.ts +7 -0
- package/src/profiling/tcpLagProxy.d.ts +18 -0
- package/src/promiseRace.d.ts +10 -0
- package/src/runPromise.d.ts +7 -0
- package/src/sniTest.d.ts +1 -0
- package/src/storagePath.d.ts +5 -0
- package/src/tlsParsing.d.ts +11 -0
- package/src/types.d.ts +6 -0
- package/src/webSocketServer.d.ts +30 -0
- package/src/websocketFactory.d.ts +9 -0
- package/test.d.ts +1 -0
- package/time/trueTimeShim.d.ts +6 -0
- package/tsconfig.declarations.json +18 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export interface StatsValue {
|
|
2
|
+
count: number;
|
|
3
|
+
sum: number;
|
|
4
|
+
sumSquares: number;
|
|
5
|
+
logn7Value: number;
|
|
6
|
+
logn7Count: number;
|
|
7
|
+
logn6Value: number;
|
|
8
|
+
logn6Count: number;
|
|
9
|
+
logn5Value: number;
|
|
10
|
+
logn5Count: number;
|
|
11
|
+
logn4Value: number;
|
|
12
|
+
logn4Count: number;
|
|
13
|
+
logn3Value: number;
|
|
14
|
+
logn3Count: number;
|
|
15
|
+
logn2Value: number;
|
|
16
|
+
logn2Count: number;
|
|
17
|
+
logn1Value: number;
|
|
18
|
+
logn1Count: number;
|
|
19
|
+
log0Value: number;
|
|
20
|
+
log0VCount: number;
|
|
21
|
+
log1Value: number;
|
|
22
|
+
log1VCount: number;
|
|
23
|
+
log2Value: number;
|
|
24
|
+
log2VCount: number;
|
|
25
|
+
log3Value: number;
|
|
26
|
+
log3VCount: number;
|
|
27
|
+
log4Value: number;
|
|
28
|
+
log4VCount: number;
|
|
29
|
+
log5Value: number;
|
|
30
|
+
log5VCount: number;
|
|
31
|
+
log6Value: number;
|
|
32
|
+
log6VCount: number;
|
|
33
|
+
log7Value: number;
|
|
34
|
+
log7VCount: number;
|
|
35
|
+
log8Value: number;
|
|
36
|
+
log8VCount: number;
|
|
37
|
+
log9Value: number;
|
|
38
|
+
log9VCount: number;
|
|
39
|
+
}
|
|
40
|
+
export declare function createStatsValue(): StatsValue;
|
|
41
|
+
export declare function addToStatsValue(stats: StatsValue, value: number): void;
|
|
42
|
+
export declare function addToStats(stats: StatsValue, other: StatsValue): void;
|
|
43
|
+
export interface StatsTop {
|
|
44
|
+
countFraction: number;
|
|
45
|
+
valueFraction: number;
|
|
46
|
+
count: number;
|
|
47
|
+
value: number;
|
|
48
|
+
topHeavy: boolean;
|
|
49
|
+
}
|
|
50
|
+
/** Identifies cases where the value is concentrated in few instances. This indicates most of the value (time)
|
|
51
|
+
* is not spent on the common case, but on an outlier. Which isn't a problem, it just means that the measurements
|
|
52
|
+
* should be more precise, to pull that heavy case out.
|
|
53
|
+
*/
|
|
54
|
+
export declare function getStatsTop(stats: StatsValue): StatsTop;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare function tcpLagProxy(config: {
|
|
2
|
+
localPort: number;
|
|
3
|
+
remoteHost: string;
|
|
4
|
+
remotePort: number;
|
|
5
|
+
lag: number;
|
|
6
|
+
networkWriteSize?: {
|
|
7
|
+
value: number;
|
|
8
|
+
};
|
|
9
|
+
networkReadSize?: {
|
|
10
|
+
value: number;
|
|
11
|
+
};
|
|
12
|
+
networkWritePackets?: {
|
|
13
|
+
value: number;
|
|
14
|
+
};
|
|
15
|
+
networkReadPackets?: {
|
|
16
|
+
value: number;
|
|
17
|
+
};
|
|
18
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class PromiseLessLeaky<T> extends Promise<T> {
|
|
2
|
+
constructor(executor: ((resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void) | undefined);
|
|
3
|
+
}
|
|
4
|
+
/** A promise race function which doesn't leak, unlike Promise.race
|
|
5
|
+
|
|
6
|
+
See https://github.com/nodejs/node/issues/17469
|
|
7
|
+
See https://bugs.chromium.org/p/v8/issues/detail?id=9858#c9
|
|
8
|
+
|
|
9
|
+
*/
|
|
10
|
+
export declare function promiseRace<T extends readonly unknown[] | []>(promises: T): Promise<Awaited<T[number]>>;
|
package/src/sniTest.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
export declare function parseTLSHello(buffer: Buffer): {
|
|
4
|
+
extensions: {
|
|
5
|
+
type: number;
|
|
6
|
+
data: Buffer;
|
|
7
|
+
}[];
|
|
8
|
+
missingBytes: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const SNIType = 0;
|
|
11
|
+
export declare function parseSNIExtension(data: Buffer): string[];
|
package/src/types.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
2
|
+
export type Args<T> = T extends (...args: infer V) => any ? V : never;
|
|
3
|
+
export type AnyFunction = (...args: any) => any;
|
|
4
|
+
export declare function canHaveChildren(value: unknown): value is {
|
|
5
|
+
[key in PropertyKey]: unknown;
|
|
6
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
import https from "https";
|
|
5
|
+
import { Watchable } from "./misc";
|
|
6
|
+
export type SocketServerConfig = (https.ServerOptions & {
|
|
7
|
+
key: string | Buffer;
|
|
8
|
+
cert: string | Buffer;
|
|
9
|
+
port: number;
|
|
10
|
+
/** You can also set `port: 0` if you don't care what port you want at all. */
|
|
11
|
+
useAvailablePortIfPortInUse?: boolean;
|
|
12
|
+
public?: boolean;
|
|
13
|
+
/** Tries forwarding ports (using UPnP), if we detect they aren't externally reachable.
|
|
14
|
+
* - This causes an extra request and delay during startup, so should only be used
|
|
15
|
+
* during development.
|
|
16
|
+
* - Ignored if public is false (in which case we mount on 127.0.0.1, so port forwarding
|
|
17
|
+
* wouldn't matter anyways).
|
|
18
|
+
*/
|
|
19
|
+
autoForwardPort?: boolean;
|
|
20
|
+
ip?: string;
|
|
21
|
+
allowHostnames?: string[];
|
|
22
|
+
allowHostnameFnc?: (hostname: string) => boolean;
|
|
23
|
+
/** If the SNI matches this domain, we use a different key/cert.
|
|
24
|
+
* We remove subdomains until we find a match
|
|
25
|
+
*/
|
|
26
|
+
SNICerts?: {
|
|
27
|
+
[domain: string]: Watchable<https.ServerOptions>;
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
export declare function startSocketServer(config: SocketServerConfig): Promise<string>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import tls from "tls";
|
|
3
|
+
import { SenderInterface } from "./CallFactory";
|
|
4
|
+
import type * as ws from "ws";
|
|
5
|
+
export declare function getTLSSocket(webSocket: ws.WebSocket): tls.TLSSocket;
|
|
6
|
+
/** NOTE: We create a factory, which embeds the key/cert information. Otherwise retries might use
|
|
7
|
+
* a different key/cert context.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createWebsocketFactory(): (nodeId: string) => SenderInterface;
|
package/test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function getTrueTime(): number;
|
|
2
|
+
export declare function getTrueTimeOffset(): number;
|
|
3
|
+
export declare function waitForFirstTimeSync(): Promise<void> | undefined;
|
|
4
|
+
export declare function shimDateNow(): void;
|
|
5
|
+
export declare function getBrowserTime(): number;
|
|
6
|
+
export declare function setGetTimeOffsetBase(base: () => Promise<number>): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"emitDeclarationOnly": true,
|
|
6
|
+
"outDir": "./",
|
|
7
|
+
"rootDir": "./"
|
|
8
|
+
},
|
|
9
|
+
"include": [
|
|
10
|
+
"**/*.ts",
|
|
11
|
+
"**/*.tsx"
|
|
12
|
+
],
|
|
13
|
+
"exclude": [
|
|
14
|
+
"node_modules",
|
|
15
|
+
"*_venv"
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
|