Skip to content

Commit

Permalink
fix: add lib package files
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelmaeuer committed Jan 19, 2023
1 parent 1001a0a commit c08394b
Show file tree
Hide file tree
Showing 60 changed files with 5,333 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/packages/recompose/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/**/__tests__
10 changes: 10 additions & 0 deletions lib/packages/recompose/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
See README.md in the root of this project

<!-- ORIGINAL CONTENT HIDDEN:
recompose
=========
[![npm version](https://img.shields.io/npm/v/recompose.svg?style=flat-square)](https://www.npmjs.com/package/recompose)
Recompose is a React utility belt for function components and higher-order components. See the [GitHub project page](https://github.com/acdlite/recompose) for more information.
- -->
51 changes: 51 additions & 0 deletions lib/packages/recompose/baconObservableConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _symbolObservable = _interopRequireDefault(require("symbol-observable"));
var Bacon = _interopRequireWildcard(require("baconjs"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var config = {
fromESObservable: function fromESObservable(observable) {
return Bacon.fromBinder(function (sink) {
var _observable$subscribe = observable.subscribe({
next: function next(val) {
return sink(new Bacon.Next(val));
},
error: function error(err) {
return sink(new Bacon.Error(err));
},
complete: function complete() {
return sink(new Bacon.End());
}
}),
unsubscribe = _observable$subscribe.unsubscribe;
return unsubscribe;
});
},
toESObservable: function toESObservable(stream) {
var _ref;
return _ref = {
subscribe: function subscribe(observer) {
var unsubscribe = stream.subscribe(function (event) {
if (event.hasValue) {
observer.next(event.value);
} else if (event.isError) {
observer.error(event.error);
} else if (event.isEnd) {
observer.complete();
}
});
return {
unsubscribe: unsubscribe
};
}
}, _ref[_symbolObservable["default"]] = function () {
return this;
}, _ref;
}
};
var _default = config;
exports["default"] = _default;
34 changes: 34 additions & 0 deletions lib/packages/recompose/branch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _createFactory = _interopRequireDefault(require("./utils/createFactory"));
var _setDisplayName = _interopRequireDefault(require("./setDisplayName"));
var _wrapDisplayName = _interopRequireDefault(require("./wrapDisplayName"));
var identity = function identity(Component) {
return Component;
};
var branch = function branch(test, left, right) {
if (right === void 0) {
right = identity;
}
return function (BaseComponent) {
var leftFactory;
var rightFactory;
var Branch = function Branch(props) {
if (test(props)) {
leftFactory = leftFactory || (0, _createFactory["default"])(left(BaseComponent));
return leftFactory(props);
}
rightFactory = rightFactory || (0, _createFactory["default"])(right(BaseComponent));
return rightFactory(props);
};
if (process.env.NODE_ENV !== 'production') {
return (0, _setDisplayName["default"])((0, _wrapDisplayName["default"])(BaseComponent, 'branch'))(Branch);
}
return Branch;
};
};
var _default = branch;
exports["default"] = _default;
16 changes: 16 additions & 0 deletions lib/packages/recompose/componentFromProp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _react = require("react");
var _omit = _interopRequireDefault(require("./utils/omit"));
var componentFromProp = function componentFromProp(propName) {
function Component(props) {
return /*#__PURE__*/(0, _react.createElement)(props[propName], (0, _omit["default"])(props, [propName]));
}
Component.displayName = "componentFromProp(" + propName + ")";
return Component;
};
var _default = componentFromProp;
exports["default"] = _default;
84 changes: 84 additions & 0 deletions lib/packages/recompose/componentFromStream.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = exports.componentFromStreamWithConfig = void 0;
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
var _react = require("react");
var _changeEmitter = require("change-emitter");
var _symbolObservable = _interopRequireDefault(require("symbol-observable"));
var _setObservableConfig = require("./setObservableConfig");
var componentFromStreamWithConfig = function componentFromStreamWithConfig(config) {
return function (propsToVdom) {
return /*#__PURE__*/function (_Component) {
(0, _inheritsLoose2["default"])(ComponentFromStream, _Component);
function ComponentFromStream() {
var _config$fromESObserva;
var _this;
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _Component.call.apply(_Component, [this].concat(args)) || this;
_this.state = {
vdom: null
};
_this.propsEmitter = (0, _changeEmitter.createChangeEmitter)();
_this.props$ = config.fromESObservable((_config$fromESObserva = {
subscribe: function subscribe(observer) {
var unsubscribe = _this.propsEmitter.listen(function (props) {
if (props) {
observer.next(props);
} else {
observer.complete();
}
});
return {
unsubscribe: unsubscribe
};
}
}, _config$fromESObserva[_symbolObservable["default"]] = function () {
return this;
}, _config$fromESObserva));
_this.vdom$ = config.toESObservable(propsToVdom(_this.props$));
return _this;
}
var _proto = ComponentFromStream.prototype;
_proto.UNSAFE_componentWillMount = function UNSAFE_componentWillMount() {
var _this2 = this;
// Subscribe to child prop changes so we know when to re-render
this.subscription = this.vdom$.subscribe({
next: function next(vdom) {
_this2.setState({
vdom: vdom
});
}
});
this.propsEmitter.emit(this.props);
};
_proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(nextProps) {
// Receive new props from the owner
this.propsEmitter.emit(nextProps);
};
_proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) {
return nextState.vdom !== this.state.vdom;
};
_proto.componentWillUnmount = function componentWillUnmount() {
// Call without arguments to complete stream
this.propsEmitter.emit();

// Clean-up subscription before un-mounting
this.subscription.unsubscribe();
};
_proto.render = function render() {
return this.state.vdom;
};
return ComponentFromStream;
}(_react.Component);
};
};
exports.componentFromStreamWithConfig = componentFromStreamWithConfig;
var componentFromStream = function componentFromStream(propsToVdom) {
return componentFromStreamWithConfig(_setObservableConfig.config)(propsToVdom);
};
var _default = componentFromStream;
exports["default"] = _default;
18 changes: 18 additions & 0 deletions lib/packages/recompose/compose.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"use strict";

exports.__esModule = true;
exports["default"] = void 0;
var compose = function compose() {
for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
funcs[_key] = arguments[_key];
}
return funcs.reduce(function (a, b) {
return function () {
return a(b.apply(void 0, arguments));
};
}, function (arg) {
return arg;
});
};
var _default = compose;
exports["default"] = _default;
34 changes: 34 additions & 0 deletions lib/packages/recompose/createEventHandler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = exports.createEventHandlerWithConfig = void 0;
var _symbolObservable = _interopRequireDefault(require("symbol-observable"));
var _changeEmitter = require("change-emitter");
var _setObservableConfig = require("./setObservableConfig");
var createEventHandlerWithConfig = function createEventHandlerWithConfig(config) {
return function () {
var _config$fromESObserva;
var emitter = (0, _changeEmitter.createChangeEmitter)();
var stream = config.fromESObservable((_config$fromESObserva = {
subscribe: function subscribe(observer) {
var unsubscribe = emitter.listen(function (value) {
return observer.next(value);
});
return {
unsubscribe: unsubscribe
};
}
}, _config$fromESObserva[_symbolObservable["default"]] = function () {
return this;
}, _config$fromESObserva));
return {
handler: emitter.emit,
stream: stream
};
};
};
exports.createEventHandlerWithConfig = createEventHandlerWithConfig;
var createEventHandler = createEventHandlerWithConfig(_setObservableConfig.config);
var _default = createEventHandler;
exports["default"] = _default;
35 changes: 35 additions & 0 deletions lib/packages/recompose/createSink.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
var _react = require("react");
var _reactLifecyclesCompat = require("react-lifecycles-compat");
var createSink = function createSink(callback) {
var Sink = /*#__PURE__*/function (_Component) {
(0, _inheritsLoose2["default"])(Sink, _Component);
function Sink() {
var _this;
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _Component.call.apply(_Component, [this].concat(args)) || this;
_this.state = {};
return _this;
}
Sink.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps) {
callback(nextProps);
return null;
};
var _proto = Sink.prototype;
_proto.render = function render() {
return null;
};
return Sink;
}(_react.Component);
(0, _reactLifecyclesCompat.polyfill)(Sink);
return Sink;
};
var _default = createSink;
exports["default"] = _default;
23 changes: 23 additions & 0 deletions lib/packages/recompose/defaultProps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _createFactory = _interopRequireDefault(require("./utils/createFactory"));
var _setDisplayName = _interopRequireDefault(require("./setDisplayName"));
var _wrapDisplayName = _interopRequireDefault(require("./wrapDisplayName"));
var defaultProps = function defaultProps(props) {
return function (BaseComponent) {
var factory = (0, _createFactory["default"])(BaseComponent);
function DefaultProps(ownerProps) {
return factory(ownerProps);
}
DefaultProps.defaultProps = props;
if (process.env.NODE_ENV !== 'production') {
return (0, _setDisplayName["default"])((0, _wrapDisplayName["default"])(BaseComponent, 'defaultProps'))(DefaultProps);
}
return DefaultProps;
};
};
var _default = defaultProps;
exports["default"] = _default;
Loading

0 comments on commit c08394b

Please sign in to comment.