Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hastscript

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hastscript - npm Package Compare versions

Comparing version 7.2.0 to 8.0.0

lib/automatic-runtime-html.d.ts

8

index.d.ts

@@ -1,4 +0,4 @@

export type Child = import('./lib/index.js').Child
export type Properties = import('./lib/index.js').Properties
export type Result = import('./lib/index.js').Result
export {h, s} from './lib/index.js'
export type Child = import('./lib/index.js').Child;
export type Properties = import('./lib/index.js').Properties;
export type Result = import('./lib/index.js').Result;
export { h, s } from "./lib/index.js";

@@ -1,14 +0,33 @@

export {h} from './html.js'
export {s} from './svg.js'
/** @type {ReturnType<createH>} */
export const h: ReturnType<typeof createH>;
export namespace h {
namespace JSX {
type Element = import('./jsx-classic.js').Element;
type ElementChildrenAttribute = import('./jsx-classic.js').ElementChildrenAttribute;
type IntrinsicAttributes = import('./jsx-classic.js').IntrinsicAttributes;
type IntrinsicElements = import('./jsx-classic.js').IntrinsicElements;
}
}
/** @type {ReturnType<createH>} */
export const s: ReturnType<typeof createH>;
export namespace s {
namespace JSX {
type Element = import('./jsx-classic.js').Element;
type ElementChildrenAttribute = import('./jsx-classic.js').ElementChildrenAttribute;
type IntrinsicAttributes = import('./jsx-classic.js').IntrinsicAttributes;
type IntrinsicElements = import('./jsx-classic.js').IntrinsicElements;
}
}
/**
* Acceptable child value.
*/
export type Child = import('./core.js').HChild
export type Child = import('./create-h.js').Child;
/**
* Acceptable value for element properties.
*/
export type Properties = import('./core.js').HProperties
export type Properties = import('./create-h.js').Properties;
/**
* Result from a `h` (or `s`) call.
*/
export type Result = import('./core.js').HResult
export type Result = import('./create-h.js').Result;
import { createH } from './create-h.js';
/**
* @typedef {import('./core.js').HChild} Child
* @typedef {import('./create-h.js').Child} Child
* Acceptable child value.
* @typedef {import('./core.js').HProperties} Properties
* @typedef {import('./create-h.js').Properties} Properties
* Acceptable value for element properties.
* @typedef {import('./core.js').HResult} Result
* @typedef {import('./create-h.js').Result} Result
* Result from a `h` (or `s`) call.
*/
export {h} from './html.js'
export {s} from './svg.js'
// Register the JSX namespace on `h`.
/**
* @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
*/
// Register the JSX namespace on `s`.
/**
* @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 {createH} from './create-h.js'
import {svgCaseSensitiveTagNames} from './svg-case-sensitive-tag-names.js'
// Note: this explicit type is needed, otherwise TS creates broken types.
/** @type {ReturnType<createH>} */
export const h = createH(html, 'div')
// Note: this explicit type is needed, otherwise TS creates broken types.
/** @type {ReturnType<createH>} */
export const s = createH(svg, 'g', svgCaseSensitiveTagNames)

@@ -1,43 +0,43 @@

import type {HProperties, HChild, HResult} from './core.js'
import type {Child, Properties, Result} from './create-h.js'
export namespace JSX {
/**
* This defines the return value of JSX syntax.
* Define the return value of JSX syntax.
*/
type Element = HResult
type Element = Result
/**
* This disallows the use of functional components.
* Key of this interface defines as what prop children are passed.
*/
interface ElementChildrenAttribute {
/**
* Only the key matters, not the value.
*/
children?: never
}
/**
* Disallow the use of functional components.
*/
type IntrinsicAttributes = never
/**
* This defines the prop types for known elements.
* Define the prop types for known elements.
*
* For `hastscript` this defines any string may be used in combination with `hast` `Properties`.
* For `hastscript` this defines any string may be used in combination with
* `hast` `Properties`.
*
* This **must** be an interface.
*/
// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style, @typescript-eslint/consistent-type-definitions
interface IntrinsicElements {
[name: string]:
| HProperties
| Properties
| {
/**
* The prop that matches `ElementChildrenAttribute` key defines the type of JSX children, defines the children type.
* The prop that matches `ElementChildrenAttribute` key defines the
* type of JSX children, defines the children type.
*/
children?: HChild
children?: Child
}
}
/**
* The key of this interface defines as what prop children are passed.
*/
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
interface ElementChildrenAttribute {
/**
* Only the key matters, not the value.
*/
children?: never
}
}

@@ -1,6 +0,6 @@

import type {HProperties, HChild, HResult} from './core.js'
import type {Child, Properties, Result} from './create-h.js'
/**
* This unique symbol is declared to specify the key on which JSX children are passed, without conflicting
* with the Attributes type.
* This unique symbol is declared to specify the key on which JSX children are
* passed, without conflicting with the `Attributes` type.
*/

@@ -10,39 +10,39 @@ declare const children: unique symbol

/**
* This defines the return value of JSX syntax.
* Define the return value of JSX syntax.
*/
export type Element = HResult
export type Element = Result
/**
* This disallows the use of functional components.
* Key of this interface defines as what prop children are passed.
*/
export interface ElementChildrenAttribute {
/**
* Only the key matters, not the value.
*/
[children]?: never
}
/**
* Disallow the use of functional components.
*/
export type IntrinsicAttributes = never
/**
* This defines the prop types for known elements.
* Define the prop types for known elements.
*
* For `hastscript` this defines any string may be used in combination with `hast` `Properties`.
* For `hastscript` this defines any string may be used in combination with
* `hast` `Properties`.
*
* This **must** be an interface.
*/
// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style, @typescript-eslint/consistent-type-definitions
export interface IntrinsicElements {
[name: string]:
| HProperties
| Properties
| {
/**
* The prop that matches `ElementChildrenAttribute` key defines the type of JSX children, defines the children type.
* The prop that matches `ElementChildrenAttribute` key defines the
* type of JSX children, defines the children type.
*/
[children]?: HChild
[children]?: Child
}
}
/**
* The key of this interface defines as what prop children are passed.
*/
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
export interface ElementChildrenAttribute {
/**
* Only the key matters, not the value.
*/
[children]?: never
}

@@ -1,1 +0,1 @@

export const svgCaseSensitiveTagNames: string[]
export const svgCaseSensitiveTagNames: string[];
{
"name": "hastscript",
"version": "7.2.0",
"version": "8.0.0",
"description": "hast utility to create trees",

@@ -36,22 +36,9 @@ "license": "MIT",

".": "./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",
"./html/jsx-dev-runtime": "./html/jsx-runtime.js",
"./svg/jsx-runtime": "./svg/jsx-runtime.js",
"./svg/jsx-dev-runtime": "./svg/jsx-runtime.js"
"./jsx-runtime": "./lib/automatic-runtime-html.js",
"./jsx-dev-runtime": "./lib/automatic-runtime-html.js",
"./svg/jsx-runtime": "./lib/automatic-runtime-svg.js",
"./svg/jsx-dev-runtime": "./lib/automatic-runtime-svg.js"
},
"files": [
"lib/",
"html/",
"svg/",
"html.d.ts",
"html.js",
"svg.d.ts",
"svg.js",
"jsx-runtime.d.ts",
"jsx-runtime.js",
"index.d.ts",

@@ -61,5 +48,5 @@ "index.js"

"dependencies": {
"@types/hast": "^2.0.0",
"@types/hast": "^3.0.0",
"comma-separated-tokens": "^2.0.0",
"hast-util-parse-selector": "^3.0.0",
"hast-util-parse-selector": "^4.0.0",
"property-information": "^6.0.0",

@@ -69,17 +56,17 @@ "space-separated-tokens": "^2.0.0"

"devDependencies": {
"@types/node": "^18.0.0",
"@types/node": "^20.0.0",
"acorn-jsx": "^5.0.0",
"c8": "^7.0.0",
"esast-util-from-js": "^1.0.0",
"estree-util-build-jsx": "^2.0.0",
"estree-util-to-js": "^1.0.0",
"prettier": "^2.0.0",
"c8": "^8.0.0",
"esast-util-from-js": "^2.0.0",
"estree-util-build-jsx": "^3.0.0",
"estree-util-to-js": "^2.0.0",
"prettier": "^3.0.0",
"remark-cli": "^11.0.0",
"remark-preset-wooorm": "^9.0.0",
"svg-tag-names": "^3.0.0",
"tsd": "^0.25.0",
"tsd": "^0.28.0",
"type-coverage": "^2.0.0",
"typescript": "^4.0.0",
"unist-builder": "^3.0.0",
"xo": "^0.53.0"
"typescript": "^5.0.0",
"unist-builder": "^4.0.0",
"xo": "^0.55.0"
},

@@ -90,21 +77,18 @@ "scripts": {

"generate": "node script/generate-jsx.js && node script/build.js",
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"format": "remark . -qfo && prettier . -w --log-level warn && xo --fix",
"test-api": "node --conditions development test/index.js",
"test-coverage": "c8 --check-coverage --100 --reporter lcov npm run test-api",
"test": "npm run build && npm run generate && npm run format && npm run test-coverage"
"test-coverage": "c8 --100 --reporter lcov npm run test-api",
"test": "npm run generate && npm run build && npm run format && npm run test-coverage"
},
"prettier": {
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"bracketSpacing": false,
"semi": false,
"trailingComma": "none"
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "none",
"useTabs": false
},
"xo": {
"prettier": true
},
"remarkConfig": {
"plugins": [
"preset-wooorm"
"remark-preset-wooorm"
]

@@ -115,4 +99,24 @@ },

"detail": true,
"ignoreCatch": true,
"#": "needed `any`s :'(",
"ignoreFiles": [
"test/jsx-build-jsx-automatic-development.js"
],
"strict": true
},
"xo": {
"overrides": [
{
"files": "**/*.ts",
"rules": {
"@typescript-eslint/consistent-indexed-object-style": "off",
"@typescript-eslint/consistent-type-definitions": "off"
}
}
],
"prettier": true,
"rules": {
"n/file-extension-in-import": "off"
}
}
}

@@ -54,3 +54,3 @@ # hastscript

This package is [ESM only][esm].
In Node.js (version 14.14+ or 16.0+), install with [npm][]:
In Node.js (version 16+), install with [npm][]:

@@ -64,3 +64,3 @@ ```sh

```js
import {h} from 'https://esm.sh/hastscript@7'
import {h} from 'https://esm.sh/hastscript@8'
```

@@ -72,3 +72,3 @@

<script type="module">
import {h} from 'https://esm.sh/hastscript@7?bundle'
import {h} from 'https://esm.sh/hastscript@8?bundle'
</script>

@@ -152,8 +152,8 @@ ```

This package exports the identifiers `h` and `s`.
This package exports the identifiers [`h`][api-h] and [`s`][api-s].
There is no default export.
The export map supports the automatic JSX runtime.
You can pass `hastscript` (or `hastscript/html`) or `hastscript/svg` to your
build tool (TypeScript, Babel, SWC) with an `importSource` option or similar.
You can pass `hastscript` or `hastscript/svg` to your build tool (TypeScript,
Babel, SWC) with an `importSource` option or similar.

@@ -184,11 +184,12 @@ ### `h(selector?[, properties][, …children])`

Properties of the element ([`Properties`][properties], optional).
Properties of the element ([`Properties`][api-properties], optional).
###### `children`
Children of the element ([`Child`][child] or `Array<Child>`, optional).
Children of the node ([`Child`][api-child] or `Array<Child>`, optional).
##### Returns
Created tree ([`Result`][result]).
Created tree ([`Result`][api-result]).
[`Element`][element] when a `selector` is passed, otherwise [`Root`][root].

@@ -207,2 +208,3 @@

(Lists of) children (TypeScript type).
When strings or numbers are encountered, they are turned into [`Text`][text]

@@ -217,8 +219,8 @@ nodes.

type Child =
| Array<Node | number | string | null | undefined>
| Node
| number
| string
| number
| null
| undefined
| Node
| Array<string | number | null | undefined | Node>
```

@@ -237,11 +239,11 @@

string,
| boolean
| number
| string
| number
| boolean
| null
| undefined
// For comma- and space-separated values such as `className`:
| Array<string | number>
| Array<number | string>
// Accepts value for `style` prop as object.
| Record<string, string | number>
| Record<string, number | string>
>

@@ -257,3 +259,3 @@ ```

```ts
type Result = Root | Element
type Result = Element | Root
```

@@ -268,4 +270,4 @@

This package can be used with JSX.
You should use the automatic JSX runtime set to `hastscript` (also available as
the more explicit name `hastscript/html`) or `hastscript/svg`.
You should use the automatic JSX runtime set to `hastscript` or
`hastscript/svg`.

@@ -313,11 +315,16 @@ > 👉 **Note**: while `h` supports dots (`.`) for classes or number signs (`#`)

This package is fully typed with [TypeScript][].
It exports the additional types `Child`, `Properties`, and `Result`.
It exports the additional types [`Child`][api-child],
[`Properties`][api-properties], and
[`Result`][api-result].
## Compatibility
Projects maintained by the unified collective are compatible with all maintained
Projects maintained by the unified collective are compatible with maintained
versions of Node.js.
As of now, that is Node.js 14.14+ and 16.0+.
Our projects sometimes work with older versions, but this is not guaranteed.
When we cut a new major release, we drop support for unmaintained versions of
Node.
This means we try to keep the current release line, `hastscript@^8`,
compatible with Node.js 16.
## Security

@@ -337,3 +344,3 @@

// `alt`:
const otherProps = {src: 'x', onError: 'alert(2)'}
const otherProps = {src: 'x', onError: 'alert(1)'}

@@ -346,3 +353,3 @@ tree.children.push(h('img', {src: 'default.png', ...otherProps}))

```html
<img src="x" onerror="alert(2)">
<img src="x" onerror="alert(1)">
```

@@ -360,3 +367,3 @@

tagName: 'script',
children: [{type: 'text', value: 'alert(3)'}]
children: [{type: 'text', value: 'alert(2)'}]
}

@@ -370,3 +377,3 @@

```html
<span class="handle"><script>alert(3)</script></span>
<span class="handle"><script>alert(2)</script></span>
```

@@ -395,3 +402,3 @@

See [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for
started.
ways to get started.
See [`support.md`][support] for ways to get help.

@@ -421,5 +428,5 @@

[size-badge]: https://img.shields.io/bundlephobia/minzip/hastscript.svg
[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=hastscript
[size]: https://bundlephobia.com/result?p=hastscript
[size]: https://bundlejs.com/?q=hastscript

@@ -474,6 +481,10 @@ [sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg

[child]: #child
[api-h]: #hselector-properties-children
[properties]: #properties-1
[api-s]: #sselector-properties-children
[result]: #result
[api-child]: #child
[api-properties]: #properties-1
[api-result]: #result
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc