diff --git a/types/gl-react-dom/index.d.ts b/types/gl-react-dom/index.d.ts new file mode 100644 index 0000000000..8d25b244ee --- /dev/null +++ b/types/gl-react-dom/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for gl-react-dom 3.15 +// Project: https://github.com/gre/gl-react +// Definitions by: Jussi Kinnula +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from 'react'; +import * as glReact from 'gl-react'; + +export interface SurfaceProps extends glReact.SurfaceProps { + width: number; + height: number; +} + +export class Surface extends glReact.Surface { + props: SurfaceProps; +} diff --git a/types/gl-react-dom/tsconfig.json b/types/gl-react-dom/tsconfig.json new file mode 100644 index 0000000000..9c4d38ca44 --- /dev/null +++ b/types/gl-react-dom/tsconfig.json @@ -0,0 +1,24 @@ +{ + "files": [ + "index.d.ts" + ], + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "preserve" + } +} diff --git a/types/gl-react-dom/tslint.json b/types/gl-react-dom/tslint.json new file mode 100644 index 0000000000..b4b47a0378 --- /dev/null +++ b/types/gl-react-dom/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/gl-react-expo/index.d.ts b/types/gl-react-expo/index.d.ts new file mode 100644 index 0000000000..20a1e19928 --- /dev/null +++ b/types/gl-react-expo/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for gl-react-expo 3.16 +// Project: https://github.com/gre/gl-react +// Definitions by: Jussi Kinnula +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import { Surface } from 'gl-react'; +export { Surface }; diff --git a/types/gl-react-expo/tsconfig.json b/types/gl-react-expo/tsconfig.json new file mode 100644 index 0000000000..9c4d38ca44 --- /dev/null +++ b/types/gl-react-expo/tsconfig.json @@ -0,0 +1,24 @@ +{ + "files": [ + "index.d.ts" + ], + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "preserve" + } +} diff --git a/types/gl-react-expo/tslint.json b/types/gl-react-expo/tslint.json new file mode 100644 index 0000000000..b4b47a0378 --- /dev/null +++ b/types/gl-react-expo/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/gl-react-headless/index.d.ts b/types/gl-react-headless/index.d.ts new file mode 100644 index 0000000000..a8b0ec5212 --- /dev/null +++ b/types/gl-react-headless/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for gl-react-headless 3.15 +// Project: https://github.com/gre/gl-react +// Definitions by: Jussi Kinnula +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from 'react'; +import * as glReact from 'gl-react'; + +export interface SurfaceProps extends glReact.SurfaceProps { + width: number; + height: number; +} + +export class Surface extends glReact.Surface { + props: SurfaceProps; +} diff --git a/types/gl-react-headless/tsconfig.json b/types/gl-react-headless/tsconfig.json new file mode 100644 index 0000000000..9c4d38ca44 --- /dev/null +++ b/types/gl-react-headless/tsconfig.json @@ -0,0 +1,24 @@ +{ + "files": [ + "index.d.ts" + ], + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "preserve" + } +} diff --git a/types/gl-react-headless/tslint.json b/types/gl-react-headless/tslint.json new file mode 100644 index 0000000000..b4b47a0378 --- /dev/null +++ b/types/gl-react-headless/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/gl-react-native/index.d.ts b/types/gl-react-native/index.d.ts new file mode 100644 index 0000000000..b9bce2a806 --- /dev/null +++ b/types/gl-react-native/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for gl-react-native 3.15 +// Project: https://github.com/gre/gl-react +// Definitions by: Jussi Kinnula +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import { Surface } from 'gl-react'; +export { Surface }; diff --git a/types/gl-react-native/tsconfig.json b/types/gl-react-native/tsconfig.json new file mode 100644 index 0000000000..9c4d38ca44 --- /dev/null +++ b/types/gl-react-native/tsconfig.json @@ -0,0 +1,24 @@ +{ + "files": [ + "index.d.ts" + ], + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "preserve" + } +} diff --git a/types/gl-react-native/tslint.json b/types/gl-react-native/tslint.json new file mode 100644 index 0000000000..b4b47a0378 --- /dev/null +++ b/types/gl-react-native/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/gl-react/index.d.ts b/types/gl-react/index.d.ts new file mode 100644 index 0000000000..e16b0d887c --- /dev/null +++ b/types/gl-react/index.d.ts @@ -0,0 +1,218 @@ +// Type definitions for gl-react 3.15 +// Project: https://github.com/gre/gl-react +// Definitions by: Jussi Kinnula +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from 'react'; + +export type Vec2 = [number, number]; +export type Vec4 = [number, number, number, number]; + +export interface BusProps { + children?: any; + uniform?: string; + index: number; +} + +export class Bus extends React.Component { + id: number; + context: { glParent: Surface | Node, glSurface: Surface }; + dependents: Array; + glNode?: Node; + glBusRootNode: any; + + static defaultProps: BusProps; + static contextTypes: { glParent: any, glSurface: any }; + static childContextTypes: { glParent: any }; + + getChildContext(): { glParent: Bus }; + getGLRenderableNode(): Node; + getGLRenderableContent(): any; + getGLName(): string; + getGLShortName(): string; + capture(x?: number, y?: number, w?: number, h?: number): any[]; + onRef: (ref: any) => void; + redraw: () => void; +} + +export type connectSize = (GLComponent: any) => any; + +export interface SurfaceProps { + children?: any; + style?: any; + preload?: any[]; + visitor?: Visitor; + + onLoad?: () => void; + onLoadError?: (e: Error) => void; + onContextLost?: () => void; + onContextRestored?: () => void; +} + +export interface SurfaceState { + ready: boolean; + rebootId: number; + debug: boolean; +} + +export class Surface extends React.Component { + props: SurfaceProps; + state: SurfaceState; + id: number; + gl: WebGLRenderingContext; + RenderLessElement: any; + root: Node; + + mapRenderableContent(inst: any): any; + getVisitors(): Visitor[]; + getGLSize(): [number, number]; + getGLName(): string; + getGLShortName(): string; + captureAsDataURL(...args: any[]): string; + captureAsBlob(...args: any[]): Promise; + capture(x?: number, y?: number, w?: number, h?: number): any[]; + redraw(): void; + flush(): void; + getEmptyTexture(): WebGLTexture; + glIsAvailable(): boolean; + rebootForDebug(): void; +} + +export type createSurface = ( + GLView: any, + RenderLessElement: any, + mapRenderableContent: any, + requestFrame: (callback: (time: number) => void) => number, + cancelFrame: (id: number) => void +) => Surface; + +export type listSurfaces = () => Surface[]; + +export function GLSL(strings: TemplateStringsArray, ...values: any[]): string; + +export interface LinearCopyProps { + children?: any; +} + +export class LinearCopy extends React.Component { + getNodeRef(): Node; +} + +export interface NearestCopyProps { + children?: any; +} + +export class NearestCopy extends React.Component { + getNodeRef(): Node; +} + +export interface SurfaceContext { + glParent: Node | Surface | Bus; + glSurface: Surface; + glSizable: { + getGLSize: () => [number, number]; + }; +} + +export interface Framebuffer { + handle: WebGLFramebuffer; + color: WebGLTexture; + bind: () => void; + dispose: () => void; + syncSize: (w: number, h: number) => void; +} + +export interface NodeProps { + shader: ShaderIdentifier | ShaderDefinition; + uniformsOptions?: any; + uniforms: { [key: string]: any }; + ignoreUnusedUniforms?: string[] | boolean; + sync?: boolean; + width?: number; + height?: number; + children?: any; + backbuffering?: boolean; + blendFunc?: { + src: () => void; + dst: () => void; + }; + clear?: { + color: Vec4; + }; + + onDraw?: () => void; +} + +export class Node extends React.Component { + drawProps: NodeProps; + context: SurfaceContext; + framebuffer?: Framebuffer; + backbuffer?: Framebuffer; + capturePixelsArray?: Uint8Array; + id: number; + uniformsBus: { + [key: string]: Array; + }; + dependencies: Array; + dependents: Array; +} + +export interface ShaderIdentifier { + type: string; + id: string; +} + +export interface ShaderDefinition { + frag: string; + vert?: string; +} + +export interface ShaderInfo { + frag: string; + vert: string; +} + +export interface ShadersSheet { + [key: string]: ShaderIdentifier; +} + +export namespace Shaders { + function create(shaders: { [key: string]: ShaderDefinition }): ShadersSheet; + function getName(shaderIdentifier: ShaderIdentifier): string; + function getShortName(shaderIdentifier: ShaderIdentifier): string; + function get(shaderIdentifier: ShaderIdentifier): ShaderInfo; +} + +export namespace Uniform { + const Backbuffer: string; + function backbufferFrom(node: Node | Bus): { type: string, node: Node | Bus }; + const Resolution: string; + function textureSize(obj: any): { type: string, obj: any }; + function textureSizeRatio(obj: any): { type: string, obj: any, ratio: boolean }; +} + +export class Visitor { + onSurfaceMount(surface: Surface): void; + onSurfaceUnmount(surface: Surface): void; + onSurfaceGLContextChange(surface: Surface, gl?: WebGLRenderingContext): void; + onSurfaceDrawSkipped(surface: Surface): void; + onSurfaceDrawStart(surface: Surface): void; + onSurfaceDrawError(e: Error): boolean; + onSurfaceDrawEnd(surface: Surface): void; + onNodeDrawSkipped(node: Node): void; + onNodeDrawStart(node: Node): void; + onNodeSyncDeps(node: Node, additions: Array, deletions: Array): void; + onNodeDraw(node: Node, preparedUniforms: any[]): void; + onNodeDrawEnd(node: Node): void; +} + +export class VisitorLogger extends Visitor { + groupNestedLvl: number; +} + +export namespace Visitors { + function add(visitor: Visitor): void; + function remove(visitor: Visitor): void; + function get(): Visitor[]; +} diff --git a/types/gl-react/package.json b/types/gl-react/package.json new file mode 100644 index 0000000000..e6696d08e7 --- /dev/null +++ b/types/gl-react/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "csstype": "^2.2.0" + } +} diff --git a/types/gl-react/tsconfig.json b/types/gl-react/tsconfig.json new file mode 100644 index 0000000000..9c4d38ca44 --- /dev/null +++ b/types/gl-react/tsconfig.json @@ -0,0 +1,24 @@ +{ + "files": [ + "index.d.ts" + ], + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "preserve" + } +} diff --git a/types/gl-react/tslint.json b/types/gl-react/tslint.json new file mode 100644 index 0000000000..b4b47a0378 --- /dev/null +++ b/types/gl-react/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}