@@ -62,7 +62,7 @@ development, and have guaranteed support for fragments.
62
62
## Install
63
63
64
64
This package is [ ESM only] [ esm ] .
65
- In Node.js (version 14.14+ and 16.0 +), install with [ npm] [ ] :
65
+ In Node.js (version 16 +), install with [ npm] [ ] :
66
66
67
67
``` sh
68
68
npm install hast-util-to-jsx-runtime
@@ -85,10 +85,10 @@ In browsers with [`esm.sh`][esmsh]:
85
85
## Use
86
86
87
87
``` js
88
- import {Fragment , jsx , jsxs } from ' react/jsx-runtime'
89
- import {renderToStaticMarkup } from ' react-dom/server'
90
88
import {h } from ' hastscript'
91
89
import {toJsxRuntime } from ' hast-util-to-jsx-runtime'
90
+ import {Fragment , jsx , jsxs } from ' react/jsx-runtime'
91
+ import {renderToStaticMarkup } from ' react-dom/server'
92
92
93
93
const tree = h (' h1' , ' Hello, world!' )
94
94
@@ -185,10 +185,10 @@ Configuration (TypeScript type).
185
185
— static JSX
186
186
* ` jsxDEV ` ([ ` JsxDev ` ] [ api-jsx-dev ] , required in development)
187
187
— development JSX
188
- * ` development ` (` boolean ` , default: ` false ` )
189
- — whether to use ` jsxDEV ` when on or ` jsx ` and ` jsxs ` when off
190
188
* ` components ` ([ ` Partial<Components> ` ] [ api-components ] , optional)
191
189
— components to use
190
+ * ` development ` (` boolean ` , default: ` false ` )
191
+ — whether to use ` jsxDEV ` when on or ` jsx ` and ` jsxs ` when off
192
192
* ` elementAttributeNameCase `
193
193
([ ` ElementAttributeNameCase ` ] [ api-element-attribute-name-case ] ,
194
194
default: ` 'react' ` )
@@ -232,10 +232,10 @@ type Components = {
232
232
type ExtraProps = {node? : Element | undefined }
233
233
234
234
type Component <ComponentProps > =
235
- // Function component:
236
- | ((props : ComponentProps ) => JSX .Element | string | null | undefined )
237
235
// Class component:
238
236
| (new (props : ComponentProps ) => JSX .ElementClass )
237
+ // Function component:
238
+ | ((props : ComponentProps ) => JSX .Element | string | null | undefined )
239
239
` ` `
240
240
241
241
### ` ElementAttributeNameCase `
@@ -248,7 +248,7 @@ React casing is for example `className`, `strokeLinecap`, `xmlLang`.
248
248
###### Type
249
249
250
250
` ` ` ts
251
- type ElementAttributeNameCase = ' react ' | ' html '
251
+ type ElementAttributeNameCase = ' html ' | ' react '
252
252
` ` `
253
253
254
254
### ` Fragment `
@@ -313,12 +313,12 @@ import type {Element} from 'hast'
313
313
314
314
type Props = {
315
315
[prop : string ]:
316
- | Element // For `node`.
317
316
| Array <JSX .Element | string | null | undefined > // For `children`.
318
317
| Record <string , string > // For `style`.
319
- | string
320
- | number
318
+ | Element // For `node`.
321
319
| boolean
320
+ | number
321
+ | string
322
322
| undefined
323
323
children: Array <JSX .Element | string | null | undefined > | undefined
324
324
node? : Element | undefined
@@ -331,12 +331,12 @@ Info about source (TypeScript type).
331
331
332
332
###### Fields
333
333
334
+ * ` columnNumber ` ( ` number ` or ` undefined ` )
335
+ — column where thing starts (0-indexed)
334
336
* ` fileName ` ( ` string ` or ` undefined ` )
335
337
— name of source file
336
338
* ` lineNumber ` ( ` number ` or ` undefined ` )
337
339
— line where thing starts (1-indexed)
338
- * ` columnNumber ` ( ` number ` or ` undefined ` )
339
- — column where thing starts (0-indexed)
340
340
341
341
### ` Space `
342
342
@@ -364,7 +364,7 @@ DOM casing is for example `backgroundColor` and `WebkitLineClamp`.
364
364
###### Type
365
365
366
366
` ` ` ts
367
- type StylePropertyNameCase = ' dom ' | ' css '
367
+ type StylePropertyNameCase = ' css ' | ' dom '
368
368
` ` `
369
369
370
370
## Examples
@@ -376,10 +376,10 @@ type StylePropertyNameCase = 'dom' | 'css'
376
376
In Node.js, do:
377
377
378
378
` ` ` js
379
- import {Fragment , jsx , jsxs } from ' preact/jsx-runtime'
380
- import {render } from ' preact-render-to-string'
381
379
import {h } from ' hastscript'
382
380
import {toJsxRuntime } from ' hast-util-to-jsx-runtime'
381
+ import {Fragment , jsx , jsxs } from ' preact/jsx-runtime'
382
+ import {render } from ' preact-render-to-string'
383
383
384
384
const result = render (
385
385
toJsxRuntime (h (' h1' , ' hi!' ), {
@@ -402,10 +402,10 @@ Yields:
402
402
In a browser, do:
403
403
404
404
``` js
405
- import {Fragment , jsx , jsxs } from ' https://esm.sh/preact@10/jsx-runtime'
406
- import {render } from ' https://esm.sh/preact@10'
407
405
import {h } from ' https://esm.sh/hastscript@7'
408
406
import {toJsxRuntime } from ' https://esm.sh/hast-util-to-jsx-runtime@1'
407
+ import {Fragment , jsx , jsxs } from ' https://esm.sh/preact@10/jsx-runtime'
408
+ import {render } from ' https://esm.sh/preact@10'
409
409
410
410
render (
411
411
toJsxRuntime (h (' h1' , ' hi!' ), {
@@ -425,10 +425,10 @@ render(
425
425
In Node.js, do:
426
426
427
427
``` js
428
- import {Fragment , jsx , jsxs } from ' vue/jsx-runtime' // Available since `vue@^3.3.0-alpha.6`.
429
428
import serverRenderer from ' @vue/server-renderer'
430
429
import {h } from ' hastscript'
431
430
import {toJsxRuntime } from ' hast-util-to-jsx-runtime'
431
+ import {Fragment , jsx , jsxs } from ' vue/jsx-runtime' // Available since `vue@^3.3.0-alpha.6`.
432
432
433
433
console .log (
434
434
await serverRenderer .renderToString (
@@ -451,10 +451,10 @@ Yields:
451
451
In a browser, do:
452
452
453
453
``` js
454
- import {createApp } from ' https://esm.sh/vue@3'
455
- import {
Fragment ,
jsx ,
jsxs }
from ' https://esm.sh/[email protected] /jsx-runtime'
456
454
import {h } from ' https://esm.sh/hastscript@7'
457
455
import {toJsxRuntime } from ' https://esm.sh/hast-util-to-jsx-runtime@1'
456
+ import {createApp } from ' https://esm.sh/vue@3'
457
+ import {
Fragment ,
jsx ,
jsxs }
from ' https://esm.sh/[email protected] /jsx-runtime'
458
458
459
459
createApp (Component).mount (' #root' )
460
460
@@ -476,9 +476,9 @@ function Component() {
476
476
In Node.js, do:
477
477
478
478
``` js
479
- import {Fragment , jsx , jsxs } from ' solid-jsx/jsx-runtime'
480
479
import {h } from ' hastscript'
481
480
import {toJsxRuntime } from ' hast-util-to-jsx-runtime'
481
+ import {Fragment , jsx , jsxs } from ' solid-jsx/jsx-runtime'
482
482
483
483
console .log (
484
484
toJsxRuntime (h (' h1' , ' hi!' ), {
@@ -500,10 +500,10 @@ Yields:
500
500
In a browser, do:
501
501
502
502
``` js
503
- import {Fragment , jsx , jsxs } from ' https://esm.sh/solid-js@1/h/jsx-runtime'
504
- import {render } from ' https://esm.sh/solid-js@1/web'
505
503
import {h } from ' https://esm.sh/hastscript@7'
506
504
import {toJsxRuntime } from ' https://esm.sh/hast-util-to-jsx-runtime@1'
505
+ import {Fragment , jsx , jsxs } from ' https://esm.sh/solid-js@1/h/jsx-runtime'
506
+ import {render } from ' https://esm.sh/solid-js@1/web'
507
507
508
508
render (Component, document .getElementById (' root' ))
509
509
@@ -549,12 +549,17 @@ followed by browsers such as Chrome, Firefox, and Safari.
549
549
## Types
550
550
551
551
This package is fully typed with [ TypeScript] [ ] .
552
- It exports the additional types [ ` Components ` ] [ api-components ] ,
552
+ It exports the additional types
553
+ [ ` Components ` ] [ api-components ] ,
553
554
[ ` ElementAttributeNameCase ` ] [ api-element-attribute-name-case ] ,
554
- [ ` Fragment ` ] [ api-fragment ] , [ ` Jsx ` ] [ api-jsx ] , [ ` JsxDev ` ] [ api-jsx-dev ] ,
555
- [ ` Options ` ] [ api-options ] , [ ` Props ` ] [ api-props ] , [ ` Source ` ] [ api-source ] ,
556
- [ ` Space ` ] [ api-Space ] ,
557
- and [ ` StylePropertyNameCase ` ] [ api-style-property-name-case ] .
555
+ [ ` Fragment ` ] [ api-fragment ] ,
556
+ [ ` Jsx ` ] [ api-jsx ] ,
557
+ [ ` JsxDev ` ] [ api-jsx-dev ] ,
558
+ [ ` Options ` ] [ api-options ] ,
559
+ [ ` Props ` ] [ api-props ] ,
560
+ [ ` Source ` ] [ api-source ] ,
561
+ [ ` Space ` ] [ api-Space ] , and
562
+ [ ` StylePropertyNameCase ` ] [ api-style-property-name-case ] .
558
563
559
564
The function ` toJsxRuntime ` returns a ` JSX.Element ` , which means that the JSX
560
565
namespace has to by typed.
@@ -563,10 +568,13 @@ Typically this is done by installing your frameworks types (e.g.,
563
568
564
569
## Compatibility
565
570
566
- Projects maintained by the unified collective are compatible with all maintained
571
+ Projects maintained by the unified collective are compatible with maintained
567
572
versions of Node.js.
568
- As of now, that is Node.js 14.14+ and 16.0+.
569
- Our projects sometimes work with older versions, but this is not guaranteed.
573
+
574
+ When we cut a new major release, we drop support for unmaintained versions of
575
+ Node.
576
+ This means we try to keep the current release line,
577
+ ` hast-util-to-jsx-runtime@^1 ` , compatible with Node.js 12.
570
578
571
579
## Security
572
580
@@ -610,9 +618,9 @@ abide by its terms.
610
618
611
619
[ downloads ] : https://www.npmjs.com/package/hast-util-to-jsx-runtime
612
620
613
- [ size-badge ] : https://img.shields.io/bundlephobia/minzip/ hast-util-to-jsx-runtime.svg
621
+ [ size-badge ] : https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q= hast-util-to-jsx-runtime
614
622
615
- [ size ] : https://bundlephobia .com/result?p =hast-util-to-jsx-runtime
623
+ [ size ] : https://bundlejs .com/?q =hast-util-to-jsx-runtime
616
624
617
625
[ sponsors-badge ] : https://opencollective.com/unified/sponsors/badge.svg
618
626
0 commit comments