socket-function 0.80.0 → 0.82.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/package.json +1 -1
- package/require/require.ts +36 -16
package/package.json
CHANGED
package/require/require.ts
CHANGED
|
@@ -207,6 +207,11 @@ export function requireMain() {
|
|
|
207
207
|
|
|
208
208
|
let requireBatch: { [request: string]: (() => void)[] } | undefined;
|
|
209
209
|
function rootRequire(request: string, batch?: boolean): unknown {
|
|
210
|
+
if (request.includes("file://")) {
|
|
211
|
+
// How does this happen? It definitely breaks things, and we could remove the file://, but... how
|
|
212
|
+
// does it even happen?
|
|
213
|
+
debugger;
|
|
214
|
+
}
|
|
210
215
|
if (isFirstImport) {
|
|
211
216
|
isFirstImport = false;
|
|
212
217
|
if (request.startsWith("https://")) {
|
|
@@ -365,6 +370,7 @@ export function requireMain() {
|
|
|
365
370
|
|
|
366
371
|
|
|
367
372
|
if (Object.keys(modules).length === 1 && "" in modules) {
|
|
373
|
+
debugger;
|
|
368
374
|
eval(modules[""].source || "");
|
|
369
375
|
throw new Error(`Failed to find modules for ${originalRequests.join(", ")} (mapped to ${requests.join(", ")})`);
|
|
370
376
|
}
|
|
@@ -468,10 +474,31 @@ export function requireMain() {
|
|
|
468
474
|
|
|
469
475
|
function createRequire(module: ModuleType, serializedModule: SerializedModule, asyncIsFineOuter?: boolean) {
|
|
470
476
|
require.cache = moduleCache;
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
477
|
+
function resolve(request: string) {
|
|
478
|
+
let requests = serializedModule.requests;
|
|
479
|
+
if (request in requests) {
|
|
480
|
+
return requests[request];
|
|
481
|
+
}
|
|
482
|
+
let absolutePath = request;
|
|
483
|
+
if (absolutePath.startsWith("./") || absolutePath.startsWith("../")) {
|
|
484
|
+
let folderParts = moduleFolder.split("/");
|
|
485
|
+
while (absolutePath.startsWith("./") || absolutePath.startsWith("../")) {
|
|
486
|
+
if (absolutePath.startsWith("./")) {
|
|
487
|
+
absolutePath = absolutePath.slice("./".length);
|
|
488
|
+
} else {
|
|
489
|
+
folderParts.pop();
|
|
490
|
+
absolutePath = absolutePath.slice("../".length);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
absolutePath = folderParts.join("/") + "/" + absolutePath;
|
|
494
|
+
}
|
|
495
|
+
// Still use the same domain
|
|
496
|
+
if (!absolutePath.startsWith("https://")) {
|
|
497
|
+
absolutePath = mainRootOrigin + absolutePath;
|
|
498
|
+
}
|
|
499
|
+
return absolutePath;
|
|
500
|
+
}
|
|
501
|
+
require.resolve = resolve;
|
|
475
502
|
let moduleFolder = module.filename.replace(/\\/g, "/").split("/").slice(0, -1).join("/") + "/";
|
|
476
503
|
return require;
|
|
477
504
|
function require(request: string, asyncIsFine?: boolean) {
|
|
@@ -488,9 +515,13 @@ export function requireMain() {
|
|
|
488
515
|
return builtInModuleExports[request as keyof typeof builtInModuleExports];
|
|
489
516
|
}
|
|
490
517
|
|
|
518
|
+
let absolutePath = resolve(request);
|
|
519
|
+
|
|
491
520
|
let resolvedPath: string | undefined;
|
|
492
521
|
if (request in moduleCache) {
|
|
493
522
|
resolvedPath = request;
|
|
523
|
+
} else if (absolutePath in moduleCache) {
|
|
524
|
+
resolvedPath = absolutePath;
|
|
494
525
|
} else {
|
|
495
526
|
if (!(request in serializedModule.requests)) {
|
|
496
527
|
if (!asyncIsFine && !globalThis.suppressUnexpectedModuleWarning) {
|
|
@@ -502,18 +533,7 @@ export function requireMain() {
|
|
|
502
533
|
"color: unset"
|
|
503
534
|
);
|
|
504
535
|
}
|
|
505
|
-
|
|
506
|
-
// otherwise relative async imports won't work!
|
|
507
|
-
// (This path isn't hit often, as we usually preload, but... sometimes we won't).
|
|
508
|
-
if (request.startsWith(".")) {
|
|
509
|
-
request = moduleFolder + request;
|
|
510
|
-
} else {
|
|
511
|
-
// Still use the same domain
|
|
512
|
-
if (!request.startsWith("https://")) {
|
|
513
|
-
request = getRootDomain(request) + request;
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
return rootRequire(request);
|
|
536
|
+
return rootRequire(absolutePath);
|
|
517
537
|
}
|
|
518
538
|
|
|
519
539
|
// Built in modules that we haven't been implemented
|