socket-function 1.0.2 → 1.0.4
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/SocketFunction.d.ts +1 -0
- package/generateIndexDts.js +10 -1
- package/index.d.ts +120 -2
- package/package.json +1 -1
- package/require/RequireController.d.ts +1 -0
- package/require/extMapper.d.ts +1 -0
- package/src/CallFactory.d.ts +1 -0
- package/src/JSONLACKS/JSONLACKS.d.ts +1 -0
- package/src/callHTTPHandler.d.ts +1 -0
- package/src/certStore.d.ts +1 -0
- package/src/https.d.ts +1 -0
- package/src/misc.d.ts +1 -0
- package/src/tlsParsing.d.ts +1 -0
- package/src/webSocketServer.d.ts +1 -0
package/SocketFunction.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference path="require/RequireController.d.ts" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
3
4
|
import { SocketExposedInterface, SocketFunctionHook, SocketFunctionClientHook, SocketExposedShape, SocketRegistered, CallerContext, FullCallType, SocketRegisterType } from "./SocketFunctionTypes";
|
|
4
5
|
import { SocketServerConfig } from "./src/webSocketServer";
|
|
5
6
|
import { Args, MaybePromise } from "./src/types";
|
package/generateIndexDts.js
CHANGED
|
@@ -24,7 +24,7 @@ function generateIndexDts() {
|
|
|
24
24
|
const renderUtilsPath = __dirname;
|
|
25
25
|
const dtsFiles = getAllDtsFiles(renderUtilsPath);
|
|
26
26
|
|
|
27
|
-
const excludedModules = ["socket-function/
|
|
27
|
+
const excludedModules = ["socket-function/index"];
|
|
28
28
|
|
|
29
29
|
const modules = dtsFiles
|
|
30
30
|
.map(filePath => {
|
|
@@ -45,6 +45,15 @@ function generateIndexDts() {
|
|
|
45
45
|
}
|
|
46
46
|
);
|
|
47
47
|
|
|
48
|
+
// Resolve dynamic imports like import("../path")
|
|
49
|
+
content = content.replace(
|
|
50
|
+
/import\(["'](\.[^"']+)["']\)/g,
|
|
51
|
+
(match, relativeImport) => {
|
|
52
|
+
const absoluteModulePath = path.join(moduleDir, relativeImport).replace(/\\/g, "/");
|
|
53
|
+
return `import("${absoluteModulePath}")`;
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
|
|
48
57
|
const indentedContent = content
|
|
49
58
|
.split("\n")
|
|
50
59
|
.map(line => line ? " " + line : line)
|
package/index.d.ts
CHANGED
|
@@ -6,6 +6,114 @@ declare module "socket-function/SetProcessVariables" {
|
|
|
6
6
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
declare module "socket-function/SocketFunction" {
|
|
10
|
+
/// <reference path="require/RequireController.d.ts" />
|
|
11
|
+
/// <reference types="node" />
|
|
12
|
+
/// <reference types="node" />
|
|
13
|
+
import { SocketExposedInterface, SocketFunctionHook, SocketFunctionClientHook, SocketExposedShape, SocketRegistered, CallerContext, FullCallType, SocketRegisterType } from "socket-function/SocketFunctionTypes";
|
|
14
|
+
import { SocketServerConfig } from "socket-function/src/webSocketServer";
|
|
15
|
+
import { Args, MaybePromise } from "socket-function/src/types";
|
|
16
|
+
import "./SetProcessVariables";
|
|
17
|
+
type ExtractShape<ClassType, Shape> = {
|
|
18
|
+
[key in keyof ClassType]: (key extends keyof Shape ? ClassType[key] extends SocketExposedInterface[""] ? ClassType[key] : ClassType[key] extends Function ? "All exposed function must be async (or return a Promise)" : never : "Function has implementation but is not exposed in the SocketFunction.register call");
|
|
19
|
+
};
|
|
20
|
+
export declare class SocketFunction {
|
|
21
|
+
static logMessages: boolean;
|
|
22
|
+
static trackMessageSizes: {
|
|
23
|
+
upload: ((size: number) => void)[];
|
|
24
|
+
download: ((size: number) => void)[];
|
|
25
|
+
callTimes: ((obj: {
|
|
26
|
+
start: number;
|
|
27
|
+
end: number;
|
|
28
|
+
}) => void)[];
|
|
29
|
+
};
|
|
30
|
+
static MAX_MESSAGE_SIZE: number;
|
|
31
|
+
static HTTP_ETAG_CACHE: boolean;
|
|
32
|
+
static silent: boolean;
|
|
33
|
+
static HTTP_COMPRESS: boolean;
|
|
34
|
+
static COEP: string;
|
|
35
|
+
static COOP: string;
|
|
36
|
+
static readonly WIRE_SERIALIZER: {
|
|
37
|
+
serialize: (obj: unknown) => MaybePromise<Buffer[]>;
|
|
38
|
+
deserialize: (buffers: Buffer[]) => MaybePromise<unknown>;
|
|
39
|
+
};
|
|
40
|
+
static WIRE_WARN_TIME: number;
|
|
41
|
+
private static onMountCallbacks;
|
|
42
|
+
static exposedClasses: Set<string>;
|
|
43
|
+
static callerContext: CallerContext | undefined;
|
|
44
|
+
static getCaller(): CallerContext;
|
|
45
|
+
static harvestFailedCallCount: () => number;
|
|
46
|
+
static getPendingCallCount: () => number;
|
|
47
|
+
static harvestCallTimes: () => {
|
|
48
|
+
start: number;
|
|
49
|
+
end: number;
|
|
50
|
+
}[];
|
|
51
|
+
static register<ClassInstance extends object, Shape extends SocketExposedShape<{
|
|
52
|
+
[key in keyof ClassInstance]: (...args: any[]) => Promise<unknown>;
|
|
53
|
+
}>, Statics>(classGuid: string, instance: ClassInstance | (() => ClassInstance), shapeFnc: () => Shape, defaultHooksFnc?: () => SocketExposedShape[""] & {
|
|
54
|
+
onMount?: () => MaybePromise<void>;
|
|
55
|
+
}, config?: {
|
|
56
|
+
/** @noAutoExpose If true SocketFunction.expose(Controller) must be called explicitly. */
|
|
57
|
+
noAutoExpose?: boolean;
|
|
58
|
+
statics?: Statics;
|
|
59
|
+
/** Skip timing functions calls. Useful if a lot of functions have wait time that
|
|
60
|
+
is unrelated to processing, and therefore their timings won't be useful.
|
|
61
|
+
- Also useful if our auto function wrapping code is breaking functionality,
|
|
62
|
+
such as if you have a singleton function which you compare with ===,
|
|
63
|
+
which will breaks because we replaced it with a wrapped measure function.
|
|
64
|
+
*/
|
|
65
|
+
noFunctionMeasure?: boolean;
|
|
66
|
+
}): SocketRegistered<ExtractShape<ClassInstance, Shape>> & Statics;
|
|
67
|
+
private static socketCache;
|
|
68
|
+
static rehydrateSocketCaller<Controller>(socketRegistered: SocketRegisterType<Controller>, shapeFnc?: () => SocketExposedShape): SocketRegistered<Controller>;
|
|
69
|
+
private static callFromGuid;
|
|
70
|
+
static onNextDisconnect(nodeId: string, callback: () => void): void;
|
|
71
|
+
static getLastDisconnectTime(nodeId: string): number | undefined;
|
|
72
|
+
static isNodeConnected(nodeId: string): boolean;
|
|
73
|
+
/** NOTE: Only works if the nodeIs used is from SocketFunction.connect (we can't convert arbitrary nodeIds into urls,
|
|
74
|
+
* as we have no way of knowing how to contain a nodeId).
|
|
75
|
+
* */
|
|
76
|
+
static getHTTPCallLink(call: FullCallType): string;
|
|
77
|
+
private static ignoreExposeCount;
|
|
78
|
+
static ignoreExposeCalls<T>(code: () => Promise<T>): Promise<T>;
|
|
79
|
+
/** Expose should be called before your mounting occurs. It mostly just exists to ensure you include the class type,
|
|
80
|
+
* so the class type's module construction runs, which should trigger register. Otherwise you would have
|
|
81
|
+
* to add additional imports to ensure the register call runs.
|
|
82
|
+
*/
|
|
83
|
+
static expose(socketRegistered: SocketRegistered): void;
|
|
84
|
+
static mountedNodeId: string;
|
|
85
|
+
static isMounted(): boolean;
|
|
86
|
+
static mountedIP: string;
|
|
87
|
+
private static hasMounted;
|
|
88
|
+
private static onMountCallback;
|
|
89
|
+
static mountPromise: Promise<void>;
|
|
90
|
+
static mount(config: SocketServerConfig): Promise<string>;
|
|
91
|
+
/** Sets the default call when an http request is made, but no classGuid is set.
|
|
92
|
+
* NOTE: All other calls should be endpoint calls, even if those endpoints return a static file with an HTML content type.
|
|
93
|
+
* - However, to load new content, you should probably just use `require("./example.ts")`, which works on any files
|
|
94
|
+
* clientside that have also been required serverside (and whitelisted with module.allowclient = true,
|
|
95
|
+
* or with an `allowclient.flag` file in the directory or parent directory).
|
|
96
|
+
*/
|
|
97
|
+
static setDefaultHTTPCall<Registered extends SocketRegistered, FunctionName extends keyof Registered["nodes"][""] & string>(registered: Registered, functionName: FunctionName, ...args: Args<Registered["nodes"][""][FunctionName]>): void;
|
|
98
|
+
static connect(location: {
|
|
99
|
+
address: string;
|
|
100
|
+
port: number;
|
|
101
|
+
}): string;
|
|
102
|
+
static browserNodeId(): string;
|
|
103
|
+
static getBrowserNodeId(): string;
|
|
104
|
+
static addGlobalHook(hook: SocketFunctionHook): void;
|
|
105
|
+
static addGlobalClientHook(hook: SocketFunctionClientHook): void;
|
|
106
|
+
}
|
|
107
|
+
declare global {
|
|
108
|
+
var BOOTED_EDGE_NODE: {
|
|
109
|
+
host: string;
|
|
110
|
+
} | undefined;
|
|
111
|
+
}
|
|
112
|
+
export declare function _setSocketContext<T>(caller: CallerContext, code: () => T): T;
|
|
113
|
+
export {};
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
|
|
9
117
|
declare module "socket-function/SocketFunctionTypes" {
|
|
10
118
|
/// <reference path="require/RequireController.d.ts" />
|
|
11
119
|
import { getCallObj } from "socket-function/src/nodeProxy";
|
|
@@ -127,7 +235,7 @@ declare module "socket-function/hot/HotReloadController" {
|
|
|
127
235
|
export declare function hotReloadingGuard(): true;
|
|
128
236
|
export declare function setExternalHotReloading(value: boolean): void;
|
|
129
237
|
export declare function onHotReload(callback: (modules: NodeJS.Module[]) => void): void;
|
|
130
|
-
export declare const HotReloadController: import("
|
|
238
|
+
export declare const HotReloadController: import("socket-function/SocketFunctionTypes").SocketRegistered<{
|
|
131
239
|
watchFiles: () => Promise<void>;
|
|
132
240
|
fileUpdated: (files: string[], changeTime: number) => Promise<void>;
|
|
133
241
|
}>;
|
|
@@ -194,6 +302,7 @@ declare module "socket-function/require/CSSShim" {
|
|
|
194
302
|
declare module "socket-function/require/RequireController" {
|
|
195
303
|
/// <reference path="../../typenode/index.d.ts" />
|
|
196
304
|
/// <reference types="node" />
|
|
305
|
+
/// <reference types="node" />
|
|
197
306
|
declare global {
|
|
198
307
|
namespace NodeJS {
|
|
199
308
|
interface Module {
|
|
@@ -272,7 +381,7 @@ declare module "socket-function/require/RequireController" {
|
|
|
272
381
|
/** @deprecated, not needed, as this defaults to ".", which is a lot easier to reason about anyways. */
|
|
273
382
|
export declare function setRequireBootRequire(dir: string): void;
|
|
274
383
|
export declare function allowAllNodeModules(): void;
|
|
275
|
-
export declare const RequireController: import("
|
|
384
|
+
export declare const RequireController: import("socket-function/SocketFunctionTypes").SocketRegistered<{
|
|
276
385
|
rootResolvePath: "Function has implementation but is not exposed in the SocketFunction.register call";
|
|
277
386
|
requireHTML: (config?: {
|
|
278
387
|
requireCalls?: string[];
|
|
@@ -317,6 +426,7 @@ declare module "socket-function/require/compileFlags" {
|
|
|
317
426
|
}
|
|
318
427
|
|
|
319
428
|
declare module "socket-function/require/extMapper" {
|
|
429
|
+
/// <reference types="node" />
|
|
320
430
|
/// <reference types="node" />
|
|
321
431
|
export declare function getExtContentType(ext: string): string;
|
|
322
432
|
export declare function getContentTypeFromBuffer(buffer: Buffer): string | undefined;
|
|
@@ -342,6 +452,7 @@ declare module "socket-function/require/require" {
|
|
|
342
452
|
}
|
|
343
453
|
|
|
344
454
|
declare module "socket-function/src/CallFactory" {
|
|
455
|
+
/// <reference types="node" />
|
|
345
456
|
/// <reference types="node" />
|
|
346
457
|
/// <reference types="node" />
|
|
347
458
|
import { CallType } from "socket-function/SocketFunctionTypes";
|
|
@@ -382,6 +493,7 @@ declare module "socket-function/src/CallFactory" {
|
|
|
382
493
|
}
|
|
383
494
|
|
|
384
495
|
declare module "socket-function/src/JSONLACKS/JSONLACKS" {
|
|
496
|
+
/// <reference types="node" />
|
|
385
497
|
/// <reference types="node" />
|
|
386
498
|
export interface JSONLACKS_ParseConfig {
|
|
387
499
|
extended?: boolean;
|
|
@@ -528,6 +640,7 @@ declare module "socket-function/src/caching" {
|
|
|
528
640
|
}
|
|
529
641
|
|
|
530
642
|
declare module "socket-function/src/callHTTPHandler" {
|
|
643
|
+
/// <reference types="node" />
|
|
531
644
|
/// <reference types="node" />
|
|
532
645
|
/// <reference types="node" />
|
|
533
646
|
import http from "http";
|
|
@@ -582,6 +695,7 @@ declare module "socket-function/src/callManager" {
|
|
|
582
695
|
}
|
|
583
696
|
|
|
584
697
|
declare module "socket-function/src/certStore" {
|
|
698
|
+
/// <reference types="node" />
|
|
585
699
|
/// <reference types="node" />
|
|
586
700
|
/** Must be populated before the server starts */
|
|
587
701
|
export declare function trustCertificate(cert: string | Buffer): void;
|
|
@@ -695,6 +809,7 @@ declare module "socket-function/src/forwardPort" {
|
|
|
695
809
|
}
|
|
696
810
|
|
|
697
811
|
declare module "socket-function/src/https" {
|
|
812
|
+
/// <reference types="node" />
|
|
698
813
|
/// <reference types="node" />
|
|
699
814
|
export declare function httpsRequest(url: string, payload?: Buffer | Buffer[], method?: string, sendSessionCookies?: boolean, config?: {
|
|
700
815
|
headers?: {
|
|
@@ -706,6 +821,7 @@ declare module "socket-function/src/https" {
|
|
|
706
821
|
}
|
|
707
822
|
|
|
708
823
|
declare module "socket-function/src/misc" {
|
|
824
|
+
/// <reference types="node" />
|
|
709
825
|
/// <reference types="node" />
|
|
710
826
|
import { MaybePromise } from "socket-function/src/types";
|
|
711
827
|
export declare const timeInSecond = 1000;
|
|
@@ -1116,6 +1232,7 @@ declare module "socket-function/src/storagePath" {
|
|
|
1116
1232
|
}
|
|
1117
1233
|
|
|
1118
1234
|
declare module "socket-function/src/tlsParsing" {
|
|
1235
|
+
/// <reference types="node" />
|
|
1119
1236
|
/// <reference types="node" />
|
|
1120
1237
|
export declare function parseTLSHello(buffer: Buffer): {
|
|
1121
1238
|
extensions: {
|
|
@@ -1140,6 +1257,7 @@ declare module "socket-function/src/types" {
|
|
|
1140
1257
|
}
|
|
1141
1258
|
|
|
1142
1259
|
declare module "socket-function/src/webSocketServer" {
|
|
1260
|
+
/// <reference types="node" />
|
|
1143
1261
|
/// <reference types="node" />
|
|
1144
1262
|
/// <reference types="node" />
|
|
1145
1263
|
import https from "https";
|
package/package.json
CHANGED
package/require/extMapper.d.ts
CHANGED
package/src/CallFactory.d.ts
CHANGED
package/src/callHTTPHandler.d.ts
CHANGED
package/src/certStore.d.ts
CHANGED
package/src/https.d.ts
CHANGED
package/src/misc.d.ts
CHANGED
package/src/tlsParsing.d.ts
CHANGED