ai-props 2.3.0 → 2.4.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/.turbo/turbo-build.log +4 -0
- package/CHANGELOG.md +9 -0
- package/dist/ai.d.ts +125 -0
- package/dist/ai.d.ts.map +1 -0
- package/dist/ai.js +199 -0
- package/dist/ai.js.map +1 -0
- package/dist/cache.d.ts +66 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +183 -0
- package/dist/cache.js.map +1 -0
- package/dist/cascade.d.ts +329 -0
- package/dist/cascade.d.ts.map +1 -0
- package/dist/cascade.js +522 -0
- package/dist/cascade.js.map +1 -0
- package/dist/client.d.ts +233 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +191 -0
- package/dist/client.js.map +1 -0
- package/dist/durable-cascade.d.ts +280 -0
- package/dist/durable-cascade.d.ts.map +1 -0
- package/dist/durable-cascade.js +469 -0
- package/dist/durable-cascade.js.map +1 -0
- package/dist/event-bridge.d.ts +257 -0
- package/dist/event-bridge.d.ts.map +1 -0
- package/dist/event-bridge.js +317 -0
- package/dist/event-bridge.js.map +1 -0
- package/dist/generate.d.ts +69 -0
- package/dist/generate.d.ts.map +1 -0
- package/dist/generate.js +227 -0
- package/dist/generate.js.map +1 -0
- package/dist/hoc.d.ts +164 -0
- package/dist/hoc.d.ts.map +1 -0
- package/dist/hoc.js +236 -0
- package/dist/hoc.js.map +1 -0
- package/dist/hono-jsx.d.ts +208 -0
- package/dist/hono-jsx.d.ts.map +1 -0
- package/dist/hono-jsx.js +459 -0
- package/dist/hono-jsx.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/mdx-types.d.ts +152 -0
- package/dist/mdx-types.d.ts.map +1 -0
- package/dist/mdx-types.js +9 -0
- package/dist/mdx-types.js.map +1 -0
- package/dist/mdx-utils.d.ts +106 -0
- package/dist/mdx-utils.d.ts.map +1 -0
- package/dist/mdx-utils.js +384 -0
- package/dist/mdx-utils.js.map +1 -0
- package/dist/mdx.d.ts +230 -0
- package/dist/mdx.d.ts.map +1 -0
- package/dist/mdx.js +820 -0
- package/dist/mdx.js.map +1 -0
- package/dist/rpc.d.ts +313 -0
- package/dist/rpc.d.ts.map +1 -0
- package/dist/rpc.js +359 -0
- package/dist/rpc.js.map +1 -0
- package/dist/streaming.d.ts +199 -0
- package/dist/streaming.d.ts.map +1 -0
- package/dist/streaming.js +402 -0
- package/dist/streaming.js.map +1 -0
- package/dist/types.d.ts +152 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/dist/validate.d.ts +58 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +251 -0
- package/dist/validate.js.map +1 -0
- package/dist/worker.d.ts +270 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +405 -0
- package/dist/worker.js.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MDX utility functions
|
|
3
|
+
*
|
|
4
|
+
* Internal utilities for MDX parsing, component extraction, and content hashing.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Default cache TTL for MDX parsing (5 minutes)
|
|
10
|
+
*/
|
|
11
|
+
export const MDX_CACHE_TTL = 5 * 60 * 1000;
|
|
12
|
+
/**
|
|
13
|
+
* Create a content hash for cache keys
|
|
14
|
+
*
|
|
15
|
+
* Uses a simple but fast hash algorithm suitable for cache keys.
|
|
16
|
+
*
|
|
17
|
+
* @param content - Content to hash
|
|
18
|
+
* @returns Hash string
|
|
19
|
+
*/
|
|
20
|
+
export function hashContent(content) {
|
|
21
|
+
let hash = 0;
|
|
22
|
+
for (let i = 0; i < content.length; i++) {
|
|
23
|
+
const char = content.charCodeAt(i);
|
|
24
|
+
hash = (hash << 5) - hash + char;
|
|
25
|
+
hash = hash & hash; // Convert to 32-bit integer
|
|
26
|
+
}
|
|
27
|
+
return hash.toString(36);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create an MDX parse error with location information
|
|
31
|
+
*
|
|
32
|
+
* @param message - Error message
|
|
33
|
+
* @param source - Source content where error occurred
|
|
34
|
+
* @param position - Position in source (optional)
|
|
35
|
+
* @returns MDXParseError
|
|
36
|
+
*/
|
|
37
|
+
export function createParseError(message, source, position) {
|
|
38
|
+
const error = new Error(message);
|
|
39
|
+
if (source !== undefined) {
|
|
40
|
+
error.source = source;
|
|
41
|
+
}
|
|
42
|
+
if (source && position !== undefined) {
|
|
43
|
+
const lines = source.slice(0, position).split('\n');
|
|
44
|
+
error.line = lines.length;
|
|
45
|
+
error.column = (lines[lines.length - 1]?.length || 0) + 1;
|
|
46
|
+
}
|
|
47
|
+
return error;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Parse YAML frontmatter
|
|
51
|
+
*
|
|
52
|
+
* Handles basic YAML types: strings, numbers, booleans, arrays, and nested objects.
|
|
53
|
+
*
|
|
54
|
+
* @param yaml - YAML content string
|
|
55
|
+
* @returns Parsed key-value pairs
|
|
56
|
+
* @throws Error if YAML is invalid
|
|
57
|
+
*/
|
|
58
|
+
export function parseYAML(yaml) {
|
|
59
|
+
const result = {};
|
|
60
|
+
const lines = yaml.trim().split('\n');
|
|
61
|
+
// Stack for tracking nested objects
|
|
62
|
+
// Each entry stores: the parent object, the parent indent level, and the current object's indent
|
|
63
|
+
const stack = [];
|
|
64
|
+
let currentObj = result;
|
|
65
|
+
let currentIndent = -1; // Use -1 for root level
|
|
66
|
+
let currentArray = null;
|
|
67
|
+
for (const line of lines) {
|
|
68
|
+
// Skip empty lines
|
|
69
|
+
if (!line.trim())
|
|
70
|
+
continue;
|
|
71
|
+
// Calculate indentation
|
|
72
|
+
const indentMatch = line.match(/^(\s*)/);
|
|
73
|
+
const indent = indentMatch && indentMatch[1] !== undefined ? indentMatch[1].length : 0;
|
|
74
|
+
// Pop stack if we've dedented (back to a parent level or sibling)
|
|
75
|
+
while (stack.length > 0 && indent <= stack[stack.length - 1].thisIndent) {
|
|
76
|
+
const popped = stack.pop();
|
|
77
|
+
currentObj = popped.parentObj;
|
|
78
|
+
currentIndent = popped.parentIndent;
|
|
79
|
+
currentArray = null;
|
|
80
|
+
}
|
|
81
|
+
// Check for array item
|
|
82
|
+
const arrayMatch = line.match(/^(\s*)-\s*(.*)$/);
|
|
83
|
+
if (arrayMatch && arrayMatch[2] !== undefined && currentArray !== null) {
|
|
84
|
+
const value = parseYAMLValue(arrayMatch[2].trim());
|
|
85
|
+
currentArray.push(value);
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
// Check for key-value pair (supporting special chars like $)
|
|
89
|
+
const keyMatch = line.match(/^(\s*)([\w$]+):\s*(.*)$/);
|
|
90
|
+
if (keyMatch && keyMatch[2] !== undefined && keyMatch[3] !== undefined) {
|
|
91
|
+
const key = keyMatch[2];
|
|
92
|
+
const value = keyMatch[3].trim();
|
|
93
|
+
// If the value is empty, this might be a nested object or array
|
|
94
|
+
if (value === '') {
|
|
95
|
+
// Check if this is an array or nested object by looking at the next line
|
|
96
|
+
const lineIndex = lines.indexOf(line);
|
|
97
|
+
const nextLine = lines[lineIndex + 1];
|
|
98
|
+
if (nextLine && nextLine.trim().startsWith('-')) {
|
|
99
|
+
// It's an array
|
|
100
|
+
currentArray = [];
|
|
101
|
+
currentObj[key] = currentArray;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
// It's a nested object
|
|
105
|
+
const nestedObj = {};
|
|
106
|
+
currentObj[key] = nestedObj;
|
|
107
|
+
stack.push({
|
|
108
|
+
parentObj: currentObj,
|
|
109
|
+
parentIndent: currentIndent,
|
|
110
|
+
thisIndent: indent,
|
|
111
|
+
});
|
|
112
|
+
currentObj = nestedObj;
|
|
113
|
+
currentIndent = indent;
|
|
114
|
+
currentArray = null;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
currentObj[key] = parseYAMLValue(value);
|
|
119
|
+
currentArray = null;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Parse a YAML value to its appropriate type
|
|
127
|
+
*
|
|
128
|
+
* @param value - YAML value string
|
|
129
|
+
* @returns Parsed value
|
|
130
|
+
* @throws Error if value is malformed
|
|
131
|
+
*/
|
|
132
|
+
export function parseYAMLValue(value) {
|
|
133
|
+
// Boolean
|
|
134
|
+
if (value === 'true')
|
|
135
|
+
return true;
|
|
136
|
+
if (value === 'false')
|
|
137
|
+
return false;
|
|
138
|
+
// Number
|
|
139
|
+
const num = Number(value);
|
|
140
|
+
if (!isNaN(num) && value !== '')
|
|
141
|
+
return num;
|
|
142
|
+
// String (remove quotes if present)
|
|
143
|
+
if ((value.startsWith('"') && value.endsWith('"')) ||
|
|
144
|
+
(value.startsWith("'") && value.endsWith("'"))) {
|
|
145
|
+
return value.slice(1, -1);
|
|
146
|
+
}
|
|
147
|
+
// Check for invalid YAML (incomplete objects/arrays)
|
|
148
|
+
if (value.startsWith('[') && !value.endsWith(']')) {
|
|
149
|
+
throw createParseError('Invalid YAML: unclosed array');
|
|
150
|
+
}
|
|
151
|
+
if (value.startsWith('{') && !value.endsWith('}')) {
|
|
152
|
+
throw createParseError('Invalid YAML: unclosed object');
|
|
153
|
+
}
|
|
154
|
+
return value;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Extract component names from MDX content
|
|
158
|
+
*
|
|
159
|
+
* Finds all PascalCase JSX component tags.
|
|
160
|
+
*
|
|
161
|
+
* @param content - MDX body content
|
|
162
|
+
* @returns Array of unique component names
|
|
163
|
+
*/
|
|
164
|
+
export function extractComponents(content) {
|
|
165
|
+
const components = new Set();
|
|
166
|
+
// Match JSX component tags (PascalCase)
|
|
167
|
+
// Self-closing: <Component />
|
|
168
|
+
// Opening: <Component>
|
|
169
|
+
const tagRegex = /<([A-Z][a-zA-Z0-9]*)(?:\s|>|\/)/g;
|
|
170
|
+
let match;
|
|
171
|
+
while ((match = tagRegex.exec(content)) !== null) {
|
|
172
|
+
if (match[1]) {
|
|
173
|
+
components.add(match[1]);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return Array.from(components);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Extract props from a component tag string
|
|
180
|
+
*
|
|
181
|
+
* Parses string props, expression props, and boolean props.
|
|
182
|
+
*
|
|
183
|
+
* @param tag - Component tag content (attributes portion)
|
|
184
|
+
* @returns Props object
|
|
185
|
+
*/
|
|
186
|
+
export function extractPropsFromTag(tag) {
|
|
187
|
+
const props = {};
|
|
188
|
+
// Extract string props: name="value"
|
|
189
|
+
const stringPropRegex = /(\w+)="([^"]*)"/g;
|
|
190
|
+
let match;
|
|
191
|
+
while ((match = stringPropRegex.exec(tag)) !== null) {
|
|
192
|
+
const name = match[1];
|
|
193
|
+
const value = match[2];
|
|
194
|
+
if (name !== undefined && value !== undefined) {
|
|
195
|
+
props[name] = value;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
// Extract expression props: name={expression}
|
|
199
|
+
const exprPropRegex = /(\w+)=\{([^}]*)\}/g;
|
|
200
|
+
while ((match = exprPropRegex.exec(tag)) !== null) {
|
|
201
|
+
const name = match[1];
|
|
202
|
+
const exprValue = match[2];
|
|
203
|
+
if (name !== undefined && exprValue !== undefined) {
|
|
204
|
+
try {
|
|
205
|
+
// Try to parse as JSON
|
|
206
|
+
props[name] = JSON.parse(exprValue);
|
|
207
|
+
}
|
|
208
|
+
catch {
|
|
209
|
+
// Try to evaluate simple expressions
|
|
210
|
+
if (exprValue === 'true') {
|
|
211
|
+
props[name] = true;
|
|
212
|
+
}
|
|
213
|
+
else if (exprValue === 'false') {
|
|
214
|
+
props[name] = false;
|
|
215
|
+
}
|
|
216
|
+
else if (!isNaN(Number(exprValue))) {
|
|
217
|
+
props[name] = Number(exprValue);
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
// Keep as expression string
|
|
221
|
+
props[name] = exprValue;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
// Extract boolean props (word not followed by =)
|
|
227
|
+
const booleanPropRegex = /\s([a-z][a-zA-Z0-9]*)(?=\s|>|\/|$)/g;
|
|
228
|
+
while ((match = booleanPropRegex.exec(tag)) !== null) {
|
|
229
|
+
const name = match[1];
|
|
230
|
+
// Only add if not already defined
|
|
231
|
+
if (name !== undefined && !(name in props)) {
|
|
232
|
+
props[name] = true;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return props;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Extract component props from all components in MDX content
|
|
239
|
+
*
|
|
240
|
+
* @param content - MDX body content
|
|
241
|
+
* @returns Map of component names to their props
|
|
242
|
+
*/
|
|
243
|
+
export function extractComponentProps(content) {
|
|
244
|
+
const componentProps = {};
|
|
245
|
+
// Match full component tags (including multi-line)
|
|
246
|
+
const tagRegex = /<([A-Z][a-zA-Z0-9]*)([\s\S]*?)(?:\/>|>)/g;
|
|
247
|
+
let match;
|
|
248
|
+
while ((match = tagRegex.exec(content)) !== null) {
|
|
249
|
+
const componentName = match[1];
|
|
250
|
+
const propsStr = match[2];
|
|
251
|
+
if (componentName === undefined || propsStr === undefined)
|
|
252
|
+
continue;
|
|
253
|
+
const props = extractPropsFromTag(propsStr);
|
|
254
|
+
if (Object.keys(props).length > 0) {
|
|
255
|
+
// Merge with existing props for this component
|
|
256
|
+
componentProps[componentName] = {
|
|
257
|
+
...componentProps[componentName],
|
|
258
|
+
...props,
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return componentProps;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Validate MDX syntax
|
|
266
|
+
*
|
|
267
|
+
* Checks for unclosed tags and invalid prop syntax.
|
|
268
|
+
*
|
|
269
|
+
* @param content - MDX body content
|
|
270
|
+
* @throws MDXParseError if syntax is invalid
|
|
271
|
+
*/
|
|
272
|
+
export function validateMDX(content) {
|
|
273
|
+
// Check for incomplete tags at the end of content
|
|
274
|
+
const tagStarts = [];
|
|
275
|
+
const tagStartRegex = /<([A-Z][a-zA-Z0-9]*)/g;
|
|
276
|
+
let match;
|
|
277
|
+
while ((match = tagStartRegex.exec(content)) !== null) {
|
|
278
|
+
const name = match[1];
|
|
279
|
+
if (name !== undefined) {
|
|
280
|
+
tagStarts.push({ name, index: match.index });
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
// For each tag start, check if there's a closing >
|
|
284
|
+
for (let i = 0; i < tagStarts.length; i++) {
|
|
285
|
+
const start = tagStarts[i];
|
|
286
|
+
if (!start)
|
|
287
|
+
continue;
|
|
288
|
+
const endBound = tagStarts[i + 1]?.index ?? content.length;
|
|
289
|
+
const tagContent = content.slice(start.index, endBound);
|
|
290
|
+
if (!tagContent.includes('>')) {
|
|
291
|
+
throw createParseError(`Invalid MDX syntax: incomplete tag <${start.name}`, content, start.index);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
// Check for invalid prop syntax: prop=>
|
|
295
|
+
const invalidPropMatch = content.match(/\w+=\s*>/);
|
|
296
|
+
if (invalidPropMatch) {
|
|
297
|
+
const position = content.indexOf(invalidPropMatch[0]);
|
|
298
|
+
throw createParseError('Invalid MDX syntax: incomplete prop value', content, position);
|
|
299
|
+
}
|
|
300
|
+
// Validate matching open/close tags
|
|
301
|
+
const allTagsRegex = /<\/?([A-Z][a-zA-Z0-9]*)[\s\S]*?>/g;
|
|
302
|
+
const tagMatches = [];
|
|
303
|
+
while ((match = allTagsRegex.exec(content)) !== null) {
|
|
304
|
+
const full = match[0];
|
|
305
|
+
const name = match[1];
|
|
306
|
+
if (name === undefined)
|
|
307
|
+
continue;
|
|
308
|
+
if (full.startsWith('</')) {
|
|
309
|
+
tagMatches.push({ name, type: 'close', full });
|
|
310
|
+
}
|
|
311
|
+
else if (full.trimEnd().endsWith('/>')) {
|
|
312
|
+
tagMatches.push({ name, type: 'selfClose', full });
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
tagMatches.push({ name, type: 'open', full });
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
// Count opens and closes per tag name
|
|
319
|
+
const openCount = {};
|
|
320
|
+
const closeCount = {};
|
|
321
|
+
for (const tag of tagMatches) {
|
|
322
|
+
if (tag.type === 'open') {
|
|
323
|
+
openCount[tag.name] = (openCount[tag.name] || 0) + 1;
|
|
324
|
+
}
|
|
325
|
+
else if (tag.type === 'close') {
|
|
326
|
+
closeCount[tag.name] = (closeCount[tag.name] || 0) + 1;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
// Each open tag should have a matching close tag
|
|
330
|
+
for (const name of Object.keys(openCount)) {
|
|
331
|
+
const opens = openCount[name] || 0;
|
|
332
|
+
const closes = closeCount[name] || 0;
|
|
333
|
+
if (opens > closes) {
|
|
334
|
+
throw createParseError(`Invalid MDX syntax: unclosed <${name}> tag`, content);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Serialize props to JSX attribute string
|
|
340
|
+
*
|
|
341
|
+
* @param props - Props object
|
|
342
|
+
* @returns JSX attribute string
|
|
343
|
+
*/
|
|
344
|
+
export function serializeProps(props) {
|
|
345
|
+
return Object.entries(props)
|
|
346
|
+
.map(([k, v]) => {
|
|
347
|
+
if (typeof v === 'string') {
|
|
348
|
+
return `${k}="${v}"`;
|
|
349
|
+
}
|
|
350
|
+
return `${k}={${JSON.stringify(v)}}`;
|
|
351
|
+
})
|
|
352
|
+
.join(' ');
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Sort object keys for consistent hashing
|
|
356
|
+
*
|
|
357
|
+
* @param obj - Object to sort
|
|
358
|
+
* @returns Object with sorted keys
|
|
359
|
+
*/
|
|
360
|
+
export function sortObject(obj) {
|
|
361
|
+
const sorted = {};
|
|
362
|
+
for (const key of Object.keys(obj).sort()) {
|
|
363
|
+
const value = obj[key];
|
|
364
|
+
sorted[key] =
|
|
365
|
+
value && typeof value === 'object' && !Array.isArray(value)
|
|
366
|
+
? sortObject(value)
|
|
367
|
+
: value;
|
|
368
|
+
}
|
|
369
|
+
return sorted;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Create a cache key for MDX props generation
|
|
373
|
+
*
|
|
374
|
+
* @param componentName - Component name
|
|
375
|
+
* @param schema - Component schema
|
|
376
|
+
* @param context - Frontmatter context
|
|
377
|
+
* @returns Cache key string
|
|
378
|
+
*/
|
|
379
|
+
export function createMDXCacheKey(componentName, schema, context) {
|
|
380
|
+
const schemaHash = hashContent(JSON.stringify(sortObject(schema)));
|
|
381
|
+
const contextHash = context ? hashContent(JSON.stringify(sortObject(context))) : '';
|
|
382
|
+
return `mdx:${componentName}:${schemaHash}:${contextHash}`;
|
|
383
|
+
}
|
|
384
|
+
//# sourceMappingURL=mdx-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mdx-utils.js","sourceRoot":"","sources":["../src/mdx-utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAA;AAE1C;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,IAAI,IAAI,GAAG,CAAC,CAAA;IACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,MAAM,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;QAClC,IAAI,GAAG,CAAC,IAAI,IAAI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ACD,OAAO,GAAG,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAA;IACtC,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,CAAC,CAAA;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,GAA4B;IACrD,MAAM,MAAM,GAA4B,EAAE,CAAA;IAC1C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;QAC1C,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAA;QACtB,MAAM,CAAC,GAAG,CAAC;YACT,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;gBACzD,CAAC,CAAC,UAAU,CAAC,KAAgC,CAAC;gBAC9C,CAAC,CAAC,KAAK,CAAA;IACb,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAC/B,aAAqB,EACrB,MAA8B,EAC9B,OAAiC;IAEjC,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IAClE,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IACnF,OAAO,OAAO,aAAa,IAAI,UAAU,IAAI,WAAW,EAAE,CAAA;AAC5D,CAAC"}
|
package/dist/mdx.d.ts
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MDX parsing and rendering with AI-generated props
|
|
3
|
+
*
|
|
4
|
+
* Provides utilities for parsing MDX content, extracting component schemas,
|
|
5
|
+
* and rendering with AI-generated props.
|
|
6
|
+
*
|
|
7
|
+
* Key features:
|
|
8
|
+
* - Content-hash based caching for parsed MDX
|
|
9
|
+
* - Parallel prop generation for multiple components
|
|
10
|
+
* - Streaming-ready architecture
|
|
11
|
+
* - Graceful error handling with detailed messages
|
|
12
|
+
*
|
|
13
|
+
* @packageDocumentation
|
|
14
|
+
*/
|
|
15
|
+
export type { ParsedMDX, ComponentSchemas, MDXPropsGeneratorOptions, MDXPropsGenerator, RenderMDXOptions, CompileMDXOptions, CompiledMDXFunction, StreamMDXOptions, MDXCacheEntry, MDXParseError, CacheInvalidationStrategy, MDXCacheOptions, MDXCacheStats, } from './mdx-types.js';
|
|
16
|
+
import type { ParsedMDX, ComponentSchemas, MDXPropsGeneratorOptions, MDXPropsGenerator, RenderMDXOptions, CompileMDXOptions, CompiledMDXFunction, StreamMDXOptions, MDXCacheOptions, MDXCacheStats } from './mdx-types.js';
|
|
17
|
+
/**
|
|
18
|
+
* Configure the global MDX parse cache
|
|
19
|
+
*
|
|
20
|
+
* @param options - Cache configuration options
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* // Configure with larger cache and longer TTL
|
|
25
|
+
* configureMDXCache({
|
|
26
|
+
* maxSize: 500,
|
|
27
|
+
* ttl: 30 * 60 * 1000, // 30 minutes
|
|
28
|
+
* autoCleanup: true,
|
|
29
|
+
* })
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function configureMDXCache(options: MDXCacheOptions): void;
|
|
33
|
+
/**
|
|
34
|
+
* Get MDX cache statistics
|
|
35
|
+
*
|
|
36
|
+
* Useful for monitoring cache performance and tuning configuration.
|
|
37
|
+
*
|
|
38
|
+
* @returns Cache statistics
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* const stats = getMDXCacheStats()
|
|
43
|
+
* console.log(`Cache hit ratio: ${(stats.hitRatio * 100).toFixed(1)}%`)
|
|
44
|
+
* console.log(`Cache size: ${stats.size}/${stats.maxSize}`)
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function getMDXCacheStats(): MDXCacheStats;
|
|
48
|
+
/**
|
|
49
|
+
* Invalidate MDX cache entries by tag
|
|
50
|
+
*
|
|
51
|
+
* @param tag - Tag to invalidate
|
|
52
|
+
* @returns Number of entries invalidated
|
|
53
|
+
*/
|
|
54
|
+
export declare function invalidateMDXCacheByTag(tag: string): number;
|
|
55
|
+
/**
|
|
56
|
+
* Cleanup expired MDX cache entries
|
|
57
|
+
*
|
|
58
|
+
* @returns Number of entries removed
|
|
59
|
+
*/
|
|
60
|
+
export declare function cleanupMDXCache(): number;
|
|
61
|
+
/**
|
|
62
|
+
* Options for parsing MDX
|
|
63
|
+
*/
|
|
64
|
+
export interface ParseMDXOptions {
|
|
65
|
+
/**
|
|
66
|
+
* Tags to associate with the cached result for group invalidation
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* parseMDX(content, { tags: ['page:/products', 'component:Hero'] })
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
tags?: string[];
|
|
74
|
+
/**
|
|
75
|
+
* Skip caching for this parse operation
|
|
76
|
+
*/
|
|
77
|
+
skipCache?: boolean;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Parse MDX content string
|
|
81
|
+
*
|
|
82
|
+
* Extracts frontmatter, identifies components, and parses component props.
|
|
83
|
+
* Results are cached based on content hash for performance.
|
|
84
|
+
*
|
|
85
|
+
* @param mdx - MDX content string
|
|
86
|
+
* @param options - Parse options (optional)
|
|
87
|
+
* @returns Parsed MDX structure
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* const result = parseMDX(`---
|
|
92
|
+
* title: Hello
|
|
93
|
+
* ---
|
|
94
|
+
*
|
|
95
|
+
* # {title}
|
|
96
|
+
*
|
|
97
|
+
* <Hero />
|
|
98
|
+
* `)
|
|
99
|
+
*
|
|
100
|
+
* console.log(result.frontmatter.title) // 'Hello'
|
|
101
|
+
* console.log(result.components) // ['Hero']
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```ts
|
|
106
|
+
* // Parse with cache tags for group invalidation
|
|
107
|
+
* const result = parseMDX(content, {
|
|
108
|
+
* tags: ['page:/home', 'component:Hero']
|
|
109
|
+
* })
|
|
110
|
+
*
|
|
111
|
+
* // Later, invalidate all home page entries
|
|
112
|
+
* invalidateMDXCacheByTag('page:/home')
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
export declare function parseMDX(mdx: string, options?: ParseMDXOptions): ParsedMDX;
|
|
116
|
+
/**
|
|
117
|
+
* Extract prop schemas from MDX component usage
|
|
118
|
+
*
|
|
119
|
+
* Analyzes component tags in MDX to infer prop schemas.
|
|
120
|
+
*
|
|
121
|
+
* @param mdx - MDX content string
|
|
122
|
+
* @returns Schemas for each component
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```ts
|
|
126
|
+
* const schemas = extractComponentSchemas(`
|
|
127
|
+
* <Card title="Hello" count={5} />
|
|
128
|
+
* `)
|
|
129
|
+
*
|
|
130
|
+
* // schemas.Card = { title: 'title (string)', count: 'count (number)' }
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
export declare function extractComponentSchemas(mdx: string): ComponentSchemas;
|
|
134
|
+
/**
|
|
135
|
+
* Create an MDX props generator
|
|
136
|
+
*
|
|
137
|
+
* The generator uses content-hash based caching and supports parallel
|
|
138
|
+
* generation for multiple components.
|
|
139
|
+
*
|
|
140
|
+
* @param options - Generator options
|
|
141
|
+
* @returns MDX props generator instance
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```ts
|
|
145
|
+
* const generator = createMDXPropsGenerator({
|
|
146
|
+
* schemas: {
|
|
147
|
+
* Hero: { title: 'Hero title', subtitle: 'Hero subtitle' },
|
|
148
|
+
* },
|
|
149
|
+
* cache: true,
|
|
150
|
+
* maxParallel: 3,
|
|
151
|
+
* })
|
|
152
|
+
*
|
|
153
|
+
* const props = await generator.generate(`<Hero />`)
|
|
154
|
+
* // props.Hero = { title: '...', subtitle: '...' }
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
export declare function createMDXPropsGenerator(options: MDXPropsGeneratorOptions): MDXPropsGenerator;
|
|
158
|
+
/**
|
|
159
|
+
* Render MDX with injected props
|
|
160
|
+
*
|
|
161
|
+
* @param mdx - MDX content string
|
|
162
|
+
* @param props - Props for each component
|
|
163
|
+
* @param options - Render options
|
|
164
|
+
* @returns Rendered content (string or stream)
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```ts
|
|
168
|
+
* const html = await renderMDXWithProps(
|
|
169
|
+
* `<Hero title="Welcome" />`,
|
|
170
|
+
* { Hero: { title: 'Welcome', subtitle: 'To the site' } }
|
|
171
|
+
* )
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
export declare function renderMDXWithProps(mdx: string, props: Record<string, Record<string, unknown> | null>, options?: RenderMDXOptions): Promise<string | ReadableStream<string>>;
|
|
175
|
+
/**
|
|
176
|
+
* Stream MDX content with injected props
|
|
177
|
+
*
|
|
178
|
+
* Returns a ReadableStream for progressive rendering of MDX content.
|
|
179
|
+
*
|
|
180
|
+
* @param mdx - MDX content string
|
|
181
|
+
* @param props - Props for each component
|
|
182
|
+
* @param options - Stream options
|
|
183
|
+
* @returns ReadableStream of rendered content
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```ts
|
|
187
|
+
* const stream = await streamMDXWithProps(
|
|
188
|
+
* `<Hero title="Welcome" />`,
|
|
189
|
+
* { Hero: { title: 'Welcome', subtitle: 'To the site' } }
|
|
190
|
+
* )
|
|
191
|
+
*
|
|
192
|
+
* const reader = stream.getReader()
|
|
193
|
+
* while (true) {
|
|
194
|
+
* const { done, value } = await reader.read()
|
|
195
|
+
* if (done) break
|
|
196
|
+
* console.log(new TextDecoder().decode(value))
|
|
197
|
+
* }
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
export declare function streamMDXWithProps(mdx: string, props: Record<string, Record<string, unknown>>, options?: StreamMDXOptions): Promise<ReadableStream<Uint8Array>>;
|
|
201
|
+
/**
|
|
202
|
+
* Compile MDX to an executable function
|
|
203
|
+
*
|
|
204
|
+
* Compilation is lazy - the MDX is parsed once, and the returned function
|
|
205
|
+
* can be called multiple times with different props.
|
|
206
|
+
*
|
|
207
|
+
* @param mdx - MDX content string
|
|
208
|
+
* @param options - Compile options
|
|
209
|
+
* @returns Compiled function that accepts props
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```ts
|
|
213
|
+
* const compiled = await compileMDX(`<Greeting name="World" />`)
|
|
214
|
+
* const result = compiled({ Greeting: { name: 'World' } })
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
export declare function compileMDX(mdx: string, options?: CompileMDXOptions): Promise<CompiledMDXFunction>;
|
|
218
|
+
/**
|
|
219
|
+
* Clear the MDX parse cache
|
|
220
|
+
*
|
|
221
|
+
* Use this when you need to force re-parsing of all MDX content.
|
|
222
|
+
*/
|
|
223
|
+
export declare function clearMDXCache(): void;
|
|
224
|
+
/**
|
|
225
|
+
* Get the current MDX parse cache size
|
|
226
|
+
*
|
|
227
|
+
* @returns Number of cached parse results
|
|
228
|
+
*/
|
|
229
|
+
export declare function getMDXCacheSize(): number;
|
|
230
|
+
//# sourceMappingURL=mdx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mdx.d.ts","sourceRoot":"","sources":["../src/mdx.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAkBH,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,wBAAwB,EACxB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EAC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