Skip to content

Commit 6976cbb

Browse files
committed
Remove hastscript/html, hastscript/svg from exports
Use `hastscript`.
1 parent de3143c commit 6976cbb

File tree

11 files changed

+26
-86
lines changed

11 files changed

+26
-86
lines changed

Diff for: html.js

-6
This file was deleted.

Diff for: lib/html.js

-22
This file was deleted.

Diff for: lib/index.js

+24-2
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,27 @@
77
* Result from a `h` (or `s`) call.
88
*/
99

10-
export {h} from './html.js'
11-
export {s} from './svg.js'
10+
// Register the JSX namespace.
11+
/**
12+
* @typedef {import('./jsx-classic.js').Element} h.JSX.Element
13+
* @typedef {import('./jsx-classic.js').ElementChildrenAttribute} h.JSX.ElementChildrenAttribute
14+
* @typedef {import('./jsx-classic.js').IntrinsicAttributes} h.JSX.IntrinsicAttributes
15+
* @typedef {import('./jsx-classic.js').IntrinsicElements} h.JSX.IntrinsicElements
16+
*
17+
* @typedef {import('./jsx-classic.js').Element} s.JSX.Element
18+
* @typedef {import('./jsx-classic.js').ElementChildrenAttribute} s.JSX.ElementChildrenAttribute
19+
* @typedef {import('./jsx-classic.js').IntrinsicAttributes} s.JSX.IntrinsicAttributes
20+
* @typedef {import('./jsx-classic.js').IntrinsicElements} s.JSX.IntrinsicElements
21+
*/
22+
23+
import {html, svg} from 'property-information'
24+
import {core} from './core.js'
25+
import {svgCaseSensitiveTagNames} from './svg-case-sensitive-tag-names.js'
26+
27+
// Note: this explicit type is needed, otherwise TS creates broken types.
28+
/** @type {ReturnType<core>} */
29+
export const h = core(html, 'div')
30+
31+
// Note: this explicit type is needed, otherwise TS creates broken types.
32+
/** @type {ReturnType<core>} */
33+
export const s = core(svg, 'g', svgCaseSensitiveTagNames)

Diff for: lib/runtime-html.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {h} from './html.js'
21
import {runtime} from './runtime.js'
2+
import {h} from './index.js'
33

44
// Export `JSX` as a global for TypeScript.
55
export * from './jsx-automatic.js'

Diff for: lib/runtime-svg.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {runtime} from './runtime.js'
2-
import {s} from './svg.js'
2+
import {s} from './index.js'
33

44
// Export `JSX` as a global for TypeScript.
55
export * from './jsx-automatic.js'

Diff for: lib/svg.js

-23
This file was deleted.

Diff for: package.json

-7
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@
3333
"types": "index.d.ts",
3434
"exports": {
3535
".": "./index.js",
36-
"./index.js": "./index.js",
37-
"./html.js": "./html.js",
38-
"./svg.js": "./svg.js",
3936
"./jsx-runtime": "./jsx-runtime.js",
4037
"./jsx-dev-runtime": "./jsx-runtime.js",
4138
"./html/jsx-runtime": "./html/jsx-runtime.js",
@@ -47,10 +44,6 @@
4744
"lib/",
4845
"html/",
4946
"svg/",
50-
"html.d.ts",
51-
"html.js",
52-
"svg.d.ts",
53-
"svg.js",
5447
"jsx-runtime.d.ts",
5548
"jsx-runtime.js",
5649
"index.d.ts",

Diff for: svg.js

-6
This file was deleted.

Diff for: test-d/files.ts

-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import {expectType} from 'tsd'
22
import type {Root} from 'hast'
3-
import {h as hFromRoot} from '../html.js'
4-
import {s as sFromRoot} from '../svg.js'
53
import {h as hFromIndex, s as sFromIndex} from '../index.js'
64

7-
expectType<Root>(hFromRoot())
85
expectType<Root>(hFromIndex())
9-
expectType<Root>(sFromRoot())
106
expectType<Root>(sFromIndex())

Diff for: test-d/index.ts

-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
import {expectType} from 'tsd'
22
import type {Root, Element} from 'hast'
3-
import {h as hFromRoot} from '../html.js'
43
import {h, s} from '../index.js'
54
import {Fragment, jsx, jsxs} from '../jsx-runtime.js'
6-
import {s as sFromRoot} from '../svg.js'
7-
8-
// Ensure files are loadable in TS.
9-
expectType<Root>(hFromRoot())
10-
expectType<Root>(sFromRoot())
115

126
expectType<Root>(h())
137
expectType<Root>(s())

Diff for: test/core.js

-8
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@ test('core', async function (t) {
1010
])
1111
})
1212

13-
await t.test('should expose the public api (`/html`)', async function () {
14-
assert.deepEqual(Object.keys(await import('../html.js')).sort(), ['h'])
15-
})
16-
17-
await t.test('should expose the public api (`/svg`)', async function () {
18-
assert.deepEqual(Object.keys(await import('../svg.js')).sort(), ['s'])
19-
})
20-
2113
await t.test(
2214
'should expose the public api (`/jsx-runtime`)',
2315
async function () {

0 commit comments

Comments
 (0)