Skip to content

Commit

Permalink
Fix JSR requirements
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos Candeia <[email protected]>
  • Loading branch information
mcandeia committed Aug 7, 2024
1 parent f850c57 commit 0ce7ae3
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 16 deletions.
5 changes: 4 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@
},
"name": "@deco/inspect-vscode",
"version": "0.2.1",
"exports": "./mod.ts"
"exports": "./mod.ts",
"imports": {
"@std/path": "jsr:@std/path@^1.0.2"
}
}
26 changes: 26 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { search } from "./search.ts";
export default async function inspectHandler(
inspectPath = "/_live/inspect/",
req: Request,
) {
): Promise<Response> {
const outerHTML = await req.text();
const url = new URL(req.url);
const manifestKey = "./" + url.pathname.replace(inspectPath, "");
Expand All @@ -18,6 +18,10 @@ export default async function inspectHandler(
});
}

function vsCodeLinkFromResult(file: string, line: number, column: number) {
function vsCodeLinkFromResult(
file: string,
line: number,
column: number,
): string {
return `vscode://file/${file}:${line}:${column}`;
}
22 changes: 11 additions & 11 deletions inspector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default class DomInspector {
);
}

activate = (onDeactivate?: () => void) => {
activate = (onDeactivate?: () => void): void => {
this.addEventListeners();
this.active = true;
this.onDeactivate = onDeactivate;
Expand All @@ -60,7 +60,7 @@ export default class DomInspector {
);
};

deactivate = () => {
deactivate = (): void => {
console.log(
`InspectVSCode deactivated. Press ${this.options.activator.label} to activate again.`,
);
Expand All @@ -83,12 +83,12 @@ export default class DomInspector {
}
};

isActive = () => this.active;
isActive = (): boolean => this.active;

/**
* Add event listeners for DOM-inspectorey actions
*/
addEventListeners = () => {
addEventListeners = (): void => {
const { element } = this;

element.addEventListener("mouseover", this.handleMouseOver, true);
Expand All @@ -97,13 +97,13 @@ export default class DomInspector {
element.addEventListener("keydown", this.handleCancelKey, true);
};

handleKeydown = (event: KeyboardEvent) => {
handleKeydown = (event: KeyboardEvent): void => {
if (this.options.activator.matchEvent(event) && !this.active) {
this.activate();
}
};

handleMouseOver = (event: MouseEvent) => {
handleMouseOver = (event: MouseEvent): void => {
const targetElement = event.target as HTMLElement;
if (
!targetElement || targetElement === document.body ||
Expand All @@ -118,12 +118,12 @@ export default class DomInspector {
this.hoveredElement = targetElement;
};

handleMouseOut = (event: MouseEvent) => {
handleMouseOut = (event: MouseEvent): void => {
const targetElement = event.target as HTMLElement;
this.clean(targetElement);
};

handleClick = async (event: MouseEvent) => {
handleClick = async (event: MouseEvent): Promise<void> => {
event.preventDefault();
const targetElement = event.target as HTMLElement;

Expand Down Expand Up @@ -158,7 +158,7 @@ export default class DomInspector {
this.deactivate();
};

handleCancelKey = (event: KeyboardEvent) => {
handleCancelKey = (event: KeyboardEvent): void => {
if (event.key !== "Escape" || event.defaultPrevented) {
return;
}
Expand All @@ -180,13 +180,13 @@ export default class DomInspector {
return null;
};

paint = (element: HTMLElement) => {
paint = (element: HTMLElement): void => {
element.style.outline = this.options.outline;
element.style.backgroundColor = this.options.backgroundColor;
element.style.backgroundBlendMode = this.options.backgroundBlendMode;
};

clean = (element: HTMLElement) => {
clean = (element: HTMLElement): void => {
element.style.outline = "";
element.style.backgroundColor = "";
element.style.backgroundBlendMode = "";
Expand Down
4 changes: 2 additions & 2 deletions search.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { join } from "https://deno.land/[email protected]/path/mod.ts";
import Fuse from "https://deno.land/x/fuse@v6.4.1/dist/fuse.esm.min.js";
import { join } from "@std/path";
import Fuse from "npm:fuse[email protected]";

export async function search(content: string, manifestKey: string) {
const escaped = content.replace(/>.*/, ">");
Expand Down

0 comments on commit 0ce7ae3

Please sign in to comment.