Skip to content

Commit

Permalink
adding plugins to debug
Browse files Browse the repository at this point in the history
  • Loading branch information
mimiMonads committed Jun 21, 2024
1 parent 131c24d commit 24b1fd8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/exportable/display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { isUsing as query } from "../components/queries/mainQueries.ts";
import { isUsing as cookie } from "../components/cookies/mainCookies.ts";
import { isUsing as token } from "../components/cookieToToken/mainCookieToToken.ts";
import type { Petition } from "../morphism.ts";
import type { FunRouterOptions } from "../options.ts";
import type {
CyclePlugin,
CyclePluginMap,
FunRouterOptions,
} from "../options.ts";

type Display = {
using?: string[];
Expand Down Expand Up @@ -34,6 +38,7 @@ export const displayPaths = (p: Petition): void => (
)
);

type PluginType = [string, CyclePlugin<any>];
export const display =
(options?: FunRouterOptions<any>) =>
(p: Petition) =>
Expand All @@ -58,5 +63,24 @@ export const display =
: acc + "",
"--- Components ---\n",
),
),
console.log(
Object.keys(options?.cyclePlugin)
.map((name) =>
(object.using ?? []).includes(name) &&
"isUsing" in options!.cyclePlugin[name]
? [name, options!.cyclePlugin[name]] as PluginType
: false
)
.filter((item): item is PluginType => Boolean(item))
.filter((x) => void console.log(x) ?? x)
.reduce(
(acc, tulip): string =>
acc +
`\x1b[35m${tulip[0]}\x1b[0m: \x1b[38;2;255;165;0m${
//@ts-ignore
tulip[1].isUsing(options)(p)}\x1b[0m \n`,
"--- Plugins ---\n",
),
)
);
1 change: 1 addition & 0 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export type CyclePlugin<
p: Petition,
) => (r: Request | [Request, Record<string, unknown>]) => any;
readonly type: unknown;
readonly isUsing?: (o?: FunRouterOptions<any>) => (p: Petition) => string;
readonly options?: { [k: string]: any };
};

Expand Down
1 change: 1 addition & 0 deletions test/exportable/wrap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const pluginMethod = plugins.type({
name: Symbol.for("method"),
type: {} as string,
f: () => () => () => " inCycle",
isUsing: () => () => "sup",
});

const opt = plugins.globalOptions({
Expand Down

0 comments on commit 24b1fd8

Please sign in to comment.