mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 14:30:02 -04:00
chore: code cleanup
This commit is contained in:
parent
e4a0ee9ac0
commit
7de29b7cf3
2 changed files with 4 additions and 16 deletions
|
@ -1,18 +1,11 @@
|
|||
import { flagEnabled } from "../../../scramjet";
|
||||
import { config, unrewriteUrl, rewriteUrl } from "../../../shared";
|
||||
import { ScramjetClient } from "../../client";
|
||||
let nativeworker;
|
||||
let postmessage;
|
||||
|
||||
if (self.Worker) {
|
||||
nativeworker = Worker;
|
||||
postmessage = Worker.prototype.postMessage;
|
||||
}
|
||||
|
||||
export default function (client: ScramjetClient, self: Self) {
|
||||
let worker;
|
||||
if (self.Worker && flagEnabled("syncxhr", client.url)) {
|
||||
worker = new nativeworker(config.files.sync);
|
||||
worker = new client.natives["Worker"](config.files.sync);
|
||||
}
|
||||
const ARGS = Symbol("xhr original args");
|
||||
const HEADERS = Symbol("xhr headers");
|
||||
|
@ -50,7 +43,7 @@ export default function (client: ScramjetClient, self: Self) {
|
|||
const sab = new SharedArrayBuffer(1024, { maxByteLength: 2147483647 });
|
||||
const view = new DataView(sab);
|
||||
|
||||
postmessage.call(worker, {
|
||||
client.natives["Worker.prototype.postMessage"].call(worker, {
|
||||
sab,
|
||||
args,
|
||||
headers: ctx.this[HEADERS],
|
||||
|
|
|
@ -4,11 +4,6 @@ import { rewriteUrl } from "../../shared";
|
|||
import type { MessageC2W } from "../../worker";
|
||||
import { ScramjetClient } from "../client";
|
||||
|
||||
const sharedworkerpostmessage = MessagePort.prototype.postMessage;
|
||||
let workerpostmessage;
|
||||
if (self.Worker) {
|
||||
workerpostmessage = Worker.prototype.postMessage;
|
||||
}
|
||||
export default function (client: ScramjetClient, self: typeof globalThis) {
|
||||
if (self.Worker) {
|
||||
client.Proxy("Worker", {
|
||||
|
@ -26,7 +21,7 @@ export default function (client: ScramjetClient, self: typeof globalThis) {
|
|||
|
||||
(async () => {
|
||||
const port = await conn.getInnerPort();
|
||||
workerpostmessage.call(
|
||||
client.natives["Worker.prototype.postMessage"].call(
|
||||
worker,
|
||||
{
|
||||
$scramjet$type: "baremuxinit",
|
||||
|
@ -71,7 +66,7 @@ export default function (client: ScramjetClient, self: typeof globalThis) {
|
|||
|
||||
(async () => {
|
||||
const port = await conn.getInnerPort();
|
||||
sharedworkerpostmessage.call(
|
||||
client.natives["MessagePort.prototype.postMessage"].call(
|
||||
worker.port,
|
||||
{
|
||||
$scramjet$type: "baremuxinit",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue