mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 21:52:19 +00:00
0.2.0 - Mid migration
This commit is contained in:
parent
139e6a915e
commit
7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions
167
web/node_modules/mini-create-react-context/dist/cjs/index.js
generated
vendored
Normal file
167
web/node_modules/mini-create-react-context/dist/cjs/index.js
generated
vendored
Normal file
|
@ -0,0 +1,167 @@
|
|||
'use strict';var React=require('react'),_inheritsLoose=require('@babel/runtime/helpers/inheritsLoose'),PropTypes=require('prop-types'),warning=require('tiny-warning');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var React__default=/*#__PURE__*/_interopDefaultLegacy(React);var _inheritsLoose__default=/*#__PURE__*/_interopDefaultLegacy(_inheritsLoose);var PropTypes__default=/*#__PURE__*/_interopDefaultLegacy(PropTypes);var warning__default=/*#__PURE__*/_interopDefaultLegacy(warning);var MAX_SIGNED_31_BIT_INT = 1073741823;
|
||||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : {};
|
||||
|
||||
function getUniqueId() {
|
||||
var key = '__global_unique_id__';
|
||||
return commonjsGlobal[key] = (commonjsGlobal[key] || 0) + 1;
|
||||
}
|
||||
|
||||
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-' + getUniqueId() + '__';
|
||||
|
||||
var Provider = /*#__PURE__*/function (_Component) {
|
||||
_inheritsLoose__default['default'](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__default['default']((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__default['default'].object.isRequired, _Provider$childContex);
|
||||
|
||||
var Consumer = /*#__PURE__*/function (_Component2) {
|
||||
_inheritsLoose__default['default'](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__default['default'].object, _Consumer$contextType);
|
||||
return {
|
||||
Provider: Provider,
|
||||
Consumer: Consumer
|
||||
};
|
||||
}var index = React__default['default'].createContext || createReactContext;module.exports=index;
|
1
web/node_modules/mini-create-react-context/dist/cjs/index.min.js
generated
vendored
Normal file
1
web/node_modules/mini-create-react-context/dist/cjs/index.min.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
"use strict";var t=require("react"),e=require("@babel/runtime/helpers/inheritsLoose"),n=require("prop-types"),r=require("tiny-warning");function o(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var i=o(t),u=o(e),a=o(n),s=o(r),c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{};function l(t){var e=[];return{on:function(t){e.push(t)},off:function(t){e=e.filter((function(e){return e!==t}))},get:function(){return t},set:function(n,r){t=n,e.forEach((function(e){return e(t,r)}))}}}var p=i.default.createContext||function(e,n){var r,o,i,p="__create-react-context-"+((c[i="__global_unique_id__"]=(c[i]||0)+1)+"__"),f=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).emitter=l(e.props.value),e}u.default(e,t);var r=e.prototype;return r.getChildContext=function(){var t;return(t={})[p]=this.emitter,t},r.componentWillReceiveProps=function(t){if(this.props.value!==t.value){var e,r=this.props.value,o=t.value;((i=r)===(u=o)?0!==i||1/i==1/u:i!=i&&u!=u)?e=0:(e="function"==typeof n?n(r,o):1073741823,"production"!==process.env.NODE_ENV&&s.default((1073741823&e)===e,"calculateChangedBits: Expected the return value to be a 31-bit integer. Instead received: "+e),0!==(e|=0)&&this.emitter.set(t.value,e))}var i,u},r.render=function(){return this.props.children},e}(t.Component);f.childContextTypes=((r={})[p]=a.default.object.isRequired,r);var d=function(t){function n(){var e;return(e=t.apply(this,arguments)||this).state={value:e.getValue()},e.onUpdate=function(t,n){0!=((0|e.observedBits)&n)&&e.setState({value:e.getValue()})},e}u.default(n,t);var r=n.prototype;return r.componentWillReceiveProps=function(t){var e=t.observedBits;this.observedBits=null==e?1073741823:e},r.componentDidMount=function(){this.context[p]&&this.context[p].on(this.onUpdate);var t=this.props.observedBits;this.observedBits=null==t?1073741823:t},r.componentWillUnmount=function(){this.context[p]&&this.context[p].off(this.onUpdate)},r.getValue=function(){return this.context[p]?this.context[p].get():e},r.render=function(){return(t=this.props.children,Array.isArray(t)?t[0]:t)(this.state.value);var t},n}(t.Component);return d.contextTypes=((o={})[p]=a.default.object,o),{Provider:f,Consumer:d}};module.exports=p;
|
Loading…
Add table
Add a link
Reference in a new issue