socket-function 0.165.0 → 1.0.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/SocketFunction.d.ts +0 -1
- package/index.d.ts +110 -9
- package/package.json +2 -2
- package/require/RequireController.d.ts +106 -0
- package/require/RequireController.ts +1 -1
- package/require/extMapper.d.ts +0 -1
- package/src/CallFactory.d.ts +0 -1
- package/src/JSONLACKS/JSONLACKS.d.ts +0 -1
- package/src/callHTTPHandler.d.ts +0 -1
- package/src/certStore.d.ts +0 -1
- package/src/https.d.ts +0 -1
- package/src/misc.d.ts +0 -1
- package/src/tlsParsing.d.ts +0 -1
- package/src/webSocketServer.d.ts +0 -1
package/SocketFunction.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference path="require/RequireController.d.ts" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
3
|
import { SocketExposedInterface, SocketFunctionHook, SocketFunctionClientHook, SocketExposedShape, SocketRegistered, CallerContext, FullCallType, SocketRegisterType } from "./SocketFunctionTypes";
|
|
5
4
|
import { SocketServerConfig } from "./src/webSocketServer";
|
|
6
5
|
import { Args, MaybePromise } from "./src/types";
|
package/index.d.ts
CHANGED
|
@@ -191,6 +191,116 @@ declare module "socket-function/require/CSSShim" {
|
|
|
191
191
|
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
+
declare module "socket-function/require/RequireController" {
|
|
195
|
+
/// <reference path="../../typenode/index.d.ts" />
|
|
196
|
+
/// <reference types="node" />
|
|
197
|
+
declare global {
|
|
198
|
+
namespace NodeJS {
|
|
199
|
+
interface Module {
|
|
200
|
+
/** Indicates the module is allowed clientside.
|
|
201
|
+
* NOTE: Set with `module.allowclient = true`. HOWEVER, access via getIsAllowClient, which will check
|
|
202
|
+
*/
|
|
203
|
+
allowclient?: boolean;
|
|
204
|
+
/** Causes the module to not preload, requiring `await import()` for it to load correctly
|
|
205
|
+
* - Shouldn't be set recursively, otherwise nested packages will break.
|
|
206
|
+
*/
|
|
207
|
+
lazyload?: boolean;
|
|
208
|
+
/** Indicates the module is definitely not allowed clientside */
|
|
209
|
+
serveronly?: boolean;
|
|
210
|
+
/** Used internally by RequireController */
|
|
211
|
+
requireControllerSeqNum?: number;
|
|
212
|
+
evalStartTime?: number;
|
|
213
|
+
evalEndTime?: number;
|
|
214
|
+
/** (Presently only called by require.js)
|
|
215
|
+
* Called on require calls, to allow providers to create custom exports depending on the caller.
|
|
216
|
+
* - Mostly used to allow functions to know the calling module.
|
|
217
|
+
*/
|
|
218
|
+
remapExports?: (exports: {
|
|
219
|
+
[key: string]: unknown;
|
|
220
|
+
}, callerModule: NodeJS.Module) => {
|
|
221
|
+
[key: string]: unknown;
|
|
222
|
+
};
|
|
223
|
+
/** Only set if clientside (and allowed clientside) */
|
|
224
|
+
source?: string;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
interface Window {
|
|
228
|
+
clientsideBootTime: number;
|
|
229
|
+
}
|
|
230
|
+
var suppressUnexpectedModuleWarning: number | undefined;
|
|
231
|
+
}
|
|
232
|
+
/** Imports it, serverside, delayed. For dynamic imports, which we need to include once, but don't want to include
|
|
233
|
+
* immediately (due to cyclic issues), and isn't included initially.
|
|
234
|
+
*/
|
|
235
|
+
export declare function lazyImport(getModule: () => Promise<unknown>): void;
|
|
236
|
+
declare const requireSeqNumProcessId: string;
|
|
237
|
+
declare function injectHTMLBeforeStartup(text: string | (() => Promise<string>)): void;
|
|
238
|
+
declare function addStaticRoot(root: string): void;
|
|
239
|
+
type GetModulesResult = ReturnType<RequireControllerBase["getModules"]> extends Promise<infer T> ? T : never;
|
|
240
|
+
export type GetModulesArgs = Parameters<RequireControllerBase["getModules"]>;
|
|
241
|
+
declare let mapGetModules: {
|
|
242
|
+
remap(result: GetModulesResult, args: GetModulesArgs): Promise<GetModulesResult>;
|
|
243
|
+
}[];
|
|
244
|
+
declare function addMapGetModules(remap: typeof mapGetModules[number]["remap"]): void;
|
|
245
|
+
declare class RequireControllerBase {
|
|
246
|
+
rootResolvePath: string;
|
|
247
|
+
requireHTML(config?: {
|
|
248
|
+
requireCalls?: string[];
|
|
249
|
+
cacheTime?: number;
|
|
250
|
+
}): Promise<Buffer>;
|
|
251
|
+
getModules(pathRequests: string[], alreadyHave?: {
|
|
252
|
+
requireSeqNumProcessId: string;
|
|
253
|
+
seqNumRanges: {
|
|
254
|
+
s: number;
|
|
255
|
+
e?: number;
|
|
256
|
+
}[];
|
|
257
|
+
}, config?: {}): Promise<{
|
|
258
|
+
requestsResolvedPaths: string[];
|
|
259
|
+
modules: {
|
|
260
|
+
[resolvedPath: string]: SerializedModule;
|
|
261
|
+
};
|
|
262
|
+
requireSeqNumProcessId: string;
|
|
263
|
+
}>;
|
|
264
|
+
}
|
|
265
|
+
export declare function getIsAllowClient(module: NodeJS.Module): boolean | undefined;
|
|
266
|
+
type ClientRemapCallback = (args: GetModulesArgs) => Promise<GetModulesArgs>;
|
|
267
|
+
declare global {
|
|
268
|
+
/** Must be set clientside BEFORE requests are made (so you likely want to use RequireController.addMapGetModules
|
|
269
|
+
* to inject code that will use this) */
|
|
270
|
+
var remapImportRequestsClientside: undefined | ClientRemapCallback[];
|
|
271
|
+
}
|
|
272
|
+
/** @deprecated, not needed, as this defaults to ".", which is a lot easier to reason about anyways. */
|
|
273
|
+
export declare function setRequireBootRequire(dir: string): void;
|
|
274
|
+
export declare function allowAllNodeModules(): void;
|
|
275
|
+
export declare const RequireController: import("../SocketFunctionTypes").SocketRegistered<{
|
|
276
|
+
rootResolvePath: "Function has implementation but is not exposed in the SocketFunction.register call";
|
|
277
|
+
requireHTML: (config?: {
|
|
278
|
+
requireCalls?: string[];
|
|
279
|
+
cacheTime?: number;
|
|
280
|
+
}) => Promise<Buffer>;
|
|
281
|
+
getModules: (pathRequests: string[], alreadyHave?: {
|
|
282
|
+
requireSeqNumProcessId: string;
|
|
283
|
+
seqNumRanges: {
|
|
284
|
+
s: number;
|
|
285
|
+
e?: number;
|
|
286
|
+
}[];
|
|
287
|
+
}, config?: {}) => Promise<{
|
|
288
|
+
requestsResolvedPaths: string[];
|
|
289
|
+
modules: {
|
|
290
|
+
[resolvedPath: string]: SerializedModule;
|
|
291
|
+
};
|
|
292
|
+
requireSeqNumProcessId: string;
|
|
293
|
+
}>;
|
|
294
|
+
}> & {
|
|
295
|
+
injectHTMLBeforeStartup: typeof injectHTMLBeforeStartup;
|
|
296
|
+
addMapGetModules: typeof addMapGetModules;
|
|
297
|
+
addStaticRoot: typeof addStaticRoot;
|
|
298
|
+
allowAllNodeModules: typeof allowAllNodeModules;
|
|
299
|
+
};
|
|
300
|
+
export {};
|
|
301
|
+
|
|
302
|
+
}
|
|
303
|
+
|
|
194
304
|
declare module "socket-function/require/compileFlags" {
|
|
195
305
|
/// <reference path="RequireController.d.ts" />
|
|
196
306
|
/// <reference types="node" />
|
|
@@ -207,7 +317,6 @@ declare module "socket-function/require/compileFlags" {
|
|
|
207
317
|
}
|
|
208
318
|
|
|
209
319
|
declare module "socket-function/require/extMapper" {
|
|
210
|
-
/// <reference types="node" />
|
|
211
320
|
/// <reference types="node" />
|
|
212
321
|
export declare function getExtContentType(ext: string): string;
|
|
213
322
|
export declare function getContentTypeFromBuffer(buffer: Buffer): string | undefined;
|
|
@@ -233,7 +342,6 @@ declare module "socket-function/require/require" {
|
|
|
233
342
|
}
|
|
234
343
|
|
|
235
344
|
declare module "socket-function/src/CallFactory" {
|
|
236
|
-
/// <reference types="node" />
|
|
237
345
|
/// <reference types="node" />
|
|
238
346
|
/// <reference types="node" />
|
|
239
347
|
import { CallType } from "../SocketFunctionTypes";
|
|
@@ -274,7 +382,6 @@ declare module "socket-function/src/CallFactory" {
|
|
|
274
382
|
}
|
|
275
383
|
|
|
276
384
|
declare module "socket-function/src/JSONLACKS/JSONLACKS" {
|
|
277
|
-
/// <reference types="node" />
|
|
278
385
|
/// <reference types="node" />
|
|
279
386
|
export interface JSONLACKS_ParseConfig {
|
|
280
387
|
extended?: boolean;
|
|
@@ -421,7 +528,6 @@ declare module "socket-function/src/caching" {
|
|
|
421
528
|
}
|
|
422
529
|
|
|
423
530
|
declare module "socket-function/src/callHTTPHandler" {
|
|
424
|
-
/// <reference types="node" />
|
|
425
531
|
/// <reference types="node" />
|
|
426
532
|
/// <reference types="node" />
|
|
427
533
|
import http from "http";
|
|
@@ -476,7 +582,6 @@ declare module "socket-function/src/callManager" {
|
|
|
476
582
|
}
|
|
477
583
|
|
|
478
584
|
declare module "socket-function/src/certStore" {
|
|
479
|
-
/// <reference types="node" />
|
|
480
585
|
/// <reference types="node" />
|
|
481
586
|
/** Must be populated before the server starts */
|
|
482
587
|
export declare function trustCertificate(cert: string | Buffer): void;
|
|
@@ -590,7 +695,6 @@ declare module "socket-function/src/forwardPort" {
|
|
|
590
695
|
}
|
|
591
696
|
|
|
592
697
|
declare module "socket-function/src/https" {
|
|
593
|
-
/// <reference types="node" />
|
|
594
698
|
/// <reference types="node" />
|
|
595
699
|
export declare function httpsRequest(url: string, payload?: Buffer | Buffer[], method?: string, sendSessionCookies?: boolean, config?: {
|
|
596
700
|
headers?: {
|
|
@@ -602,7 +706,6 @@ declare module "socket-function/src/https" {
|
|
|
602
706
|
}
|
|
603
707
|
|
|
604
708
|
declare module "socket-function/src/misc" {
|
|
605
|
-
/// <reference types="node" />
|
|
606
709
|
/// <reference types="node" />
|
|
607
710
|
import { MaybePromise } from "./types";
|
|
608
711
|
export declare const timeInSecond = 1000;
|
|
@@ -1013,7 +1116,6 @@ declare module "socket-function/src/storagePath" {
|
|
|
1013
1116
|
}
|
|
1014
1117
|
|
|
1015
1118
|
declare module "socket-function/src/tlsParsing" {
|
|
1016
|
-
/// <reference types="node" />
|
|
1017
1119
|
/// <reference types="node" />
|
|
1018
1120
|
export declare function parseTLSHello(buffer: Buffer): {
|
|
1019
1121
|
extensions: {
|
|
@@ -1038,7 +1140,6 @@ declare module "socket-function/src/types" {
|
|
|
1038
1140
|
}
|
|
1039
1141
|
|
|
1040
1142
|
declare module "socket-function/src/webSocketServer" {
|
|
1041
|
-
/// <reference types="node" />
|
|
1042
1143
|
/// <reference types="node" />
|
|
1043
1144
|
/// <reference types="node" />
|
|
1044
1145
|
import https from "https";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "socket-function",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"dependencies": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"pako": "^2.1.0",
|
|
12
12
|
"preact": "10.24.3",
|
|
13
13
|
"typedev": "^0.4.0",
|
|
14
|
-
"typenode": "^
|
|
14
|
+
"typenode": "^6.0.1",
|
|
15
15
|
"ws": "^8.17.1"
|
|
16
16
|
},
|
|
17
17
|
"types": "index.d.ts",
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/// <reference path="../../typenode/index.d.ts" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
declare global {
|
|
4
|
+
namespace NodeJS {
|
|
5
|
+
interface Module {
|
|
6
|
+
/** Indicates the module is allowed clientside.
|
|
7
|
+
* NOTE: Set with `module.allowclient = true`. HOWEVER, access via getIsAllowClient, which will check
|
|
8
|
+
*/
|
|
9
|
+
allowclient?: boolean;
|
|
10
|
+
/** Causes the module to not preload, requiring `await import()` for it to load correctly
|
|
11
|
+
* - Shouldn't be set recursively, otherwise nested packages will break.
|
|
12
|
+
*/
|
|
13
|
+
lazyload?: boolean;
|
|
14
|
+
/** Indicates the module is definitely not allowed clientside */
|
|
15
|
+
serveronly?: boolean;
|
|
16
|
+
/** Used internally by RequireController */
|
|
17
|
+
requireControllerSeqNum?: number;
|
|
18
|
+
evalStartTime?: number;
|
|
19
|
+
evalEndTime?: number;
|
|
20
|
+
/** (Presently only called by require.js)
|
|
21
|
+
* Called on require calls, to allow providers to create custom exports depending on the caller.
|
|
22
|
+
* - Mostly used to allow functions to know the calling module.
|
|
23
|
+
*/
|
|
24
|
+
remapExports?: (exports: {
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
}, callerModule: NodeJS.Module) => {
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
};
|
|
29
|
+
/** Only set if clientside (and allowed clientside) */
|
|
30
|
+
source?: string;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
interface Window {
|
|
34
|
+
clientsideBootTime: number;
|
|
35
|
+
}
|
|
36
|
+
var suppressUnexpectedModuleWarning: number | undefined;
|
|
37
|
+
}
|
|
38
|
+
/** Imports it, serverside, delayed. For dynamic imports, which we need to include once, but don't want to include
|
|
39
|
+
* immediately (due to cyclic issues), and isn't included initially.
|
|
40
|
+
*/
|
|
41
|
+
export declare function lazyImport(getModule: () => Promise<unknown>): void;
|
|
42
|
+
declare const requireSeqNumProcessId: string;
|
|
43
|
+
declare function injectHTMLBeforeStartup(text: string | (() => Promise<string>)): void;
|
|
44
|
+
declare function addStaticRoot(root: string): void;
|
|
45
|
+
type GetModulesResult = ReturnType<RequireControllerBase["getModules"]> extends Promise<infer T> ? T : never;
|
|
46
|
+
export type GetModulesArgs = Parameters<RequireControllerBase["getModules"]>;
|
|
47
|
+
declare let mapGetModules: {
|
|
48
|
+
remap(result: GetModulesResult, args: GetModulesArgs): Promise<GetModulesResult>;
|
|
49
|
+
}[];
|
|
50
|
+
declare function addMapGetModules(remap: typeof mapGetModules[number]["remap"]): void;
|
|
51
|
+
declare class RequireControllerBase {
|
|
52
|
+
rootResolvePath: string;
|
|
53
|
+
requireHTML(config?: {
|
|
54
|
+
requireCalls?: string[];
|
|
55
|
+
cacheTime?: number;
|
|
56
|
+
}): Promise<Buffer>;
|
|
57
|
+
getModules(pathRequests: string[], alreadyHave?: {
|
|
58
|
+
requireSeqNumProcessId: string;
|
|
59
|
+
seqNumRanges: {
|
|
60
|
+
s: number;
|
|
61
|
+
e?: number;
|
|
62
|
+
}[];
|
|
63
|
+
}, config?: {}): Promise<{
|
|
64
|
+
requestsResolvedPaths: string[];
|
|
65
|
+
modules: {
|
|
66
|
+
[resolvedPath: string]: SerializedModule;
|
|
67
|
+
};
|
|
68
|
+
requireSeqNumProcessId: string;
|
|
69
|
+
}>;
|
|
70
|
+
}
|
|
71
|
+
export declare function getIsAllowClient(module: NodeJS.Module): boolean | undefined;
|
|
72
|
+
type ClientRemapCallback = (args: GetModulesArgs) => Promise<GetModulesArgs>;
|
|
73
|
+
declare global {
|
|
74
|
+
/** Must be set clientside BEFORE requests are made (so you likely want to use RequireController.addMapGetModules
|
|
75
|
+
* to inject code that will use this) */
|
|
76
|
+
var remapImportRequestsClientside: undefined | ClientRemapCallback[];
|
|
77
|
+
}
|
|
78
|
+
/** @deprecated, not needed, as this defaults to ".", which is a lot easier to reason about anyways. */
|
|
79
|
+
export declare function setRequireBootRequire(dir: string): void;
|
|
80
|
+
export declare function allowAllNodeModules(): void;
|
|
81
|
+
export declare const RequireController: import("../SocketFunctionTypes").SocketRegistered<{
|
|
82
|
+
rootResolvePath: "Function has implementation but is not exposed in the SocketFunction.register call";
|
|
83
|
+
requireHTML: (config?: {
|
|
84
|
+
requireCalls?: string[];
|
|
85
|
+
cacheTime?: number;
|
|
86
|
+
}) => Promise<Buffer>;
|
|
87
|
+
getModules: (pathRequests: string[], alreadyHave?: {
|
|
88
|
+
requireSeqNumProcessId: string;
|
|
89
|
+
seqNumRanges: {
|
|
90
|
+
s: number;
|
|
91
|
+
e?: number;
|
|
92
|
+
}[];
|
|
93
|
+
}, config?: {}) => Promise<{
|
|
94
|
+
requestsResolvedPaths: string[];
|
|
95
|
+
modules: {
|
|
96
|
+
[resolvedPath: string]: SerializedModule;
|
|
97
|
+
};
|
|
98
|
+
requireSeqNumProcessId: string;
|
|
99
|
+
}>;
|
|
100
|
+
}> & {
|
|
101
|
+
injectHTMLBeforeStartup: typeof injectHTMLBeforeStartup;
|
|
102
|
+
addMapGetModules: typeof addMapGetModules;
|
|
103
|
+
addStaticRoot: typeof addStaticRoot;
|
|
104
|
+
allowAllNodeModules: typeof allowAllNodeModules;
|
|
105
|
+
};
|
|
106
|
+
export {};
|
|
@@ -115,7 +115,7 @@ class RequireControllerBase {
|
|
|
115
115
|
public async requireHTML(config?: {
|
|
116
116
|
requireCalls?: string[];
|
|
117
117
|
cacheTime?: number;
|
|
118
|
-
}) {
|
|
118
|
+
}): Promise<Buffer> {
|
|
119
119
|
let { requireCalls, cacheTime } = config || {};
|
|
120
120
|
let httpRequest = getCurrentHTTPRequest();
|
|
121
121
|
let headers: Record<string, string> = {
|
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