Skip to content

Commit

Permalink
fix(polyfill): add globals
Browse files Browse the repository at this point in the history
  • Loading branch information
triniwiz committed Oct 15, 2021
1 parent 91ef2f9 commit 603467a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/canvas-polyfill/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/canvas-polyfill",
"version": "1.0.0-beta.0",
"version": "1.0.0-beta.1",
"description": "Polyfill for making NativeScript compatible with web libs like pixi.js, three.js, phaser.js, babylon.js, etc....",
"main": "index",
"typings": "index.d.ts",
Expand Down
4 changes: 3 additions & 1 deletion packages/canvas-polyfill/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { HTMLCanvasElement } from './DOM/HTMLCanvasElement';
import { HTMLVideoElement } from './DOM/HTMLVideoElement';
import { XMLDocument } from './DOM/XMLDocument';
import { Device, fromObject, View } from '@nativescript/core';
import { CanvasRenderingContext2D, WebGLRenderingContext, WebGL2RenderingContext } from '@nativescript/canvas';
import { CanvasRenderingContext2D, WebGLRenderingContext, WebGL2RenderingContext, ImageData } from '@nativescript/canvas';

(global as any).CANVAS_RENDERER = 'true';
(global as any).WEBGL_RENDERER = 'true';
Expand All @@ -26,6 +26,8 @@ import { CanvasRenderingContext2D, WebGLRenderingContext, WebGL2RenderingContext
(global as any).window.WebGLRenderingContext = (global as any).WebGLRenderingContext = (global as any).WebGLRenderingContext || WebGLRenderingContext;
(global as any).window.WebGL2RenderingContext = (global as any).WebGL2RenderingContext = (global as any).WebGL2RenderingContext || WebGL2RenderingContext;

(global as any).window.ImageData = (global as any).ImageData = (global as any).ImageData || ImageData;

function checkEmitter() {
if (!(global as any).emitter || !((global as any).emitter.on || (global as any).emitter.addEventListener || (global as any).emitter.addListener)) {
(global as any).window.emitter = (global as any).emitter = fromObject({});
Expand Down

0 comments on commit 603467a

Please sign in to comment.