From 5d4e80d386c46b4cb21b5a41671c5b41df46bde1 Mon Sep 17 00:00:00 2001 From: Delusoire Date: Thu, 29 Aug 2024 17:14:08 +0100 Subject: [PATCH] y --- deno.json | 1 + modules/palette-manager/index.ts | 2 +- modules/stdlib/index.ts | 10 ++++++++-- modules/stdlib/src/logger.ts | 6 +++--- modules/stdlib/src/storage.ts | 7 ++++--- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/deno.json b/deno.json index 3d1a611..bb62020 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,7 @@ { "compilerOptions": { "experimentalDecorators": true, + "noImplicitOverride": true, "lib": [ "DOM", "DOM.Iterable", diff --git a/modules/palette-manager/index.ts b/modules/palette-manager/index.ts index dafea24..f350346 100644 --- a/modules/palette-manager/index.ts +++ b/modules/palette-manager/index.ts @@ -1,7 +1,7 @@ import type { ModuleInstance } from "/hooks/index.ts"; export async function preload(mod: ModuleInstance) { - return (await import("./palette.ts")).default(mod); + return await (await import("./palette.ts")).default(mod); } export async function load(mod: ModuleInstance) { diff --git a/modules/stdlib/index.ts b/modules/stdlib/index.ts index 3c735a8..1e38313 100644 --- a/modules/stdlib/index.ts +++ b/modules/stdlib/index.ts @@ -1,3 +1,9 @@ -export { default as mixin } from "./mix.ts"; +import type { ModuleInstance, Transformer } from "/hooks/index.ts"; -export { default as load } from "./mod.ts"; +export async function mixin(transformer: Transformer) { + return await (await import("./mix.ts")).default(transformer); +} + +export async function load(mod: ModuleInstance) { + return await (await import("./mod.ts")).default(mod); +} diff --git a/modules/stdlib/src/logger.ts b/modules/stdlib/src/logger.ts index e71e0ee..4bd2d0e 100644 --- a/modules/stdlib/src/logger.ts +++ b/modules/stdlib/src/logger.ts @@ -10,11 +10,11 @@ export const createLogger = (mod: ModuleInstance) => { return new Proxy(globalThis.console, { get(target, p, receiver) { - const func = Reflect.get(target, p, receiver); + const func: unknown = Reflect.get(target, p, receiver); - if (typeof p === "string" && hookedMethods.has(p)) { + if (typeof p === "string" && hookedMethods.has(p) && typeof func === "function") { // @ts-ignore - return (...data: any[]) => func(`[${mod.getModuleIdentifier()}]:`, ...data); + return (...data: any[]) => func.call(target, `[${mod.getModuleIdentifier()}]:`, ...data); } return func; diff --git a/modules/stdlib/src/storage.ts b/modules/stdlib/src/storage.ts index 7d1f8a8..18e1c74 100644 --- a/modules/stdlib/src/storage.ts +++ b/modules/stdlib/src/storage.ts @@ -13,10 +13,11 @@ export const createStorage = (mod: ModuleInstance) => { return new Proxy(globalThis.localStorage, { get(target, p, receiver) { - const func = Reflect.get(target, p, receiver); + const func: unknown = Reflect.get(target, p, receiver); - if (typeof p === "string" && hookedNativeStorageMethods.has(p)) { - return (key: string, ...data: any[]) => func(`module:${mod.getModuleIdentifier()}:${key}`, ...data); + if (typeof p === "string" && hookedNativeStorageMethods.has(p) && typeof func === "function") { + return (key: string, ...data: any[]) => + func.call(target, `module:${mod.getModuleIdentifier()}:${key}`, ...data); } return func;