Refactor routing in App component to enhance navigation and improve error handling by integrating dynamic routes and updating the NotFound route.

This commit is contained in:
becarta
2025-05-23 12:43:00 +02:00
parent f40db0f5c9
commit a544759a3b
11127 changed files with 1647032 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
/* eslint-disable @typescript-eslint/naming-convention */
import type {Element, Root} from 'hast'
import type {Child} from './create-h.js'
import type {JSXProps} from './create-automatic-runtime.js'
export * from './jsx-automatic.js'
export const Fragment: null
export const jsxDEV: {
(
type: null,
properties: {children?: Child},
key?: string | null | undefined
): Root
(type: string, properties: JSXProps, key?: string | null | undefined): Element
}
export const jsxs: {
(
type: null,
properties: {children?: Child},
key?: string | null | undefined
): Root
(type: string, properties: JSXProps, key?: string | null | undefined): Element
}
export const jsx: {
(
type: null,
properties: {children?: Child},
key?: string | null | undefined
): Root
(type: string, properties: JSXProps, key?: string | null | undefined): Element
}

View File

@@ -0,0 +1,9 @@
// Note: types exposed from `automatic-runtime-html.d.ts` because TS has bugs
// when generating types.
import {createAutomaticRuntime} from './create-automatic-runtime.js'
import {h} from './index.js'
// Export `JSX` as a global for TypeScript.
export * from './jsx-automatic.js'
export const {Fragment, jsxDEV, jsxs, jsx} = createAutomaticRuntime(h)

36
node_modules/hastscript/lib/automatic-runtime-svg.d.ts generated vendored Normal file
View File

@@ -0,0 +1,36 @@
/* eslint-disable @typescript-eslint/naming-convention */
import type {Element, Root} from 'hast'
import type {Child} from './create-h.js'
import type {JSXProps} from './create-automatic-runtime.js'
export * from './jsx-automatic.js'
export const Fragment: null
export const jsxDEV: {
(
type: null,
properties: {children?: Child},
key?: string | null | undefined
): Root
(type: string, properties: JSXProps, key?: string | null | undefined): Element
}
export const jsxs: {
(
type: null,
properties: {children?: Child},
key?: string | null | undefined
): Root
(type: string, properties: JSXProps, key?: string | null | undefined): Element
}
export const jsx: {
(
type: null,
properties: {children?: Child},
key?: string | null | undefined
): Root
(type: string, properties: JSXProps, key?: string | null | undefined): Element
}

View File

@@ -0,0 +1 @@
{"version":3,"file":"automatic-runtime-svg.d.ts","sourceRoot":"","sources":["automatic-runtime-svg.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;gBAOsiB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAAD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAAD,CAAC"}

7
node_modules/hastscript/lib/automatic-runtime-svg.js generated vendored Normal file
View File

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

View File

@@ -0,0 +1,237 @@
/**
* Create an automatic runtime.
*
* @param {ReturnType<CreateH>} f
* `h` function.
* @returns
* Automatic JSX runtime.
*/
export function createAutomaticRuntime(f: ReturnType<typeof CreateH>): {
Fragment: null;
jsxDEV: {
/**
* @overload
* @param {null} type
* @param {{children?: Child}} properties
* @param {string | null | undefined} [key]
* @returns {Root}
*
* @overload
* @param {string} type
* @param {JSXProps} properties
* @param {string | null | undefined} [key]
* @returns {Element}
*
* @param {string | null} type
* Element name or `null` to get a root.
* @param {Properties & {children?: Child}} properties
* Properties.
* @returns {Result}
* Result.
*/
(type: null, properties: {
children?: Child;
}, key?: string | null | undefined): Root;
/**
* @overload
* @param {null} type
* @param {{children?: Child}} properties
* @param {string | null | undefined} [key]
* @returns {Root}
*
* @overload
* @param {string} type
* @param {JSXProps} properties
* @param {string | null | undefined} [key]
* @returns {Element}
*
* @param {string | null} type
* Element name or `null` to get a root.
* @param {Properties & {children?: Child}} properties
* Properties.
* @returns {Result}
* Result.
*/
(type: string, properties: JSXProps, key?: string | null | undefined): Element;
};
jsxs: {
/**
* @overload
* @param {null} type
* @param {{children?: Child}} properties
* @param {string | null | undefined} [key]
* @returns {Root}
*
* @overload
* @param {string} type
* @param {JSXProps} properties
* @param {string | null | undefined} [key]
* @returns {Element}
*
* @param {string | null} type
* Element name or `null` to get a root.
* @param {Properties & {children?: Child}} properties
* Properties.
* @returns {Result}
* Result.
*/
/**
* @overload
* @param {null} type
* @param {{children?: Child}} properties
* @param {string | null | undefined} [key]
* @returns {Root}
*
* @overload
* @param {string} type
* @param {JSXProps} properties
* @param {string | null | undefined} [key]
* @returns {Element}
*
* @param {string | null} type
* Element name or `null` to get a root.
* @param {Properties & {children?: Child}} properties
* Properties.
* @returns {Result}
* Result.
*/
(type: null, properties: {
children?: Child;
}, key?: string | null | undefined): Root;
/**
* @overload
* @param {null} type
* @param {{children?: Child}} properties
* @param {string | null | undefined} [key]
* @returns {Root}
*
* @overload
* @param {string} type
* @param {JSXProps} properties
* @param {string | null | undefined} [key]
* @returns {Element}
*
* @param {string | null} type
* Element name or `null` to get a root.
* @param {Properties & {children?: Child}} properties
* Properties.
* @returns {Result}
* Result.
*/
/**
* @overload
* @param {null} type
* @param {{children?: Child}} properties
* @param {string | null | undefined} [key]
* @returns {Root}
*
* @overload
* @param {string} type
* @param {JSXProps} properties
* @param {string | null | undefined} [key]
* @returns {Element}
*
* @param {string | null} type
* Element name or `null` to get a root.
* @param {Properties & {children?: Child}} properties
* Properties.
* @returns {Result}
* Result.
*/
(type: string, properties: JSXProps, key?: string | null | undefined): Element;
};
jsx: {
/**
* @overload
* @param {null} type
* @param {{children?: Child}} properties
* @param {string | null | undefined} [key]
* @returns {Root}
*
* @overload
* @param {string} type
* @param {JSXProps} properties
* @param {string | null | undefined} [key]
* @returns {Element}
*
* @param {string | null} type
* Element name or `null` to get a root.
* @param {Properties & {children?: Child}} properties
* Properties.
* @returns {Result}
* Result.
*/
/**
* @overload
* @param {null} type
* @param {{children?: Child}} properties
* @param {string | null | undefined} [key]
* @returns {Root}
*
* @overload
* @param {string} type
* @param {JSXProps} properties
* @param {string | null | undefined} [key]
* @returns {Element}
*
* @param {string | null} type
* Element name or `null` to get a root.
* @param {Properties & {children?: Child}} properties
* Properties.
* @returns {Result}
* Result.
*/
(type: null, properties: {
children?: Child;
}, key?: string | null | undefined): Root;
/**
* @overload
* @param {null} type
* @param {{children?: Child}} properties
* @param {string | null | undefined} [key]
* @returns {Root}
*
* @overload
* @param {string} type
* @param {JSXProps} properties
* @param {string | null | undefined} [key]
* @returns {Element}
*
* @param {string | null} type
* Element name or `null` to get a root.
* @param {Properties & {children?: Child}} properties
* Properties.
* @returns {Result}
* Result.
*/
/**
* @overload
* @param {null} type
* @param {{children?: Child}} properties
* @param {string | null | undefined} [key]
* @returns {Root}
*
* @overload
* @param {string} type
* @param {JSXProps} properties
* @param {string | null | undefined} [key]
* @returns {Element}
*
* @param {string | null} type
* Element name or `null` to get a root.
* @param {Properties & {children?: Child}} properties
* Properties.
* @returns {Result}
* Result.
*/
(type: string, properties: JSXProps, key?: string | null | undefined): Element;
};
};
export type JSXProps = Record<string, Child | PropertyValue | Style>;
import type { createH as CreateH } from './create-h.js';
import type { Child } from './create-h.js';
import type { Root } from 'hast';
import type { Element } from 'hast';
import type { PropertyValue } from './create-h.js';
import type { Style } from './create-h.js';
//# sourceMappingURL=create-automatic-runtime.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"create-automatic-runtime.d.ts","sourceRoot":"","sources":["create-automatic-runtime.js"],"names":[],"mappings":"AAYA;;;;;;;GAOG;AACH,0CALW,UAAU,gBAAS;;;;;;;;;;;;;;;;;;;;;;;eAQjB,IAAI,cACJ;YAAC,QAAQ,CAAC,EAAE,KAAK,CAAA;SAAC,QAClB,MAAM,GAAG,IAAI,GAAG,SAAS,GACvB,IAAI;;;;;;;;;;;;;;;;;;;;;eAGN,MAAM,cACN,QAAQ,QACR,MAAM,GAAG,IAAI,GAAG,SAAS,GACvB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eATT,IAAI,cACJ;YAAC,QAAQ,CAAC,EAAE,KAAK,CAAA;SAAC,QAClB,MAAM,GAAG,IAAI,GAAG,SAAS,GACvB,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAGN,MAAM,cACN,QAAQ,QACR,MAAM,GAAG,IAAI,GAAG,SAAS,GACvB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eATT,IAAI,cACJ;YAAC,QAAQ,CAAC,EAAE,KAAK,CAAA;SAAC,QAClB,MAAM,GAAG,IAAI,GAAG,SAAS,GACvB,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAGN,MAAM,cACN,QAAQ,QACR,MAAM,GAAG,IAAI,GAAG,SAAS,GACvB,OAAO;;EAmBrB;uBA7CY,MAAM,CAAC,MAAM,EAAE,KAAK,GAAG,aAAa,GAAG,KAAK,CAAC;wCAJ4B,eAAe;2BAAf,eAAe;0BADrE,MAAM;6BAAN,MAAM;mCACgD,eAAe;2BAAf,eAAe"}

View File

@@ -0,0 +1,52 @@
/**
* @import {Element, Root} from 'hast'
* @import {Child, Properties, PropertyValue, Result, Style, createH as CreateH} from './create-h.js'
*/
/**
* @typedef {Record<string, Child | PropertyValue | Style>} JSXProps
*/
// Make VS code see references to above symbols.
''
/**
* Create an automatic runtime.
*
* @param {ReturnType<CreateH>} f
* `h` function.
* @returns
* Automatic JSX runtime.
*/
export function createAutomaticRuntime(f) {
/**
* @overload
* @param {null} type
* @param {{children?: Child}} properties
* @param {string | null | undefined} [key]
* @returns {Root}
*
* @overload
* @param {string} type
* @param {JSXProps} properties
* @param {string | null | undefined} [key]
* @returns {Element}
*
* @param {string | null} type
* Element name or `null` to get a root.
* @param {Properties & {children?: Child}} properties
* Properties.
* @returns {Result}
* Result.
*/
function jsx(type, properties) {
const {children, ...properties_} = properties
const result =
// @ts-ignore: `children` is fine: TS has a recursion problem which
// sometimes generates broken types.
type === null ? f(null, children) : f(type, properties_, children)
return result
}
return {Fragment: null, jsxDEV: jsx, jsxs: jsx, jsx}
}

148
node_modules/hastscript/lib/create-h.d.ts generated vendored Normal file
View File

@@ -0,0 +1,148 @@
/**
* @param {Schema} schema
* Schema to use.
* @param {string} defaultTagName
* Default tag name.
* @param {ReadonlyArray<string> | undefined} [caseSensitive]
* Case-sensitive tag names (default: `undefined`).
* @returns
* `h`.
*/
export function createH(schema: Schema, defaultTagName: string, caseSensitive?: ReadonlyArray<string> | undefined): {
/**
* Hyperscript compatible DSL for creating virtual hast trees.
*
* @overload
* @param {null | undefined} [selector]
* @param {...Child} children
* @returns {Root}
*
* @overload
* @param {string} selector
* @param {Properties} properties
* @param {...Child} children
* @returns {Element}
*
* @overload
* @param {string} selector
* @param {...Child} children
* @returns {Element}
*
* @param {string | null | undefined} [selector]
* Selector.
* @param {Child | Properties | null | undefined} [properties]
* Properties (or first child) (default: `undefined`).
* @param {...Child} children
* Children.
* @returns {Result}
* Result.
*/
(selector?: null | undefined, ...children: Child[]): Root;
/**
* Hyperscript compatible DSL for creating virtual hast trees.
*
* @overload
* @param {null | undefined} [selector]
* @param {...Child} children
* @returns {Root}
*
* @overload
* @param {string} selector
* @param {Properties} properties
* @param {...Child} children
* @returns {Element}
*
* @overload
* @param {string} selector
* @param {...Child} children
* @returns {Element}
*
* @param {string | null | undefined} [selector]
* Selector.
* @param {Child | Properties | null | undefined} [properties]
* Properties (or first child) (default: `undefined`).
* @param {...Child} children
* Children.
* @returns {Result}
* Result.
*/
(selector: string, properties: Properties, ...children: Child[]): Element;
/**
* Hyperscript compatible DSL for creating virtual hast trees.
*
* @overload
* @param {null | undefined} [selector]
* @param {...Child} children
* @returns {Root}
*
* @overload
* @param {string} selector
* @param {Properties} properties
* @param {...Child} children
* @returns {Element}
*
* @overload
* @param {string} selector
* @param {...Child} children
* @returns {Element}
*
* @param {string | null | undefined} [selector]
* Selector.
* @param {Child | Properties | null | undefined} [properties]
* Properties (or first child) (default: `undefined`).
* @param {...Child} children
* Children.
* @returns {Result}
* Result.
*/
(selector: string, ...children: Child[]): Element;
};
/**
* List of children (deep).
*/
export type ArrayChildNested = Array<Nodes | PrimitiveChild>;
/**
* List of children.
*/
export type ArrayChild = Array<ArrayChildNested | Nodes | PrimitiveChild>;
/**
* List of property values for space- or comma separated values (such as `className`).
*/
export type ArrayValue = Array<number | string>;
/**
* Acceptable child value.
*/
export type Child = ArrayChild | Nodes | PrimitiveChild;
/**
* Primitive children, either ignored (nullish), or turned into text nodes.
*/
export type PrimitiveChild = number | string | null | undefined;
/**
* Primitive property value.
*/
export type PrimitiveValue = boolean | number | string | null | undefined;
/**
* Acceptable value for element properties.
*/
export type Properties = Record<string, PropertyValue | Style>;
/**
* Primitive value or list value.
*/
export type PropertyValue = ArrayValue | PrimitiveValue;
/**
* Result from a `h` (or `s`) call.
*/
export type Result = Element | Root;
/**
* Value for a CSS style field.
*/
export type StyleValue = number | string;
/**
* Supported value of a `style` prop.
*/
export type Style = Record<string, StyleValue>;
import type { Schema } from 'property-information';
import type { Root } from 'hast';
import type { Element } from 'hast';
import type { Nodes } from 'hast';
//# sourceMappingURL=create-h.d.ts.map

1
node_modules/hastscript/lib/create-h.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"create-h.d.ts","sourceRoot":"","sources":["create-h.js"],"names":[],"mappings":"AAiEA;;;;;;;;;GASG;AACH,gCATW,MAAM,kBAEN,MAAM,kBAEN,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAY/B,IAAI,GAAG,SAAS,eACb,KAAK,EAAA,GACN,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAGN,MAAM,cACN,UAAU,eACP,KAAK,EAAA,GACN,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAGT,MAAM,eACH,KAAK,EAAA,GACN,OAAO;EAmDrB;;;;+BA5IY,KAAK,CAAC,KAAK,GAAG,cAAc,CAAC;;;;yBAK7B,KAAK,CAAC,gBAAgB,GAAG,KAAK,GAAG,cAAc,CAAC;;;;yBAKhD,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;;;;oBAKtB,UAAU,GAAG,KAAK,GAAG,cAAc;;;;6BAKnC,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS;;;;6BAKlC,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS;;;;yBAK5C,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,KAAK,CAAC;;;;4BAKrC,UAAU,GAAG,cAAc;;;;qBAK3B,OAAO,GAAG,IAAI;;;;yBAKd,MAAM,GAAG,MAAM;;;;oBAKf,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;4BAtDR,sBAAsB;0BADD,MAAM;6BAAN,MAAM;2BAAN,MAAM"}

365
node_modules/hastscript/lib/create-h.js generated vendored Normal file
View File

@@ -0,0 +1,365 @@
/**
* @import {Element, Nodes, RootContent, Root} from 'hast'
* @import {Info, Schema} from 'property-information'
*/
/**
* @typedef {Array<Nodes | PrimitiveChild>} ArrayChildNested
* List of children (deep).
*/
/**
* @typedef {Array<ArrayChildNested | Nodes | PrimitiveChild>} ArrayChild
* List of children.
*/
/**
* @typedef {Array<number | string>} ArrayValue
* List of property values for space- or comma separated values (such as `className`).
*/
/**
* @typedef {ArrayChild | Nodes | PrimitiveChild} Child
* Acceptable child value.
*/
/**
* @typedef {number | string | null | undefined} PrimitiveChild
* Primitive children, either ignored (nullish), or turned into text nodes.
*/
/**
* @typedef {boolean | number | string | null | undefined} PrimitiveValue
* Primitive property value.
*/
/**
* @typedef {Record<string, PropertyValue | Style>} Properties
* Acceptable value for element properties.
*/
/**
* @typedef {ArrayValue | PrimitiveValue} PropertyValue
* Primitive value or list value.
*/
/**
* @typedef {Element | Root} Result
* Result from a `h` (or `s`) call.
*/
/**
* @typedef {number | string} StyleValue
* Value for a CSS style field.
*/
/**
* @typedef {Record<string, StyleValue>} Style
* Supported value of a `style` prop.
*/
import {parse as parseCommas} from 'comma-separated-tokens'
import {parseSelector} from 'hast-util-parse-selector'
import {find, normalize} from 'property-information'
import {parse as parseSpaces} from 'space-separated-tokens'
/**
* @param {Schema} schema
* Schema to use.
* @param {string} defaultTagName
* Default tag name.
* @param {ReadonlyArray<string> | undefined} [caseSensitive]
* Case-sensitive tag names (default: `undefined`).
* @returns
* `h`.
*/
export function createH(schema, defaultTagName, caseSensitive) {
const adjust = caseSensitive ? createAdjustMap(caseSensitive) : undefined
/**
* Hyperscript compatible DSL for creating virtual hast trees.
*
* @overload
* @param {null | undefined} [selector]
* @param {...Child} children
* @returns {Root}
*
* @overload
* @param {string} selector
* @param {Properties} properties
* @param {...Child} children
* @returns {Element}
*
* @overload
* @param {string} selector
* @param {...Child} children
* @returns {Element}
*
* @param {string | null | undefined} [selector]
* Selector.
* @param {Child | Properties | null | undefined} [properties]
* Properties (or first child) (default: `undefined`).
* @param {...Child} children
* Children.
* @returns {Result}
* Result.
*/
function h(selector, properties, ...children) {
/** @type {Result} */
let node
if (selector === null || selector === undefined) {
node = {type: 'root', children: []}
// Properties are not supported for roots.
const child = /** @type {Child} */ (properties)
children.unshift(child)
} else {
node = parseSelector(selector, defaultTagName)
// Normalize the name.
const lower = node.tagName.toLowerCase()
const adjusted = adjust ? adjust.get(lower) : undefined
node.tagName = adjusted || lower
// Handle properties.
if (isChild(properties)) {
children.unshift(properties)
} else {
for (const [key, value] of Object.entries(properties)) {
addProperty(schema, node.properties, key, value)
}
}
}
// Handle children.
for (const child of children) {
addChild(node.children, child)
}
if (node.type === 'element' && node.tagName === 'template') {
node.content = {type: 'root', children: node.children}
node.children = []
}
return node
}
return h
}
/**
* Check if something is properties or a child.
*
* @param {Child | Properties} value
* Value to check.
* @returns {value is Child}
* Whether `value` is definitely a child.
*/
function isChild(value) {
// Never properties if not an object.
if (value === null || typeof value !== 'object' || Array.isArray(value)) {
return true
}
// Never node without `type`; thats the main discriminator.
if (typeof value.type !== 'string') return false
// Slower check: never property value if object or array with
// non-number/strings.
const record = /** @type {Record<string, unknown>} */ (value)
const keys = Object.keys(value)
for (const key of keys) {
const value = record[key]
if (value && typeof value === 'object') {
if (!Array.isArray(value)) return true
const list = /** @type {ReadonlyArray<unknown>} */ (value)
for (const item of list) {
if (typeof item !== 'number' && typeof item !== 'string') {
return true
}
}
}
}
// Also see empty `children` as a node.
if ('children' in value && Array.isArray(value.children)) {
return true
}
// Default to properties, someone can always pass an empty object,
// put `data: {}` in a node,
// or wrap it in an array.
return false
}
/**
* @param {Schema} schema
* Schema.
* @param {Properties} properties
* Properties object.
* @param {string} key
* Property name.
* @param {PropertyValue | Style} value
* Property value.
* @returns {undefined}
* Nothing.
*/
function addProperty(schema, properties, key, value) {
const info = find(schema, key)
/** @type {PropertyValue} */
let result
// Ignore nullish and NaN values.
if (value === null || value === undefined) 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 = parseSpaces(value)
} else if (info.commaSeparated) {
result = parseCommas(value)
} else if (info.commaOrSpaceSeparated) {
result = parseSpaces(parseCommas(value).join(' '))
} else {
result = parsePrimitive(info, info.property, value)
}
} else if (Array.isArray(value)) {
result = [...value]
} else {
result = info.property === 'style' ? style(value) : String(value)
}
if (Array.isArray(result)) {
/** @type {Array<number | string>} */
const finalResult = []
for (const item of result) {
// Assume no booleans in array.
finalResult.push(
/** @type {number | string} */ (
parsePrimitive(info, info.property, item)
)
)
}
result = finalResult
}
// Class names (which can be added both on the `selector` and here).
if (info.property === 'className' && Array.isArray(properties.className)) {
// Assume no booleans in `className`.
result = properties.className.concat(
/** @type {Array<number | string> | number | string} */ (result)
)
}
properties[info.property] = result
}
/**
* @param {Array<RootContent>} nodes
* Children.
* @param {Child} value
* Child.
* @returns {undefined}
* Nothing.
*/
function addChild(nodes, value) {
if (value === null || value === undefined) {
// Empty.
} else if (typeof value === 'number' || typeof value === 'string') {
nodes.push({type: 'text', value: String(value)})
} else if (Array.isArray(value)) {
for (const child of value) {
addChild(nodes, child)
}
} 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
* Property information.
* @param {string} name
* Property name.
* @param {PrimitiveValue} value
* Property value.
* @returns {PrimitiveValue}
* Property value.
*/
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 {Style} styles
* Style object.
* @returns {string}
* CSS string.
*/
function style(styles) {
/** @type {Array<string>} */
const result = []
for (const [key, value] of Object.entries(styles)) {
result.push([key, value].join(': '))
}
return result.join('; ')
}
/**
* Create a map to adjust casing.
*
* @param {ReadonlyArray<string>} values
* List of properly cased keys.
* @returns {Map<string, string>}
* Map of lowercase keys to uppercase keys.
*/
function createAdjustMap(values) {
/** @type {Map<string, string>} */
const result = new Map()
for (const value of values) {
result.set(value.toLowerCase(), value)
}
return result
}

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

@@ -0,0 +1,22 @@
/** @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;
}
}
import { createH } from './create-h.js';
//# sourceMappingURL=index.d.ts.map

1
node_modules/hastscript/lib/index.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"AAqBA,kCAAkC;AAClC,gBADW,UAAU,gBAAS,CACO;;;uBApBxB,OAAO,kBAAkB,EAAE,OAAO;wCAClC,OAAO,kBAAkB,EAAE,wBAAwB;mCACnD,OAAO,kBAAkB,EAAE,mBAAmB;iCAC9C,OAAO,kBAAkB,EAAE,iBAAiB;;;AAoBzD,kCAAkC;AAClC,gBADW,UAAU,gBAAS,CAC8B;;;uBAhB/C,OAAO,kBAAkB,EAAE,OAAO;wCAClC,OAAO,kBAAkB,EAAE,wBAAwB;mCACnD,OAAO,kBAAkB,EAAE,mBAAmB;iCAC9C,OAAO,kBAAkB,EAAE,iBAAiB;;;wBAInC,eAAe"}

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

@@ -0,0 +1,27 @@
// 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)

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

@@ -0,0 +1,43 @@
import type {Child, Properties, Result} from './create-h.js'
export namespace JSX {
/**
* Define the return value of JSX syntax.
*/
type Element = Result
/**
* 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
/**
* Define 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.
*/
type IntrinsicElements = Record<
string,
| Properties
| {
/**
* The prop that matches `ElementChildrenAttribute` key defines the
* type of JSX children, defines the children type.
*/
children?: Child
}
>
}

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 {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.
*/
declare const children: unique symbol
/**
* Define the return value of JSX syntax.
*/
export type Element = Result
/**
* 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
/**
* Define 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.
*/
export type IntrinsicElements = Record<
string,
| Properties
| {
/**
* The prop that matches `ElementChildrenAttribute` key defines the
* type of JSX children, defines the children type.
*/
[children]?: Child
}
>

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

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

View File

@@ -0,0 +1,7 @@
/**
* List of case-sensitive SVG tag names.
*
* @type {ReadonlyArray<string>}
*/
export const svgCaseSensitiveTagNames: ReadonlyArray<string>;
//# sourceMappingURL=svg-case-sensitive-tag-names.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"svg-case-sensitive-tag-names.d.ts","sourceRoot":"","sources":["svg-case-sensitive-tag-names.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,uCAFU,aAAa,CAAC,MAAM,CAAC,CA0C9B"}

View File

@@ -0,0 +1,46 @@
/**
* List of case-sensitive SVG tag names.
*
* @type {ReadonlyArray<string>}
*/
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'
]