@@ -2,7 +2,7 @@ import { Tag } from "./lib/tags.ts";
22import { EmptyElements } from "./lib/emptyElements.ts" ;
33import { Attr } from "./lib/attributes.ts" ;
44import { Falsy , isFalsy } from "./util.ts" ;
5- import { Ref , ReadonlyRef } from "./state.ts" ;
5+ import { State , ReadonlyState } from "./state.ts" ;
66
77export type NonEmptyElement = Exclude < Tag , EmptyElements > ;
88
@@ -30,7 +30,9 @@ interface HN<T extends Tag = Tag> {
3030 children : ( HyperNode < Tag > | HyperTextNode ) [ ] ;
3131}
3232
33- export type HyperNode < T extends Tag = Tag > = { [ T in Tag ] : HN < T > } [ T ] ;
33+ export type HyperNodes = { [ T in Tag ] : HN < T > } ;
34+
35+ export type HyperNode < T extends Tag = Tag > = HyperNodes [ T ] ;
3436
3537// TypeScript constructors cannot return custom types, including unions.
3638// Instead, we create a class expression and assert it to the correct constructor type which returns the HyperNode union.
@@ -44,16 +46,16 @@ export type HyperNodeish<T extends Tag = Tag> =
4446 | HyperTextNode
4547 | HyperHTMLStringNode
4648 | Falsy
47- | Ref < HyperNode < T > | HyperTextNode | HyperHTMLStringNode | Falsy >
48- | ReadonlyRef < HyperNode < T > | HyperTextNode | HyperHTMLStringNode | Falsy > ;
49+ | State < HyperNode < T > | HyperTextNode | HyperHTMLStringNode | Falsy >
50+ | ReadonlyState < HyperNode < T > | HyperTextNode | HyperHTMLStringNode | Falsy > ;
4951
5052// deno-lint-ignore no-explicit-any
5153const isHyperNode = ( n : any ) : n is HyperNode | HyperHTMLStringNode | HyperTextNode =>
5254 n instanceof HyperNode || n instanceof HyperHTMLStringNode || typeof n === "string" ;
5355
5456export function normaliseParams < T extends Tag > ( props ?: Attr < T > | HyperNodeish , childNodes ?: HyperNodeish [ ] ) {
5557 const [ attrs , children ] : [ Attr < T > , HyperNodeish [ ] ] =
56- isHyperNode ( props ) || isFalsy ( props ) || Ref . isRef ( props )
58+ isHyperNode ( props ) || isFalsy ( props ) || State . isState ( props )
5759 ? [ { } , [ props , ...( childNodes || [ ] ) ] ]
5860 : [ props || { } , childNodes || [ ] ] ;
5961
0 commit comments