Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/vortex-cli/src/corebind/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ export function cli({ onUpdate }: { onUpdate?(): void; } = {}): Renderer<TreeNod
throw new Error("Function not implemented.");
},
implementations: [
implementIntrinsic(Frame, (props) => {
Frame.implement((props) => {
return jsx("box", props);
}),
implementIntrinsic(TextIntrinsic, (props) => {
TextIntrinsic.implement((props) => {
return jsx("text", props);
})
]
Expand Down
17 changes: 7 additions & 10 deletions packages/vortex-core/src/intrinsic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const IntrinsicKey = "~vortex:intrinsic";

export type IntrinsicComponent<Args extends {}, Id extends string> = {
"~vortex:intrinsic": Id;
implement(impl: (args: Args) => JSXNode): IntrinsicImplementation<Args, Id>;
} & ((args: Args) => JSXNode);

export function intrinsic<Args extends {}, Id extends string>(id: Id) {
Expand All @@ -14,6 +15,12 @@ export function intrinsic<Args extends {}, Id extends string>(id: Id) {
}) as unknown as IntrinsicComponent<Args, Id>;

impl[IntrinsicKey] = id;
impl.implement = (implementation) => {
return {
intrinsic: impl,
implementation,
};
};

return impl;
}
Expand All @@ -25,13 +32,3 @@ export type IntrinsicImplementation<
intrinsic: IntrinsicComponent<Args, Id>;
implementation: (args: Args) => JSXNode;
};

export function implementIntrinsic<Args extends {}, Id extends string>(
intrinsic: IntrinsicComponent<Args, Id>,
implementation: (args: Args) => JSXNode,
): IntrinsicImplementation<Args, Id> {
return {
intrinsic,
implementation,
};
}