🎉 initiate project *astro_rewrite*

This commit is contained in:
sindrekjelsrud 2023-07-19 21:31:30 +02:00
parent ffd4d5e86c
commit 2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions

3
node_modules/hastscript/html.d.ts generated vendored Normal file
View file

@ -0,0 +1,3 @@
export {h} from './lib/html.js'
export type Child = import('./lib/index.js').Child
export type Properties = import('./lib/index.js').Properties

6
node_modules/hastscript/html.js generated vendored Normal file
View file

@ -0,0 +1,6 @@
/**
* @typedef {import('./lib/index.js').Child} Child
* @typedef {import('./lib/index.js').Properties} Properties
*/
export {h} from './lib/html.js'

1
node_modules/hastscript/html/jsx-runtime.d.ts generated vendored Normal file
View file

@ -0,0 +1 @@
export * from '../lib/runtime-html.js'

5
node_modules/hastscript/html/jsx-runtime.js generated vendored Normal file
View file

@ -0,0 +1,5 @@
/**
* @typedef {import('../lib/runtime.js').JSXProps}} JSXProps
*/
export * from '../lib/runtime-html.js'

4
node_modules/hastscript/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,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'

7
node_modules/hastscript/index.js generated vendored Normal file
View file

@ -0,0 +1,7 @@
/**
* @typedef {import('./lib/index.js').Child} Child
* @typedef {import('./lib/index.js').Properties} Properties
* @typedef {import('./lib/index.js').Result} Result
*/
export {h, s} from './lib/index.js'

1
node_modules/hastscript/jsx-runtime.d.ts generated vendored Normal file
View file

@ -0,0 +1 @@
export * from './lib/runtime-html.js'

5
node_modules/hastscript/jsx-runtime.js generated vendored Normal file
View file

@ -0,0 +1,5 @@
/**
* @typedef {import('./lib/runtime.js').JSXProps}} JSXProps
*/
export * from './lib/runtime-html.js'

71
node_modules/hastscript/lib/core.d.ts generated vendored Normal file
View file

@ -0,0 +1,71 @@
/**
* @param {Schema} schema
* @param {string} defaultTagName
* @param {Array<string>} [caseSensitive]
*/
export function core(
schema: Schema,
defaultTagName: string,
caseSensitive?: string[] | undefined
): {
(): Root
(selector: null | undefined, ...children: Array<HChild>): Root
(
selector: string,
properties?: HProperties,
...children: Array<HChild>
): Element
(selector: string, ...children: Array<HChild>): Element
}
export type Root = import('hast').Root
export type Content = import('hast').Content
export type Element = import('hast').Element
export type Properties = import('hast').Properties
export type Info = import('property-information').Info
export type Schema = import('property-information').Schema
/**
* Any concrete `hast` node.
*/
export type Node = Content | Root
/**
* Result from a `h` (or `s`) call.
*/
export type HResult = Root | Element
/**
* Value for a CSS style field.
*/
export type HStyleValue = string | number
/**
* Supported value of a `style` prop.
*/
export type HStyle = Record<string, HStyleValue>
/**
* Primitive property value.
*/
export type HPrimitiveValue = string | number | boolean | null | undefined
/**
* List of property values for space- or comma separated values (such as `className`).
*/
export type HArrayValue = Array<string | number>
/**
* Primitive value or list value.
*/
export type HPropertyValue = HPrimitiveValue | (string | number)[]
/**
* Acceptable value for element properties.
*/
export type HProperties = {
[property: string]: HStyle | HPropertyValue
}
/**
* Primitive children, either ignored (nullish), or turned into text nodes.
*/
export type HPrimitiveChild = string | number | null | undefined
/**
* List of children.
*/
export type HArrayChild = Array<Node | HPrimitiveChild>
/**
* Acceptable child value.
*/
export type HChild = Node | HPrimitiveChild | (Node | HPrimitiveChild)[]

309
node_modules/hastscript/lib/core.js generated vendored Normal file
View file

@ -0,0 +1,309 @@
/**
* @typedef {import('hast').Root} Root
* @typedef {import('hast').Content} Content
* @typedef {import('hast').Element} Element
* @typedef {import('hast').Properties} Properties
* @typedef {import('property-information').Info} Info
* @typedef {import('property-information').Schema} Schema
*/
/**
* @typedef {Content | Root} Node
* Any concrete `hast` node.
* @typedef {Root | Element} HResult
* Result from a `h` (or `s`) call.
*
* @typedef {string | number} HStyleValue
* Value for a CSS style field.
* @typedef {Record<string, HStyleValue>} HStyle
* Supported value of a `style` prop.
* @typedef {string | number | boolean | null | undefined} HPrimitiveValue
* Primitive property value.
* @typedef {Array<string | number>} HArrayValue
* List of property values for space- or comma separated values (such as `className`).
* @typedef {HPrimitiveValue | HArrayValue} HPropertyValue
* Primitive value or list value.
* @typedef {{[property: string]: HPropertyValue | HStyle}} HProperties
* Acceptable value for element properties.
*
* @typedef {string | number | null | undefined} HPrimitiveChild
* Primitive children, either ignored (nullish), or turned into text nodes.
* @typedef {Array<Node | HPrimitiveChild>} HArrayChild
* List of children.
* @typedef {Node | HPrimitiveChild | HArrayChild} HChild
* Acceptable child value.
*/
import {find, normalize} from 'property-information'
import {parseSelector} from 'hast-util-parse-selector'
import {parse as spaces} from 'space-separated-tokens'
import {parse as commas} from 'comma-separated-tokens'
const buttonTypes = new Set(['menu', 'submit', 'reset', 'button'])
const own = {}.hasOwnProperty
/**
* @param {Schema} schema
* @param {string} defaultTagName
* @param {Array<string>} [caseSensitive]
*/
export function core(schema, defaultTagName, caseSensitive) {
const adjust = caseSensitive && createAdjustMap(caseSensitive)
const h =
/**
* @type {{
* (): Root
* (selector: null | undefined, ...children: Array<HChild>): Root
* (selector: string, properties?: HProperties, ...children: Array<HChild>): Element
* (selector: string, ...children: Array<HChild>): Element
* }}
*/
(
/**
* Hyperscript compatible DSL for creating virtual hast trees.
*
* @param {string | null} [selector]
* @param {HProperties | HChild} [properties]
* @param {Array<HChild>} children
* @returns {HResult}
*/
function (selector, properties, ...children) {
let index = -1
/** @type {HResult} */
let node
if (selector === undefined || selector === null) {
node = {type: 'root', children: []}
// @ts-expect-error Properties are not supported for roots.
children.unshift(properties)
} else {
node = parseSelector(selector, defaultTagName)
// Normalize the name.
node.tagName = node.tagName.toLowerCase()
if (adjust && own.call(adjust, node.tagName)) {
node.tagName = adjust[node.tagName]
}
// Handle props.
if (isProperties(properties, node.tagName)) {
/** @type {string} */
let key
for (key in properties) {
if (own.call(properties, key)) {
// @ts-expect-error `node.properties` is set.
addProperty(schema, node.properties, key, properties[key])
}
}
} else {
children.unshift(properties)
}
}
// Handle children.
while (++index < children.length) {
addChild(node.children, children[index])
}
if (node.type === 'element' && node.tagName === 'template') {
node.content = {type: 'root', children: node.children}
node.children = []
}
return node
}
)
return h
}
/**
* @param {HProperties | HChild} value
* @param {string} name
* @returns {value is HProperties}
*/
function isProperties(value, name) {
if (
value === null ||
value === undefined ||
typeof value !== 'object' ||
Array.isArray(value)
) {
return false
}
if (name === 'input' || !value.type || typeof value.type !== 'string') {
return true
}
if ('children' in value && Array.isArray(value.children)) {
return false
}
if (name === 'button') {
return buttonTypes.has(value.type.toLowerCase())
}
return !('value' in value)
}
/**
* @param {Schema} schema
* @param {Properties} properties
* @param {string} key
* @param {HStyle | HPropertyValue} value
* @returns {void}
*/
function addProperty(schema, properties, key, value) {
const info = find(schema, key)
let index = -1
/** @type {HPropertyValue} */
let result
// Ignore nullish and NaN values.
if (value === undefined || value === null) return
if (typeof value === 'number') {
// Ignore NaN.
if (Number.isNaN(value)) return
result = value
}
// Booleans.
else if (typeof value === 'boolean') {
result = value
}
// Handle list values.
else if (typeof value === 'string') {
if (info.spaceSeparated) {
result = spaces(value)
} else if (info.commaSeparated) {
result = commas(value)
} else if (info.commaOrSpaceSeparated) {
result = spaces(commas(value).join(' '))
} else {
result = parsePrimitive(info, info.property, value)
}
} else if (Array.isArray(value)) {
result = value.concat()
} else {
result = info.property === 'style' ? style(value) : String(value)
}
if (Array.isArray(result)) {
/** @type {Array<string | number>} */
const finalResult = []
while (++index < result.length) {
// @ts-expect-error Assume no booleans in array.
finalResult[index] = parsePrimitive(info, info.property, result[index])
}
result = finalResult
}
// Class names (which can be added both on the `selector` and here).
if (info.property === 'className' && Array.isArray(properties.className)) {
// @ts-expect-error Assume no booleans in `className`.
result = properties.className.concat(result)
}
properties[info.property] = result
}
/**
* @param {Array<Content>} nodes
* @param {HChild} value
* @returns {void}
*/
function addChild(nodes, value) {
let index = -1
if (value === undefined || value === null) {
// Empty.
} else if (typeof value === 'string' || typeof value === 'number') {
nodes.push({type: 'text', value: String(value)})
} else if (Array.isArray(value)) {
while (++index < value.length) {
addChild(nodes, value[index])
}
} else if (typeof value === 'object' && 'type' in value) {
if (value.type === 'root') {
addChild(nodes, value.children)
} else {
nodes.push(value)
}
} else {
throw new Error('Expected node, nodes, or string, got `' + value + '`')
}
}
/**
* Parse a single primitives.
*
* @param {Info} info
* @param {string} name
* @param {HPrimitiveValue} value
* @returns {HPrimitiveValue}
*/
function parsePrimitive(info, name, value) {
if (typeof value === 'string') {
if (info.number && value && !Number.isNaN(Number(value))) {
return Number(value)
}
if (
(info.boolean || info.overloadedBoolean) &&
(value === '' || normalize(value) === normalize(name))
) {
return true
}
}
return value
}
/**
* Serialize a `style` object as a string.
*
* @param {HStyle} value
* Style object.
* @returns {string}
* CSS string.
*/
function style(value) {
/** @type {Array<string>} */
const result = []
/** @type {string} */
let key
for (key in value) {
if (own.call(value, key)) {
result.push([key, value[key]].join(': '))
}
}
return result.join('; ')
}
/**
* Create a map to adjust casing.
*
* @param {Array<string>} values
* List of properly cased keys.
* @returns {Record<string, string>}
* Map of lowercase keys to uppercase keys.
*/
function createAdjustMap(values) {
/** @type {Record<string, string>} */
const result = {}
let index = -1
while (++index < values.length) {
result[values[index].toLowerCase()] = values[index]
}
return result
}

37
node_modules/hastscript/lib/html.d.ts generated vendored Normal file
View file

@ -0,0 +1,37 @@
export const h: {
(): import('hast').Root
(
selector: null | undefined,
...children: import('./core.js').HChild[]
): import('hast').Root
(
selector: string,
properties?: import('./core.js').HProperties | undefined,
...children: import('./core.js').HChild[]
): import('hast').Element
(
selector: string,
...children: import('./core.js').HChild[]
): import('hast').Element
}
export namespace h {
namespace JSX {
type Element = import('./jsx-classic.js').Element
type IntrinsicAttributes = import('./jsx-classic.js').IntrinsicAttributes
type IntrinsicElements = import('./jsx-classic.js').IntrinsicElements
type ElementChildrenAttribute =
import('./jsx-classic.js').ElementChildrenAttribute
}
}
/**
* Acceptable child value.
*/
export type Child = import('./core.js').HChild
/**
* Acceptable value for element properties.
*/
export type Properties = import('./core.js').HProperties
/**
* Result from a `h` (or `s`) call.
*/
export type Result = import('./core.js').HResult

18
node_modules/hastscript/lib/html.js generated vendored Normal file
View file

@ -0,0 +1,18 @@
/**
* @typedef {import('./core.js').HChild} Child
* Acceptable child value.
* @typedef {import('./core.js').HProperties} Properties
* Acceptable value for element properties.
* @typedef {import('./core.js').HResult} Result
* Result from a `h` (or `s`) call.
*
* @typedef {import('./jsx-classic.js').Element} h.JSX.Element
* @typedef {import('./jsx-classic.js').IntrinsicAttributes} h.JSX.IntrinsicAttributes
* @typedef {import('./jsx-classic.js').IntrinsicElements} h.JSX.IntrinsicElements
* @typedef {import('./jsx-classic.js').ElementChildrenAttribute} h.JSX.ElementChildrenAttribute
*/
import {html} from 'property-information'
import {core} from './core.js'
export const h = core(html, 'div')

14
node_modules/hastscript/lib/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,14 @@
export {h} from './html.js'
export {s} from './svg.js'
/**
* Acceptable child value.
*/
export type Child = import('./core.js').HChild
/**
* Acceptable value for element properties.
*/
export type Properties = import('./core.js').HProperties
/**
* Result from a `h` (or `s`) call.
*/
export type Result = import('./core.js').HResult

11
node_modules/hastscript/lib/index.js generated vendored Normal file
View file

@ -0,0 +1,11 @@
/**
* @typedef {import('./core.js').HChild} Child
* Acceptable child value.
* @typedef {import('./core.js').HProperties} Properties
* Acceptable value for element properties.
* @typedef {import('./core.js').HResult} Result
* Result from a `h` (or `s`) call.
*/
export {h} from './html.js'
export {s} from './svg.js'

43
node_modules/hastscript/lib/jsx-automatic.d.ts generated vendored Normal file
View file

@ -0,0 +1,43 @@
import type {HProperties, HChild, HResult} from './core.js'
export namespace JSX {
/**
* This defines the return value of JSX syntax.
*/
type Element = HResult
/**
* This disallows the use of functional components.
*/
type IntrinsicAttributes = never
/**
* This defines the prop types for known elements.
*
* 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
| {
/**
* The prop that matches `ElementChildrenAttribute` key defines the type of JSX children, defines the children type.
*/
children?: HChild
}
}
/**
* 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
}
}

2
node_modules/hastscript/lib/jsx-automatic.js generated vendored Normal file
View file

@ -0,0 +1,2 @@
// Empty (only used for TypeScript).
export {}

47
node_modules/hastscript/lib/jsx-classic.d.ts generated vendored Normal file
View file

@ -0,0 +1,47 @@
import type {HProperties, HChild, HResult} from './core.js'
/**
* This unique symbol is declared to specify the key on which JSX children are passed, without conflicting
* with the Attributes type.
*/
declare const children: unique symbol
/**
* This defines the return value of JSX syntax.
*/
export type Element = HResult
/**
* This disallows the use of functional components.
*/
export type IntrinsicAttributes = never
/**
* This defines the prop types for known elements.
*
* 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
| {
/**
* The prop that matches `ElementChildrenAttribute` key defines the type of JSX children, defines the children type.
*/
[children]?: HChild
}
}
/**
* 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
}

2
node_modules/hastscript/lib/jsx-classic.js generated vendored Normal file
View file

@ -0,0 +1,2 @@
// Empty (only used for TypeScript).
export {}

89
node_modules/hastscript/lib/runtime-html.d.ts generated vendored Normal file
View file

@ -0,0 +1,89 @@
export * from './jsx-automatic.js'
export const Fragment: null
export const jsx: {
(
type: null | undefined,
props: {
children?: import('./core.js').HChild
},
key?: string | undefined
): import('hast').Root
(
type: string,
props: Record<
string,
| string
| number
| boolean
| import('hast').Root
| import('hast').Comment
| import('hast').DocType
| import('hast').Element
| import('hast').Text
| import('./core.js').HStyle
| import('./core.js').HArrayValue
| import('./core.js').HArrayChild
| null
| undefined
>,
key?: string | undefined
): import('hast').Element
}
export const jsxs: {
(
type: null | undefined,
props: {
children?: import('./core.js').HChild
},
key?: string | undefined
): import('hast').Root
(
type: string,
props: Record<
string,
| string
| number
| boolean
| import('hast').Root
| import('hast').Comment
| import('hast').DocType
| import('hast').Element
| import('hast').Text
| import('./core.js').HStyle
| import('./core.js').HArrayValue
| import('./core.js').HArrayChild
| null
| undefined
>,
key?: string | undefined
): import('hast').Element
}
export const jsxDEV: {
(
type: null | undefined,
props: {
children?: import('./core.js').HChild
},
key?: string | undefined
): import('hast').Root
(
type: string,
props: Record<
string,
| string
| number
| boolean
| import('hast').Root
| import('hast').Comment
| import('hast').DocType
| import('hast').Element
| import('hast').Text
| import('./core.js').HStyle
| import('./core.js').HArrayValue
| import('./core.js').HArrayChild
| null
| undefined
>,
key?: string | undefined
): import('hast').Element
}

6
node_modules/hastscript/lib/runtime-html.js generated vendored Normal file
View file

@ -0,0 +1,6 @@
// Export `JSX` as a global for TypeScript.
import {runtime} from './runtime.js'
import {h} from './html.js'
export * from './jsx-automatic.js'
export const {Fragment, jsx, jsxs, jsxDEV} = runtime(h)

89
node_modules/hastscript/lib/runtime-svg.d.ts generated vendored Normal file
View file

@ -0,0 +1,89 @@
export * from './jsx-automatic.js'
export const Fragment: null
export const jsx: {
(
type: null | undefined,
props: {
children?: import('./core.js').HChild
},
key?: string | undefined
): import('hast').Root
(
type: string,
props: Record<
string,
| string
| number
| boolean
| import('hast').Root
| import('hast').Comment
| import('hast').DocType
| import('hast').Element
| import('hast').Text
| import('./core.js').HStyle
| import('./core.js').HArrayValue
| import('./core.js').HArrayChild
| null
| undefined
>,
key?: string | undefined
): import('hast').Element
}
export const jsxs: {
(
type: null | undefined,
props: {
children?: import('./core.js').HChild
},
key?: string | undefined
): import('hast').Root
(
type: string,
props: Record<
string,
| string
| number
| boolean
| import('hast').Root
| import('hast').Comment
| import('hast').DocType
| import('hast').Element
| import('hast').Text
| import('./core.js').HStyle
| import('./core.js').HArrayValue
| import('./core.js').HArrayChild
| null
| undefined
>,
key?: string | undefined
): import('hast').Element
}
export const jsxDEV: {
(
type: null | undefined,
props: {
children?: import('./core.js').HChild
},
key?: string | undefined
): import('hast').Root
(
type: string,
props: Record<
string,
| string
| number
| boolean
| import('hast').Root
| import('hast').Comment
| import('hast').DocType
| import('hast').Element
| import('hast').Text
| import('./core.js').HStyle
| import('./core.js').HArrayValue
| import('./core.js').HArrayChild
| null
| undefined
>,
key?: string | undefined
): import('hast').Element
}

6
node_modules/hastscript/lib/runtime-svg.js generated vendored Normal file
View file

@ -0,0 +1,6 @@
// Export `JSX` as a global for TypeScript.
import {runtime} from './runtime.js'
import {s} from './svg.js'
export * from './jsx-automatic.js'
export const {Fragment, jsx, jsxs, jsxDEV} = runtime(s)

59
node_modules/hastscript/lib/runtime.d.ts generated vendored Normal file
View file

@ -0,0 +1,59 @@
/**
* @typedef {import('./core.js').Element} Element
* @typedef {import('./core.js').Root} Root
* @typedef {import('./core.js').HResult} HResult
* @typedef {import('./core.js').HChild} HChild
* @typedef {import('./core.js').HProperties} HProperties
* @typedef {import('./core.js').HPropertyValue} HPropertyValue
* @typedef {import('./core.js').HStyle} HStyle
* @typedef {import('./core.js').core} Core
*
* @typedef {Record<string, HPropertyValue | HStyle | HChild>} JSXProps
*/
/**
* Create an automatic runtime.
*
* @param {ReturnType<Core>} f
*/
export function runtime(f: ReturnType<Core>): {
Fragment: null
jsx: {
(
type: null | undefined,
props: {
children?: HChild
},
key?: string
): Root
(type: string, props: JSXProps, key?: string): Element
}
jsxs: {
(
type: null | undefined,
props: {
children?: HChild
},
key?: string
): Root
(type: string, props: JSXProps, key?: string): Element
}
jsxDEV: {
(
type: null | undefined,
props: {
children?: HChild
},
key?: string
): Root
(type: string, props: JSXProps, key?: string): Element
}
}
export type Element = import('./core.js').Element
export type Root = import('./core.js').Root
export type HResult = import('./core.js').HResult
export type HChild = import('./core.js').HChild
export type HProperties = import('./core.js').HProperties
export type HPropertyValue = import('./core.js').HPropertyValue
export type HStyle = import('./core.js').HStyle
export type Core = typeof import('./core.js').core
export type JSXProps = Record<string, HPropertyValue | HStyle | HChild>

40
node_modules/hastscript/lib/runtime.js generated vendored Normal file
View file

@ -0,0 +1,40 @@
/**
* @typedef {import('./core.js').Element} Element
* @typedef {import('./core.js').Root} Root
* @typedef {import('./core.js').HResult} HResult
* @typedef {import('./core.js').HChild} HChild
* @typedef {import('./core.js').HProperties} HProperties
* @typedef {import('./core.js').HPropertyValue} HPropertyValue
* @typedef {import('./core.js').HStyle} HStyle
* @typedef {import('./core.js').core} Core
*
* @typedef {Record<string, HPropertyValue | HStyle | HChild>} JSXProps
*/
/**
* Create an automatic runtime.
*
* @param {ReturnType<Core>} f
*/
export function runtime(f) {
const jsx =
/**
* @type {{
* (type: null | undefined, props: {children?: HChild}, key?: string): Root
* (type: string, props: JSXProps, key?: string): Element
* }}
*/
(
/**
* @param {string | null} type
* @param {HProperties & {children?: HChild}} props
* @returns {HResult}
*/
function (type, props) {
const {children, ...properties} = props
return type === null ? f(type, children) : f(type, properties, children)
}
)
return {Fragment: null, jsx, jsxs: jsx, jsxDEV: jsx}
}

View file

@ -0,0 +1 @@
export const svgCaseSensitiveTagNames: string[]

View file

@ -0,0 +1,41 @@
export const svgCaseSensitiveTagNames = [
'altGlyph',
'altGlyphDef',
'altGlyphItem',
'animateColor',
'animateMotion',
'animateTransform',
'clipPath',
'feBlend',
'feColorMatrix',
'feComponentTransfer',
'feComposite',
'feConvolveMatrix',
'feDiffuseLighting',
'feDisplacementMap',
'feDistantLight',
'feDropShadow',
'feFlood',
'feFuncA',
'feFuncB',
'feFuncG',
'feFuncR',
'feGaussianBlur',
'feImage',
'feMerge',
'feMergeNode',
'feMorphology',
'feOffset',
'fePointLight',
'feSpecularLighting',
'feSpotLight',
'feTile',
'feTurbulence',
'foreignObject',
'glyphRef',
'linearGradient',
'radialGradient',
'solidColor',
'textArea',
'textPath'
]

37
node_modules/hastscript/lib/svg.d.ts generated vendored Normal file
View file

@ -0,0 +1,37 @@
export const s: {
(): import('hast').Root
(
selector: null | undefined,
...children: import('./core.js').HChild[]
): import('hast').Root
(
selector: string,
properties?: import('./core.js').HProperties | undefined,
...children: import('./core.js').HChild[]
): import('hast').Element
(
selector: string,
...children: import('./core.js').HChild[]
): import('hast').Element
}
export namespace s {
namespace JSX {
type Element = import('./jsx-classic.js').Element
type IntrinsicAttributes = import('./jsx-classic.js').IntrinsicAttributes
type IntrinsicElements = import('./jsx-classic.js').IntrinsicElements
type ElementChildrenAttribute =
import('./jsx-classic.js').ElementChildrenAttribute
}
}
/**
* Acceptable child value.
*/
export type Child = import('./core.js').HChild
/**
* Acceptable value for element properties.
*/
export type Properties = import('./core.js').HProperties
/**
* Result from a `h` (or `s`) call.
*/
export type Result = import('./core.js').HResult

19
node_modules/hastscript/lib/svg.js generated vendored Normal file
View file

@ -0,0 +1,19 @@
/**
* @typedef {import('./core.js').HChild} Child
* Acceptable child value.
* @typedef {import('./core.js').HProperties} Properties
* Acceptable value for element properties.
* @typedef {import('./core.js').HResult} Result
* Result from a `h` (or `s`) call.
*
* @typedef {import('./jsx-classic.js').Element} s.JSX.Element
* @typedef {import('./jsx-classic.js').IntrinsicAttributes} s.JSX.IntrinsicAttributes
* @typedef {import('./jsx-classic.js').IntrinsicElements} s.JSX.IntrinsicElements
* @typedef {import('./jsx-classic.js').ElementChildrenAttribute} s.JSX.ElementChildrenAttribute
*/
import {svg} from 'property-information'
import {core} from './core.js'
import {svgCaseSensitiveTagNames} from './svg-case-sensitive-tag-names.js'
export const s = core(svg, 'g', svgCaseSensitiveTagNames)

22
node_modules/hastscript/license generated vendored Normal file
View file

@ -0,0 +1,22 @@
(The MIT License)
Copyright (c) 2016 Titus Wormer <tituswormer@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

113
node_modules/hastscript/package.json generated vendored Normal file
View file

@ -0,0 +1,113 @@
{
"name": "hastscript",
"version": "7.2.0",
"description": "hast utility to create trees",
"license": "MIT",
"keywords": [
"unist",
"hast",
"hast-util",
"util",
"utility",
"html",
"rehype",
"vdom",
"virtual",
"dom",
"hyperscript",
"dsl"
],
"repository": "syntax-tree/hastscript",
"bugs": "https://github.com/syntax-tree/hastscript/issues",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
},
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
"contributors": [
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
],
"sideEffects": false,
"type": "module",
"main": "index.js",
"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",
"./html/jsx-dev-runtime": "./html/jsx-runtime.js",
"./svg/jsx-runtime": "./svg/jsx-runtime.js",
"./svg/jsx-dev-runtime": "./svg/jsx-runtime.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",
"index.js"
],
"dependencies": {
"@types/hast": "^2.0.0",
"comma-separated-tokens": "^2.0.0",
"hast-util-parse-selector": "^3.0.0",
"property-information": "^6.0.0",
"space-separated-tokens": "^2.0.0"
},
"devDependencies": {
"@types/node": "^18.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",
"remark-cli": "^11.0.0",
"remark-preset-wooorm": "^9.0.0",
"svg-tag-names": "^3.0.0",
"tsd": "^0.25.0",
"type-coverage": "^2.0.0",
"typescript": "^4.0.0",
"unist-builder": "^3.0.0",
"xo": "^0.53.0"
},
"scripts": {
"prepack": "npm run build && npm run format",
"build": "tsc --build --clean && tsc --build && tsd && type-coverage",
"generate": "node script/generate-jsx.js && node script/build.js",
"format": "remark . -qfo && prettier . -w --loglevel 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"
},
"prettier": {
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"bracketSpacing": false,
"semi": false,
"trailingComma": "none"
},
"xo": {
"prettier": true
},
"remarkConfig": {
"plugins": [
"preset-wooorm"
]
},
"typeCoverage": {
"atLeast": 100,
"detail": true,
"strict": true
}
}

461
node_modules/hastscript/readme.md generated vendored Normal file
View file

@ -0,0 +1,461 @@
# hastscript
[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]
[![Sponsors][sponsors-badge]][collective]
[![Backers][backers-badge]][collective]
[![Chat][chat-badge]][chat]
[hast][] utility to create trees with ease.
## Contents
* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Install](#install)
* [Use](#use)
* [API](#api)
* [`h(selector?[, properties][, …children])`](#hselector-properties-children)
* [`s(selector?[, properties][, …children])`](#sselector-properties-children)
* [`Child`](#child)
* [`Properties`](#properties-1)
* [`Result`](#result)
* [Syntax tree](#syntax-tree)
* [JSX](#jsx)
* [Types](#types)
* [Compatibility](#compatibility)
* [Security](#security)
* [Related](#related)
* [Contribute](#contribute)
* [License](#license)
## What is this?
This package is a hyperscript interface (like `createElement` from React and
`h` from Vue and such) to help with creating hast trees.
## When should I use this?
You can use this utility in your project when you generate hast syntax trees
with code.
It helps because it replaces most of the repetition otherwise needed in a syntax
tree with function calls.
It also helps as it improves the attributes you pass by turning them into the
form that is required by hast.
You can instead use [`unist-builder`][u] when creating any unist nodes and
[`xastscript`][x] when creating xast (XML) nodes.
## Install
This package is [ESM only][esm].
In Node.js (version 14.14+ or 16.0+), install with [npm][]:
```sh
npm install hastscript
```
In Deno with [`esm.sh`][esmsh]:
```js
import {h} from 'https://esm.sh/hastscript@7'
```
In browsers with [`esm.sh`][esmsh]:
```html
<script type="module">
import {h} from 'https://esm.sh/hastscript@7?bundle'
</script>
```
## Use
```js
import {h, s} from 'hastscript'
console.log(
h('.foo#some-id', [
h('span', 'some text'),
h('input', {type: 'text', value: 'foo'}),
h('a.alpha', {class: 'bravo charlie', download: 'download'}, [
'delta',
'echo'
])
])
)
console.log(
s('svg', {xmlns: 'http://www.w3.org/2000/svg', viewbox: '0 0 500 500'}, [
s('title', 'SVG `<circle>` element'),
s('circle', {cx: 120, cy: 120, r: 100})
])
)
```
Yields:
```js
{
type: 'element',
tagName: 'div',
properties: {className: ['foo'], id: 'some-id'},
children: [
{
type: 'element',
tagName: 'span',
properties: {},
children: [{type: 'text', value: 'some text'}]
},
{
type: 'element',
tagName: 'input',
properties: {type: 'text', value: 'foo'},
children: []
},
{
type: 'element',
tagName: 'a',
properties: {className: ['alpha', 'bravo', 'charlie'], download: true},
children: [{type: 'text', value: 'delta'}, {type: 'text', value: 'echo'}]
}
]
}
{
type: 'element',
tagName: 'svg',
properties: {xmlns: 'http://www.w3.org/2000/svg', viewBox: '0 0 500 500'},
children: [
{
type: 'element',
tagName: 'title',
properties: {},
children: [{type: 'text', value: 'SVG `<circle>` element'}]
},
{
type: 'element',
tagName: 'circle',
properties: {cx: 120, cy: 120, r: 100},
children: []
}
]
}
```
## API
This package exports the identifiers `h` and `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.
### `h(selector?[, properties][, …children])`
Create virtual **[hast][]** trees for HTML.
##### Signatures
* `h(): root`
* `h(null[, …children]): root`
* `h(selector[, properties][, …children]): element`
##### Parameters
###### `selector`
Simple CSS selector (`string`, optional).
Can contain a tag name (`foo`), IDs (`#bar`), and classes (`.baz`).
If the selector is a string but there is no tag name in it, `h` defaults to
build a `div` element, and `s` to a `g` element.
`selector` is parsed by [`hast-util-parse-selector`][parse-selector].
When string, builds an [`Element`][element].
When nullish, builds a [`Root`][root] instead.
###### `properties`
Properties of the element ([`Properties`][properties], optional).
###### `children`
Children of the element ([`Child`][child] or `Array<Child>`, optional).
##### Returns
Created tree ([`Result`][result]).
[`Element`][element] when a `selector` is passed, otherwise [`Root`][root].
### `s(selector?[, properties][, …children])`
Create virtual **[hast][]** trees for SVG.
Signatures, parameters, and return value are the same as `h` above.
Importantly, the `selector` and `properties` parameters are interpreted as
SVG.
### `Child`
(Lists of) children (TypeScript type).
When strings or numbers are encountered, they are turned into [`Text`][text]
nodes.
[`Root`][root] nodes are treated as “fragments”, meaning that their children
are used instead.
###### Type
```ts
type Child =
| string
| number
| null
| undefined
| Node
| Array<string | number | null | undefined | Node>
```
### `Properties`
Map of properties (TypeScript type).
Keys should match either the HTML attribute name, or the DOM property name, but
are case-insensitive.
###### Type
```ts
type Properties = Record<
string,
| string
| number
| boolean
| null
| undefined
// For comma- and space-separated values such as `className`:
| Array<string | number>
// Accepts value for `style` prop as object.
| Record<string, string | number>
>
```
### `Result`
Result from a `h` (or `s`) call (TypeScript type).
###### Type
```ts
type Result = Root | Element
```
## Syntax tree
The syntax tree is [hast][].
## JSX
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`.
> 👉 **Note**: while `h` supports dots (`.`) for classes or number signs (`#`)
> for IDs in `selector`, those are not supported in JSX.
> 🪦 **Legacy**: you can also use the classic JSX runtime, but this is not
> recommended.
> To do so, import `h` (or `s`) yourself and define it as the pragma (plus
> set the fragment to `null`).
The Use example above can then be written like so, using inline pragmas, so
that SVG can be used too:
`example-html.jsx`:
```jsx
/** @jsxImportSource hastscript */
console.log(
<div class="foo" id="some-id">
<span>some text</span>
<input type="text" value="foo" />
<a class="alpha bravo charlie" download>
deltaecho
</a>
</div>
)
```
`example-svg.jsx`:
```jsx
/** @jsxImportSource hastscript/svg */
console.log(
<svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 500 500">
<title>SVG `&lt;circle&gt;` element</title>
<circle cx={120} cy={120} r={100} />
</svg>
)
```
## Types
This package is fully typed with [TypeScript][].
It exports the additional types `Child`, `Properties`, and `Result`.
## Compatibility
Projects maintained by the unified collective are compatible with all 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.
## Security
Use of `hastscript` can open you up to a [cross-site scripting (XSS)][xss]
when you pass user-provided input to it because values are injected into the
syntax tree.
The following example shows how an image is injected that fails loading and
therefore runs code in a browser.
```js
const tree = h()
// Somehow someone injected these properties instead of an expected `src` and
// `alt`:
const otherProps = {src: 'x', onError: 'alert(2)'}
tree.children.push(h('img', {src: 'default.png', ...otherProps}))
```
Yields:
```html
<img src="x" onerror="alert(2)">
```
The following example shows how code can run in a browser because someone stored
an object in a database instead of the expected string.
```js
const tree = h()
// Somehow this isnt the expected `'wooorm'`.
const username = {
type: 'element',
tagName: 'script',
children: [{type: 'text', value: 'alert(3)'}]
}
tree.children.push(h('span.handle', username))
```
Yields:
```html
<span class="handle"><script>alert(3)</script></span>
```
Either do not use user-provided input in `hastscript` or use
[`hast-util-santize`][hast-util-sanitize].
## Related
* [`unist-builder`](https://github.com/syntax-tree/unist-builder)
— create unist trees
* [`xastscript`](https://github.com/syntax-tree/xastscript)
— create xast trees
* [`hast-to-hyperscript`](https://github.com/syntax-tree/hast-to-hyperscript)
— turn hast into React, Preact, Vue, etc
* [`hast-util-to-html`](https://github.com/syntax-tree/hast-util-to-html)
— turn hast into HTML
* [`hast-util-to-dom`](https://github.com/syntax-tree/hast-util-to-dom)
— turn hast into DOM trees
* [`estree-util-build-jsx`](https://github.com/syntax-tree/estree-util-build-jsx)
— compile JSX away
## Contribute
See [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for
started.
See [`support.md`][support] for ways to get help.
This project has a [code of conduct][coc].
By interacting with this repository, organization, or community you agree to
abide by its terms.
## License
[MIT][license] © [Titus Wormer][author]
<!-- Definitions -->
[build-badge]: https://github.com/syntax-tree/hastscript/workflows/main/badge.svg
[build]: https://github.com/syntax-tree/hastscript/actions
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/hastscript.svg
[coverage]: https://codecov.io/github/syntax-tree/hastscript
[downloads-badge]: https://img.shields.io/npm/dm/hastscript.svg
[downloads]: https://www.npmjs.com/package/hastscript
[size-badge]: https://img.shields.io/bundlephobia/minzip/hastscript.svg
[size]: https://bundlephobia.com/result?p=hastscript
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
[collective]: https://opencollective.com/unified
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
[chat]: https://github.com/syntax-tree/unist/discussions
[npm]: https://docs.npmjs.com/cli/install
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[esmsh]: https://esm.sh
[typescript]: https://www.typescriptlang.org
[license]: license
[author]: https://wooorm.com
[health]: https://github.com/syntax-tree/.github
[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md
[support]: https://github.com/syntax-tree/.github/blob/main/support.md
[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
[hast]: https://github.com/syntax-tree/hast
[element]: https://github.com/syntax-tree/hast#element
[root]: https://github.com/syntax-tree/xast#root
[text]: https://github.com/syntax-tree/hast#text
[u]: https://github.com/syntax-tree/unist-builder
[x]: https://github.com/syntax-tree/xastscript
[parse-selector]: https://github.com/syntax-tree/hast-util-parse-selector
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
[hast-util-sanitize]: https://github.com/syntax-tree/hast-util-sanitize
[child]: #child
[properties]: #properties-1
[result]: #result

3
node_modules/hastscript/svg.d.ts generated vendored Normal file
View file

@ -0,0 +1,3 @@
export {s} from './lib/svg.js'
export type Child = import('./lib/index.js').Child
export type Properties = import('./lib/index.js').Properties

6
node_modules/hastscript/svg.js generated vendored Normal file
View file

@ -0,0 +1,6 @@
/**
* @typedef {import('./lib/index.js').Child} Child
* @typedef {import('./lib/index.js').Properties} Properties
*/
export {s} from './lib/svg.js'

1
node_modules/hastscript/svg/jsx-runtime.d.ts generated vendored Normal file
View file

@ -0,0 +1 @@
export * from '../lib/runtime-svg.js'

5
node_modules/hastscript/svg/jsx-runtime.js generated vendored Normal file
View file

@ -0,0 +1,5 @@
/**
* @typedef {import('../lib/runtime.js').JSXProps}} JSXProps
*/
export * from '../lib/runtime-svg.js'