@limo-labs/deity 0.3.0-alpha.0 → 0.3.0-alpha.1
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/index.cjs +106 -78
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -8
- package/dist/index.d.ts +12 -8
- package/dist/index.js +106 -78
- package/dist/index.js.map +1 -1
- package/dist/{jsx-dev-runtime-BQMsrQII.d.cts → jsx-dev-runtime-CCicXopP.d.cts} +37 -32
- package/dist/{jsx-dev-runtime-BQMsrQII.d.ts → jsx-dev-runtime-CCicXopP.d.ts} +37 -32
- package/dist/jsx-dev-runtime.cjs.map +1 -1
- package/dist/jsx-dev-runtime.d.cts +1 -1
- package/dist/jsx-dev-runtime.d.ts +1 -1
- package/dist/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx-runtime.cjs.map +1 -1
- package/dist/jsx-runtime.d.cts +1 -1
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js.map +1 -1
- package/package.json +1 -1
|
@@ -1006,12 +1006,12 @@ interface Validator {
|
|
|
1006
1006
|
interface AgentComponent<I = unknown, O = unknown> {
|
|
1007
1007
|
/** Unique stage identifier */
|
|
1008
1008
|
id: string;
|
|
1009
|
+
/** Agent execution mode: 'llm' (default) calls LLM, 'pure' runs code only */
|
|
1010
|
+
mode?: 'llm' | 'pure';
|
|
1009
1011
|
/** Input validation schema */
|
|
1010
1012
|
inputSchema: ZodSchema<I>;
|
|
1011
1013
|
/** Output validation schema */
|
|
1012
1014
|
outputSchema: ZodSchema<O>;
|
|
1013
|
-
/** Execution mode: 'llm' (default) requires LLM adapter, 'pure' skips LLM */
|
|
1014
|
-
mode?: 'llm' | 'pure';
|
|
1015
1015
|
/**
|
|
1016
1016
|
* Build prompt messages (declarative)
|
|
1017
1017
|
* Component declares what to send, runtime controls execution
|
|
@@ -1277,6 +1277,8 @@ interface AgentNode<I = unknown, O = unknown> extends ASTNode {
|
|
|
1277
1277
|
description?: string;
|
|
1278
1278
|
/** Optional tags for categorization */
|
|
1279
1279
|
tags?: string[];
|
|
1280
|
+
/** Agent execution mode: 'llm' (default) calls LLM, 'pure' runs code only */
|
|
1281
|
+
mode?: 'llm' | 'pure';
|
|
1280
1282
|
/** Optional loop-level validator (validates during LLM loop) */
|
|
1281
1283
|
loopValidator?: Validator;
|
|
1282
1284
|
/** Optional LLM loop configuration */
|
|
@@ -1288,10 +1290,8 @@ interface AgentNode<I = unknown, O = unknown> extends ASTNode {
|
|
|
1288
1290
|
};
|
|
1289
1291
|
/** Optional tool definitions (static array) */
|
|
1290
1292
|
tools?: ToolSpec[];
|
|
1291
|
-
/** Execution mode: 'llm' (default) requires LLM adapter, 'pure' skips LLM */
|
|
1292
|
-
mode?: 'llm' | 'pure';
|
|
1293
1293
|
};
|
|
1294
|
-
/** Child nodes (Prompt is required for
|
|
1294
|
+
/** Child nodes (Prompt is required for llm mode, optional for pure mode) */
|
|
1295
1295
|
children: (PromptNode | ObserveNode | ResultNode | ValidateNode | RetryNode | ToolsNode)[];
|
|
1296
1296
|
}
|
|
1297
1297
|
/**
|
|
@@ -1770,49 +1770,54 @@ declare function jsxs<T extends ASTNode = ASTNode>(type: JSXElementType | ((prop
|
|
|
1770
1770
|
*/
|
|
1771
1771
|
declare const Fragment: unique symbol;
|
|
1772
1772
|
/**
|
|
1773
|
-
* JSX Namespace
|
|
1773
|
+
* Exported JSX Namespace
|
|
1774
1774
|
*
|
|
1775
|
-
*
|
|
1775
|
+
* TypeScript 5.1+ resolves JSX types from the **exported** `JSX` namespace
|
|
1776
|
+
* of the `{jsxImportSource}/jsx-runtime` module. This takes priority over
|
|
1777
|
+
* any global `JSX` namespace (including the one from `@types/react`).
|
|
1778
|
+
*
|
|
1779
|
+
* Without this export, projects that have both `@limo-labs/deity` and
|
|
1780
|
+
* `@types/react` installed will get TS2786 errors because React's global
|
|
1781
|
+
* JSX declarations override Deity's `declare global { namespace JSX }`.
|
|
1782
|
+
*/
|
|
1783
|
+
declare namespace JSX {
|
|
1784
|
+
type Element = any;
|
|
1785
|
+
type ElementType = any;
|
|
1786
|
+
interface IntrinsicElements {
|
|
1787
|
+
[elemName: string]: any;
|
|
1788
|
+
}
|
|
1789
|
+
interface ElementClass {
|
|
1790
|
+
render(): any;
|
|
1791
|
+
}
|
|
1792
|
+
interface ElementAttributesProperty {
|
|
1793
|
+
props: {};
|
|
1794
|
+
}
|
|
1795
|
+
interface ElementChildrenAttribute {
|
|
1796
|
+
children: {};
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
/**
|
|
1800
|
+
* Global JSX Namespace (backward compatibility)
|
|
1801
|
+
*
|
|
1802
|
+
* Kept for projects that don't use `jsxImportSource` or use older TypeScript
|
|
1803
|
+
* versions (< 5.1) that rely on the global `JSX` namespace.
|
|
1776
1804
|
*/
|
|
1777
1805
|
declare global {
|
|
1778
1806
|
namespace JSX {
|
|
1779
|
-
/**
|
|
1780
|
-
* Element type (return type of JSX expressions)
|
|
1781
|
-
*
|
|
1782
|
-
* Instead of fixing this to ASTNode, we leave it generic so TypeScript
|
|
1783
|
-
* can infer the specific return type from the component function.
|
|
1784
|
-
*/
|
|
1785
1807
|
type Element = any;
|
|
1786
|
-
/**
|
|
1787
|
-
* Intrinsic elements (built-in HTML-like elements)
|
|
1788
|
-
*
|
|
1789
|
-
* In Deity TSX, we don't use intrinsic elements.
|
|
1790
|
-
* All elements are explicit component types.
|
|
1791
|
-
*/
|
|
1792
1808
|
interface IntrinsicElements {
|
|
1793
|
-
[elemName: string]:
|
|
1809
|
+
[elemName: string]: any;
|
|
1794
1810
|
}
|
|
1795
|
-
/**
|
|
1796
|
-
* Element class (for class components)
|
|
1797
|
-
*
|
|
1798
|
-
* Deity TSX only uses function components.
|
|
1799
|
-
*/
|
|
1800
1811
|
interface ElementClass {
|
|
1801
1812
|
render(): any;
|
|
1802
1813
|
}
|
|
1803
|
-
/**
|
|
1804
|
-
* Element attributes property
|
|
1805
|
-
*/
|
|
1806
1814
|
interface ElementAttributesProperty {
|
|
1807
1815
|
props: {};
|
|
1808
1816
|
}
|
|
1809
|
-
/**
|
|
1810
|
-
* Element children attribute
|
|
1811
|
-
*/
|
|
1812
1817
|
interface ElementChildrenAttribute {
|
|
1813
1818
|
children: {};
|
|
1814
1819
|
}
|
|
1815
1820
|
}
|
|
1816
1821
|
}
|
|
1817
1822
|
|
|
1818
|
-
export { isObserveNode as $, type AgentNode as A, type MemoryConfig as B, ConversationManager as C, type SessionConfig as D, type ExecutionContext as E, type JSXElementType as F, type GenerationConfig as G, type JSXProps as H, type LLMLoopState as I, type JSXComponent as J, type LLMResponse as K, type LLMLoopResult as L, type Message as M, type MessageRole as N, type ObserveNode as O, type PromptNode as P, type TemplatePart as Q, type ResultNode as R, type SystemNode as S, type ToolSpec as T, type UserNode as U, type Validator as V, type WorkflowChildNode as W, type ToolCall as X, type ToolResult as Y, type ValidationRule as Z, isAgentNode as _, type ValidationRules as a, isPromptNode as a0, isResultNode as a1, isRetryNode as a2, isSystemNode as a3, isToolDefNode as a4, isToolRefNode as a5, isToolsNode as a6, isUserNode as a7, isValidateNode as a8, isWorkflowConditionalNode as a9, isWorkflowForEachNode as aa, isWorkflowLoopNode as ab, isWorkflowNode as ac, isWorkflowParallelNode as ad, isWorkflowSequenceNode as ae, Fragment as af,
|
|
1823
|
+
export { isObserveNode as $, type AgentNode as A, type MemoryConfig as B, ConversationManager as C, type SessionConfig as D, type ExecutionContext as E, type JSXElementType as F, type GenerationConfig as G, type JSXProps as H, type LLMLoopState as I, type JSXComponent as J, type LLMResponse as K, type LLMLoopResult as L, type Message as M, type MessageRole as N, type ObserveNode as O, type PromptNode as P, type TemplatePart as Q, type ResultNode as R, type SystemNode as S, type ToolSpec as T, type UserNode as U, type Validator as V, type WorkflowChildNode as W, type ToolCall as X, type ToolResult as Y, type ValidationRule as Z, isAgentNode as _, type ValidationRules as a, isPromptNode as a0, isResultNode as a1, isRetryNode as a2, isSystemNode as a3, isToolDefNode as a4, isToolRefNode as a5, isToolsNode as a6, isUserNode as a7, isValidateNode as a8, isWorkflowConditionalNode as a9, isWorkflowForEachNode as aa, isWorkflowLoopNode as ab, isWorkflowNode as ac, isWorkflowParallelNode as ad, isWorkflowSequenceNode as ae, Fragment as af, JSX as ag, jsx as ah, jsxs as ai, type ValidateNode as b, type RetryNode as c, type ToolDefNode as d, type ToolsNode as e, type ToolRefNode as f, type WorkflowSequenceNode as g, type WorkflowParallelNode as h, type WorkflowConditionalNode as i, type WorkflowLoopNode as j, type WorkflowForEachNode as k, type WorkflowNode as l, type AgentComponent as m, type WorkflowConfig as n, type ExecutionNode as o, type ASTNode as p, type ValidationResult as q, type LLMAdapter as r, type StateStore as s, type TraceLogger as t, type TraceEntry as u, type ExecutionStats as v, LimoMemoryManager as w, type UIUpdateBridge as x, type SessionStore as y, type ConversationConfig as z };
|
|
@@ -1006,12 +1006,12 @@ interface Validator {
|
|
|
1006
1006
|
interface AgentComponent<I = unknown, O = unknown> {
|
|
1007
1007
|
/** Unique stage identifier */
|
|
1008
1008
|
id: string;
|
|
1009
|
+
/** Agent execution mode: 'llm' (default) calls LLM, 'pure' runs code only */
|
|
1010
|
+
mode?: 'llm' | 'pure';
|
|
1009
1011
|
/** Input validation schema */
|
|
1010
1012
|
inputSchema: ZodSchema<I>;
|
|
1011
1013
|
/** Output validation schema */
|
|
1012
1014
|
outputSchema: ZodSchema<O>;
|
|
1013
|
-
/** Execution mode: 'llm' (default) requires LLM adapter, 'pure' skips LLM */
|
|
1014
|
-
mode?: 'llm' | 'pure';
|
|
1015
1015
|
/**
|
|
1016
1016
|
* Build prompt messages (declarative)
|
|
1017
1017
|
* Component declares what to send, runtime controls execution
|
|
@@ -1277,6 +1277,8 @@ interface AgentNode<I = unknown, O = unknown> extends ASTNode {
|
|
|
1277
1277
|
description?: string;
|
|
1278
1278
|
/** Optional tags for categorization */
|
|
1279
1279
|
tags?: string[];
|
|
1280
|
+
/** Agent execution mode: 'llm' (default) calls LLM, 'pure' runs code only */
|
|
1281
|
+
mode?: 'llm' | 'pure';
|
|
1280
1282
|
/** Optional loop-level validator (validates during LLM loop) */
|
|
1281
1283
|
loopValidator?: Validator;
|
|
1282
1284
|
/** Optional LLM loop configuration */
|
|
@@ -1288,10 +1290,8 @@ interface AgentNode<I = unknown, O = unknown> extends ASTNode {
|
|
|
1288
1290
|
};
|
|
1289
1291
|
/** Optional tool definitions (static array) */
|
|
1290
1292
|
tools?: ToolSpec[];
|
|
1291
|
-
/** Execution mode: 'llm' (default) requires LLM adapter, 'pure' skips LLM */
|
|
1292
|
-
mode?: 'llm' | 'pure';
|
|
1293
1293
|
};
|
|
1294
|
-
/** Child nodes (Prompt is required for
|
|
1294
|
+
/** Child nodes (Prompt is required for llm mode, optional for pure mode) */
|
|
1295
1295
|
children: (PromptNode | ObserveNode | ResultNode | ValidateNode | RetryNode | ToolsNode)[];
|
|
1296
1296
|
}
|
|
1297
1297
|
/**
|
|
@@ -1770,49 +1770,54 @@ declare function jsxs<T extends ASTNode = ASTNode>(type: JSXElementType | ((prop
|
|
|
1770
1770
|
*/
|
|
1771
1771
|
declare const Fragment: unique symbol;
|
|
1772
1772
|
/**
|
|
1773
|
-
* JSX Namespace
|
|
1773
|
+
* Exported JSX Namespace
|
|
1774
1774
|
*
|
|
1775
|
-
*
|
|
1775
|
+
* TypeScript 5.1+ resolves JSX types from the **exported** `JSX` namespace
|
|
1776
|
+
* of the `{jsxImportSource}/jsx-runtime` module. This takes priority over
|
|
1777
|
+
* any global `JSX` namespace (including the one from `@types/react`).
|
|
1778
|
+
*
|
|
1779
|
+
* Without this export, projects that have both `@limo-labs/deity` and
|
|
1780
|
+
* `@types/react` installed will get TS2786 errors because React's global
|
|
1781
|
+
* JSX declarations override Deity's `declare global { namespace JSX }`.
|
|
1782
|
+
*/
|
|
1783
|
+
declare namespace JSX {
|
|
1784
|
+
type Element = any;
|
|
1785
|
+
type ElementType = any;
|
|
1786
|
+
interface IntrinsicElements {
|
|
1787
|
+
[elemName: string]: any;
|
|
1788
|
+
}
|
|
1789
|
+
interface ElementClass {
|
|
1790
|
+
render(): any;
|
|
1791
|
+
}
|
|
1792
|
+
interface ElementAttributesProperty {
|
|
1793
|
+
props: {};
|
|
1794
|
+
}
|
|
1795
|
+
interface ElementChildrenAttribute {
|
|
1796
|
+
children: {};
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
/**
|
|
1800
|
+
* Global JSX Namespace (backward compatibility)
|
|
1801
|
+
*
|
|
1802
|
+
* Kept for projects that don't use `jsxImportSource` or use older TypeScript
|
|
1803
|
+
* versions (< 5.1) that rely on the global `JSX` namespace.
|
|
1776
1804
|
*/
|
|
1777
1805
|
declare global {
|
|
1778
1806
|
namespace JSX {
|
|
1779
|
-
/**
|
|
1780
|
-
* Element type (return type of JSX expressions)
|
|
1781
|
-
*
|
|
1782
|
-
* Instead of fixing this to ASTNode, we leave it generic so TypeScript
|
|
1783
|
-
* can infer the specific return type from the component function.
|
|
1784
|
-
*/
|
|
1785
1807
|
type Element = any;
|
|
1786
|
-
/**
|
|
1787
|
-
* Intrinsic elements (built-in HTML-like elements)
|
|
1788
|
-
*
|
|
1789
|
-
* In Deity TSX, we don't use intrinsic elements.
|
|
1790
|
-
* All elements are explicit component types.
|
|
1791
|
-
*/
|
|
1792
1808
|
interface IntrinsicElements {
|
|
1793
|
-
[elemName: string]:
|
|
1809
|
+
[elemName: string]: any;
|
|
1794
1810
|
}
|
|
1795
|
-
/**
|
|
1796
|
-
* Element class (for class components)
|
|
1797
|
-
*
|
|
1798
|
-
* Deity TSX only uses function components.
|
|
1799
|
-
*/
|
|
1800
1811
|
interface ElementClass {
|
|
1801
1812
|
render(): any;
|
|
1802
1813
|
}
|
|
1803
|
-
/**
|
|
1804
|
-
* Element attributes property
|
|
1805
|
-
*/
|
|
1806
1814
|
interface ElementAttributesProperty {
|
|
1807
1815
|
props: {};
|
|
1808
1816
|
}
|
|
1809
|
-
/**
|
|
1810
|
-
* Element children attribute
|
|
1811
|
-
*/
|
|
1812
1817
|
interface ElementChildrenAttribute {
|
|
1813
1818
|
children: {};
|
|
1814
1819
|
}
|
|
1815
1820
|
}
|
|
1816
1821
|
}
|
|
1817
1822
|
|
|
1818
|
-
export { isObserveNode as $, type AgentNode as A, type MemoryConfig as B, ConversationManager as C, type SessionConfig as D, type ExecutionContext as E, type JSXElementType as F, type GenerationConfig as G, type JSXProps as H, type LLMLoopState as I, type JSXComponent as J, type LLMResponse as K, type LLMLoopResult as L, type Message as M, type MessageRole as N, type ObserveNode as O, type PromptNode as P, type TemplatePart as Q, type ResultNode as R, type SystemNode as S, type ToolSpec as T, type UserNode as U, type Validator as V, type WorkflowChildNode as W, type ToolCall as X, type ToolResult as Y, type ValidationRule as Z, isAgentNode as _, type ValidationRules as a, isPromptNode as a0, isResultNode as a1, isRetryNode as a2, isSystemNode as a3, isToolDefNode as a4, isToolRefNode as a5, isToolsNode as a6, isUserNode as a7, isValidateNode as a8, isWorkflowConditionalNode as a9, isWorkflowForEachNode as aa, isWorkflowLoopNode as ab, isWorkflowNode as ac, isWorkflowParallelNode as ad, isWorkflowSequenceNode as ae, Fragment as af,
|
|
1823
|
+
export { isObserveNode as $, type AgentNode as A, type MemoryConfig as B, ConversationManager as C, type SessionConfig as D, type ExecutionContext as E, type JSXElementType as F, type GenerationConfig as G, type JSXProps as H, type LLMLoopState as I, type JSXComponent as J, type LLMResponse as K, type LLMLoopResult as L, type Message as M, type MessageRole as N, type ObserveNode as O, type PromptNode as P, type TemplatePart as Q, type ResultNode as R, type SystemNode as S, type ToolSpec as T, type UserNode as U, type Validator as V, type WorkflowChildNode as W, type ToolCall as X, type ToolResult as Y, type ValidationRule as Z, isAgentNode as _, type ValidationRules as a, isPromptNode as a0, isResultNode as a1, isRetryNode as a2, isSystemNode as a3, isToolDefNode as a4, isToolRefNode as a5, isToolsNode as a6, isUserNode as a7, isValidateNode as a8, isWorkflowConditionalNode as a9, isWorkflowForEachNode as aa, isWorkflowLoopNode as ab, isWorkflowNode as ac, isWorkflowParallelNode as ad, isWorkflowSequenceNode as ae, Fragment as af, JSX as ag, jsx as ah, jsxs as ai, type ValidateNode as b, type RetryNode as c, type ToolDefNode as d, type ToolsNode as e, type ToolRefNode as f, type WorkflowSequenceNode as g, type WorkflowParallelNode as h, type WorkflowConditionalNode as i, type WorkflowLoopNode as j, type WorkflowForEachNode as k, type WorkflowNode as l, type AgentComponent as m, type WorkflowConfig as n, type ExecutionNode as o, type ASTNode as p, type ValidationResult as q, type LLMAdapter as r, type StateStore as s, type TraceLogger as t, type TraceEntry as u, type ExecutionStats as v, LimoMemoryManager as w, type UIUpdateBridge as x, type SessionStore as y, type ConversationConfig as z };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/jsx-runtime.ts"],"names":[],"mappings":";;;AAgEO,SAAS,GAAA,CACd,IAAA,EACA,KAAA,EACA,GAAA,EACG;AAEH,EAAA,MAAM,eAAA,GAAkB,SAAS,EAAC;AAGlC,EAAA,MAAM,EAAE,QAAA,EAAU,GAAG,SAAA,EAAU,GAAI,eAAA;AAGnC,EAAA,MAAM,aAAA,GAAgB,kBAAkB,QAAQ,CAAA;AAGhD,EAAA,IAAI,OAAO,SAAS,UAAA,EAAY;AAC9B,IAAA,OAAO,KAAK,EAAE,GAAG,SAAA,EAAW,QAAA,EAAU,eAAe,CAAA;AAAA,EACvD;AAGA,EAAA,OAAO,aAAA,CAAc,IAAA,EAAgB,SAAA,EAAW,aAAA,EAAe,GAAG,CAAA;AACpE;AAQO,SAAS,IAAA,CACd,IAAA,EACA,KAAA,EACA,GAAA,EACG;AAEH,EAAA,OAAO,GAAA,CAAI,IAAA,EAAM,KAAA,EAAO,GAAG,CAAA;AAC7B;AAKO,IAAM,QAAA,0BAAkB,UAAU;AAezC,SAAS,kBAAkB,QAAA,EAA8B;AACvD,EAAA,IAAI,QAAA,KAAa,MAAA,IAAa,QAAA,KAAa,IAAA,EAAM;AAC/C,IAAA,OAAO,EAA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T;AAKA,SAAS,UAAU,KAAA,EAAkC;AACnD,EAAA,OACE,OAAO,UAAU,QAAA,IACjB,KAAA,KAAU,QACV,MAAA,IAAU,KAAA,IACV,OAAQ,KAAA,CAAkB,IAAA,KAAS,QAAA;AAEvC","file":"jsx-dev-runtime.cjs","sourcesContent":["/**\r\n * Deity TSX - JSX Runtime\r\n *\r\n * This module implements the JSX Factory for transforming TSX syntax into AST nodes.\r\n *\r\n * Design principles:\r\n * - Pure transformation (no side effects)\r\n * - Type-safe (leverage TypeScript's JSX type checking)\r\n * - Minimal runtime overhead\r\n */\r\n\r\nimport type { ASTNode } from './ast/types.js';\r\n\r\n// ============================================================================\r\n// JSX Runtime Types\r\n// ============================================================================\r\n\r\n/**\r\n * JSX Element Type\r\n *\r\n * Can be:\r\n * - String (intrinsic element): 'div', 'span', etc.\r\n * - Component function: (props) => ASTNode\r\n */\r\nexport type JSXElementType = string | JSXComponent;\r\n\r\n/**\r\n * JSX Component Function\r\n */\r\nexport type JSXComponent = (props: JSXProps) => ASTNode;\r\n\r\n/**\r\n * JSX Props (generic)\r\n */\r\nexport interface JSXProps {\r\n children?: ASTNode | ASTNode[];\r\n [key: string]: unknown;\r\n}\r\n\r\n// ============================================================================\r\n// JSX Factory Implementation\r\n// ============================================================================\r\n\r\n/**\r\n * JSX Factory - Transform JSX calls into AST nodes\r\n *\r\n * This is the core function called by TypeScript when it encounters JSX syntax.\r\n *\r\n * @example\r\n * // TSX code:\r\n * <Agent id=\"test\" input={schema} output={schema}>\r\n * <Prompt>...</Prompt>\r\n * </Agent>\r\n *\r\n * // Compiled to:\r\n * jsx('Agent', { id: 'test', input: schema, output: schema }, [\r\n * jsx('Prompt', {}, [...])\r\n * ])\r\n *\r\n * @param type - Element type (string or component function)\r\n * @param props - Element props (includes children)\r\n * @param key - Optional key (for lists)\r\n * @returns AST Node\r\n */\r\nexport function jsx<T extends ASTNode = ASTNode>(\r\n type: JSXElementType | ((props: any) => T),\r\n props: JSXProps | null,\r\n key?: string\r\n): T {\r\n // Normalize props\r\n const normalizedProps = props ?? {};\r\n\r\n // Extract children from props\r\n const { children, ...restProps } = normalizedProps;\r\n\r\n // Normalize children to array\r\n const childrenArray = normalizeChildren(children);\r\n\r\n // Handle component functions\r\n if (typeof type === 'function') {\r\n return type({ ...restProps, children: childrenArray }) as T;\r\n }\r\n\r\n // Handle intrinsic elements (string type)\r\n return createASTNode(type as string, restProps, childrenArray, key) as T;\r\n}\r\n\r\n/**\r\n * JSX Fragment - For <></> syntax\r\n *\r\n * Fragments are not used in Deity TSX (we use explicit nodes),\r\n * but we implement it for completeness.\r\n */\r\nexport function jsxs<T extends ASTNode = ASTNode>(\r\n type: JSXElementType | ((props: any) => T),\r\n props: JSXProps | null,\r\n key?: string\r\n): T {\r\n // jsxs is the same as jsx in our implementation\r\n return jsx(type, props, key);\r\n}\r\n\r\n/**\r\n * JSX Fragment component\r\n */\r\nexport const Fragment = Symbol('Fragment');\r\n\r\n// ============================================================================\r\n// Helper Functions\r\n// ============================================================================\r\n\r\n/**\r\n * Normalize children into an array\r\n *\r\n * Children can be:\r\n * - Undefined/null (no children)\r\n * - Single child (ASTNode or primitive)\r\n * - Array of children\r\n * - Function (for computed children)\r\n */\r\nfunction normalizeChildren(children: unknown): ASTNode[] {\r\n if (children === undefined || children === null) {\r\n return [];\r\n }\r\n\r\n if (Array.isArray(children)) {\r\n return children\r\n .filter(child => child !== null && child !== undefined)\r\n .flatMap(child => normalizeChildren(child));\r\n }\r\n\r\n // If it's already an ASTNode, return it\r\n if (isASTNode(children)) {\r\n return [children];\r\n }\r\n\r\n // If it's a function, we'll store it as a special TextNode\r\n // (This is for computed content like {(ctx) => \"...\"}\r\n if (typeof children === 'function') {\r\n return [{\r\n type: 'ComputedText',\r\n props: { compute: children },\r\n }];\r\n }\r\n\r\n // If it's a primitive (string/number/boolean), create a TextNode\r\n if (typeof children === 'string' || typeof children === 'number' || typeof children === 'boolean') {\r\n return [{\r\n type: 'Text',\r\n props: { content: String(children) },\r\n }];\r\n }\r\n\r\n return [];\r\n}\r\n\r\n/**\r\n * Create an AST Node from JSX elements\r\n */\r\nfunction createASTNode(\r\n type: string,\r\n props: Record<string, unknown>,\r\n children: ASTNode[],\r\n key?: string\r\n): ASTNode {\r\n const node: ASTNode = {\r\n type,\r\n props: { ...props },\r\n };\r\n\r\n if (children.length > 0) {\r\n node.children = children;\r\n }\r\n\r\n if (key !== undefined) {\r\n node.props = { ...node.props, key };\r\n }\r\n\r\n return node;\r\n}\r\n\r\n/**\r\n * Type guard for ASTNode\r\n */\r\nfunction isASTNode(value: unknown): value is ASTNode {\r\n return (\r\n typeof value === 'object' &&\r\n value !== null &&\r\n 'type' in value &&\r\n typeof (value as ASTNode).type === 'string'\r\n );\r\n}\r\n\r\n// ============================================================================\r\n// TypeScript JSX Namespace\r\n// ============================================================================\r\n\r\n/**\r\n * JSX Namespace
|
|
1
|
+
{"version":3,"sources":["../src/jsx-runtime.ts"],"names":[],"mappings":";;;AAgEO,SAAS,GAAA,CACd,IAAA,EACA,KAAA,EACA,GAAA,EACG;AAEH,EAAA,MAAM,eAAA,GAAkB,SAAS,EAAC;AAGlC,EAAA,MAAM,EAAE,QAAA,EAAU,GAAG,SAAA,EAAU,GAAI,eAAA;AAGnC,EAAA,MAAM,aAAA,GAAgB,kBAAkB,QAAQ,CAAA;AAGhD,EAAA,IAAI,OAAO,SAAS,UAAA,EAAY;AAC9B,IAAA,OAAO,KAAK,EAAE,GAAG,SAAA,EAAW,QAAA,EAAU,eAAe,CAAA;AAAA,EACvD;AAGA,EAAA,OAAO,aAAA,CAAc,IAAA,EAAgB,SAAA,EAAW,aAAA,EAAe,GAAG,CAAA;AACpE;AAQO,SAAS,IAAA,CACd,IAAA,EACA,KAAA,EACA,GAAA,EACG;AAEH,EAAA,OAAO,GAAA,CAAI,IAAA,EAAM,KAAA,EAAO,GAAG,CAAA;AAC7B;AAKO,IAAM,QAAA,0BAAkB,UAAU;AAezC,SAAS,kBAAkB,QAAA,EAA8B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A,GAAQ,EAAE,GAAG,IAAA,CAAK,OAAO,GAAA,EAAI;AAAA,EACpC;AAEA,EAAA,OAAO,IAAA;AACT;AAKA,SAAS,UAAU,KAAA,EAAkC;AACnD,EAAA,OACE,OAAO,UAAU,QAAA,IACjB,KAAA,KAAU,QACV,MAAA,IAAU,KAAA,IACV,OAAQ,KAAA,CAAkB,IAAA,KAAS,QAAA;AAEvC","file":"jsx-dev-runtime.cjs","sourcesContent":["/**\r\n * Deity TSX - JSX Runtime\r\n *\r\n * This module implements the JSX Factory for transforming TSX syntax into AST nodes.\r\n *\r\n * Design principles:\r\n * - Pure transformation (no side effects)\r\n * - Type-safe (leverage TypeScript's JSX type checking)\r\n * - Minimal runtime overhead\r\n */\r\n\r\nimport type { ASTNode } from './ast/types.js';\r\n\r\n// ============================================================================\r\n// JSX Runtime Types\r\n// ============================================================================\r\n\r\n/**\r\n * JSX Element Type\r\n *\r\n * Can be:\r\n * - String (intrinsic element): 'div', 'span', etc.\r\n * - Component function: (props) => ASTNode\r\n */\r\nexport type JSXElementType = string | JSXComponent;\r\n\r\n/**\r\n * JSX Component Function\r\n */\r\nexport type JSXComponent = (props: JSXProps) => ASTNode;\r\n\r\n/**\r\n * JSX Props (generic)\r\n */\r\nexport interface JSXProps {\r\n children?: ASTNode | ASTNode[];\r\n [key: string]: unknown;\r\n}\r\n\r\n// ============================================================================\r\n// JSX Factory Implementation\r\n// ============================================================================\r\n\r\n/**\r\n * JSX Factory - Transform JSX calls into AST nodes\r\n *\r\n * This is the core function called by TypeScript when it encounters JSX syntax.\r\n *\r\n * @example\r\n * // TSX code:\r\n * <Agent id=\"test\" input={schema} output={schema}>\r\n * <Prompt>...</Prompt>\r\n * </Agent>\r\n *\r\n * // Compiled to:\r\n * jsx('Agent', { id: 'test', input: schema, output: schema }, [\r\n * jsx('Prompt', {}, [...])\r\n * ])\r\n *\r\n * @param type - Element type (string or component function)\r\n * @param props - Element props (includes children)\r\n * @param key - Optional key (for lists)\r\n * @returns AST Node\r\n */\r\nexport function jsx<T extends ASTNode = ASTNode>(\r\n type: JSXElementType | ((props: any) => T),\r\n props: JSXProps | null,\r\n key?: string\r\n): T {\r\n // Normalize props\r\n const normalizedProps = props ?? {};\r\n\r\n // Extract children from props\r\n const { children, ...restProps } = normalizedProps;\r\n\r\n // Normalize children to array\r\n const childrenArray = normalizeChildren(children);\r\n\r\n // Handle component functions\r\n if (typeof type === 'function') {\r\n return type({ ...restProps, children: childrenArray }) as T;\r\n }\r\n\r\n // Handle intrinsic elements (string type)\r\n return createASTNode(type as string, restProps, childrenArray, key) as T;\r\n}\r\n\r\n/**\r\n * JSX Fragment - For <></> syntax\r\n *\r\n * Fragments are not used in Deity TSX (we use explicit nodes),\r\n * but we implement it for completeness.\r\n */\r\nexport function jsxs<T extends ASTNode = ASTNode>(\r\n type: JSXElementType | ((props: any) => T),\r\n props: JSXProps | null,\r\n key?: string\r\n): T {\r\n // jsxs is the same as jsx in our implementation\r\n return jsx(type, props, key);\r\n}\r\n\r\n/**\r\n * JSX Fragment component\r\n */\r\nexport const Fragment = Symbol('Fragment');\r\n\r\n// ============================================================================\r\n// Helper Functions\r\n// ============================================================================\r\n\r\n/**\r\n * Normalize children into an array\r\n *\r\n * Children can be:\r\n * - Undefined/null (no children)\r\n * - Single child (ASTNode or primitive)\r\n * - Array of children\r\n * - Function (for computed children)\r\n */\r\nfunction normalizeChildren(children: unknown): ASTNode[] {\r\n if (children === undefined || children === null) {\r\n return [];\r\n }\r\n\r\n if (Array.isArray(children)) {\r\n return children\r\n .filter(child => child !== null && child !== undefined)\r\n .flatMap(child => normalizeChildren(child));\r\n }\r\n\r\n // If it's already an ASTNode, return it\r\n if (isASTNode(children)) {\r\n return [children];\r\n }\r\n\r\n // If it's a function, we'll store it as a special TextNode\r\n // (This is for computed content like {(ctx) => \"...\"}\r\n if (typeof children === 'function') {\r\n return [{\r\n type: 'ComputedText',\r\n props: { compute: children },\r\n }];\r\n }\r\n\r\n // If it's a primitive (string/number/boolean), create a TextNode\r\n if (typeof children === 'string' || typeof children === 'number' || typeof children === 'boolean') {\r\n return [{\r\n type: 'Text',\r\n props: { content: String(children) },\r\n }];\r\n }\r\n\r\n return [];\r\n}\r\n\r\n/**\r\n * Create an AST Node from JSX elements\r\n */\r\nfunction createASTNode(\r\n type: string,\r\n props: Record<string, unknown>,\r\n children: ASTNode[],\r\n key?: string\r\n): ASTNode {\r\n const node: ASTNode = {\r\n type,\r\n props: { ...props },\r\n };\r\n\r\n if (children.length > 0) {\r\n node.children = children;\r\n }\r\n\r\n if (key !== undefined) {\r\n node.props = { ...node.props, key };\r\n }\r\n\r\n return node;\r\n}\r\n\r\n/**\r\n * Type guard for ASTNode\r\n */\r\nfunction isASTNode(value: unknown): value is ASTNode {\r\n return (\r\n typeof value === 'object' &&\r\n value !== null &&\r\n 'type' in value &&\r\n typeof (value as ASTNode).type === 'string'\r\n );\r\n}\r\n\r\n// ============================================================================\r\n// TypeScript JSX Namespace (Module-scoped export)\r\n// ============================================================================\r\n\r\n/**\r\n * Exported JSX Namespace\r\n *\r\n * TypeScript 5.1+ resolves JSX types from the **exported** `JSX` namespace\r\n * of the `{jsxImportSource}/jsx-runtime` module. This takes priority over\r\n * any global `JSX` namespace (including the one from `@types/react`).\r\n *\r\n * Without this export, projects that have both `@limo-labs/deity` and\r\n * `@types/react` installed will get TS2786 errors because React's global\r\n * JSX declarations override Deity's `declare global { namespace JSX }`.\r\n */\r\nexport namespace JSX {\r\n export type Element = any;\r\n export type ElementType = any;\r\n\r\n export interface IntrinsicElements {\r\n [elemName: string]: any;\r\n }\r\n\r\n export interface ElementClass {\r\n render(): any;\r\n }\r\n\r\n export interface ElementAttributesProperty {\r\n props: {};\r\n }\r\n\r\n export interface ElementChildrenAttribute {\r\n children: {};\r\n }\r\n}\r\n\r\n// ============================================================================\r\n// TypeScript JSX Namespace (Global fallback)\r\n// ============================================================================\r\n\r\n/**\r\n * Global JSX Namespace (backward compatibility)\r\n *\r\n * Kept for projects that don't use `jsxImportSource` or use older TypeScript\r\n * versions (< 5.1) that rely on the global `JSX` namespace.\r\n */\r\ndeclare global {\r\n namespace JSX {\r\n type Element = any;\r\n\r\n interface IntrinsicElements {\r\n [elemName: string]: any;\r\n }\r\n\r\n interface ElementClass {\r\n render(): any;\r\n }\r\n\r\n interface ElementAttributesProperty {\r\n props: {};\r\n }\r\n\r\n interface ElementChildrenAttribute {\r\n children: {};\r\n }\r\n }\r\n}\r\n\r\n// ============================================================================\r\n// Exports\r\n// ============================================================================\r\n\r\nexport { jsx as jsxDEV };\r\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { af as Fragment, J as JSXComponent, F as JSXElementType, H as JSXProps,
|
|
1
|
+
export { af as Fragment, J as JSXComponent, F as JSXElementType, H as JSXProps, ah as jsx, ah as jsxDEV, ai as jsxs } from './jsx-dev-runtime-CCicXopP.cjs';
|
|
2
2
|
import 'zod';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { af as Fragment, J as JSXComponent, F as JSXElementType, H as JSXProps,
|
|
1
|
+
export { af as Fragment, J as JSXComponent, F as JSXElementType, H as JSXProps, ah as jsx, ah as jsxDEV, ai as jsxs } from './jsx-dev-runtime-CCicXopP.js';
|
|
2
2
|
import 'zod';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/jsx-runtime.ts"],"names":[],"mappings":";AAgEO,SAAS,GAAA,CACd,IAAA,EACA,KAAA,EACA,GAAA,EACG;AAEH,EAAA,MAAM,eAAA,GAAkB,SAAS,EAAC;AAGlC,EAAA,MAAM,EAAE,QAAA,EAAU,GAAG,SAAA,EAAU,GAAI,eAAA;AAGnC,EAAA,MAAM,aAAA,GAAgB,kBAAkB,QAAQ,CAAA;AAGhD,EAAA,IAAI,OAAO,SAAS,UAAA,EAAY;AAC9B,IAAA,OAAO,KAAK,EAAE,GAAG,SAAA,EAAW,QAAA,EAAU,eAAe,CAAA;AAAA,EACvD;AAGA,EAAA,OAAO,aAAA,CA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,IAAA,GAAgB;AAAA,IACpB,IAAA;AAAA,IACA,KAAA,EAAO,EAAE,GAAG,KAAA;AAAM,GACpB;AAEA,EAAA,IAAI,QAAA,CAAS,SAAS,CAAA,EAAG;AACvB,IAAA,IAAA,CAAK,QAAA,GAAW,QAAA;AAAA,EAClB;AAEA,EAAA,IAAI,QAAQ,MAAA,EAAW;AACrB,IAAA,IAAA,CAAK,KAAA,GAAQ,EAAE,GAAG,IAAA,CAAK,OAAO,GAAA,EAAI;AAAA,EACpC;AAEA,EAAA,OAAO,IAAA;AACT;AAKA,SAAS,UAAU,KAAA,EAAkC;AACnD,EAAA,OACE,OAAO,UAAU,QAAA,IACjB,KAAA,KAAU,QACV,MAAA,IAAU,KAAA,IACV,OAAQ,KAAA,CAAkB,IAAA,KAAS,QAAA;AAEvC","file":"jsx-dev-runtime.js","sourcesContent":["/**\r\n * Deity TSX - JSX Runtime\r\n *\r\n * This module implements the JSX Factory for transforming TSX syntax into AST nodes.\r\n *\r\n * Design principles:\r\n * - Pure transformation (no side effects)\r\n * - Type-safe (leverage TypeScript's JSX type checking)\r\n * - Minimal runtime overhead\r\n */\r\n\r\nimport type { ASTNode } from './ast/types.js';\r\n\r\n// ============================================================================\r\n// JSX Runtime Types\r\n// ============================================================================\r\n\r\n/**\r\n * JSX Element Type\r\n *\r\n * Can be:\r\n * - String (intrinsic element): 'div', 'span', etc.\r\n * - Component function: (props) => ASTNode\r\n */\r\nexport type JSXElementType = string | JSXComponent;\r\n\r\n/**\r\n * JSX Component Function\r\n */\r\nexport type JSXComponent = (props: JSXProps) => ASTNode;\r\n\r\n/**\r\n * JSX Props (generic)\r\n */\r\nexport interface JSXProps {\r\n children?: ASTNode | ASTNode[];\r\n [key: string]: unknown;\r\n}\r\n\r\n// ============================================================================\r\n// JSX Factory Implementation\r\n// ============================================================================\r\n\r\n/**\r\n * JSX Factory - Transform JSX calls into AST nodes\r\n *\r\n * This is the core function called by TypeScript when it encounters JSX syntax.\r\n *\r\n * @example\r\n * // TSX code:\r\n * <Agent id=\"test\" input={schema} output={schema}>\r\n * <Prompt>...</Prompt>\r\n * </Agent>\r\n *\r\n * // Compiled to:\r\n * jsx('Agent', { id: 'test', input: schema, output: schema }, [\r\n * jsx('Prompt', {}, [...])\r\n * ])\r\n *\r\n * @param type - Element type (string or component function)\r\n * @param props - Element props (includes children)\r\n * @param key - Optional key (for lists)\r\n * @returns AST Node\r\n */\r\nexport function jsx<T extends ASTNode = ASTNode>(\r\n type: JSXElementType | ((props: any) => T),\r\n props: JSXProps | null,\r\n key?: string\r\n): T {\r\n // Normalize props\r\n const normalizedProps = props ?? {};\r\n\r\n // Extract children from props\r\n const { children, ...restProps } = normalizedProps;\r\n\r\n // Normalize children to array\r\n const childrenArray = normalizeChildren(children);\r\n\r\n // Handle component functions\r\n if (typeof type === 'function') {\r\n return type({ ...restProps, children: childrenArray }) as T;\r\n }\r\n\r\n // Handle intrinsic elements (string type)\r\n return createASTNode(type as string, restProps, childrenArray, key) as T;\r\n}\r\n\r\n/**\r\n * JSX Fragment - For <></> syntax\r\n *\r\n * Fragments are not used in Deity TSX (we use explicit nodes),\r\n * but we implement it for completeness.\r\n */\r\nexport function jsxs<T extends ASTNode = ASTNode>(\r\n type: JSXElementType | ((props: any) => T),\r\n props: JSXProps | null,\r\n key?: string\r\n): T {\r\n // jsxs is the same as jsx in our implementation\r\n return jsx(type, props, key);\r\n}\r\n\r\n/**\r\n * JSX Fragment component\r\n */\r\nexport const Fragment = Symbol('Fragment');\r\n\r\n// ============================================================================\r\n// Helper Functions\r\n// ============================================================================\r\n\r\n/**\r\n * Normalize children into an array\r\n *\r\n * Children can be:\r\n * - Undefined/null (no children)\r\n * - Single child (ASTNode or primitive)\r\n * - Array of children\r\n * - Function (for computed children)\r\n */\r\nfunction normalizeChildren(children: unknown): ASTNode[] {\r\n if (children === undefined || children === null) {\r\n return [];\r\n }\r\n\r\n if (Array.isArray(children)) {\r\n return children\r\n .filter(child => child !== null && child !== undefined)\r\n .flatMap(child => normalizeChildren(child));\r\n }\r\n\r\n // If it's already an ASTNode, return it\r\n if (isASTNode(children)) {\r\n return [children];\r\n }\r\n\r\n // If it's a function, we'll store it as a special TextNode\r\n // (This is for computed content like {(ctx) => \"...\"}\r\n if (typeof children === 'function') {\r\n return [{\r\n type: 'ComputedText',\r\n props: { compute: children },\r\n }];\r\n }\r\n\r\n // If it's a primitive (string/number/boolean), create a TextNode\r\n if (typeof children === 'string' || typeof children === 'number' || typeof children === 'boolean') {\r\n return [{\r\n type: 'Text',\r\n props: { content: String(children) },\r\n }];\r\n }\r\n\r\n return [];\r\n}\r\n\r\n/**\r\n * Create an AST Node from JSX elements\r\n */\r\nfunction createASTNode(\r\n type: string,\r\n props: Record<string, unknown>,\r\n children: ASTNode[],\r\n key?: string\r\n): ASTNode {\r\n const node: ASTNode = {\r\n type,\r\n props: { ...props },\r\n };\r\n\r\n if (children.length > 0) {\r\n node.children = children;\r\n }\r\n\r\n if (key !== undefined) {\r\n node.props = { ...node.props, key };\r\n }\r\n\r\n return node;\r\n}\r\n\r\n/**\r\n * Type guard for ASTNode\r\n */\r\nfunction isASTNode(value: unknown): value is ASTNode {\r\n return (\r\n typeof value === 'object' &&\r\n value !== null &&\r\n 'type' in value &&\r\n typeof (value as ASTNode).type === 'string'\r\n );\r\n}\r\n\r\n// ============================================================================\r\n// TypeScript JSX Namespace\r\n// ============================================================================\r\n\r\n/**\r\n * JSX Namespace
|
|
1
|
+
{"version":3,"sources":["../src/jsx-runtime.ts"],"names":[],"mappings":";AAgEO,SAAS,GAAA,CACd,IAAA,EACA,KAAA,EACA,GAAA,EACG;AAEH,EAAA,MAAM,eAAA,GAAkB,SAAS,EAAC;AAGlC,EAAA,MAAM,EAAE,QAAA,EAAU,GAAG,SAAA,EAAU,GAAI,eAAA;AAGnC,EAAA,MAAM,aAAA,GAAgB,kBAAkB,QAAQ,CAAA;AAGhD,EAAA,IAAI,OAAO,SAAS,UAAA,EAAY;AAC9B,IAAA,OAAO,KAAK,E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ACV;AAKA,SAAS,aAAA,CACP,IAAA,EACA,KAAA,EACA,QAAA,EACA,GAAA,EACS;AACT,EAAA,MAAM,IAAA,GAAgB;AAAA,IACpB,IAAA;AAAA,IACA,KAAA,EAAO,EAAE,GAAG,KAAA;AAAM,GACpB;AAEA,EAAA,IAAI,QAAA,CAAS,SAAS,CAAA,EAAG;AACvB,IAAA,IAAA,CAAK,QAAA,GAAW,QAAA;AAAA,EAClB;AAEA,EAAA,IAAI,QAAQ,MAAA,EAAW;AACrB,IAAA,IAAA,CAAK,KAAA,GAAQ,EAAE,GAAG,IAAA,CAAK,OAAO,GAAA,EAAI;AAAA,EACpC;AAEA,EAAA,OAAO,IAAA;AACT;AAKA,SAAS,UAAU,KAAA,EAAkC;AACnD,EAAA,OACE,OAAO,UAAU,QAAA,IACjB,KAAA,KAAU,QACV,MAAA,IAAU,KAAA,IACV,OAAQ,KAAA,CAAkB,IAAA,KAAS,QAAA;AAEvC","file":"jsx-dev-runtime.js","sourcesContent":["/**\r\n * Deity TSX - JSX Runtime\r\n *\r\n * This module implements the JSX Factory for transforming TSX syntax into AST nodes.\r\n *\r\n * Design principles:\r\n * - Pure transformation (no side effects)\r\n * - Type-safe (leverage TypeScript's JSX type checking)\r\n * - Minimal runtime overhead\r\n */\r\n\r\nimport type { ASTNode } from './ast/types.js';\r\n\r\n// ============================================================================\r\n// JSX Runtime Types\r\n// ============================================================================\r\n\r\n/**\r\n * JSX Element Type\r\n *\r\n * Can be:\r\n * - String (intrinsic element): 'div', 'span', etc.\r\n * - Component function: (props) => ASTNode\r\n */\r\nexport type JSXElementType = string | JSXComponent;\r\n\r\n/**\r\n * JSX Component Function\r\n */\r\nexport type JSXComponent = (props: JSXProps) => ASTNode;\r\n\r\n/**\r\n * JSX Props (generic)\r\n */\r\nexport interface JSXProps {\r\n children?: ASTNode | ASTNode[];\r\n [key: string]: unknown;\r\n}\r\n\r\n// ============================================================================\r\n// JSX Factory Implementation\r\n// ============================================================================\r\n\r\n/**\r\n * JSX Factory - Transform JSX calls into AST nodes\r\n *\r\n * This is the core function called by TypeScript when it encounters JSX syntax.\r\n *\r\n * @example\r\n * // TSX code:\r\n * <Agent id=\"test\" input={schema} output={schema}>\r\n * <Prompt>...</Prompt>\r\n * </Agent>\r\n *\r\n * // Compiled to:\r\n * jsx('Agent', { id: 'test', input: schema, output: schema }, [\r\n * jsx('Prompt', {}, [...])\r\n * ])\r\n *\r\n * @param type - Element type (string or component function)\r\n * @param props - Element props (includes children)\r\n * @param key - Optional key (for lists)\r\n * @returns AST Node\r\n */\r\nexport function jsx<T extends ASTNode = ASTNode>(\r\n type: JSXElementType | ((props: any) => T),\r\n props: JSXProps | null,\r\n key?: string\r\n): T {\r\n // Normalize props\r\n const normalizedProps = props ?? {};\r\n\r\n // Extract children from props\r\n const { children, ...restProps } = normalizedProps;\r\n\r\n // Normalize children to array\r\n const childrenArray = normalizeChildren(children);\r\n\r\n // Handle component functions\r\n if (typeof type === 'function') {\r\n return type({ ...restProps, children: childrenArray }) as T;\r\n }\r\n\r\n // Handle intrinsic elements (string type)\r\n return createASTNode(type as string, restProps, childrenArray, key) as T;\r\n}\r\n\r\n/**\r\n * JSX Fragment - For <></> syntax\r\n *\r\n * Fragments are not used in Deity TSX (we use explicit nodes),\r\n * but we implement it for completeness.\r\n */\r\nexport function jsxs<T extends ASTNode = ASTNode>(\r\n type: JSXElementType | ((props: any) => T),\r\n props: JSXProps | null,\r\n key?: string\r\n): T {\r\n // jsxs is the same as jsx in our implementation\r\n return jsx(type, props, key);\r\n}\r\n\r\n/**\r\n * JSX Fragment component\r\n */\r\nexport const Fragment = Symbol('Fragment');\r\n\r\n// ============================================================================\r\n// Helper Functions\r\n// ============================================================================\r\n\r\n/**\r\n * Normalize children into an array\r\n *\r\n * Children can be:\r\n * - Undefined/null (no children)\r\n * - Single child (ASTNode or primitive)\r\n * - Array of children\r\n * - Function (for computed children)\r\n */\r\nfunction normalizeChildren(children: unknown): ASTNode[] {\r\n if (children === undefined || children === null) {\r\n return [];\r\n }\r\n\r\n if (Array.isArray(children)) {\r\n return children\r\n .filter(child => child !== null && child !== undefined)\r\n .flatMap(child => normalizeChildren(child));\r\n }\r\n\r\n // If it's already an ASTNode, return it\r\n if (isASTNode(children)) {\r\n return [children];\r\n }\r\n\r\n // If it's a function, we'll store it as a special TextNode\r\n // (This is for computed content like {(ctx) => \"...\"}\r\n if (typeof children === 'function') {\r\n return [{\r\n type: 'ComputedText',\r\n props: { compute: children },\r\n }];\r\n }\r\n\r\n // If it's a primitive (string/number/boolean), create a TextNode\r\n if (typeof children === 'string' || typeof children === 'number' || typeof children === 'boolean') {\r\n return [{\r\n type: 'Text',\r\n props: { content: String(children) },\r\n }];\r\n }\r\n\r\n return [];\r\n}\r\n\r\n/**\r\n * Create an AST Node from JSX elements\r\n */\r\nfunction createASTNode(\r\n type: string,\r\n props: Record<string, unknown>,\r\n children: ASTNode[],\r\n key?: string\r\n): ASTNode {\r\n const node: ASTNode = {\r\n type,\r\n props: { ...props },\r\n };\r\n\r\n if (children.length > 0) {\r\n node.children = children;\r\n }\r\n\r\n if (key !== undefined) {\r\n node.props = { ...node.props, key };\r\n }\r\n\r\n return node;\r\n}\r\n\r\n/**\r\n * Type guard for ASTNode\r\n */\r\nfunction isASTNode(value: unknown): value is ASTNode {\r\n return (\r\n typeof value === 'object' &&\r\n value !== null &&\r\n 'type' in value &&\r\n typeof (value as ASTNode).type === 'string'\r\n );\r\n}\r\n\r\n// ============================================================================\r\n// TypeScript JSX Namespace (Module-scoped export)\r\n// ============================================================================\r\n\r\n/**\r\n * Exported JSX Namespace\r\n *\r\n * TypeScript 5.1+ resolves JSX types from the **exported** `JSX` namespace\r\n * of the `{jsxImportSource}/jsx-runtime` module. This takes priority over\r\n * any global `JSX` namespace (including the one from `@types/react`).\r\n *\r\n * Without this export, projects that have both `@limo-labs/deity` and\r\n * `@types/react` installed will get TS2786 errors because React's global\r\n * JSX declarations override Deity's `declare global { namespace JSX }`.\r\n */\r\nexport namespace JSX {\r\n export type Element = any;\r\n export type ElementType = any;\r\n\r\n export interface IntrinsicElements {\r\n [elemName: string]: any;\r\n }\r\n\r\n export interface ElementClass {\r\n render(): any;\r\n }\r\n\r\n export interface ElementAttributesProperty {\r\n props: {};\r\n }\r\n\r\n export interface ElementChildrenAttribute {\r\n children: {};\r\n }\r\n}\r\n\r\n// ============================================================================\r\n// TypeScript JSX Namespace (Global fallback)\r\n// ============================================================================\r\n\r\n/**\r\n * Global JSX Namespace (backward compatibility)\r\n *\r\n * Kept for projects that don't use `jsxImportSource` or use older TypeScript\r\n * versions (< 5.1) that rely on the global `JSX` namespace.\r\n */\r\ndeclare global {\r\n namespace JSX {\r\n type Element = any;\r\n\r\n interface IntrinsicElements {\r\n [elemName: string]: any;\r\n }\r\n\r\n interface ElementClass {\r\n render(): any;\r\n }\r\n\r\n interface ElementAttributesProperty {\r\n props: {};\r\n }\r\n\r\n interface ElementChildrenAttribute {\r\n children: {};\r\n }\r\n }\r\n}\r\n\r\n// ============================================================================\r\n// Exports\r\n// ============================================================================\r\n\r\nexport { jsx as jsxDEV };\r\n"]}
|
package/dist/jsx-runtime.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/jsx-runtime.ts"],"names":[],"mappings":";;;AAgEO,SAAS,GAAA,CACd,IAAA,EACA,KAAA,EACA,GAAA,EACG;AAEH,EAAA,MAAM,eAAA,GAAkB,SAAS,EAAC;AAGlC,EAAA,MAAM,EAAE,QAAA,EAAU,GAAG,SAAA,EAAU,GAAI,eAAA;AAGnC,EAAA,MAAM,aAAA,GAAgB,kBAAkB,QAAQ,CAAA;AAGhD,EAAA,IAAI,OAAO,SAAS,UAAA,EAAY;AAC9B,IAAA,OAAO,KAAK,EAAE,GAAG,SAAA,EAAW,QAAA,EAAU,eAAe,CAAA;AAAA,EACvD;AAGA,EAAA,OAAO,aAAA,CAAc,IAAA,EAAgB,SAAA,EAAW,aAAA,EAAe,GAAG,CAAA;AACpE;AAQ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AAG,KAAA;AAAM,GACpB;AAEA,EAAA,IAAI,QAAA,CAAS,SAAS,CAAA,EAAG;AACvB,IAAA,IAAA,CAAK,QAAA,GAAW,QAAA;AAAA,EAClB;AAEA,EAAA,IAAI,QAAQ,MAAA,EAAW;AACrB,IAAA,IAAA,CAAK,KAAA,GAAQ,EAAE,GAAG,IAAA,CAAK,OAAO,GAAA,EAAI;AAAA,EACpC;AAEA,EAAA,OAAO,IAAA;AACT;AAKA,SAAS,UAAU,KAAA,EAAkC;AACnD,EAAA,OACE,OAAO,UAAU,QAAA,IACjB,KAAA,KAAU,QACV,MAAA,IAAU,KAAA,IACV,OAAQ,KAAA,CAAkB,IAAA,KAAS,QAAA;AAEvC","file":"jsx-runtime.cjs","sourcesContent":["/**\r\n * Deity TSX - JSX Runtime\r\n *\r\n * This module implements the JSX Factory for transforming TSX syntax into AST nodes.\r\n *\r\n * Design principles:\r\n * - Pure transformation (no side effects)\r\n * - Type-safe (leverage TypeScript's JSX type checking)\r\n * - Minimal runtime overhead\r\n */\r\n\r\nimport type { ASTNode } from './ast/types.js';\r\n\r\n// ============================================================================\r\n// JSX Runtime Types\r\n// ============================================================================\r\n\r\n/**\r\n * JSX Element Type\r\n *\r\n * Can be:\r\n * - String (intrinsic element): 'div', 'span', etc.\r\n * - Component function: (props) => ASTNode\r\n */\r\nexport type JSXElementType = string | JSXComponent;\r\n\r\n/**\r\n * JSX Component Function\r\n */\r\nexport type JSXComponent = (props: JSXProps) => ASTNode;\r\n\r\n/**\r\n * JSX Props (generic)\r\n */\r\nexport interface JSXProps {\r\n children?: ASTNode | ASTNode[];\r\n [key: string]: unknown;\r\n}\r\n\r\n// ============================================================================\r\n// JSX Factory Implementation\r\n// ============================================================================\r\n\r\n/**\r\n * JSX Factory - Transform JSX calls into AST nodes\r\n *\r\n * This is the core function called by TypeScript when it encounters JSX syntax.\r\n *\r\n * @example\r\n * // TSX code:\r\n * <Agent id=\"test\" input={schema} output={schema}>\r\n * <Prompt>...</Prompt>\r\n * </Agent>\r\n *\r\n * // Compiled to:\r\n * jsx('Agent', { id: 'test', input: schema, output: schema }, [\r\n * jsx('Prompt', {}, [...])\r\n * ])\r\n *\r\n * @param type - Element type (string or component function)\r\n * @param props - Element props (includes children)\r\n * @param key - Optional key (for lists)\r\n * @returns AST Node\r\n */\r\nexport function jsx<T extends ASTNode = ASTNode>(\r\n type: JSXElementType | ((props: any) => T),\r\n props: JSXProps | null,\r\n key?: string\r\n): T {\r\n // Normalize props\r\n const normalizedProps = props ?? {};\r\n\r\n // Extract children from props\r\n const { children, ...restProps } = normalizedProps;\r\n\r\n // Normalize children to array\r\n const childrenArray = normalizeChildren(children);\r\n\r\n // Handle component functions\r\n if (typeof type === 'function') {\r\n return type({ ...restProps, children: childrenArray }) as T;\r\n }\r\n\r\n // Handle intrinsic elements (string type)\r\n return createASTNode(type as string, restProps, childrenArray, key) as T;\r\n}\r\n\r\n/**\r\n * JSX Fragment - For <></> syntax\r\n *\r\n * Fragments are not used in Deity TSX (we use explicit nodes),\r\n * but we implement it for completeness.\r\n */\r\nexport function jsxs<T extends ASTNode = ASTNode>(\r\n type: JSXElementType | ((props: any) => T),\r\n props: JSXProps | null,\r\n key?: string\r\n): T {\r\n // jsxs is the same as jsx in our implementation\r\n return jsx(type, props, key);\r\n}\r\n\r\n/**\r\n * JSX Fragment component\r\n */\r\nexport const Fragment = Symbol('Fragment');\r\n\r\n// ============================================================================\r\n// Helper Functions\r\n// ============================================================================\r\n\r\n/**\r\n * Normalize children into an array\r\n *\r\n * Children can be:\r\n * - Undefined/null (no children)\r\n * - Single child (ASTNode or primitive)\r\n * - Array of children\r\n * - Function (for computed children)\r\n */\r\nfunction normalizeChildren(children: unknown): ASTNode[] {\r\n if (children === undefined || children === null) {\r\n return [];\r\n }\r\n\r\n if (Array.isArray(children)) {\r\n return children\r\n .filter(child => child !== null && child !== undefined)\r\n .flatMap(child => normalizeChildren(child));\r\n }\r\n\r\n // If it's already an ASTNode, return it\r\n if (isASTNode(children)) {\r\n return [children];\r\n }\r\n\r\n // If it's a function, we'll store it as a special TextNode\r\n // (This is for computed content like {(ctx) => \"...\"}\r\n if (typeof children === 'function') {\r\n return [{\r\n type: 'ComputedText',\r\n props: { compute: children },\r\n }];\r\n }\r\n\r\n // If it's a primitive (string/number/boolean), create a TextNode\r\n if (typeof children === 'string' || typeof children === 'number' || typeof children === 'boolean') {\r\n return [{\r\n type: 'Text',\r\n props: { content: String(children) },\r\n }];\r\n }\r\n\r\n return [];\r\n}\r\n\r\n/**\r\n * Create an AST Node from JSX elements\r\n */\r\nfunction createASTNode(\r\n type: string,\r\n props: Record<string, unknown>,\r\n children: ASTNode[],\r\n key?: string\r\n): ASTNode {\r\n const node: ASTNode = {\r\n type,\r\n props: { ...props },\r\n };\r\n\r\n if (children.length > 0) {\r\n node.children = children;\r\n }\r\n\r\n if (key !== undefined) {\r\n node.props = { ...node.props, key };\r\n }\r\n\r\n return node;\r\n}\r\n\r\n/**\r\n * Type guard for ASTNode\r\n */\r\nfunction isASTNode(value: unknown): value is ASTNode {\r\n return (\r\n typeof value === 'object' &&\r\n value !== null &&\r\n 'type' in value &&\r\n typeof (value as ASTNode).type === 'string'\r\n );\r\n}\r\n\r\n// ============================================================================\r\n// TypeScript JSX Namespace\r\n// ============================================================================\r\n\r\n/**\r\n * JSX Namespace
|
|
1
|
+
{"version":3,"sources":["../src/jsx-runtime.ts"],"names":[],"mappings":";;;AAgEO,SAAS,GAAA,CACd,IAAA,EACA,KAAA,EACA,GAAA,EACG;AAEH,EAAA,MAAM,eAAA,GAAkB,SAAS,EAAC;AAGlC,EAAA,MAAM,EAAE,QAAA,EAAU,GAAG,SAAA,EAAU,GAAI,eAAA;AAGnC,EAAA,MAAM,aAAA,GAAgB,kBAAkB,QAAQ,CAAA;AAGhD,EAAA,IAAI,OAAO,SAAS,UAAA,EAAY;AAC9B,IAAA,OAAO,KAAK,EAAE,GAAG,SAAA,EAAW,QAAA,EAAU,eAAe,CAAA;AAAA,EACvD;AA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AA,EACS;AACT,EAAA,MAAM,IAAA,GAAgB;AAAA,IACpB,IAAA;AAAA,IACA,KAAA,EAAO,EAAE,GAAG,KAAA;AAAM,GACpB;AAEA,EAAA,IAAI,QAAA,CAAS,SAAS,CAAA,EAAG;AACvB,IAAA,IAAA,CAAK,QAAA,GAAW,QAAA;AAAA,EAClB;AAEA,EAAA,IAAI,QAAQ,MAAA,EAAW;AACrB,IAAA,IAAA,CAAK,KAAA,GAAQ,EAAE,GAAG,IAAA,CAAK,OAAO,GAAA,EAAI;AAAA,EACpC;AAEA,EAAA,OAAO,IAAA;AACT;AAKA,SAAS,UAAU,KAAA,EAAkC;AACnD,EAAA,OACE,OAAO,UAAU,QAAA,IACjB,KAAA,KAAU,QACV,MAAA,IAAU,KAAA,IACV,OAAQ,KAAA,CAAkB,IAAA,KAAS,QAAA;AAEvC","file":"jsx-runtime.cjs","sourcesContent":["/**\r\n * Deity TSX - JSX Runtime\r\n *\r\n * This module implements the JSX Factory for transforming TSX syntax into AST nodes.\r\n *\r\n * Design principles:\r\n * - Pure transformation (no side effects)\r\n * - Type-safe (leverage TypeScript's JSX type checking)\r\n * - Minimal runtime overhead\r\n */\r\n\r\nimport type { ASTNode } from './ast/types.js';\r\n\r\n// ============================================================================\r\n// JSX Runtime Types\r\n// ============================================================================\r\n\r\n/**\r\n * JSX Element Type\r\n *\r\n * Can be:\r\n * - String (intrinsic element): 'div', 'span', etc.\r\n * - Component function: (props) => ASTNode\r\n */\r\nexport type JSXElementType = string | JSXComponent;\r\n\r\n/**\r\n * JSX Component Function\r\n */\r\nexport type JSXComponent = (props: JSXProps) => ASTNode;\r\n\r\n/**\r\n * JSX Props (generic)\r\n */\r\nexport interface JSXProps {\r\n children?: ASTNode | ASTNode[];\r\n [key: string]: unknown;\r\n}\r\n\r\n// ============================================================================\r\n// JSX Factory Implementation\r\n// ============================================================================\r\n\r\n/**\r\n * JSX Factory - Transform JSX calls into AST nodes\r\n *\r\n * This is the core function called by TypeScript when it encounters JSX syntax.\r\n *\r\n * @example\r\n * // TSX code:\r\n * <Agent id=\"test\" input={schema} output={schema}>\r\n * <Prompt>...</Prompt>\r\n * </Agent>\r\n *\r\n * // Compiled to:\r\n * jsx('Agent', { id: 'test', input: schema, output: schema }, [\r\n * jsx('Prompt', {}, [...])\r\n * ])\r\n *\r\n * @param type - Element type (string or component function)\r\n * @param props - Element props (includes children)\r\n * @param key - Optional key (for lists)\r\n * @returns AST Node\r\n */\r\nexport function jsx<T extends ASTNode = ASTNode>(\r\n type: JSXElementType | ((props: any) => T),\r\n props: JSXProps | null,\r\n key?: string\r\n): T {\r\n // Normalize props\r\n const normalizedProps = props ?? {};\r\n\r\n // Extract children from props\r\n const { children, ...restProps } = normalizedProps;\r\n\r\n // Normalize children to array\r\n const childrenArray = normalizeChildren(children);\r\n\r\n // Handle component functions\r\n if (typeof type === 'function') {\r\n return type({ ...restProps, children: childrenArray }) as T;\r\n }\r\n\r\n // Handle intrinsic elements (string type)\r\n return createASTNode(type as string, restProps, childrenArray, key) as T;\r\n}\r\n\r\n/**\r\n * JSX Fragment - For <></> syntax\r\n *\r\n * Fragments are not used in Deity TSX (we use explicit nodes),\r\n * but we implement it for completeness.\r\n */\r\nexport function jsxs<T extends ASTNode = ASTNode>(\r\n type: JSXElementType | ((props: any) => T),\r\n props: JSXProps | null,\r\n key?: string\r\n): T {\r\n // jsxs is the same as jsx in our implementation\r\n return jsx(type, props, key);\r\n}\r\n\r\n/**\r\n * JSX Fragment component\r\n */\r\nexport const Fragment = Symbol('Fragment');\r\n\r\n// ============================================================================\r\n// Helper Functions\r\n// ============================================================================\r\n\r\n/**\r\n * Normalize children into an array\r\n *\r\n * Children can be:\r\n * - Undefined/null (no children)\r\n * - Single child (ASTNode or primitive)\r\n * - Array of children\r\n * - Function (for computed children)\r\n */\r\nfunction normalizeChildren(children: unknown): ASTNode[] {\r\n if (children === undefined || children === null) {\r\n return [];\r\n }\r\n\r\n if (Array.isArray(children)) {\r\n return children\r\n .filter(child => child !== null && child !== undefined)\r\n .flatMap(child => normalizeChildren(child));\r\n }\r\n\r\n // If it's already an ASTNode, return it\r\n if (isASTNode(children)) {\r\n return [children];\r\n }\r\n\r\n // If it's a function, we'll store it as a special TextNode\r\n // (This is for computed content like {(ctx) => \"...\"}\r\n if (typeof children === 'function') {\r\n return [{\r\n type: 'ComputedText',\r\n props: { compute: children },\r\n }];\r\n }\r\n\r\n // If it's a primitive (string/number/boolean), create a TextNode\r\n if (typeof children === 'string' || typeof children === 'number' || typeof children === 'boolean') {\r\n return [{\r\n type: 'Text',\r\n props: { content: String(children) },\r\n }];\r\n }\r\n\r\n return [];\r\n}\r\n\r\n/**\r\n * Create an AST Node from JSX elements\r\n */\r\nfunction createASTNode(\r\n type: string,\r\n props: Record<string, unknown>,\r\n children: ASTNode[],\r\n key?: string\r\n): ASTNode {\r\n const node: ASTNode = {\r\n type,\r\n props: { ...props },\r\n };\r\n\r\n if (children.length > 0) {\r\n node.children = children;\r\n }\r\n\r\n if (key !== undefined) {\r\n node.props = { ...node.props, key };\r\n }\r\n\r\n return node;\r\n}\r\n\r\n/**\r\n * Type guard for ASTNode\r\n */\r\nfunction isASTNode(value: unknown): value is ASTNode {\r\n return (\r\n typeof value === 'object' &&\r\n value !== null &&\r\n 'type' in value &&\r\n typeof (value as ASTNode).type === 'string'\r\n );\r\n}\r\n\r\n// ============================================================================\r\n// TypeScript JSX Namespace (Module-scoped export)\r\n// ============================================================================\r\n\r\n/**\r\n * Exported JSX Namespace\r\n *\r\n * TypeScript 5.1+ resolves JSX types from the **exported** `JSX` namespace\r\n * of the `{jsxImportSource}/jsx-runtime` module. This takes priority over\r\n * any global `JSX` namespace (including the one from `@types/react`).\r\n *\r\n * Without this export, projects that have both `@limo-labs/deity` and\r\n * `@types/react` installed will get TS2786 errors because React's global\r\n * JSX declarations override Deity's `declare global { namespace JSX }`.\r\n */\r\nexport namespace JSX {\r\n export type Element = any;\r\n export type ElementType = any;\r\n\r\n export interface IntrinsicElements {\r\n [elemName: string]: any;\r\n }\r\n\r\n export interface ElementClass {\r\n render(): any;\r\n }\r\n\r\n export interface ElementAttributesProperty {\r\n props: {};\r\n }\r\n\r\n export interface ElementChildrenAttribute {\r\n children: {};\r\n }\r\n}\r\n\r\n// ============================================================================\r\n// TypeScript JSX Namespace (Global fallback)\r\n// ============================================================================\r\n\r\n/**\r\n * Global JSX Namespace (backward compatibility)\r\n *\r\n * Kept for projects that don't use `jsxImportSource` or use older TypeScript\r\n * versions (< 5.1) that rely on the global `JSX` namespace.\r\n */\r\ndeclare global {\r\n namespace JSX {\r\n type Element = any;\r\n\r\n interface IntrinsicElements {\r\n [elemName: string]: any;\r\n }\r\n\r\n interface ElementClass {\r\n render(): any;\r\n }\r\n\r\n interface ElementAttributesProperty {\r\n props: {};\r\n }\r\n\r\n interface ElementChildrenAttribute {\r\n children: {};\r\n }\r\n }\r\n}\r\n\r\n// ============================================================================\r\n// Exports\r\n// ============================================================================\r\n\r\nexport { jsx as jsxDEV };\r\n"]}
|
package/dist/jsx-runtime.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { af as Fragment, J as JSXComponent, F as JSXElementType, H as JSXProps,
|
|
1
|
+
export { af as Fragment, ag as JSX, J as JSXComponent, F as JSXElementType, H as JSXProps, ah as jsx, ah as jsxDEV, ai as jsxs } from './jsx-dev-runtime-CCicXopP.cjs';
|
|
2
2
|
import 'zod';
|
package/dist/jsx-runtime.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { af as Fragment, J as JSXComponent, F as JSXElementType, H as JSXProps,
|
|
1
|
+
export { af as Fragment, ag as JSX, J as JSXComponent, F as JSXElementType, H as JSXProps, ah as jsx, ah as jsxDEV, ai as jsxs } from './jsx-dev-runtime-CCicXopP.js';
|
|
2
2
|
import 'zod';
|
package/dist/jsx-runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/jsx-runtime.ts"],"names":[],"mappings":";A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S,KAC5B,CAAA;AAAA,EACH;AAGA,EAAA,IAAI,OAAO,aAAa,QAAA,IAAY,OAAO,aAAa,QAAA,IAAY,OAAO,aAAa,SAAA,EAAW;AACjG,IAAA,OAAO,CAAC;AAAA,MACN,IAAA,EAAM,MAAA;AAAA,MACN,KAAA,EAAO,EAAE,OAAA,EAAS,MAAA,CAAO,QAAQ,CAAA;AAAE,KACpC,CAAA;AAAA,EACH;AAEA,EAAA,OAAO,EAAC;AACV;AAKA,SAAS,aAAA,CACP,IAAA,EACA,KAAA,EACA,QAAA,EACA,GAAA,EACS;AACT,EAAA,MAAM,IAAA,GAAgB;AAAA,IACpB,IAAA;AAAA,IACA,KAAA,EAAO,EAAE,GAAG,KAAA;AAAM,GACpB;AAEA,EAAA,IAAI,QAAA,CAAS,SAAS,CAAA,EAAG;AACvB,IAAA,IAAA,CAAK,QAAA,GAAW,QAAA;AAAA,EAClB;AAEA,EAAA,IAAI,QAAQ,MAAA,EAAW;AACrB,IAAA,IAAA,CAAK,KAAA,GAAQ,EAAE,GAAG,IAAA,CAAK,OAAO,GAAA,EAAI;AAAA,EACpC;AAEA,EAAA,OAAO,IAAA;AACT;AAKA,SAAS,UAAU,KAAA,EAAkC;AACnD,EAAA,OACE,OAAO,UAAU,QAAA,IACjB,KAAA,KAAU,QACV,MAAA,IAAU,KAAA,IACV,OAAQ,KAAA,CAAkB,IAAA,KAAS,QAAA;AAEvC","file":"jsx-runtime.js","sourcesContent":["/**\r\n * Deity TSX - JSX Runtime\r\n *\r\n * This module implements the JSX Factory for transforming TSX syntax into AST nodes.\r\n *\r\n * Design principles:\r\n * - Pure transformation (no side effects)\r\n * - Type-safe (leverage TypeScript's JSX type checking)\r\n * - Minimal runtime overhead\r\n */\r\n\r\nimport type { ASTNode } from './ast/types.js';\r\n\r\n// ============================================================================\r\n// JSX Runtime Types\r\n// ============================================================================\r\n\r\n/**\r\n * JSX Element Type\r\n *\r\n * Can be:\r\n * - String (intrinsic element): 'div', 'span', etc.\r\n * - Component function: (props) => ASTNode\r\n */\r\nexport type JSXElementType = string | JSXComponent;\r\n\r\n/**\r\n * JSX Component Function\r\n */\r\nexport type JSXComponent = (props: JSXProps) => ASTNode;\r\n\r\n/**\r\n * JSX Props (generic)\r\n */\r\nexport interface JSXProps {\r\n children?: ASTNode | ASTNode[];\r\n [key: string]: unknown;\r\n}\r\n\r\n// ============================================================================\r\n// JSX Factory Implementation\r\n// ============================================================================\r\n\r\n/**\r\n * JSX Factory - Transform JSX calls into AST nodes\r\n *\r\n * This is the core function called by TypeScript when it encounters JSX syntax.\r\n *\r\n * @example\r\n * // TSX code:\r\n * <Agent id=\"test\" input={schema} output={schema}>\r\n * <Prompt>...</Prompt>\r\n * </Agent>\r\n *\r\n * // Compiled to:\r\n * jsx('Agent', { id: 'test', input: schema, output: schema }, [\r\n * jsx('Prompt', {}, [...])\r\n * ])\r\n *\r\n * @param type - Element type (string or component function)\r\n * @param props - Element props (includes children)\r\n * @param key - Optional key (for lists)\r\n * @returns AST Node\r\n */\r\nexport function jsx<T extends ASTNode = ASTNode>(\r\n type: JSXElementType | ((props: any) => T),\r\n props: JSXProps | null,\r\n key?: string\r\n): T {\r\n // Normalize props\r\n const normalizedProps = props ?? {};\r\n\r\n // Extract children from props\r\n const { children, ...restProps } = normalizedProps;\r\n\r\n // Normalize children to array\r\n const childrenArray = normalizeChildren(children);\r\n\r\n // Handle component functions\r\n if (typeof type === 'function') {\r\n return type({ ...restProps, children: childrenArray }) as T;\r\n }\r\n\r\n // Handle intrinsic elements (string type)\r\n return createASTNode(type as string, restProps, childrenArray, key) as T;\r\n}\r\n\r\n/**\r\n * JSX Fragment - For <></> syntax\r\n *\r\n * Fragments are not used in Deity TSX (we use explicit nodes),\r\n * but we implement it for completeness.\r\n */\r\nexport function jsxs<T extends ASTNode = ASTNode>(\r\n type: JSXElementType | ((props: any) => T),\r\n props: JSXProps | null,\r\n key?: string\r\n): T {\r\n // jsxs is the same as jsx in our implementation\r\n return jsx(type, props, key);\r\n}\r\n\r\n/**\r\n * JSX Fragment component\r\n */\r\nexport const Fragment = Symbol('Fragment');\r\n\r\n// ============================================================================\r\n// Helper Functions\r\n// ============================================================================\r\n\r\n/**\r\n * Normalize children into an array\r\n *\r\n * Children can be:\r\n * - Undefined/null (no children)\r\n * - Single child (ASTNode or primitive)\r\n * - Array of children\r\n * - Function (for computed children)\r\n */\r\nfunction normalizeChildren(children: unknown): ASTNode[] {\r\n if (children === undefined || children === null) {\r\n return [];\r\n }\r\n\r\n if (Array.isArray(children)) {\r\n return children\r\n .filter(child => child !== null && child !== undefined)\r\n .flatMap(child => normalizeChildren(child));\r\n }\r\n\r\n // If it's already an ASTNode, return it\r\n if (isASTNode(children)) {\r\n return [children];\r\n }\r\n\r\n // If it's a function, we'll store it as a special TextNode\r\n // (This is for computed content like {(ctx) => \"...\"}\r\n if (typeof children === 'function') {\r\n return [{\r\n type: 'ComputedText',\r\n props: { compute: children },\r\n }];\r\n }\r\n\r\n // If it's a primitive (string/number/boolean), create a TextNode\r\n if (typeof children === 'string' || typeof children === 'number' || typeof children === 'boolean') {\r\n return [{\r\n type: 'Text',\r\n props: { content: String(children) },\r\n }];\r\n }\r\n\r\n return [];\r\n}\r\n\r\n/**\r\n * Create an AST Node from JSX elements\r\n */\r\nfunction createASTNode(\r\n type: string,\r\n props: Record<string, unknown>,\r\n children: ASTNode[],\r\n key?: string\r\n): ASTNode {\r\n const node: ASTNode = {\r\n type,\r\n props: { ...props },\r\n };\r\n\r\n if (children.length > 0) {\r\n node.children = children;\r\n }\r\n\r\n if (key !== undefined) {\r\n node.props = { ...node.props, key };\r\n }\r\n\r\n return node;\r\n}\r\n\r\n/**\r\n * Type guard for ASTNode\r\n */\r\nfunction isASTNode(value: unknown): value is ASTNode {\r\n return (\r\n typeof value === 'object' &&\r\n value !== null &&\r\n 'type' in value &&\r\n typeof (value as ASTNode).type === 'string'\r\n );\r\n}\r\n\r\n// ============================================================================\r\n// TypeScript JSX Namespace\r\n// ============================================================================\r\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C;AAAA,MACN,IAAA,EAAM,cAAA;AAAA,MACN,KAAA,EAAO,EAAE,OAAA,EAAS,QAAA;AAAS,KAC5B,CAAA;AAAA,EACH;AAGA,EAAA,IAAI,OAAO,aAAa,QAAA,IAAY,OAAO,aAAa,QAAA,IAAY,OAAO,aAAa,SAAA,EAAW;AACjG,IAAA,OAAO,CAAC;AAAA,MACN,IAAA,EAAM,MAAA;AAAA,MACN,KAAA,EAAO,EAAE,OAAA,EAAS,MAAA,CAAO,QAAQ,CAAA;AAAE,KACpC,CAAA;AAAA,EACH;AAEA,EAAA,OAAO,EAAC;AACV;AAKA,SAAS,aAAA,CACP,IAAA,EACA,KAAA,EACA,QAAA,EACA,GAAA,EACS;AACT,EAAA,MAAM,IAAA,GAAgB;AAAA,IACpB,IAAA;AAAA,IACA,KAAA,EAAO,EAAE,GAAG,KAAA;AAAM,GACpB;AAEA,EAAA,IAAI,QAAA,CAAS,SAAS,CAAA,EAAG;AACvB,IAAA,IAAA,CAAK,QAAA,GAAW,QAAA;AAAA,EAClB;AAEA,EAAA,IAAI,QAAQ,MAAA,EAAW;AACrB,IAAA,IAAA,CAAK,KAAA,GAAQ,EAAE,GAAG,IAAA,CAAK,OAAO,GAAA,EAAI;AAAA,EACpC;AAEA,EAAA,OAAO,IAAA;AACT;AAKA,SAAS,UAAU,KAAA,EAAkC;AACnD,EAAA,OACE,OAAO,UAAU,QAAA,IACjB,KAAA,KAAU,QACV,MAAA,IAAU,KAAA,IACV,OAAQ,KAAA,CAAkB,IAAA,KAAS,QAAA;AAEvC","file":"jsx-runtime.js","sourcesContent":["/**\r\n * Deity TSX - JSX Runtime\r\n *\r\n * This module implements the JSX Factory for transforming TSX syntax into AST nodes.\r\n *\r\n * Design principles:\r\n * - Pure transformation (no side effects)\r\n * - Type-safe (leverage TypeScript's JSX type checking)\r\n * - Minimal runtime overhead\r\n */\r\n\r\nimport type { ASTNode } from './ast/types.js';\r\n\r\n// ============================================================================\r\n// JSX Runtime Types\r\n// ============================================================================\r\n\r\n/**\r\n * JSX Element Type\r\n *\r\n * Can be:\r\n * - String (intrinsic element): 'div', 'span', etc.\r\n * - Component function: (props) => ASTNode\r\n */\r\nexport type JSXElementType = string | JSXComponent;\r\n\r\n/**\r\n * JSX Component Function\r\n */\r\nexport type JSXComponent = (props: JSXProps) => ASTNode;\r\n\r\n/**\r\n * JSX Props (generic)\r\n */\r\nexport interface JSXProps {\r\n children?: ASTNode | ASTNode[];\r\n [key: string]: unknown;\r\n}\r\n\r\n// ============================================================================\r\n// JSX Factory Implementation\r\n// ============================================================================\r\n\r\n/**\r\n * JSX Factory - Transform JSX calls into AST nodes\r\n *\r\n * This is the core function called by TypeScript when it encounters JSX syntax.\r\n *\r\n * @example\r\n * // TSX code:\r\n * <Agent id=\"test\" input={schema} output={schema}>\r\n * <Prompt>...</Prompt>\r\n * </Agent>\r\n *\r\n * // Compiled to:\r\n * jsx('Agent', { id: 'test', input: schema, output: schema }, [\r\n * jsx('Prompt', {}, [...])\r\n * ])\r\n *\r\n * @param type - Element type (string or component function)\r\n * @param props - Element props (includes children)\r\n * @param key - Optional key (for lists)\r\n * @returns AST Node\r\n */\r\nexport function jsx<T extends ASTNode = ASTNode>(\r\n type: JSXElementType | ((props: any) => T),\r\n props: JSXProps | null,\r\n key?: string\r\n): T {\r\n // Normalize props\r\n const normalizedProps = props ?? {};\r\n\r\n // Extract children from props\r\n const { children, ...restProps } = normalizedProps;\r\n\r\n // Normalize children to array\r\n const childrenArray = normalizeChildren(children);\r\n\r\n // Handle component functions\r\n if (typeof type === 'function') {\r\n return type({ ...restProps, children: childrenArray }) as T;\r\n }\r\n\r\n // Handle intrinsic elements (string type)\r\n return createASTNode(type as string, restProps, childrenArray, key) as T;\r\n}\r\n\r\n/**\r\n * JSX Fragment - For <></> syntax\r\n *\r\n * Fragments are not used in Deity TSX (we use explicit nodes),\r\n * but we implement it for completeness.\r\n */\r\nexport function jsxs<T extends ASTNode = ASTNode>(\r\n type: JSXElementType | ((props: any) => T),\r\n props: JSXProps | null,\r\n key?: string\r\n): T {\r\n // jsxs is the same as jsx in our implementation\r\n return jsx(type, props, key);\r\n}\r\n\r\n/**\r\n * JSX Fragment component\r\n */\r\nexport const Fragment = Symbol('Fragment');\r\n\r\n// ============================================================================\r\n// Helper Functions\r\n// ============================================================================\r\n\r\n/**\r\n * Normalize children into an array\r\n *\r\n * Children can be:\r\n * - Undefined/null (no children)\r\n * - Single child (ASTNode or primitive)\r\n * - Array of children\r\n * - Function (for computed children)\r\n */\r\nfunction normalizeChildren(children: unknown): ASTNode[] {\r\n if (children === undefined || children === null) {\r\n return [];\r\n }\r\n\r\n if (Array.isArray(children)) {\r\n return children\r\n .filter(child => child !== null && child !== undefined)\r\n .flatMap(child => normalizeChildren(child));\r\n }\r\n\r\n // If it's already an ASTNode, return it\r\n if (isASTNode(children)) {\r\n return [children];\r\n }\r\n\r\n // If it's a function, we'll store it as a special TextNode\r\n // (This is for computed content like {(ctx) => \"...\"}\r\n if (typeof children === 'function') {\r\n return [{\r\n type: 'ComputedText',\r\n props: { compute: children },\r\n }];\r\n }\r\n\r\n // If it's a primitive (string/number/boolean), create a TextNode\r\n if (typeof children === 'string' || typeof children === 'number' || typeof children === 'boolean') {\r\n return [{\r\n type: 'Text',\r\n props: { content: String(children) },\r\n }];\r\n }\r\n\r\n return [];\r\n}\r\n\r\n/**\r\n * Create an AST Node from JSX elements\r\n */\r\nfunction createASTNode(\r\n type: string,\r\n props: Record<string, unknown>,\r\n children: ASTNode[],\r\n key?: string\r\n): ASTNode {\r\n const node: ASTNode = {\r\n type,\r\n props: { ...props },\r\n };\r\n\r\n if (children.length > 0) {\r\n node.children = children;\r\n }\r\n\r\n if (key !== undefined) {\r\n node.props = { ...node.props, key };\r\n }\r\n\r\n return node;\r\n}\r\n\r\n/**\r\n * Type guard for ASTNode\r\n */\r\nfunction isASTNode(value: unknown): value is ASTNode {\r\n return (\r\n typeof value === 'object' &&\r\n value !== null &&\r\n 'type' in value &&\r\n typeof (value as ASTNode).type === 'string'\r\n );\r\n}\r\n\r\n// ============================================================================\r\n// TypeScript JSX Namespace (Module-scoped export)\r\n// ============================================================================\r\n\r\n/**\r\n * Exported JSX Namespace\r\n *\r\n * TypeScript 5.1+ resolves JSX types from the **exported** `JSX` namespace\r\n * of the `{jsxImportSource}/jsx-runtime` module. This takes priority over\r\n * any global `JSX` namespace (including the one from `@types/react`).\r\n *\r\n * Without this export, projects that have both `@limo-labs/deity` and\r\n * `@types/react` installed will get TS2786 errors because React's global\r\n * JSX declarations override Deity's `declare global { namespace JSX }`.\r\n */\r\nexport namespace JSX {\r\n export type Element = any;\r\n export type ElementType = any;\r\n\r\n export interface IntrinsicElements {\r\n [elemName: string]: any;\r\n }\r\n\r\n export interface ElementClass {\r\n render(): any;\r\n }\r\n\r\n export interface ElementAttributesProperty {\r\n props: {};\r\n }\r\n\r\n export interface ElementChildrenAttribute {\r\n children: {};\r\n }\r\n}\r\n\r\n// ============================================================================\r\n// TypeScript JSX Namespace (Global fallback)\r\n// ============================================================================\r\n\r\n/**\r\n * Global JSX Namespace (backward compatibility)\r\n *\r\n * Kept for projects that don't use `jsxImportSource` or use older TypeScript\r\n * versions (< 5.1) that rely on the global `JSX` namespace.\r\n */\r\ndeclare global {\r\n namespace JSX {\r\n type Element = any;\r\n\r\n interface IntrinsicElements {\r\n [elemName: string]: any;\r\n }\r\n\r\n interface ElementClass {\r\n render(): any;\r\n }\r\n\r\n interface ElementAttributesProperty {\r\n props: {};\r\n }\r\n\r\n interface ElementChildrenAttribute {\r\n children: {};\r\n }\r\n }\r\n}\r\n\r\n// ============================================================================\r\n// Exports\r\n// ============================================================================\r\n\r\nexport { jsx as jsxDEV };\r\n"]}
|