mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 06:50:01 -04:00
Merge branch 'main' of https://github.com/MercuryWorkshop/aerojet
This commit is contained in:
commit
6ea474c3d0
8 changed files with 42 additions and 21 deletions
|
@ -48,7 +48,7 @@
|
|||
},
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@mercuryworkshop/bare-mux": "^2.0.2",
|
||||
"@mercuryworkshop/bare-mux": "^2.0.5",
|
||||
"@webreflection/idb-map": "^0.3.1",
|
||||
"astravel": "^0.6.1",
|
||||
"astring": "^1.8.6",
|
||||
|
|
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
|
@ -9,8 +9,8 @@ importers:
|
|||
.:
|
||||
dependencies:
|
||||
'@mercuryworkshop/bare-mux':
|
||||
specifier: ^2.0.2
|
||||
version: 2.0.2
|
||||
specifier: ^2.0.5
|
||||
version: 2.0.5
|
||||
'@webreflection/idb-map':
|
||||
specifier: ^0.3.1
|
||||
version: 0.3.1
|
||||
|
@ -230,8 +230,8 @@ packages:
|
|||
'@mercuryworkshop/bare-as-module3@2.2.2':
|
||||
resolution: {integrity: sha512-Ds8981SmI1DQp1mDCVax1x0I5mH2dR1tYKytW7xTjlnpsfwn3RzQDiVJHUCrpc7cWGCe+7mHCF3EoMjM3hFfvQ==}
|
||||
|
||||
'@mercuryworkshop/bare-mux@2.0.2':
|
||||
resolution: {integrity: sha512-1rnqFfI29VXi3jrMbkotHV+NnafJ3tpTIuH3Ov/BtVAfZMNGcsCRr3dwEKRWc+mDb0tWdNWC0PnZghgfAlbr+A==}
|
||||
'@mercuryworkshop/bare-mux@2.0.5':
|
||||
resolution: {integrity: sha512-Uu0JGqqh4K0MuOGnz5QI8DvnW3SGqmdeIP5HET1JKFjMy3HqPpRrIb3UAETZ7TPYjWgR/YJxNp2DmCsPluohCg==}
|
||||
|
||||
'@mercuryworkshop/epoxy-tls@2.1.2-1':
|
||||
resolution: {integrity: sha512-qt6UOEZcVMYblFwOKaNAZHoDHSYN3JZ5Z6BvRHKB6zo1DFMub+cPuYQ+Aauib7LmIabYWZi2cMyfO5VsNLDYoA==}
|
||||
|
@ -3183,7 +3183,7 @@ snapshots:
|
|||
dependencies:
|
||||
typescript: 5.5.3
|
||||
|
||||
'@mercuryworkshop/bare-mux@2.0.2': {}
|
||||
'@mercuryworkshop/bare-mux@2.0.5': {}
|
||||
|
||||
'@mercuryworkshop/epoxy-tls@2.1.2-1': {}
|
||||
|
||||
|
|
|
@ -6,7 +6,13 @@ import { createGlobalProxy } from "./global";
|
|||
import { getOwnPropertyDescriptorHandler } from "./helpers";
|
||||
import { createLocationProxy } from "./location";
|
||||
import { nativeGetOwnPropertyDescriptor } from "./natives";
|
||||
import { CookieStore, config, decodeUrl, encodeUrl } from "../shared";
|
||||
import {
|
||||
BareClient,
|
||||
CookieStore,
|
||||
config,
|
||||
decodeUrl,
|
||||
encodeUrl,
|
||||
} from "../shared";
|
||||
import { createWrapFn } from "./shared/wrap";
|
||||
import { NavigateEvent } from "./events";
|
||||
|
||||
|
@ -53,6 +59,7 @@ export class ScramjetClient {
|
|||
globalProxy: any;
|
||||
locationProxy: any;
|
||||
serviceWorker: ServiceWorkerContainer;
|
||||
bare: any;
|
||||
|
||||
descriptors: Record<string, PropertyDescriptor> = {};
|
||||
natives: Record<string, any> = {};
|
||||
|
@ -83,7 +90,19 @@ export class ScramjetClient {
|
|||
this.locationProxy = createLocationProxy(this, global);
|
||||
this.globalProxy = createGlobalProxy(this, global);
|
||||
this.wrapfn = createWrapFn(this, global);
|
||||
|
||||
if (iswindow) {
|
||||
this.bare = new BareClient();
|
||||
} else {
|
||||
this.bare = new BareClient(
|
||||
new Promise((resolve) => {
|
||||
addEventListener("message", (e) => {
|
||||
if (e.data instanceof MessagePort) {
|
||||
resolve(e.data);
|
||||
}
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
global[SCRAMJETCLIENT] = this;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,10 @@
|
|||
import { iswindow, isworker } from "../..";
|
||||
import { ScramjetClient } from "../../client";
|
||||
import { BareClient } from "../../../shared";
|
||||
|
||||
const bare = iswindow && new BareClient();
|
||||
|
||||
export default function (client: ScramjetClient, self: typeof globalThis) {
|
||||
// r58 please fix
|
||||
if (isworker) return;
|
||||
|
||||
client.Proxy("WebSocket", {
|
||||
construct(ctx) {
|
||||
ctx.return(
|
||||
bare.createWebSocket(
|
||||
client.bare.createWebSocket(
|
||||
ctx.args[0],
|
||||
ctx.args[1],
|
||||
ctx.fn as typeof WebSocket,
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { encodeUrl } from "../../shared";
|
||||
import { encodeUrl, BareMuxConnection } from "../../shared";
|
||||
import { ScramjetClient } from "../client";
|
||||
|
||||
export default function (client: ScramjetClient, self: typeof globalThis) {
|
||||
client.Proxy("Worker", {
|
||||
construct({ args }) {
|
||||
construct({ args, call }) {
|
||||
if (args[0] instanceof URL) args[0] = args[0].href;
|
||||
if (args[0].startsWith("blob:") || args[0].startsWith("data:")) {
|
||||
if (args[0].startsWith("blob:")) {
|
||||
|
@ -27,6 +27,13 @@ export default function (client: ScramjetClient, self: typeof globalThis) {
|
|||
if (args[1] && args[1].type === "module") {
|
||||
args[0] += "&type=module";
|
||||
}
|
||||
|
||||
const worker = call();
|
||||
const conn = new BareMuxConnection();
|
||||
(async () => {
|
||||
const port = await conn.getInnerPort();
|
||||
worker.postMessage(port, [port]);
|
||||
})();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
export const {
|
||||
util: { BareClient, ScramjetHeaders },
|
||||
util: { BareClient, ScramjetHeaders, BareMuxConnection },
|
||||
url: { encodeUrl, decodeUrl },
|
||||
rewrite: {
|
||||
rewriteCss,
|
||||
|
|
|
@ -4,7 +4,7 @@ import { rewriteHtml, rewriteSrcset } from "./rewriters/html";
|
|||
import { rewriteJs } from "./rewriters/js";
|
||||
import { rewriteHeaders } from "./rewriters/headers";
|
||||
import { rewriteWorkers } from "./rewriters/worker";
|
||||
import { BareClient } from "@mercuryworkshop/bare-mux";
|
||||
import { BareClient, BareMuxConnection } from "@mercuryworkshop/bare-mux";
|
||||
import { parseDomain } from "parse-domain";
|
||||
import { ScramjetHeaders } from "./headers";
|
||||
import { CookieStore } from "./cookie";
|
||||
|
@ -14,6 +14,7 @@ self.$scramjet.shared = {
|
|||
util: {
|
||||
parseDomain,
|
||||
BareClient,
|
||||
BareMuxConnection,
|
||||
ScramjetHeaders,
|
||||
},
|
||||
url: {
|
||||
|
|
3
src/types.d.ts
vendored
3
src/types.d.ts
vendored
|
@ -11,7 +11,7 @@ import { rewriteJs } from "./shared/rewriters/js";
|
|||
import { rewriteHeaders } from "./shared/rewriters/headers";
|
||||
import { rewriteWorkers } from "./shared/rewriters/worker";
|
||||
import type { Codec } from "./codecs";
|
||||
import { BareClient } from "@mercuryworkshop/bare-mux";
|
||||
import { BareClient, BareMuxConnection } from "@mercuryworkshop/bare-mux";
|
||||
import { parseDomain } from "parse-domain";
|
||||
import { ScramjetHeaders } from "./shared/headers";
|
||||
import { CookieStore } from "./shared/cookie";
|
||||
|
@ -64,6 +64,7 @@ declare global {
|
|||
};
|
||||
util: {
|
||||
BareClient: typeof BareClient;
|
||||
BareMuxConnection: typeof BareMuxConnection;
|
||||
ScramjetHeaders: typeof ScramjetHeaders;
|
||||
parseDomain: typeof parseDomain;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue