Skip to content

Commit

Permalink
start typing modules imported from webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
Percslol committed Nov 11, 2024
1 parent addae16 commit 3025110
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default defineConfig({
showError: true,
},
],
["github"],
]
: "html",
timeout: 20000,
Expand Down
16 changes: 13 additions & 3 deletions src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ import type { URLMeta } from "../shared/rewriters/url";
//eslint-disable-next-line
export type AnyFunction = Function;

export type ScramjetModule = {
enabled: (client: ScramjetClient) => boolean | undefined;
disabled: (
client: ScramjetClient,
self: typeof globalThis
) => void | undefined;
order: number | undefined;
default: (client: ScramjetClient, self: typeof globalThis) => void;
};

export type ProxyCtx = {
fn: AnyFunction;
this: any;
Expand Down Expand Up @@ -77,7 +87,7 @@ export class ScramjetClient {
constructor(public global: typeof globalThis) {
if (SCRAMJETCLIENT in global) {
console.error(
"attempted to initialize a scramjet client, but one is already loaded - this is very bad"
"attempted to initialize a scramjet cl ient, but one is already loaded - this is very bad"
);
throw new Error();
}
Expand Down Expand Up @@ -171,10 +181,10 @@ export class ScramjetClient {
recursive: true,
});

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

for (const key of context.keys()) {
const module = context(key);
const module: ScramjetModule = context(key);
if (!key.endsWith(".ts")) continue;
if (
(key.startsWith("./dom/") && "window" in this.global) ||
Expand Down

0 comments on commit 3025110

Please sign in to comment.