From 4ecbbadf718e9d7ce60a0767fbaca47e28f5ae3b Mon Sep 17 00:00:00 2001 From: imeepos <1037483576@qq.com> Date: Fri, 3 May 2019 17:18:47 +0800 Subject: [PATCH] =?UTF-8?q?Controller=E7=BC=96=E8=AF=91=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- .../template/admin/task-edit/index.scss | 3 + .../template/admin/task-list/index.scss | 3 + framework/inc/home.ts | 10 + packages/nger-compiler-preact/lib/index.ts | 5 +- packages/nger-compiler-preact/lib/preact.ts | 35 +- packages/nger-compiler/__tests__/index.ts | 7 + packages/nger-compiler/lib/compiler.ts | 54 ++ packages/nger-compiler/lib/index.ts | 23 +- packages/nger-compiler/lib/ts/babel.ts | 5 +- packages/nger-compiler/lib/ts/typescript.ts | 64 +- .../nger-compiler/lib/visitors/controller.ts | 8 + packages/nger-util/lib/index.ts | 9 +- typings/jsx.d.ts | 891 ------------------ 14 files changed, 201 insertions(+), 918 deletions(-) create mode 100644 framework/inc/home.ts create mode 100644 packages/nger-compiler/lib/compiler.ts create mode 100644 packages/nger-compiler/lib/visitors/controller.ts delete mode 100644 typings/jsx.d.ts diff --git a/.gitignore b/.gitignore index 54f239b..ff9ee8a 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,4 @@ /**/.rts2_cache_umd /**/node_modules /app -/hooks \ No newline at end of file +/hooks diff --git a/addon/nger-todo/template/admin/task-edit/index.scss b/addon/nger-todo/template/admin/task-edit/index.scss index e69de29..1cb2f20 100644 --- a/addon/nger-todo/template/admin/task-edit/index.scss +++ b/addon/nger-todo/template/admin/task-edit/index.scss @@ -0,0 +1,3 @@ +.task-edit{ + display: block; +} \ No newline at end of file diff --git a/addon/nger-todo/template/admin/task-list/index.scss b/addon/nger-todo/template/admin/task-list/index.scss index e69de29..c9a2a89 100644 --- a/addon/nger-todo/template/admin/task-list/index.scss +++ b/addon/nger-todo/template/admin/task-list/index.scss @@ -0,0 +1,3 @@ +.task-list{ + display: block; +} \ No newline at end of file diff --git a/framework/inc/home.ts b/framework/inc/home.ts new file mode 100644 index 0000000..c355f14 --- /dev/null +++ b/framework/inc/home.ts @@ -0,0 +1,10 @@ +import { Controller, Get } from 'nger-core' + +// 首页 +@Controller({ + path: '/api' +}) +export class NgerHome { + @Get() + getSystemInfo() { } +} diff --git a/packages/nger-compiler-preact/lib/index.ts b/packages/nger-compiler-preact/lib/index.ts index 022ca3a..0a6bd5f 100644 --- a/packages/nger-compiler-preact/lib/index.ts +++ b/packages/nger-compiler-preact/lib/index.ts @@ -7,7 +7,7 @@ import { NgerCompilerPreactController } from './controller' import { StaticProvider, Injector } from 'nger-di'; import { NgerCompilerNgMetadata } from 'nger-compiler' -import { NgModuleBootstrap, NgerConfig } from 'nger-core' +import { NgModuleBootstrap, NgerConfig, Logger } from 'nger-core' import ngerCompiler, { NgerPlatformStyle } from 'nger-compiler' const provider: StaticProvider[] = [...ngerCompiler, { provide: NgModuleBootstrap, @@ -19,7 +19,8 @@ const provider: StaticProvider[] = [...ngerCompiler, { NgerCompilerPreactTypescript, NgerCompilerNgMetadata, NgerCompilerPreactController, - NgerConfig + NgerConfig, + Logger ], multi: true }, { diff --git a/packages/nger-compiler-preact/lib/preact.ts b/packages/nger-compiler-preact/lib/preact.ts index ea58024..e71aaa2 100644 --- a/packages/nger-compiler-preact/lib/preact.ts +++ b/packages/nger-compiler-preact/lib/preact.ts @@ -25,28 +25,32 @@ export class NgerCompilerPreact extends NgModuleBootstrap { ) { super(); } + // 这里需要记录一下 + cache: Map = new Map(); + // 任务是去除无用代码 async run(ref: NgModuleRef) { try { // 拿到ngModule的文件名 const framework = join(root, 'framework'); const addon = join(root, 'addon'); const handlerFile = async (opt: string, fileName: string, stats: Stats) => { - this.logger.info(`${opt}:${fileName}@${stats.atime}`) - if (fileName && stats.isFile() && (opt === 'add' || opt === 'change')) { + this.logger.info(`${opt}: ${fileName} @${stats && stats.atime}`) + const isFile = stats && stats.isFile() + if (fileName && !!isFile && (opt === 'add' || opt === 'change')) { // 拿到ngModuleMetadata const metadata = this.metadata.getMetadata(fileName); if (metadata) { - // 处理component - const component: NgerComponentConfig = this.metadata.getComponentConfig(metadata) - if (component) { - component.sourceRoot = fileName; - await Promise.all([ - this.html.run(component), - this.style.run(component), - this.assets.run(component), - this.ts.run(component), - ]); - } + // 不用处理component + // const component: NgerComponentConfig = this.metadata.getComponentConfig(metadata) + // if (component) { + // component.sourceRoot = fileName; + // await Promise.all([ + // this.html.run(component), + // this.style.run(component), + // this.assets.run(component), + // this.ts.run(component), + // ]); + // } // 处理Controller const controller: NgerControllerConfig = this.metadata.getControllerConfig(metadata); if (controller) { @@ -58,10 +62,9 @@ export class NgerCompilerPreact extends NgModuleBootstrap { } } chokidar.watch([addon, framework]) - .on('add', (opt, file, stats) => handlerFile(opt, file, stats)) - .on('change', (opt, file, stats) => handlerFile(opt, file, stats)) + .on('add', (file, stats) => handlerFile('add', file, stats)) + .on('change', (file, stats) => handlerFile('change', file, stats)) .on('error', () => { }); - } catch (e) { } } } diff --git a/packages/nger-compiler/__tests__/index.ts b/packages/nger-compiler/__tests__/index.ts index e69de29..7f5d6ef 100644 --- a/packages/nger-compiler/__tests__/index.ts +++ b/packages/nger-compiler/__tests__/index.ts @@ -0,0 +1,7 @@ +import { createPlatformFactory, NgModule } from 'nger-core' +import ngerPlatformNode from 'nger-platform-node' +import providers from '../lib' +@NgModule() +export class NgerCompilerTestModule { } +createPlatformFactory(ngerPlatformNode, 'test', providers)([]).bootstrapModule(NgerCompilerTestModule) + diff --git a/packages/nger-compiler/lib/compiler.ts b/packages/nger-compiler/lib/compiler.ts new file mode 100644 index 0000000..17bb591 --- /dev/null +++ b/packages/nger-compiler/lib/compiler.ts @@ -0,0 +1,54 @@ +import { NgModuleBootstrap, NgModuleRef, FileSystem,Logger } from 'nger-core'; +import chokidar from 'chokidar'; +import { join, relative, extname } from 'path' +import { Stats } from 'fs-extra' +import { NgerCompilerNgMetadata } from './helper/ng_metadata' +const root = process.cwd(); +import { NgerUtil } from 'nger-util' +import { NgerCompilerBabel } from './ts/babel' +export class NgerCompilerBootstrap extends NgModuleBootstrap { + constructor( + public metadata: NgerCompilerNgMetadata, + public fs: FileSystem, + public util: NgerUtil, + public babel: NgerCompilerBabel, + public logger: Logger + ) { + super(); + } + async run(ref: NgModuleRef) { + await this.watchTsx(); + } + async watchTsx() { + // 监听ts文件变更并生成metadata.json文件 + const framework = join(root, 'framework'); + const addon = join(root, 'addon'); + await this.util.rimraf(join(root, '.temp')); + chokidar.watch([`${addon}/**/*.(ts|tsx)`, `${framework}/**/*.(ts|tsx)`]) + .on('add', (file, stats) => this.handlerTsxFile('add', file, stats)) + .on('change', (file, stats) => this.handlerTsxFile('change', file, stats)) + .on('error', () => { }); + } + metadataCache: Map = new Map(); + ngModuleMetadataCache: Map = new Map(); + handlerTsxFile(opt: 'add' | 'change', file: string, stats: Stats) { + const metadata = this.metadata.getMetadata(file); + const relativePath = relative(root, file) + const ext = extname(relativePath); + const noExtPath = relativePath.replace(ext, '') + const metadataPath = join(root, '.temp', `${noExtPath}.metadata.json`); + this.fs.writeFileSync(metadataPath, JSON.stringify(metadata, null, 2)) + this.metadataCache.set(file, metadataPath) + // 解析Controller成浏览器端接口 + if (metadata) { + this.logger.info(`compiler controller`) + const config = this.metadata.getControllerConfig(metadata); + if (config) { + // 是controller + const code = this.babel.compile(file); + const controllerPath = join(root, '.temp', `${noExtPath}.js`); + this.fs.writeFileSync(controllerPath, code) + } + } + } +} \ No newline at end of file diff --git a/packages/nger-compiler/lib/index.ts b/packages/nger-compiler/lib/index.ts index 1fbcf9f..9eae774 100644 --- a/packages/nger-compiler/lib/index.ts +++ b/packages/nger-compiler/lib/index.ts @@ -3,7 +3,7 @@ import { StaticProvider } from 'nger-di' import { NgerCompilerImage } from './assets/image' import { NgerCompilerUglify } from './ts/uglify' import { NgerCompilerBabel } from './ts/babel' -import { TraverVisitor, Resolver } from 'nger-core' +import { TraverVisitor, Resolver, NgModuleBootstrap, FileSystem,Logger } from 'nger-core' import { NgerCompilerTypescript } from './ts/typescript' import { NgerCompilerRollup } from './ts/rollup' import { NgerCompilerNgTemplate } from './html/ng' @@ -18,10 +18,29 @@ export { NgerCompilerRollup, NgerCompilerNgTemplate, NgerCompilerCid, - NgerCompilerNgMetadata + NgerCompilerNgMetadata, + NgerCompilerBootstrap } +import { NgerCompilerBootstrap } from './compiler' +import { NgerUtil } from 'nger-util' +import { controllerVisitor } from './visitors/controller' const provides: StaticProvider[] = [ ...styleProviders, + { + provide: TraverVisitor, + useValue: controllerVisitor, + multi: true + }, + { + provide: NgModuleBootstrap, + useExisting: NgerCompilerBootstrap, + multi: true + }, + { + provide: NgerCompilerBootstrap, + useClass: NgerCompilerBootstrap, + deps: [NgerCompilerNgMetadata, FileSystem, NgerUtil, NgerCompilerBabel,Logger], + }, { provide: NgerCompilerNgMetadata, useClass: NgerCompilerNgMetadata, diff --git a/packages/nger-compiler/lib/ts/babel.ts b/packages/nger-compiler/lib/ts/babel.ts index c5298c9..fce694b 100644 --- a/packages/nger-compiler/lib/ts/babel.ts +++ b/packages/nger-compiler/lib/ts/babel.ts @@ -6,7 +6,6 @@ import fs from 'fs-extra'; import { Injectable } from 'nger-core'; import { NgerCompilerTypescript } from 'nger-compiler'; - function mergeVisitors(visitors: Visitor[], that: NgerCompilerBabel): Visitor { if (visitors && visitors.length > 0) { if (visitors.length === 1) { @@ -55,14 +54,14 @@ export class NgerCompilerBabel { } return code; } - copy(from: string) { + compile(from: string) { // 如果已经处理过了则忽略 // 拿到文件内容 let code = this.getFileContent(from); // 解析 const ast = parse(code, {}); // 替换处理 - traverse(ast, this.visitor); + traverse(ast, this.visitor || {}); code = generator(ast).code; return code; } diff --git a/packages/nger-compiler/lib/ts/typescript.ts b/packages/nger-compiler/lib/ts/typescript.ts index aeec1b1..bc8720d 100644 --- a/packages/nger-compiler/lib/ts/typescript.ts +++ b/packages/nger-compiler/lib/ts/typescript.ts @@ -3,13 +3,73 @@ import ts from 'typescript' import { join } from 'path' const root = process.cwd(); const options = require(join(root, 'tsconfig.json')).compilerOptions; -import { CompilerOptions } from 'typescript' +import { CompilerOptions, CustomTransformers, TransformationContext, Transformer } from 'typescript' +// 遍历吧 没啥好方法 + +// 这个是负责任Controller处理器 +const ConstructorTransformerFactory = (context: TransformationContext): Transformer => { + return (node: ts.SourceFile): ts.SourceFile => { + // 骚年在这里处理吧 + node.statements = ts.createNodeArray( + node.statements.map((node: ts.Statement) => { + if (ts.isImportDeclaration(node)) { + return node; + } else if (ts.isClassDeclaration(node)) { + return ts.createClassDeclaration( + node.decorators, + node.modifiers, + node.name, + node.typeParameters, + node.heritageClauses, + node.members.map(member => { + if (ts.isMethodDeclaration(member)) { + // 先判断是否Get/Post等方法 + // 这里需要创建一个type + const isController = hasControllerMetadata(member.decorators); + if (isController) { + debugger; + return ts.createProperty(member.decorators, member.modifiers, member.name, null, null, null) + } else { + return member; + } + } else { + return member; + } + }) + ) + } else { + return node; + } + }) + ) + return node; + } +} + +function hasControllerMetadata(nodes: ts.NodeArray) { + return !!nodes.find(node => { + if (ts.isDecorator(node)) { + if (ts.isIdentifier(node.expression)) { + return ['Get', 'Post'].indexOf(node.expression.text) > -1; + } + } + return false; + }) +} +const customTransformer: CustomTransformers = { + before: [ + ConstructorTransformerFactory + ], + after: [], + afterDeclarations: [] +} @Injectable() export class NgerCompilerTypescript { options: CompilerOptions = options; constructor() { } compile(content: string, config: ts.TranspileOptions = { - compilerOptions: this.options + compilerOptions: this.options, + transformers: customTransformer }): string { const output = ts.transpileModule(content, config) return output.outputText diff --git a/packages/nger-compiler/lib/visitors/controller.ts b/packages/nger-compiler/lib/visitors/controller.ts new file mode 100644 index 0000000..61c1681 --- /dev/null +++ b/packages/nger-compiler/lib/visitors/controller.ts @@ -0,0 +1,8 @@ +import { Visitor, NodePath } from '@babel/traverse'; +import t from '@babel/types'; + +export const controllerVisitor: Visitor = { + // 转义Controller里面的Get/Post等,删除Injector + ClassMethod(path: NodePath) { } +} + diff --git a/packages/nger-util/lib/index.ts b/packages/nger-util/lib/index.ts index 5c33a8b..aa72f2e 100644 --- a/packages/nger-util/lib/index.ts +++ b/packages/nger-util/lib/index.ts @@ -3,9 +3,16 @@ import { execSync } from 'child_process'; import { join } from 'path'; import { Logger, NgerConfig } from 'nger-core'; import { CompilerOptions } from 'typescript' +import rimraf = require('rimraf'); + export class NgerUtil { root: string = process.cwd() constructor(public logger: Logger, public config: NgerConfig) { } + rimraf(dir: string) { + return new Promise((resolve, reject) => { + rimraf(dir, () => resolve()) + }); + } getCompilerOptions(): CompilerOptions { return require(join(this.root, 'tsconfig')).compilerOptions } @@ -32,7 +39,7 @@ export class NgerUtil { // cnpm 优先 if (this.shouldUseCnpm()) { this.config.set('npm', 'cnpm') - }else if (this.shouldUseYarn()) { + } else if (this.shouldUseYarn()) { this.config.set('npm', 'yarn') } else { this.config.set('npm', 'npm') diff --git a/typings/jsx.d.ts b/typings/jsx.d.ts deleted file mode 100644 index 5a37bb5..0000000 --- a/typings/jsx.d.ts +++ /dev/null @@ -1,891 +0,0 @@ -declare namespace preact { - type Key = string | number; - type Ref = (instance: T) => void; - type ComponentChild = VNode | object | string | number | boolean | null; - type ComponentChildren = ComponentChild[] | ComponentChild; - - /** - * @deprecated - * - * Use Attributes instead - */ - type ComponentProps = Attributes; - - /** - * @deprecated - * - * Use ClassAttributes instead - */ - type PreactHTMLAttributes = ClassAttributes; - - interface Attributes { - key?: Key; - jsx?: boolean; - } - - interface ClassAttributes extends Attributes { - ref?: Ref; - } - - interface PreactDOMAttributes { - children?: ComponentChildren; - dangerouslySetInnerHTML?: { - __html: string; - }; - } - - type ComponentFactory

= ComponentConstructor

| FunctionalComponent

; - /** - * Define the contract for a virtual node in preact. - * - * A virtual node has a name, a map of attributes, an array - * of child {VNode}s and a key. The key is used by preact for - * internal purposes. - */ - interface VNode

{ - nodeName: ComponentFactory

| string; - attributes: P; - children: Array | string>; - key?: Key | null; - } - - type RenderableProps = Readonly< - P & Attributes & { children?: ComponentChildren; ref?: Ref } - >; - - interface FunctionalComponent

{ - (props: RenderableProps

, context?: any): VNode | null; - displayName?: string; - defaultProps?: Partial

; - } - - interface ComponentConstructor

{ - new(props: P, context?: any): Component; - displayName?: string; - defaultProps?: Partial

; - } - - // Type alias for a component considered generally, whether stateless or stateful. - type AnyComponent

= FunctionalComponent

| ComponentConstructor; - - interface Component

{ - componentWillMount?(): void; - componentDidMount?(): void; - componentWillUnmount?(): void; - getChildContext?(): object; - componentWillReceiveProps?(nextProps: Readonly

, nextContext: any): void; - shouldComponentUpdate?(nextProps: Readonly

, nextState: Readonly, nextContext: any): boolean; - componentWillUpdate?(nextProps: Readonly

, nextState: Readonly, nextContext: any): void; - componentDidUpdate?(previousProps: Readonly

, previousState: Readonly, previousContext: any): void; - } - - abstract class Component { - constructor(props?: P, context?: any); - - static displayName?: string; - static defaultProps?: any; - - state: Readonly; - props: RenderableProps

; - context: any; - base?: HTMLElement; - - setState(state: Pick, callback?: () => void): void; - setState(fn: (prevState: S, props: P) => Pick, callback?: () => void): void; - - forceUpdate(callback?: () => void): void; - - abstract render(props?: RenderableProps

, state?: Readonly, context?: any): ComponentChild; - } - - function h( - node: string, - params: JSX.HTMLAttributes & JSX.SVGAttributes & Record | null, - ...children: ComponentChildren[] - ): VNode; - function h

( - node: ComponentFactory

, - params: Attributes & P | null, - ...children: ComponentChildren[] - ): VNode; - - function render(node: ComponentChild, parent: Element | Document | ShadowRoot | DocumentFragment, mergeWith?: Element): Element; - function rerender(): void; - function cloneElement(element: JSX.Element, props: any, ...children: ComponentChildren[]): JSX.Element; - - var options: { - syncComponentUpdates?: boolean; - debounceRendering?: (render: () => void) => void; - vnode?: (vnode: VNode) => void; - event?: (event: Event) => Event; - }; -} - -type Defaultize = - // Distribute over unions - Props extends any - ? // Make any properties included in Default optional - & Partial>> - // Include the remaining properties from Props - & Pick> - : never; - -declare global { - namespace JSX { - interface Element extends preact.VNode { } - interface ElementClass extends preact.Component { } - interface ElementAttributesProperty { - props: any; - } - interface ElementChildrenAttribute { - children: any; - } - type LibraryManagedAttributes = - Component extends { defaultProps: infer Defaults } - ? Defaultize - : Props; - interface SVGAttributes extends HTMLAttributes { - accentHeight?: number | string; - accumulate?: "none" | "sum"; - additive?: "replace" | "sum"; - alignmentBaseline?: "auto" | "baseline" | "before-edge" | "text-before-edge" | "middle" | "central" | "after-edge" | "text-after-edge" | "ideographic" | "alphabetic" | "hanging" | "mathematical" | "inherit"; - allowReorder?: "no" | "yes"; - alphabetic?: number | string; - amplitude?: number | string; - arabicForm?: "initial" | "medial" | "terminal" | "isolated"; - ascent?: number | string; - attributeName?: string; - attributeType?: string; - autoReverse?: number | string; - azimuth?: number | string; - baseFrequency?: number | string; - baselineShift?: number | string; - baseProfile?: number | string; - bbox?: number | string; - begin?: number | string; - bias?: number | string; - by?: number | string; - calcMode?: number | string; - capHeight?: number | string; - clip?: number | string; - clipPath?: string; - clipPathUnits?: number | string; - clipRule?: number | string; - colorInterpolation?: number | string; - colorInterpolationFilters?: "auto" | "sRGB" | "linearRGB" | "inherit"; - colorProfile?: number | string; - colorRendering?: number | string; - contentScriptType?: number | string; - contentStyleType?: number | string; - cursor?: number | string; - cx?: number | string; - cy?: number | string; - d?: string; - decelerate?: number | string; - descent?: number | string; - diffuseConstant?: number | string; - direction?: number | string; - display?: number | string; - divisor?: number | string; - dominantBaseline?: number | string; - dur?: number | string; - dx?: number | string; - dy?: number | string; - edgeMode?: number | string; - elevation?: number | string; - enableBackground?: number | string; - end?: number | string; - exponent?: number | string; - externalResourcesRequired?: number | string; - fill?: string; - fillOpacity?: number | string; - fillRule?: "nonzero" | "evenodd" | "inherit"; - filter?: string; - filterRes?: number | string; - filterUnits?: number | string; - floodColor?: number | string; - floodOpacity?: number | string; - focusable?: number | string; - fontFamily?: string; - fontSize?: number | string; - fontSizeAdjust?: number | string; - fontStretch?: number | string; - fontStyle?: number | string; - fontVariant?: number | string; - fontWeight?: number | string; - format?: number | string; - from?: number | string; - fx?: number | string; - fy?: number | string; - g1?: number | string; - g2?: number | string; - glyphName?: number | string; - glyphOrientationHorizontal?: number | string; - glyphOrientationVertical?: number | string; - glyphRef?: number | string; - gradientTransform?: string; - gradientUnits?: string; - hanging?: number | string; - horizAdvX?: number | string; - horizOriginX?: number | string; - ideographic?: number | string; - imageRendering?: number | string; - in2?: number | string; - in?: string; - intercept?: number | string; - k1?: number | string; - k2?: number | string; - k3?: number | string; - k4?: number | string; - k?: number | string; - kernelMatrix?: number | string; - kernelUnitLength?: number | string; - kerning?: number | string; - keyPoints?: number | string; - keySplines?: number | string; - keyTimes?: number | string; - lengthAdjust?: number | string; - letterSpacing?: number | string; - lightingColor?: number | string; - limitingConeAngle?: number | string; - local?: number | string; - markerEnd?: string; - markerHeight?: number | string; - markerMid?: string; - markerStart?: string; - markerUnits?: number | string; - markerWidth?: number | string; - mask?: string; - maskContentUnits?: number | string; - maskUnits?: number | string; - mathematical?: number | string; - mode?: number | string; - numOctaves?: number | string; - offset?: number | string; - opacity?: number | string; - operator?: number | string; - order?: number | string; - orient?: number | string; - orientation?: number | string; - origin?: number | string; - overflow?: number | string; - overlinePosition?: number | string; - overlineThickness?: number | string; - paintOrder?: number | string; - panose1?: number | string; - pathLength?: number | string; - patternContentUnits?: string; - patternTransform?: number | string; - patternUnits?: string; - pointerEvents?: number | string; - points?: string; - pointsAtX?: number | string; - pointsAtY?: number | string; - pointsAtZ?: number | string; - preserveAlpha?: number | string; - preserveAspectRatio?: string; - primitiveUnits?: number | string; - r?: number | string; - radius?: number | string; - refX?: number | string; - refY?: number | string; - renderingIntent?: number | string; - repeatCount?: number | string; - repeatDur?: number | string; - requiredExtensions?: number | string; - requiredFeatures?: number | string; - restart?: number | string; - result?: string; - rotate?: number | string; - rx?: number | string; - ry?: number | string; - scale?: number | string; - seed?: number | string; - shapeRendering?: number | string; - slope?: number | string; - spacing?: number | string; - specularConstant?: number | string; - specularExponent?: number | string; - speed?: number | string; - spreadMethod?: string; - startOffset?: number | string; - stdDeviation?: number | string; - stemh?: number | string; - stemv?: number | string; - stitchTiles?: number | string; - stopColor?: string; - stopOpacity?: number | string; - strikethroughPosition?: number | string; - strikethroughThickness?: number | string; - string?: number | string; - stroke?: string; - strokeDasharray?: string | number; - strokeDashoffset?: string | number; - strokeLinecap?: "butt" | "round" | "square" | "inherit"; - strokeLinejoin?: "miter" | "round" | "bevel" | "inherit"; - strokeMiterlimit?: string; - strokeOpacity?: number | string; - strokeWidth?: number | string; - surfaceScale?: number | string; - systemLanguage?: number | string; - tableValues?: number | string; - targetX?: number | string; - targetY?: number | string; - textAnchor?: string; - textDecoration?: number | string; - textLength?: number | string; - textRendering?: number | string; - to?: number | string; - transform?: string; - u1?: number | string; - u2?: number | string; - underlinePosition?: number | string; - underlineThickness?: number | string; - unicode?: number | string; - unicodeBidi?: number | string; - unicodeRange?: number | string; - unitsPerEm?: number | string; - vAlphabetic?: number | string; - values?: string; - vectorEffect?: number | string; - version?: string; - vertAdvY?: number | string; - vertOriginX?: number | string; - vertOriginY?: number | string; - vHanging?: number | string; - vIdeographic?: number | string; - viewBox?: string; - viewTarget?: number | string; - visibility?: number | string; - vMathematical?: number | string; - widths?: number | string; - wordSpacing?: number | string; - writingMode?: number | string; - x1?: number | string; - x2?: number | string; - x?: number | string; - xChannelSelector?: string; - xHeight?: number | string; - xlinkActuate?: string; - xlinkArcrole?: string; - xlinkHref?: string; - xlinkRole?: string; - xlinkShow?: string; - xlinkTitle?: string; - xlinkType?: string; - xmlBase?: string; - xmlLang?: string; - xmlns?: string; - xmlnsXlink?: string; - xmlSpace?: string; - y1?: number | string; - y2?: number | string; - y?: number | string; - yChannelSelector?: string; - z?: number | string; - zoomAndPan?: string; - } - interface PathAttributes { - d: string; - } - interface EventHandler { - (event: E): void; - } - type ClipboardEventHandler = EventHandler; - type CompositionEventHandler = EventHandler; - type DragEventHandler = EventHandler; - type FocusEventHandler = EventHandler; - type KeyboardEventHandler = EventHandler; - type MouseEventHandler = EventHandler; - type TouchEventHandler = EventHandler; - type UIEventHandler = EventHandler; - type WheelEventHandler = EventHandler; - type AnimationEventHandler = EventHandler; - type TransitionEventHandler = EventHandler; - type GenericEventHandler = EventHandler; - type PointerEventHandler = EventHandler; - interface DOMAttributes extends preact.PreactDOMAttributes { - // Image Events - onLoad?: GenericEventHandler; - onError?: GenericEventHandler; - onLoadCapture?: GenericEventHandler; - - // Clipboard Events - onCopy?: ClipboardEventHandler; - onCopyCapture?: ClipboardEventHandler; - onCut?: ClipboardEventHandler; - onCutCapture?: ClipboardEventHandler; - onPaste?: ClipboardEventHandler; - onPasteCapture?: ClipboardEventHandler; - - // Composition Events - onCompositionEnd?: CompositionEventHandler; - onCompositionEndCapture?: CompositionEventHandler; - onCompositionStart?: CompositionEventHandler; - onCompositionStartCapture?: CompositionEventHandler; - onCompositionUpdate?: CompositionEventHandler; - onCompositionUpdateCapture?: CompositionEventHandler; - - // Focus Events - onFocus?: FocusEventHandler; - onFocusCapture?: FocusEventHandler; - onBlur?: FocusEventHandler; - onBlurCapture?: FocusEventHandler; - - // Form Events - onChange?: GenericEventHandler; - onChangeCapture?: GenericEventHandler; - onInput?: GenericEventHandler; - onInputCapture?: GenericEventHandler; - onSearch?: GenericEventHandler; - onSearchCapture?: GenericEventHandler; - onSubmit?: GenericEventHandler; - onSubmitCapture?: GenericEventHandler; - onInvalid?: GenericEventHandler; - - // Keyboard Events - onKeyDown?: KeyboardEventHandler; - onKeyDownCapture?: KeyboardEventHandler; - onKeyPress?: KeyboardEventHandler; - onKeyPressCapture?: KeyboardEventHandler; - onKeyUp?: KeyboardEventHandler; - onKeyUpCapture?: KeyboardEventHandler; - - // Media Events - onAbort?: GenericEventHandler; - onAbortCapture?: GenericEventHandler; - onCanPlay?: GenericEventHandler; - onCanPlayCapture?: GenericEventHandler; - onCanPlayThrough?: GenericEventHandler; - onCanPlayThroughCapture?: GenericEventHandler; - onDurationChange?: GenericEventHandler; - onDurationChangeCapture?: GenericEventHandler; - onEmptied?: GenericEventHandler; - onEmptiedCapture?: GenericEventHandler; - onEncrypted?: GenericEventHandler; - onEncryptedCapture?: GenericEventHandler; - onEnded?: GenericEventHandler; - onEndedCapture?: GenericEventHandler; - onLoadedData?: GenericEventHandler; - onLoadedDataCapture?: GenericEventHandler; - onLoadedMetadata?: GenericEventHandler; - onLoadedMetadataCapture?: GenericEventHandler; - onLoadStart?: GenericEventHandler; - onLoadStartCapture?: GenericEventHandler; - onPause?: GenericEventHandler; - onPauseCapture?: GenericEventHandler; - onPlay?: GenericEventHandler; - onPlayCapture?: GenericEventHandler; - onPlaying?: GenericEventHandler; - onPlayingCapture?: GenericEventHandler; - onProgress?: GenericEventHandler; - onProgressCapture?: GenericEventHandler; - onRateChange?: GenericEventHandler; - onRateChangeCapture?: GenericEventHandler; - onSeeked?: GenericEventHandler; - onSeekedCapture?: GenericEventHandler; - onSeeking?: GenericEventHandler; - onSeekingCapture?: GenericEventHandler; - onStalled?: GenericEventHandler; - onStalledCapture?: GenericEventHandler; - onSuspend?: GenericEventHandler; - onSuspendCapture?: GenericEventHandler; - onTimeUpdate?: GenericEventHandler; - onTimeUpdateCapture?: GenericEventHandler; - onVolumeChange?: GenericEventHandler; - onVolumeChangeCapture?: GenericEventHandler; - onWaiting?: GenericEventHandler; - onWaitingCapture?: GenericEventHandler; - - // MouseEvents - onClick?: MouseEventHandler; - onClickCapture?: MouseEventHandler; - onContextMenu?: MouseEventHandler; - onContextMenuCapture?: MouseEventHandler; - onDblClick?: MouseEventHandler; - onDblClickCapture?: MouseEventHandler; - onDrag?: DragEventHandler; - onDragCapture?: DragEventHandler; - onDragEnd?: DragEventHandler; - onDragEndCapture?: DragEventHandler; - onDragEnter?: DragEventHandler; - onDragEnterCapture?: DragEventHandler; - onDragExit?: DragEventHandler; - onDragExitCapture?: DragEventHandler; - onDragLeave?: DragEventHandler; - onDragLeaveCapture?: DragEventHandler; - onDragOver?: DragEventHandler; - onDragOverCapture?: DragEventHandler; - onDragStart?: DragEventHandler; - onDragStartCapture?: DragEventHandler; - onDrop?: DragEventHandler; - onDropCapture?: DragEventHandler; - onMouseDown?: MouseEventHandler; - onMouseDownCapture?: MouseEventHandler; - onMouseEnter?: MouseEventHandler; - onMouseEnterCapture?: MouseEventHandler; - onMouseLeave?: MouseEventHandler; - onMouseLeaveCapture?: MouseEventHandler; - onMouseMove?: MouseEventHandler; - onMouseMoveCapture?: MouseEventHandler; - onMouseOut?: MouseEventHandler; - onMouseOutCapture?: MouseEventHandler; - onMouseOver?: MouseEventHandler; - onMouseOverCapture?: MouseEventHandler; - onMouseUp?: MouseEventHandler; - onMouseUpCapture?: MouseEventHandler; - - // Selection Events - onSelect?: GenericEventHandler; - onSelectCapture?: GenericEventHandler; - - // Touch Events - onTouchCancel?: TouchEventHandler; - onTouchCancelCapture?: TouchEventHandler; - onTouchEnd?: TouchEventHandler; - onTouchEndCapture?: TouchEventHandler; - onTouchMove?: TouchEventHandler; - onTouchMoveCapture?: TouchEventHandler; - onTouchStart?: TouchEventHandler; - onTouchStartCapture?: TouchEventHandler; - - // Pointer Events - onPointerOver?: PointerEventHandler; - onPointerOverCapture?: PointerEventHandler; - onPointerEnter?: PointerEventHandler; - onPointerEnterCapture?: PointerEventHandler; - onPointerDown?: PointerEventHandler; - onPointerDownCapture?: PointerEventHandler; - onPointerMove?: PointerEventHandler; - onPointerMoveCapture?: PointerEventHandler; - onPointerUp?: PointerEventHandler; - onPointerUpCapture?: PointerEventHandler; - onPointerCancel?: PointerEventHandler; - onPointerCancelCapture?: PointerEventHandler; - onPointerOut?: PointerEventHandler; - onPointerOutCapture?: PointerEventHandler; - onPointerLeave?: PointerEventHandler; - onPointerLeaveCapture?: PointerEventHandler; - onGotPointerCapture?: PointerEventHandler; - onGotPointerCaptureCapture?: PointerEventHandler; - onLostPointerCapture?: PointerEventHandler; - onLostPointerCaptureCapture?: PointerEventHandler; - - // UI Events - onScroll?: UIEventHandler; - onScrollCapture?: UIEventHandler; - - // Wheel Events - onWheel?: WheelEventHandler; - onWheelCapture?: WheelEventHandler; - - // Animation Events - onAnimationStart?: AnimationEventHandler; - onAnimationStartCapture?: AnimationEventHandler; - onAnimationEnd?: AnimationEventHandler; - onAnimationEndCapture?: AnimationEventHandler; - onAnimationIteration?: AnimationEventHandler; - onAnimationIterationCapture?: AnimationEventHandler; - - // Transition Events - onTransitionEnd?: TransitionEventHandler; - onTransitionEndCapture?: TransitionEventHandler; - } - interface HTMLAttributes extends preact.PreactHTMLAttributes, DOMAttributes { - // Standard HTML Attributes - accept?: string; - acceptCharset?: string; - accessKey?: string; - action?: string; - allowFullScreen?: boolean; - allowTransparency?: boolean; - alt?: string; - async?: boolean; - autocomplete?: string; - autofocus?: boolean; - autoPlay?: boolean; - capture?: boolean; - cellPadding?: number | string; - cellSpacing?: number | string; - charSet?: string; - challenge?: string; - checked?: boolean; - class?: string; - className?: string; - cols?: number; - colSpan?: number; - content?: string; - contentEditable?: boolean; - contextMenu?: string; - controls?: boolean; - controlsList?: string; - coords?: string; - crossOrigin?: string; - data?: string; - dateTime?: string; - default?: boolean; - defer?: boolean; - dir?: string; - disabled?: boolean; - download?: any; - draggable?: boolean; - encType?: string; - form?: string; - formAction?: string; - formEncType?: string; - formMethod?: string; - formNoValidate?: boolean; - formTarget?: string; - frameBorder?: number | string; - headers?: string; - height?: number | string; - hidden?: boolean; - high?: number; - href?: string; - hrefLang?: string; - for?: string; - httpEquiv?: string; - icon?: string; - id?: string; - inputMode?: string; - integrity?: string; - is?: string; - keyParams?: string; - keyType?: string; - kind?: string; - label?: string; - lang?: string; - list?: string; - loop?: boolean; - low?: number; - manifest?: string; - marginHeight?: number; - marginWidth?: number; - max?: number | string; - maxLength?: number; - media?: string; - mediaGroup?: string; - method?: string; - min?: number | string; - minLength?: number; - multiple?: boolean; - muted?: boolean; - name?: string; - noValidate?: boolean; - open?: boolean; - optimum?: number; - pattern?: string; - placeholder?: string; - playsInline?: boolean; - poster?: string; - preload?: string; - radioGroup?: string; - readOnly?: boolean; - rel?: string; - required?: boolean; - role?: string; - rows?: number; - rowSpan?: number; - sandbox?: string; - scope?: string; - scoped?: boolean; - scrolling?: string; - seamless?: boolean; - selected?: boolean; - shape?: string; - size?: number; - sizes?: string; - slot?: string; - span?: number; - spellcheck?: boolean; - src?: string; - srcset?: string; - srcDoc?: string; - srcLang?: string; - srcSet?: string; - start?: number; - step?: number | string; - style?: any; - summary?: string; - tabIndex?: number; - target?: string; - title?: string; - type?: string; - useMap?: string; - value?: string | string[] | number; - width?: number | string; - wmode?: string; - wrap?: string; - - // RDFa Attributes - about?: string; - datatype?: string; - inlist?: any; - prefix?: string; - property?: string; - resource?: string; - typeof?: string; - vocab?: string; - } - interface IntrinsicElements { - // HTML - a: HTMLAttributes; - abbr: HTMLAttributes; - address: HTMLAttributes; - area: HTMLAttributes; - article: HTMLAttributes; - aside: HTMLAttributes; - audio: HTMLAttributes; - b: HTMLAttributes; - base: HTMLAttributes; - bdi: HTMLAttributes; - bdo: HTMLAttributes; - big: HTMLAttributes; - blockquote: HTMLAttributes; - body: HTMLAttributes; - br: HTMLAttributes; - button: HTMLAttributes; - canvas: HTMLAttributes; - caption: HTMLAttributes; - cite: HTMLAttributes; - code: HTMLAttributes; - col: HTMLAttributes; - colgroup: HTMLAttributes; - data: HTMLAttributes; - datalist: HTMLAttributes; - dd: HTMLAttributes; - del: HTMLAttributes; - details: HTMLAttributes; - dfn: HTMLAttributes; - dialog: HTMLAttributes; - div: HTMLAttributes; - dl: HTMLAttributes; - dt: HTMLAttributes; - em: HTMLAttributes; - embed: HTMLAttributes; - fieldset: HTMLAttributes; - figcaption: HTMLAttributes; - figure: HTMLAttributes; - footer: HTMLAttributes; - form: HTMLAttributes; - h1: HTMLAttributes; - h2: HTMLAttributes; - h3: HTMLAttributes; - h4: HTMLAttributes; - h5: HTMLAttributes; - h6: HTMLAttributes; - head: HTMLAttributes; - header: HTMLAttributes; - hr: HTMLAttributes; - html: HTMLAttributes; - i: HTMLAttributes; - iframe: HTMLAttributes; - img: HTMLAttributes; - input: HTMLAttributes; - ins: HTMLAttributes; - kbd: HTMLAttributes; - keygen: HTMLAttributes; - label: HTMLAttributes; - legend: HTMLAttributes; - li: HTMLAttributes; - link: HTMLAttributes; - main: HTMLAttributes; - map: HTMLAttributes; - mark: HTMLAttributes; - menu: HTMLAttributes; - menuitem: HTMLAttributes; - meta: HTMLAttributes; - meter: HTMLAttributes; - nav: HTMLAttributes; - noscript: HTMLAttributes; - object: HTMLAttributes; - ol: HTMLAttributes; - optgroup: HTMLAttributes; - option: HTMLAttributes; - output: HTMLAttributes; - p: HTMLAttributes; - param: HTMLAttributes; - picture: HTMLAttributes; - pre: HTMLAttributes; - progress: HTMLAttributes; - q: HTMLAttributes; - rp: HTMLAttributes; - rt: HTMLAttributes; - ruby: HTMLAttributes; - s: HTMLAttributes; - samp: HTMLAttributes; - script: HTMLAttributes; - section: HTMLAttributes; - select: HTMLAttributes; - slot: HTMLAttributes; - small: HTMLAttributes; - source: HTMLAttributes; - span: HTMLAttributes; - strong: HTMLAttributes; - style: HTMLAttributes; - sub: HTMLAttributes; - summary: HTMLAttributes; - sup: HTMLAttributes; - table: HTMLAttributes; - tbody: HTMLAttributes; - td: HTMLAttributes; - textarea: HTMLAttributes; - tfoot: HTMLAttributes; - th: HTMLAttributes; - thead: HTMLAttributes; - time: HTMLAttributes; - title: HTMLAttributes; - tr: HTMLAttributes; - track: HTMLAttributes; - u: HTMLAttributes; - ul: HTMLAttributes; - "var": HTMLAttributes; - video: HTMLAttributes; - wbr: HTMLAttributes; - - //SVG - svg: SVGAttributes; - animate: SVGAttributes; - circle: SVGAttributes; - clipPath: SVGAttributes; - defs: SVGAttributes; - ellipse: SVGAttributes; - feBlend: SVGAttributes; - feColorMatrix: SVGAttributes; - feComponentTransfer: SVGAttributes; - feComposite: SVGAttributes; - feConvolveMatrix: SVGAttributes; - feDiffuseLighting: SVGAttributes; - feDisplacementMap: SVGAttributes; - feFlood: SVGAttributes; - feGaussianBlur: SVGAttributes; - feImage: SVGAttributes; - feMerge: SVGAttributes; - feMergeNode: SVGAttributes; - feMorphology: SVGAttributes; - feOffset: SVGAttributes; - feSpecularLighting: SVGAttributes; - feTile: SVGAttributes; - feTurbulence: SVGAttributes; - filter: SVGAttributes; - foreignObject: SVGAttributes; - g: SVGAttributes; - image: SVGAttributes; - line: SVGAttributes; - linearGradient: SVGAttributes; - marker: SVGAttributes; - mask: SVGAttributes; - path: SVGAttributes; - pattern: SVGAttributes; - polygon: SVGAttributes; - polyline: SVGAttributes; - radialGradient: SVGAttributes; - rect: SVGAttributes; - stop: SVGAttributes; - symbol: SVGAttributes; - text: SVGAttributes; - tspan: SVGAttributes; - use: SVGAttributes; - } - } -}