Skip to content

Commit

Permalink
y
Browse files Browse the repository at this point in the history
  • Loading branch information
Delusoire committed Aug 29, 2024
1 parent 0d62553 commit 5d4e80d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
1 change: 1 addition & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"noImplicitOverride": true,
"lib": [
"DOM",
"DOM.Iterable",
Expand Down
2 changes: 1 addition & 1 deletion modules/palette-manager/index.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
10 changes: 8 additions & 2 deletions modules/stdlib/index.ts
Original file line number Diff line number Diff line change
@@ -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);
}
6 changes: 3 additions & 3 deletions modules/stdlib/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions modules/stdlib/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5d4e80d

Please sign in to comment.