socket-function 1.0.1 → 1.0.3
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 +25 -8
- package/index.d.ts +27 -17
- 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,20 +24,36 @@ function generateIndexDts() {
|
|
|
24
24
|
const renderUtilsPath = __dirname;
|
|
25
25
|
const dtsFiles = getAllDtsFiles(renderUtilsPath);
|
|
26
26
|
|
|
27
|
+
const excludedModules = ["socket-function/SocketFunction", "socket-function/index"];
|
|
28
|
+
|
|
27
29
|
const modules = dtsFiles
|
|
28
|
-
.filter(filePath => {
|
|
29
|
-
// Exclude SocketFunction.d.ts and index.d.ts from being wrapped in a module declaration
|
|
30
|
-
const relativePath = path.relative(renderUtilsPath, filePath);
|
|
31
|
-
const withoutExt = relativePath.replace(/\.d\.ts$/, "");
|
|
32
|
-
const modulePath = "socket-function/" + withoutExt.replace(/\\/g, "/");
|
|
33
|
-
return modulePath !== "socket-function/SocketFunction" && modulePath !== "socket-function/index";
|
|
34
|
-
})
|
|
35
30
|
.map(filePath => {
|
|
36
31
|
const relativePath = path.relative(renderUtilsPath, filePath);
|
|
37
32
|
const withoutExt = relativePath.replace(/\.d\.ts$/, "");
|
|
38
33
|
const modulePath = "socket-function/" + withoutExt.replace(/\\/g, "/");
|
|
34
|
+
if (excludedModules.includes(modulePath)) return undefined;
|
|
35
|
+
|
|
36
|
+
let content = fs.readFileSync(filePath, "utf8");
|
|
37
|
+
|
|
38
|
+
// Resolve relative imports to absolute module paths
|
|
39
|
+
const moduleDir = path.dirname(modulePath);
|
|
40
|
+
content = content.replace(
|
|
41
|
+
/(import|export)\s+([^"']*)\s+from\s+["'](\.[^"']+)["']/g,
|
|
42
|
+
(match, keyword, imported, relativeImport) => {
|
|
43
|
+
const absoluteModulePath = path.join(moduleDir, relativeImport).replace(/\\/g, "/");
|
|
44
|
+
return `${keyword} ${imported} from "${absoluteModulePath}"`;
|
|
45
|
+
}
|
|
46
|
+
);
|
|
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
|
+
);
|
|
39
56
|
|
|
40
|
-
const content = fs.readFileSync(filePath, "utf8");
|
|
41
57
|
const indentedContent = content
|
|
42
58
|
.split("\n")
|
|
43
59
|
.map(line => line ? " " + line : line)
|
|
@@ -45,6 +61,7 @@ function generateIndexDts() {
|
|
|
45
61
|
|
|
46
62
|
return `declare module "${modulePath}" {\n${indentedContent}\n}`;
|
|
47
63
|
})
|
|
64
|
+
.filter(x => x)
|
|
48
65
|
.sort()
|
|
49
66
|
.join("\n\n");
|
|
50
67
|
|
package/index.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ declare module "socket-function/SetProcessVariables" {
|
|
|
8
8
|
|
|
9
9
|
declare module "socket-function/SocketFunctionTypes" {
|
|
10
10
|
/// <reference path="require/RequireController.d.ts" />
|
|
11
|
-
import { getCallObj } from "
|
|
12
|
-
import { Args, MaybePromise } from "
|
|
11
|
+
import { getCallObj } from "socket-function/src/nodeProxy";
|
|
12
|
+
import { Args, MaybePromise } from "socket-function/src/types";
|
|
13
13
|
export declare const socket: unique symbol;
|
|
14
14
|
export type SocketExposedInterface = {
|
|
15
15
|
[functionName: string]: (...args: any[]) => Promise<unknown>;
|
|
@@ -127,7 +127,7 @@ declare module "socket-function/hot/HotReloadController" {
|
|
|
127
127
|
export declare function hotReloadingGuard(): true;
|
|
128
128
|
export declare function setExternalHotReloading(value: boolean): void;
|
|
129
129
|
export declare function onHotReload(callback: (modules: NodeJS.Module[]) => void): void;
|
|
130
|
-
export declare const HotReloadController: import("
|
|
130
|
+
export declare const HotReloadController: import("socket-function/SocketFunctionTypes").SocketRegistered<{
|
|
131
131
|
watchFiles: () => Promise<void>;
|
|
132
132
|
fileUpdated: (files: string[], changeTime: number) => Promise<void>;
|
|
133
133
|
}>;
|
|
@@ -194,6 +194,7 @@ declare module "socket-function/require/CSSShim" {
|
|
|
194
194
|
declare module "socket-function/require/RequireController" {
|
|
195
195
|
/// <reference path="../../typenode/index.d.ts" />
|
|
196
196
|
/// <reference types="node" />
|
|
197
|
+
/// <reference types="node" />
|
|
197
198
|
declare global {
|
|
198
199
|
namespace NodeJS {
|
|
199
200
|
interface Module {
|
|
@@ -272,7 +273,7 @@ declare module "socket-function/require/RequireController" {
|
|
|
272
273
|
/** @deprecated, not needed, as this defaults to ".", which is a lot easier to reason about anyways. */
|
|
273
274
|
export declare function setRequireBootRequire(dir: string): void;
|
|
274
275
|
export declare function allowAllNodeModules(): void;
|
|
275
|
-
export declare const RequireController: import("
|
|
276
|
+
export declare const RequireController: import("socket-function/SocketFunctionTypes").SocketRegistered<{
|
|
276
277
|
rootResolvePath: "Function has implementation but is not exposed in the SocketFunction.register call";
|
|
277
278
|
requireHTML: (config?: {
|
|
278
279
|
requireCalls?: string[];
|
|
@@ -317,6 +318,7 @@ declare module "socket-function/require/compileFlags" {
|
|
|
317
318
|
}
|
|
318
319
|
|
|
319
320
|
declare module "socket-function/require/extMapper" {
|
|
321
|
+
/// <reference types="node" />
|
|
320
322
|
/// <reference types="node" />
|
|
321
323
|
export declare function getExtContentType(ext: string): string;
|
|
322
324
|
export declare function getContentTypeFromBuffer(buffer: Buffer): string | undefined;
|
|
@@ -344,7 +346,8 @@ declare module "socket-function/require/require" {
|
|
|
344
346
|
declare module "socket-function/src/CallFactory" {
|
|
345
347
|
/// <reference types="node" />
|
|
346
348
|
/// <reference types="node" />
|
|
347
|
-
|
|
349
|
+
/// <reference types="node" />
|
|
350
|
+
import { CallType } from "socket-function/SocketFunctionTypes";
|
|
348
351
|
import * as ws from "ws";
|
|
349
352
|
import * as tls from "tls";
|
|
350
353
|
export interface CallFactory {
|
|
@@ -382,6 +385,7 @@ declare module "socket-function/src/CallFactory" {
|
|
|
382
385
|
}
|
|
383
386
|
|
|
384
387
|
declare module "socket-function/src/JSONLACKS/JSONLACKS" {
|
|
388
|
+
/// <reference types="node" />
|
|
385
389
|
/// <reference types="node" />
|
|
386
390
|
export interface JSONLACKS_ParseConfig {
|
|
387
391
|
extended?: boolean;
|
|
@@ -430,7 +434,7 @@ declare module "socket-function/src/args" {
|
|
|
430
434
|
}
|
|
431
435
|
|
|
432
436
|
declare module "socket-function/src/batching" {
|
|
433
|
-
import { AnyFunction } from "
|
|
437
|
+
import { AnyFunction } from "socket-function/src/types";
|
|
434
438
|
export type DelayType = (number | "afterio" | "immediate" | "afterpromises" | "paintLoop" | "afterPaint");
|
|
435
439
|
export declare function delay(delayTime: DelayType, immediateShortDelays?: "immediateShortDelays"): Promise<void>;
|
|
436
440
|
export declare function batchFunctionNone<Arg, Result = void>(config: unknown, fnc: (arg: Arg[]) => (Promise<Result> | Result)): (arg: Arg) => Promise<Result>;
|
|
@@ -465,7 +469,7 @@ declare module "socket-function/src/batching" {
|
|
|
465
469
|
}
|
|
466
470
|
|
|
467
471
|
declare module "socket-function/src/caching" {
|
|
468
|
-
import { AnyFunction, Args } from "
|
|
472
|
+
import { AnyFunction, Args } from "socket-function/src/types";
|
|
469
473
|
export declare function lazy<T>(factory: () => T): {
|
|
470
474
|
(): T;
|
|
471
475
|
reset(): void;
|
|
@@ -528,10 +532,11 @@ declare module "socket-function/src/caching" {
|
|
|
528
532
|
}
|
|
529
533
|
|
|
530
534
|
declare module "socket-function/src/callHTTPHandler" {
|
|
535
|
+
/// <reference types="node" />
|
|
531
536
|
/// <reference types="node" />
|
|
532
537
|
/// <reference types="node" />
|
|
533
538
|
import http from "http";
|
|
534
|
-
import { CallType } from "
|
|
539
|
+
import { CallType } from "socket-function/SocketFunctionTypes";
|
|
535
540
|
export declare function setDefaultHTTPCall(call: CallType): void;
|
|
536
541
|
export declare function getServerLocationFromRequest(request: http.IncomingMessage): {
|
|
537
542
|
address: string;
|
|
@@ -558,7 +563,7 @@ declare module "socket-function/src/callHTTPHandler" {
|
|
|
558
563
|
|
|
559
564
|
declare module "socket-function/src/callManager" {
|
|
560
565
|
/// <reference path="../hot/HotReloadController.d.ts" />
|
|
561
|
-
import { CallerContext, CallType, ClientHookContext, FullCallType, FunctionFlags, HookContext, SocketExposedInterface, SocketExposedShape, SocketFunctionClientHook, SocketFunctionHook, SocketRegistered } from "
|
|
566
|
+
import { CallerContext, CallType, ClientHookContext, FullCallType, FunctionFlags, HookContext, SocketExposedInterface, SocketExposedShape, SocketFunctionClientHook, SocketFunctionHook, SocketRegistered } from "socket-function/SocketFunctionTypes";
|
|
562
567
|
export declare function getCallFlags(call: CallType): FunctionFlags | undefined;
|
|
563
568
|
export declare function shouldCompressCall(call: CallType): boolean;
|
|
564
569
|
export declare function performLocalCall(config: {
|
|
@@ -582,6 +587,7 @@ declare module "socket-function/src/callManager" {
|
|
|
582
587
|
}
|
|
583
588
|
|
|
584
589
|
declare module "socket-function/src/certStore" {
|
|
590
|
+
/// <reference types="node" />
|
|
585
591
|
/// <reference types="node" />
|
|
586
592
|
/** Must be populated before the server starts */
|
|
587
593
|
export declare function trustCertificate(cert: string | Buffer): void;
|
|
@@ -695,6 +701,7 @@ declare module "socket-function/src/forwardPort" {
|
|
|
695
701
|
}
|
|
696
702
|
|
|
697
703
|
declare module "socket-function/src/https" {
|
|
704
|
+
/// <reference types="node" />
|
|
698
705
|
/// <reference types="node" />
|
|
699
706
|
export declare function httpsRequest(url: string, payload?: Buffer | Buffer[], method?: string, sendSessionCookies?: boolean, config?: {
|
|
700
707
|
headers?: {
|
|
@@ -707,7 +714,8 @@ declare module "socket-function/src/https" {
|
|
|
707
714
|
|
|
708
715
|
declare module "socket-function/src/misc" {
|
|
709
716
|
/// <reference types="node" />
|
|
710
|
-
|
|
717
|
+
/// <reference types="node" />
|
|
718
|
+
import { MaybePromise } from "socket-function/src/types";
|
|
711
719
|
export declare const timeInSecond = 1000;
|
|
712
720
|
export declare const timeInMinute: number;
|
|
713
721
|
export declare const timeInHour: number;
|
|
@@ -822,8 +830,8 @@ declare module "socket-function/src/networking" {
|
|
|
822
830
|
}
|
|
823
831
|
|
|
824
832
|
declare module "socket-function/src/nodeCache" {
|
|
825
|
-
import { CallFactory } from "
|
|
826
|
-
import { MaybePromise } from "
|
|
833
|
+
import { CallFactory } from "socket-function/src/CallFactory";
|
|
834
|
+
import { MaybePromise } from "socket-function/src/types";
|
|
827
835
|
export declare function getNodeId(domain: string, port: number): string;
|
|
828
836
|
/** @deprecated, call getBrowserUrlNode instead, which does important additional checks. */
|
|
829
837
|
export declare function getNodeIdFromLocation(): string;
|
|
@@ -850,7 +858,7 @@ declare module "socket-function/src/nodeCache" {
|
|
|
850
858
|
}
|
|
851
859
|
|
|
852
860
|
declare module "socket-function/src/nodeProxy" {
|
|
853
|
-
import { FullCallType, SocketInternalInterface } from "
|
|
861
|
+
import { FullCallType, SocketInternalInterface } from "socket-function/SocketFunctionTypes";
|
|
854
862
|
type CallProxyType = {
|
|
855
863
|
[nodeId: string]: SocketInternalInterface;
|
|
856
864
|
};
|
|
@@ -877,7 +885,7 @@ declare module "socket-function/src/profiling/getOwnTime" {
|
|
|
877
885
|
}
|
|
878
886
|
|
|
879
887
|
declare module "socket-function/src/profiling/measure" {
|
|
880
|
-
import { StatsValue } from "
|
|
888
|
+
import { StatsValue } from "socket-function/src/profiling/stats";
|
|
881
889
|
/** NOTE: Must be called BEFORE anything else is imported!
|
|
882
890
|
* NOTE: Measurements on on by default now, so this doesn't really need to be called...
|
|
883
891
|
*/
|
|
@@ -998,7 +1006,7 @@ declare module "socket-function/src/profiling/stats" {
|
|
|
998
1006
|
}
|
|
999
1007
|
|
|
1000
1008
|
declare module "socket-function/src/profiling/statsFormat" {
|
|
1001
|
-
import { StatsValue } from "
|
|
1009
|
+
import { StatsValue } from "socket-function/src/profiling/stats";
|
|
1002
1010
|
export declare function percent(value: number): string;
|
|
1003
1011
|
export declare function formatStats(stats: StatsValue, config?: {
|
|
1004
1012
|
noColor?: boolean;
|
|
@@ -1116,6 +1124,7 @@ declare module "socket-function/src/storagePath" {
|
|
|
1116
1124
|
}
|
|
1117
1125
|
|
|
1118
1126
|
declare module "socket-function/src/tlsParsing" {
|
|
1127
|
+
/// <reference types="node" />
|
|
1119
1128
|
/// <reference types="node" />
|
|
1120
1129
|
export declare function parseTLSHello(buffer: Buffer): {
|
|
1121
1130
|
extensions: {
|
|
@@ -1140,10 +1149,11 @@ declare module "socket-function/src/types" {
|
|
|
1140
1149
|
}
|
|
1141
1150
|
|
|
1142
1151
|
declare module "socket-function/src/webSocketServer" {
|
|
1152
|
+
/// <reference types="node" />
|
|
1143
1153
|
/// <reference types="node" />
|
|
1144
1154
|
/// <reference types="node" />
|
|
1145
1155
|
import https from "https";
|
|
1146
|
-
import { Watchable } from "
|
|
1156
|
+
import { Watchable } from "socket-function/src/misc";
|
|
1147
1157
|
export type SocketServerConfig = (https.ServerOptions & {
|
|
1148
1158
|
key: string | Buffer;
|
|
1149
1159
|
cert: string | Buffer;
|
|
@@ -1175,7 +1185,7 @@ declare module "socket-function/src/webSocketServer" {
|
|
|
1175
1185
|
declare module "socket-function/src/websocketFactory" {
|
|
1176
1186
|
/// <reference types="node" />
|
|
1177
1187
|
import tls from "tls";
|
|
1178
|
-
import { SenderInterface } from "
|
|
1188
|
+
import { SenderInterface } from "socket-function/src/CallFactory";
|
|
1179
1189
|
import type * as ws from "ws";
|
|
1180
1190
|
export declare function getTLSSocket(webSocket: ws.WebSocket): tls.TLSSocket;
|
|
1181
1191
|
/** NOTE: We create a factory, which embeds the key/cert information. Otherwise retries might use
|
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