This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
deps.ts
70 lines (60 loc) · 1.84 KB
/
deps.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import * as path from "https://deno.land/std/path/mod.ts";
import { expandGlobSync, existsSync } from "https://deno.land/std/fs/mod.ts";
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
import {
setup as setupOceanwind,
getStyleTag,
VirtualInjector,
themed,
} from "https://unpkg.com/@bebraw/[email protected]";
import { Application } from "https://deno.land/x/[email protected]/mod.ts";
import * as elements from "./lib/elements.ts";
import parseCode from "./ast/parse-code.ts";
import parseProps from "./ast/parse-props.ts";
import queryNodes from "./ast/query-nodes.ts";
import getComponents from "./utils/get-components.ts";
import processMarkdown from "./utils/process-markdown.ts";
import type { AstNode } from "./types.ts";
import { createRemote } from "./lib/gentleRpc/rpcClient.ts";
import userTheme from "./user-theme.ts";
import Prism from "./lib/prism/mod.ts";
const remote = createRemote("http://0.0.0.0:4000");
const joinPath = path.posix.join;
const getDirectory = path.posix.dirname;
const getRelativePath = path.posix.relative;
const printAst = async (ast: AstNode): Promise<string> =>
// @ts-ignore
remote.print(ast);
const parseSource = async (source: string): Promise<AstNode> =>
// @ts-ignore
remote.parse(source);
const getStyleInjector = () => {
const injector = VirtualInjector();
setupOceanwind({ injector });
return injector;
};
const ow = themed(userTheme);
// TODO: Check that given language exists
const highlight = (str: string, language: string) =>
Prism.highlight(str, Prism.languages[language], language);
export {
ow,
highlight,
assertEquals,
expandGlobSync,
elements,
joinPath,
existsSync,
getComponents,
getDirectory,
getRelativePath,
parseCode,
parseProps,
parseSource,
printAst,
processMarkdown,
queryNodes,
getStyleInjector,
getStyleTag,
Application,
};