@expo/browser-polyfill
Browser polyfill for making React Native compatible with web libs like pixi.js, three.js, phaser.js
Last updated 8 months ago by lukmccall .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @expo/browser-polyfill 
SYNC missed versions from official npm registry.

@expo/browser-polyfill

Browser polyfill for React Native

Installation

yarn add @expo/browser-polyfill

Usage

Import the library into your JavaScript file:

import '@expo/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;

External Libraries

Some external node.js polyfills are added as well.

text-encoding

global.TextEncoder
global.TextDecoder

xmldom-qsa

window.DOMParser

react-native-console-time-polyfill

console.time(label);
console.timeEnd(label);
console.count(label);

Debug flags

For debugging base64 image transformations toggle:

global.__debug_browser_polyfill_image = true;

By default global.__debug_browser_polyfill_image is false.

Current Tags

  • 1.0.1                                ...           latest (8 months ago)

22 Versions

  • 1.0.1                                ...           8 months ago
  • 1.0.0                                ...           3 years ago
  • 0.1.1                                ...           4 years ago
  • 0.1.0                                ...           5 years ago
  • 0.0.1-alpha.6                                ...           5 years ago
  • 0.0.1-alpha.5                                ...           6 years ago
  • 0.0.1-alpha.4                                ...           6 years ago
  • 0.0.1-alpha.3                                ...           6 years ago
  • 0.0.1-alpha.2                                ...           6 years ago
  • 0.0.1-alpha.1                                ...           6 years ago
  • 0.0.1-alpha.0                                ...           6 years ago
  • 0.0.0-alpha.10                                ...           6 years ago
  • 0.0.0-alpha.9                                ...           6 years ago
  • 0.0.0-alpha.8                                ...           7 years ago
  • 0.0.0-alpha.7                                ...           7 years ago
  • 0.0.0-alpha.6                                ...           7 years ago
  • 0.0.0-alpha.5                                ...           7 years ago
  • 0.0.0-alpha.4                                ...           7 years ago
  • 0.0.0-alpha.3                                ...           7 years ago
  • 0.0.0-alpha.2                                ...           7 years ago
  • 0.0.0-alpha.1                                ...           7 years ago
  • 0.0.0-alpha.0                                ...           7 years ago

© 2010 - cnpmjs.org x YWFE | Home | YWFE