Download client/simple/src/js/loader.ts from Openyx/xcdv: direct link, hf CLI and curl.
- Browser
- Download file 812 Bytes
-
https://huggingface.co/spaces/Openyx/xcdv/resolve/main/client/simple/src/js/loader.ts
- Command line
-
hf download hf://spaces/Openyx/xcdv/client/simple/src/js/loader.ts
-
curl -L -o loader.ts https://huggingface.co/spaces/Openyx/xcdv/resolve/main/client/simple/src/js/loader.ts
812 Bytes
| // SPDX-License-Identifier: AGPL-3.0-or-later | |
| import type { Plugin } from "./Plugin.ts"; | |
| import { type EndpointsKeys, endpoint } from "./toolkit.ts"; | |
| type Options = | |
| | { | |
| on: "global"; | |
| } | |
| | { | |
| on: "endpoint"; | |
| where: EndpointsKeys[]; | |
| }; | |
| export const load = <T extends Plugin>(instance: () => Promise<T>, options: Options): void => { | |
| if (!check(options)) return; | |
| void instance(); | |
| }; | |
| const check = (options: Options): boolean => { | |
| // biome-ignore lint/style/useDefaultSwitchClause: options is typed | |
| switch (options.on) { | |
| case "global": { | |
| return true; | |
| } | |
| case "endpoint": { | |
| if (!options.where.includes(endpoint)) { | |
| // not on the expected endpoint | |
| return false; | |
| } | |
| return true; | |
| } | |
| } | |
| }; | |