summaryrefslogtreecommitdiff
path: root/gjs/src/jsx/jsx-runtime.ts
diff options
context:
space:
mode:
authorAylur <[email protected]>2024-09-01 02:06:50 +0200
committerAylur <[email protected]>2024-09-01 02:06:50 +0200
commit0738194780ce52b9047c430b9498487417b2cd07 (patch)
treee0cdbcbc31ccbe1620a5f228f18fead658487652 /gjs/src/jsx/jsx-runtime.ts
parent49cdf5d5e010c9abb9b02034999eef2f49f066b9 (diff)
move libastal to /core
starting point of the monorepo
Diffstat (limited to 'gjs/src/jsx/jsx-runtime.ts')
-rw-r--r--gjs/src/jsx/jsx-runtime.ts87
1 files changed, 0 insertions, 87 deletions
diff --git a/gjs/src/jsx/jsx-runtime.ts b/gjs/src/jsx/jsx-runtime.ts
deleted file mode 100644
index 70f098f..0000000
--- a/gjs/src/jsx/jsx-runtime.ts
+++ /dev/null
@@ -1,87 +0,0 @@
-import { Gtk } from "../imports.js"
-import * as Widget from "../widgets.js"
-
-function isArrowFunction(func: any): func is (args: any) => any {
- return !Object.hasOwn(func, "prototype")
-}
-
-export function jsx(
- ctor: keyof typeof ctors | typeof Gtk.Widget,
- { children, ...props }: any,
-) {
- children ??= []
-
- if (!Array.isArray(children))
- children = [children]
-
- children = children.filter(Boolean)
-
- if (typeof ctor === "string")
- return (ctors as any)[ctor](props, children)
-
- if (children.length === 1)
- props.child = children[0]
- else if (children.length > 1)
- props.children = children
-
- if (isArrowFunction(ctor))
- return ctor(props)
-
- // @ts-expect-error can be class or function
- return new ctor(props)
-}
-
-const ctors = {
- box: Widget.Box,
- button: Widget.Button,
- centerbox: Widget.CenterBox,
- // TODO: circularprogress
- drawingarea: Widget.DrawingArea,
- entry: Widget.Entry,
- eventbox: Widget.EventBox,
- // TODO: fixed
- // TODO: flowbox
- icon: Widget.Icon,
- label: Widget.Label,
- levelbar: Widget.LevelBar,
- // TODO: listbox
- overlay: Widget.Overlay,
- revealer: Widget.Revealer,
- scrollable: Widget.Scrollable,
- slider: Widget.Slider,
- // TODO: stack
- switch: Widget.Switch,
- window: Widget.Window,
-}
-
-declare global {
- // eslint-disable-next-line @typescript-eslint/no-namespace
- namespace JSX {
- type Element = Gtk.Widget
- type ElementClass = Gtk.Widget
- interface IntrinsicElements {
- box: Widget.BoxProps
- button: Widget.ButtonProps
- centerbox: Widget.CenterBoxProps
- // TODO: circularprogress
- drawingarea: Widget.DrawingAreaProps
- entry: Widget.EntryProps
- eventbox: Widget.EventBoxProps
- // TODO: fixed
- // TODO: flowbox
- icon: Widget.IconProps
- label: Widget.LabelProps
- levelbar: Widget.LevelBarProps
- // TODO: listbox
- overlay: Widget.OverlayProps
- revealer: Widget.RevealerProps
- scrollable: Widget.ScrollableProps
- slider: Widget.SliderProps
- // TODO: stack
- switch: Widget.SwitchProps
- window: Widget.WindowProps
- }
- }
-}
-
-export const jsxs = jsx