Skip to content

Commit

Permalink
Prepare to jsr
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Jun 14, 2024
1 parent e7a6696 commit 8c53570
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 31 deletions.
2 changes: 1 addition & 1 deletion deps.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export * as path from "jsr:@std/[email protected]";
export * as html from "jsr:@std/[email protected]";

export * as astring from "https://deno.land/x/astring@v1.8.6/src/astring.js";
export * as astring from "jsr:@davidbonnet/astring@1.8.6";
export * as meriyah from "npm:[email protected]";
export * as walker from "npm:[email protected]";
export type * as ESTree from "npm:@types/[email protected]";
2 changes: 1 addition & 1 deletion mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface Options {
autoescape?: boolean;
}

export default function (options: Options = {}) {
export default function (options: Options = {}): Environment {
const loader = typeof options.includes === "object"
? options.includes
: new FileLoader(options.includes || Deno.cwd());
Expand Down
6 changes: 4 additions & 2 deletions plugins/auto_trim.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Token } from "../src/tokenizer.ts";
import type { Environment } from "../src/environment.ts";
import type { Environment, Plugin } from "../src/environment.ts";

export const defaultTags = [
">",
Expand All @@ -21,7 +21,9 @@ export const defaultTags = [

export type AutoTrimOptions = { tags: string[] };

export default function (options: AutoTrimOptions = { tags: defaultTags }) {
export default function (
options: AutoTrimOptions = { tags: defaultTags },
): Plugin {
return (env: Environment) => {
env.tokenPreprocessors.push((_, tokens) => autoTrim(tokens, options));
};
Expand Down
4 changes: 2 additions & 2 deletions plugins/echo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Token } from "../src/tokenizer.ts";
import type { Environment } from "../src/environment.ts";
import type { Environment, Plugin } from "../src/environment.ts";

export default function () {
export default function (): Plugin {
return (env: Environment) => {
env.tags.push(setTag);
};
Expand Down
4 changes: 2 additions & 2 deletions plugins/escape.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { html } from "../deps.ts";
import type { Environment } from "../src/environment.ts";
import type { Environment, Plugin } from "../src/environment.ts";

export default function () {
export default function (): Plugin {
return (env: Environment) => {
// deno-lint-ignore no-explicit-any
env.filters.escape = (value: any) =>
Expand Down
4 changes: 2 additions & 2 deletions plugins/export.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Token } from "../src/tokenizer.ts";
import type { Environment } from "../src/environment.ts";
import type { Environment, Plugin } from "../src/environment.ts";

export default function () {
export default function (): Plugin {
return (env: Environment) => {
env.tags.push(exportTag);
};
Expand Down
4 changes: 2 additions & 2 deletions plugins/for.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Token } from "../src/tokenizer.ts";
import type { Environment } from "../src/environment.ts";
import type { Environment, Plugin } from "../src/environment.ts";

export default function () {
export default function (): Plugin {
return (env: Environment) => {
env.tags.push(forTag);
env.utils.toIterator = toIterator;
Expand Down
4 changes: 2 additions & 2 deletions plugins/function.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Token } from "../src/tokenizer.ts";
import type { Environment } from "../src/environment.ts";
import type { Environment, Plugin } from "../src/environment.ts";

export default function () {
export default function (): Plugin {
return (env: Environment) => {
env.tags.push(functionTag);
};
Expand Down
4 changes: 2 additions & 2 deletions plugins/if.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Token } from "../src/tokenizer.ts";
import type { Environment } from "../src/environment.ts";
import type { Environment, Plugin } from "../src/environment.ts";

export default function () {
export default function (): Plugin {
return (env: Environment) => {
env.tags.push(ifTag);
env.tags.push(elseTag);
Expand Down
4 changes: 2 additions & 2 deletions plugins/import.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Environment } from "../src/environment.ts";
import type { Environment, Plugin } from "../src/environment.ts";

export default function () {
export default function (): Plugin {
return (env: Environment) => {
env.tags.push(importTag);
};
Expand Down
4 changes: 2 additions & 2 deletions plugins/include.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import analyze from "../src/js.ts";
import type { Token } from "../src/tokenizer.ts";
import type { Environment } from "../src/environment.ts";
import type { Environment, Plugin } from "../src/environment.ts";

export default function () {
export default function (): Plugin {
return (env: Environment) => {
env.tags.push(includeTag);
};
Expand Down
4 changes: 2 additions & 2 deletions plugins/js.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Environment } from "../src/environment.ts";
import type { Environment, Plugin } from "../src/environment.ts";

export default function () {
export default function (): Plugin {
return (env: Environment) => {
env.tags.push(jsTag);
};
Expand Down
4 changes: 2 additions & 2 deletions plugins/layout.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Token } from "../src/tokenizer.ts";
import type { Environment } from "../src/environment.ts";
import type { Environment, Plugin } from "../src/environment.ts";

export default function () {
export default function (): Plugin {
return (env: Environment) => {
env.tags.push(layoutTag);
};
Expand Down
4 changes: 2 additions & 2 deletions plugins/set.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Token } from "../src/tokenizer.ts";
import type { Environment } from "../src/environment.ts";
import type { Environment, Plugin } from "../src/environment.ts";

export default function () {
export default function (): Plugin {
return (env: Environment) => {
env.tags.push(setTag);
};
Expand Down
4 changes: 2 additions & 2 deletions plugins/trim.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Token } from "../src/tokenizer.ts";
import type { Environment } from "../src/environment.ts";
import type { Environment, Plugin } from "../src/environment.ts";

export default function () {
export default function (): Plugin {
return (env: Environment) => {
env.tokenPreprocessors.push(trim);
};
Expand Down
4 changes: 2 additions & 2 deletions plugins/unescape.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { html } from "../deps.ts";
import type { Environment } from "../src/environment.ts";
import type { Environment, Plugin } from "../src/environment.ts";

export default function () {
export default function (): Plugin {
return (env: Environment) => {
// deno-lint-ignore no-explicit-any
env.filters.unescape = (value: any) =>
Expand Down
2 changes: 1 addition & 1 deletion src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export interface Options {
}

export class Environment {
cache = new Map<string, Template>();
cache: Map<string, Template> = new Map();
options: Options;
tags: Tag[] = [];
tokenPreprocessors: TokenPreprocessor[] = [];
Expand Down

0 comments on commit 8c53570

Please sign in to comment.