@b4moss/hyogen-md 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -2
- package/README_ja.md +23 -2
- package/dist/build/build.d.ts +2 -0
- package/dist/build/buildDependencyGraph.d.ts +22 -0
- package/dist/build/collectDependencies.d.ts +8 -0
- package/dist/build/collectEntryPaths.d.ts +10 -0
- package/dist/build/isUnderscorePartial.d.ts +4 -0
- package/dist/cli.js +5587 -0
- package/dist/client.js +1022 -895
- package/dist/component/ComponentRegistry.d.ts +11 -0
- package/dist/component/parsePropsContract.d.ts +10 -0
- package/dist/component/renderComponent.d.ts +17 -0
- package/dist/component/validateProps.d.ts +7 -0
- package/dist/config/defineConfig.d.ts +5 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.js +143 -0
- package/dist/config/loadConfig.d.ts +13 -0
- package/dist/config/types.d.ts +26 -0
- package/dist/context/mergeContext.d.ts +3 -0
- package/dist/control/StructureNestTracker.d.ts +14 -0
- package/dist/control/expandControlStructures.d.ts +3 -0
- package/dist/control/parseControlOpener.d.ts +2 -0
- package/dist/control/parseControlStructures.d.ts +2 -0
- package/dist/createError-WZmAl05N.js +30 -0
- package/dist/errors/createError.d.ts +7 -0
- package/dist/errors/formatDiagnosticLog.d.ts +6 -0
- package/dist/errors/formatMessage.d.ts +3 -0
- package/dist/expr/evaluateExpression.d.ts +4 -0
- package/dist/expr/interpolateExpressions.d.ts +4 -0
- package/dist/expr/parseExpression.d.ts +4 -0
- package/dist/frontmatter/parseFrontMatter.d.ts +3 -0
- package/dist/include/VisitStack.d.ts +13 -0
- package/dist/include/expandIncludes.d.ts +18 -0
- package/dist/index.d.ts +11 -113
- package/dist/index.js +753 -625
- package/dist/io/createFsLoader.d.ts +6 -0
- package/dist/io/createNodeLoader.d.ts +4 -0
- package/dist/io/isRemotePath.d.ts +2 -0
- package/dist/io/loadDataSources.d.ts +8 -0
- package/dist/io/parseCsvFromString.d.ts +1 -0
- package/dist/io/parseDataFile.d.ts +1 -0
- package/dist/io/resolveIncludePath.d.ts +1 -0
- package/dist/layout/expandExtendsAndBlocks.d.ts +19 -0
- package/dist/layout/parseBlockOpener.d.ts +8 -0
- package/dist/layout/parseBlockStructures.d.ts +15 -0
- package/dist/layout/parseExtendBlock.d.ts +12 -0
- package/dist/layout/parseExtendDirective.d.ts +5 -0
- package/dist/logic/executeDeclaration.d.ts +6 -0
- package/dist/logic/executeDeclarations.d.ts +6 -0
- package/dist/logic/executeStatement.d.ts +10 -0
- package/dist/logic/hgBlockUtils.d.ts +3 -0
- package/dist/logic/parseDeclaration.d.ts +5 -0
- package/dist/logic/parseStatement.d.ts +3 -0
- package/dist/logic/reservedWords.d.ts +2 -0
- package/dist/logic/stripComments.d.ts +2 -0
- package/dist/markdown/shiftHeadings.d.ts +25 -0
- package/dist/parse/hgMarkers.d.ts +5 -0
- package/dist/parse/parseComponentDirective.d.ts +6 -0
- package/dist/parse/parseIncludeDirective.d.ts +2 -0
- package/dist/parse/scanHgBlocks.d.ts +10 -0
- package/dist/paths/assertWithinRootDir.d.ts +2 -0
- package/dist/paths/findDocRoot.d.ts +1 -0
- package/dist/paths/resolveRenderInput.d.ts +11 -0
- package/dist/paths/resolveTemplatePath.d.ts +9 -0
- package/dist/pipeline/applyFrontMatterOutputOption.d.ts +4 -0
- package/dist/pipeline/executeHgBlocks.d.ts +9 -0
- package/dist/pipeline/joinRemovalSeam.d.ts +12 -0
- package/dist/pipeline/renderDocument.d.ts +22 -0
- package/dist/pipeline/stripHgComments.d.ts +7 -0
- package/dist/renderClient.d.ts +15 -0
- package/dist/renderServer.d.ts +4 -0
- package/dist/security/forbiddenKeys.d.ts +3 -0
- package/dist/security/scanSuspiciousContext.d.ts +6 -0
- package/dist/shims/fs-browser.d.ts +6 -0
- package/dist/shims/fs-promises-browser.d.ts +5 -0
- package/dist/toc/expandToc.d.ts +8 -0
- package/dist/toc/extractHeadings.d.ts +10 -0
- package/dist/toc/formatTocMarkdown.d.ts +7 -0
- package/dist/toc/githubHeadingSlug.d.ts +11 -0
- package/dist/toc/parseTocDirective.d.ts +10 -0
- package/dist/toc/plainifyHeadingText.d.ts +2 -0
- package/dist/types.d.ts +211 -0
- package/package.json +17 -4
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type ComponentRegistration = {
|
|
2
|
+
alias: string;
|
|
3
|
+
componentPath: string;
|
|
4
|
+
definedAt?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare class ComponentRegistry {
|
|
7
|
+
private readonly components;
|
|
8
|
+
register(entry: ComponentRegistration, contextKeys: string[], path?: string): void;
|
|
9
|
+
get(alias: string): ComponentRegistration | undefined;
|
|
10
|
+
has(alias: string): boolean;
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HyogenContext } from '../types.js';
|
|
2
|
+
export type PropType = "string" | "number" | "boolean" | "object" | "array";
|
|
3
|
+
export type PropContract = {
|
|
4
|
+
type?: PropType;
|
|
5
|
+
isRequired?: boolean;
|
|
6
|
+
default?: unknown;
|
|
7
|
+
};
|
|
8
|
+
export declare function parsePropsContract(fmContext: HyogenContext, path?: string): Record<string, PropContract>;
|
|
9
|
+
export declare function inferPropType(value: unknown): PropType | undefined;
|
|
10
|
+
export declare function matchesPropType(value: unknown, expected: PropType): boolean;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ComponentRegistry } from './ComponentRegistry.js';
|
|
2
|
+
import { HyogenContext, HyogenWarning, Loader } from '../types.js';
|
|
3
|
+
import { VisitStack } from '../include/VisitStack.js';
|
|
4
|
+
export type RenderComponentOptions = {
|
|
5
|
+
alias: string;
|
|
6
|
+
props: Record<string, unknown>;
|
|
7
|
+
parentContext: HyogenContext;
|
|
8
|
+
registry: ComponentRegistry;
|
|
9
|
+
loader: Loader;
|
|
10
|
+
rootDir?: string;
|
|
11
|
+
path?: string;
|
|
12
|
+
warnings: HyogenWarning[];
|
|
13
|
+
visitStack: VisitStack;
|
|
14
|
+
preserveHgComments?: boolean;
|
|
15
|
+
constrainToRoot?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare function renderComponent(options: RenderComponentOptions): Promise<string>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { HyogenWarning } from '../types.js';
|
|
2
|
+
import { PropContract } from './parsePropsContract.js';
|
|
3
|
+
export type ValidatePropsResult = {
|
|
4
|
+
values: Record<string, unknown>;
|
|
5
|
+
warnings: HyogenWarning[];
|
|
6
|
+
};
|
|
7
|
+
export declare function validateProps(callProps: Record<string, unknown>, contract: Record<string, PropContract>, componentAlias: string): ValidatePropsResult;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { access as s } from "node:fs/promises";
|
|
2
|
+
import i from "node:path";
|
|
3
|
+
import { pathToFileURL as g } from "node:url";
|
|
4
|
+
import { createJiti as h } from "jiti";
|
|
5
|
+
import { c as n } from "../createError-WZmAl05N.js";
|
|
6
|
+
function D(t) {
|
|
7
|
+
return t;
|
|
8
|
+
}
|
|
9
|
+
const l = [
|
|
10
|
+
"hyogen.config.ts",
|
|
11
|
+
"hyogen.config.mjs",
|
|
12
|
+
"hyogen.config.js",
|
|
13
|
+
"hyogen.config.cjs"
|
|
14
|
+
];
|
|
15
|
+
function f(t) {
|
|
16
|
+
return typeof t == "object" && t !== null && !Array.isArray(t);
|
|
17
|
+
}
|
|
18
|
+
function d(t) {
|
|
19
|
+
if (typeof t == "string") {
|
|
20
|
+
if (t.trim() === "")
|
|
21
|
+
throw n({
|
|
22
|
+
code: "parse_error",
|
|
23
|
+
path: "<config>",
|
|
24
|
+
details: {
|
|
25
|
+
path: "<config>",
|
|
26
|
+
message: "`input` must not be empty"
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (Array.isArray(t) && t.every((r) => typeof r == "string")) {
|
|
32
|
+
if (t.length === 0 || t.some((r) => r.trim() === ""))
|
|
33
|
+
throw n({
|
|
34
|
+
code: "parse_error",
|
|
35
|
+
path: "<config>",
|
|
36
|
+
details: {
|
|
37
|
+
path: "<config>",
|
|
38
|
+
message: "`input` array is invalid"
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
throw n({
|
|
44
|
+
code: "parse_error",
|
|
45
|
+
path: "<config>",
|
|
46
|
+
details: {
|
|
47
|
+
path: "<config>",
|
|
48
|
+
message: "`input` is required as a string or string[]"
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
async function m(t = {}) {
|
|
53
|
+
const r = i.resolve(t.cwd ?? process.cwd());
|
|
54
|
+
if (t.configFile) {
|
|
55
|
+
const o = i.isAbsolute(t.configFile) ? t.configFile : i.resolve(r, t.configFile);
|
|
56
|
+
try {
|
|
57
|
+
return await s(o), o;
|
|
58
|
+
} catch {
|
|
59
|
+
throw n({
|
|
60
|
+
code: "file_not_found",
|
|
61
|
+
path: o,
|
|
62
|
+
details: {
|
|
63
|
+
path: o,
|
|
64
|
+
from: r,
|
|
65
|
+
via: "config"
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
for (const o of l) {
|
|
71
|
+
const e = i.join(r, o);
|
|
72
|
+
try {
|
|
73
|
+
return await s(e), e;
|
|
74
|
+
} catch {
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
throw n({
|
|
78
|
+
code: "file_not_found",
|
|
79
|
+
path: r,
|
|
80
|
+
details: {
|
|
81
|
+
path: i.join(r, "hyogen.config.*"),
|
|
82
|
+
from: r,
|
|
83
|
+
via: "config"
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
async function y(t) {
|
|
88
|
+
const r = h(import.meta.url, {
|
|
89
|
+
interopDefault: !0
|
|
90
|
+
});
|
|
91
|
+
try {
|
|
92
|
+
return await r.import(t);
|
|
93
|
+
} catch (o) {
|
|
94
|
+
try {
|
|
95
|
+
return await import(g(t).href);
|
|
96
|
+
} catch {
|
|
97
|
+
const e = o instanceof Error ? o.message : String(o);
|
|
98
|
+
throw n({
|
|
99
|
+
code: "load_failed",
|
|
100
|
+
path: t,
|
|
101
|
+
details: { path: t, reason: e }
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function w(t) {
|
|
107
|
+
return f(t) && "default" in t ? t.default : t;
|
|
108
|
+
}
|
|
109
|
+
function c(t, r) {
|
|
110
|
+
if (t !== void 0)
|
|
111
|
+
return i.isAbsolute(t) ? t : i.resolve(r, t);
|
|
112
|
+
}
|
|
113
|
+
function _(t, r) {
|
|
114
|
+
return typeof t == "string" ? c(t, r) : t.map((o) => c(o, r));
|
|
115
|
+
}
|
|
116
|
+
async function F(t = {}) {
|
|
117
|
+
const r = await m(t), o = i.dirname(r), e = w(await y(r));
|
|
118
|
+
if (!f(e))
|
|
119
|
+
throw n({
|
|
120
|
+
code: "parse_error",
|
|
121
|
+
path: r,
|
|
122
|
+
details: {
|
|
123
|
+
path: r,
|
|
124
|
+
message: "config must default-export an object"
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
d(e.input);
|
|
128
|
+
const a = e, u = c(a.outDir ?? "./out", o), p = c(a.root, o);
|
|
129
|
+
return {
|
|
130
|
+
...a,
|
|
131
|
+
input: _(a.input, o),
|
|
132
|
+
outDir: u,
|
|
133
|
+
root: p,
|
|
134
|
+
configDir: o,
|
|
135
|
+
configPath: r
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
export {
|
|
139
|
+
D as defineConfig,
|
|
140
|
+
F as loadConfig,
|
|
141
|
+
m as resolveConfigPath
|
|
142
|
+
};
|
|
143
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ResolvedHyogenConfig } from './types.js';
|
|
2
|
+
export type LoadConfigOptions = {
|
|
3
|
+
/** Directory to search for config. Defaults to `process.cwd()`. */
|
|
4
|
+
cwd?: string;
|
|
5
|
+
/** Explicit config file path (absolute or cwd-relative). */
|
|
6
|
+
configFile?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function resolveConfigPath(options?: LoadConfigOptions): Promise<string>;
|
|
9
|
+
/**
|
|
10
|
+
* Load and normalize `hyogen.config.*`.
|
|
11
|
+
* Ensures `outDir` defaults to `./out` (resolved against the config directory).
|
|
12
|
+
*/
|
|
13
|
+
export declare function loadConfig(options?: LoadConfigOptions): Promise<ResolvedHyogenConfig>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DataSourcesMap, HyogenContext } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* User-facing config for `hyogen.config.(js|ts)`.
|
|
4
|
+
* Maps onto library `build()` / `renderServer()` options.
|
|
5
|
+
*/
|
|
6
|
+
export type HyogenConfig = {
|
|
7
|
+
/** Entry markdown path(s) or glob(s). Required. */
|
|
8
|
+
input: string | string[];
|
|
9
|
+
/** Build output directory. Defaults to `./out`. Unused by `dev`. */
|
|
10
|
+
outDir?: string;
|
|
11
|
+
context?: HyogenContext;
|
|
12
|
+
serverContext?: HyogenContext;
|
|
13
|
+
dataSources?: DataSourcesMap;
|
|
14
|
+
root?: string;
|
|
15
|
+
includeUnderscoreEntries?: boolean;
|
|
16
|
+
preserveFrontMatter?: boolean;
|
|
17
|
+
preserveHgComments?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export type ResolvedHyogenConfig = Omit<HyogenConfig, "outDir" | "input"> & {
|
|
20
|
+
input: string | string[];
|
|
21
|
+
outDir: string;
|
|
22
|
+
/** Absolute directory containing the config file. */
|
|
23
|
+
configDir: string;
|
|
24
|
+
/** Absolute path to the config file when loaded from disk. */
|
|
25
|
+
configPath?: string;
|
|
26
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const STRUCTURE_NEST_LIMIT = 20;
|
|
2
|
+
export type NestEnterResult = {
|
|
3
|
+
exceeded: false;
|
|
4
|
+
depth: number;
|
|
5
|
+
} | {
|
|
6
|
+
exceeded: true;
|
|
7
|
+
limit: number;
|
|
8
|
+
};
|
|
9
|
+
export declare class StructureNestTracker {
|
|
10
|
+
private depth;
|
|
11
|
+
get currentDepth(): number;
|
|
12
|
+
enter(): NestEnterResult;
|
|
13
|
+
exit(): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { EvaluateExpressionOptions } from '../types.js';
|
|
2
|
+
export declare function expandControlStructures(source: string, options: EvaluateExpressionOptions): Promise<string>;
|
|
3
|
+
export declare function expandControlStructuresOrThrow(source: string, options: EvaluateExpressionOptions): Promise<string>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const s = { file_not_found: "File not found: {path} (referenced from {from} via {via})", frontmatter_too_large: "Front matter exceeds size limit in {path} ({size} bytes, limit {limit})", duplicate_component_alias: 'Duplicate component alias "{alias}" in {path}', alias_collision: 'Component alias "{alias}" collides with an existing binding in {path}', forbidden_property_access: 'Forbidden property access "{property}" in {path}', parse_error: "Parse error in {path}: {message}", server_context_on_client: "serverContext is not allowed with renderClient", load_failed: "Failed to load {path}: {reason}", data_sources_on_client: "dataSources is not allowed with renderClient", data_source_too_large: "Data source exceeds size limit in {path} ({size} bytes, limit {limit})" }, c = { circular_include: "Circular reference detected; skipped {path} (referenced from {from} via {via})", nest_limit_exceeded: "Nesting limit exceeded ({limit}); skipped block in {path}", extend_in_component: "extend is not allowed inside a component; skipped in {path}", prop_type_mismatch: 'Prop "{prop}" type mismatch in component "{component}"; expected {expected}, got {actual}', prop_missing: 'Required prop "{prop}" is missing for component "{component}"', prop_unknown: 'Unknown prop "{prop}" passed to component "{component}"; ignored', suspicious_context_value: 'Suspicious value in context key "{key}" ({reason})' }, p = { contains_html_script_tag: "contains HTML script tag", contains_event_handler: "contains inline event handler", contains_dangerous_scheme: "contains dangerous URL scheme", contains_embed_tag: "contains embeddable HTML tag", contains_meta_refresh: "contains meta refresh" }, a = {
|
|
2
|
+
errors: s,
|
|
3
|
+
warnings: c,
|
|
4
|
+
warningReasons: p
|
|
5
|
+
}, l = a.errors, d = a.warnings;
|
|
6
|
+
function i(e, n) {
|
|
7
|
+
return e === void 0 ? "" : e.replace(/\{([^}]+)\}/g, (t, r) => {
|
|
8
|
+
if (n === void 0 || !(r in n))
|
|
9
|
+
return t;
|
|
10
|
+
const o = n[r];
|
|
11
|
+
return o == null ? "" : String(o);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
function m(e, n) {
|
|
15
|
+
return i(l[e], n);
|
|
16
|
+
}
|
|
17
|
+
function _(e, n) {
|
|
18
|
+
return i(d[e], n);
|
|
19
|
+
}
|
|
20
|
+
function u(e) {
|
|
21
|
+
const n = e.message ?? m(e.code, e.details), t = new Error(n);
|
|
22
|
+
return t.name = "HyogenError", t.code = e.code, t.message = n, t.path = e.path, t.details = e.details, t;
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
m as a,
|
|
26
|
+
u as c,
|
|
27
|
+
_ as f,
|
|
28
|
+
a as m
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=createError-WZmAl05N.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { HyogenDiagnostic } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Formats a diagnostic as multi-line log text (api.md).
|
|
4
|
+
* Does not write to console — callers decide how to output.
|
|
5
|
+
*/
|
|
6
|
+
export declare function formatDiagnosticLog(kind: "error" | "warning", diagnostic: HyogenDiagnostic): string;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Unknown codes resolve to empty string (implementation choice for v0.1). */
|
|
2
|
+
export declare function formatMessage(code: string, details?: Record<string, unknown>): string;
|
|
3
|
+
export declare function formatWarningMessage(code: string, details?: Record<string, unknown>): string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ExprNode, EvaluateExpressionOptions, HyogenContext } from '../types.js';
|
|
2
|
+
export declare function evaluateExpression(node: ExprNode, options: EvaluateExpressionOptions): Promise<unknown>;
|
|
3
|
+
/** @deprecated Use evaluateExpression with options object. */
|
|
4
|
+
export declare function evaluateExpressionAsync(node: ExprNode, context: HyogenContext, options?: Omit<EvaluateExpressionOptions, "context">): Promise<unknown>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { InterpolateExpressionsOptions } from '../types.js';
|
|
2
|
+
export declare function interpolateExpressions(source: string, context: InterpolateExpressionsOptions["context"], options?: Omit<InterpolateExpressionsOptions, "context"> & {
|
|
3
|
+
path?: string;
|
|
4
|
+
}): Promise<string>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type CircularIncludeResult = {
|
|
2
|
+
circular: false;
|
|
3
|
+
} | {
|
|
4
|
+
circular: true;
|
|
5
|
+
path: string;
|
|
6
|
+
from: string;
|
|
7
|
+
};
|
|
8
|
+
export declare class VisitStack {
|
|
9
|
+
private readonly stack;
|
|
10
|
+
check(visitPath: string): CircularIncludeResult;
|
|
11
|
+
push(visitPath: string): void;
|
|
12
|
+
pop(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ComponentRegistry } from '../component/ComponentRegistry.js';
|
|
2
|
+
import { VisitStack } from './VisitStack.js';
|
|
3
|
+
import { HyogenContext, HyogenWarning, IncludeDirective, Loader } from '../types.js';
|
|
4
|
+
export type ExpandIncludesOptions = {
|
|
5
|
+
source: string;
|
|
6
|
+
directives: IncludeDirective[];
|
|
7
|
+
context: HyogenContext;
|
|
8
|
+
loader: Loader;
|
|
9
|
+
root?: string;
|
|
10
|
+
path?: string;
|
|
11
|
+
preserveFrontMatter?: boolean;
|
|
12
|
+
preserveHgComments?: boolean;
|
|
13
|
+
visitStack?: VisitStack;
|
|
14
|
+
warnings?: HyogenWarning[];
|
|
15
|
+
registry?: ComponentRegistry;
|
|
16
|
+
constrainToRoot?: boolean;
|
|
17
|
+
};
|
|
18
|
+
export declare function expandIncludes(options: ExpandIncludesOptions): Promise<string>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,113 +1,11 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export declare type BuildResult = {
|
|
13
|
-
files: {
|
|
14
|
-
path: string;
|
|
15
|
-
markdown: string;
|
|
16
|
-
}[];
|
|
17
|
-
warnings: HyogenWarning[];
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
declare type ClientRenderOptions = RenderOptions & {
|
|
21
|
-
/** Rejected on client — use renderServer/build instead */
|
|
22
|
-
serverContext?: HyogenContext;
|
|
23
|
-
/** Rejected on client — use renderServer/build instead */
|
|
24
|
-
dataSources?: DataSourcesMap;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export declare function createFsLoader(options?: FsLoaderOptions): Loader;
|
|
28
|
-
|
|
29
|
-
export declare function createHyogenError(options: {
|
|
30
|
-
code: string;
|
|
31
|
-
message?: string;
|
|
32
|
-
path?: string;
|
|
33
|
-
details?: Record<string, unknown>;
|
|
34
|
-
}): HyogenError;
|
|
35
|
-
|
|
36
|
-
export declare function createNodeLoader(options?: NodeLoaderOptions): Loader;
|
|
37
|
-
|
|
38
|
-
export declare type DataSourcesMap = Record<string, string>;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Formats a diagnostic as multi-line log text (api.md).
|
|
42
|
-
* Does not write to console — callers decide how to output.
|
|
43
|
-
*/
|
|
44
|
-
export declare function formatDiagnosticLog(kind: "error" | "warning", diagnostic: HyogenDiagnostic): string;
|
|
45
|
-
|
|
46
|
-
/** Unknown codes resolve to empty string (implementation choice for v0.1). */
|
|
47
|
-
export declare function formatMessage(code: string, details?: Record<string, unknown>): string;
|
|
48
|
-
|
|
49
|
-
declare type FsLoaderOptions = {
|
|
50
|
-
from?: string;
|
|
51
|
-
via?: "include" | "component" | "extend";
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export declare type HyogenContext = Record<string, unknown>;
|
|
55
|
-
|
|
56
|
-
export declare type HyogenDiagnostic = {
|
|
57
|
-
code: string;
|
|
58
|
-
message: string;
|
|
59
|
-
path?: string;
|
|
60
|
-
details?: Record<string, unknown>;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export declare type HyogenError = Error & HyogenDiagnostic;
|
|
64
|
-
|
|
65
|
-
export declare type HyogenWarning = HyogenDiagnostic;
|
|
66
|
-
|
|
67
|
-
/** Returns true when path is an http(s) URL. */
|
|
68
|
-
export declare function isRemotePath(path: string): boolean;
|
|
69
|
-
|
|
70
|
-
export declare function loadDataSources(sources: DataSourcesMap, options?: LoadDataSourcesOptions): Promise<HyogenContext>;
|
|
71
|
-
|
|
72
|
-
declare type LoadDataSourcesOptions = {
|
|
73
|
-
root?: string;
|
|
74
|
-
loader?: Loader;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
export declare type Loader = (path: string) => Promise<string>;
|
|
78
|
-
|
|
79
|
-
declare type NodeLoaderOptions = FsLoaderOptions;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Client-side render entry. Requires an injected loader; never uses
|
|
83
|
-
* createNodeLoader / resolveRenderInput (no FS or network in the library).
|
|
84
|
-
*/
|
|
85
|
-
export declare function renderClient(input: string | {
|
|
86
|
-
path: string;
|
|
87
|
-
}, context?: HyogenContext, options?: ClientRenderOptions): Promise<RenderResult>;
|
|
88
|
-
|
|
89
|
-
export declare type RenderOptions = {
|
|
90
|
-
preserveFrontMatter?: boolean;
|
|
91
|
-
preserveHgComments?: boolean;
|
|
92
|
-
loader?: Loader;
|
|
93
|
-
root?: string;
|
|
94
|
-
path?: string;
|
|
95
|
-
constrainToRoot?: boolean;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export declare type RenderResult = {
|
|
99
|
-
markdown: string;
|
|
100
|
-
warnings: HyogenWarning[];
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export declare function renderServer(input: string | {
|
|
104
|
-
path: string;
|
|
105
|
-
}, context?: HyogenContext, options?: ServerRenderOptions): Promise<RenderResult>;
|
|
106
|
-
|
|
107
|
-
export declare type ServerRenderOptions = RenderOptions & {
|
|
108
|
-
serverContext?: HyogenContext;
|
|
109
|
-
/** Variable name → root-relative data file path (YAML / JSON / CSV). */
|
|
110
|
-
dataSources?: DataSourcesMap;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
export { }
|
|
1
|
+
export { renderServer } from './renderServer.js';
|
|
2
|
+
export { renderClient } from './renderClient.js';
|
|
3
|
+
export { build } from './build/build.js';
|
|
4
|
+
export { createFsLoader } from './io/createFsLoader.js';
|
|
5
|
+
export { createNodeLoader } from './io/createNodeLoader.js';
|
|
6
|
+
export { loadDataSources } from './io/loadDataSources.js';
|
|
7
|
+
export { isRemotePath } from './io/isRemotePath.js';
|
|
8
|
+
export { createHyogenError } from './errors/createError.js';
|
|
9
|
+
export { formatMessage } from './errors/formatMessage.js';
|
|
10
|
+
export { formatDiagnosticLog } from './errors/formatDiagnosticLog.js';
|
|
11
|
+
export type { HyogenContext, HyogenDiagnostic, HyogenError, HyogenWarning, Loader, DataSourcesMap, RenderOptions, RenderResult, ServerRenderOptions, BuildOptions, BuildResult, } from './types.js';
|