11/**
22 * @typedef {import('hast').Element } Element
33 * @typedef {import('hast').Nodes } Nodes
4- * @typedef {import('hast').Properties } Properties
54 * @typedef {import('hast').Root } Root
65 * @typedef {import('hast').RootContent } RootContent
76 *
109 */
1110
1211/**
13- * @typedef {Element | Root } HResult
12+ * @typedef {Element | Root } Result
1413 * Result from a `h` (or `s`) call.
1514 *
16- * @typedef {number | string } HStyleValue
15+ * @typedef {number | string } StyleValue
1716 * Value for a CSS style field.
18- * @typedef {Record<string, HStyleValue > } HStyle
17+ * @typedef {Record<string, StyleValue > } Style
1918 * Supported value of a `style` prop.
20- * @typedef {boolean | number | string | null | undefined } HPrimitiveValue
19+ * @typedef {boolean | number | string | null | undefined } PrimitiveValue
2120 * Primitive property value.
22- * @typedef {Array<number | string> } HArrayValue
21+ * @typedef {Array<number | string> } ArrayValue
2322 * List of property values for space- or comma separated values (such as `className`).
24- * @typedef {HArrayValue | HPrimitiveValue } HPropertyValue
23+ * @typedef {ArrayValue | PrimitiveValue } PropertyValue
2524 * Primitive value or list value.
26- * @typedef {{[property: string]: HPropertyValue | HStyle } } HProperties
25+ * @typedef {{[property: string]: PropertyValue | Style } } Properties
2726 * Acceptable value for element properties.
2827 *
29- * @typedef {number | string | null | undefined } HPrimitiveChild
28+ * @typedef {number | string | null | undefined } PrimitiveChild
3029 * Primitive children, either ignored (nullish), or turned into text nodes.
31- * @typedef {Array<HPrimitiveChild | Nodes> } HArrayChildNested
30+ * @typedef {Array<ArrayChildNested | Nodes | PrimitiveChild > } ArrayChild
3231 * List of children.
33- * @typedef {Array<HArrayChildNested | HPrimitiveChild | Nodes > } HArrayChild
34- * List of children.
35- * @typedef {HArrayChild | HPrimitiveChild | Nodes } HChild
32+ * @typedef {Array<Nodes | PrimitiveChild > } ArrayChildNested
33+ * List of children (deep) .
34+ * @typedef {ArrayChild | Nodes | PrimitiveChild } Child
3635 * Acceptable child value.
3736 */
3837
@@ -55,46 +54,46 @@ const own = {}.hasOwnProperty
5554 * @returns
5655 * `h`.
5756 */
58- export function core ( schema , defaultTagName , caseSensitive ) {
57+ export function createH ( schema , defaultTagName , caseSensitive ) {
5958 const adjust = caseSensitive && createAdjustMap ( caseSensitive )
6059
6160 /**
6261 * Hyperscript compatible DSL for creating virtual hast trees.
6362 *
6463 * @overload
6564 * @param {null | undefined } [selector]
66- * @param {...HChild } children
65+ * @param {...Child } children
6766 * @returns {Root }
6867 *
6968 * @overload
7069 * @param {string } selector
71- * @param {HProperties } properties
72- * @param {...HChild } children
70+ * @param {Properties } properties
71+ * @param {...Child } children
7372 * @returns {Element }
7473 *
7574 * @overload
7675 * @param {string } selector
77- * @param {...HChild } children
76+ * @param {...Child } children
7877 * @returns {Element }
7978 *
8079 * @param {string | null | undefined } [selector]
8180 * Selector.
82- * @param {HChild | HProperties | null | undefined } [properties]
81+ * @param {Child | Properties | null | undefined } [properties]
8382 * Properties (or first child) (default: `undefined`).
84- * @param {...HChild } children
83+ * @param {...Child } children
8584 * Children.
86- * @returns {HResult }
85+ * @returns {Result }
8786 * Result.
8887 */
8988 function h ( selector , properties , ...children ) {
9089 let index = - 1
91- /** @type {HResult } */
90+ /** @type {Result } */
9291 let node
9392
9493 if ( selector === undefined || selector === null ) {
9594 node = { type : 'root' , children : [ ] }
9695 // Properties are not supported for roots.
97- const child = /** @type {HChild } */ ( properties )
96+ const child = /** @type {Child } */ ( properties )
9897 children . unshift ( child )
9998 } else {
10099 node = parseSelector ( selector , defaultTagName )
@@ -138,11 +137,11 @@ export function core(schema, defaultTagName, caseSensitive) {
138137/**
139138 * Check if something is properties or a child.
140139 *
141- * @param {HChild | HProperties } value
140+ * @param {Child | Properties } value
142141 * Value to check.
143142 * @param {string } name
144143 * Tag name.
145- * @returns {value is HProperties }
144+ * @returns {value is Properties }
146145 * Whether `value` is a properties object.
147146 */
148147function isProperties ( value , name ) {
@@ -177,15 +176,15 @@ function isProperties(value, name) {
177176 * Properties object.
178177 * @param {string } key
179178 * Property name.
180- * @param {HPropertyValue | HStyle } value
179+ * @param {PropertyValue | Style } value
181180 * Property value.
182181 * @returns {undefined }
183182 * Nothing.
184183 */
185184function addProperty ( schema , properties , key , value ) {
186185 const info = find ( schema , key )
187186 let index = - 1
188- /** @type {HPropertyValue } */
187+ /** @type {PropertyValue } */
189188 let result
190189
191190 // Ignore nullish and NaN values.
@@ -246,7 +245,7 @@ function addProperty(schema, properties, key, value) {
246245/**
247246 * @param {Array<RootContent> } nodes
248247 * Children.
249- * @param {HChild } value
248+ * @param {Child } value
250249 * Child.
251250 * @returns {undefined }
252251 * Nothing.
@@ -280,9 +279,9 @@ function addChild(nodes, value) {
280279 * Property information.
281280 * @param {string } name
282281 * Property name.
283- * @param {HPrimitiveValue } value
282+ * @param {PrimitiveValue } value
284283 * Property value.
285- * @returns {HPrimitiveValue }
284+ * @returns {PrimitiveValue }
286285 * Property value.
287286 */
288287function parsePrimitive ( info , name , value ) {
@@ -305,7 +304,7 @@ function parsePrimitive(info, name, value) {
305304/**
306305 * Serialize a `style` object as a string.
307306 *
308- * @param {HStyle } value
307+ * @param {Style } value
309308 * Style object.
310309 * @returns {string }
311310 * CSS string.
0 commit comments