mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 14:30:02 -04:00
start typing modules imported from webpack
This commit is contained in:
parent
addae1621d
commit
3025110378
2 changed files with 14 additions and 3 deletions
|
@ -19,6 +19,7 @@ export default defineConfig({
|
|||
showError: true,
|
||||
},
|
||||
],
|
||||
["github"],
|
||||
]
|
||||
: "html",
|
||||
timeout: 20000,
|
||||
|
|
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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) ||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue