-
Notifications
You must be signed in to change notification settings - Fork 347
/
Copy pathtypes.ts
240 lines (208 loc) · 5.91 KB
/
types.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
/*
* types.ts
*
* Copyright (C) 2020-2022 Posit Software, PBC
*/
import { RenderServices } from "../command/render/types.ts";
import { Metadata, PandocFlags } from "../config/types.ts";
import { Format, FormatExtras } from "../config/types.ts";
import { MappedString } from "../core/mapped-text.ts";
import { PartitionedMarkdown } from "../core/pandoc/types.ts";
import { ExecutionEngine, ExecutionTarget } from "../execute/types.ts";
import { NotebookContext } from "../render/notebook/notebook-types.ts";
import {
NavigationItem as NavItem,
NavigationItemObject,
NavigationItemObject as SidebarTool,
ProjectConfig as ProjectConfig_Project,
} from "../resources/types/schema-types.ts";
import { ProjectEnvironment } from "./project-environment-types.ts";
export {
type NavigationItem as NavItem,
type NavigationItemObject,
type NavigationItemObject as SidebarTool,
type PageFooter as NavigationFooter,
type ProjectPreview,
} from "../resources/types/schema-types.ts";
export const kProjectType = "type";
export const kProjectTitle = "title";
export const kProjectRender = "render";
export const kProjectPreRender = "pre-render";
export const kProjectPostRender = "post-render";
export const kProjectExecuteDir = "execute-dir";
export const kProjectOutputDir = "output-dir";
export const kProjectLibDir = "lib-dir";
export const kProjectResources = "resources";
export const kProjectWatchInputs = "watch-inputs";
export type FileInclusion = {
source: string;
target: string;
};
export type FileInformation = {
fullMarkdown?: MappedString;
includeMap?: FileInclusion[];
};
export interface ProjectContext {
dir: string;
engines: string[];
files: ProjectFiles;
config?: ProjectConfig;
notebookContext: NotebookContext;
outputNameIndex?: Map<string, { file: string; format: Format } | undefined>;
// This is a cache of the engine and target for a given filename
engineAndTargetCache?: Map<
string,
{ engine: ExecutionEngine; target: ExecutionTarget }
>;
fileInformationCache: Map<string, FileInformation>;
// expands markdown for a file
// input file doesn't have to be markdown; it can be, for example, a knitr spin file
// output file is always markdown, though, and it is cached in the project
resolveFullMarkdownForFile: (
engine: ExecutionEngine | undefined,
file: string,
markdown?: MappedString,
force?: boolean,
) => Promise<MappedString>;
fileExecutionEngineAndTarget: (
file: string,
force?: boolean,
) => Promise<{ engine: ExecutionEngine; target: ExecutionTarget }>;
formatExtras?: (
source: string,
flags: PandocFlags,
format: Format,
services: RenderServices,
) => Promise<FormatExtras>;
// declaring renderFormats here is a relatively ugly hack to avoid a circular import chain
// that causes a deno bundler bug
renderFormats: (
file: string,
services: RenderServices,
to: string | undefined,
project: ProjectContext,
) => Promise<Record<string, Format>>;
environment: () => Promise<ProjectEnvironment>;
isSingleFile: boolean;
}
export interface ProjectFiles {
input: string[];
resources?: string[];
config?: string[];
configResources?: string[];
}
export interface ProjectConfig {
project: ProjectConfig_Project;
[key: string]: unknown;
}
export const kProject404File = "404.html";
export type LayoutBreak = "" | "sm" | "md" | "lg" | "xl" | "xxl";
export const kAriaLabel = "aria-label";
export const kCollapseLevel = "collapse-level";
export const kCollapseBelow = "collapse-below";
export const kToolsCollapse = "tools-collapse";
export const kLogoAlt = "logo-alt";
export const kLogoHref = "logo-href";
export const kSidebarMenus = "sidebar-menus";
export interface Navbar {
title?: string | false;
logo?: string;
[kLogoAlt]?: string;
[kLogoHref]?: string;
background:
| "primary"
| "secondary"
| "success"
| "danger"
| "warning"
| "info"
| "light"
| "dark";
search?: boolean | string;
left?: NavItem[];
right?: NavItem[];
collapse?: boolean;
tools?: SidebarTool[];
pinned?: boolean;
[kCollapseBelow]?: LayoutBreak;
[kSidebarMenus]?: boolean;
darkToggle?: boolean;
readerToggle?: boolean;
[kToolsCollapse]?: boolean;
}
/* export interface NavItem {
// href + more readable/understndable aliases
icon?: string;
href?: string;
file?: string;
text?: string;
url?: string;
[kAriaLabel]?: string;
// core identification
id?: string;
// more
menu?: NavItem[];
}
*/
export interface Sidebar {
id?: string;
title?: string;
subtitle?: string;
logo?: string;
[kLogoAlt]?: string;
[kLogoHref]?: string;
alignment?: "left" | "right" | "center";
align?: "left" | "right" | "center"; // This is here only because older versions of Quarto used to use it even though it wasn't documented
background?:
| "none"
| "primary"
| "secondary"
| "success"
| "danger"
| "warning"
| "info"
| "light"
| "dark"
| "white";
search?: boolean | string;
[kCollapseLevel]?: number;
contents: SidebarItem[];
tools: SidebarTool[];
style: "docked" | "floating";
pinned?: boolean;
header?: Array<string> | string;
footer?: Array<string> | string;
}
export type SidebarItem = NavigationItemObject & {
// core structure/contents
section?: string;
sectionId?: string;
contents?: SidebarItem[];
// more
expanded?: boolean;
active?: boolean;
// transient properties used for expanding 'auto'
auto?: boolean | string | string[];
};
export interface InputTargetIndex extends Metadata {
title?: string;
markdown: PartitionedMarkdown;
formats: Record<string, Format>;
draft?: boolean;
}
export interface InputTarget {
input: string;
title?: string;
outputHref: string;
draft: boolean;
}
/*export interface SidebarTool {
// label/contents
icon?: string;
text?: string;
menu?: NavItem[];
// href + more readable/understndable aliases
href?: string;
file?: string;
url?: string;
}*/