mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 06:20: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,
|
showError: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
["github"],
|
||||||
]
|
]
|
||||||
: "html",
|
: "html",
|
||||||
timeout: 20000,
|
timeout: 20000,
|
||||||
|
|
|
@ -21,6 +21,16 @@ import type { URLMeta } from "../shared/rewriters/url";
|
||||||
//eslint-disable-next-line
|
//eslint-disable-next-line
|
||||||
export type AnyFunction = Function;
|
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 = {
|
export type ProxyCtx = {
|
||||||
fn: AnyFunction;
|
fn: AnyFunction;
|
||||||
this: any;
|
this: any;
|
||||||
|
@ -77,7 +87,7 @@ export class ScramjetClient {
|
||||||
constructor(public global: typeof globalThis) {
|
constructor(public global: typeof globalThis) {
|
||||||
if (SCRAMJETCLIENT in global) {
|
if (SCRAMJETCLIENT in global) {
|
||||||
console.error(
|
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();
|
throw new Error();
|
||||||
}
|
}
|
||||||
|
@ -171,10 +181,10 @@ export class ScramjetClient {
|
||||||
recursive: true,
|
recursive: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const modules = [];
|
const modules: ScramjetModule[] = [];
|
||||||
|
|
||||||
for (const key of context.keys()) {
|
for (const key of context.keys()) {
|
||||||
const module = context(key);
|
const module: ScramjetModule = context(key);
|
||||||
if (!key.endsWith(".ts")) continue;
|
if (!key.endsWith(".ts")) continue;
|
||||||
if (
|
if (
|
||||||
(key.startsWith("./dom/") && "window" in this.global) ||
|
(key.startsWith("./dom/") && "window" in this.global) ||
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue