diff --git a/napi/canvas-napi/NSCTouchHandler.ts b/napi/canvas-napi/NSCTouchHandler.ts deleted file mode 100644 index b61da431..00000000 --- a/napi/canvas-napi/NSCTouchHandler.ts +++ /dev/null @@ -1,250 +0,0 @@ -import '@nativescript/foundation'; - -import type { NSCCanvas } from './canvas'; - -class Pointer { - pointerId: number; - location: CGPoint; - touch: NSTouch; - released: boolean; - - constructor(pointerId: number, location: CGPoint, touch: NSTouch, released: boolean) { - this.pointerId = pointerId; - this.location = location; - this.touch = touch; - this.released = released; - } -} - -class NSCClickGestureRecognizerImpl extends NSGestureRecognizer { - _owner?: WeakRef; - _view?: WeakRef; - static { - NativeClass(this); - } - - static initWithOwner(owner: NSCTouchHandler) { - const ret = NSCClickGestureRecognizerImpl.alloc().initWithTargetAction(owner, null); - ret._owner = new WeakRef(owner); - return ret; - } - - mouseDown(event: NSEvent) { - super.mouseDown(event); - const owner = this._owner?.deref?.(); - - if (!owner) { - this._view?.deref?.()?.mouseDown?.(event); - return; - } - const allTouches = event; - if (allTouches) { - // const touches = allTouches.allObjects as NSArray; - // const count = touches.count; - // for (let i = 0; i < count; i++) { - // const touch = touches.objectAtIndex(i); - // const location = touch.locationInView(this.view); - // const pointer = new Pointer(owner.nextId, location, touch, false); - // owner.pointers.push(pointer); - // owner.onPress(pointer.pointerId, location.x, location.y, this); - // owner.nextId++; - // } - } - - // this._view?.deref?.()?.mouseDown?.(event); - } - - mouseUp(event: NSEvent) { - super.mouseUp(event); - // const owner = this._owner?.deref?.(); - // if (!owner) { - // this._view?.deref?.()?.mouseUp?.(event); - // return; - // } - // - // const allTouches = event.allTouches(); - // if (allTouches) { - // const touches = allTouches.allObjects as NSArray; - // const count = touches.count; - // for (let i = 0; i < count; i++) { - // const touch = touches.objectAtIndex(i); - // const location = touch.locationInView(this.view); - // const index = owner.pointers.findIndex((pointer) => { - // return touch.isEqual(pointer.touch); - // }); - // if (index === -1) { - // continue; - // } - // const pointer = owner.pointers[index]; - // if (pointer.released) { - // owner.pointers.splice(index, 1); - // continue; - // } - // - // owner.onRelease(pointer.pointerId, location.x, location.y, this); - // pointer.released = true; - // owner.pointers.splice(index, 1); - // } - // } - // - // this._view?.deref?.()?.mouseUp?.(event); - } - - mouseDragged(event: NSEvent) { - super.mouseDragged(event); - // const owner = this._owner?.deref?.(); - // if (!owner) { - // this._view?.deref?.()?.mouseDragged?.(event); - // return; - // } - // - // const view = this._view?.deref?.(); - // const allTouches = event.allTouches(); - // if (allTouches) { - // const touches = allTouches.allObjects as NSArray; - // if (touches) { - // const ret = { - // event: 'move', - // pointers: new Array(owner.pointers.length) - // }; - // for (const [index, pointer] of owner.pointers.entries()) { - // const location = pointer.touch.locationInView(view); - // const pointerId = pointer.pointerId; - // ret.pointers[index] = { - // ptrId: pointerId, - // isPrimary: index === 0, - // x: location.x, - // y: location.y - // - // }; - // } - // view.touchEventListener(ret, this); - // } - // } - // - // view?.mouseDragged?.(event); - } - - touchesCancelledWithEvent(event: NSEvent) { - const owner = this._owner?.deref?.(); - if (!owner) { - this._view?.deref?.()?.touchesCancelledWithEvent?.(event); - return; - } - - const allTouches = event.allTouches(); - if (allTouches) { - const touches = allTouches.allObjects as NSArray; - const count = touches.count; - for (let i = 0; i < count; i++) { - const touch = touches.objectAtIndex(i); - const location = touch.locationInView(this.view); - const index = owner.pointers.findIndex((pointer) => { - return touch.isEqual(pointer.touch); - }); - if (index === -1) { - continue; - } - const pointer = owner.pointers[index]; - if (pointer.released) { - owner.pointers.splice(index, 1); - continue; - } - - owner.onCancel(pointer.pointerId, location.x, location.y, this); - pointer.released = true; - owner.pointers.splice(index, 1); - } - } - - this._view?.deref?.()?.touchesCancelledWithEvent?.(event); - } -} - -class NSCPanGestureRecognizerImpl extends NSPanGestureRecognizer { - _owner: WeakRef; - static { - NativeClass(this); - } - - static initWithOwner(owner: NSCTouchHandler) { - const ret = new NSCPanGestureRecognizerImpl(); - ret._owner = new WeakRef(owner); - return ret; - } -} - -class NSCMagnificationGestureRecognizerImpl extends NSMagnificationGestureRecognizer { - _owner: WeakRef; - static { - NativeClass(this); - } - - static initWithOwner(owner: NSCTouchHandler) { - const ret = new NSCMagnificationGestureRecognizerImpl(); - ret._owner = new WeakRef(owner); - return ret; - } -} - -class NSCTouchHandler extends NSObject { - static { - NativeClass(this); - } - view?: WeakRef; - nextId = 0; - pointers: Array = []; - gestureRecognizer: NSCClickGestureRecognizerImpl; - panRecognizer: NSCPanGestureRecognizerImpl; - magnificationRecognizer: NSCMagnificationGestureRecognizerImpl; - - static initWithOwner(owner: NSCCanvas) { - const ret = NSCTouchHandler.new(); - ret.view = new WeakRef(owner); - ret.gestureRecognizer = NSCClickGestureRecognizerImpl.initWithOwner(ret); - ret.panRecognizer = NSCPanGestureRecognizerImpl.initWithOwner(ret); - ret.magnificationRecognizer = NSCMagnificationGestureRecognizerImpl.initWithOwner(ret); - return ret; - } - - onPress(ptrId: number, x: number, y: number, gestureRecognizer: NSGestureRecognizer) { - const object = { - event: 'down', - ptrId, - isPrimary: this.pointers[0]?.pointerId === ptrId, - x, - y, - }; - this.view?.deref?.()?.touchEventListener?.(object, gestureRecognizer); - } - - onRelease(ptrId: number, x: number, y: number, gestureRecognizer: NSGestureRecognizer) { - const object = { - event: 'up', - ptrId, - isPrimary: this.pointers[0]?.pointerId === ptrId, - x, - y, - }; - this.view?.deref?.()?.touchEventListener?.(object, gestureRecognizer); - } - - onCancel(ptrId: number, x: number, y: number, gestureRecognizer: NSGestureRecognizer) { - const object = { - event: 'cancel', - ptrId, - isPrimary: this.pointers[0]?.pointerId === ptrId, - x, - y, - }; - - this.view?.deref?.()?.touchEventListener?.(object, gestureRecognizer); - } - - static ObjCExposedMethods = { - mouseEntered: { returns: interop.types.void, params: [NSEvent] }, - mouseExited: { returns: interop.types.void, params: [NSEvent] }, - }; -} - -export default NSCTouchHandler; diff --git a/napi/canvas-napi/canvas.ts b/napi/canvas-napi/canvas.ts index 7eead0b1..6a89ff7a 100644 --- a/napi/canvas-napi/canvas.ts +++ b/napi/canvas-napi/canvas.ts @@ -1,10 +1,9 @@ -import { createRequire } from 'node:module'; import { Event } from '@nativescript/foundation/dom/dom-utils.js'; import { type YogaNodeLayout } from '@nativescript/foundation/layout/index.js'; import { view } from '@nativescript/foundation/views/decorators/view.js'; import { ViewBase } from '@nativescript/foundation/views/view/view-base.js'; -// @ts-ignore -const require = createRequire(import.meta.url); + +import { CanvasRenderingContext2D, WebGLRenderingContext, WebGL2RenderingContext, GPU, GPUCanvasContext, GPUDevice } from './js-bindings.js'; objc.import('OpenGL'); objc.import('Metal'); @@ -24,18 +23,18 @@ function renderContexts() { } switch (canvas._contextType) { case ContextType.WebGL: - canvas.__native__context.render?.(); + (canvas.__native__context as WebGLRenderingContext | undefined)?.render?.(); break; case ContextType.WebGL2: - canvas.__native__context.render?.(); + (canvas.__native__context as WebGL2RenderingContext | undefined)?.render?.(); break; case ContextType.WebGPU: - if (canvas.__native__context.hasCurrentTexture) { - canvas.__native__context.presentSurface?.(); + if ((canvas.__native__context as never as GPUCanvasContext).hasCurrentTexture) { + (canvas.__native__context as never as GPUCanvasContext)?.presentSurface?.(); } break; case ContextType.Canvas: - canvas.__native__context.render?.(); + (canvas.__native__context as CanvasRenderingContext2D | undefined)?.render?.(); break; case ContextType.None: break; @@ -75,8 +74,7 @@ NSNotificationCenter.defaultCenter.addObserverForNameObjectQueueUsingBlock(NSApp } }); -const { CanvasRenderingContext2D, WebGLRenderingContext, WebGL2RenderingContext, GPU, GPUCanvasContext, GPUDevice } = require('./js-binding.js'); - +// @ts-ignore GPUDevice.prototype.lost = new Promise((resolve, reject) => {}); export class DOMRectReadOnly { @@ -391,7 +389,7 @@ const buildMouseEvent = ( pageX: number; pageY: number; } => { - const location = view.convertPointToView(event.locationInWindow, this as never); + const location = view.convertPointToView(event.locationInWindow, view as never); const clientX = location.x; const clientY = location.y; const screenX = location.x; @@ -710,7 +708,7 @@ export class NSCCanvas extends NSView { mtlViewLayerPtr?: interop.Pointer; mtlViewPtr?: interop.Pointer; glViewPtr?: interop.Pointer; - gpuContext?: typeof GPUCanvasContext; + gpuContext?: GPUCanvasContext; glContext: WebGLRenderingContext | WebGL2RenderingContext | undefined; initWebGPUContext() { @@ -718,7 +716,7 @@ export class NSCCanvas extends NSView { return; } if (this.mtlViewLayerPtr) { - this.gpuContext = GPUCanvasContext.withLayer(getGPU(), this.mtlViewLayerPtr.toNumber(), this.surfaceWidth, this.surfaceHeight); + this.gpuContext = GPUCanvasContext.withLayer(getGPU(), this.mtlViewLayerPtr.toNumber(), this.surfaceWidth, this.surfaceHeight) as never; if (this.gpuContext) { this.engine = Engine.GPU; } @@ -732,7 +730,10 @@ export class NSCCanvas extends NSView { return; } if (!this.is2D && this.engine == Engine.GPU && this.mtlViewLayerPtr) { - this.gpuContext?.resize(this.mtlViewLayerPtr.toNumber(), this.surfaceWidth, this.surfaceHeight); + if (this.gpuContext) { + this.gpuContext?.resize(this.mtlViewLayerPtr.toNumber(), this.surfaceWidth, this.surfaceHeight); + } + this.scaleSurface(); return; } diff --git a/napi/canvas-napi/config/rollup.config.js b/napi/canvas-napi/config/rollup.config.js new file mode 100644 index 00000000..275832cb --- /dev/null +++ b/napi/canvas-napi/config/rollup.config.js @@ -0,0 +1,28 @@ +import typescript from '@rollup/plugin-typescript'; +import commonjs from '@rollup/plugin-commonjs'; +const config = [ + { + input: 'index.ts', + plugins: [typescript(), commonjs()], + output: [ + { + format: 'cjs', + file: 'dist/index.cjs', + indent: '\t', + }, + ], + }, + { + input: 'index.ts', + plugins: [typescript(), commonjs()], + output: [ + { + format: 'es', + file: 'dist/index.mjs', + indent: '\t', + }, + ], + }, +]; + +export default config; diff --git a/napi/canvas-napi/examples/node/main.mts b/napi/canvas-napi/examples/node/main.mts index d3554196..74075350 100644 --- a/napi/canvas-napi/examples/node/main.mts +++ b/napi/canvas-napi/examples/node/main.mts @@ -1,10 +1,7 @@ import '@nativescript/macos-node-api'; -import { createRequire } from 'node:module'; -import utils from '../../utils'; import '@nativescript/foundation/dom/index.js'; import '../app.ts'; -import '../../canvas'; -import '../../polyfill'; +import {ImageAsset} from '@nativescript/canvas-napi'; import three from './three'; import { ViewBase } from '@nativescript/foundation/views/view/view-base'; @@ -20,15 +17,10 @@ import {run as tsl_galaxy} from './threejs/tsl_galaxy'; const { webgpuCube, cube } = three; // import { run as damagedHelmet } from './threejs/damaged_helmet'; import { run as simplePixi } from './pixijs/simple'; -// @ts-ignore -const require = createRequire(import.meta.url); // import { GPU, ImageAsset } from '../../index.js'; -const { ImageAsset } = require('../../canvas-napi.darwin-arm64.node'); - -const { requestAnimationFrame, cancelAnimationFrame } = utils; objc.import('AppKit'); diff --git a/napi/canvas-napi/examples/node/tsconfig.json b/napi/canvas-napi/examples/node/tsconfig.json index 588f02df..ec1a77c9 100644 --- a/napi/canvas-napi/examples/node/tsconfig.json +++ b/napi/canvas-napi/examples/node/tsconfig.json @@ -1,10 +1,11 @@ { "compilerOptions": { - "moduleResolution": "node", - "rootDir": ".", "target": "ES2020", "outDir": "./dist", - "downlevelIteration": true + "downlevelIteration": true, + "paths": { + "@nativescript/canvas-napi": ["../../index.js"] + } }, "extends": "../../tsconfig.json" } diff --git a/napi/canvas-napi/index.ts b/napi/canvas-napi/index.ts index d865566d..acad47af 100644 --- a/napi/canvas-napi/index.ts +++ b/napi/canvas-napi/index.ts @@ -1,2 +1,4 @@ -export * from './js-binding.js'; -export * from './canvas.js'; +export * from './js-bindings'; +export * from './canvas'; + +import './polyfill'; diff --git a/napi/canvas-napi/js-bindings.d.ts b/napi/canvas-napi/js-bindings.d.ts new file mode 100644 index 00000000..3c1540cf --- /dev/null +++ b/napi/canvas-napi/js-bindings.d.ts @@ -0,0 +1,2451 @@ +/* tslint:disable */ +/* eslint-disable */ + +/* auto-generated by NAPI-RS */ + +export interface GpuCommandEncoderFinishDescriptor { + label?: string; +} +export interface CanvasSurfaceCapabilities { + formats: Array; + usages: number; + alphaModes: Array; + presentModes: Array; +} +export interface GpuCanvasContextConfigOptions { + device: g_p_u_device; + format?: GPUTextureFormat; + usage?: number; + viewFormats?: Array; + colorSpace?: PredefinedColorSpaceEnum; + alphaMode?: GPUCanvasAlphaMode; + presentMode?: GPUCanvasPresentMode; + size?: Array | GPUExtent3DDict; +} +export interface DefaultQueue { + label?: string; +} +export const enum GPUFeatureName { + depthClipControl = 'depth-clip-control', + depth32floatStencil8 = 'depth32float-stencil8', + textureCompressionBc = 'texture-compression-bc', + textureCompressionBcSliced3d = 'texture-compression-bc-sliced-3d', + textureCompressionEtc2 = 'texture-compression-etc2', + textureCompressionAstc = 'texture-compression-astc', + textureCompressionAstcSliced3d = 'texture-compression-astc-sliced-3d', + timestampQuery = 'timestamp-query', + indirectFirstInstance = 'indirect-first-instance', + shaderF16 = 'shader-f16', + rg11b10ufloatRenderable = 'rg11b10ufloat-renderable', + bgra8unormStorage = 'bgra8unorm-storage', + float32Filterable = 'float32-filterable', + float32Blendable = 'float32-blendable', + clipDistances = 'clip-distances', + dualSourceBlending = 'dual-source-blending', +} +export interface GPUDeviceDescriptor { + defaultQueue?: DefaultQueue; + label?: string; + requiredFeatures?: Array; + requiredLimits?: GPUSupportedLimits; +} +export const enum GPUShaderStage { + VERTEX = 1, + FRAGMENT = 2, + COMPUTE = 4, +} +export const enum GPUQueryType { + occlusion = 'occlusion', + timestamp = 'timestamp', +} +export const enum GPUMipmapFilterMode { + nearest = 'nearest', + linear = 'linear', +} +export const enum GPUFilterMode { + nearest = 'nearest', + linear = 'linear', +} +export const enum GPUAddressMode { + clampToEdge = 'clamp-to-edge', + repeat = 'repeat', + mirrorRepeat = 'mirror-repeat', +} +export const enum GPUBufferUsage { + MAP_READ = 1, + MAP_WRITE = 2, + COPY_SRC = 4, + COPY_DST = 8, + INDEX = 16, + VERTEX = 32, + UNIFORM = 64, + STORAGE = 128, + INDIRECT = 256, + QUERY_RESOLVE = 512, +} +export const enum GPUTextureUsage { + COPY_SRC = 1, + COPY_DST = 2, + RENDER_ATTACHMENT = 16, + STORAGE_BINDING = 8, + TEXTURE_BINDING = 4, +} +export const enum GPUErrorFilter { + validation = 'validation', + outOfMemory = 'out-of-memory', + internal = 'internal', +} +export const enum GPUTextureSampleType { + float = 'float', + unfilterableFloat = 'unfilterable-float', + depth = 'depth', + sint = 'sint', + uint = 'uint', +} +export const enum GPUTextureViewDimension { + d1 = '1d', + d2 = '2d', + array2d = '2d-array', + cube = 'cube', + cubeArray = 'cube-array', + d3 = '3d', +} +export const enum GPUStorageTextureAccess { + writeOnly = 'write-only', + readOnly = 'read-only', + readWrite = 'read-write', +} +export const enum GPUSamplerBindingType { + filtering = 'filtering', + nonFiltering = 'non-filtering', + comparison = 'comparison', +} +export const enum GPUBufferBindingType { + uniform = 'uniform', + storage = 'storage', + readOnlyStorage = 'read-only-storage', +} +export const enum GPUTextureDimension { + d1 = '1d', + d2 = '2d', + d3 = '3d', +} +export const enum GPUTextureAspect { + all = 'all', + stencilOnly = 'stencil-only', + depthOnly = 'depth-only', +} +export const enum GPUMapMode { + READ = 1, + WRITE = 2, +} +export const enum GPULoadOp { + load = 'load', + clear = 'clear', +} +export const enum GPUStoreOp { + Store = 'store', + Discard = 'discard', +} +export const enum GPUVertexFormat { + uint8x2 = 'uint8x2', + uint8x4 = 'uint8x4', + sint8x2 = 'sint8x2', + sint8x4 = 'sint8x4', + unorm8x2 = 'unorm8x2', + unorm8x4 = 'unorm8x4', + snorm8x2 = 'snorm8x2', + snorm8x4 = 'snorm8x4', + uint16x2 = 'uint16x2', + uint16x4 = 'uint16x4', + sint16x2 = 'sint16x2', + sint16x4 = 'sint16x4', + unorm16x2 = 'unorm16x2', + unorm16x4 = 'unorm16x4', + snorm16x2 = 'snorm16x2', + snorm16x4 = 'snorm16x4', + float16x2 = 'float16x2', + float16x4 = 'float16x4', + float32 = 'float32', + float32x2 = 'float32x2', + float32x3 = 'float32x3', + float32x4 = 'float32x4', + uint32 = 'uint32', + uint32x2 = 'uint32x2', + uint32x3 = 'uint32x3', + uint32x4 = 'uint32x4', + sint32 = 'sint32', + sint32x2 = 'sint32x2', + sint32x3 = 'sint32x3', + sint32x4 = 'sint32x4', + float64 = 'float64', + float64x2 = 'float64x2', + float64x3 = 'float64x3', + float64x4 = 'float64x4', + unorm1010102 = 'unorm10-10-10-2', +} +export const enum GPUVertexStepMode { + vertex = 'vertex', + instance = 'instance', +} +export const enum GPUPrimitiveTopology { + pointList = 'point-list', + lineList = 'line-list', + lineStrip = 'line-strip', + triangleList = 'triangle-list', + triangleStrip = 'triangle-strip', +} +export const enum GPUIndexFormat { + uint16 = 'uint16', + uint32 = 'uint32', +} +export const enum GPUFrontFace { + ccw = 'ccw', + cw = 'cw', +} +export const enum GPUCullMode { + none = 'none', + front = 'front', + back = 'back', +} +export const enum GPUBlendOperation { + add = 'add', + subtract = 'subtract', + reverseSubtract = 'reverse-subtract', + min = 'min', + max = 'max', +} +export const enum GPUBlendFactor { + zero = 'zero', + one = 'one', + src = 'src', + oneMinusSrc = 'one-minus-src', + srcAlpha = 'src-alpha', + oneMinusSrcAlpha = 'one-minus-src-alpha', + dst = 'dst', + oneMinusDst = 'one-minus-dst', + dstAlpha = 'dst-alpha', + oneMinusDstAlpha = 'one-minus-dst-alpha', + srcAlphaSaturated = 'src-alpha-saturated', + constant = 'constant', + oneMinusConstant = 'one-minus-constant', + src1 = 'src1', + oneMinusSrc1 = 'oneMinusSrc1', + src1Alpha = 'src1Alpha', + oneMinusSrc1Alpha = 'oneMinusSrc1Alpha', +} +export const enum GPUPipelineLayoutAuto { + auto = 'auto', +} +export const enum GPUStencilOperation { + keep = 'keep', + zero = 'zero', + replace = 'replace', + invert = 'invert', + incrementClamp = 'increment-clamp', + decrementClamp = 'decrement-clamp', + incrementWrap = 'increment-wrap', + decrementWrap = 'decrement-wrap', +} +export const enum GPUCompareFunction { + never = 'never', + less = 'less', + equal = 'equal', + lessEqual = 'less-equal', + greater = 'greater', + notEqual = 'not-equal', + greaterEqual = 'greater-equal', + always = 'always', +} +export const enum PredefinedColorSpaceEnum { + displayP3 = 'display-p3', + srgb = 'srgb', +} +export const enum GPUCanvasAlphaMode { + opaque = 'opaque', + premultiplied = 'premultiplied', + postmultiplied = 'postmultiplied', + inherit = 'inherit', +} +export const enum GPUCanvasPresentMode { + autoVsync = 'autoVsync', + autoNoVsync = 'autoNoVsync', + fifo = 'fifo', + fifoRelaxed = 'fifoRelaxed', + immediate = 'immediate', + mailbox = 'mailbox', +} +export const enum GPUTextureFormat { + r8unorm = 'r8unorm', + r8snorm = 'r8snorm', + r8uint = 'r8uint', + r8sint = 'r8sint', + r16uint = 'r16uint', + r16sint = 'r16sint', + r16unorm = 'r16unorm', + r16snorm = 'r16snorm', + r16float = 'r16float', + rg8unorm = 'rg8unorm', + rg8snorm = 'rg8snorm', + rg8uint = 'rg8uint', + rg8sint = 'rg8sint', + rg16unorm = 'rg16unorm', + rg16snorm = 'rg16snorm', + r32uint = 'r32uint', + r32sint = 'r32sint', + r32float = 'r32float', + rg16uint = 'rg16uint', + rg16sint = 'rg16sint', + rg16float = 'rg16float', + rgba8unorm = 'rgba8unorm', + rgba8unorm_srgb = 'rgba8unorm-srgb', + rgba8snorm = 'rgba8snorm', + rgba8uint = 'rgba8uint', + rgba8sint = 'rgba8sint', + bgra8unorm = 'bgra8unorm', + bgra8unorm_srgb = 'bgra8unorm-srgb', + rgb9e5ufloat = 'rgb9e5ufloat', + rgb10a2uint = 'rgb10a2uint', + rgb10a2unorm = 'rgb10a2unorm', + rg11b10ufloat = 'rg11b10ufloat', + rg32uint = 'rg32uint', + rg32sint = 'rg32sint', + rg32float = 'rg32float', + rgba16uint = 'rgba16uint', + rgba16sint = 'rgba16sint', + rgba16unorm = 'rgba16unorm', + rgba16snorm = 'rgba16snorm', + rgba16float = 'rgba16float', + rgba32uint = 'rgba32uint', + rgba32sint = 'rgba32sint', + rgba32float = 'rgba32float', + stencil8 = 'stencil8', + nv12 = 'nv12', + depth16unorm = 'depth16unorm', + depth24plus = 'depth24plus', + depth24plus_stencil8 = 'depth24plus_stencil8', + depth32float = 'depth32float', + depth32float_stencil8 = 'depth32float-stencil8', + bc1_rgba_unorm = 'bc1-rgba-unorm', + bc1_rgba_unorm_srgb = 'bc1-rgba-unorm-srgb', + bc2_rgba_unorm = 'bc2-rgba-unorm', + bc2_rgba_unorm_srgb = 'bc2-rgba-unorm-srgb', + bc3_rgba_unorm = 'bc3-rgba-unorm', + bc3_rgba_unorm_srgb = 'bc3-rgba-unorm-srgb', + bc4_r_unorm = 'bc4-r-unorm', + bc4_r_snorm = 'bc4-r-snorm', + bc5_rg_unorm = 'bc5-rg-unorm', + bc5_rg_snorm = 'bc5-rg-snorm', + bc6h_rgb_ufloat = 'bc6h-rgb-ufloat', + bc6h_rgb_float = 'bc6h-rgb-float', + bc7_rgba_unorm = 'bc7-rgba-unorm', + bc7_rgba_unorm_srgb = 'bc7-rgba-unorm-srgb', + etc2_rgb8unorm = 'etc2-rgb8unorm', + etc2_rgb8unorm_srgb = 'etc2-rgb8unorm-srgb', + etc2_rgb8a1unorm = 'etc2-rgb8a1unorm', + etc2_rgb8a1unorm_srgb = 'etc2-rgb8a1unorm-srgb', + etc2_rgba8unorm = 'etc2-rgba8unorm', + etc2_rgba8unorm_srgb = 'etc2-rgba8unorm-srgb', + eac_r11unorm = 'eac-r11unorm', + eac_r11snorm = 'eac-r11snorm', + eac_rg11unorm = 'eac-rg11unorm', + eac_rg11snorm = 'eac-rg11snorm', + astc_4x4_unorm = 'astc-4x4-unorm', + astc_4x4_unorm_srgb = 'astc-4x4-unorm-srgb', + astc_4x4_hdr = 'astc-4x4-hdr', + astc_5x4_unorm = 'astc-5x4-unorm', + astc_5x4_unorm_srgb = 'astc-5x4-unorm-srgb', + astc_5x4_hdr = 'astc-5x4-hdr', + astc_5x5_unorm = 'astc-5x5-unorm', + astc_5x5_unorm_srgb = 'astc-5x5-unorm-srgb', + astc_5x5_hdr = 'astc-5x5-hdr', + astc_6x5_unorm = 'astc-6x5-unorm', + astc_6x5_unorm_srgb = 'astc-6x5-unorm-srgb', + astc_6x5_hdr = 'astc-6x5-hdr', + astc_6x6_unorm = 'astc-6x6-unorm', + astc_6x6_unorm_srgb = 'astc-6x6-unorm-srgb', + astc_6x6_hdr = 'astc-6x6-hdr', + astc_8x5_unorm = 'astc-8x5-unorm', + astc_8x5_unorm_srgb = 'astc-8x5-unorm-srgb', + astc_8x5_hdr = 'astc-8x5-hdr', + astc_8x6_unorm = 'astc-8x6-unorm', + astc_8x6_unorm_srgb = 'astc-8x6-unorm-srgb', + astc_8x6_hdr = 'astc-8x6-hdr', + astc_8x8_unorm = 'astc-8x8-unorm', + astc_8x8_unorm_srgb = 'astc-8x8-unorm-srgb', + astc_8x8_hdr = 'astc-8x8-hdr', + astc_10x5_unorm = 'astc-10x5-unorm', + astc_10x5_unorm_srgb = 'astc-10x5-unorm-srgb', + astc_10x5_hdr = 'astc-10x5-hdr', + astc_10x6_unorm = 'astc-10x6-unorm', + astc_10x6_unorm_srgb = 'astc-10x6-unorm-srgb', + astc_10x6_hdr = 'astc-10x6-hdr', + astc_10x8_unorm = 'astc-10x8-unorm', + astc_10x8_unorm_srgb = 'astc-10x8-unorm-srgb', + astc_10x8_hdr = 'astc-10x8-hdr', + astc_10x10_unorm = 'astc-10x10-unorm', + astc_10x10_unorm_srgb = 'astc-10x10-unorm-srgb', + astc_10x10_hdr = 'astc-10x10-hdr', + astc_12x10_unorm = 'astc-12x10-unorm', + astc_12x10_unorm_srgb = 'astc-12x10-unorm-srgb', + astc_12x10_hdr = 'astc-12x10-hdr', + astc_12x12_unorm = 'astc-12x12-unorm', + astc_12x12_unorm_srgb = 'astc-12x12-unorm-srgb', + astc_12x12_hdr = 'astc-12x12-hdr', +} +export interface GPUImageDataLayout { + bytesPerRow: number; + offset?: number; + rowsPerImage?: number; +} +export interface GPURenderBundleDescriptor { + label?: string; +} +export interface GPURenderBundleEncoderDescriptor { + label?: string; + colorFormats: Array; + depthReadOnly?: boolean; + depthStencilFormat?: GPUTextureFormat; + sampleCount?: number; + stencilReadOnly?: boolean; +} +export interface GPUPipelineLayoutDescriptor { + label?: string; + bindGroupLayouts: Array; +} +export interface GPUQuerySetDescriptor { + label?: string; + count: number; + type: GPUQueryType; +} +export interface GPUSamplerDescriptor { + label?: string; + addressModeU?: GPUAddressMode; + addressModeV?: GPUAddressMode; + addressModeW?: GPUAddressMode; + compare?: GPUCompareFunction; + lodMaxClamp?: number; + lodMinClamp?: number; + magFilter?: GPUFilterMode; + maxAnisotropy?: number; + minFilter?: GPUFilterMode; + mipmapFilter?: GPUFilterMode; +} +export interface GPUOrigin2DDict { + x?: number; + y?: number; +} +export interface GPUImageCopyTextureTagged { + aspect?: GPUTextureAspect; + colorSpace?: PredefinedColorSpaceEnum; + mipLevel?: number; + origin?: Array | GPUOrigin3DDict; + premultipliedAlpha?: boolean; + texture: g_p_u_texture; +} +export interface GPUImageCopyExternalImage { + flipY?: boolean; + origin?: Array | GPUOrigin2DDict; + source: ImageData | ImageAsset | CanvasRenderingContext2D | web_g_l_rendering_context | web_g_l_2_rendering_context | GPUCanvasContext | ImageBitmap; +} +export interface GPUTextureDescriptor { + label?: string; + dimension?: GPUTextureDimension; + format: GPUTextureFormat; + mipLevelCount?: number; + sampleCount?: number; + size: Array | GPUExtent3DDict; + usage: number; + viewFormats?: Array; +} +export interface GPUTextureViewDescriptor { + label?: string; + format?: GPUTextureFormat; + dimension?: GPUTextureViewDimension; + aspect?: GPUTextureAspect; + baseMipLevel?: number; + mipLevelCount?: number; + baseArrayLayer?: number; + arrayLayerCount?: number; +} +export interface GPUProgrammableStage { + constants?: Record; + entryPoint?: string; + module: g_p_u_shader_module; +} +export interface GPUComputePipelineDescriptor { + label?: string; + compute: GPUProgrammableStage; + layout: g_p_u_pipeline_layout | GPUPipelineLayoutAuto; +} +export interface GPUBufferDescriptor { + label?: string; + mappedAtCreation?: boolean; + size: number; + usage: number; +} +export interface GpuBufferBinding { + buffer: g_p_u_buffer; + offset?: number; + size?: number; +} +export interface GPUTextureBindingLayout { + multisampled?: boolean; + sampleType?: GPUTextureSampleType; + viewDimension?: GPUTextureViewDimension; +} +export interface GPUStorageTextureBindingLayout { + access?: GPUStorageTextureAccess; + format: GPUTextureFormat; + viewDimension?: GPUTextureViewDimension; +} +export interface GPUSamplerBindingLayout { + type?: GPUSamplerBindingType; +} +export interface GPUExternalTextureBindingLayout {} +export interface GPUBufferBindingLayout { + hasDynamicOffset?: boolean; + minBindingSize?: number; + type?: GPUBufferBindingType; +} +export interface GPUBindGroupLayoutEntry { + label?: string; + binding: number; + buffer?: GPUBufferBindingLayout; + externalTexture?: GPUExternalTextureBindingLayout; + sampler?: GPUSamplerBindingLayout; + storageTexture?: GPUStorageTextureBindingLayout; + texture?: GPUTextureBindingLayout; + visibility: number; +} +export interface GPUBindGroupLayoutDescriptor { + label?: string; + entries: Array; +} +export interface GPUBindGroupSampleEntry { + binding: number; + resource: g_p_u_sampler; +} +export interface GPUBindGroupTextureViewEntry { + binding: number; + resource: g_p_u_texture_view; +} +export interface GPUBindGroupBufferEntry { + binding: number; + resource: GpuBufferBinding; +} +export interface GPUBindGroupEntry { + binding: number; + resource: object; +} +export interface GPUBindGroupDescriptor { + entries: Array; + label?: string; + layout: GPUBindGroupLayout; +} +export interface GPUSupportedLimits { + maxTextureDimension1D?: number; + maxTextureDimension2D?: number; + maxTextureDimension3D?: number; + maxTextureArrayLayers?: number; + maxBindGroups?: number; + maxBindingsPerBindGroup?: number; + maxDynamicUniformBuffersPerPipelineLayout?: number; + maxDynamicStorageBuffersPerPipelineLayout?: number; + maxSampledTexturesPerShaderStage?: number; + maxSamplersPerShaderStage?: number; + maxStorageBuffersPerShaderStage?: number; + maxStorageTexturesPerShaderStage?: number; + maxUniformBuffersPerShaderStage?: number; + maxUniformBufferBindingSize?: number; + maxStorageBufferBindingSize?: number; + maxVertexBuffers?: number; + maxBufferSize?: number; + maxVertexAttributes?: number; + maxVertexBufferArrayStride?: number; + minUniformBufferOffsetAlignment?: number; + minStorageBufferOffsetAlignment?: number; + maxInterStageShaderComponents?: number; + maxColorAttachments?: number; + maxColorAttachmentBytesPerSample?: number; + maxComputeWorkgroupStorageSize?: number; + maxComputeInvocationsPerWorkgroup?: number; + maxComputeWorkgroupSizeX?: number; + maxComputeWorkgroupSizeY?: number; + maxComputeWorkgroupSizeZ?: number; + maxComputeWorkgroupsPerDimension?: number; + minSubgroupSize?: number; + maxSubgroupSize?: number; + maxPushConstantSize?: number; + maxNonSamplerBindings?: number; +} +export interface GpuImageCopyBuffer { + buffer: g_p_u_buffer; + bytesPerRow: number; + offset?: number; + rowsPerImage?: number; +} +export interface GpuOrigin3DDict { + x: number; + y: number; + z: number; +} +export interface GpuImageCopyTexture { + aspect?: GPUTextureAspect; + mipLevel?: number; + origin?: GpuOrigin3DDict | Array; + texture: g_p_u_texture; +} +export interface GpuComputePassTimestampWrites { + beginningOfPassWriteIndex: number; + endOfPassWriteIndex: number; + querySet: g_p_u_query_set; +} +export interface GpuComputePassDescriptor { + label?: string; + timestampWrites?: GpuComputePassTimestampWrites; +} +export interface GpuColorDict { + a: number; + b: number; + g: number; + r: number; +} +export interface GPURenderPassColorAttachment { + clearValue?: Array | GpuColorDict; + depthSlice?: number; + loadOp: GPULoadOp; + resolveTarget?: g_p_u_texture_view; + storeOp: GPUStoreOp; + view: g_p_u_texture_view; +} +export interface GpuRenderPassDepthStencilAttachment { + depthClearValue?: number; + depthLoadOp?: GPULoadOp; + depthReadOnly?: boolean; + depthStoreOp?: GPUStoreOp; + stencilClearValue?: number; + stencilLoadOp?: GPULoadOp; + stencilReadOnly?: boolean; + stencilStoreOp?: GPUStoreOp; + view: g_p_u_texture_view; +} +export interface GpuRenderPassTimestampWrites { + beginningOfPassWriteIndex?: number; + endOfPassWriteIndex?: number; + querySet: g_p_u_query_set; +} +export interface GpuRenderPassDescriptor { + colorAttachments: Array; + depthStencilAttachment?: GpuRenderPassDepthStencilAttachment; + label?: string; + maxDrawCount?: number; + occlusionQuerySet?: g_p_u_query_set; + timestampWrites?: GpuRenderPassTimestampWrites; +} +export interface GpuCommandEncoderDescriptor { + label?: string; +} +export interface GpuShaderModuleDescriptor { + code: string; + label?: string; +} +export interface GpuExtent3DDict { + width: number; + height?: number; + depthOrArrayLayers?: number; +} +export interface GpuStencilFaceState { + compare?: GPUCompareFunction; + depthFailOp?: GPUStencilOperation; + failOp?: GPUStencilOperation; + passOp?: GPUStencilOperation; +} +export interface GpuDepthStencilState { + depthBias?: number; + depthBiasClamp?: number; + depthBiasSlopeScale?: number; + depthCompare?: GPUCompareFunction; + depthWriteEnabled?: boolean; + format: GPUTextureFormat; + stencilBack?: GpuStencilFaceState; + stencilFront?: GpuStencilFaceState; + stencilReadMask?: number; + stencilWriteMask?: number; +} +export interface GpuBlendComponent { + dstFactor?: GPUBlendFactor; + operation?: GPUBlendOperation; + srcFactor?: GPUBlendFactor; +} +export interface GpuBlendState { + alpha: GpuBlendComponent; + color: GpuBlendComponent; +} +export interface GpuColorTargetState { + blend?: GpuBlendState; + format: GPUTextureFormat; + writeMask?: number; +} +export interface GpuFragmentState { + constants?: Record; + entryPoint?: string; + module: g_p_u_shader_module; + targets: Array; +} +export interface GpuMultisampleState { + alphaToCoverageEnabled?: boolean; + count?: number; + mask?: number; +} +export interface GpuPrimitiveState { + cullMode?: GPUCullMode; + frontFace?: GPUFrontFace; + stripIndexFormat?: GPUIndexFormat; + topology?: GPUPrimitiveTopology; + unclippedDepth?: boolean; +} +export interface GpuVertexAttribute { + format: GPUVertexFormat; + offset: number; + shaderLocation: number; +} +export interface GpuVertexBufferLayout { + arrayStride: number; + attributes: Array; + stepMode?: GPUVertexStepMode; +} +export interface GpuVertexState { + buffers?: Array; + constants?: Record; + entryPoint?: string; + module: g_p_u_shader_module; +} +export interface GpuRenderPipelineDescriptor { + depthStencil?: GpuDepthStencilState; + fragment?: GpuFragmentState; + label?: string; + layout?: object | GPUPipelineLayoutAuto; + multisample?: GpuMultisampleState; + primitive?: GpuPrimitiveState; + vertex: GpuVertexState; +} +export const enum GPUMapState { + unmapped = 'unmapped', + mapped = 'mapped', + pending = 'pending', +} +export interface GpuRequestAdapterOptions { + powerPreference?: string; + isFallbackAdapter?: boolean; +} +export interface ContextAttributes { + alpha: boolean; + antialias: boolean; + depth: boolean; + failIfMajorPerformanceCaveat: boolean; + powerPreference: string; + premultipliedAlpha: boolean; + preserveDrawingBuffer: boolean; + stencil: boolean; + desynchronized: boolean; + xrCompatible: boolean; +} +export const enum ImageBitmapOptionsImageOrientation { + fromImage = 'from-image', + flipY = 'flipY', + none = 'none', +} +export const enum ImageBitmapOptionsPremultiplyAlpha { + premultiply = 'premultiply', + none = 'none', + default = 'default', +} +export const enum ImageBitmapOptionsColorSpaceConversion { + default = 'default', + none = 'none', +} +export const enum ImageBitmapOptionResizeQuality { + low = 'low', + medium = 'medium', + high = 'high', + pixelated = 'pixelated', +} +export interface ImageBitmapOptions { + imageOrientation?: ImageBitmapOptionsImageOrientation; + premultiplyAlpha?: ImageBitmapOptionsPremultiplyAlpha; + colorSpaceConversion?: ImageBitmapOptionsColorSpaceConversion; + resizeWidth?: number; + resizeHeight?: number; + resizeQuality?: ImageBitmapOptionResizeQuality; +} +export declare function createImageBitmap(source: ImageAsset | ImageBitmap | ImageData | Uint8Array, sxOrOptions?: ImageBitmapOptions | number | undefined | null, sy?: number | undefined | null, sw?: number | undefined | null, sh?: number | undefined | null, options?: ImageBitmapOptions | undefined | null): Promise; +export type g_p_u_adapter = GPUAdapter; +export declare class GPUAdapter { + get features(): unknown; + get isFallbackAdapter(): boolean; + get limits(): GPUSupportedLimits; + requestAdapterInfo(): Promise; + requestDevice(descriptor?: GPUDeviceDescriptor | undefined | null): Promise; +} +export type g_p_u_adapter_info = GPUAdapterInfo; +export declare class GPUAdapterInfo { + get architecture(): string; + get description(): string; + get device(): string; + get vendor(): string; +} +export type g_p_u_bind_group = GPUBindGroup; +export declare class GPUBindGroup { + get label(): string; +} +export type g_p_u_bind_group_layout = GPUBindGroupLayout; +export declare class GPUBindGroupLayout { + get label(): string; +} +export type g_p_u_command_buffer = GPUCommandBuffer; +export declare class GPUCommandBuffer { + get label(): string; +} +export type g_p_u_command_encoder = GPUCommandEncoder; +export declare class GPUCommandEncoder { + get label(): string; + beginComputePass(descriptor?: GPUComputePassDescriptor | undefined | null): g_p_u_compute_pass_encoder; + beginRenderPass(descriptor: GPURenderPassDescriptor): g_p_u_render_pass_encoder; + clearBuffer(buffer: g_p_u_buffer, offset?: number | undefined | null, size?: number | undefined | null): void; + copyBufferToBuffer(source: g_p_u_buffer, sourceOffset: number, destination: g_p_u_buffer, destinationOffset: number, size: number): void; + copyBufferToTexture(source: GPUImageCopyBuffer, destination: GPUImageCopyTexture, copySize: GPUExtent3DDict | Array): void; + copyTextureToBuffer(source: GPUImageCopyTexture, destination: GPUImageCopyBuffer, copySize: GPUExtent3DDict | Array): void; + copyTextureToTexture(source: GPUImageCopyTexture, destination: GPUImageCopyTexture, copySize: GPUExtent3DDict | Array): void; + finish(descriptor?: GpuCommandEncoderFinishDescriptor | undefined | null): GPUCommandBuffer; + insertDebugMarker(markerLabel: string): void; + popDebugGroup(): void; + pushDebugGroup(groupLabel: string): void; + resolveQuerySet(querySet: g_p_u_query_set, firstQuery: number, queryCount: number, destination: g_p_u_buffer, destinationOffset: number): void; + writeTimestamp(querySet: g_p_u_query_set, queryIndex: number): void; +} +export type g_p_u_canvas_context = GPUCanvasContext; +export declare class GPUCanvasContext { + static withLayer(gpu: g_p_u, layer: number, width: number, height: number): GPUCanvasContext; + static withView(gpu: g_p_u, layer: number, width: number, height: number): GPUCanvasContext; + resize(layer: number, width: number, height: number): void; + presentSurface(): void; + configure(options: GpuCanvasContextConfigOptions): void; + unconfigure(): void; + getCurrentTexture(): g_p_u_texture | null; + get hasCurrentTexture(): boolean; + getCapabilities(adapter: GPUAdapter): { usages: number; formats: string[]; alphaModes: string[]; presentModes: string[] }; + toDataURL(format?: string | undefined | null, encoderOptions?: number | undefined | null): string; +} +export type g_p_u_device = GPUDevice; +export declare class GPUDevice { + get label(): string; + get queue(): g_p_u_queue; + get limits(): GPUSupportedLimits; + get features(): unknown; + createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup; + createBindGroupLayout(descriptor: GPUBindGroupLayoutDescriptor): GPUBindGroupLayout; + createBuffer(descriptor: GPUBufferDescriptor): g_p_u_buffer; + createCommandEncoder(descriptor?: GPUCommandEncoderDescriptor | undefined | null): GPUCommandEncoder; + createComputePipeline(descriptor: GPUComputePipelineDescriptor): g_p_u_compute_pipeline; + createPipelineLayout(descriptor: GPUPipelineLayoutDescriptor): g_p_u_pipeline_layout; + createRenderPipeline(descriptor: GPURenderPipelineDescriptor): g_p_u_render_pipeline; + createQuerySet(descriptor: GPUQuerySetDescriptor): g_p_u_query_set; + createRenderBundleEncoder(descriptor: GPURenderBundleEncoderDescriptor): g_p_u_render_bundle_encoder; + createShaderModule(descriptor: GPUShaderModuleDescriptor): g_p_u_shader_module; + destroy(): void; + createSampler(descriptor?: GPUSamplerDescriptor | undefined | null): g_p_u_sampler; + createTexture(descriptor: GPUTextureDescriptor): g_p_u_texture | null; + pushErrorScope(filter: GPUErrorFilter): void; +} +export type g_p_u_pipeline_layout = GPUPipelineLayout; +export declare class GPUPipelineLayout { + get label(): string; +} +export type g_p_u_query_set = GPUQuerySet; +export declare class GPUQuerySet { + get label(): string; +} +export type g_p_u_queue = GPUQueue; +export declare class GPUQueue { + get label(): string; + copyExternalImageToTexture(source: GPUImageCopyExternalImage, destination: GPUImageCopyTextureTagged, copySize: Array | GpuExtent3DDict): void; + writeBuffer(buffer: g_p_u_buffer, bufferOffset: number, data: ArrayBuffer | Uint8Array | Float32Array | Uint32Array, dataOffset?: number | undefined | null, size?: number | undefined | null): void; + writeTexture(destination: GpuImageCopyTexture, data: Uint8Array | Uint16Array | Uint32Array | ArrayBuffer, dataLayout: GPUImageDataLayout, size: Array | GpuExtent3DDict): void; + submit(buffers: Array): void; +} +export type g_p_u_render_pass_encoder = GPURenderPassEncoder; +export declare class GPURenderPassEncoder { + get label(): string; + beginOcclusionQuery(queryIndex: number): void; + draw(vertexCount: number, instanceCount?: number | undefined | null, firstVertex?: number | undefined | null, firstInstance?: number | undefined | null): void; + drawIndexed(indexCount: number, instanceCount?: number | undefined | null, firstVertex?: number | undefined | null, baseVertex?: number | undefined | null, firstInstance?: number | undefined | null): void; + drawIndexedIndirect(indirectBuffer: g_p_u_buffer, indirectOffset: number): void; + drawIndirect(indirectBuffer: g_p_u_buffer, indirectOffset: number): void; + multiDrawIndexedIndirect(indirectBuffer: g_p_u_buffer, indirectOffset: number, count?: number | undefined | null): void; + multiDrawIndirect(indirectBuffer: g_p_u_buffer, indirectOffset: number, count?: number | undefined | null): void; + end(): void; + endOcclusionQuery(): void; + executeBundles(bundles: Array): void; + insertDebugMarker(markerLabel: string): void; + popDebugGroup(): void; + pushDebugGroup(groupLabel: string): void; + setBindGroup(index: number, bindGroup: GPUBindGroup, dynamicOffsetsData?: Array | Uint32Array | undefined | null, dynamicOffsetsDataStart?: number | undefined | null, dynamicOffsetsDataLength?: number | undefined | null): void; + setBlendConstant(color: GpuColorDict | Array): void; + setIndexBuffer(buffer: g_p_u_buffer, indexFormat: GPUIndexFormat, offset?: number | undefined | null, size?: number | undefined | null): void; + setPipeline(renderPipeline: g_p_u_render_pipeline): void; + setScissorRect(x: number, y: number, width: number, height: number): void; + setStencilReference(reference: number): void; + setVertexBuffer(slot: number, buffer: g_p_u_buffer, offset?: number | undefined | null, size?: number | undefined | null): void; + setViewport(x: number, y: number, width: number, height: number, minDepth: number, maxDepth: number): void; +} +export type g_p_u_render_pipeline = GPURenderPipeline; +export declare class GPURenderPipeline { + get label(): string; + getBindGroupLayout(index: number): GPUBindGroupLayout | null; +} +export type g_p_u_shader_module = GPUShaderModule; +export declare class GPUShaderModule { + get label(): string; +} +export type g_p_u_texture = GPUTexture; +export declare class GPUTexture { + get label(): string; + get depthOrArrayLayers(): number; + get dimension(): GPUTextureDimension; + get format(): GPUTextureFormat; + get mipLevelCount(): number; + get sampleCount(): number; + get width(): number; + get height(): number; + get usage(): number; + createView(descriptor?: GPUTextureViewDescriptor | undefined | null): g_p_u_texture_view; + destroy(): void; +} +export type g_p_u_texture_view = GPUTextureView; +export declare class GPUTextureView { + get label(): string; +} +export type g_p_u_buffer = GPUBuffer; +export declare class GPUBuffer { + get mapState(): GPUMapState; + get label(): string; + get usage(): number; + getMappedRange(offset?: number | undefined | null, size?: number | undefined | null): ArrayBuffer; + mapAsync(mode: GPUMapMode, offset?: number | undefined | null, size?: number | undefined | null): Promise; + destroy(): void; + get size(): number; + unmap(): void; +} +export type g_p_u_compute_pass_encoder = GPUComputePassEncoder; +export declare class GPUComputePassEncoder { + get label(): string; + dispatchWorkgroups(workgroupCountX: number, workgroupCountY?: number | undefined | null, workgroupCountZ?: number | undefined | null): void; + dispatchWorkgroupsIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void; + end(): void; + insertDebugMarker(markerLabel: string): void; + popDebugGroup(): void; + pushDebugGroup(groupLabel: string): void; + setBindGroup(index: number, bindGroup: GPUBindGroup, dynamicOffsetsData?: Array | Uint32Array | undefined | null, dynamicOffsetsDataStart?: number | undefined | null, dynamicOffsetsDataLength?: number | undefined | null): void; + setPipeline(renderPipeline: g_p_u_compute_pipeline): void; +} +export type g_p_u_compute_pipeline = GPUComputePipeline; +export declare class GPUComputePipeline { + get label(): string; + getBindGroupLayout(index: number): GPUBindGroupLayout | null; +} +export type g_p_u_external_texture = GPUExternalTexture; +export declare class GPUExternalTexture {} +export type g_p_u_render_bundle = GPURenderBundle; +export declare class GPURenderBundle { + get label(): string; +} +export type g_p_u_render_bundle_encoder = GPURenderBundleEncoder; +export declare class GPURenderBundleEncoder { + get label(): string; + draw(vertexCount: number, instanceCount?: number | undefined | null, firstVertex?: number | undefined | null, firstInstance?: number | undefined | null): void; + drawIndexed(indexCount: number, instanceCount?: number | undefined | null, firstVertex?: number | undefined | null, baseVertex?: number | undefined | null, firstInstance?: number | undefined | null): void; + drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void; + drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void; + finish(descriptor?: GPURenderBundleDescriptor | undefined | null): GPURenderBundle; + insertDebugMarker(markerLabel: string): void; + popDebugGroup(): void; + pushDebugGroup(groupLabel: string): void; + setBindGroup(index: number, bindGroup: GPUBindGroup, dynamicOffsetsData?: Array | Uint32Array | undefined | null, dynamicOffsetsDataStart?: number | undefined | null, dynamicOffsetsDataLength?: number | undefined | null): void; + setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number | undefined | null, size?: number | undefined | null): void; + setPipeline(renderPipeline: GPURenderPipeline): void; + setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number | undefined | null, size?: number | undefined | null): void; +} +export type g_p_u_sampler = GPUSampler; +export declare class GPUSampler { + get label(): string; +} +export type g_p_u = GPU; +export declare class GPU { + static getInstance(): GPU; + wgslLanguageFeatures(): Array; + getPreferredCanvasFormat(): string; + requestAdapter(options?: GpuRequestAdapterOptions | undefined | null): Promise; +} +export declare class Path2D { + constructor(data?: Path2D | string | undefined | null); + addPath(path: Path2D): void; + arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean | undefined | null): void; + arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; + bezierCurveTo(cp1X: number, cp1Y: number, cp2X: number, cp2Y: number, x: number, y: number): void; + closePath(): void; + ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: boolean | undefined | null): void; + lineTo(x: number, y: number): void; + moveTo(x: number, y: number): void; + quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; + rect(x: number, y: number, width: number, height: number): void; + roundRect(x: number, y: number, width: number, height: number, radii: number | Array): void; + trim(start: number, end: number): void; + toSvg(): string; +} +export declare class CanvasPattern {} +export declare class CanvasGradient { + addColorStop(offset: number, color: string): void; +} +export declare class ImageData { + constructor(widthOrImageData: number | Uint8ClampedArray, height?: number | undefined | null, settingsOrHeight?: object | number | undefined | null); + get width(): number; + get height(): number; + get data(): Uint8Array; +} +export declare class TextMetrics { + get width(): number; + get actualBoundingBoxLeft(): number; + get actualBoundingBoxRight(): number; + get actualBoundingBoxAscent(): number; + get actualBoundingBoxDescent(): number; + get fontBoundingBoxAscent(): number; + get fontBoundingBoxDescent(): number; + get emHeightAscent(): number; + get emHeightDescent(): number; + get hangingBaseline(): number; + get alphabeticBaseline(): number; + get ideographicBaseline(): number; +} +export declare class CanvasRenderingContext2D { + static withView(view: number, width: number, height: number, density: number, alpha: boolean, fontColor: number, ppi: number, direction: number): CanvasRenderingContext2D; + static withMtlViewDeviceQueue(view: number, device: number, queue: number, alpha: boolean, density: number, samples: number, fontColor: number, ppi: number, direction: number): CanvasRenderingContext2D; + present(): void; + flush(): void; + render(): void; + resize(width: number, height: number): void; + static withCpu(width: number, height: number, density: number, alpha: boolean, fontColor: number, ppi: number, direction: number): CanvasRenderingContext2D; + toDataURL(format: string, encoderOptions?: number | undefined | null): string; + get direction(): string; + set direction(direction: string); + get fillStyle(): unknown; + set fillStyle(style: string | CanvasPattern | CanvasGradient); + get filter(): string; + set filter(value: string); + get font(): string; + set font(value: string); + get fontKerning(): string; + set fontKerning(value: string); + get fontStretch(): string; + set fontStretch(value: string); + get fontVariantCaps(): string; + set fontVariantCaps(value: string); + get globalAlpha(): number; + set globalAlpha(alpha: number); + get globalCompositeOperation(): string; + set globalCompositeOperation(operation: string); + get imageSmoothingEnabled(): boolean; + set imageSmoothingEnabled(enabled: boolean); + get imageSmoothingQuality(): string; + set imageSmoothingQuality(quality: number | string); + get letterSpacing(): string; + set letterSpacing(spacing: string); + get lineCap(): string; + set lineCap(cap: string); + get lineDashOffset(): number; + set lineDashOffset(offset: number); + get lineJoin(): string; + set lineJoin(join: string); + get lineWidth(): number; + set lineWidth(width: number); + get miterLimit(): number; + set miterLimit(limit: number); + get shadowBlur(): number; + set shadowBlur(blur: number); + get shadowColor(): string; + set shadowColor(color: string); + get shadowOffsetX(): number; + set shadowOffsetX(x: number); + get shadowOffsetY(): number; + set shadowOffsetY(y: number); + get strokeStyle(): unknown; + set strokeStyle(style: string | CanvasPattern | CanvasGradient); + get textAlign(): string; + set textAlign(align: string); + get textBaseline(): string; + set textBaseline(value: string); + get textRendering(): string; + set textRendering(value: string); + get wordSpacing(): string; + set wordSpacing(value: string); + arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean | undefined | null): void; + arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; + beginPath(): void; + bezierCurveTo(cp1X: number, cp1Y: number, cp2X: number, cp2Y: number, x: number, y: number): void; + clearRect(x: number, y: number, width: number, height: number): void; + clip(path?: Path2D | undefined | null, rule?: string | undefined | null): void; + closePath(): void; + createConicGradient(startAngle: number, x: number, y: number): CanvasGradient; + createImageData(widthOrImageData: number | ImageData, height?: number | undefined | null): ImageData; + createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; + createPattern(image: ImageAsset, repetition?: string | undefined | null): CanvasPattern; + createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; + drawFocusIfNeeded(elementPath: object | Path2D, element?: object | undefined | null): void; + drawImage(image: ImageAsset, sx?: number | undefined | null, sy?: number | undefined | null, sWidth?: number | undefined | null, sHeight?: number | undefined | null, dx?: number | undefined | null, dy?: number | undefined | null, dWidth?: number | undefined | null, dHeight?: number | undefined | null): void; + ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: boolean | undefined | null): void; + fill(path?: Path2D | undefined | null, rule?: string | undefined | null): void; + fillRect(x: number, y: number, width: number, height: number): void; + fillText(text: string, x: number, y: number, maxWidth?: number | undefined | null): void; + getImageData(x: number, y: number, width: number, height: number): ImageData; + getLineDash(): Array; + getTransform(): DOMMatrix; + isContextLost(): boolean; + isPointInPath(xOrPath: number | Path2D, y?: number | undefined | null, ruleOrY?: number | string | undefined | null, rule?: string | undefined | null): boolean; + isPointInStroke(xOrPath: number | Path2D, xOrY?: number | undefined | null, y?: number | undefined | null): boolean; + lineTo(x: number, y: number): void; + measureText(text: string): TextMetrics; + moveTo(x: number, y: number): void; + putImageData(imageData: ImageData, dx: number, dy: number, dirtyX?: number | undefined | null, dirtyY?: number | undefined | null, dirtyWidth?: number | undefined | null, dirtyHeight?: number | undefined | null): void; + quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; + rect(x: number, y: number, width: number, height: number): void; + reset(): void; + resetTransform(): void; + restore(): void; + rotate(angle: number): void; + roundRect(x: number, y: number, width: number, height: number, radii: number | Array): void; + save(): void; + scale(x: number, y: number): void; + setLineDash(segments: Array): void; + stroke(path?: Path2D | undefined | null): void; + strokeRect(x: number, y: number, width: number, height: number): void; + strokeText(text: string, x: number, y: number, maxWidth?: number | undefined | null): void; + strokeOval(x: number, y: number, width: number, height: number): void; + setTransform(a: number | DOMMatrix, b?: number | undefined | null, c?: number | undefined | null, d?: number | undefined | null, e?: number | undefined | null, f?: number | undefined | null): void; + transform(a: number, b: number, c: number, d: number, e: number, f: number): void; + translate(x: number, y: number): void; +} +export declare class ImageAsset { + constructor(); + get width(): number; + get height(): number; + get error(): string; + fromUrlSync(url: string): boolean; + fromUrl(url: string): Promise; + loadUrlCallback(url: string, callback: (...args: any[]) => any): void; + fromFileSync(path: string): boolean; + fromFile(path: string): Promise; +} +export type DOMMatrix = DomMatrix; +export declare class DomMatrix { + constructor(data?: Array | undefined | null); +} +export declare class TextEncoder { + constructor(encoding?: string | undefined | null); + get encoding(): string; + encode(text: string): Buffer; +} +export declare class TextDecoder { + constructor(encoding?: string | undefined | null); + get encoding(): string; + decode(data: Uint8Array): string; +} +export declare class ANGLE_instanced_arrays {} +export declare class OES_fbo_render_mipmap {} +export declare class EXT_blend_minmax {} +export declare class EXT_color_buffer_half_float {} +export declare class EXT_disjoint_timer_query {} +export declare class EXT_sRGB {} +export declare class EXT_shader_texture_lod {} +export declare class EXT_texture_filter_anisotropic {} +export declare class OES_element_index_uint {} +export declare class OES_standard_derivatives {} +export declare class OES_texture_float {} +export declare class OES_texture_float_linear {} +export declare class OES_texture_half_float {} +export declare class OES_texture_half_float_linear {} +export declare class OES_vertex_array_object {} +export declare class WEBGL_color_buffer_float {} +export declare class WEBGL_compressed_texture_atc {} +export declare class WEBGL_compressed_texture_etc {} +export declare class WEBGL_compressed_texture_etc1 {} +export declare class WEBGL_compressed_texture_pvrtc {} +export declare class WEBGL_compressed_texture_s3tc {} +export declare class WEBGL_lose_context {} +export declare class WEBGL_depth_texture {} +export declare class WEBGL_draw_buffers {} +export type web_g_l_active_info = WebGLActiveInfo; +export declare class WebGLActiveInfo { + get name(): string; + get size(): number; + get type(): number; + get isEmpty(): boolean; +} +export declare class WebGLBuffer {} +export type web_g_l_framebuffer = WebGLFramebuffer; +export declare class WebGLFramebuffer {} +export declare class WebGLProgram {} +export declare class WebGLRenderbuffer {} +export declare class WebGLShader {} +export type web_g_l_shader_precision_format = WebGLShaderPrecisionFormat; +export declare class WebGLShaderPrecisionFormat { + get precision(): number; + get rangeMin(): number; + get rangeMax(): number; +} +export declare class WebGLTexture {} +export declare class WebGLUniformLocation {} +export type web_g_l_rendering_context = WebGLRenderingContext; +export declare class WebGLRenderingContext { + renderImmediate(): void; + render(): void; + get drawingBufferWidth(): number; + get drawingBufferHeight(): number; + activeTexture(texture: number): void; + attachShader(program: WebGLProgram, shader: WebGLShader): void; + bindAttribLocation(program: WebGLProgram, index: number, name: string): void; + bindBuffer(target: number, buffer: WebGLBuffer): void; + bindFramebuffer(target: number, framebuffer?: WebGLFramebuffer | undefined | null): void; + bindRenderbuffer(target: number, renderbuffer?: WebGLRenderbuffer | undefined | null): void; + bindTexture(target: number, texture?: WebGLTexture | undefined | null): void; + blendColor(red: number, green: number, blue: number, alpha: number): void; + blendEquationSeparate(modeRGB: number, modeAlpha: number): void; + blendEquation(mode: number): void; + blendFuncSeparate(srcRGB?: number | undefined | null, dstRGB?: number | undefined | null, srcAlpha?: number | undefined | null, dstAlpha?: number | undefined | null): void; + blendFunc(sfactor?: number | undefined | null, dfactor?: number | undefined | null): void; + bufferData(target: number, sizeOrSrcData?: number | Buffer | Float32Array | undefined | null, usage?: number | undefined | null): void; + bufferSubData(target: number, offset: number, srcData: Uint8Array): void; + checkFramebufferStatus(target: number): number; + clearColor(red: number, green: number, blue: number, alpha: number): void; + clearDepth(depth: number): void; + clearStencil(stencil: number): void; + clear(mask: number): void; + colorMask(red: boolean, green: boolean, blue: boolean, alpha: boolean): void; + commit(): void; + compileShader(shader: WebGLShader): void; + compressedTexImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, pixels: Uint8Array): void; + compressedTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, pixels: Uint8Array): void; + copyTexImage2D(target: number, level: number, internalformat: number, x: number, y: number, width: number, height: number, border: number): void; + copyTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, x: number, y: number, width: number, height: number): void; + createBuffer(): WebGLBuffer; + createFramebuffer(): WebGLFramebuffer; + createProgram(): WebGLProgram; + createRenderbuffer(): WebGLRenderbuffer; + createShader(type: number): WebGLShader; + createTexture(): WebGLTexture; + cullFace(mode: number): void; + deleteBuffer(buffer: WebGLBuffer): void; + deleteFramebuffer(frameBuffer: WebGLFramebuffer): void; + deleteProgram(program: WebGLProgram): void; + deleteRenderbuffer(renderBuffer: WebGLRenderbuffer): void; + deleteShader(shader: WebGLRenderbuffer): void; + deleteTexture(texture: WebGLTexture): void; + depthFunc(func: number): void; + depthMask(flag: boolean): void; + depthRange(zNear: number, zFar: number): void; + detachShader(program: WebGLProgram, shader: WebGLShader): void; + disableVertexAttribArray(index: number): void; + disable(cap: number): void; + drawArrays(mode: number, first: number, count: number): void; + drawElements(mode: number, count: number, type: number, offset: number): void; + enableVertexAttribArray(index: number): void; + enable(cap: number): void; + finish(): void; + flush(): void; + framebufferRenderbuffer(target: number, attachment: number, renderbuffertarget: number, renderbuffer: WebGLRenderbuffer): void; + framebufferTexture2D(target: number, attachment: number, textarget: number, texture: WebGLTexture, level: number): void; + frontFace(mode: number): void; + generateMipmap(target: number): void; + getActiveAttrib(program: WebGLProgram, index: number): WebGLActiveInfo; + getActiveUniform(program: WebGLProgram, index: number): WebGLActiveInfo; + getAttachedShaders(program: WebGLProgram): Array; + getAttribLocation(program: WebGLProgram, name: string): number; + getBufferParameter(target: number, pname: number): number; + getContextAttributes(): ContextAttributes; + getError(): number; + getExtension(name: string): unknown; + getFramebufferAttachmentParameter(target: number, attachment: number, pname: number): unknown; + getProgramInfoLog(program: WebGLProgram): string; + getProgramParameter(program: WebGLProgram, pname: number): unknown; + getRenderbufferParameter(target: number, pname: number): number; + getShaderInfoLog(shader: WebGLShader): string; + getShaderParameter(shader: WebGLShader, pname: number): unknown; + getShaderPrecisionFormat(shaderType: number, precisionType: number): WebGLShaderPrecisionFormat; + getShaderSource(shader: WebGLShader): string; + getSupportedExtensions(): Array; + getTexParameter(target: number, pname: number): number; + getUniformLocation(program: WebGLProgram, name: string): unknown; + getUniform(program: WebGLProgram, location: WebGLUniformLocation): unknown; + getVertexAttribOffset(index: number, pname: number): number; + getVertexAttrib(index: number, pname: number): unknown; + hint(target: number, mode: number): void; + isBuffer(buffer: WebGLBuffer): boolean; + isContextLost(): boolean; + isEnabled(cap: number): boolean; + isFramebuffer(framebuffer?: WebGLFramebuffer | undefined | null): boolean; + isProgram(program: WebGLProgram): boolean; + isRenderbuffer(renderbuffer: WebGLRenderbuffer): boolean; + isShader(shader: WebGLShader): boolean; + isTexture(texture: WebGLTexture): boolean; + lineWidth(width: number): void; + linkProgram(program: WebGLProgram): void; + pixelStorei(pname: number, param: boolean | number): void; + polygonOffset(factor: number, units: number): void; + readPixels(x: number, y: number, width: number, height: number, format: number, type: number, pixels: ArrayBuffer | ArrayBufferView): void; + renderbufferStorage(target: number, internalFormat: number, width: number, height: number): void; + sampleCoverage(value: number, invert: boolean): void; + scissor(x: number, y: number, width: number, height: number): void; + shaderSource(shader: WebGLShader, source: string): void; + stencilFuncSeparate(face: number, func: number, ref: number, mask: number): void; + stencilFunc(func: number, ref: number, mask: number): void; + stencilMaskSeparate(face: number, mask: number): void; + stencilMask(mask: number): void; + stencilOpSeparate(face: number, fail: number, zfail: number, zpass: number): void; + stencilOp(fail: number, zfail: number, zpass: number): void; + texImage2D(target: number, level: number, internalformat: number, widthOrFormat: number, heightOrType: number, borderOrPixels: number | CanvasRenderingContext2D | WebGLRenderingContext | ImageAsset, format?: number | undefined | null, type?: number | undefined | null, pixels?: Buffer | number | undefined | null, offset?: number | undefined | null): void; + texParameterf(target: number, pname: number, param: number): void; + texParameteri(target: number, pname: number, param: number): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, formatOrWidth: number, typeOrHeight: number, pixelsOrFormat: number | ImageBitmap | ImageAsset | CanvasRenderingContext2D | WebGLRenderingContext | web_g_l_2_rendering_context | ImageData, type?: number | undefined | null, pixels?: Uint8Array | Uint16Array | Float32Array | ArrayBuffer | number | undefined | null, offset?: number | undefined | null): void; + uniform1f(location: WebGLUniformLocation, v0: number): void; + uniform1iv(location: WebGLUniformLocation, value: Array | Int32Array): void; + uniform1fv(location: WebGLUniformLocation, value: Array | Float32Array): void; + uniform1i(location: WebGLUniformLocation, v0: number | boolean): void; + uniform2f(location: WebGLUniformLocation, v0: number, v1: number): void; + uniform2iv(location: WebGLUniformLocation, value: Array | Int32Array): void; + uniform2fv(location: WebGLUniformLocation, value: Array | Float32Array): void; + uniform2i(location: WebGLUniformLocation, v0: number, v1: number): void; + uniform3f(location: WebGLUniformLocation, v0: number, v1: number, v2: number): void; + uniform3iv(location: WebGLUniformLocation, value: Array | Int32Array): void; + uniform3fv(location: WebGLUniformLocation, value: Array | Float32Array): void; + uniform3i(location: WebGLUniformLocation, v0: number, v1: number, v2: number): void; + uniform4f(location: WebGLUniformLocation, v0: number, v1: number, v2: number, v3: number): void; + uniform4iv(location: WebGLUniformLocation, value: Array | Int32Array): void; + uniform4fv(location: WebGLUniformLocation, value: Array | Float32Array): void; + uniform4i(location: WebGLUniformLocation, v0: number, v1: number, v2: number, v3: number): void; + uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: Array | Float32Array): void; + uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: Array | Float32Array): void; + uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: Array | Float32Array): void; + useProgram(program?: WebGLProgram | undefined | null): void; + validateProgram(program: WebGLProgram): void; + vertexAttrib1f(index: number, v0: number): void; + vertexAttrib1fv(index: number, value: Array | Float32Array): void; + vertexAttrib2f(index: number, v0: number, v1: number): void; + vertexAttrib2fv(index: number, value: Array | Float32Array): void; + vertexAttrib3f(index: number, v0: number, v1: number, v2: number): void; + vertexAttrib3fv(index: number, value: Array | Float32Array): void; + vertexAttrib4f(index: number, v0: number, v1: number, v2: number, v3: number): void; + vertexAttrib4fv(index: number, value: Array | Float32Array): void; + vertexAttribPointer(index: number, size: number, type: number, normalized: boolean, stride: number, offset: number): void; + viewport(x: number, y: number, width: number, height: number): void; + toDataURL(format?: string | undefined | null, encoderOptions?: number | undefined | null): string; + static withView(view: number, alpha: boolean, antialias: boolean, depth: boolean, failIfMajorPerformanceCaveat: boolean, powerPreference: number, premultipliedAlpha: boolean, preserveDrawingBuffer: boolean, stencil: boolean, desynchronized: boolean, xrCompatible: boolean): WebGLRenderingContext; + static offscreen(width: number, height: number, alpha: boolean, antialias: boolean, depth: boolean, failIfMajorPerformanceCaveat: boolean, powerPreference: number, premultipliedAlpha: boolean, preserveDrawingBuffer: boolean, stencil: boolean, desynchronized: boolean, xrCompatible: boolean, isCanvas: boolean): WebGLRenderingContext; + getParameter(pname: number): unknown; + get DEPTH_BUFFER_BIT(): number; + get STENCIL_BUFFER_BIT(): number; + get COLOR_BUFFER_BIT(): number; + get POINTS(): number; + get LINES(): number; + get LINE_LOOP(): number; + get LINE_STRIP(): number; + get TRIANGLES(): number; + get TRIANGLE_STRIP(): number; + get TRIANGLE_FAN(): number; + get ZERO(): number; + get ONE(): number; + get SRC_COLOR(): number; + get ONE_MINUS_SRC_COLOR(): number; + get SRC_ALPHA(): number; + get ONE_MINUS_SRC_ALPHA(): number; + get DST_ALPHA(): number; + get ONE_MINUS_DST_ALPHA(): number; + get DST_COLOR(): number; + get ONE_MINUS_DST_COLOR(): number; + get SRC_ALPHA_SATURATE(): number; + get CONSTANT_COLOR(): number; + get ONE_MINUS_CONSTANT_COLOR(): number; + get CONSTANT_ALPHA(): number; + get ONE_MINUS_CONSTANT_ALPHA(): number; + get FUNC_ADD(): number; + get FUNC_SUBTRACT(): number; + get FUNC_REVERSE_SUBTRACT(): number; + get BLEND_EQUATION(): number; + get BLEND_EQUATION_RGB(): number; + get BLEND_EQUATION_ALPHA(): number; + get BLEND_DST_RGB(): number; + get BLEND_SRC_RGB(): number; + get BLEND_DST_ALPHA(): number; + get BLEND_SRC_ALPHA(): number; + get BLEND_COLOR(): number; + get ARRAY_BUFFER_BINDING(): number; + get ELEMENT_ARRAY_BUFFER_BINDING(): number; + get LINE_WIDTH(): number; + get ALIASED_POINT_SIZE_RANGE(): number; + get ALIASED_LINE_WIDTH_RANGE(): number; + get CULL_FACE_MODE(): number; + get FRONT_FACE(): number; + get DEPTH_RANGE(): number; + get DEPTH_WRITEMASK(): number; + get DEPTH_CLEAR_VALUE(): number; + get DEPTH_FUNC(): number; + get STENCIL_CLEAR_VALUE(): number; + get STENCIL_FUNC(): number; + get STENCIL_FAIL(): number; + get STENCIL_PASS_DEPTH_FAIL(): number; + get STENCIL_PASS_DEPTH_PASS(): number; + get STENCIL_REF(): number; + get STENCIL_VALUE_MASK(): number; + get STENCIL_WRITEMASK(): number; + get STENCIL_BACK_FUNC(): number; + get STENCIL_BACK_FAIL(): number; + get STENCIL_BACK_PASS_DEPTH_FAIL(): number; + get STENCIL_BACK_PASS_DEPTH_PASS(): number; + get STENCIL_BACK_REF(): number; + get STENCIL_BACK_VALUE_MASK(): number; + get STENCIL_BACK_WRITEMASK(): number; + get VIEWPORT(): number; + get SCISSOR_BOX(): number; + get COLOR_CLEAR_VALUE(): number; + get COLOR_WRITEMASK(): number; + get UNPACK_ALIGNMENT(): number; + get PACK_ALIGNMENT(): number; + get MAX_TEXTURE_SIZE(): number; + get MAX_VIEWPORT_DIMS(): number; + get SUBPIXEL_BITS(): number; + get RED_BITS(): number; + get GREEN_BITS(): number; + get BLUE_BITS(): number; + get ALPHA_BITS(): number; + get DEPTH_BITS(): number; + get STENCIL_BITS(): number; + get POLYGON_OFFSET_UNITS(): number; + get POLYGON_OFFSET_FACTOR(): number; + get TEXTURE_BINDING_2D(): number; + get SAMPLE_BUFFERS(): number; + get SAMPLES(): number; + get SAMPLE_COVERAGE_VALUE(): number; + get SAMPLE_COVERAGE_INVERT(): number; + get COMPRESSED_TEXTURE_FORMATS(): number; + get VENDOR(): number; + get RENDERER(): number; + get VERSION(): number; + get IMPLEMENTATION_COLOR_READ_TYPE(): number; + get IMPLEMENTATION_COLOR_READ_FORMAT(): number; + get BROWSER_DEFAULT_WEBGL(): number; + get STATIC_DRAW(): number; + get STREAM_DRAW(): number; + get DYNAMIC_DRAW(): number; + get ARRAY_BUFFER(): number; + get ELEMENT_ARRAY_BUFFER(): number; + get BUFFER_SIZE(): number; + get BUFFER_USAGE(): number; + get CURRENT_VERTEX_ATTRIB(): number; + get VERTEX_ATTRIB_ARRAY_ENABLED(): number; + get VERTEX_ATTRIB_ARRAY_SIZE(): number; + get VERTEX_ATTRIB_ARRAY_STRIDE(): number; + get VERTEX_ATTRIB_ARRAY_TYPE(): number; + get VERTEX_ATTRIB_ARRAY_NORMALIZED(): number; + get VERTEX_ATTRIB_ARRAY_POINTER(): number; + get VERTEX_ATTRIB_ARRAY_BUFFER_BINDING(): number; + get CULL_FACE(): number; + get FRONT(): number; + get BACK(): number; + get FRONT_AND_BACK(): number; + get BLEND(): number; + get DEPTH_TEST(): number; + get DITHER(): number; + get POLYGON_OFFSET_FILL(): number; + get SAMPLE_ALPHA_TO_COVERAGE(): number; + get SAMPLE_COVERAGE(): number; + get SCISSOR_TEST(): number; + get STENCIL_TEST(): number; + get NO_ERROR(): number; + get INVALID_ENUM(): number; + get INVALID_VALUE(): number; + get INVALID_OPERATION(): number; + get OUT_OF_MEMORY(): number; + get CONTEXT_LOST_WEBGL(): number; + get CW(): number; + get CCW(): number; + get DONT_CARE(): number; + get FASTEST(): number; + get NICEST(): number; + get GENERATE_MIPMAP_HINT(): number; + get BYTE(): number; + get UNSIGNED_BYTE(): number; + get SHORT(): number; + get UNSIGNED_SHORT(): number; + get INT(): number; + get UNSIGNED_INT(): number; + get FLOAT(): number; + get DEPTH_COMPONENT(): number; + get ALPHA(): number; + get RGB(): number; + get RGBA(): number; + get LUMINANCE(): number; + get LUMINANCE_ALPHA(): number; + get UNSIGNED_SHORT_4_4_4_4(): number; + get UNSIGNED_SHORT_5_5_5_1(): number; + get UNSIGNED_SHORT_5_6_5(): number; + get FRAGMENT_SHADER(): number; + get VERTEX_SHADER(): number; + get COMPILE_STATUS(): number; + get DELETE_STATUS(): number; + get LINK_STATUS(): number; + get VALIDATE_STATUS(): number; + get ATTACHED_SHADERS(): number; + get ACTIVE_ATTRIBUTES(): number; + get ACTIVE_UNIFORMS(): number; + get MAX_VERTEX_ATTRIBS(): number; + get MAX_VERTEX_UNIFORM_VECTORS(): number; + get MAX_VARYING_VECTORS(): number; + get MAX_COMBINED_TEXTURE_IMAGE_UNITS(): number; + get MAX_VERTEX_TEXTURE_IMAGE_UNITS(): number; + get MAX_TEXTURE_IMAGE_UNITS(): number; + get MAX_FRAGMENT_UNIFORM_VECTORS(): number; + get SHADER_TYPE(): number; + get SHADING_LANGUAGE_VERSION(): number; + get CURRENT_PROGRAM(): number; + get NEVER(): number; + get LESS(): number; + get EQUAL(): number; + get LEQUAL(): number; + get GREATER(): number; + get NOTEQUAL(): number; + get GEQUAL(): number; + get ALWAYS(): number; + get KEEP(): number; + get REPLACE(): number; + get INCR(): number; + get DECR(): number; + get INVERT(): number; + get INCR_WRAP(): number; + get DECR_WRAP(): number; + get NEAREST(): number; + get LINEAR(): number; + get NEAREST_MIPMAP_NEAREST(): number; + get LINEAR_MIPMAP_NEAREST(): number; + get NEAREST_MIPMAP_LINEAR(): number; + get LINEAR_MIPMAP_LINEAR(): number; + get TEXTURE_MAG_FILTER(): number; + get TEXTURE_MIN_FILTER(): number; + get TEXTURE_WRAP_S(): number; + get TEXTURE_WRAP_T(): number; + get TEXTURE_2D(): number; + get TEXTURE(): number; + get TEXTURE_CUBE_MAP(): number; + get TEXTURE_BINDING_CUBE_MAP(): number; + get TEXTURE_CUBE_MAP_POSITIVE_X(): number; + get TEXTURE_CUBE_MAP_NEGATIVE_X(): number; + get TEXTURE_CUBE_MAP_POSITIVE_Y(): number; + get TEXTURE_CUBE_MAP_NEGATIVE_Y(): number; + get TEXTURE_CUBE_MAP_POSITIVE_Z(): number; + get TEXTURE_CUBE_MAP_NEGATIVE_Z(): number; + get MAX_CUBE_MAP_TEXTURE_SIZE(): number; + get TEXTURE0(): number; + get TEXTURE1(): number; + get TEXTURE2(): number; + get TEXTURE3(): number; + get TEXTURE4(): number; + get TEXTURE5(): number; + get TEXTURE6(): number; + get TEXTURE7(): number; + get TEXTURE8(): number; + get TEXTURE9(): number; + get TEXTURE10(): number; + get TEXTURE11(): number; + get TEXTURE12(): number; + get TEXTURE13(): number; + get TEXTURE14(): number; + get TEXTURE15(): number; + get TEXTURE16(): number; + get TEXTURE17(): number; + get TEXTURE18(): number; + get TEXTURE19(): number; + get TEXTURE20(): number; + get TEXTURE21(): number; + get TEXTURE22(): number; + get TEXTURE23(): number; + get TEXTURE24(): number; + get TEXTURE25(): number; + get TEXTURE26(): number; + get TEXTURE27(): number; + get TEXTURE28(): number; + get TEXTURE29(): number; + get TEXTURE30(): number; + get TEXTURE31(): number; + get ACTIVE_TEXTURE(): number; + get REPEAT(): number; + get CLAMP_TO_EDGE(): number; + get MIRRORED_REPEAT(): number; + get FLOAT_VEC2(): number; + get FLOAT_VEC3(): number; + get FLOAT_VEC4(): number; + get INT_VEC2(): number; + get INT_VEC3(): number; + get INT_VEC4(): number; + get BOOL(): number; + get BOOL_VEC2(): number; + get BOOL_VEC3(): number; + get BOOL_VEC4(): number; + get FLOAT_MAT2(): number; + get FLOAT_MAT3(): number; + get FLOAT_MAT4(): number; + get SAMPLER_2D(): number; + get SAMPLER_CUBE(): number; + get LOW_FLOAT(): number; + get MEDIUM_FLOAT(): number; + get HIGH_FLOAT(): number; + get LOW_INT(): number; + get MEDIUM_INT(): number; + get HIGH_INT(): number; + get FRAMEBUFFER(): number; + get RENDERBUFFER(): number; + get RGBA4(): number; + get RGB5_A1(): number; + get RGB565(): number; + get DEPTH_COMPONENT16(): number; + get STENCIL_INDEX8(): number; + get DEPTH_STENCIL(): number; + get RENDERBUFFER_WIDTH(): number; + get RENDERBUFFER_HEIGHT(): number; + get RENDERBUFFER_INTERNAL_FORMAT(): number; + get RENDERBUFFER_RED_SIZE(): number; + get RENDERBUFFER_GREEN_SIZE(): number; + get RENDERBUFFER_BLUE_SIZE(): number; + get RENDERBUFFER_ALPHA_SIZE(): number; + get RENDERBUFFER_DEPTH_SIZE(): number; + get RENDERBUFFER_STENCIL_SIZE(): number; + get FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE(): number; + get FRAMEBUFFER_ATTACHMENT_OBJECT_NAME(): number; + get FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL(): number; + get FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE(): number; + get COLOR_ATTACHMENT0(): number; + get DEPTH_ATTACHMENT(): number; + get STENCIL_ATTACHMENT(): number; + get DEPTH_STENCIL_ATTACHMENT(): number; + get NONE(): number; + get FRAMEBUFFER_COMPLETE(): number; + get FRAMEBUFFER_INCOMPLETE_ATTACHMENT(): number; + get FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT(): number; + get FRAMEBUFFER_INCOMPLETE_DIMENSIONS(): number; + get FRAMEBUFFER_UNSUPPORTED(): number; + get FRAMEBUFFER_BINDING(): number; + get RENDERBUFFER_BINDING(): number; + get MAX_RENDERBUFFER_SIZE(): number; + get INVALID_FRAMEBUFFER_OPERATION(): number; + get UNPACK_FLIP_Y_WEBGL(): number; + get UNPACK_PREMULTIPLY_ALPHA_WEBGL(): number; + get UNPACK_COLORSPACE_CONVERSION_WEBGL(): number; +} +export declare class WebGLQuery {} +export declare class WebGLSampler {} +export declare class WebGLSync {} +export declare class WebGLTransformFeedback {} +export declare class WebGLVertexArrayObject {} +export type web_g_l_2_rendering_context = WebGL2RenderingContext; +export declare class WebGL2RenderingContext { + renderImmediate(): void; + render(): void; + get drawingBufferWidth(): number; + get drawingBufferHeight(): number; + activeTexture(texture: number): void; + attachShader(program: WebGLProgram, shader: WebGLShader): void; + bindAttribLocation(program: WebGLProgram, index: number, name: string): void; + bindBuffer(target: number, buffer: WebGLBuffer): void; + bindFramebuffer(target: number, framebuffer?: WebGLFramebuffer | undefined | null): void; + bindRenderbuffer(target: number, renderbuffer?: WebGLRenderbuffer | undefined | null): void; + bindTexture(target: number, texture?: WebGLTexture | undefined | null): void; + blendColor(red: number, green: number, blue: number, alpha: number): void; + blendEquationSeparate(modeRGB: number, modeAlpha: number): void; + blendEquation(mode: number): void; + blendFuncSeparate(srcRGB?: number | undefined | null, dstRGB?: number | undefined | null, srcAlpha?: number | undefined | null, dstAlpha?: number | undefined | null): void; + blendFunc(sfactor?: number | undefined | null, dfactor?: number | undefined | null): void; + bufferData(target: number, sizeOrSrcData?: number | Buffer | Float32Array | undefined | null, usage?: number | undefined | null): void; + bufferSubData(target: number, offset: number, srcData: Uint8Array): void; + checkFramebufferStatus(target: number): number; + clearColor(red: number, green: number, blue: number, alpha: number): void; + clearDepth(depth: number): void; + clearStencil(stencil: number): void; + clear(mask: number): void; + colorMask(red: boolean, green: boolean, blue: boolean, alpha: boolean): void; + commit(): void; + compileShader(shader: WebGLShader): void; + compressedTexImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, pixels: Uint8Array): void; + compressedTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, pixels: Uint8Array): void; + copyTexImage2D(target: number, level: number, internalformat: number, x: number, y: number, width: number, height: number, border: number): void; + copyTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, x: number, y: number, width: number, height: number): void; + createBuffer(): WebGLBuffer; + createFramebuffer(): WebGLFramebuffer; + createProgram(): WebGLProgram; + createRenderbuffer(): WebGLRenderbuffer; + createShader(type: number): WebGLShader; + createTexture(): WebGLTexture; + cullFace(mode: number): void; + deleteBuffer(buffer: WebGLBuffer): void; + deleteFramebuffer(frameBuffer: WebGLFramebuffer): void; + deleteProgram(program: WebGLProgram): void; + deleteRenderbuffer(renderBuffer: WebGLRenderbuffer): void; + deleteShader(shader: WebGLRenderbuffer): void; + deleteTexture(texture: WebGLTexture): void; + depthFunc(func: number): void; + depthMask(flag: boolean): void; + depthRange(zNear: number, zFar: number): void; + detachShader(program: WebGLProgram, shader: WebGLShader): void; + disableVertexAttribArray(index: number): void; + disable(cap: number): void; + drawArrays(mode: number, first: number, count: number): void; + drawElements(mode: number, count: number, type: number, offset: number): void; + enableVertexAttribArray(index: number): void; + enable(cap: number): void; + finish(): void; + flush(): void; + framebufferRenderbuffer(target: number, attachment: number, renderbuffertarget: number, renderbuffer: WebGLRenderbuffer): void; + framebufferTexture2D(target: number, attachment: number, textarget: number, texture: WebGLTexture, level: number): void; + frontFace(mode: number): void; + generateMipmap(target: number): void; + getActiveAttrib(program: WebGLProgram, index: number): WebGLActiveInfo; + getActiveUniform(program: WebGLProgram, index: number): WebGLActiveInfo; + getAttachedShaders(program: WebGLProgram): Array; + getAttribLocation(program: WebGLProgram, name: string): number; + getBufferParameter(target: number, pname: number): number; + getContextAttributes(): ContextAttributes; + getError(): number; + getExtension(name: string): unknown; + getFramebufferAttachmentParameter(target: number, attachment: number, pname: number): unknown; + getProgramInfoLog(program: WebGLProgram): string; + getProgramParameter(program: WebGLProgram, pname: number): unknown; + getRenderbufferParameter(target: number, pname: number): number; + getShaderInfoLog(shader: WebGLShader): string; + getShaderParameter(shader: WebGLShader, pname: number): unknown; + getShaderPrecisionFormat(shaderType: number, precisionType: number): WebGLShaderPrecisionFormat; + getShaderSource(shader: WebGLShader): string; + getSupportedExtensions(): Array; + getTexParameter(target: number, pname: number): number; + getUniformLocation(program: WebGLProgram, name: string): unknown; + getUniform(program: WebGLProgram, location: WebGLUniformLocation): unknown; + getVertexAttribOffset(index: number, pname: number): number; + getVertexAttrib(index: number, pname: number): unknown; + hint(target: number, mode: number): void; + isBuffer(buffer: WebGLBuffer): boolean; + isContextLost(): boolean; + isEnabled(cap: number): boolean; + isFramebuffer(framebuffer?: WebGLFramebuffer | undefined | null): boolean; + isProgram(program: WebGLProgram): boolean; + isRenderbuffer(renderbuffer: WebGLRenderbuffer): boolean; + isShader(shader: WebGLShader): boolean; + isTexture(texture: WebGLTexture): boolean; + lineWidth(width: number): void; + linkProgram(program: WebGLProgram): void; + pixelStorei(pname: number, param: boolean | number): void; + polygonOffset(factor: number, units: number): void; + readPixels(x: number, y: number, width: number, height: number, format: number, type: number, pixels: ArrayBuffer | ArrayBufferView): void; + renderbufferStorage(target: number, internalFormat: number, width: number, height: number): void; + sampleCoverage(value: number, invert: boolean): void; + scissor(x: number, y: number, width: number, height: number): void; + shaderSource(shader: WebGLShader, source: string): void; + stencilFuncSeparate(face: number, func: number, ref: number, mask: number): void; + stencilFunc(func: number, ref: number, mask: number): void; + stencilMaskSeparate(face: number, mask: number): void; + stencilMask(mask: number): void; + stencilOpSeparate(face: number, fail: number, zfail: number, zpass: number): void; + stencilOp(fail: number, zfail: number, zpass: number): void; + texImage2D(target: number, level: number, internalformat: number, widthOrFormat: number, heightOrType: number, borderOrPixels: number | CanvasRenderingContext2D | WebGLRenderingContext | ImageAsset, format?: number | undefined | null, type?: number | undefined | null, pixels?: Buffer | number | undefined | null, offset?: number | undefined | null): void; + texParameterf(target: number, pname: number, param: number): void; + texParameteri(target: number, pname: number, param: number): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, formatOrWidth: number, typeOrHeight: number, pixelsOrFormat: number | ImageBitmap | ImageAsset | CanvasRenderingContext2D | WebGLRenderingContext | WebGL2RenderingContext | ImageData, type?: number | undefined | null, pixels?: Uint8Array | Uint16Array | Float32Array | ArrayBuffer | number | undefined | null, offset?: number | undefined | null): void; + uniform1f(location: WebGLUniformLocation, v0: number): void; + uniform1iv(location: WebGLUniformLocation, value: Array | Int32Array): void; + uniform1fv(location: WebGLUniformLocation, value: Array | Float32Array): void; + uniform1i(location: WebGLUniformLocation, v0: number | boolean): void; + uniform2f(location: WebGLUniformLocation, v0: number, v1: number): void; + uniform2iv(location: WebGLUniformLocation, value: Array | Int32Array): void; + uniform2fv(location: WebGLUniformLocation, value: Array | Float32Array): void; + uniform2i(location: WebGLUniformLocation, v0: number, v1: number): void; + uniform3f(location: WebGLUniformLocation, v0: number, v1: number, v2: number): void; + uniform3iv(location: WebGLUniformLocation, value: Array | Int32Array): void; + uniform3fv(location: WebGLUniformLocation, value: Array | Float32Array): void; + uniform3i(location: WebGLUniformLocation, v0: number, v1: number, v2: number): void; + uniform4f(location: WebGLUniformLocation, v0: number, v1: number, v2: number, v3: number): void; + uniform4iv(location: WebGLUniformLocation, value: Array | Int32Array): void; + uniform4fv(location: WebGLUniformLocation, value: Array | Float32Array): void; + uniform4i(location: WebGLUniformLocation, v0: number, v1: number, v2: number, v3: number): void; + uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: Array | Float32Array): void; + uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: Array | Float32Array): void; + uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: Array | Float32Array): void; + useProgram(program?: WebGLProgram | undefined | null): void; + validateProgram(program: WebGLProgram): void; + vertexAttrib1f(index: number, v0: number): void; + vertexAttrib1fv(index: number, value: Array | Float32Array): void; + vertexAttrib2f(index: number, v0: number, v1: number): void; + vertexAttrib2fv(index: number, value: Array | Float32Array): void; + vertexAttrib3f(index: number, v0: number, v1: number, v2: number): void; + vertexAttrib3fv(index: number, value: Array | Float32Array): void; + vertexAttrib4f(index: number, v0: number, v1: number, v2: number, v3: number): void; + vertexAttrib4fv(index: number, value: Array | Float32Array): void; + vertexAttribPointer(index: number, size: number, type: number, normalized: boolean, stride: number, offset: number): void; + viewport(x: number, y: number, width: number, height: number): void; + toDataURL(format?: string | undefined | null, encoderOptions?: number | undefined | null): string; + static withView(view: number, alpha: boolean, antialias: boolean, depth: boolean, failIfMajorPerformanceCaveat: boolean, powerPreference: number, premultipliedAlpha: boolean, preserveDrawingBuffer: boolean, stencil: boolean, desynchronized: boolean, xrCompatible: boolean): WebGL2RenderingContext; + static offscreen(width: number, height: number, alpha: boolean, antialias: boolean, depth: boolean, failIfMajorPerformanceCaveat: boolean, powerPreference: number, premultipliedAlpha: boolean, preserveDrawingBuffer: boolean, stencil: boolean, desynchronized: boolean, xrCompatible: boolean, isCanvas: boolean): WebGL2RenderingContext; + beginQuery(target: number, query: WebGLQuery): void; + beginTransformFeedback(primitiveMode: number): void; + bindBufferBase(target: number, index: number, buffer: WebGLBuffer): void; + bindBufferRange(target: number, index: number, buffer: WebGLBuffer, offset: number, size: number): void; + bindSampler(unit: number, sampler: WebGLSampler): void; + bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback): void; + bindVertexArray(vertexArray: WebGLVertexArrayObject): void; + blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void; + clearBufferfi(buffer: WebGLBuffer, drawbuffer: number, depth: number, stencil: number): void; + clearBufferfv(buffer: WebGLBuffer, drawbuffer: number, values: Array | Float32Array): void; + clearBufferiv(buffer: WebGLBuffer, drawbuffer: number, values: Array | Int32Array): void; + clearBufferuiv(buffer: WebGLBuffer, drawbuffer: number, values: Array | Uint32Array): void; + clientWaitSync(sync: WebGLSync, flags: number, timeout: number): number; + compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, imageSizeOrSrcData: number | Buffer, srcOffset?: number | undefined | null, srcLengthOverride?: number | undefined | null): void; + compressedTexSubImage3D(target: number, level: number, xoffset: number, yoffset: number, zoffset: number, width: number, height: number, depth: number, format: number, imageSizeOrSrcData: number | Buffer, srcOffset?: number | undefined | null, srcLengthOverride?: number | undefined | null): void; + copyBufferSubData(readTarget: number, writeTarget: number, readOffset: number, writeOffset: number, size: number): void; + copyTexSubImage3D(target: number, level: number, xoffset: number, yoffset: number, zoffset: number, x: number, y: number, width: number, height: number): void; + createQuery(): WebGLQuery; + createSampler(): WebGLSampler; + createTransformFeedback(): WebGLTransformFeedback; + createVertexArray(): WebGLVertexArrayObject; + deleteQuery(query: WebGLQuery): void; + deleteSampler(sampler: WebGLSampler): void; + deleteSync(sync: WebGLSync): void; + deleteTransformFeedback(transformFeedback: WebGLTransformFeedback): void; + deleteVertexArray(vertexArray: WebGLVertexArrayObject): void; + drawArraysInstanced(mode: number, first: number, count: number, instanceCount: number): void; + drawBuffers(buffers: Array): void; + drawElementsInstanced(mode: number, count: number, type: number, offset: number, instanceCount: number): void; + drawRangeElements(mode: number, start: number, end: number, count: number, type: number, offset: number): void; + endQuery(target: number): void; + endTransformFeedback(): void; + fenceSync(condition: number, flags: number): WebGLSync; + framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture, level: number, layer: number): void; + getActiveUniformBlockName(program: WebGLProgram, uniformBlockIndex: number): string; + getActiveUniformBlockParameter(program: WebGLProgram, uniformBlockIndex: number, pname: number): unknown; + getActiveUniforms(program: WebGLProgram, uniformIndices: Array, pname: number): unknown; + getBufferSubData(target: number, srcByteOffset: number, dstData: Buffer, dstOffset?: number | undefined | null, length?: number | undefined | null): void; + getFragDataLocation(program: WebGLProgram, name: string): number | null; + getIndexedParameter(target: number, index: number): unknown; + getInternalformatParameter(target: number, internalformat: number, pname: number): unknown; + getQueryParameter(query: WebGLQuery, pname: number): unknown; + getParameter(pname: number): unknown; + getQuery(target: number, pname: number): unknown; + getSamplerParameter(sampler: WebGLSampler, pname: number): unknown; + getSyncParameter(sync: WebGLSync, pname: number): unknown; + getTransformFeedbackVarying(program: WebGLProgram, index: number): WebGLActiveInfo | null; + getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number; + getUniformIndices(program: WebGLProgram, uniformNames: Array): Array; + invalidateFramebuffer(target: number, attachments: Array): void; + invalidateSubFramebuffer(target: number, attachments: Array, x: number, y: number, width: number, height: number): void; + isQuery(query: WebGLQuery): boolean; + isSampler(sampler: WebGLSampler): boolean; + isSync(sync: WebGLSync): boolean; + isTransformFeedback(transformFeedback: WebGLTransformFeedback): boolean; + isVertexArray(vertexArray: WebGLVertexArrayObject): boolean; + pauseTransformFeedback(): void; + readBuffer(src: number): void; + renderbufferStorageMultisample(target: number, samples: number, internalFormat: number, width: number, height: number): void; + resumeTransformFeedback(): void; + samplerParameterf(sampler: WebGLSampler, pname: number, param: number): void; + samplerParameteri(sampler: WebGLSampler, pname: number, param: number): void; + texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, offsetOrSourceOrSrcData: number | Buffer | CanvasRenderingContext2D | WebGLRenderingContext | WebGL2RenderingContext, srcOffset?: number | undefined | null): void; + texStorage2D(target: number, levels: number, internalformat: number, width: number, height: number): void; + texStorage3D(target: number, levels: number, internalformat: number, width: number, height: number, depth: number): void; + texSubImage3D(target: number, level: number, xoffset: number, yoffset: number, zoffset: number, width: number, height: number, depth: number, format: number, type: number, srcData: number | Buffer | CanvasRenderingContext2D | WebGLRenderingContext | WebGL2RenderingContext, srcOffset?: number | undefined | null): void; + transformFeedbackVaryings(program: WebGLProgram, varyings: Array, bufferMode: number): void; + uniform1ui(location: WebGLUniformLocation, v0: number): void; + uniform1uiv(location: WebGLUniformLocation, data: Array | Uint32Array): void; + uniform2ui(location: WebGLUniformLocation, v0: number, v1: number): void; + uniform2uiv(location: WebGLUniformLocation, data: Array | Uint32Array): void; + uniform3ui(location: WebGLUniformLocation, v0: number, v1: number, v2: number): void; + uniform3uiv(location: WebGLUniformLocation, data: Array | Uint32Array): void; + uniform4ui(location: WebGLUniformLocation, v0: number, v1: number, v2: number, v3: number): void; + uniform4uiv(location: WebGLUniformLocation, data: Array | Uint32Array): void; + uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void; + uniformMatrix2x3fv(location: WebGLUniformLocation, transpose: boolean, data: Float32Array): void; + uniformMatrix2x4fv(location: WebGLUniformLocation, transpose: boolean, data: Float32Array): void; + uniformMatrix3x2fv(location: WebGLUniformLocation, transpose: boolean, data: Float32Array): void; + uniformMatrix3x4fv(location: WebGLUniformLocation, transpose: boolean, data: Float32Array): void; + uniformMatrix4x2fv(location: WebGLUniformLocation, transpose: boolean, data: Float32Array): void; + uniformMatrix4x3fv(location: WebGLUniformLocation, transpose: boolean, data: Float32Array): void; + vertexAttribDivisor(index: number, divisor: number): void; + vertexAttribI4i(index: number, v0: number, v1: number, v2: number, v3: number): void; + vertexAttribI4ui(index: number, v0: number, v1: number, v2: number, v3: number): void; + vertexAttribI4iv(index: number, value: Array | Int32Array): void; + vertexAttribI4uiv(index: number, value: Array | Uint32Array): void; + get DEPTH_BUFFER_BIT(): number; + get STENCIL_BUFFER_BIT(): number; + get COLOR_BUFFER_BIT(): number; + get POINTS(): number; + get LINES(): number; + get LINE_LOOP(): number; + get LINE_STRIP(): number; + get TRIANGLES(): number; + get TRIANGLE_STRIP(): number; + get TRIANGLE_FAN(): number; + get ZERO(): number; + get ONE(): number; + get SRC_COLOR(): number; + get ONE_MINUS_SRC_COLOR(): number; + get SRC_ALPHA(): number; + get ONE_MINUS_SRC_ALPHA(): number; + get DST_ALPHA(): number; + get ONE_MINUS_DST_ALPHA(): number; + get DST_COLOR(): number; + get ONE_MINUS_DST_COLOR(): number; + get SRC_ALPHA_SATURATE(): number; + get CONSTANT_COLOR(): number; + get ONE_MINUS_CONSTANT_COLOR(): number; + get CONSTANT_ALPHA(): number; + get ONE_MINUS_CONSTANT_ALPHA(): number; + get FUNC_ADD(): number; + get FUNC_SUBTRACT(): number; + get FUNC_REVERSE_SUBTRACT(): number; + get BLEND_EQUATION(): number; + get BLEND_EQUATION_RGB(): number; + get BLEND_EQUATION_ALPHA(): number; + get BLEND_DST_RGB(): number; + get BLEND_SRC_RGB(): number; + get BLEND_DST_ALPHA(): number; + get BLEND_SRC_ALPHA(): number; + get BLEND_COLOR(): number; + get ARRAY_BUFFER_BINDING(): number; + get ELEMENT_ARRAY_BUFFER_BINDING(): number; + get LINE_WIDTH(): number; + get ALIASED_POINT_SIZE_RANGE(): number; + get ALIASED_LINE_WIDTH_RANGE(): number; + get CULL_FACE_MODE(): number; + get FRONT_FACE(): number; + get DEPTH_RANGE(): number; + get DEPTH_WRITEMASK(): number; + get DEPTH_CLEAR_VALUE(): number; + get DEPTH_FUNC(): number; + get STENCIL_CLEAR_VALUE(): number; + get STENCIL_FUNC(): number; + get STENCIL_FAIL(): number; + get STENCIL_PASS_DEPTH_FAIL(): number; + get STENCIL_PASS_DEPTH_PASS(): number; + get STENCIL_REF(): number; + get STENCIL_VALUE_MASK(): number; + get STENCIL_WRITEMASK(): number; + get STENCIL_BACK_FUNC(): number; + get STENCIL_BACK_FAIL(): number; + get STENCIL_BACK_PASS_DEPTH_FAIL(): number; + get STENCIL_BACK_PASS_DEPTH_PASS(): number; + get STENCIL_BACK_REF(): number; + get STENCIL_BACK_VALUE_MASK(): number; + get STENCIL_BACK_WRITEMASK(): number; + get VIEWPORT(): number; + get SCISSOR_BOX(): number; + get COLOR_CLEAR_VALUE(): number; + get COLOR_WRITEMASK(): number; + get UNPACK_ALIGNMENT(): number; + get PACK_ALIGNMENT(): number; + get MAX_TEXTURE_SIZE(): number; + get MAX_VIEWPORT_DIMS(): number; + get SUBPIXEL_BITS(): number; + get RED_BITS(): number; + get GREEN_BITS(): number; + get BLUE_BITS(): number; + get ALPHA_BITS(): number; + get DEPTH_BITS(): number; + get STENCIL_BITS(): number; + get POLYGON_OFFSET_UNITS(): number; + get POLYGON_OFFSET_FACTOR(): number; + get TEXTURE_BINDING_2D(): number; + get SAMPLE_BUFFERS(): number; + get SAMPLES(): number; + get SAMPLE_COVERAGE_VALUE(): number; + get SAMPLE_COVERAGE_INVERT(): number; + get COMPRESSED_TEXTURE_FORMATS(): number; + get VENDOR(): number; + get RENDERER(): number; + get VERSION(): number; + get IMPLEMENTATION_COLOR_READ_TYPE(): number; + get IMPLEMENTATION_COLOR_READ_FORMAT(): number; + get BROWSER_DEFAULT_WEBGL(): number; + get STATIC_DRAW(): number; + get STREAM_DRAW(): number; + get DYNAMIC_DRAW(): number; + get ARRAY_BUFFER(): number; + get ELEMENT_ARRAY_BUFFER(): number; + get BUFFER_SIZE(): number; + get BUFFER_USAGE(): number; + get CURRENT_VERTEX_ATTRIB(): number; + get VERTEX_ATTRIB_ARRAY_ENABLED(): number; + get VERTEX_ATTRIB_ARRAY_SIZE(): number; + get VERTEX_ATTRIB_ARRAY_STRIDE(): number; + get VERTEX_ATTRIB_ARRAY_TYPE(): number; + get VERTEX_ATTRIB_ARRAY_NORMALIZED(): number; + get VERTEX_ATTRIB_ARRAY_POINTER(): number; + get VERTEX_ATTRIB_ARRAY_BUFFER_BINDING(): number; + get CULL_FACE(): number; + get FRONT(): number; + get BACK(): number; + get FRONT_AND_BACK(): number; + get BLEND(): number; + get DEPTH_TEST(): number; + get DITHER(): number; + get POLYGON_OFFSET_FILL(): number; + get SAMPLE_ALPHA_TO_COVERAGE(): number; + get SAMPLE_COVERAGE(): number; + get SCISSOR_TEST(): number; + get STENCIL_TEST(): number; + get NO_ERROR(): number; + get INVALID_ENUM(): number; + get INVALID_VALUE(): number; + get INVALID_OPERATION(): number; + get OUT_OF_MEMORY(): number; + get CONTEXT_LOST_WEBGL(): number; + get CW(): number; + get CCW(): number; + get DONT_CARE(): number; + get FASTEST(): number; + get NICEST(): number; + get GENERATE_MIPMAP_HINT(): number; + get BYTE(): number; + get UNSIGNED_BYTE(): number; + get SHORT(): number; + get UNSIGNED_SHORT(): number; + get INT(): number; + get UNSIGNED_INT(): number; + get FLOAT(): number; + get DEPTH_COMPONENT(): number; + get ALPHA(): number; + get RGB(): number; + get RGBA(): number; + get LUMINANCE(): number; + get LUMINANCE_ALPHA(): number; + get UNSIGNED_SHORT_4_4_4_4(): number; + get UNSIGNED_SHORT_5_5_5_1(): number; + get UNSIGNED_SHORT_5_6_5(): number; + get FRAGMENT_SHADER(): number; + get VERTEX_SHADER(): number; + get COMPILE_STATUS(): number; + get DELETE_STATUS(): number; + get LINK_STATUS(): number; + get VALIDATE_STATUS(): number; + get ATTACHED_SHADERS(): number; + get ACTIVE_ATTRIBUTES(): number; + get ACTIVE_UNIFORMS(): number; + get MAX_VERTEX_ATTRIBS(): number; + get MAX_VERTEX_UNIFORM_VECTORS(): number; + get MAX_VARYING_VECTORS(): number; + get MAX_COMBINED_TEXTURE_IMAGE_UNITS(): number; + get MAX_VERTEX_TEXTURE_IMAGE_UNITS(): number; + get MAX_TEXTURE_IMAGE_UNITS(): number; + get MAX_FRAGMENT_UNIFORM_VECTORS(): number; + get SHADER_TYPE(): number; + get SHADING_LANGUAGE_VERSION(): number; + get CURRENT_PROGRAM(): number; + get NEVER(): number; + get LESS(): number; + get EQUAL(): number; + get LEQUAL(): number; + get GREATER(): number; + get NOTEQUAL(): number; + get GEQUAL(): number; + get ALWAYS(): number; + get KEEP(): number; + get REPLACE(): number; + get INCR(): number; + get DECR(): number; + get INVERT(): number; + get INCR_WRAP(): number; + get DECR_WRAP(): number; + get NEAREST(): number; + get LINEAR(): number; + get NEAREST_MIPMAP_NEAREST(): number; + get LINEAR_MIPMAP_NEAREST(): number; + get NEAREST_MIPMAP_LINEAR(): number; + get LINEAR_MIPMAP_LINEAR(): number; + get TEXTURE_MAG_FILTER(): number; + get TEXTURE_MIN_FILTER(): number; + get TEXTURE_WRAP_S(): number; + get TEXTURE_WRAP_T(): number; + get TEXTURE_2D(): number; + get TEXTURE(): number; + get TEXTURE_CUBE_MAP(): number; + get TEXTURE_BINDING_CUBE_MAP(): number; + get TEXTURE_CUBE_MAP_POSITIVE_X(): number; + get TEXTURE_CUBE_MAP_NEGATIVE_X(): number; + get TEXTURE_CUBE_MAP_POSITIVE_Y(): number; + get TEXTURE_CUBE_MAP_NEGATIVE_Y(): number; + get TEXTURE_CUBE_MAP_POSITIVE_Z(): number; + get TEXTURE_CUBE_MAP_NEGATIVE_Z(): number; + get MAX_CUBE_MAP_TEXTURE_SIZE(): number; + get TEXTURE0(): number; + get TEXTURE1(): number; + get TEXTURE2(): number; + get TEXTURE3(): number; + get TEXTURE4(): number; + get TEXTURE5(): number; + get TEXTURE6(): number; + get TEXTURE7(): number; + get TEXTURE8(): number; + get TEXTURE9(): number; + get TEXTURE10(): number; + get TEXTURE11(): number; + get TEXTURE12(): number; + get TEXTURE13(): number; + get TEXTURE14(): number; + get TEXTURE15(): number; + get TEXTURE16(): number; + get TEXTURE17(): number; + get TEXTURE18(): number; + get TEXTURE19(): number; + get TEXTURE20(): number; + get TEXTURE21(): number; + get TEXTURE22(): number; + get TEXTURE23(): number; + get TEXTURE24(): number; + get TEXTURE25(): number; + get TEXTURE26(): number; + get TEXTURE27(): number; + get TEXTURE28(): number; + get TEXTURE29(): number; + get TEXTURE30(): number; + get TEXTURE31(): number; + get ACTIVE_TEXTURE(): number; + get REPEAT(): number; + get CLAMP_TO_EDGE(): number; + get MIRRORED_REPEAT(): number; + get FLOAT_VEC2(): number; + get FLOAT_VEC3(): number; + get FLOAT_VEC4(): number; + get INT_VEC2(): number; + get INT_VEC3(): number; + get INT_VEC4(): number; + get BOOL(): number; + get BOOL_VEC2(): number; + get BOOL_VEC3(): number; + get BOOL_VEC4(): number; + get FLOAT_MAT2(): number; + get FLOAT_MAT3(): number; + get FLOAT_MAT4(): number; + get SAMPLER_2D(): number; + get SAMPLER_CUBE(): number; + get LOW_FLOAT(): number; + get MEDIUM_FLOAT(): number; + get HIGH_FLOAT(): number; + get LOW_INT(): number; + get MEDIUM_INT(): number; + get HIGH_INT(): number; + get FRAMEBUFFER(): number; + get RENDERBUFFER(): number; + get RGBA4(): number; + get RGB5_A1(): number; + get RGB565(): number; + get DEPTH_COMPONENT16(): number; + get STENCIL_INDEX8(): number; + get DEPTH_STENCIL(): number; + get RENDERBUFFER_WIDTH(): number; + get RENDERBUFFER_HEIGHT(): number; + get RENDERBUFFER_INTERNAL_FORMAT(): number; + get RENDERBUFFER_RED_SIZE(): number; + get RENDERBUFFER_GREEN_SIZE(): number; + get RENDERBUFFER_BLUE_SIZE(): number; + get RENDERBUFFER_ALPHA_SIZE(): number; + get RENDERBUFFER_DEPTH_SIZE(): number; + get RENDERBUFFER_STENCIL_SIZE(): number; + get FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE(): number; + get FRAMEBUFFER_ATTACHMENT_OBJECT_NAME(): number; + get FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL(): number; + get FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE(): number; + get COLOR_ATTACHMENT0(): number; + get DEPTH_ATTACHMENT(): number; + get STENCIL_ATTACHMENT(): number; + get DEPTH_STENCIL_ATTACHMENT(): number; + get NONE(): number; + get FRAMEBUFFER_COMPLETE(): number; + get FRAMEBUFFER_INCOMPLETE_ATTACHMENT(): number; + get FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT(): number; + get FRAMEBUFFER_INCOMPLETE_DIMENSIONS(): number; + get FRAMEBUFFER_UNSUPPORTED(): number; + get FRAMEBUFFER_BINDING(): number; + get RENDERBUFFER_BINDING(): number; + get MAX_RENDERBUFFER_SIZE(): number; + get INVALID_FRAMEBUFFER_OPERATION(): number; + get UNPACK_FLIP_Y_WEBGL(): number; + get UNPACK_PREMULTIPLY_ALPHA_WEBGL(): number; + get UNPACK_COLORSPACE_CONVERSION_WEBGL(): number; + get READ_BUFFER(): number; + get UNPACK_ROW_LENGTH(): number; + get UNPACK_SKIP_ROWS(): number; + get UNPACK_SKIP_PIXELS(): number; + get PACK_ROW_LENGTH(): number; + get PACK_SKIP_ROWS(): number; + get PACK_SKIP_PIXELS(): number; + get TEXTURE_BINDING_3D(): number; + get UNPACK_SKIP_IMAGES(): number; + get UNPACK_IMAGE_HEIGHT(): number; + get MAX_3D_TEXTURE_SIZE(): number; + get MAX_ELEMENTS_VERTICES(): number; + get MAX_ELEMENTS_INDICES(): number; + get MAX_TEXTURE_LOD_BIAS(): number; + get MAX_FRAGMENT_UNIFORM_COMPONENTS(): number; + get MAX_VERTEX_UNIFORM_COMPONENTS(): number; + get MAX_ARRAY_TEXTURE_LAYERS(): number; + get MIN_PROGRAM_TEXEL_OFFSET(): number; + get MAX_PROGRAM_TEXEL_OFFSET(): number; + get MAX_VARYING_COMPONENTS(): number; + get FRAGMENT_SHADER_DERIVATIVE_HINT(): number; + get RASTERIZER_DISCARD(): number; + get VERTEX_ARRAY_BINDING(): number; + get MAX_VERTEX_OUTPUT_COMPONENTS(): number; + get MAX_FRAGMENT_INPUT_COMPONENTS(): number; + get MAX_SERVER_WAIT_TIMEOUT(): number; + get MAX_ELEMENT_INDEX(): number; + get RED(): number; + get RGB8(): number; + get RGBA8(): number; + get RGB10_A2(): number; + get TEXTURE_3D(): number; + get TEXTURE_WRAP_R(): number; + get TEXTURE_MIN_LOD(): number; + get TEXTURE_MAX_LOD(): number; + get TEXTURE_BASE_LEVEL(): number; + get TEXTURE_MAX_LEVEL(): number; + get TEXTURE_COMPARE_MODE(): number; + get TEXTURE_COMPARE_FUNC(): number; + get SRGB(): number; + get SRGB8(): number; + get SRGB8_ALPHA8(): number; + get COMPARE_REF_TO_TEXTURE(): number; + get RGBA32F(): number; + get RGB32F(): number; + get RGBA16F(): number; + get RGB16F(): number; + get TEXTURE_2D_ARRAY(): number; + get TEXTURE_BINDING_2D_ARRAY(): number; + get R11F_G11F_B10F(): number; + get RGB9_E5(): number; + get RGBA32UI(): number; + get RGB32UI(): number; + get RGBA16UI(): number; + get RGB16UI(): number; + get RGBA8UI(): number; + get RGB8UI(): number; + get RGBA32I(): number; + get RGB32I(): number; + get RGBA16I(): number; + get RGB16I(): number; + get RGBA8I(): number; + get RGB8I(): number; + get RED_INTEGER(): number; + get RGB_INTEGER(): number; + get RGBA_INTEGER(): number; + get R8(): number; + get RG8(): number; + get R16F(): number; + get R32F(): number; + get RG16F(): number; + get RG32F(): number; + get R8I(): number; + get R8UI(): number; + get R16I(): number; + get R16UI(): number; + get R32I(): number; + get R32UI(): number; + get RG8I(): number; + get RG8UI(): number; + get RG16I(): number; + get RG16UI(): number; + get RG32I(): number; + get RG32UI(): number; + get R8_SNORM(): number; + get RG8_SNORM(): number; + get RGB8_SNORM(): number; + get RGBA8_SNORM(): number; + get RGB10_A2UI(): number; + get TEXTURE_IMMUTABLE_FORMAT(): number; + get TEXTURE_IMMUTABLE_LEVELS(): number; + get UNSIGNED_INT_2_10_10_10_REV(): number; + get UNSIGNED_INT_10F_11F_11F_REV(): number; + get UNSIGNED_INT_5_9_9_9_REV(): number; + get FLOAT_32_UNSIGNED_INT_24_8_REV(): number; + get UNSIGNED_INT_24_8(): number; + get HALF_FLOAT(): number; + get RG(): number; + get RG_INTEGER(): number; + get INT_2_10_10_10_REV(): number; + get QUERY_RESULT_AVAILABLE(): number; + get QUERY_RESULT(): number; + get CURRENT_QUERY(): number; + get ANY_SAMPLES_PASSED(): number; + get ANY_SAMPLES_PASSED_CONSERVATIVE(): number; + get MAX_DRAW_BUFFERS(): number; + get DRAW_BUFFER0(): number; + get DRAW_BUFFER1(): number; + get DRAW_BUFFER2(): number; + get DRAW_BUFFER3(): number; + get DRAW_BUFFER4(): number; + get DRAW_BUFFER5(): number; + get DRAW_BUFFER6(): number; + get DRAW_BUFFER7(): number; + get DRAW_BUFFER8(): number; + get DRAW_BUFFER9(): number; + get DRAW_BUFFER10(): number; + get DRAW_BUFFER11(): number; + get DRAW_BUFFER12(): number; + get DRAW_BUFFER13(): number; + get DRAW_BUFFER14(): number; + get DRAW_BUFFER15(): number; + get MAX_COLOR_ATTACHMENTS(): number; + get COLOR_ATTACHMENT1(): number; + get COLOR_ATTACHMENT2(): number; + get COLOR_ATTACHMENT3(): number; + get COLOR_ATTACHMENT4(): number; + get COLOR_ATTACHMENT5(): number; + get COLOR_ATTACHMENT6(): number; + get COLOR_ATTACHMENT7(): number; + get COLOR_ATTACHMENT8(): number; + get COLOR_ATTACHMENT9(): number; + get COLOR_ATTACHMENT10(): number; + get COLOR_ATTACHMENT11(): number; + get COLOR_ATTACHMENT12(): number; + get COLOR_ATTACHMENT13(): number; + get COLOR_ATTACHMENT14(): number; + get COLOR_ATTACHMENT15(): number; + get SAMPLER_3D(): number; + get SAMPLER_2D_SHADOW(): number; + get SAMPLER_2D_ARRAY(): number; + get SAMPLER_2D_ARRAY_SHADOW(): number; + get SAMPLER_CUBE_SHADOW(): number; + get INT_SAMPLER_2D(): number; + get INT_SAMPLER_3D(): number; + get INT_SAMPLER_CUBE(): number; + get INT_SAMPLER_2D_ARRAY(): number; + get UNSIGNED_INT_SAMPLER_2D(): number; + get UNSIGNED_INT_SAMPLER_3D(): number; + get UNSIGNED_INT_SAMPLER_CUBE(): number; + get UNSIGNED_INT_SAMPLER_2D_ARRAY(): number; + get MAX_SAMPLES(): number; + get SAMPLER_BINDING(): number; + get PIXEL_PACK_BUFFER(): number; + get PIXEL_UNPACK_BUFFER(): number; + get PIXEL_PACK_BUFFER_BINDING(): number; + get PIXEL_UNPACK_BUFFER_BINDING(): number; + get COPY_READ_BUFFER(): number; + get COPY_WRITE_BUFFER(): number; + get COPY_READ_BUFFER_BINDING(): number; + get COPY_WRITE_BUFFER_BINDING(): number; + get FLOAT_MAT2x3(): number; + get FLOAT_MAT2x4(): number; + get FLOAT_MAT3x2(): number; + get FLOAT_MAT3x4(): number; + get FLOAT_MAT4x2(): number; + get FLOAT_MAT4x3(): number; + get UNSIGNED_INT_VEC2(): number; + get UNSIGNED_INT_VEC3(): number; + get UNSIGNED_INT_VEC4(): number; + get UNSIGNED_NORMALIZED(): number; + get SIGNED_NORMALIZED(): number; + get VERTEX_ATTRIB_ARRAY_INTEGER(): number; + get VERTEX_ATTRIB_ARRAY_DIVISOR(): number; + get TRANSFORM_FEEDBACK_BUFFER_MODE(): number; + get MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS(): number; + get TRANSFORM_FEEDBACK_VARYINGS(): number; + get TRANSFORM_FEEDBACK_BUFFER_START(): number; + get TRANSFORM_FEEDBACK_BUFFER_SIZE(): number; + get TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN(): number; + get MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS(): number; + get MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS(): number; + get INTERLEAVED_ATTRIBS(): number; + get SEPARATE_ATTRIBS(): number; + get TRANSFORM_FEEDBACK_BUFFER(): number; + get TRANSFORM_FEEDBACK_BUFFER_BINDING(): number; + get TRANSFORM_FEEDBACK(): number; + get TRANSFORM_FEEDBACK_PAUSED(): number; + get TRANSFORM_FEEDBACK_ACTIVE(): number; + get TRANSFORM_FEEDBACK_BINDING(): number; + get FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING(): number; + get FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE(): number; + get FRAMEBUFFER_ATTACHMENT_RED_SIZE(): number; + get FRAMEBUFFER_ATTACHMENT_GREEN_SIZE(): number; + get FRAMEBUFFER_ATTACHMENT_BLUE_SIZE(): number; + get FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE(): number; + get FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE(): number; + get FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE(): number; + get FRAMEBUFFER_DEFAULT(): number; + get DEPTH24_STENCIL8(): number; + get DRAW_FRAMEBUFFER_BINDING(): number; + get READ_FRAMEBUFFER(): number; + get DRAW_FRAMEBUFFER(): number; + get READ_FRAMEBUFFER_BINDING(): number; + get RENDERBUFFER_SAMPLES(): number; + get FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER(): number; + get FRAMEBUFFER_INCOMPLETE_MULTISAMPLE(): number; + get UNIFORM_BUFFER(): number; + get UNIFORM_BUFFER_BINDING(): number; + get UNIFORM_BUFFER_START(): number; + get UNIFORM_BUFFER_SIZE(): number; + get MAX_VERTEX_UNIFORM_BLOCKS(): number; + get MAX_FRAGMENT_UNIFORM_BLOCKS(): number; + get MAX_COMBINED_UNIFORM_BLOCKS(): number; + get MAX_UNIFORM_BUFFER_BINDINGS(): number; + get MAX_UNIFORM_BLOCK_SIZE(): number; + get MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS(): number; + get MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS(): number; + get UNIFORM_BUFFER_OFFSET_ALIGNMENT(): number; + get ACTIVE_UNIFORM_BLOCKS(): number; + get UNIFORM_TYPE(): number; + get UNIFORM_SIZE(): number; + get UNIFORM_BLOCK_INDEX(): number; + get UNIFORM_OFFSET(): number; + get UNIFORM_ARRAY_STRIDE(): number; + get UNIFORM_MATRIX_STRIDE(): number; + get UNIFORM_IS_ROW_MAJOR(): number; + get UNIFORM_BLOCK_BINDING(): number; + get UNIFORM_BLOCK_DATA_SIZE(): number; + get UNIFORM_BLOCK_ACTIVE_UNIFORMS(): number; + get UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES(): number; + get UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER(): number; + get UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER(): number; + get OBJECT_TYPE(): number; + get SYNC_CONDITION(): number; + get SYNC_STATUS(): number; + get SYNC_FLAGS(): number; + get SYNC_FENCE(): number; + get SYNC_GPU_COMMANDS_COMPLETE(): number; + get UNSIGNALED(): number; + get SIGNALED(): number; + get ALREADY_SIGNALED(): number; + get TIMEOUT_EXPIRED(): number; + get CONDITION_SATISFIED(): number; + get WAIT_FAILED(): number; + get SYNC_FLUSH_COMMANDS_BIT(): number; + get COLOR(): number; + get DEPTH(): number; + get STENCIL(): number; + get MIN(): number; + get MAX(): number; + get DEPTH_COMPONENT24(): number; + get STREAM_READ(): number; + get STREAM_COPY(): number; + get STATIC_READ(): number; + get STATIC_COPY(): number; + get DYNAMIC_READ(): number; + get DYNAMIC_COPY(): number; + get DEPTH_COMPONENT32F(): number; + get DEPTH32F_STENCIL8(): number; + get INVALID_INDEX(): number; + get TIMEOUT_IGNORED(): number; + get MAX_CLIENT_WAIT_TIMEOUT_WEBGL(): number; +} +export declare class ImageBitmap { + get width(): number; + get height(): number; + close(): void; +} diff --git a/napi/canvas-napi/js-binding.js b/napi/canvas-napi/js-bindings.js similarity index 61% rename from napi/canvas-napi/js-binding.js rename to napi/canvas-napi/js-bindings.js index 7ffb62e1..19dfc8f0 100644 --- a/napi/canvas-napi/js-binding.js +++ b/napi/canvas-napi/js-bindings.js @@ -4,8 +4,20 @@ /* auto-generated by NAPI-RS */ -const { existsSync, readFileSync } = require('fs') -const { join } = require('path'); +import { createRequire } from 'module'; + +const require = createRequire(import.meta.url); + +const { existsSync, readFileSync } = require('fs'); +const { join, dirname } = require('path'); + +const { fileURLToPath } = require('url'); + +// Get the current file path +const __filename = fileURLToPath(import.meta.url); + +// Get the directory name +const __dirname = dirname(__filename); const { platform, arch } = process; @@ -284,7 +296,7 @@ if (!nativeBinding) { throw new Error(`Failed to load native binding`); } -const { +export const { GPUAdapter, GPUAdapterInfo, GPUBindGroup, @@ -299,8 +311,8 @@ const { GPUMipmapFilterMode, GPUFilterMode, GPUAddressMode, - GPUBufferUsage, - GPUTextureUsage, + GPUBufferUsage: GPUBufferUsage, + GPUTextureUsage: GPUTextureUsage, GPUErrorFilter, GPUTextureSampleType, GPUTextureViewDimension, @@ -401,119 +413,3 @@ const { createImageBitmap, ImageBitmap, } = nativeBinding; - -module.exports.GPUAdapter = GPUAdapter; -module.exports.GPUAdapterInfo = GPUAdapterInfo; -module.exports.GPUBindGroup = GPUBindGroup; -module.exports.GPUBindGroupLayout = GPUBindGroupLayout; -module.exports.GPUCommandBuffer = GPUCommandBuffer; -module.exports.GPUCommandEncoder = GPUCommandEncoder; -module.exports.GPUCanvasContext = GPUCanvasContext; -module.exports.GPUDevice = GPUDevice; -module.exports.GPUFeatureName = GPUFeatureName; -module.exports.GPUShaderStage = GPUShaderStage; -module.exports.GPUQueryType = GPUQueryType; -module.exports.GPUMipmapFilterMode = GPUMipmapFilterMode; -module.exports.GPUFilterMode = GPUFilterMode; -module.exports.GPUAddressMode = GPUAddressMode; -module.exports.GPUBufferUsage = GPUBufferUsage; -module.exports.GPUTextureUsage = GPUTextureUsage; -module.exports.GPUErrorFilter = GPUErrorFilter; -module.exports.GPUTextureSampleType = GPUTextureSampleType; -module.exports.GPUTextureViewDimension = GPUTextureViewDimension; -module.exports.GPUStorageTextureAccess = GPUStorageTextureAccess; -module.exports.GPUSamplerBindingType = GPUSamplerBindingType; -module.exports.GPUBufferBindingType = GPUBufferBindingType; -module.exports.GPUTextureDimension = GPUTextureDimension; -module.exports.GPUTextureAspect = GPUTextureAspect; -module.exports.GPUMapMode = GPUMapMode; -module.exports.GPULoadOp = GPULoadOp; -module.exports.GPUStoreOp = GPUStoreOp; -module.exports.GPUVertexFormat = GPUVertexFormat; -module.exports.GPUVertexStepMode = GPUVertexStepMode; -module.exports.GPUPrimitiveTopology = GPUPrimitiveTopology; -module.exports.GPUIndexFormat = GPUIndexFormat; -module.exports.GPUFrontFace = GPUFrontFace; -module.exports.GPUCullMode = GPUCullMode; -module.exports.GPUBlendOperation = GPUBlendOperation; -module.exports.GPUBlendFactor = GPUBlendFactor; -module.exports.GPUPipelineLayoutAuto = GPUPipelineLayoutAuto; -module.exports.GPUStencilOperation = GPUStencilOperation; -module.exports.GPUCompareFunction = GPUCompareFunction; -module.exports.PredefinedColorSpaceEnum = PredefinedColorSpaceEnum; -module.exports.GPUCanvasAlphaMode = GPUCanvasAlphaMode; -module.exports.GPUCanvasPresentMode = GPUCanvasPresentMode; -module.exports.GPUTextureFormat = GPUTextureFormat; -module.exports.GPUPipelineLayout = GPUPipelineLayout; -module.exports.GPUQuerySet = GPUQuerySet; -module.exports.GPUQueue = GPUQueue; -module.exports.GPURenderPassEncoder = GPURenderPassEncoder; -module.exports.GPURenderPipeline = GPURenderPipeline; -module.exports.GPUShaderModule = GPUShaderModule; -module.exports.GPUTexture = GPUTexture; -module.exports.GPUTextureView = GPUTextureView; -module.exports.GPUMapState = GPUMapState; -module.exports.GPUBuffer = GPUBuffer; -module.exports.GPUComputePassEncoder = GPUComputePassEncoder; -module.exports.GPUComputePipeline = GPUComputePipeline; -module.exports.GPUExternalTexture = GPUExternalTexture; -module.exports.GPURenderBundle = GPURenderBundle; -module.exports.GPURenderBundleEncoder = GPURenderBundleEncoder; -module.exports.GPUSampler = GPUSampler; -module.exports.GPU = GPU; -module.exports.Path2D = Path2D; -module.exports.CanvasPattern = CanvasPattern; -module.exports.CanvasGradient = CanvasGradient; -module.exports.ImageData = ImageData; -module.exports.TextMetrics = TextMetrics; -module.exports.CanvasRenderingContext2D = CanvasRenderingContext2D; -module.exports.ImageAsset = ImageAsset; -module.exports.DomMatrix = DomMatrix; -module.exports.TextEncoder = TextEncoder; -module.exports.TextDecoder = TextDecoder; -module.exports.ANGLE_instanced_arrays = ANGLE_instanced_arrays; -module.exports.OES_fbo_render_mipmap = OES_fbo_render_mipmap; -module.exports.EXT_blend_minmax = EXT_blend_minmax; -module.exports.EXT_color_buffer_half_float = EXT_color_buffer_half_float; -module.exports.EXT_disjoint_timer_query = EXT_disjoint_timer_query; -module.exports.EXT_sRGB = EXT_sRGB; -module.exports.EXT_shader_texture_lod = EXT_shader_texture_lod; -module.exports.EXT_texture_filter_anisotropic = EXT_texture_filter_anisotropic; -module.exports.OES_element_index_uint = OES_element_index_uint; -module.exports.OES_standard_derivatives = OES_standard_derivatives; -module.exports.OES_texture_float = OES_texture_float; -module.exports.OES_texture_float_linear = OES_texture_float_linear; -module.exports.OES_texture_half_float = OES_texture_half_float; -module.exports.OES_texture_half_float_linear = OES_texture_half_float_linear; -module.exports.OES_vertex_array_object = OES_vertex_array_object; -module.exports.WEBGL_color_buffer_float = WEBGL_color_buffer_float; -module.exports.WEBGL_compressed_texture_atc = WEBGL_compressed_texture_atc; -module.exports.WEBGL_compressed_texture_etc = WEBGL_compressed_texture_etc; -module.exports.WEBGL_compressed_texture_etc1 = WEBGL_compressed_texture_etc1; -module.exports.WEBGL_compressed_texture_pvrtc = WEBGL_compressed_texture_pvrtc; -module.exports.WEBGL_compressed_texture_s3tc = WEBGL_compressed_texture_s3tc; -module.exports.WEBGL_lose_context = WEBGL_lose_context; -module.exports.WEBGL_depth_texture = WEBGL_depth_texture; -module.exports.WEBGL_draw_buffers = WEBGL_draw_buffers; -module.exports.WebGLActiveInfo = WebGLActiveInfo; -module.exports.WebGLBuffer = WebGLBuffer; -module.exports.WebGLFramebuffer = WebGLFramebuffer; -module.exports.WebGLProgram = WebGLProgram; -module.exports.WebGLRenderbuffer = WebGLRenderbuffer; -module.exports.WebGLShader = WebGLShader; -module.exports.WebGLShaderPrecisionFormat = WebGLShaderPrecisionFormat; -module.exports.WebGLTexture = WebGLTexture; -module.exports.WebGLUniformLocation = WebGLUniformLocation; -module.exports.WebGLRenderingContext = WebGLRenderingContext; -module.exports.WebGLQuery = WebGLQuery; -module.exports.WebGLSampler = WebGLSampler; -module.exports.WebGLSync = WebGLSync; -module.exports.WebGLTransformFeedback = WebGLTransformFeedback; -module.exports.WebGLVertexArrayObject = WebGLVertexArrayObject; -module.exports.WebGL2RenderingContext = WebGL2RenderingContext; -module.exports.ImageBitmapOptionsImageOrientation = ImageBitmapOptionsImageOrientation; -module.exports.ImageBitmapOptionsPremultiplyAlpha = ImageBitmapOptionsPremultiplyAlpha; -module.exports.ImageBitmapOptionsColorSpaceConversion = ImageBitmapOptionsColorSpaceConversion; -module.exports.ImageBitmapOptionResizeQuality = ImageBitmapOptionResizeQuality; -module.exports.createImageBitmap = createImageBitmap; -module.exports.ImageBitmap = ImageBitmap; diff --git a/napi/canvas-napi/package.json b/napi/canvas-napi/package.json index cf46674f..7fec1b32 100644 --- a/napi/canvas-napi/package.json +++ b/napi/canvas-napi/package.json @@ -1,7 +1,8 @@ { "name": "@nativescript/canvas-napi", - "version": "0.0.2", - "main": "index.js", + "version": "0.0.5", + "main": "index.cjs", + "module": "index.mjs", "types": "index.d.ts", "type": "module", "napi": { @@ -18,14 +19,18 @@ "license": "MIT", "dependencies": { "@nativescript/foundation": "0.0.1-alpha.22", - "@nativescript/macos-node-api": "0.1.3", + "@nativescript/macos-node-api": "0.1.4", "yoga-layout": "3.1.0" }, "devDependencies": { "@napi-rs/cli": "^2.18.4", + "@rollup/plugin-commonjs": "^28.0.2", + "@rollup/plugin-typescript": "^12.1.2", "@tsconfig/node22": "^22.0.0", "@types/node": "^22.9.0", "ava": "^6.0.1", + "rollup": "^4.28.1", + "rollup-plugin-dts": "^6.1.1", "typescript": "^5.6.3" }, "ava": { @@ -36,8 +41,10 @@ }, "scripts": { "artifacts": "napi artifacts", - "build": "napi build --platform --release --js js-binding.js", - "build:debug": "napi build --platform --js js-binding.js", + "build": "napi build --platform --release --js js-bindings.cjs", + "build:debug": "napi build --platform --js js-bindings.cjs", + "build:esm": "napi build --platform --release --js js-bindings.mjs --esm", + "build:esm:debug": "napi build --platform --js js-bindings.mjs --esm", "prepublishOnly": "napi prepublish -t npm", "test": "ava", "universal": "napi universal", @@ -47,7 +54,7 @@ }, "optionalDependencies": { "@nativescript/canvas-napi-darwin-arm64": "0.0.2", - "@nativescript/canvas-napi-darwin-x64": "0.0.2", - "@nativescript/canvas-napi-darwin-universal": "0.0.2" + "@nativescript/canvas-napi-darwin-universal": "0.0.2", + "@nativescript/canvas-napi-darwin-x64": "0.0.2" } } diff --git a/napi/canvas-napi/polyfill.ts b/napi/canvas-napi/polyfill.ts index d5b53ec8..cb3fcd87 100644 --- a/napi/canvas-napi/polyfill.ts +++ b/napi/canvas-napi/polyfill.ts @@ -1,14 +1,8 @@ import '@nativescript/macos-node-api'; -import { createRequire } from 'node:module'; -import utils from './utils/index.js'; -import { Event } from '@nativescript/foundation/dom/dom-utils.js'; +import { requestAnimationFrame, cancelAnimationFrame } from './utils/raf'; +import { Event } from '@nativescript/foundation/dom/dom-utils'; -// @ts-ignore -const require = createRequire(import.meta.url); - -const { GPU, GPUDevice, GPUAdapter, GPUTextureUsage, GPUBufferUsage, CanvasRenderingContext2D, WebGLRenderingContext, createImageBitmap, Path2D } = require('./canvas-napi.darwin-arm64.node'); - -const { requestAnimationFrame, cancelAnimationFrame } = utils; +import { GPU, GPUDevice, GPUAdapter, GPUTextureUsage, GPUBufferUsage, CanvasRenderingContext2D, WebGLRenderingContext, WebGL2RenderingContext, createImageBitmap, Path2D } from './js-bindings.js'; function fixup_shader_code(code: string) { let ret = `${code}`; @@ -44,15 +38,7 @@ export class ProgressEvent extends Event { loaded: number; total: number; - constructor( - type: string, - data: { lengthComputable: boolean; loaded: number; total: number; target: any } = { - lengthComputable: false, - loaded: 0, - total: 0, - target: {}, - } - ) { + constructor(type: string, data: { lengthComputable: boolean; loaded: number; total: number }) { super(type); this.lengthComputable = data.lengthComputable ?? false; this.loaded = data.loaded ?? 0; @@ -60,6 +46,44 @@ export class ProgressEvent extends Event { } } +function install2DPolyfills() { + // @ts-ignore + globalThis.CanvasRenderingContext2D = CanvasRenderingContext2D; + // @ts-ignore + globalThis.Path2D = Path2D; +} + +function installWebGLPolyfills() { + // @ts-ignore + globalThis.WebGLRenderingContext = WebGLRenderingContext; +} + +function installWebGL2Polyfills() { + // @ts-ignore + globalThis.WebGL2RenderingContext = WebGL2RenderingContext; +} + +// @ts-ignore +GPUDevice.prototype.__createShaderModule = GPUDevice.prototype.createShaderModule; + +function installWebGPUPolyfills() { + // @ts-ignore + globalThis.GPUTextureUsage = GPUTextureUsage; + // @ts-ignore + globalThis.GPUBufferUsage = GPUBufferUsage; + // @ts-ignore + globalThis.GPUAdapter = GPUAdapter; + GPUDevice.prototype.createShaderModule = function (descriptor) { + const desc = { + ...descriptor, + code: fixup_shader_code(descriptor.code), + }; + + // @ts-ignore + return this.__createShaderModule(desc); + }; +} + function installPolyfills(window: any) { globalThis.addEventListener = window.addEventListener = () => {}; Object.defineProperty(window, 'devicePixelRatio', { @@ -74,43 +98,28 @@ function installPolyfills(window: any) { }); } - globalThis.window.devicePixelRatio = window.devicePixelRatio = NSScreen.mainScreen.backingScaleFactor; - globalThis.requestAnimationFrame = window.requestAnimationFrame = requestAnimationFrame; - globalThis.cancelAnimationFrame = window.cancelAnimationFrame = cancelAnimationFrame; - - globalThis.self = window; - - //@ts-ignore - globalThis.GPUTextureUsage = GPUTextureUsage; - //@ts-ignore - globalThis.GPUBufferUsage = GPUBufferUsage; //@ts-ignore globalThis.ProgressEvent = ProgressEvent; - globalThis.CanvasRenderingContext2D = CanvasRenderingContext2D; - globalThis.WebGLRenderingContext = WebGLRenderingContext; - globalThis.Path2D = Path2D; - GPUDevice.prototype.__createShaderModule = GPUDevice.prototype.createShaderModule; - GPUDevice.prototype.createShaderModule = function (descriptor: any) { - const desc: { label?: string; code: string; sourceMap?: object; compilationHints?: any[] } = { - ...descriptor, - code: fixup_shader_code(descriptor.code), - }; - - return this.__createShaderModule(desc); - }; - - globalThis.createImageBitmap = function (source, sxOroptions?, sy?, sw?, sh?, options?) { + globalThis.devicePixelRatio = window.devicePixelRatio = NSScreen.mainScreen.backingScaleFactor; + globalThis.requestAnimationFrame = window.requestAnimationFrame = requestAnimationFrame; + globalThis.cancelAnimationFrame = window.cancelAnimationFrame = cancelAnimationFrame; + globalThis.self = window; + // @ts-ignore + globalThis.createImageBitmap = function (source, sxOroptions, sy, sw, sh, options) { if (source instanceof Blob) { return source.arrayBuffer().then((buffer) => { - return createImageBitmap(new Uint8Array(buffer), sxOroptions, sy, sw, sh, options); + return createImageBitmap(new Uint8Array(buffer), sxOroptions, sy, sw, sh, options as never); }); } else { - return createImageBitmap(source, sxOroptions, sy, sw, sh, options); + return createImageBitmap(source as never, sxOroptions, sy, sw, sh, options as never); } }; + + install2DPolyfills(); + installWebGLPolyfills(); + installWebGL2Polyfills(); + installWebGPUPolyfills(); } installPolyfills(globalThis.window); - -export default installPolyfills; diff --git a/napi/canvas-napi/tsconfig.cjs.json b/napi/canvas-napi/tsconfig.cjs.json new file mode 100644 index 00000000..31b2e6e6 --- /dev/null +++ b/napi/canvas-napi/tsconfig.cjs.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "declaration": true, + "module": "CommonJS", + "moduleResolution": "node", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "noEmitHelpers": false, + "noEmitOnError": false, + "allowJs": true, + "importHelpers": true, + "target": "ESNext", + "outDir": "./dist", + "lib": ["ESNext", "dom"], + "noEmit": false, + "skipLibCheck": true, + "skipDefaultLibCheck": true + }, + "extends": "@tsconfig/node22/tsconfig.json", + "include": ["canvas.ts", "polyfill.ts", "utils/raf/*.ts", "utils/*.ts", "references.d.ts"], + "exclude": ["node_modules", "examples"] +} diff --git a/napi/canvas-napi/tsconfig.json b/napi/canvas-napi/tsconfig.json index 59d519ad..34b350cf 100644 --- a/napi/canvas-napi/tsconfig.json +++ b/napi/canvas-napi/tsconfig.json @@ -1,19 +1,22 @@ { "compilerOptions": { - "module": "NodeNext", - "moduleResolution": "nodenext", + "declaration": true, + "module": "ESNext", + "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true, - "noEmitHelpers": true, + "noEmitHelpers": false, "noEmitOnError": false, "allowJs": true, "importHelpers": true, "target": "ESNext", "outDir": "./dist", "lib": ["ESNext", "dom"], - "noEmit": false + "noEmit": false, + "skipLibCheck": true, + "skipDefaultLibCheck": true }, "extends": "@tsconfig/node22/tsconfig.json", - "include": ["canvas.ts", "index.ts", "polyfill.ts", "utils/*.ts", "references.d.ts"], - "exclude": ["node_modules", "examples"] + "include": ["canvas.ts", "polyfill.ts", "utils/raf/*.ts", "utils/*.ts", "references.d.ts"], + "exclude": ["node_modules", "examples", "npm", "dist"] } diff --git a/napi/canvas-napi/utils/index.ts b/napi/canvas-napi/utils/index.ts index 9af67150..615e76e7 100644 --- a/napi/canvas-napi/utils/index.ts +++ b/napi/canvas-napi/utils/index.ts @@ -1,6 +1,2 @@ -import raf from './raf/index.js'; - -export default raf; - -// export * from './mainthread-helper.js'; -// export * from './macrotask-scheduler.js'; +export { queueMacrotask } from './macrotask-scheduler'; +export { dispatchToMainThread, dispatchToUIThread, isMainThread } from './mainthread-helper'; diff --git a/napi/canvas-napi/utils/macrotask-scheduler.ts b/napi/canvas-napi/utils/macrotask-scheduler.ts index f0f7d831..69357d8c 100644 --- a/napi/canvas-napi/utils/macrotask-scheduler.ts +++ b/napi/canvas-napi/utils/macrotask-scheduler.ts @@ -1,4 +1,4 @@ -import { dispatchToMainThread } from './mainthread-helper.js'; +import { dispatchToMainThread } from './mainthread-helper'; let scheduled = false; @@ -17,7 +17,7 @@ function drainMacrotaskQueue() { }); } -export function queueMacrotask(task: () => void): void { +export function queueMacrotask(task: () => void) { macroTaskQueue.push(task); if (!scheduled) { scheduled = true; diff --git a/napi/canvas-napi/utils/mainthread-helper.ts b/napi/canvas-napi/utils/mainthread-helper.ts index 31b59d69..b22ee551 100644 --- a/napi/canvas-napi/utils/mainthread-helper.ts +++ b/napi/canvas-napi/utils/mainthread-helper.ts @@ -1,4 +1,4 @@ -export function dispatchToMainThread(func: () => void): void { +export function dispatchToMainThread(func: () => void) { NSOperationQueue.mainQueue.addOperationWithBlock(func); } @@ -6,7 +6,7 @@ export function isMainThread(): boolean { return NSThread.isMainThread; } -export function dispatchToUIThread(func: () => void): void { +export function dispatchToUIThread(func: () => void) { const runloop = CFRunLoopGetMain(); if (runloop && func) { CFRunLoopPerformBlock(runloop, kCFRunLoopDefaultMode, func); diff --git a/napi/canvas-napi/utils/raf/fps-meter.ts b/napi/canvas-napi/utils/raf/fps-meter.ts index 419d5d70..28823296 100644 --- a/napi/canvas-napi/utils/raf/fps-meter.ts +++ b/napi/canvas-napi/utils/raf/fps-meter.ts @@ -1,6 +1,6 @@ import '@nativescript/macos-node-api'; class FrameHandlerImpl extends NSObject { - _owner?: WeakRef; + _owner: WeakRef | undefined; static { NativeClass(this); @@ -13,10 +13,6 @@ class FrameHandlerImpl extends NSObject { return handler; } - /** - * - * @param {CADisplayLink} sender - */ handleFrame(sender: CADisplayLink) { const owner = this._owner?.deref(); if (owner) { diff --git a/napi/canvas-napi/utils/raf/index.ts b/napi/canvas-napi/utils/raf/index.ts index 8a7ce0f7..68936159 100644 --- a/napi/canvas-napi/utils/raf/index.ts +++ b/napi/canvas-napi/utils/raf/index.ts @@ -1,22 +1,19 @@ -import { queueMacrotask } from '../macrotask-scheduler.js'; -import { FPSCallback } from './fps-meter.js'; +import { queueMacrotask } from '../macrotask-scheduler'; +import { FPSCallback } from './fps-meter'; -/** - * @returns {function(): number} The current time in milliseconds. - */ - -// @ts-ignore -const time = ('global' in globalThis ? global : globalThis).__time || Date.now; +const time: () => number = (('global' in globalThis ? global : globalThis) as any).__time || Date.now; export function getTimeInFrameBase() { return time(); } -export interface FrameRequestCallback { +interface FrameRequestCallback { (time: number): void; } -type AnimationFrameCallbacks = { [key: string]: FrameRequestCallback }; +interface AnimationFrameCallbacks { + [key: number]: FrameRequestCallback; +} let animationId = 0; let currentFrameAnimationCallbacks: AnimationFrameCallbacks = {}; // requests that were scheduled in this frame and must be called ASAP @@ -88,21 +85,21 @@ function ensureCurrentFrameScheduled() { * @param {Function} callback * @returns {Function} */ -const zonedCallback = function (callback: any) { - const global = 'global' in globalThis ? globalThis.global : globalThis; - if ((global as any).zone) { +const zonedCallback = function (callback: T) { + const global: any = 'global' in globalThis ? globalThis.global : globalThis; + if (global.zone) { // Zone v0.5.* style callback wrapping - return (global as any).zone.bind(callback); + return global.zone.bind(callback); } - if ((global as any).Zone) { + if (global.Zone) { // Zone v0.6.* style callback wrapping - return (global as any).Zone.current.wrap(callback); + return global.Zone.current.wrap(callback); } else { return callback; } }; -function requestAnimationFrame(cb: FrameRequestCallback): number { +export function requestAnimationFrame(cb: FrameRequestCallback): number { const animId = getNewId(); if (!inAnimationFrame) { ensureCurrentFrameScheduled(); @@ -117,12 +114,7 @@ function requestAnimationFrame(cb: FrameRequestCallback): number { return animId; } -function cancelAnimationFrame(id: number) { +export function cancelAnimationFrame(id: number) { delete currentFrameAnimationCallbacks[id]; delete nextFrameAnimationCallbacks[id]; } - -export default { - requestAnimationFrame, - cancelAnimationFrame, -};