Skip to content

Commit

Permalink
Remove hastscript/html, hastscript/svg from exports
Browse files Browse the repository at this point in the history
Use `hastscript`.
  • Loading branch information
wooorm committed Aug 1, 2023
1 parent de3143c commit 6976cbb
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 86 deletions.
6 changes: 0 additions & 6 deletions html.js

This file was deleted.

22 changes: 0 additions & 22 deletions lib/html.js

This file was deleted.

26 changes: 24 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,27 @@
* Result from a `h` (or `s`) call.
*/

export {h} from './html.js'
export {s} from './svg.js'
// Register the JSX namespace.
/**
* @typedef {import('./jsx-classic.js').Element} h.JSX.Element
* @typedef {import('./jsx-classic.js').ElementChildrenAttribute} h.JSX.ElementChildrenAttribute
* @typedef {import('./jsx-classic.js').IntrinsicAttributes} h.JSX.IntrinsicAttributes
* @typedef {import('./jsx-classic.js').IntrinsicElements} h.JSX.IntrinsicElements
*
* @typedef {import('./jsx-classic.js').Element} s.JSX.Element
* @typedef {import('./jsx-classic.js').ElementChildrenAttribute} s.JSX.ElementChildrenAttribute
* @typedef {import('./jsx-classic.js').IntrinsicAttributes} s.JSX.IntrinsicAttributes
* @typedef {import('./jsx-classic.js').IntrinsicElements} s.JSX.IntrinsicElements
*/

import {html, svg} from 'property-information'
import {core} from './core.js'
import {svgCaseSensitiveTagNames} from './svg-case-sensitive-tag-names.js'

// Note: this explicit type is needed, otherwise TS creates broken types.
/** @type {ReturnType<core>} */
export const h = core(html, 'div')

// Note: this explicit type is needed, otherwise TS creates broken types.
/** @type {ReturnType<core>} */
export const s = core(svg, 'g', svgCaseSensitiveTagNames)
2 changes: 1 addition & 1 deletion lib/runtime-html.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {h} from './html.js'
import {runtime} from './runtime.js'
import {h} from './index.js'

// Export `JSX` as a global for TypeScript.
export * from './jsx-automatic.js'
Expand Down
2 changes: 1 addition & 1 deletion lib/runtime-svg.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {runtime} from './runtime.js'
import {s} from './svg.js'
import {s} from './index.js'

// Export `JSX` as a global for TypeScript.
export * from './jsx-automatic.js'
Expand Down
23 changes: 0 additions & 23 deletions lib/svg.js

This file was deleted.

7 changes: 0 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
"types": "index.d.ts",
"exports": {
".": "./index.js",
"./index.js": "./index.js",
"./html.js": "./html.js",
"./svg.js": "./svg.js",
"./jsx-runtime": "./jsx-runtime.js",
"./jsx-dev-runtime": "./jsx-runtime.js",
"./html/jsx-runtime": "./html/jsx-runtime.js",
Expand All @@ -47,10 +44,6 @@
"lib/",
"html/",
"svg/",
"html.d.ts",
"html.js",
"svg.d.ts",
"svg.js",
"jsx-runtime.d.ts",
"jsx-runtime.js",
"index.d.ts",
Expand Down
6 changes: 0 additions & 6 deletions svg.js

This file was deleted.

4 changes: 0 additions & 4 deletions test-d/files.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import {expectType} from 'tsd'
import type {Root} from 'hast'
import {h as hFromRoot} from '../html.js'
import {s as sFromRoot} from '../svg.js'
import {h as hFromIndex, s as sFromIndex} from '../index.js'

expectType<Root>(hFromRoot())
expectType<Root>(hFromIndex())
expectType<Root>(sFromRoot())
expectType<Root>(sFromIndex())
6 changes: 0 additions & 6 deletions test-d/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import {expectType} from 'tsd'
import type {Root, Element} from 'hast'
import {h as hFromRoot} from '../html.js'
import {h, s} from '../index.js'
import {Fragment, jsx, jsxs} from '../jsx-runtime.js'
import {s as sFromRoot} from '../svg.js'

// Ensure files are loadable in TS.
expectType<Root>(hFromRoot())
expectType<Root>(sFromRoot())

expectType<Root>(h())
expectType<Root>(s())
Expand Down
8 changes: 0 additions & 8 deletions test/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@ test('core', async function (t) {
])
})

await t.test('should expose the public api (`/html`)', async function () {
assert.deepEqual(Object.keys(await import('../html.js')).sort(), ['h'])
})

await t.test('should expose the public api (`/svg`)', async function () {
assert.deepEqual(Object.keys(await import('../svg.js')).sort(), ['s'])
})

await t.test(
'should expose the public api (`/jsx-runtime`)',
async function () {
Expand Down

0 comments on commit 6976cbb

Please sign in to comment.