Tweaked gitignore

gitignore removed all composer and npm files, so automated builds would fail
This commit is contained in:
Henry Whitaker
2020-04-12 21:24:03 +01:00
parent 698687f12d
commit ea5808047f
27863 changed files with 3399604 additions and 5 deletions

View File

@@ -0,0 +1,21 @@
Copyright (c) 2019-present StringEpsilon <StringEpsilon@gmail.com>
Copyright (c) 2017-2019 James Kyle <me@thejameskyle.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,117 @@
# mini-create-react-context
<p align="center">
<a href="https://packagephobia.now.sh/result?p=mini-create-react-context">
<img alt="npm install size" src="https://packagephobia.now.sh/badge?p=mini-create-react-context">
</a>
<a href="https://bundlephobia.com/result?p=mini-create-react-context">
<img alt="npm bundle size" src="https://img.shields.io/bundlephobia/min/mini-create-react-context.svg?style=flat-square">
</a>
<a href="https://www.npmjs.com/package/mini-create-react-context">
<img alt="npm" src="https://img.shields.io/npm/v/mini-create-react-context.svg?style=flat-square">
</a>
</p>
> (A smaller) Polyfill for the [proposed React context API](https://github.com/reactjs/rfcs/pull/2)
## Install
```sh
npm install mini-create-react-context
```
You'll need to also have `react` and `prop-types` installed.
## API
```js
const Context = createReactContext(defaultValue);
/*
<Context.Provider value={providedValue}>
{children}
</Context.Provider>
...
<Context.Consumer>
{value => children}
</Context.Consumer>
*/
```
## Example
```js
// @flow
import React, { type Node } from 'react';
import createReactContext, { type Context } from 'mini-create-react-context';
type Theme = 'light' | 'dark';
// Pass a default theme to ensure type correctness
const ThemeContext: Context<Theme> = createReactContext('light');
class ThemeToggler extends React.Component<
{ children: Node },
{ theme: Theme }
> {
state = { theme: 'light' };
render() {
return (
// Pass the current context value to the Provider's `value` prop.
// Changes are detected using strict comparison (Object.is)
<ThemeContext.Provider value={this.state.theme}>
<button
onClick={() => {
this.setState(state => ({
theme: state.theme === 'light' ? 'dark' : 'light'
}));
}}
>
Toggle theme
</button>
{this.props.children}
</ThemeContext.Provider>
);
}
}
class Title extends React.Component<{ children: Node }> {
render() {
return (
// The Consumer uses a render prop API. Avoids conflicts in the
// props namespace.
<ThemeContext.Consumer>
{theme => (
<h1 style={{ color: theme === 'light' ? '#000' : '#fff' }}>
{this.props.children}
</h1>
)}
</ThemeContext.Consumer>
);
}
}
```
## Compatibility
This package only "ponyfills" the `React.createContext` API, not other unrelated React 16+ APIs. If you are using a version of React <16, keep in mind that you can only use features available in that version.
For example, you cannot pass children types aren't valid pre React 16:
```js
<Context.Provider>
<div/>
<div/>
</Context.Provider>
```
It will throw `A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.` because `<Context.Provider>` can only receive a single child element. To fix the error just wrap everyting in a single `<div>`:
```js
<Context.Provider>
<div>
<div/>
<div/>
</div>
</Context.Provider>
```

View File

@@ -0,0 +1,165 @@
'use strict';function _interopDefault(e){return(e&&(typeof e==='object')&&'default'in e)?e['default']:e}var React=require('react'),React__default=_interopDefault(React),_inheritsLoose=_interopDefault(require('@babel/runtime/helpers/inheritsLoose')),PropTypes=_interopDefault(require('prop-types')),gud=_interopDefault(require('gud')),warning=_interopDefault(require('tiny-warning'));var MAX_SIGNED_31_BIT_INT = 1073741823;
function objectIs(x, y) {
if (x === y) {
return x !== 0 || 1 / x === 1 / y;
} else {
return x !== x && y !== y;
}
}
function createEventEmitter(value) {
var handlers = [];
return {
on: function on(handler) {
handlers.push(handler);
},
off: function off(handler) {
handlers = handlers.filter(function (h) {
return h !== handler;
});
},
get: function get() {
return value;
},
set: function set(newValue, changedBits) {
value = newValue;
handlers.forEach(function (handler) {
return handler(value, changedBits);
});
}
};
}
function onlyChild(children) {
return Array.isArray(children) ? children[0] : children;
}
function createReactContext(defaultValue, calculateChangedBits) {
var _Provider$childContex, _Consumer$contextType;
var contextProp = '__create-react-context-' + gud() + '__';
var Provider =
/*#__PURE__*/
function (_Component) {
_inheritsLoose(Provider, _Component);
function Provider() {
var _this;
_this = _Component.apply(this, arguments) || this;
_this.emitter = createEventEmitter(_this.props.value);
return _this;
}
var _proto = Provider.prototype;
_proto.getChildContext = function getChildContext() {
var _ref;
return _ref = {}, _ref[contextProp] = this.emitter, _ref;
};
_proto.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
if (this.props.value !== nextProps.value) {
var oldValue = this.props.value;
var newValue = nextProps.value;
var changedBits;
if (objectIs(oldValue, newValue)) {
changedBits = 0;
} else {
changedBits = typeof calculateChangedBits === 'function' ? calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
if (process.env.NODE_ENV !== 'production') {
warning((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: ' + changedBits);
}
changedBits |= 0;
if (changedBits !== 0) {
this.emitter.set(nextProps.value, changedBits);
}
}
}
};
_proto.render = function render() {
return this.props.children;
};
return Provider;
}(React.Component);
Provider.childContextTypes = (_Provider$childContex = {}, _Provider$childContex[contextProp] = PropTypes.object.isRequired, _Provider$childContex);
var Consumer =
/*#__PURE__*/
function (_Component2) {
_inheritsLoose(Consumer, _Component2);
function Consumer() {
var _this2;
_this2 = _Component2.apply(this, arguments) || this;
_this2.state = {
value: _this2.getValue()
};
_this2.onUpdate = function (newValue, changedBits) {
var observedBits = _this2.observedBits | 0;
if ((observedBits & changedBits) !== 0) {
_this2.setState({
value: _this2.getValue()
});
}
};
return _this2;
}
var _proto2 = Consumer.prototype;
_proto2.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
var observedBits = nextProps.observedBits;
this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT : observedBits;
};
_proto2.componentDidMount = function componentDidMount() {
if (this.context[contextProp]) {
this.context[contextProp].on(this.onUpdate);
}
var observedBits = this.props.observedBits;
this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT : observedBits;
};
_proto2.componentWillUnmount = function componentWillUnmount() {
if (this.context[contextProp]) {
this.context[contextProp].off(this.onUpdate);
}
};
_proto2.getValue = function getValue() {
if (this.context[contextProp]) {
return this.context[contextProp].get();
} else {
return defaultValue;
}
};
_proto2.render = function render() {
return onlyChild(this.props.children)(this.state.value);
};
return Consumer;
}(React.Component);
Consumer.contextTypes = (_Consumer$contextType = {}, _Consumer$contextType[contextProp] = PropTypes.object, _Consumer$contextType);
return {
Provider: Provider,
Consumer: Consumer
};
}var index = React__default.createContext || createReactContext;module.exports=index;

View File

@@ -0,0 +1 @@
"use strict";function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var React=require("react"),React__default=_interopDefault(React),_inheritsLoose=_interopDefault(require("@babel/runtime/helpers/inheritsLoose")),PropTypes=_interopDefault(require("prop-types")),gud=_interopDefault(require("gud")),warning=_interopDefault(require("tiny-warning")),MAX_SIGNED_31_BIT_INT=1073741823;function objectIs(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}function createEventEmitter(n){var r=[];return{on:function(t){r.push(t)},off:function(e){r=r.filter(function(t){return t!==e})},get:function(){return n},set:function(t,e){n=t,r.forEach(function(t){return t(n,e)})}}}function onlyChild(t){return Array.isArray(t)?t[0]:t}function createReactContext(r,o){var t,e,i="__create-react-context-"+gud()+"__",n=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).emitter=createEventEmitter(t.props.value),t}_inheritsLoose(t,e);var n=t.prototype;return n.getChildContext=function(){var t;return(t={})[i]=this.emitter,t},n.componentWillReceiveProps=function(t){if(this.props.value!==t.value){var e,n=this.props.value,r=t.value;objectIs(n,r)?e=0:(e="function"==typeof o?o(n,r):MAX_SIGNED_31_BIT_INT,"production"!==process.env.NODE_ENV&&warning((e&MAX_SIGNED_31_BIT_INT)===e,"calculateChangedBits: Expected the return value to be a 31-bit integer. Instead received: "+e),0!==(e|=0)&&this.emitter.set(t.value,e))}},n.render=function(){return this.props.children},t}(React.Component);n.childContextTypes=((t={})[i]=PropTypes.object.isRequired,t);var u=function(t){function e(){var n;return(n=t.apply(this,arguments)||this).state={value:n.getValue()},n.onUpdate=function(t,e){0!=((0|n.observedBits)&e)&&n.setState({value:n.getValue()})},n}_inheritsLoose(e,t);var n=e.prototype;return n.componentWillReceiveProps=function(t){var e=t.observedBits;this.observedBits=null==e?MAX_SIGNED_31_BIT_INT:e},n.componentDidMount=function(){this.context[i]&&this.context[i].on(this.onUpdate);var t=this.props.observedBits;this.observedBits=null==t?MAX_SIGNED_31_BIT_INT:t},n.componentWillUnmount=function(){this.context[i]&&this.context[i].off(this.onUpdate)},n.getValue=function(){return this.context[i]?this.context[i].get():r},n.render=function(){return onlyChild(this.props.children)(this.state.value)},e}(React.Component);return u.contextTypes=((e={})[i]=PropTypes.object,e),{Provider:n,Consumer:u}}var index=React__default.createContext||createReactContext;module.exports=index;

View File

@@ -0,0 +1,175 @@
import React, { Component } from 'react';
import _inheritsLoose from '@babel/runtime/helpers/inheritsLoose';
import PropTypes from 'prop-types';
import gud from 'gud';
import warning from 'tiny-warning';
var MAX_SIGNED_31_BIT_INT = 1073741823;
function objectIs(x, y) {
if (x === y) {
return x !== 0 || 1 / x === 1 / y;
} else {
return x !== x && y !== y;
}
}
function createEventEmitter(value) {
var handlers = [];
return {
on: function on(handler) {
handlers.push(handler);
},
off: function off(handler) {
handlers = handlers.filter(function (h) {
return h !== handler;
});
},
get: function get() {
return value;
},
set: function set(newValue, changedBits) {
value = newValue;
handlers.forEach(function (handler) {
return handler(value, changedBits);
});
}
};
}
function onlyChild(children) {
return Array.isArray(children) ? children[0] : children;
}
function createReactContext(defaultValue, calculateChangedBits) {
var _Provider$childContex, _Consumer$contextType;
var contextProp = '__create-react-context-' + gud() + '__';
var Provider =
/*#__PURE__*/
function (_Component) {
_inheritsLoose(Provider, _Component);
function Provider() {
var _this;
_this = _Component.apply(this, arguments) || this;
_this.emitter = createEventEmitter(_this.props.value);
return _this;
}
var _proto = Provider.prototype;
_proto.getChildContext = function getChildContext() {
var _ref;
return _ref = {}, _ref[contextProp] = this.emitter, _ref;
};
_proto.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
if (this.props.value !== nextProps.value) {
var oldValue = this.props.value;
var newValue = nextProps.value;
var changedBits;
if (objectIs(oldValue, newValue)) {
changedBits = 0;
} else {
changedBits = typeof calculateChangedBits === 'function' ? calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
if (process.env.NODE_ENV !== 'production') {
warning((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: ' + changedBits);
}
changedBits |= 0;
if (changedBits !== 0) {
this.emitter.set(nextProps.value, changedBits);
}
}
}
};
_proto.render = function render() {
return this.props.children;
};
return Provider;
}(Component);
Provider.childContextTypes = (_Provider$childContex = {}, _Provider$childContex[contextProp] = PropTypes.object.isRequired, _Provider$childContex);
var Consumer =
/*#__PURE__*/
function (_Component2) {
_inheritsLoose(Consumer, _Component2);
function Consumer() {
var _this2;
_this2 = _Component2.apply(this, arguments) || this;
_this2.state = {
value: _this2.getValue()
};
_this2.onUpdate = function (newValue, changedBits) {
var observedBits = _this2.observedBits | 0;
if ((observedBits & changedBits) !== 0) {
_this2.setState({
value: _this2.getValue()
});
}
};
return _this2;
}
var _proto2 = Consumer.prototype;
_proto2.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
var observedBits = nextProps.observedBits;
this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT : observedBits;
};
_proto2.componentDidMount = function componentDidMount() {
if (this.context[contextProp]) {
this.context[contextProp].on(this.onUpdate);
}
var observedBits = this.props.observedBits;
this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT : observedBits;
};
_proto2.componentWillUnmount = function componentWillUnmount() {
if (this.context[contextProp]) {
this.context[contextProp].off(this.onUpdate);
}
};
_proto2.getValue = function getValue() {
if (this.context[contextProp]) {
return this.context[contextProp].get();
} else {
return defaultValue;
}
};
_proto2.render = function render() {
return onlyChild(this.props.children)(this.state.value);
};
return Consumer;
}(Component);
Consumer.contextTypes = (_Consumer$contextType = {}, _Consumer$contextType[contextProp] = PropTypes.object, _Consumer$contextType);
return {
Provider: Provider,
Consumer: Consumer
};
}
var index = React.createContext || createReactContext;
export default index;

View File

@@ -0,0 +1,24 @@
import * as React from 'react';
export default function createReactContext<T>(
defaultValue: T,
calculateChangedBits?: (prev: T, next: T) => number
): Context<T>;
type RenderFn<T> = (value: T) => React.ReactNode;
export type Context<T> = {
Provider: React.ComponentClass<ProviderProps<T>>;
Consumer: React.ComponentClass<ConsumerProps<T>>;
};
export type ProviderProps<T> = {
value: T;
children?: React.ReactNode;
observedBits?: any,
};
export type ConsumerProps<T> = {
children: RenderFn<T> | [RenderFn<T>];
observedBits?: number;
};

View File

@@ -0,0 +1,99 @@
{
"_from": "mini-create-react-context@^0.3.0",
"_id": "mini-create-react-context@0.3.2",
"_inBundle": false,
"_integrity": "sha512-2v+OeetEyliMt5VHMXsBhABoJ0/M4RCe7fatd/fBy6SMiKazUSEt3gxxypfnk2SHMkdBYvorHRoQxuGoiwbzAw==",
"_location": "/mini-create-react-context",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "mini-create-react-context@^0.3.0",
"name": "mini-create-react-context",
"escapedName": "mini-create-react-context",
"rawSpec": "^0.3.0",
"saveSpec": null,
"fetchSpec": "^0.3.0"
},
"_requiredBy": [
"/react-router"
],
"_resolved": "https://registry.npmjs.org/mini-create-react-context/-/mini-create-react-context-0.3.2.tgz",
"_shasum": "79fc598f283dd623da8e088b05db8cddab250189",
"_spec": "mini-create-react-context@^0.3.0",
"_where": "/home/henry/Documents/git/Speedtest-checker/node_modules/react-router",
"author": {
"name": "StringEpsilon"
},
"bugs": {
"url": "https://github.com/StringEpsilon/mini-create-react-context/issues"
},
"bundleDependencies": false,
"dependencies": {
"@babel/runtime": "^7.4.0",
"gud": "^1.0.0",
"tiny-warning": "^1.0.2"
},
"deprecated": false,
"description": "Smaller Polyfill for the proposed React context API",
"devDependencies": {
"@babel/cli": "^7.4.3",
"@babel/core": "^7.4.3",
"@babel/plugin-proposal-class-properties": "^7.4.0",
"@babel/preset-env": "^7.4.3",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.3.3",
"@types/enzyme": "^3.9.1",
"@types/jest": "^24.0.11",
"@types/react": "^16.8.13",
"@wessberg/rollup-plugin-ts": "^1.1.46",
"babel-jest": "^24.7.1",
"enzyme": "^3.9.0",
"enzyme-adapter-react-16": "^1.11.2",
"enzyme-to-json": "^3.3.5",
"jest": "^24.7.1",
"prop-types": "^15.6.0",
"raf": "^3.4.1",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"rollup": "^1.10.0",
"rollup-plugin-commonjs": "^9.3.4",
"rollup-plugin-node-resolve": "^4.2.3",
"rollup-plugin-uglify": "^6.0.2"
},
"files": [
"dist/**"
],
"homepage": "https://github.com/StringEpsilon/mini-create-react-context#readme",
"jest": {
"snapshotSerializers": [
"enzyme-to-json/serializer"
]
},
"keywords": [
"react",
"context",
"contextTypes",
"polyfill",
"ponyfill"
],
"license": "MIT",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"name": "mini-create-react-context",
"peerDependencies": {
"prop-types": "^15.0.0",
"react": "^0.14.0 || ^15.0.0 || ^16.0.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/StringEpsilon/mini-create-react-context.git"
},
"scripts": {
"build": "rollup -c rollup.config.js",
"prepublish": "npm run build",
"test": "jest"
},
"types": "dist/index.d.ts",
"version": "0.3.2"
}