Socket
Book a DemoInstallSign in
Socket

nativescript-browser-polyfill

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nativescript-browser-polyfill

Browser polyfill for making NativeScript compatible with web libs like pixi.js, three.js, phaser.js

latest
Source
npmnpm
Version
1.0.0-alpha8
Version published
Maintainers
1
Created
Source

nativescript-browser-polyfill

Browser polyfill for NativeScript

Installation

npm i nativescript-browser-polyfill

Usage

Import the library into your JavaScript file:

import 'nativescript-browser-polyfill';

Implements

DOM

DOM is provided with very low support, these are used for libs like pixi.js that validate type.

class Node
class Element
class Document
class HTMLImageElement
class Image
class ImageBitmap
class HTMLVideoElement
class Video
class HTMLCanvasElement
class Canvas

Image, HTMLImageElement, ImageBitmap

Image has support for loading callbacks, however the loaded uri must be passed to the src already.

const image = new Image();
image.src = '';
image.onload = () => {
  const { src, width, height } = image;
};
image.addEventListener('loading', () => {});
image.addEventListener('error', () => {});

Document

const element = document.createElement('div');
const fakeContext = element.getContext('');

Element

All sizes return the window size:

element.clientWidth;
element.clientHeight;
element.innerWidth;
element.innerHeight;
element.offsetWidth;
element.offsetHeight;

Empty attributes that prevent libraries from crashing

element.tagName;
element.addEventListener;
element.removeEventListener;
element.setAttributeNS;
element.createElementNS;

Node

node.ownerDocument;
node.className;
node.appendChild;
node.insertBefore;
node.removeChild;
node.setAttributeNS;
node.getBoundingClientRect;

Debug flags

For debugging base64 image transformations toggle:

global.__debug_browser_polyfill_image = true;

By default global.__debug_browser_polyfill_image is false.

License

Apache License Version 2.0, January 2004

Keywords

NativeScript

FAQs

Package last updated on 26 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts