Skip to content

Commit

Permalink
kwik progress
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanThatOneKid committed Dec 26, 2021
1 parent c277f89 commit fa81791
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
13 changes: 6 additions & 7 deletions lib/transpile/cartridge/cartridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ export type CartridgeEventReturnType = (
// TODO: Refactor PropertyDefinition interface to be more strict using the
// list of possible definitions as a guide.
// Possible Property Definitions
// - example: string
// - example: string; data = { id: "example", optional: false, value: "string" }
// - example?: string
// - example: { nestedExample: string }
// - example: { abc?: string }; data = { id: "example", optional: false, value: { id: "abc", optional: true, value: "string" } }
// - example: async % string; Promise<string>
// - example: fn % async % string; () => Promise<string>
// - example: fn % (a: string, async % string); (a: string) => Promise<string>
// - example: fn % (cb: fn % (async % _), number); (cb: () => Promise<void>) => number
// ; data = { id: "example", value: { mods: [{ name: "fn" }] } }

export interface PropertyDefinition {
optional?: boolean;
Expand Down Expand Up @@ -181,11 +182,9 @@ export class Cartridge {
): Promise<string | null> {
const handleEvent = this.handlers[name] as CartridgeHandler<T>;
if (handleEvent === undefined) return null;
const executionResult = handleEvent(ctx);
if (executionResult instanceof Promise) {
return (await executionResult) ?? null;
}
return executionResult ?? null;
const result = await handleEvent(ctx);
if (typeof result === "string") return result;
return null;
}

public getType(type?: string): string | undefined {
Expand Down
2 changes: 1 addition & 1 deletion lib/transpile/tokenize/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class Token {
switch (this.kind) {
case Lexicon.TextLiteral: {
// strips expected text markers from beginning and end of input string
return this.raw.slice(1, this.value.length - 1);
return this.raw.slice(1, this.raw.length - 1);
}
case Lexicon.InlineComment: {
return this.raw.slice(1).trim();
Expand Down
7 changes: 1 addition & 6 deletions lib/transpile/transpile.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { Lexicon, Token, tokenize } from "./tokenize/mod.ts";
import { Cartridge, CartridgeEvent } from "./cartridge/mod.ts";
import type {
ModHandler,
Modifier,
PropertyDefinition,
} from "./cartridge/mod.ts";
import type { ModHandler, PropertyDefinition } from "./cartridge/mod.ts";
import { TextBuilder } from "./text_builder/mod.ts";
// import { Lang } from "../constants/lang.ts";
import { assertKind } from "./utils.ts";
import type { FartTokenGenerator } from "./tokenize/mod.ts";

Expand Down

1 comment on commit fa81791

@deno-deploy
Copy link

@deno-deploy deno-deploy bot commented on fa81791 Dec 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failed to deploy:

failed to fetch 'https://raw.githubusercontent.com/EthanThatOneKid/fart/fa81791b20cd0c6e1fbb005590988e11da5b9e73/fart_server/handle_request.ts': HTTP status client error (404 Not Found) for url (https://raw.githubusercontent.com/EthanThatOneKid/fart/fa81791b20cd0c6e1fbb005590988e11da5b9e73/fart_server/handle_request.ts)

Please sign in to comment.