finishes functionality for cart, checkout, return and renter registration

This commit is contained in:
David Lick
2020-05-31 23:25:49 -04:00
parent 28e52a4e08
commit 5cd92132b3
326 changed files with 495 additions and 16570 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ func cors(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, PATCH, DELETE, OPTIONS")
w.Header().Set("Access-Control-Allow_Headers", "Origin, Content-Type, Accept, Authorization")
w.Header().Set("Access-Control-Allow-Headers", "Origin, Content-Type, Accept, Authorization")
w.Header().Set("Access-Control-Allow-Credentials", "true")
w.Header().Set("Access-Control-Max-Age", "600")
-3
View File
@@ -1,8 +1,6 @@
package rental
import (
"fmt"
"github.com/gofrs/uuid"
)
@@ -52,7 +50,6 @@ func (s *service) CheckoutBook(renterId uuid.UUID, title string) error {
// If there was an error or the book is checked out by the renter already we'll
// say the book is unavailable.
if err != nil || checkedOut {
fmt.Println("unavailable book", err, checkedOut)
return ErrUnavailableBook
}
+15 -3
View File
@@ -1,8 +1,11 @@
import React from 'react';
import React, { useEffect } from 'react';
import './App.css';
import styled from 'styled-components';
import Sidebar from './containers/Sidebar/Sidebar';
import Content from './containers/Content/Content';
import { useDispatch } from 'react-redux';
import { fetchBooks } from './actions/books';
import { fetchRenters } from './actions/renters';
const AppContainer = styled.div`
background: #13334A;
@@ -10,11 +13,20 @@ const AppContainer = styled.div`
display: flex;
`
const App: React.FC = () => (
const App: React.FC = () => {
const dispatch = useDispatch();
useEffect(() => {
dispatch(fetchBooks());
dispatch(fetchRenters());
}, []);
return (
<AppContainer>
<Sidebar/>
<Content />
</AppContainer>
)
);
};
export default App;
+27 -12
View File
@@ -5,15 +5,19 @@ import bookishApi from '../api/bookish';
import { Dispatch } from 'redux';
import { fetchRenters } from './renters';
export function fetchBooks() {
return (dispatch: Dispatch) => {
dispatch({ type: actionTypes.FETCH_BOOKS.request });
booksApi.get('/books')
.then(res => dispatch({
type: actionTypes.FETCH_BOOKS.success,
data: res.data
}))
.then(res => {
dispatch({
type: actionTypes.FETCH_BOOKS.success,
data: res.data
})
})
.catch(err => dispatch({
type: actionTypes.FETCH_BOOKS.failure,
err: err.message
@@ -29,12 +33,11 @@ export function fetchBookCover(title: string, isbn: string) {
.then(res => {
if (res.data.totalItems === 0 ||
res.data.items[0].volumeInfo.imageLinks === undefined) {
return dispatch({
type: actionTypes.FETCH_COVER_IMAGE.failure,
err: "no image"
})
return dispatch({
type: actionTypes.FETCH_COVER_IMAGE.failure,
err: "no image"
})
}
dispatch({
type: actionTypes.FETCH_COVER_IMAGE.success,
data: { title: title, imageLink: res.data.items[0].volumeInfo.imageLinks.thumbnail }
@@ -48,7 +51,7 @@ export function fetchBookCover(title: string, isbn: string) {
}
}
export function checkoutBook(title: string, renterId: number) {
export function checkoutBook(title: string, renterId: string) {
return (dispatch: Dispatch) => {
dispatch({ type: actionTypes.CHECKOUT_BOOK.request });
@@ -56,7 +59,12 @@ export function checkoutBook(title: string, renterId: number) {
.then(() => {
dispatch({ type: actionTypes.CHECKOUT_BOOK.success });
})
// After a book is checked out successfully, refetch renters.
.then(() => {
dispatch<any>(fetchRenters());
})
.catch(err => {
alert(`Couldn't check out ${title}`);
dispatch({
type: actionTypes.CHECKOUT_BOOK.failure,
err: err.message
@@ -64,18 +72,25 @@ export function checkoutBook(title: string, renterId: number) {
}
}
export function returnBook(title: string, renterId: number) {
export function returnBook(title: string, renterId: string) {
return (dispatch: Dispatch) => {
dispatch({ type: actionTypes.RETURN_BOOK.request });
bookishApi.post(`/renters/${renterId}/books/return`, { title })
.then(() => {
dispatch({ type: actionTypes.RETURN_BOOK.success });
alert(`${title} was returned`);
})
// After a book is returned successfully, refetch renters.
.then(() => {
dispatch<any>(fetchRenters());
})
.catch(err => {
dispatch({
type: actionTypes.RETURN_BOOK.failure,
err: err.message
})})
})
alert(`Failed to return ${title}`);
})
}
}
+11 -5
View File
@@ -9,7 +9,6 @@ export function fetchRenters() {
bookishApi.get('/renters')
.then(res => {
console.log(res)
dispatch({
type: actionTypes.FETCH_RENTERS.success,
data: res.data
@@ -31,10 +30,17 @@ export function registerRenter(name: string, address: string, email: string, pho
type: actionTypes.REGISTER_RENTER.success,
data: res.data
}))
.catch(err => dispatch({
type: actionTypes.REGISTER_RENTER.failure,
err: err.message
}))
// After a renter is registered successfully, refetch renters.
.then(() => {
dispatch<any>(fetchRenters());
})
.catch(err => {
alert('Could not register renter');
dispatch({
type: actionTypes.REGISTER_RENTER.failure,
err: err.message
})
})
}
}
@@ -4,6 +4,8 @@ const FETCH_BOOKS = generateActionType('FETCH_BOOKS');
const FETCH_COVER_IMAGE = generateActionType('FETCH_COVER_IMAGE');
const SET_FILTER = 'SET_FILTER';
const ADD_TO_CART = 'ADD_TO_CART';
const REMOVE_FROM_CART = 'REMOVE_FROM_CART';
const CLEAR_CART = 'CLEAR_CART';
const CHECKOUT_BOOK = generateActionType('CHECKOUT_BOOK');
const RETURN_BOOK = generateActionType('RETURN_BOOK');
@@ -12,6 +14,8 @@ export const actionTypes = {
FETCH_COVER_IMAGE,
SET_FILTER,
ADD_TO_CART,
REMOVE_FROM_CART,
CLEAR_CART,
CHECKOUT_BOOK,
RETURN_BOOK
}
@@ -2,13 +2,16 @@ import React from 'react';
import { useSelector, RootStateOrAny } from 'react-redux';
import styled from 'styled-components';
import { useDispatch } from 'react-redux';
import { actionTypes } from '../../../../constants/books/action_types';
const BookCoverCardContainer = styled.div`
background-color: #fff;
display: flex;
border: 0.1px solid #f0f0f0;
box-shadow: 10px 5px 15px rgba(175,175,175,50);
height: 135px;
max-width: 200px;
height: 225px;
min-width: 325px;
margin: 10px 0;
`
@@ -21,23 +24,27 @@ const EmptyCart = styled.div`
`
const CoverImage = styled.img`
height: 100px;
height: 200px;
object-fit: contain;
margin: auto 15px;
cursor: pointer;
`
const BookCoverCard: React.FC = () => {
const cartItems = useSelector((state: RootStateOrAny) => state.books.cart)
const images = useSelector((state: RootStateOrAny) => state.books.images)
console.log(cartItems)
const dispatch = useDispatch();
const cartItems = useSelector((state: RootStateOrAny) => state.books.cart);
const images = useSelector((state: RootStateOrAny) => state.books.images);
return (
<BookCoverCardContainer>
{cartItems.length === 0 && (<EmptyCart>Nothing here yet!</EmptyCart>)}
{cartItems.length === 0 && (<EmptyCart>Nothing here yet. Pick out a book!</EmptyCart>)}
{cartItems && cartItems.map(cartItem => (
<CoverImage
src={images[cartItem] || 'https://college.indiana.edu/images/publications/book-cover-placeholder.jpg'} />
src={images[cartItem] || 'https://college.indiana.edu/images/publications/book-cover-placeholder.jpg'}
onClick={() => {
dispatch({ type: actionTypes.REMOVE_FROM_CART, data: cartItem })
}}
/>
))}
</BookCoverCardContainer>
)
@@ -1,13 +1,53 @@
import React from 'react';
// import styled from 'styled-components';
import Panel from '../../UIKit/Panel/Panel';
import BookCoverCard from './BookCoverCard/BookCoverCard';
import CartDetail from './CartDetail/CartDetail';
import Renters from '../Renters/Renters';
import { useDispatch, useSelector, RootStateOrAny } from 'react-redux';
import { RouteComponentProps } from 'react-router-dom';
import { checkoutBook } from '../../../actions/books';
import { actionTypes } from '../../../constants/books/action_types';
const Cart: React.FC = () => (
<Panel>
<BookCoverCard />
</Panel>
)
const Cart: React.FC<RouteComponentProps> = ({ history }) => {
const dispatch = useDispatch();
const cart = useSelector((state: RootStateOrAny) => state.books.cart);
let panelStyle = {};
if (cart.length !== 0) {
panelStyle = {
display: 'flex', justifyContent: 'space-between'
}
}
const checkoutHandler = (renterId: string) => {
if (cart.length === 0) {
alert("Add items to your cart before checking out");
return
}
// Checkout each cart item.
cart.map(cartItem => {
dispatch(checkoutBook(cartItem, renterId))
})
// After each item has been checked out clear the cart.
dispatch({ type: actionTypes.CLEAR_CART });
// Redirect to the homepage.
history.push('/');
}
return (
<>
<Panel style={panelStyle}>
<BookCoverCard />
{cart.length !== 0 && <CartDetail />}
</Panel>
<Renters
checkout={checkoutHandler}
/>
</>
);
}
export default Cart;
@@ -0,0 +1,63 @@
import React from 'react';
import styled from 'styled-components';
import { useSelector, RootStateOrAny } from 'react-redux';
const CartDetailContainer = styled.div`
background-color: #fff;
display: flex;
flex-direction: column;
border: 0.1px solid #f0f0f0;
box-shadow: 10px 5px 15px rgba(175,175,175,50);
height: 225px;
min-width: 300px;
width: 100%;
margin: 10px 0 0 20px;
font-family: 'Helvetica';
font-size: 1.5rem;
font-weight: 100;
color: #13334A;
justify-content: center;
align-items: center;
`
const BreakdownContainer = styled.div`
background-color: #fff;
width: 100%;
height: 200px;
font-size: 1.25rem;
padding: 0;
margin: 0;
`
const BreakdownP = styled.p`
margin: 0;
margin-left: 20px;
padding: 0;
line-height: 1;
`
const CartDetail: React.FC = () => {
const cart = useSelector((state: RootStateOrAny) => state.books.cart);
// 12096e5 is a magic number for 14 days.
const dueDate = new Date(Date.now() + 12096e5);
return (
<CartDetailContainer>
Cart
<BreakdownContainer>
<p/>
<BreakdownP>Books in cart:</BreakdownP>
<ul>
{cart.length !== 0 && cart.map(cartItem => (
<li>{cartItem}</li>
))}
</ul>
<BreakdownP>Due date:</BreakdownP>
<BreakdownP>{dueDate.toDateString()}</BreakdownP>
</BreakdownContainer>
</CartDetailContainer>
);
};
export default CartDetail;
@@ -6,6 +6,7 @@ import Header from './Header/Header';
import Library from './Library/Library';
import Cart from './Cart/Cart';
import Renters from './Renters/Renters';
import Register from './Register/Register';
const ContentContainer = styled.div`
width: 100%;
@@ -18,9 +19,9 @@ const Content: React.FC = () => (
<Route path="/" exact component={Library} />
<Route path="/library" component={Library} />
<Route path="/renters" component={Renters} />
<Route path="/register" component={Register} />
<Route path="/return" component={Renters} />
<Route path="/checkout" component={Cart} />
<Route path="/checkout" component={Renters} />
</ContentContainer>
)
@@ -16,7 +16,7 @@ const ButtonBay: React.FC = () => (
<ButtonBayContainer>
<Button
text="Register new renter"
destination="/renters"
destination="/register"
/>
<Button
text="Checkout"
@@ -1,6 +1,8 @@
import React from 'react';
import styled from 'styled-components';
import { useLocation } from 'react-router-dom';
import { useDispatch } from 'react-redux';
import { actionTypes } from '../../../../constants/books/action_types';
@@ -37,16 +39,21 @@ const StyledIcon = styled(FontAwesomeIcon)`
const Search: React.FC = () => {
const dispatch = useDispatch();
const location = useLocation();
const displaySearch = location.pathname === '/library' || location.pathname === '/';
return (
<SearchContainer>
<StyledInput
onChange={(e: React.FormEvent<HTMLInputElement>) => {
dispatch({ type: actionTypes.SET_FILTER, data: e.currentTarget.value });
}}
/>
<StyledIcon icon={faSearch} />
</SearchContainer>
<>
{displaySearch && <SearchContainer>
<StyledInput
onChange={(e: React.FormEvent<HTMLInputElement>) => {
dispatch({ type: actionTypes.SET_FILTER, data: e.currentTarget.value });
}}
/>
<StyledIcon icon={faSearch} />
</SearchContainer>}
</>
)
}
@@ -63,8 +63,8 @@ type Props = {
}
const Book: React.FC<Props> = ({ title, author, isbn }) => {
const imageLink = useSelector((state: RootStateOrAny) => state.books.images[title])
const cart = useSelector((state: RootStateOrAny) => state.books.cart)
const imageLink = useSelector((state: RootStateOrAny) => state.books.images[title]);
const cart = useSelector((state: RootStateOrAny) => state.books.cart);
const dispatch = useDispatch();
useEffect(() => {
@@ -75,12 +75,10 @@ const Book: React.FC<Props> = ({ title, author, isbn }) => {
const handleAddToCart = () => {
if (cart.length > 1) {
// TODO: Add a toast notification here when cart is full.
alert("You can only check out 2 books at a time!");
return;
}
// TODO: Add a toast notification here when item added to cart.
dispatch({ type: actionTypes.ADD_TO_CART, data: title });
}
@@ -18,7 +18,7 @@ const Library: React.FC = () => {
const dispatch = useDispatch();
useEffect(() => {
dispatch(fetchBooks())
dispatch(fetchBooks());
}, []);
const displayBooks = books.books.filter((book: BookType) => book.title.toLowerCase().indexOf(filter) !== -1);
@@ -0,0 +1,126 @@
import React, { useState } from 'react';
import styled from 'styled-components';
import { useDispatch } from 'react-redux';
import { registerRenter } from '../../../actions/renters';
import { RouteComponentProps } from 'react-router-dom';
import Panel from '../../UIKit/Panel/Panel';
const RegistrationContainer = styled.div`
font-family: 'Helvetica';
width: 80%;
max-width: 600px;
margin: auto;
`
const RegistrationForm = styled.form`
width: 100%;
`
const RegistrationRow = styled.div`
width: 100%;
display: block;
`
const RegistrationColumn = styled.div`
width: 100%;
display: inline-block;
`
const RegistrationLabel = styled.label`
width: 30%;
max-width: 100px;
float: left;
color: #13334A;
height: 38px;
line-height: 38px;
text-align: right;
`
const RegistrationInput = styled.input`
width: 60%;
float: right;
height: 38px;
border: 1px solid #ccc;
color: #13334A;
font-size: 1.25rem;
outline: none;
box-shadow: 10px 5px 15px rgba(175,175,175,50)
`
const RegistrationButton = styled.button`
display: block;
height: 38px;
width: 200px;
margin: 15px auto 0 auto;
cursor: pointer;
`
const Register: React.FC<RouteComponentProps> = ({ history }) => {
const dispatch = useDispatch();
const [name, setName] = useState('');
const [address, setAddress] = useState('');
const [email, setEmail] = useState('');
const [phone, setPhone] = useState('');
return (
<Panel>
<RegistrationContainer>
<RegistrationForm>
<RegistrationRow>
<RegistrationColumn>
<RegistrationLabel>
Name:
</RegistrationLabel>
<RegistrationInput
onChange={e => {
setName(e.target.value);
}}
/>
</RegistrationColumn>
<RegistrationColumn>
<RegistrationLabel>
Addresss:
</RegistrationLabel>
<RegistrationInput
onChange={e => {
setAddress(e.target.value);
}}
/>
</RegistrationColumn>
<RegistrationColumn>
<RegistrationLabel>
Email:
</RegistrationLabel>
<RegistrationInput
onChange={e => {
setEmail(e.target.value);
}}
/>
</RegistrationColumn>
<RegistrationColumn>
<RegistrationLabel>
Phone:
</RegistrationLabel>
<RegistrationInput
onChange={e => {
setPhone(e.target.value);
}}
/>
</RegistrationColumn>
</RegistrationRow>
</RegistrationForm>
</RegistrationContainer>
<RegistrationButton
onClick={() => {
dispatch(registerRenter(name, address, email, phone));
history.push('/renters');
}}
>Submit</RegistrationButton>
</Panel>
);
};
export default Register;
@@ -1,5 +1,9 @@
import React from 'react';
import React, { useEffect } from 'react';
import styled from 'styled-components';
import { BookType } from '../../../../../types/book';
import { useDispatch, useSelector, RootStateOrAny } from 'react-redux';
import { fetchBookCover, returnBook } from '../../../../../actions/books';
const BookReturnContainer = styled.div`
display: inline-flex;
@@ -11,16 +15,43 @@ const CoverImage = styled.img`
height: 100px;
object-fit: contain;
margin: auto 15px;
cursor: pointer;
`
type Props = {
imageLink: string;
renterId: string;
book: BookType;
}
const BookReturn: React.FC<Props> = ({ imageLink }) => (
<BookReturnContainer>
<CoverImage src={imageLink} />
</BookReturnContainer>
);
const BookReturn: React.FC<Props> = ({ renterId, book }) => {
let title = '';
let isbn = '';
if (book !== undefined) {
title = book.title;
if (book.isbn) {
isbn = book.isbn;
}
}
const dispatch = useDispatch();
const images = useSelector((state: RootStateOrAny) => state.books.images);
useEffect(() => {
if (images[title] === undefined) {
dispatch(fetchBookCover(title, isbn));
}
}, []);
return (
<BookReturnContainer>
<CoverImage
src={images[title] || 'https://college.indiana.edu/images/publications/book-cover-placeholder.jpg'}
onClick={() => {
dispatch(returnBook(title, renterId));
}}
/>
</BookReturnContainer>
);
}
export default BookReturn;
@@ -0,0 +1,31 @@
import React from 'react';
import styled from'styled-components';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faShoppingBasket } from '@fortawesome/free-solid-svg-icons';
const CheckoutButtonContainer = styled.div`
height: 100%;
width: 200px;
float: right;
text-align: center;
line-height: 135px;
cursor: pointer;
font-family: 'Helvetica';
font-size: 24px;
font-weight: 100;
color: #777;
`
type Props = {
clickHandler: Function;
}
const CheckoutButton: React.FC<Props> = ({ clickHandler }) => (
<CheckoutButtonContainer
onClick={() => clickHandler()}
>
Checkout <FontAwesomeIcon icon={faShoppingBasket} />
</CheckoutButtonContainer>
);
export default CheckoutButton;
@@ -1,7 +1,10 @@
import React from 'react';
import styled from 'styled-components';
import { useSelector, RootStateOrAny } from 'react-redux';
import BookReturn from './BookReturn/BookReturn';
import CheckoutButton from './CheckoutButton/CheckoutButton';
const RenterCardContainer = styled.div`
background-color: #fff;
@@ -55,41 +58,62 @@ const RenterReturnContainer = styled.div`
`
type Props = {
id: string;
name: string;
phoneNumber: string;
email: string;
rentals: [string];
displayRentals: boolean;
displayCheckout: boolean;
handleCheckoutClicked: Function;
}
const books = [
{title: "To Kill a Mockingbird", author: "Harper Lee", imageLink: "http://www.prepressure.com/images/book-cover-to-kill-a-mocking-bird.jpg"},
{title: "To Kill a Mockingbird", author: "Harper Lee", imageLink: "http://www.prepressure.com/images/book-cover-to-kill-a-mocking-bird.jpg"}
]
const RenterCard: React.FC<Props> = ({
id,
name,
phoneNumber,
email,
rentals,
displayRentals,
displayCheckout,
handleCheckoutClicked
}) => {
const books = useSelector((state: RootStateOrAny) => state.books.books);
const RenterCard: React.FC<Props> = ({ name, phoneNumber, email }) => (
<RenterCardContainer>
<RenterImageContainer>
<RenterImagePlaceholder
src="https://avatars3.githubusercontent.com/u/47925772?s=400&v=4" />
</RenterImageContainer>
<RenterInfoContainer>
<RenterName>
{name}
</RenterName>
<RenterPhone>
{phoneNumber}
</RenterPhone>
<RenterEmail>
{email}
</RenterEmail>
</RenterInfoContainer>
<RenterReturnContainer>
{books.map(book => (
<BookReturn
imageLink={book.imageLink}
/>
))}
</RenterReturnContainer>
</RenterCardContainer>
)
return (
<RenterCardContainer>
<RenterImageContainer>
<RenterImagePlaceholder
src="https://avatars3.githubusercontent.com/u/47925772?s=400&v=4" />
</RenterImageContainer>
<RenterInfoContainer>
<RenterName>
{name}
</RenterName>
<RenterPhone>
{phoneNumber}
</RenterPhone>
<RenterEmail>
{email}
</RenterEmail>
</RenterInfoContainer>
<RenterReturnContainer>
{books && displayRentals && rentals && rentals.map(rental => {
return (
<BookReturn
key={id}
renterId={id}
book={books.find(book => book.title === rental)}
/>
);
})}
{displayCheckout &&
<CheckoutButton
clickHandler={() => handleCheckoutClicked(id)}
/>}
</RenterReturnContainer>
</RenterCardContainer>
);
};
export default RenterCard;
@@ -7,9 +7,19 @@ import RenterCard from './RenterCard/RenterCard';
import { RenterType } from '../../../types/renter';
const Renters: React.FC = () => {
const renters = useSelector((state: RootStateOrAny) => state.renters);
import { useLocation } from 'react-router-dom';
type Props = {
checkout: Function;
}
const Renters: React.FC<Props> = ({ checkout }) => {
const renters = useSelector((state: RootStateOrAny) => state.renters.renters);
const dispatch = useDispatch();
const location = useLocation();
const displayRentals = location.pathname === '/return';
const displayCheckout = location.pathname === '/checkout';
useEffect(() => {
dispatch(fetchRenters())
@@ -22,11 +32,17 @@ const Renters: React.FC = () => {
flexWrap: 'wrap',
justifyContent: 'center'
}}>
{renters && renters.renters.map((renter: RenterType) => (
{renters && renters.map((renter: RenterType) => (
<RenterCard
name={renter.name || ''}
phoneNumber={renter.phoneNumber || ''}
email={renter.email || ''}
key={renter.id}
id={renter.id}
name={renter.name}
phoneNumber={renter.phoneNumber}
email={renter.email}
rentals={renter.rentals}
displayRentals={displayRentals}
displayCheckout={displayCheckout}
handleCheckoutClicked={checkout}
/>
))}
</Panel>
@@ -6,7 +6,7 @@ import Menu from './Menu/Menu'
const SidebarContainer = styled.div`
background: #011126;
box-shadow: 0px 0px 5px rgba(0,0,0,50);
box-shadow: 0px 0px 12px rgba(0,0,0,100);
padding-top: 2.5%;
min-width: 275px;
flex: 1;
+16
View File
@@ -73,11 +73,20 @@ export function books(state = initialState, action: Action) {
// ADD_TO_CART action
case actionTypes.ADD_TO_CART:
alert(`Added ${action.data} to the cart`);
return {
...state,
cart: state.cart.concat(action.data)
}
// REMOVE_FROM_CART action
case actionTypes.REMOVE_FROM_CART:
alert(`Removed ${action.data} from the cart`);
return {
...state,
cart: state.cart.filter(item => item !== action.data)
}
// CHECKOUT_BOOK action
case actionTypes.CHECKOUT_BOOK.request:
return {
@@ -116,6 +125,13 @@ export function books(state = initialState, action: Action) {
returnError: action.err
}
// CLEAR_CART action
case actionTypes.CLEAR_CART:
return {
...state,
cart: [],
}
default:
return state;
}
+2
View File
@@ -1,6 +1,8 @@
export type RenterType = {
id: string;
name: string;
address: string;
email: string;
phoneNumber: string;
rentals: [string];
}
-1
View File
@@ -1 +0,0 @@
../loose-envify/cli.js
-22
View File
@@ -1,22 +0,0 @@
MIT License
Copyright (c) 2014-present Sebastian McKenzie and other contributors
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.
-19
View File
@@ -1,19 +0,0 @@
# @babel/runtime
> babel's modular runtime helpers
See our website [@babel/runtime](https://babeljs.io/docs/en/next/babel-runtime.html) for more information.
## Install
Using npm:
```sh
npm install --save @babel/runtime
```
or using yarn:
```sh
yarn add @babel/runtime
```
-100
View File
@@ -1,100 +0,0 @@
var AwaitValue = require("./AwaitValue");
function AsyncGenerator(gen) {
var front, back;
function send(key, arg) {
return new Promise(function (resolve, reject) {
var request = {
key: key,
arg: arg,
resolve: resolve,
reject: reject,
next: null
};
if (back) {
back = back.next = request;
} else {
front = back = request;
resume(key, arg);
}
});
}
function resume(key, arg) {
try {
var result = gen[key](arg);
var value = result.value;
var wrappedAwait = value instanceof AwaitValue;
Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) {
if (wrappedAwait) {
resume(key === "return" ? "return" : "next", arg);
return;
}
settle(result.done ? "return" : "normal", arg);
}, function (err) {
resume("throw", err);
});
} catch (err) {
settle("throw", err);
}
}
function settle(type, value) {
switch (type) {
case "return":
front.resolve({
value: value,
done: true
});
break;
case "throw":
front.reject(value);
break;
default:
front.resolve({
value: value,
done: false
});
break;
}
front = front.next;
if (front) {
resume(front.key, front.arg);
} else {
back = null;
}
}
this._invoke = send;
if (typeof gen["return"] !== "function") {
this["return"] = undefined;
}
}
if (typeof Symbol === "function" && Symbol.asyncIterator) {
AsyncGenerator.prototype[Symbol.asyncIterator] = function () {
return this;
};
}
AsyncGenerator.prototype.next = function (arg) {
return this._invoke("next", arg);
};
AsyncGenerator.prototype["throw"] = function (arg) {
return this._invoke("throw", arg);
};
AsyncGenerator.prototype["return"] = function (arg) {
return this._invoke("return", arg);
};
module.exports = AsyncGenerator;
-5
View File
@@ -1,5 +0,0 @@
function _AwaitValue(value) {
this.wrapped = value;
}
module.exports = _AwaitValue;
-30
View File
@@ -1,30 +0,0 @@
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
var desc = {};
Object.keys(descriptor).forEach(function (key) {
desc[key] = descriptor[key];
});
desc.enumerable = !!desc.enumerable;
desc.configurable = !!desc.configurable;
if ('value' in desc || desc.initializer) {
desc.writable = true;
}
desc = decorators.slice().reverse().reduce(function (desc, decorator) {
return decorator(target, property, desc) || desc;
}, desc);
if (context && desc.initializer !== void 0) {
desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
desc.initializer = undefined;
}
if (desc.initializer === void 0) {
Object.defineProperty(target, property, desc);
desc = null;
}
return desc;
}
module.exports = _applyDecoratedDescriptor;
-11
View File
@@ -1,11 +0,0 @@
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) {
arr2[i] = arr[i];
}
return arr2;
}
module.exports = _arrayLikeToArray;
-5
View File
@@ -1,5 +0,0 @@
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
module.exports = _arrayWithHoles;
-7
View File
@@ -1,7 +0,0 @@
var arrayLikeToArray = require("./arrayLikeToArray");
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return arrayLikeToArray(arr);
}
module.exports = _arrayWithoutHoles;
-9
View File
@@ -1,9 +0,0 @@
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
module.exports = _assertThisInitialized;
-58
View File
@@ -1,58 +0,0 @@
function _asyncGeneratorDelegate(inner, awaitWrap) {
var iter = {},
waiting = false;
function pump(key, value) {
waiting = true;
value = new Promise(function (resolve) {
resolve(inner[key](value));
});
return {
done: false,
value: awaitWrap(value)
};
}
;
if (typeof Symbol === "function" && Symbol.iterator) {
iter[Symbol.iterator] = function () {
return this;
};
}
iter.next = function (value) {
if (waiting) {
waiting = false;
return value;
}
return pump("next", value);
};
if (typeof inner["throw"] === "function") {
iter["throw"] = function (value) {
if (waiting) {
waiting = false;
throw value;
}
return pump("throw", value);
};
}
if (typeof inner["return"] === "function") {
iter["return"] = function (value) {
if (waiting) {
waiting = false;
return value;
}
return pump("return", value);
};
}
return iter;
}
module.exports = _asyncGeneratorDelegate;
-19
View File
@@ -1,19 +0,0 @@
function _asyncIterator(iterable) {
var method;
if (typeof Symbol !== "undefined") {
if (Symbol.asyncIterator) {
method = iterable[Symbol.asyncIterator];
if (method != null) return method.call(iterable);
}
if (Symbol.iterator) {
method = iterable[Symbol.iterator];
if (method != null) return method.call(iterable);
}
}
throw new TypeError("Object is not async iterable");
}
module.exports = _asyncIterator;
-37
View File
@@ -1,37 +0,0 @@
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
module.exports = _asyncToGenerator;
-7
View File
@@ -1,7 +0,0 @@
var AwaitValue = require("./AwaitValue");
function _awaitAsyncGenerator(value) {
return new AwaitValue(value);
}
module.exports = _awaitAsyncGenerator;
-7
View File
@@ -1,7 +0,0 @@
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
module.exports = _classCallCheck;
-5
View File
@@ -1,5 +0,0 @@
function _classNameTDZError(name) {
throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys.");
}
module.exports = _classNameTDZError;
-28
View File
@@ -1,28 +0,0 @@
function _classPrivateFieldDestructureSet(receiver, privateMap) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to set private field on non-instance");
}
var descriptor = privateMap.get(receiver);
if (descriptor.set) {
if (!("__destrObj" in descriptor)) {
descriptor.__destrObj = {
set value(v) {
descriptor.set.call(receiver, v);
}
};
}
return descriptor.__destrObj;
} else {
if (!descriptor.writable) {
throw new TypeError("attempted to set read only private field");
}
return descriptor;
}
}
module.exports = _classPrivateFieldDestructureSet;
-15
View File
@@ -1,15 +0,0 @@
function _classPrivateFieldGet(receiver, privateMap) {
var descriptor = privateMap.get(receiver);
if (!descriptor) {
throw new TypeError("attempted to get private field on non-instance");
}
if (descriptor.get) {
return descriptor.get.call(receiver);
}
return descriptor.value;
}
module.exports = _classPrivateFieldGet;
-9
View File
@@ -1,9 +0,0 @@
function _classPrivateFieldBase(receiver, privateKey) {
if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {
throw new TypeError("attempted to use private field on non-instance");
}
return receiver;
}
module.exports = _classPrivateFieldBase;
-7
View File
@@ -1,7 +0,0 @@
var id = 0;
function _classPrivateFieldKey(name) {
return "__private_" + id++ + "_" + name;
}
module.exports = _classPrivateFieldKey;
-21
View File
@@ -1,21 +0,0 @@
function _classPrivateFieldSet(receiver, privateMap, value) {
var descriptor = privateMap.get(receiver);
if (!descriptor) {
throw new TypeError("attempted to set private field on non-instance");
}
if (descriptor.set) {
descriptor.set.call(receiver, value);
} else {
if (!descriptor.writable) {
throw new TypeError("attempted to set read only private field");
}
descriptor.value = value;
}
return value;
}
module.exports = _classPrivateFieldSet;
-9
View File
@@ -1,9 +0,0 @@
function _classPrivateMethodGet(receiver, privateSet, fn) {
if (!privateSet.has(receiver)) {
throw new TypeError("attempted to get private field on non-instance");
}
return fn;
}
module.exports = _classPrivateMethodGet;
-5
View File
@@ -1,5 +0,0 @@
function _classPrivateMethodSet() {
throw new TypeError("attempted to reassign private method");
}
module.exports = _classPrivateMethodSet;
-13
View File
@@ -1,13 +0,0 @@
function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) {
if (receiver !== classConstructor) {
throw new TypeError("Private static access of wrong provenance");
}
if (descriptor.get) {
return descriptor.get.call(receiver);
}
return descriptor.value;
}
module.exports = _classStaticPrivateFieldSpecGet;
-19
View File
@@ -1,19 +0,0 @@
function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) {
if (receiver !== classConstructor) {
throw new TypeError("Private static access of wrong provenance");
}
if (descriptor.set) {
descriptor.set.call(receiver, value);
} else {
if (!descriptor.writable) {
throw new TypeError("attempted to set read only private field");
}
descriptor.value = value;
}
return value;
}
module.exports = _classStaticPrivateFieldSpecSet;
-9
View File
@@ -1,9 +0,0 @@
function _classStaticPrivateMethodGet(receiver, classConstructor, method) {
if (receiver !== classConstructor) {
throw new TypeError("Private static access of wrong provenance");
}
return method;
}
module.exports = _classStaticPrivateMethodGet;
-5
View File
@@ -1,5 +0,0 @@
function _classStaticPrivateMethodSet() {
throw new TypeError("attempted to set read only static private field");
}
module.exports = _classStaticPrivateMethodSet;
-22
View File
@@ -1,22 +0,0 @@
var setPrototypeOf = require("./setPrototypeOf");
var isNativeReflectConstruct = require("./isNativeReflectConstruct");
function _construct(Parent, args, Class) {
if (isNativeReflectConstruct()) {
module.exports = _construct = Reflect.construct;
} else {
module.exports = _construct = function _construct(Parent, args, Class) {
var a = [null];
a.push.apply(a, args);
var Constructor = Function.bind.apply(Parent, a);
var instance = new Constructor();
if (Class) setPrototypeOf(instance, Class.prototype);
return instance;
};
}
return _construct.apply(null, arguments);
}
module.exports = _construct;
-17
View File
@@ -1,17 +0,0 @@
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
module.exports = _createClass;
-60
View File
@@ -1,60 +0,0 @@
var unsupportedIterableToArray = require("./unsupportedIterableToArray");
function _createForOfIteratorHelper(o, allowArrayLike) {
var it;
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
if (Array.isArray(o) || (it = unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;
var F = function F() {};
return {
s: F,
n: function n() {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
},
e: function e(_e) {
throw _e;
},
f: F
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var normalCompletion = true,
didErr = false,
err;
return {
s: function s() {
it = o[Symbol.iterator]();
},
n: function n() {
var step = it.next();
normalCompletion = step.done;
return step;
},
e: function e(_e2) {
didErr = true;
err = _e2;
},
f: function f() {
try {
if (!normalCompletion && it["return"] != null) it["return"]();
} finally {
if (didErr) throw err;
}
}
};
}
module.exports = _createForOfIteratorHelper;
-28
View File
@@ -1,28 +0,0 @@
var unsupportedIterableToArray = require("./unsupportedIterableToArray");
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
var it;
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
if (Array.isArray(o) || (it = unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;
return function () {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
it = o[Symbol.iterator]();
return it.next.bind(it);
}
module.exports = _createForOfIteratorHelperLoose;
-24
View File
@@ -1,24 +0,0 @@
var getPrototypeOf = require("./getPrototypeOf");
var isNativeReflectConstruct = require("./isNativeReflectConstruct");
var possibleConstructorReturn = require("./possibleConstructorReturn");
function _createSuper(Derived) {
var hasNativeReflectConstruct = isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = getPrototypeOf(Derived),
result;
if (hasNativeReflectConstruct) {
var NewTarget = getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return possibleConstructorReturn(this, result);
};
}
module.exports = _createSuper;
-400
View File
@@ -1,400 +0,0 @@
var toArray = require("./toArray");
var toPropertyKey = require("./toPropertyKey");
function _decorate(decorators, factory, superClass, mixins) {
var api = _getDecoratorsApi();
if (mixins) {
for (var i = 0; i < mixins.length; i++) {
api = mixins[i](api);
}
}
var r = factory(function initialize(O) {
api.initializeInstanceElements(O, decorated.elements);
}, superClass);
var decorated = api.decorateClass(_coalesceClassElements(r.d.map(_createElementDescriptor)), decorators);
api.initializeClassElements(r.F, decorated.elements);
return api.runClassFinishers(r.F, decorated.finishers);
}
function _getDecoratorsApi() {
_getDecoratorsApi = function _getDecoratorsApi() {
return api;
};
var api = {
elementsDefinitionOrder: [["method"], ["field"]],
initializeInstanceElements: function initializeInstanceElements(O, elements) {
["method", "field"].forEach(function (kind) {
elements.forEach(function (element) {
if (element.kind === kind && element.placement === "own") {
this.defineClassElement(O, element);
}
}, this);
}, this);
},
initializeClassElements: function initializeClassElements(F, elements) {
var proto = F.prototype;
["method", "field"].forEach(function (kind) {
elements.forEach(function (element) {
var placement = element.placement;
if (element.kind === kind && (placement === "static" || placement === "prototype")) {
var receiver = placement === "static" ? F : proto;
this.defineClassElement(receiver, element);
}
}, this);
}, this);
},
defineClassElement: function defineClassElement(receiver, element) {
var descriptor = element.descriptor;
if (element.kind === "field") {
var initializer = element.initializer;
descriptor = {
enumerable: descriptor.enumerable,
writable: descriptor.writable,
configurable: descriptor.configurable,
value: initializer === void 0 ? void 0 : initializer.call(receiver)
};
}
Object.defineProperty(receiver, element.key, descriptor);
},
decorateClass: function decorateClass(elements, decorators) {
var newElements = [];
var finishers = [];
var placements = {
"static": [],
prototype: [],
own: []
};
elements.forEach(function (element) {
this.addElementPlacement(element, placements);
}, this);
elements.forEach(function (element) {
if (!_hasDecorators(element)) return newElements.push(element);
var elementFinishersExtras = this.decorateElement(element, placements);
newElements.push(elementFinishersExtras.element);
newElements.push.apply(newElements, elementFinishersExtras.extras);
finishers.push.apply(finishers, elementFinishersExtras.finishers);
}, this);
if (!decorators) {
return {
elements: newElements,
finishers: finishers
};
}
var result = this.decorateConstructor(newElements, decorators);
finishers.push.apply(finishers, result.finishers);
result.finishers = finishers;
return result;
},
addElementPlacement: function addElementPlacement(element, placements, silent) {
var keys = placements[element.placement];
if (!silent && keys.indexOf(element.key) !== -1) {
throw new TypeError("Duplicated element (" + element.key + ")");
}
keys.push(element.key);
},
decorateElement: function decorateElement(element, placements) {
var extras = [];
var finishers = [];
for (var decorators = element.decorators, i = decorators.length - 1; i >= 0; i--) {
var keys = placements[element.placement];
keys.splice(keys.indexOf(element.key), 1);
var elementObject = this.fromElementDescriptor(element);
var elementFinisherExtras = this.toElementFinisherExtras((0, decorators[i])(elementObject) || elementObject);
element = elementFinisherExtras.element;
this.addElementPlacement(element, placements);
if (elementFinisherExtras.finisher) {
finishers.push(elementFinisherExtras.finisher);
}
var newExtras = elementFinisherExtras.extras;
if (newExtras) {
for (var j = 0; j < newExtras.length; j++) {
this.addElementPlacement(newExtras[j], placements);
}
extras.push.apply(extras, newExtras);
}
}
return {
element: element,
finishers: finishers,
extras: extras
};
},
decorateConstructor: function decorateConstructor(elements, decorators) {
var finishers = [];
for (var i = decorators.length - 1; i >= 0; i--) {
var obj = this.fromClassDescriptor(elements);
var elementsAndFinisher = this.toClassDescriptor((0, decorators[i])(obj) || obj);
if (elementsAndFinisher.finisher !== undefined) {
finishers.push(elementsAndFinisher.finisher);
}
if (elementsAndFinisher.elements !== undefined) {
elements = elementsAndFinisher.elements;
for (var j = 0; j < elements.length - 1; j++) {
for (var k = j + 1; k < elements.length; k++) {
if (elements[j].key === elements[k].key && elements[j].placement === elements[k].placement) {
throw new TypeError("Duplicated element (" + elements[j].key + ")");
}
}
}
}
}
return {
elements: elements,
finishers: finishers
};
},
fromElementDescriptor: function fromElementDescriptor(element) {
var obj = {
kind: element.kind,
key: element.key,
placement: element.placement,
descriptor: element.descriptor
};
var desc = {
value: "Descriptor",
configurable: true
};
Object.defineProperty(obj, Symbol.toStringTag, desc);
if (element.kind === "field") obj.initializer = element.initializer;
return obj;
},
toElementDescriptors: function toElementDescriptors(elementObjects) {
if (elementObjects === undefined) return;
return toArray(elementObjects).map(function (elementObject) {
var element = this.toElementDescriptor(elementObject);
this.disallowProperty(elementObject, "finisher", "An element descriptor");
this.disallowProperty(elementObject, "extras", "An element descriptor");
return element;
}, this);
},
toElementDescriptor: function toElementDescriptor(elementObject) {
var kind = String(elementObject.kind);
if (kind !== "method" && kind !== "field") {
throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"');
}
var key = toPropertyKey(elementObject.key);
var placement = String(elementObject.placement);
if (placement !== "static" && placement !== "prototype" && placement !== "own") {
throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"');
}
var descriptor = elementObject.descriptor;
this.disallowProperty(elementObject, "elements", "An element descriptor");
var element = {
kind: kind,
key: key,
placement: placement,
descriptor: Object.assign({}, descriptor)
};
if (kind !== "field") {
this.disallowProperty(elementObject, "initializer", "A method descriptor");
} else {
this.disallowProperty(descriptor, "get", "The property descriptor of a field descriptor");
this.disallowProperty(descriptor, "set", "The property descriptor of a field descriptor");
this.disallowProperty(descriptor, "value", "The property descriptor of a field descriptor");
element.initializer = elementObject.initializer;
}
return element;
},
toElementFinisherExtras: function toElementFinisherExtras(elementObject) {
var element = this.toElementDescriptor(elementObject);
var finisher = _optionalCallableProperty(elementObject, "finisher");
var extras = this.toElementDescriptors(elementObject.extras);
return {
element: element,
finisher: finisher,
extras: extras
};
},
fromClassDescriptor: function fromClassDescriptor(elements) {
var obj = {
kind: "class",
elements: elements.map(this.fromElementDescriptor, this)
};
var desc = {
value: "Descriptor",
configurable: true
};
Object.defineProperty(obj, Symbol.toStringTag, desc);
return obj;
},
toClassDescriptor: function toClassDescriptor(obj) {
var kind = String(obj.kind);
if (kind !== "class") {
throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"');
}
this.disallowProperty(obj, "key", "A class descriptor");
this.disallowProperty(obj, "placement", "A class descriptor");
this.disallowProperty(obj, "descriptor", "A class descriptor");
this.disallowProperty(obj, "initializer", "A class descriptor");
this.disallowProperty(obj, "extras", "A class descriptor");
var finisher = _optionalCallableProperty(obj, "finisher");
var elements = this.toElementDescriptors(obj.elements);
return {
elements: elements,
finisher: finisher
};
},
runClassFinishers: function runClassFinishers(constructor, finishers) {
for (var i = 0; i < finishers.length; i++) {
var newConstructor = (0, finishers[i])(constructor);
if (newConstructor !== undefined) {
if (typeof newConstructor !== "function") {
throw new TypeError("Finishers must return a constructor.");
}
constructor = newConstructor;
}
}
return constructor;
},
disallowProperty: function disallowProperty(obj, name, objectType) {
if (obj[name] !== undefined) {
throw new TypeError(objectType + " can't have a ." + name + " property.");
}
}
};
return api;
}
function _createElementDescriptor(def) {
var key = toPropertyKey(def.key);
var descriptor;
if (def.kind === "method") {
descriptor = {
value: def.value,
writable: true,
configurable: true,
enumerable: false
};
} else if (def.kind === "get") {
descriptor = {
get: def.value,
configurable: true,
enumerable: false
};
} else if (def.kind === "set") {
descriptor = {
set: def.value,
configurable: true,
enumerable: false
};
} else if (def.kind === "field") {
descriptor = {
configurable: true,
writable: true,
enumerable: true
};
}
var element = {
kind: def.kind === "field" ? "field" : "method",
key: key,
placement: def["static"] ? "static" : def.kind === "field" ? "own" : "prototype",
descriptor: descriptor
};
if (def.decorators) element.decorators = def.decorators;
if (def.kind === "field") element.initializer = def.value;
return element;
}
function _coalesceGetterSetter(element, other) {
if (element.descriptor.get !== undefined) {
other.descriptor.get = element.descriptor.get;
} else {
other.descriptor.set = element.descriptor.set;
}
}
function _coalesceClassElements(elements) {
var newElements = [];
var isSameElement = function isSameElement(other) {
return other.kind === "method" && other.key === element.key && other.placement === element.placement;
};
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
var other;
if (element.kind === "method" && (other = newElements.find(isSameElement))) {
if (_isDataDescriptor(element.descriptor) || _isDataDescriptor(other.descriptor)) {
if (_hasDecorators(element) || _hasDecorators(other)) {
throw new ReferenceError("Duplicated methods (" + element.key + ") can't be decorated.");
}
other.descriptor = element.descriptor;
} else {
if (_hasDecorators(element)) {
if (_hasDecorators(other)) {
throw new ReferenceError("Decorators can't be placed on different accessors with for " + "the same property (" + element.key + ").");
}
other.decorators = element.decorators;
}
_coalesceGetterSetter(element, other);
}
} else {
newElements.push(element);
}
}
return newElements;
}
function _hasDecorators(element) {
return element.decorators && element.decorators.length;
}
function _isDataDescriptor(desc) {
return desc !== undefined && !(desc.value === undefined && desc.writable === undefined);
}
function _optionalCallableProperty(obj, name) {
var value = obj[name];
if (value !== undefined && typeof value !== "function") {
throw new TypeError("Expected '" + name + "' to be a function");
}
return value;
}
module.exports = _decorate;
-16
View File
@@ -1,16 +0,0 @@
function _defaults(obj, defaults) {
var keys = Object.getOwnPropertyNames(defaults);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var value = Object.getOwnPropertyDescriptor(defaults, key);
if (value && value.configurable && obj[key] === undefined) {
Object.defineProperty(obj, key, value);
}
}
return obj;
}
module.exports = _defaults;
-24
View File
@@ -1,24 +0,0 @@
function _defineEnumerableProperties(obj, descs) {
for (var key in descs) {
var desc = descs[key];
desc.configurable = desc.enumerable = true;
if ("value" in desc) desc.writable = true;
Object.defineProperty(obj, key, desc);
}
if (Object.getOwnPropertySymbols) {
var objectSymbols = Object.getOwnPropertySymbols(descs);
for (var i = 0; i < objectSymbols.length; i++) {
var sym = objectSymbols[i];
var desc = descs[sym];
desc.configurable = desc.enumerable = true;
if ("value" in desc) desc.writable = true;
Object.defineProperty(obj, sym, desc);
}
}
return obj;
}
module.exports = _defineEnumerableProperties;
-16
View File
@@ -1,16 +0,0 @@
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
module.exports = _defineProperty;
-97
View File
@@ -1,97 +0,0 @@
import AwaitValue from "./AwaitValue";
export default function AsyncGenerator(gen) {
var front, back;
function send(key, arg) {
return new Promise(function (resolve, reject) {
var request = {
key: key,
arg: arg,
resolve: resolve,
reject: reject,
next: null
};
if (back) {
back = back.next = request;
} else {
front = back = request;
resume(key, arg);
}
});
}
function resume(key, arg) {
try {
var result = gen[key](arg);
var value = result.value;
var wrappedAwait = value instanceof AwaitValue;
Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) {
if (wrappedAwait) {
resume(key === "return" ? "return" : "next", arg);
return;
}
settle(result.done ? "return" : "normal", arg);
}, function (err) {
resume("throw", err);
});
} catch (err) {
settle("throw", err);
}
}
function settle(type, value) {
switch (type) {
case "return":
front.resolve({
value: value,
done: true
});
break;
case "throw":
front.reject(value);
break;
default:
front.resolve({
value: value,
done: false
});
break;
}
front = front.next;
if (front) {
resume(front.key, front.arg);
} else {
back = null;
}
}
this._invoke = send;
if (typeof gen["return"] !== "function") {
this["return"] = undefined;
}
}
if (typeof Symbol === "function" && Symbol.asyncIterator) {
AsyncGenerator.prototype[Symbol.asyncIterator] = function () {
return this;
};
}
AsyncGenerator.prototype.next = function (arg) {
return this._invoke("next", arg);
};
AsyncGenerator.prototype["throw"] = function (arg) {
return this._invoke("throw", arg);
};
AsyncGenerator.prototype["return"] = function (arg) {
return this._invoke("return", arg);
};
-3
View File
@@ -1,3 +0,0 @@
export default function _AwaitValue(value) {
this.wrapped = value;
}
-28
View File
@@ -1,28 +0,0 @@
export default function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
var desc = {};
Object.keys(descriptor).forEach(function (key) {
desc[key] = descriptor[key];
});
desc.enumerable = !!desc.enumerable;
desc.configurable = !!desc.configurable;
if ('value' in desc || desc.initializer) {
desc.writable = true;
}
desc = decorators.slice().reverse().reduce(function (desc, decorator) {
return decorator(target, property, desc) || desc;
}, desc);
if (context && desc.initializer !== void 0) {
desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
desc.initializer = undefined;
}
if (desc.initializer === void 0) {
Object.defineProperty(target, property, desc);
desc = null;
}
return desc;
}
-9
View File
@@ -1,9 +0,0 @@
export default function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) {
arr2[i] = arr[i];
}
return arr2;
}
-3
View File
@@ -1,3 +0,0 @@
export default function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
-4
View File
@@ -1,4 +0,0 @@
import arrayLikeToArray from "./arrayLikeToArray";
export default function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return arrayLikeToArray(arr);
}
-7
View File
@@ -1,7 +0,0 @@
export default function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
-56
View File
@@ -1,56 +0,0 @@
export default function _asyncGeneratorDelegate(inner, awaitWrap) {
var iter = {},
waiting = false;
function pump(key, value) {
waiting = true;
value = new Promise(function (resolve) {
resolve(inner[key](value));
});
return {
done: false,
value: awaitWrap(value)
};
}
;
if (typeof Symbol === "function" && Symbol.iterator) {
iter[Symbol.iterator] = function () {
return this;
};
}
iter.next = function (value) {
if (waiting) {
waiting = false;
return value;
}
return pump("next", value);
};
if (typeof inner["throw"] === "function") {
iter["throw"] = function (value) {
if (waiting) {
waiting = false;
throw value;
}
return pump("throw", value);
};
}
if (typeof inner["return"] === "function") {
iter["return"] = function (value) {
if (waiting) {
waiting = false;
return value;
}
return pump("return", value);
};
}
return iter;
}
-17
View File
@@ -1,17 +0,0 @@
export default function _asyncIterator(iterable) {
var method;
if (typeof Symbol !== "undefined") {
if (Symbol.asyncIterator) {
method = iterable[Symbol.asyncIterator];
if (method != null) return method.call(iterable);
}
if (Symbol.iterator) {
method = iterable[Symbol.iterator];
if (method != null) return method.call(iterable);
}
}
throw new TypeError("Object is not async iterable");
}
-35
View File
@@ -1,35 +0,0 @@
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
export default function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
-4
View File
@@ -1,4 +0,0 @@
import AwaitValue from "./AwaitValue";
export default function _awaitAsyncGenerator(value) {
return new AwaitValue(value);
}
-5
View File
@@ -1,5 +0,0 @@
export default function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
-3
View File
@@ -1,3 +0,0 @@
export default function _classNameTDZError(name) {
throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys.");
}
@@ -1,26 +0,0 @@
export default function _classPrivateFieldDestructureSet(receiver, privateMap) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to set private field on non-instance");
}
var descriptor = privateMap.get(receiver);
if (descriptor.set) {
if (!("__destrObj" in descriptor)) {
descriptor.__destrObj = {
set value(v) {
descriptor.set.call(receiver, v);
}
};
}
return descriptor.__destrObj;
} else {
if (!descriptor.writable) {
throw new TypeError("attempted to set read only private field");
}
return descriptor;
}
}
-13
View File
@@ -1,13 +0,0 @@
export default function _classPrivateFieldGet(receiver, privateMap) {
var descriptor = privateMap.get(receiver);
if (!descriptor) {
throw new TypeError("attempted to get private field on non-instance");
}
if (descriptor.get) {
return descriptor.get.call(receiver);
}
return descriptor.value;
}
@@ -1,7 +0,0 @@
export default function _classPrivateFieldBase(receiver, privateKey) {
if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {
throw new TypeError("attempted to use private field on non-instance");
}
return receiver;
}
-4
View File
@@ -1,4 +0,0 @@
var id = 0;
export default function _classPrivateFieldKey(name) {
return "__private_" + id++ + "_" + name;
}
-19
View File
@@ -1,19 +0,0 @@
export default function _classPrivateFieldSet(receiver, privateMap, value) {
var descriptor = privateMap.get(receiver);
if (!descriptor) {
throw new TypeError("attempted to set private field on non-instance");
}
if (descriptor.set) {
descriptor.set.call(receiver, value);
} else {
if (!descriptor.writable) {
throw new TypeError("attempted to set read only private field");
}
descriptor.value = value;
}
return value;
}
-7
View File
@@ -1,7 +0,0 @@
export default function _classPrivateMethodGet(receiver, privateSet, fn) {
if (!privateSet.has(receiver)) {
throw new TypeError("attempted to get private field on non-instance");
}
return fn;
}
-3
View File
@@ -1,3 +0,0 @@
export default function _classPrivateMethodSet() {
throw new TypeError("attempted to reassign private method");
}
@@ -1,11 +0,0 @@
export default function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) {
if (receiver !== classConstructor) {
throw new TypeError("Private static access of wrong provenance");
}
if (descriptor.get) {
return descriptor.get.call(receiver);
}
return descriptor.value;
}
@@ -1,17 +0,0 @@
export default function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) {
if (receiver !== classConstructor) {
throw new TypeError("Private static access of wrong provenance");
}
if (descriptor.set) {
descriptor.set.call(receiver, value);
} else {
if (!descriptor.writable) {
throw new TypeError("attempted to set read only private field");
}
descriptor.value = value;
}
return value;
}
@@ -1,7 +0,0 @@
export default function _classStaticPrivateMethodGet(receiver, classConstructor, method) {
if (receiver !== classConstructor) {
throw new TypeError("Private static access of wrong provenance");
}
return method;
}
@@ -1,3 +0,0 @@
export default function _classStaticPrivateMethodSet() {
throw new TypeError("attempted to set read only static private field");
}
-18
View File
@@ -1,18 +0,0 @@
import setPrototypeOf from "./setPrototypeOf";
import isNativeReflectConstruct from "./isNativeReflectConstruct";
export default function _construct(Parent, args, Class) {
if (isNativeReflectConstruct()) {
_construct = Reflect.construct;
} else {
_construct = function _construct(Parent, args, Class) {
var a = [null];
a.push.apply(a, args);
var Constructor = Function.bind.apply(Parent, a);
var instance = new Constructor();
if (Class) setPrototypeOf(instance, Class.prototype);
return instance;
};
}
return _construct.apply(null, arguments);
}
-15
View File
@@ -1,15 +0,0 @@
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
export default function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
-57
View File
@@ -1,57 +0,0 @@
import unsupportedIterableToArray from "./unsupportedIterableToArray";
export default function _createForOfIteratorHelper(o, allowArrayLike) {
var it;
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
if (Array.isArray(o) || (it = unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;
var F = function F() {};
return {
s: F,
n: function n() {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
},
e: function e(_e) {
throw _e;
},
f: F
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var normalCompletion = true,
didErr = false,
err;
return {
s: function s() {
it = o[Symbol.iterator]();
},
n: function n() {
var step = it.next();
normalCompletion = step.done;
return step;
},
e: function e(_e2) {
didErr = true;
err = _e2;
},
f: function f() {
try {
if (!normalCompletion && it["return"] != null) it["return"]();
} finally {
if (didErr) throw err;
}
}
};
}
@@ -1,25 +0,0 @@
import unsupportedIterableToArray from "./unsupportedIterableToArray";
export default function _createForOfIteratorHelperLoose(o, allowArrayLike) {
var it;
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
if (Array.isArray(o) || (it = unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;
return function () {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
it = o[Symbol.iterator]();
return it.next.bind(it);
}
-19
View File
@@ -1,19 +0,0 @@
import getPrototypeOf from "./getPrototypeOf";
import isNativeReflectConstruct from "./isNativeReflectConstruct";
import possibleConstructorReturn from "./possibleConstructorReturn";
export default function _createSuper(Derived) {
var hasNativeReflectConstruct = isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = getPrototypeOf(Derived),
result;
if (hasNativeReflectConstruct) {
var NewTarget = getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return possibleConstructorReturn(this, result);
};
}
-396
View File
@@ -1,396 +0,0 @@
import toArray from "./toArray";
import toPropertyKey from "./toPropertyKey";
export default function _decorate(decorators, factory, superClass, mixins) {
var api = _getDecoratorsApi();
if (mixins) {
for (var i = 0; i < mixins.length; i++) {
api = mixins[i](api);
}
}
var r = factory(function initialize(O) {
api.initializeInstanceElements(O, decorated.elements);
}, superClass);
var decorated = api.decorateClass(_coalesceClassElements(r.d.map(_createElementDescriptor)), decorators);
api.initializeClassElements(r.F, decorated.elements);
return api.runClassFinishers(r.F, decorated.finishers);
}
function _getDecoratorsApi() {
_getDecoratorsApi = function _getDecoratorsApi() {
return api;
};
var api = {
elementsDefinitionOrder: [["method"], ["field"]],
initializeInstanceElements: function initializeInstanceElements(O, elements) {
["method", "field"].forEach(function (kind) {
elements.forEach(function (element) {
if (element.kind === kind && element.placement === "own") {
this.defineClassElement(O, element);
}
}, this);
}, this);
},
initializeClassElements: function initializeClassElements(F, elements) {
var proto = F.prototype;
["method", "field"].forEach(function (kind) {
elements.forEach(function (element) {
var placement = element.placement;
if (element.kind === kind && (placement === "static" || placement === "prototype")) {
var receiver = placement === "static" ? F : proto;
this.defineClassElement(receiver, element);
}
}, this);
}, this);
},
defineClassElement: function defineClassElement(receiver, element) {
var descriptor = element.descriptor;
if (element.kind === "field") {
var initializer = element.initializer;
descriptor = {
enumerable: descriptor.enumerable,
writable: descriptor.writable,
configurable: descriptor.configurable,
value: initializer === void 0 ? void 0 : initializer.call(receiver)
};
}
Object.defineProperty(receiver, element.key, descriptor);
},
decorateClass: function decorateClass(elements, decorators) {
var newElements = [];
var finishers = [];
var placements = {
"static": [],
prototype: [],
own: []
};
elements.forEach(function (element) {
this.addElementPlacement(element, placements);
}, this);
elements.forEach(function (element) {
if (!_hasDecorators(element)) return newElements.push(element);
var elementFinishersExtras = this.decorateElement(element, placements);
newElements.push(elementFinishersExtras.element);
newElements.push.apply(newElements, elementFinishersExtras.extras);
finishers.push.apply(finishers, elementFinishersExtras.finishers);
}, this);
if (!decorators) {
return {
elements: newElements,
finishers: finishers
};
}
var result = this.decorateConstructor(newElements, decorators);
finishers.push.apply(finishers, result.finishers);
result.finishers = finishers;
return result;
},
addElementPlacement: function addElementPlacement(element, placements, silent) {
var keys = placements[element.placement];
if (!silent && keys.indexOf(element.key) !== -1) {
throw new TypeError("Duplicated element (" + element.key + ")");
}
keys.push(element.key);
},
decorateElement: function decorateElement(element, placements) {
var extras = [];
var finishers = [];
for (var decorators = element.decorators, i = decorators.length - 1; i >= 0; i--) {
var keys = placements[element.placement];
keys.splice(keys.indexOf(element.key), 1);
var elementObject = this.fromElementDescriptor(element);
var elementFinisherExtras = this.toElementFinisherExtras((0, decorators[i])(elementObject) || elementObject);
element = elementFinisherExtras.element;
this.addElementPlacement(element, placements);
if (elementFinisherExtras.finisher) {
finishers.push(elementFinisherExtras.finisher);
}
var newExtras = elementFinisherExtras.extras;
if (newExtras) {
for (var j = 0; j < newExtras.length; j++) {
this.addElementPlacement(newExtras[j], placements);
}
extras.push.apply(extras, newExtras);
}
}
return {
element: element,
finishers: finishers,
extras: extras
};
},
decorateConstructor: function decorateConstructor(elements, decorators) {
var finishers = [];
for (var i = decorators.length - 1; i >= 0; i--) {
var obj = this.fromClassDescriptor(elements);
var elementsAndFinisher = this.toClassDescriptor((0, decorators[i])(obj) || obj);
if (elementsAndFinisher.finisher !== undefined) {
finishers.push(elementsAndFinisher.finisher);
}
if (elementsAndFinisher.elements !== undefined) {
elements = elementsAndFinisher.elements;
for (var j = 0; j < elements.length - 1; j++) {
for (var k = j + 1; k < elements.length; k++) {
if (elements[j].key === elements[k].key && elements[j].placement === elements[k].placement) {
throw new TypeError("Duplicated element (" + elements[j].key + ")");
}
}
}
}
}
return {
elements: elements,
finishers: finishers
};
},
fromElementDescriptor: function fromElementDescriptor(element) {
var obj = {
kind: element.kind,
key: element.key,
placement: element.placement,
descriptor: element.descriptor
};
var desc = {
value: "Descriptor",
configurable: true
};
Object.defineProperty(obj, Symbol.toStringTag, desc);
if (element.kind === "field") obj.initializer = element.initializer;
return obj;
},
toElementDescriptors: function toElementDescriptors(elementObjects) {
if (elementObjects === undefined) return;
return toArray(elementObjects).map(function (elementObject) {
var element = this.toElementDescriptor(elementObject);
this.disallowProperty(elementObject, "finisher", "An element descriptor");
this.disallowProperty(elementObject, "extras", "An element descriptor");
return element;
}, this);
},
toElementDescriptor: function toElementDescriptor(elementObject) {
var kind = String(elementObject.kind);
if (kind !== "method" && kind !== "field") {
throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"');
}
var key = toPropertyKey(elementObject.key);
var placement = String(elementObject.placement);
if (placement !== "static" && placement !== "prototype" && placement !== "own") {
throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"');
}
var descriptor = elementObject.descriptor;
this.disallowProperty(elementObject, "elements", "An element descriptor");
var element = {
kind: kind,
key: key,
placement: placement,
descriptor: Object.assign({}, descriptor)
};
if (kind !== "field") {
this.disallowProperty(elementObject, "initializer", "A method descriptor");
} else {
this.disallowProperty(descriptor, "get", "The property descriptor of a field descriptor");
this.disallowProperty(descriptor, "set", "The property descriptor of a field descriptor");
this.disallowProperty(descriptor, "value", "The property descriptor of a field descriptor");
element.initializer = elementObject.initializer;
}
return element;
},
toElementFinisherExtras: function toElementFinisherExtras(elementObject) {
var element = this.toElementDescriptor(elementObject);
var finisher = _optionalCallableProperty(elementObject, "finisher");
var extras = this.toElementDescriptors(elementObject.extras);
return {
element: element,
finisher: finisher,
extras: extras
};
},
fromClassDescriptor: function fromClassDescriptor(elements) {
var obj = {
kind: "class",
elements: elements.map(this.fromElementDescriptor, this)
};
var desc = {
value: "Descriptor",
configurable: true
};
Object.defineProperty(obj, Symbol.toStringTag, desc);
return obj;
},
toClassDescriptor: function toClassDescriptor(obj) {
var kind = String(obj.kind);
if (kind !== "class") {
throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"');
}
this.disallowProperty(obj, "key", "A class descriptor");
this.disallowProperty(obj, "placement", "A class descriptor");
this.disallowProperty(obj, "descriptor", "A class descriptor");
this.disallowProperty(obj, "initializer", "A class descriptor");
this.disallowProperty(obj, "extras", "A class descriptor");
var finisher = _optionalCallableProperty(obj, "finisher");
var elements = this.toElementDescriptors(obj.elements);
return {
elements: elements,
finisher: finisher
};
},
runClassFinishers: function runClassFinishers(constructor, finishers) {
for (var i = 0; i < finishers.length; i++) {
var newConstructor = (0, finishers[i])(constructor);
if (newConstructor !== undefined) {
if (typeof newConstructor !== "function") {
throw new TypeError("Finishers must return a constructor.");
}
constructor = newConstructor;
}
}
return constructor;
},
disallowProperty: function disallowProperty(obj, name, objectType) {
if (obj[name] !== undefined) {
throw new TypeError(objectType + " can't have a ." + name + " property.");
}
}
};
return api;
}
function _createElementDescriptor(def) {
var key = toPropertyKey(def.key);
var descriptor;
if (def.kind === "method") {
descriptor = {
value: def.value,
writable: true,
configurable: true,
enumerable: false
};
} else if (def.kind === "get") {
descriptor = {
get: def.value,
configurable: true,
enumerable: false
};
} else if (def.kind === "set") {
descriptor = {
set: def.value,
configurable: true,
enumerable: false
};
} else if (def.kind === "field") {
descriptor = {
configurable: true,
writable: true,
enumerable: true
};
}
var element = {
kind: def.kind === "field" ? "field" : "method",
key: key,
placement: def["static"] ? "static" : def.kind === "field" ? "own" : "prototype",
descriptor: descriptor
};
if (def.decorators) element.decorators = def.decorators;
if (def.kind === "field") element.initializer = def.value;
return element;
}
function _coalesceGetterSetter(element, other) {
if (element.descriptor.get !== undefined) {
other.descriptor.get = element.descriptor.get;
} else {
other.descriptor.set = element.descriptor.set;
}
}
function _coalesceClassElements(elements) {
var newElements = [];
var isSameElement = function isSameElement(other) {
return other.kind === "method" && other.key === element.key && other.placement === element.placement;
};
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
var other;
if (element.kind === "method" && (other = newElements.find(isSameElement))) {
if (_isDataDescriptor(element.descriptor) || _isDataDescriptor(other.descriptor)) {
if (_hasDecorators(element) || _hasDecorators(other)) {
throw new ReferenceError("Duplicated methods (" + element.key + ") can't be decorated.");
}
other.descriptor = element.descriptor;
} else {
if (_hasDecorators(element)) {
if (_hasDecorators(other)) {
throw new ReferenceError("Decorators can't be placed on different accessors with for " + "the same property (" + element.key + ").");
}
other.decorators = element.decorators;
}
_coalesceGetterSetter(element, other);
}
} else {
newElements.push(element);
}
}
return newElements;
}
function _hasDecorators(element) {
return element.decorators && element.decorators.length;
}
function _isDataDescriptor(desc) {
return desc !== undefined && !(desc.value === undefined && desc.writable === undefined);
}
function _optionalCallableProperty(obj, name) {
var value = obj[name];
if (value !== undefined && typeof value !== "function") {
throw new TypeError("Expected '" + name + "' to be a function");
}
return value;
}
-14
View File
@@ -1,14 +0,0 @@
export default function _defaults(obj, defaults) {
var keys = Object.getOwnPropertyNames(defaults);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var value = Object.getOwnPropertyDescriptor(defaults, key);
if (value && value.configurable && obj[key] === undefined) {
Object.defineProperty(obj, key, value);
}
}
return obj;
}
-22
View File
@@ -1,22 +0,0 @@
export default function _defineEnumerableProperties(obj, descs) {
for (var key in descs) {
var desc = descs[key];
desc.configurable = desc.enumerable = true;
if ("value" in desc) desc.writable = true;
Object.defineProperty(obj, key, desc);
}
if (Object.getOwnPropertySymbols) {
var objectSymbols = Object.getOwnPropertySymbols(descs);
for (var i = 0; i < objectSymbols.length; i++) {
var sym = objectSymbols[i];
var desc = descs[sym];
desc.configurable = desc.enumerable = true;
if ("value" in desc) desc.writable = true;
Object.defineProperty(obj, sym, desc);
}
}
return obj;
}
-14
View File
@@ -1,14 +0,0 @@
export default function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
-17
View File
@@ -1,17 +0,0 @@
export default function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
-20
View File
@@ -1,20 +0,0 @@
import superPropBase from "./superPropBase";
export default function _get(target, property, receiver) {
if (typeof Reflect !== "undefined" && Reflect.get) {
_get = Reflect.get;
} else {
_get = function _get(target, property, receiver) {
var base = superPropBase(target, property);
if (!base) return;
var desc = Object.getOwnPropertyDescriptor(base, property);
if (desc.get) {
return desc.get.call(receiver);
}
return desc.value;
};
}
return _get(target, property, receiver || target);
}
-6
View File
@@ -1,6 +0,0 @@
export default function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
-15
View File
@@ -1,15 +0,0 @@
import setPrototypeOf from "./setPrototypeOf";
export default function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) setPrototypeOf(subClass, superClass);
}
-5
View File
@@ -1,5 +0,0 @@
export default function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
-9
View File
@@ -1,9 +0,0 @@
export default function _initializerDefineProperty(target, property, descriptor, context) {
if (!descriptor) return;
Object.defineProperty(target, property, {
enumerable: descriptor.enumerable,
configurable: descriptor.configurable,
writable: descriptor.writable,
value: descriptor.initializer ? descriptor.initializer.call(context) : void 0
});
}
-3
View File
@@ -1,3 +0,0 @@
export default function _initializerWarningHelper(descriptor, context) {
throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.');
}
-7
View File
@@ -1,7 +0,0 @@
export default function _instanceof(left, right) {
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
return !!right[Symbol.hasInstance](left);
} else {
return left instanceof right;
}
}
-5
View File
@@ -1,5 +0,0 @@
export default function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
"default": obj
};
}

Some files were not shown because too many files have changed in this diff Show More