Skip to content

Commit 0c537b0

Browse files
authored
Revert "Refactor scramjet to compile to a single bundle, eliminating the need for globals containing state"
1 parent b51052f commit 0c537b0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+609
-536
lines changed

INTERCEPTION_PROXY_BIBLE.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default [
5353
"@typescript-eslint/no-explicit-any": "off",
5454
"@typescript-eslint/ban-ts-comment": "off",
5555
"@typescript-eslint/ban-types": "off",
56-
"@typescript-eslint/no-require-imports": "off",
56+
5757
"@typescript-eslint/no-unused-vars": [
5858
"warn",
5959
{

frontend/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>Vite + TS</title>
88

9-
<script src="/scram/scramjet.all.js"></script>
9+
<script src="/scram/scramjet.controller.js"></script>
1010
</head>
1111

1212
<body>

lib/index.d.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
declare const scramjetPath: string;
22

33
import * as controller from "../dist/types/controller/index.ts";
4-
import * as worker from "../dist/types/worker/index.ts";
54
import * as types from "../dist/types/types.ts";
65
import * as frame from "../dist/types/controller/frame.ts";
76

87
declare global {
9-
function $scramjetLoadController(): typeof controller;
10-
function $scramjetLoadWorker(): typeof worker;
11-
function $scramjetLoadClient(config: ScramjetConfig);
8+
const ScramjetController: typeof controller.ScramjetController;
9+
const ScramjetFrame: typeof frame.ScramjetFrame;
1210
type ScramjetController = controller.ScramjetController;
1311
type ScramjetFrame = frame.ScramjetFrame;
1412

1513
type ScramjetConfig = types.ScramjetConfig;
1614
type ScramjetInitConfig = types.ScramjetInitConfig;
17-
var $scramjetVersion: {
18-
build: string;
19-
version: string;
20-
};
2115
}
2216
export { scramjetPath };

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
"@nebula-services/bare-server-node": "^2.0.4",
4444
"@playwright/test": "^1.53.1",
4545
"@rsdoctor/rspack-plugin": "^1.1.5",
46-
"@rspack/cli": "^1.4.8",
47-
"@rspack/core": "^1.4.8",
46+
"@rspack/cli": "^1.4.1",
47+
"@rspack/core": "^1.4.1",
4848
"@types/eslint": "^9.6.1",
4949
"@types/estree": "^1.0.8",
5050
"@types/node": "^24.0.6",

pnpm-lock.yaml

Lines changed: 136 additions & 159 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rspack.config.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ export default defineConfig({
1414
mode: "development",
1515
devtool: "source-map",
1616
entry: {
17-
all: join(__dirname, "src/entry.ts"),
18-
// shared: join(__dirname, "src/shared/index.ts"),
19-
// worker: join(__dirname, "src/worker/index.ts"),
20-
// client: join(__dirname, "src/client/index.ts"),
21-
// controller: join(__dirname, "src/controller/index.ts"),
17+
shared: join(__dirname, "src/shared/index.ts"),
18+
worker: join(__dirname, "src/worker/index.ts"),
19+
client: join(__dirname, "src/client/index.ts"),
20+
controller: join(__dirname, "src/controller/index.ts"),
2221
sync: join(__dirname, "src/sync.ts"),
2322
},
2423
resolve: {

src/client/client.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,16 @@ import { createLocationProxy } from "./location";
88
import { nativeGetOwnPropertyDescriptor } from "./natives";
99
import {
1010
BareClient,
11-
type BareClient as BareClientType,
12-
} from "@mercuryworkshop/bare-mux";
11+
CookieStore,
12+
config,
13+
unrewriteUrl,
14+
rewriteUrl,
15+
} from "../shared";
16+
import type { BareClient as BareClientType } from "@mercuryworkshop/bare-mux";
1317
import { createWrapFn } from "./shared/wrap";
1418
import { NavigateEvent } from "./events";
15-
import {
16-
rewriteUrl,
17-
unrewriteUrl,
18-
type URLMeta,
19-
} from "../shared/rewriters/url";
19+
import type { URLMeta } from "../shared/rewriters/url";
2020
import { SourceMaps } from "./shared/sourcemaps";
21-
import { config } from "../shared";
22-
import { CookieStore } from "../shared/cookie";
2321

2422
type NativeStore = {
2523
store: Record<string, any>;
@@ -367,14 +365,15 @@ export class ScramjetClient {
367365
}
368366

369367
hook() {
368+
// @ts-ignore
370369
const context = import.meta.webpackContext(".", {
371370
recursive: true,
372371
});
373372

374373
const modules: ScramjetModule[] = [];
375374

376375
for (const key of context.keys()) {
377-
const module = context(key) as ScramjetModule;
376+
const module: ScramjetModule = context(key);
378377
if (!key.endsWith(".ts")) continue;
379378
if (
380379
(key.startsWith("./dom/") && "window" in this.global) ||

src/client/document.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { rewriteUrl } from "../shared/rewriters/url";
1+
import { rewriteUrl } from "../shared";
22
import { ScramjetClient } from "./client";
33
import { getOwnPropertyDescriptorHandler } from "./helpers";
44

src/client/dom/beacon.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { rewriteUrl } from "../../shared/rewriters/url";
1+
import { rewriteUrl } from "../../shared";
22
import { ScramjetClient } from "../client";
33

44
export default function (client: ScramjetClient, _self: Self) {

0 commit comments

Comments
 (0)