@piqit/resolvers 0.0.2

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/dist/edge.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @piqit/resolvers/edge - Edge-compatible resolvers
3
+ *
4
+ * This entry point only exports resolvers that work in edge environments
5
+ * like Cloudflare Workers, where dynamic code generation is not allowed.
6
+ *
7
+ * Use this instead of '@piqit/resolvers' in your Worker:
8
+ *
9
+ * @example
10
+ * import { staticContent } from "@piqit/resolvers/edge";
11
+ *
12
+ * @packageDocumentation
13
+ */
14
+ export { staticContent, staticResolver } from "./static";
15
+ //# sourceMappingURL=edge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edge.d.ts","sourceRoot":"","sources":["../src/edge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA"}
package/dist/edge.js ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @piqit/resolvers/edge - Edge-compatible resolvers
3
+ *
4
+ * This entry point only exports resolvers that work in edge environments
5
+ * like Cloudflare Workers, where dynamic code generation is not allowed.
6
+ *
7
+ * Use this instead of '@piqit/resolvers' in your Worker:
8
+ *
9
+ * @example
10
+ * import { staticContent } from "@piqit/resolvers/edge";
11
+ *
12
+ * @packageDocumentation
13
+ */
14
+ export { staticContent, staticResolver } from "./static";
15
+ //# sourceMappingURL=edge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edge.js","sourceRoot":"","sources":["../src/edge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Filesystem Markdown Resolver
3
+ *
4
+ * A resolver for querying markdown files from the filesystem.
5
+ * Optimized for reading only what's needed based on the query.
6
+ */
7
+ import type { Resolver, StandardSchema, Infer } from "piqit";
8
+ import { type PathParams } from "./path-pattern";
9
+ import { type BodyOptions, type BodyResult, type Heading } from "./markdown";
10
+ /**
11
+ * Options for creating a file markdown resolver.
12
+ */
13
+ export interface FileMarkdownOptions<TPath extends string, TFrontmatter extends StandardSchema, TBody extends BodyOptions> {
14
+ /**
15
+ * Base directory for finding files.
16
+ * Can be absolute or relative to cwd.
17
+ */
18
+ base: string;
19
+ /**
20
+ * Path pattern with {param} placeholders.
21
+ * @example '{year}/{slug}.md'
22
+ */
23
+ path: TPath;
24
+ /**
25
+ * Schema for validating frontmatter.
26
+ * The schema's inferred type defines filter parameters.
27
+ */
28
+ frontmatter: TFrontmatter;
29
+ /**
30
+ * Body parsing options.
31
+ * @default { raw: false, html: false, headings: false }
32
+ */
33
+ body?: TBody;
34
+ }
35
+ /**
36
+ * The shape of results from a file markdown resolver.
37
+ */
38
+ export interface FileMarkdownResult<TParams, TFrontmatter, TBody extends BodyResult> {
39
+ params: TParams;
40
+ frontmatter: TFrontmatter;
41
+ body: TBody;
42
+ }
43
+ /**
44
+ * Type for body shape based on options.
45
+ */
46
+ type ComputedBodyShape<T extends BodyOptions | undefined> = T extends BodyOptions ? {
47
+ raw: T["raw"] extends true ? string : never;
48
+ html: T["html"] extends true ? string : never;
49
+ headings: T["headings"] extends true ? Heading[] : never;
50
+ } : Record<string, never>;
51
+ /**
52
+ * Clean up body shape to remove never types.
53
+ */
54
+ type CleanBodyShape<T> = {
55
+ [K in keyof T as T[K] extends never ? never : K]: T[K];
56
+ };
57
+ /**
58
+ * Create a filesystem markdown resolver.
59
+ *
60
+ * @example
61
+ * const postsResolver = fileMarkdown({
62
+ * base: 'content/posts',
63
+ * path: '{year}/{slug}.md',
64
+ * frontmatter: z.object({
65
+ * title: z.string(),
66
+ * status: z.enum(['draft', 'published']),
67
+ * }),
68
+ * body: { html: true, headings: true }
69
+ * })
70
+ */
71
+ export declare function fileMarkdown<TPath extends string, TFrontmatter extends StandardSchema, TBody extends BodyOptions = Record<string, never>>(options: FileMarkdownOptions<TPath, TFrontmatter, TBody>): Resolver<StandardSchema<Partial<PathParams<TPath>>>, TFrontmatter, StandardSchema<FileMarkdownResult<PathParams<TPath>, Infer<TFrontmatter>, CleanBodyShape<ComputedBodyShape<TBody>>>>>;
72
+ export {};
73
+ //# sourceMappingURL=file-markdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-markdown.d.ts","sourceRoot":"","sources":["../src/file-markdown.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC5D,OAAO,EAAsC,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEpF,OAAO,EAAqB,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAA;AAO/F;;GAEG;AACH,MAAM,WAAW,mBAAmB,CAClC,KAAK,SAAS,MAAM,EACpB,YAAY,SAAS,cAAc,EACnC,KAAK,SAAS,WAAW;IAEzB;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;;OAGG;IACH,IAAI,EAAE,KAAK,CAAA;IAEX;;;OAGG;IACH,WAAW,EAAE,YAAY,CAAA;IAEzB;;;OAGG;IACH,IAAI,CAAC,EAAE,KAAK,CAAA;CACb;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB,CACjC,OAAO,EACP,YAAY,EACZ,KAAK,SAAS,UAAU;IAExB,MAAM,EAAE,OAAO,CAAA;IACf,WAAW,EAAE,YAAY,CAAA;IACzB,IAAI,EAAE,KAAK,CAAA;CACZ;AAED;;GAEG;AACH,KAAK,iBAAiB,CAAC,CAAC,SAAS,WAAW,GAAG,SAAS,IAAI,CAAC,SAAS,WAAW,GAC7E;IACE,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,IAAI,GAAG,MAAM,GAAG,KAAK,CAAA;IAC3C,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,SAAS,IAAI,GAAG,MAAM,GAAG,KAAK,CAAA;IAC7C,QAAQ,EAAE,CAAC,CAAC,UAAU,CAAC,SAAS,IAAI,GAAG,OAAO,EAAE,GAAG,KAAK,CAAA;CACzD,GACD,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AAEzB;;GAEG;AACH,KAAK,cAAc,CAAC,CAAC,IAAI;KACtB,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACvD,CAAA;AAuHD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAC1B,KAAK,SAAS,MAAM,EACpB,YAAY,SAAS,cAAc,EACnC,KAAK,SAAS,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAEjD,OAAO,EAAE,mBAAmB,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,CAAC,GACvD,QAAQ,CACT,cAAc,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAC1C,YAAY,EACZ,cAAc,CACZ,kBAAkB,CAChB,UAAU,CAAC,KAAK,CAAC,EACjB,KAAK,CAAC,YAAY,CAAC,EACnB,cAAc,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CACzC,CACF,CACF,CA2HA"}
@@ -0,0 +1,201 @@
1
+ /**
2
+ * Filesystem Markdown Resolver
3
+ *
4
+ * A resolver for querying markdown files from the filesystem.
5
+ * Optimized for reading only what's needed based on the query.
6
+ */
7
+ import { compilePattern, createParamsSchema } from "./path-pattern";
8
+ import { parseFrontmatter } from "./frontmatter";
9
+ import { parseMarkdownBody } from "./markdown";
10
+ import path from "node:path";
11
+ // =============================================================================
12
+ // Result Schema Factory
13
+ // =============================================================================
14
+ /**
15
+ * Create a result schema for the resolver.
16
+ * This schema validates the namespaced result shape.
17
+ */
18
+ function createResultSchema(_paramNames, frontmatterSchema, bodyOptions) {
19
+ return {
20
+ "~standard": {
21
+ version: 1,
22
+ vendor: "piqit/resolvers",
23
+ validate(value) {
24
+ if (value === null || typeof value !== "object") {
25
+ return { issues: [{ message: "Expected object" }] };
26
+ }
27
+ const obj = value;
28
+ // Validate params
29
+ if (obj.params == null || typeof obj.params !== "object") {
30
+ return { issues: [{ message: "Missing params", path: ["params"] }] };
31
+ }
32
+ // Validate frontmatter using the provided schema
33
+ const fmResult = frontmatterSchema["~standard"].validate(obj.frontmatter);
34
+ if (fmResult.issues) {
35
+ return {
36
+ issues: fmResult.issues.map((issue) => ({
37
+ ...issue,
38
+ path: ["frontmatter", ...(issue.path || [])],
39
+ })),
40
+ };
41
+ }
42
+ // Validate body shape
43
+ if (bodyOptions.raw || bodyOptions.html || bodyOptions.headings) {
44
+ if (obj.body == null || typeof obj.body !== "object") {
45
+ return { issues: [{ message: "Missing body", path: ["body"] }] };
46
+ }
47
+ }
48
+ return { value: obj };
49
+ },
50
+ },
51
+ };
52
+ }
53
+ // =============================================================================
54
+ // Helper Functions
55
+ // =============================================================================
56
+ /**
57
+ * Check if any select paths require frontmatter data.
58
+ */
59
+ function needsFrontmatter(selectPaths) {
60
+ return selectPaths.some((p) => p.startsWith("frontmatter.") || p === "frontmatter.*");
61
+ }
62
+ /**
63
+ * Check if any select paths require body data.
64
+ */
65
+ function needsBody(selectPaths) {
66
+ return selectPaths.some((p) => p.startsWith("body.") || p === "body.*");
67
+ }
68
+ /**
69
+ * Check if any select paths require params.
70
+ */
71
+ function needsParams(selectPaths) {
72
+ return selectPaths.some((p) => p.startsWith("params.") || p === "params.*");
73
+ }
74
+ /**
75
+ * Get which body parts are needed based on select paths.
76
+ */
77
+ function getNeededBodyParts(selectPaths) {
78
+ const result = {};
79
+ for (const path of selectPaths) {
80
+ if (path === "body.*") {
81
+ // Need all body parts
82
+ return { raw: true, html: true, headings: true };
83
+ }
84
+ if (path === "body.raw")
85
+ result.raw = true;
86
+ if (path === "body.html")
87
+ result.html = true;
88
+ if (path === "body.headings")
89
+ result.headings = true;
90
+ }
91
+ return result;
92
+ }
93
+ /**
94
+ * Check if filter constraints match frontmatter.
95
+ * Simple equality check for now.
96
+ */
97
+ function matchesFilter(frontmatter, filter) {
98
+ for (const [key, value] of Object.entries(filter)) {
99
+ if (frontmatter[key] !== value) {
100
+ return false;
101
+ }
102
+ }
103
+ return true;
104
+ }
105
+ // =============================================================================
106
+ // Resolver Factory
107
+ // =============================================================================
108
+ /**
109
+ * Create a filesystem markdown resolver.
110
+ *
111
+ * @example
112
+ * const postsResolver = fileMarkdown({
113
+ * base: 'content/posts',
114
+ * path: '{year}/{slug}.md',
115
+ * frontmatter: z.object({
116
+ * title: z.string(),
117
+ * status: z.enum(['draft', 'published']),
118
+ * }),
119
+ * body: { html: true, headings: true }
120
+ * })
121
+ */
122
+ export function fileMarkdown(options) {
123
+ const pattern = compilePattern(options.path);
124
+ const basePath = path.isAbsolute(options.base)
125
+ ? options.base
126
+ : path.join(process.cwd(), options.base);
127
+ const bodyOptions = options.body || {};
128
+ // Create schemas
129
+ const scanSchema = createParamsSchema(pattern);
130
+ const resultSchema = createResultSchema(pattern.paramNames, options.frontmatter, bodyOptions);
131
+ return {
132
+ schema: {
133
+ scanParams: scanSchema,
134
+ filterParams: options.frontmatter,
135
+ result: resultSchema,
136
+ },
137
+ async resolve(spec) {
138
+ const results = [];
139
+ // 1. Generate glob pattern from scan constraints
140
+ const globPattern = pattern.toGlob(spec.scan);
141
+ // 2. Find matching files using Bun.Glob
142
+ const glob = new Bun.Glob(globPattern);
143
+ const files = [];
144
+ for await (const file of glob.scan({ cwd: basePath, absolute: false })) {
145
+ files.push(file);
146
+ }
147
+ // 3. Determine what we need to read
148
+ const wantParams = needsParams(spec.select);
149
+ const wantFrontmatter = needsFrontmatter(spec.select);
150
+ const wantBody = needsBody(spec.select);
151
+ const hasFilter = spec.filter && Object.keys(spec.filter).length > 0;
152
+ const neededBodyParts = wantBody ? getNeededBodyParts(spec.select) : {};
153
+ // 4. Process each file
154
+ for (const relativePath of files) {
155
+ // Extract params from path
156
+ const params = pattern.match(relativePath);
157
+ if (!params)
158
+ continue;
159
+ const fullPath = path.join(basePath, relativePath);
160
+ // Read file content only if needed
161
+ let content = null;
162
+ let frontmatter = null;
163
+ let body = null;
164
+ // If filtering or selecting frontmatter, we need to read it
165
+ if (hasFilter || wantFrontmatter) {
166
+ content = await Bun.file(fullPath).text();
167
+ frontmatter = parseFrontmatter(content);
168
+ if (!frontmatter) {
169
+ frontmatter = {};
170
+ }
171
+ // Check filter constraints
172
+ if (hasFilter && !matchesFilter(frontmatter, spec.filter)) {
173
+ continue;
174
+ }
175
+ }
176
+ // If selecting body, parse it
177
+ if (wantBody) {
178
+ if (!content) {
179
+ content = await Bun.file(fullPath).text();
180
+ }
181
+ // Only parse the body parts that are needed
182
+ body = parseMarkdownBody(content, neededBodyParts);
183
+ }
184
+ // Build result with only requested fields
185
+ const result = {};
186
+ if (wantParams) {
187
+ result.params = params;
188
+ }
189
+ if (wantFrontmatter) {
190
+ result.frontmatter = frontmatter;
191
+ }
192
+ if (wantBody && body) {
193
+ result.body = body;
194
+ }
195
+ results.push(result);
196
+ }
197
+ return results;
198
+ },
199
+ };
200
+ }
201
+ //# sourceMappingURL=file-markdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-markdown.js","sourceRoot":"","sources":["../src/file-markdown.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAmB,MAAM,gBAAgB,CAAA;AACpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,EAAE,iBAAiB,EAAmD,MAAM,YAAY,CAAA;AAC/F,OAAO,IAAI,MAAM,WAAW,CAAA;AAsE5B,gFAAgF;AAChF,wBAAwB;AACxB,gFAAgF;AAEhF;;;GAGG;AACH,SAAS,kBAAkB,C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C;YAED,OAAO,OAAO,CAAA;QAChB,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * YAML Frontmatter Extraction
3
+ *
4
+ * Optimized frontmatter parsing that reads only what's needed.
5
+ */
6
+ /**
7
+ * Parse YAML frontmatter from content string.
8
+ *
9
+ * Uses a simple YAML parser that handles common cases:
10
+ * - key: value
11
+ * - key: "quoted value"
12
+ * - key: 'quoted value'
13
+ * - key: [array, items]
14
+ * - Multi-line values with proper indentation
15
+ *
16
+ * @param content - The file content (or just the frontmatter portion)
17
+ * @returns The parsed frontmatter object, or null if not found
18
+ */
19
+ export declare function parseFrontmatter(content: string): Record<string, unknown> | null;
20
+ /**
21
+ * Extract just the frontmatter portion from content.
22
+ * Returns the raw YAML string without the --- delimiters.
23
+ *
24
+ * @param content - The file content
25
+ * @returns The YAML content, or null if no frontmatter
26
+ */
27
+ export declare function extractFrontmatterString(content: string): string | null;
28
+ /**
29
+ * Get the byte offset where frontmatter ends (after closing ---).
30
+ * Returns 0 if no frontmatter found.
31
+ *
32
+ * @param content - The file content
33
+ * @returns Byte offset after frontmatter, or 0
34
+ */
35
+ export declare function getFrontmatterEndOffset(content: string): number;
36
+ /**
37
+ * Read only the frontmatter from a file, optimized for large files.
38
+ *
39
+ * Reads incrementally until we find the closing ---, avoiding reading
40
+ * the entire file into memory.
41
+ *
42
+ * @param path - Path to the markdown file
43
+ * @param maxBytes - Maximum bytes to read looking for frontmatter (default 8KB)
44
+ * @returns The parsed frontmatter, or null if not found
45
+ */
46
+ export declare function readFrontmatter(path: string, maxBytes?: number): Promise<Record<string, unknown> | null>;
47
+ /**
48
+ * Read frontmatter and return the offset where body starts.
49
+ * Useful when you need both frontmatter and body.
50
+ *
51
+ * @param path - Path to the markdown file
52
+ * @returns Object with frontmatter and body start offset
53
+ */
54
+ export declare function readFrontmatterWithOffset(path: string): Promise<{
55
+ frontmatter: Record<string, unknown> | null;
56
+ bodyOffset: number;
57
+ }>;
58
+ //# sourceMappingURL=frontmatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../src/frontmatter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAMhF;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGvE;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAI/D;AA+JD;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,QAAQ,SAAO,GACd,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,CAazC;AAED;;;;;;GAMG;AACH,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,MAAM,GACX,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAY9E"}
@@ -0,0 +1,254 @@
1
+ /**
2
+ * YAML Frontmatter Extraction
3
+ *
4
+ * Optimized frontmatter parsing that reads only what's needed.
5
+ */
6
+ // =============================================================================
7
+ // Frontmatter Parsing
8
+ // =============================================================================
9
+ /**
10
+ * Regex to match YAML frontmatter block at the start of content.
11
+ * Matches --- at start, captures content, ends with ---
12
+ */
13
+ const FRONTMATTER_REGEX = /^---\r?\n([\s\S]*?)\r?\n---/;
14
+ /**
15
+ * Parse YAML frontmatter from content string.
16
+ *
17
+ * Uses a simple YAML parser that handles common cases:
18
+ * - key: value
19
+ * - key: "quoted value"
20
+ * - key: 'quoted value'
21
+ * - key: [array, items]
22
+ * - Multi-line values with proper indentation
23
+ *
24
+ * @param content - The file content (or just the frontmatter portion)
25
+ * @returns The parsed frontmatter object, or null if not found
26
+ */
27
+ export function parseFrontmatter(content) {
28
+ const match = FRONTMATTER_REGEX.exec(content);
29
+ if (!match)
30
+ return null;
31
+ const yaml = match[1];
32
+ return parseSimpleYaml(yaml);
33
+ }
34
+ /**
35
+ * Extract just the frontmatter portion from content.
36
+ * Returns the raw YAML string without the --- delimiters.
37
+ *
38
+ * @param content - The file content
39
+ * @returns The YAML content, or null if no frontmatter
40
+ */
41
+ export function extractFrontmatterString(content) {
42
+ const match = FRONTMATTER_REGEX.exec(content);
43
+ return match ? match[1] : null;
44
+ }
45
+ /**
46
+ * Get the byte offset where frontmatter ends (after closing ---).
47
+ * Returns 0 if no frontmatter found.
48
+ *
49
+ * @param content - The file content
50
+ * @returns Byte offset after frontmatter, or 0
51
+ */
52
+ export function getFrontmatterEndOffset(content) {
53
+ const match = FRONTMATTER_REGEX.exec(content);
54
+ if (!match)
55
+ return 0;
56
+ return match[0].length;
57
+ }
58
+ // =============================================================================
59
+ // Simple YAML Parser
60
+ // =============================================================================
61
+ /**
62
+ * Parse simple YAML into an object.
63
+ * Handles the common patterns found in markdown frontmatter.
64
+ */
65
+ function parseSimpleYaml(yaml) {
66
+ const result = {};
67
+ const lines = yaml.split(/\r?\n/);
68
+ let currentKey = null;
69
+ let currentValue = [];
70
+ let inMultiline = false;
71
+ let inBlockArray = false;
72
+ let blockArrayItems = [];
73
+ let multilineIndent = 0;
74
+ function commitValue() {
75
+ if (currentKey) {
76
+ if (inBlockArray) {
77
+ // Commit block array
78
+ result[currentKey] = blockArrayItems;
79
+ blockArrayItems = [];
80
+ inBlockArray = false;
81
+ }
82
+ else if (currentValue.length === 1) {
83
+ result[currentKey] = parseYamlValue(currentValue[0]);
84
+ }
85
+ else if (currentValue.length > 1) {
86
+ result[currentKey] = currentValue.join("\n");
87
+ }
88
+ }
89
+ currentKey = null;
90
+ currentValue = [];
91
+ inMultiline = false;
92
+ }
93
+ for (const line of lines) {
94
+ // Check for block array item (- value)
95
+ const arrayItemMatch = line.match(/^(\s+)-\s+(.*)$/);
96
+ if (arrayItemMatch && currentKey && (inBlockArray || (inMultiline && currentValue.length === 0))) {
97
+ inBlockArray = true;
98
+ inMultiline = false;
99
+ const itemValue = arrayItemMatch[2].trim();
100
+ blockArrayItems.push(parseYamlValue(itemValue));
101
+ continue;
102
+ }
103
+ // Check for key: value pattern
104
+ const keyMatch = line.match(/^([a-zA-Z_][a-zA-Z0-9_-]*)\s*:\s*(.*)$/);
105
+ if (keyMatch && !inMultiline) {
106
+ // Commit previous key-value
107
+ commitValue();
108
+ currentKey = keyMatch[1];
109
+ const valueStr = keyMatch[2].trim();
110
+ if (valueStr === "" || valueStr === "|" || valueStr === ">") {
111
+ // Multiline value or block array starts on next line
112
+ inMultiline = true;
113
+ multilineIndent = 0;
114
+ }
115
+ else {
116
+ currentValue = [valueStr];
117
+ }
118
+ }
119
+ else if (inMultiline && currentKey && !inBlockArray) {
120
+ // Continuation of multiline value
121
+ if (line.trim() === "") {
122
+ currentValue.push("");
123
+ }
124
+ else {
125
+ const indent = line.search(/\S/);
126
+ if (indent > 0) {
127
+ if (multilineIndent === 0) {
128
+ multilineIndent = indent;
129
+ }
130
+ currentValue.push(line.slice(multilineIndent));
131
+ }
132
+ else {
133
+ // No indent means new key or end of multiline
134
+ commitValue();
135
+ // Re-process this line
136
+ const reKeyMatch = line.match(/^([a-zA-Z_][a-zA-Z0-9_-]*)\s*:\s*(.*)$/);
137
+ if (reKeyMatch) {
138
+ currentKey = reKeyMatch[1];
139
+ const valueStr = reKeyMatch[2].trim();
140
+ if (valueStr === "" || valueStr === "|" || valueStr === ">") {
141
+ inMultiline = true;
142
+ multilineIndent = 0;
143
+ }
144
+ else {
145
+ currentValue = [valueStr];
146
+ }
147
+ }
148
+ }
149
+ }
150
+ }
151
+ else if (currentKey && line.trim() === "") {
152
+ // Empty line after value - keep going
153
+ }
154
+ else if (!currentKey && line.trim() !== "") {
155
+ // New key-value
156
+ const newKeyMatch = line.match(/^([a-zA-Z_][a-zA-Z0-9_-]*)\s*:\s*(.*)$/);
157
+ if (newKeyMatch) {
158
+ currentKey = newKeyMatch[1];
159
+ const valueStr = newKeyMatch[2].trim();
160
+ if (valueStr === "" || valueStr === "|" || valueStr === ">") {
161
+ inMultiline = true;
162
+ multilineIndent = 0;
163
+ }
164
+ else {
165
+ currentValue = [valueStr];
166
+ }
167
+ }
168
+ }
169
+ }
170
+ // Commit final value
171
+ commitValue();
172
+ return result;
173
+ }
174
+ /**
175
+ * Parse a single YAML value.
176
+ */
177
+ function parseYamlValue(value) {
178
+ // Remove quotes
179
+ if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
180
+ return value.slice(1, -1);
181
+ }
182
+ // Check for array
183
+ if (value.startsWith("[") && value.endsWith("]")) {
184
+ const inner = value.slice(1, -1);
185
+ if (inner.trim() === "")
186
+ return [];
187
+ return inner.split(",").map((item) => parseYamlValue(item.trim()));
188
+ }
189
+ // Check for booleans
190
+ if (value === "true")
191
+ return true;
192
+ if (value === "false")
193
+ return false;
194
+ // Check for null
195
+ if (value === "null" || value === "~")
196
+ return null;
197
+ // Check for numbers
198
+ const num = Number(value);
199
+ if (!isNaN(num) && value !== "")
200
+ return num;
201
+ // Check for dates (ISO format)
202
+ if (/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2})?/.test(value)) {
203
+ const date = new Date(value);
204
+ if (!isNaN(date.getTime()))
205
+ return date.toISOString();
206
+ }
207
+ return value;
208
+ }
209
+ // =============================================================================
210
+ // Optimized File Reading
211
+ // =============================================================================
212
+ /**
213
+ * Read only the frontmatter from a file, optimized for large files.
214
+ *
215
+ * Reads incrementally until we find the closing ---, avoiding reading
216
+ * the entire file into memory.
217
+ *
218
+ * @param path - Path to the markdown file
219
+ * @param maxBytes - Maximum bytes to read looking for frontmatter (default 8KB)
220
+ * @returns The parsed frontmatter, or null if not found
221
+ */
222
+ export async function readFrontmatter(path, maxBytes = 8192) {
223
+ try {
224
+ const file = Bun.file(path);
225
+ const size = file.size;
226
+ // Read up to maxBytes or file size
227
+ const bytesToRead = Math.min(maxBytes, size);
228
+ const buffer = await file.slice(0, bytesToRead).text();
229
+ return parseFrontmatter(buffer);
230
+ }
231
+ catch {
232
+ return null;
233
+ }
234
+ }
235
+ /**
236
+ * Read frontmatter and return the offset where body starts.
237
+ * Useful when you need both frontmatter and body.
238
+ *
239
+ * @param path - Path to the markdown file
240
+ * @returns Object with frontmatter and body start offset
241
+ */
242
+ export async function readFrontmatterWithOffset(path) {
243
+ try {
244
+ const file = Bun.file(path);
245
+ const content = await file.text();
246
+ const frontmatter = parseFrontmatter(content);
247
+ const bodyOffset = getFrontmatterEndOffset(content);
248
+ return { frontmatter, bodyOffset };
249
+ }
250
+ catch {
251
+ return { frontmatter: null, bodyOffset: 0 };
252
+ }
253
+ }
254
+ //# sourceMappingURL=frontmatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["../src/frontmatter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,gFAAgF;AAChF,sBAAsB;AACtB,gFAAgF;AAEhF;;;GAGG;AACH,MAAM,iBAAiB,GAAG,6BAA6B,CAAA;AAEvD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,MAAM,KAAK,GAAG,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC7C,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAA;IAEvB,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;IACrB,OAAO,eAAe,CAAC,IAAI,CAAC,CAAA;AAC9B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAe;IACtD,MAAM,KAAK,GAAG,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC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