@krate/runtime 0.1.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.
@@ -0,0 +1,8 @@
1
+ import { type Component } from './dom.js';
2
+ export { jsx, jsxs, Fragment } from './jsx-runtime.js';
3
+ export type { Component } from './dom.js';
4
+ export declare function jsxDEV<P extends {}>(type: string | Component<P>, props: P | null, key?: string | null, _isStaticChildren?: boolean, _source?: {
5
+ fileName: string;
6
+ lineNumber: number;
7
+ columnNumber: number;
8
+ }, _self?: unknown): Node;
@@ -0,0 +1,5 @@
1
+ import { jsx } from './jsx-runtime.js';
2
+ export { jsx, jsxs, Fragment } from './jsx-runtime.js';
3
+ export function jsxDEV(type, props, key, _isStaticChildren, _source, _self) {
4
+ return jsx(type, props, key);
5
+ }
@@ -0,0 +1,8 @@
1
+ import { type Component } from './dom.js';
2
+ import './jsx-types.js';
3
+ export { type Component } from './dom.js';
4
+ export declare function Fragment(props: {
5
+ children?: unknown[];
6
+ }): DocumentFragment;
7
+ export declare function jsx<P extends {}>(tag: string | Component<P>, props: P | null, _key?: string | null): Node;
8
+ export declare function jsxs<P extends {}>(tag: string | Component<P>, props: P | null, key?: string | null): Node;
@@ -0,0 +1,29 @@
1
+ import { h } from './dom.js';
2
+ import './jsx-types.js';
3
+ export function Fragment(props) {
4
+ const frag = document.createDocumentFragment();
5
+ const kids = props.children;
6
+ if (kids) {
7
+ const list = Array.isArray(kids) ? kids : [kids];
8
+ for (const child of list) {
9
+ if (child instanceof Node)
10
+ frag.appendChild(child);
11
+ else
12
+ frag.appendChild(document.createTextNode(String(child)));
13
+ }
14
+ }
15
+ return frag;
16
+ }
17
+ export function jsx(tag, props, _key) {
18
+ const render = tag;
19
+ if (!props)
20
+ return h(render, null);
21
+ const { children, ...rest } = props;
22
+ const kids = children !== undefined
23
+ ? (Array.isArray(children) ? children : [children])
24
+ : [];
25
+ return h(render, Object.keys(rest).length > 0 ? rest : null, ...kids);
26
+ }
27
+ export function jsxs(tag, props, key) {
28
+ return jsx(tag, props, key);
29
+ }