socket-function 1.0.1 → 1.0.2
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/generateIndexDts.js +16 -8
- package/index.d.ts +15 -15
- package/package.json +1 -1
package/generateIndexDts.js
CHANGED
|
@@ -24,20 +24,27 @@ 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
|
+
);
|
|
39
47
|
|
|
40
|
-
const content = fs.readFileSync(filePath, "utf8");
|
|
41
48
|
const indentedContent = content
|
|
42
49
|
.split("\n")
|
|
43
50
|
.map(line => line ? " " + line : line)
|
|
@@ -45,6 +52,7 @@ function generateIndexDts() {
|
|
|
45
52
|
|
|
46
53
|
return `declare module "${modulePath}" {\n${indentedContent}\n}`;
|
|
47
54
|
})
|
|
55
|
+
.filter(x => x)
|
|
48
56
|
.sort()
|
|
49
57
|
.join("\n\n");
|
|
50
58
|
|
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>;
|
|
@@ -344,7 +344,7 @@ declare module "socket-function/require/require" {
|
|
|
344
344
|
declare module "socket-function/src/CallFactory" {
|
|
345
345
|
/// <reference types="node" />
|
|
346
346
|
/// <reference types="node" />
|
|
347
|
-
import { CallType } from "
|
|
347
|
+
import { CallType } from "socket-function/SocketFunctionTypes";
|
|
348
348
|
import * as ws from "ws";
|
|
349
349
|
import * as tls from "tls";
|
|
350
350
|
export interface CallFactory {
|
|
@@ -430,7 +430,7 @@ declare module "socket-function/src/args" {
|
|
|
430
430
|
}
|
|
431
431
|
|
|
432
432
|
declare module "socket-function/src/batching" {
|
|
433
|
-
import { AnyFunction } from "
|
|
433
|
+
import { AnyFunction } from "socket-function/src/types";
|
|
434
434
|
export type DelayType = (number | "afterio" | "immediate" | "afterpromises" | "paintLoop" | "afterPaint");
|
|
435
435
|
export declare function delay(delayTime: DelayType, immediateShortDelays?: "immediateShortDelays"): Promise<void>;
|
|
436
436
|
export declare function batchFunctionNone<Arg, Result = void>(config: unknown, fnc: (arg: Arg[]) => (Promise<Result> | Result)): (arg: Arg) => Promise<Result>;
|
|
@@ -465,7 +465,7 @@ declare module "socket-function/src/batching" {
|
|
|
465
465
|
}
|
|
466
466
|
|
|
467
467
|
declare module "socket-function/src/caching" {
|
|
468
|
-
import { AnyFunction, Args } from "
|
|
468
|
+
import { AnyFunction, Args } from "socket-function/src/types";
|
|
469
469
|
export declare function lazy<T>(factory: () => T): {
|
|
470
470
|
(): T;
|
|
471
471
|
reset(): void;
|
|
@@ -531,7 +531,7 @@ declare module "socket-function/src/callHTTPHandler" {
|
|
|
531
531
|
/// <reference types="node" />
|
|
532
532
|
/// <reference types="node" />
|
|
533
533
|
import http from "http";
|
|
534
|
-
import { CallType } from "
|
|
534
|
+
import { CallType } from "socket-function/SocketFunctionTypes";
|
|
535
535
|
export declare function setDefaultHTTPCall(call: CallType): void;
|
|
536
536
|
export declare function getServerLocationFromRequest(request: http.IncomingMessage): {
|
|
537
537
|
address: string;
|
|
@@ -558,7 +558,7 @@ declare module "socket-function/src/callHTTPHandler" {
|
|
|
558
558
|
|
|
559
559
|
declare module "socket-function/src/callManager" {
|
|
560
560
|
/// <reference path="../hot/HotReloadController.d.ts" />
|
|
561
|
-
import { CallerContext, CallType, ClientHookContext, FullCallType, FunctionFlags, HookContext, SocketExposedInterface, SocketExposedShape, SocketFunctionClientHook, SocketFunctionHook, SocketRegistered } from "
|
|
561
|
+
import { CallerContext, CallType, ClientHookContext, FullCallType, FunctionFlags, HookContext, SocketExposedInterface, SocketExposedShape, SocketFunctionClientHook, SocketFunctionHook, SocketRegistered } from "socket-function/SocketFunctionTypes";
|
|
562
562
|
export declare function getCallFlags(call: CallType): FunctionFlags | undefined;
|
|
563
563
|
export declare function shouldCompressCall(call: CallType): boolean;
|
|
564
564
|
export declare function performLocalCall(config: {
|
|
@@ -707,7 +707,7 @@ declare module "socket-function/src/https" {
|
|
|
707
707
|
|
|
708
708
|
declare module "socket-function/src/misc" {
|
|
709
709
|
/// <reference types="node" />
|
|
710
|
-
import { MaybePromise } from "
|
|
710
|
+
import { MaybePromise } from "socket-function/src/types";
|
|
711
711
|
export declare const timeInSecond = 1000;
|
|
712
712
|
export declare const timeInMinute: number;
|
|
713
713
|
export declare const timeInHour: number;
|
|
@@ -822,8 +822,8 @@ declare module "socket-function/src/networking" {
|
|
|
822
822
|
}
|
|
823
823
|
|
|
824
824
|
declare module "socket-function/src/nodeCache" {
|
|
825
|
-
import { CallFactory } from "
|
|
826
|
-
import { MaybePromise } from "
|
|
825
|
+
import { CallFactory } from "socket-function/src/CallFactory";
|
|
826
|
+
import { MaybePromise } from "socket-function/src/types";
|
|
827
827
|
export declare function getNodeId(domain: string, port: number): string;
|
|
828
828
|
/** @deprecated, call getBrowserUrlNode instead, which does important additional checks. */
|
|
829
829
|
export declare function getNodeIdFromLocation(): string;
|
|
@@ -850,7 +850,7 @@ declare module "socket-function/src/nodeCache" {
|
|
|
850
850
|
}
|
|
851
851
|
|
|
852
852
|
declare module "socket-function/src/nodeProxy" {
|
|
853
|
-
import { FullCallType, SocketInternalInterface } from "
|
|
853
|
+
import { FullCallType, SocketInternalInterface } from "socket-function/SocketFunctionTypes";
|
|
854
854
|
type CallProxyType = {
|
|
855
855
|
[nodeId: string]: SocketInternalInterface;
|
|
856
856
|
};
|
|
@@ -877,7 +877,7 @@ declare module "socket-function/src/profiling/getOwnTime" {
|
|
|
877
877
|
}
|
|
878
878
|
|
|
879
879
|
declare module "socket-function/src/profiling/measure" {
|
|
880
|
-
import { StatsValue } from "
|
|
880
|
+
import { StatsValue } from "socket-function/src/profiling/stats";
|
|
881
881
|
/** NOTE: Must be called BEFORE anything else is imported!
|
|
882
882
|
* NOTE: Measurements on on by default now, so this doesn't really need to be called...
|
|
883
883
|
*/
|
|
@@ -998,7 +998,7 @@ declare module "socket-function/src/profiling/stats" {
|
|
|
998
998
|
}
|
|
999
999
|
|
|
1000
1000
|
declare module "socket-function/src/profiling/statsFormat" {
|
|
1001
|
-
import { StatsValue } from "
|
|
1001
|
+
import { StatsValue } from "socket-function/src/profiling/stats";
|
|
1002
1002
|
export declare function percent(value: number): string;
|
|
1003
1003
|
export declare function formatStats(stats: StatsValue, config?: {
|
|
1004
1004
|
noColor?: boolean;
|
|
@@ -1143,7 +1143,7 @@ declare module "socket-function/src/webSocketServer" {
|
|
|
1143
1143
|
/// <reference types="node" />
|
|
1144
1144
|
/// <reference types="node" />
|
|
1145
1145
|
import https from "https";
|
|
1146
|
-
import { Watchable } from "
|
|
1146
|
+
import { Watchable } from "socket-function/src/misc";
|
|
1147
1147
|
export type SocketServerConfig = (https.ServerOptions & {
|
|
1148
1148
|
key: string | Buffer;
|
|
1149
1149
|
cert: string | Buffer;
|
|
@@ -1175,7 +1175,7 @@ declare module "socket-function/src/webSocketServer" {
|
|
|
1175
1175
|
declare module "socket-function/src/websocketFactory" {
|
|
1176
1176
|
/// <reference types="node" />
|
|
1177
1177
|
import tls from "tls";
|
|
1178
|
-
import { SenderInterface } from "
|
|
1178
|
+
import { SenderInterface } from "socket-function/src/CallFactory";
|
|
1179
1179
|
import type * as ws from "ws";
|
|
1180
1180
|
export declare function getTLSSocket(webSocket: ws.WebSocket): tls.TLSSocket;
|
|
1181
1181
|
/** NOTE: We create a factory, which embeds the key/cert information. Otherwise retries might use
|