@theseus.run/jsx-md 0.1.0 → 0.1.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/package.json +3 -2
- package/src/jsx-runtime.ts +5 -5
- package/src/render.ts +3 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theseus.run/jsx-md",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "JSX/TSX renderer for Markdown. Write agent prompts and LLM instructions as typed, composable components. Zero runtime dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Roman Dubinin <romanonthego@gmail.com> (https://romanonthego.com)",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
|
-
"test": "bun test"
|
|
25
|
+
"test": "bun test",
|
|
26
|
+
"typecheck": "tsc"
|
|
26
27
|
},
|
|
27
28
|
"files": [
|
|
28
29
|
"src/index.ts",
|
package/src/jsx-runtime.ts
CHANGED
|
@@ -36,7 +36,7 @@ export type VNode =
|
|
|
36
36
|
| ReadonlyArray<VNode>;
|
|
37
37
|
|
|
38
38
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
|
-
type Component<P = any> = (props: P) =>
|
|
39
|
+
type Component<P = any> = (props: P) => VNode;
|
|
40
40
|
|
|
41
41
|
// ---------------------------------------------------------------------------
|
|
42
42
|
// JSX namespace
|
|
@@ -45,10 +45,10 @@ type Component<P = any> = (props: P) => string;
|
|
|
45
45
|
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
46
46
|
export namespace JSX {
|
|
47
47
|
/**
|
|
48
|
-
* JSX.Element is VNode
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
48
|
+
* JSX.Element is VNode so that components returning any valid VNode
|
|
49
|
+
* (string, VNodeElement, Fragment, null, etc.) satisfy TypeScript's
|
|
50
|
+
* component return-type check. The jsx() factory always produces
|
|
51
|
+
* VNodeElement at runtime; the wider union is only for type-checking.
|
|
52
52
|
*/
|
|
53
53
|
export type Element = VNode;
|
|
54
54
|
|
package/src/render.ts
CHANGED
|
@@ -50,8 +50,9 @@ export function render(node: VNode): string {
|
|
|
50
50
|
return `<${el.type}${attrStr}>\n${inner.trimEnd()}\n</${el.type}>\n`;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
// Function component — call with its props (children still as VNode)
|
|
54
|
-
|
|
53
|
+
// Function component — call with its props (children still as VNode),
|
|
54
|
+
// then recurse in case the component returned a VNode (e.g. a Fragment).
|
|
55
|
+
return render(el.type(el.props));
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
// Register render with Fragment immediately on module init.
|