Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quarto-dev
GitHub Repository: quarto-dev/quarto-cli
Path: blob/main/src/core/api/index.ts
6458 views
1
// src/core/api/index.ts
2
//
3
// Main entry point for QuartoAPI
4
// This module exports the global quartoAPI instance and all related types
5
6
import { globalRegistry } from "./registry.ts";
7
import type { QuartoAPI } from "./types.ts";
8
9
// Export all types for external use
10
export type {
11
ConsoleNamespace,
12
CryptoNamespace,
13
FormatNamespace,
14
JupyterNamespace,
15
MappedStringNamespace,
16
MarkdownRegexNamespace,
17
PathNamespace,
18
QuartoAPI,
19
SystemNamespace,
20
TextNamespace,
21
} from "./types.ts";
22
23
// Export registry utilities (mainly for testing)
24
export {
25
globalRegistry,
26
QuartoAPIRegistry,
27
RegistryFinalizedError,
28
UnregisteredNamespaceError,
29
} from "./registry.ts";
30
31
/**
32
* The global QuartoAPI instance (cached after first call)
33
*/
34
let _quartoAPI: QuartoAPI | null = null;
35
36
/**
37
* Get the global QuartoAPI instance
38
*
39
* This function returns the QuartoAPI instance, creating it on first call.
40
* The register.ts module (imported in src/quarto.ts) ensures all
41
* namespaces are registered before any code accesses the API.
42
*
43
* @returns {QuartoAPI} The complete API object with all namespaces
44
*/
45
export function getQuartoAPI(): QuartoAPI {
46
if (_quartoAPI === null) {
47
_quartoAPI = globalRegistry.createAPI();
48
}
49
return _quartoAPI;
50
}
51
52