Comparing version 0.1.1 to 0.1.2
34
hjsx.js
@@ -163,2 +163,19 @@ // util/normalize-attribute-name.ts | ||
// hjsx.ts | ||
function hjsx(type, props, children) { | ||
return { | ||
type, | ||
props, | ||
children, | ||
render() { | ||
return renderToString(this); | ||
}, | ||
$$typeof: Symbol.for("hjsx.element"), | ||
key: null, | ||
ref: null, | ||
_owner: null | ||
}; | ||
} | ||
function fragment({ children }) { | ||
return children; | ||
} | ||
var validateElement = function(element) { | ||
@@ -193,17 +210,2 @@ if (!isObject(element)) { | ||
]; | ||
var hjsx = (type, props, children) => { | ||
return { | ||
type, | ||
props, | ||
children, | ||
render() { | ||
return renderToString(this); | ||
}, | ||
$$typeof: Symbol.for("hjsx.element"), | ||
key: null, | ||
ref: null, | ||
_owner: null | ||
}; | ||
}; | ||
var fragment = ({ children }) => children; | ||
var renderToString = (component) => { | ||
@@ -249,2 +251,4 @@ if (isPrimitive(component)) | ||
}; | ||
globalThis.hjsx = hjsx; | ||
globalThis.fragment = fragment; | ||
export { | ||
@@ -251,0 +255,0 @@ renderToString, |
17
hjsx.ts
import { | ||
uuid, | ||
escapeHtml, | ||
@@ -33,7 +32,7 @@ normalizeAttributeName, | ||
export const hjsx = ( | ||
export function hjsx( | ||
type: hjsx.Element["type"], | ||
props?: hjsx.Element["props"], | ||
props?: Record<PropertyKey, unknown>, | ||
children?: hjsx.Node, | ||
) => { | ||
) { | ||
return { | ||
@@ -51,5 +50,7 @@ type, | ||
}; | ||
}; | ||
} | ||
export const fragment: (props: RenderProps) => hjsx.Node = ({ children }: RenderProps) => children; | ||
export function fragment({ children }: hjsx.RenderProps) { | ||
return children; | ||
} | ||
@@ -126,1 +127,5 @@ // Refactored to use functional programming style | ||
} | ||
// set globals | ||
globalThis.hjsx = hjsx; | ||
globalThis.fragment = fragment; |
{ | ||
"name": "hjsx", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"module": "hjsx.ts", | ||
"main": "hjsx.js", | ||
"type": "module", | ||
"types": "types.d.ts", | ||
"types": "hjsx.d.ts", | ||
"scripts": { | ||
@@ -9,0 +9,0 @@ "build": "bun build hjsx.ts --outfile hjsx.js --target node", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
92897
2052