diff --git a/config.toml b/config.toml index d823812c..e5e7513b 100644 --- a/config.toml +++ b/config.toml @@ -9,6 +9,7 @@ SeedRatioStop = 1.50 #automatically stops the torrent after it reaches this seeding ratio #Relative or absolute path accepted, the server will convert any relative path to an absolute path. DefaultMoveFolder = 'downloaded' #default path that a finished torrent is symlinked to after completion. Torrents added via RSS will default here + TorrentWatchFolder = 'torrentUpload' #folder path that is watched for .torrent files and adds them automatically every 5 minutes [notifications] diff --git a/engine/cronJobs.go b/engine/cronJobs.go index df87ebfb..ce4541cb 100644 --- a/engine/cronJobs.go +++ b/engine/cronJobs.go @@ -1,6 +1,10 @@ package engine import ( + "io/ioutil" + "os" + "path/filepath" + "github.com/anacrolix/torrent" "github.com/asdine/storm" Storage "github.com/deranjer/goTorrent/storage" @@ -19,8 +23,37 @@ func InitializeCronEngine() *cron.Cron { return c } +//CheckTorrentWatchFolder adds torrents from a watch folder //TODO see if you can use filepath.Abs instead of changing directory +func CheckTorrentWatchFolder(c *cron.Cron, db *storm.DB, tclient *torrent.Client, torrentLocalStorage Storage.TorrentLocal, config FullClientSettings) { + c.AddFunc("@every 5m", func() { + Logger.WithFields(logrus.Fields{"Watch Folder": config.TorrentWatchFolder}).Info("Running the watch folder cron job") + torrentFiles, err := ioutil.ReadDir(config.TorrentWatchFolder) + if err != nil { + Logger.WithFields(logrus.Fields{"Folder": config.TorrentWatchFolder, "Error": err}).Error("Unable to read from the torrent upload folder") + return + } + for _, file := range torrentFiles { + if filepath.Ext(file.Name()) != ".torrent" { + Logger.WithFields(logrus.Fields{"File": file.Name(), "error": err}).Error("Not a torrent file..") + } else { + fullFilePath := filepath.Join(config.TorrentWatchFolder, file.Name()) + clientTorrent, err := tclient.AddTorrentFromFile(fullFilePath) + if err != nil { + Logger.WithFields(logrus.Fields{"err": err, "Torrent": file.Name()}).Warn("Unable to add torrent to torrent client!") + break //break out of the loop entirely for this message since we hit an error + } + fullNewFilePath := filepath.Join(config.TFileUploadFolder, file.Name()) + StartTorrent(clientTorrent, torrentLocalStorage, db, config.TorrentConfig.DataDir, "file", file.Name(), config.DefaultMoveFolder) + CopyFile(fullFilePath, fullNewFilePath) + os.Remove(fullFilePath) //delete the torrent after adding it and copying it over + Logger.WithFields(logrus.Fields{"Source Folder": config.TorrentWatchFolder, "Destination Folder": config.TFileUploadFolder, "Torrent": file.Name()}).Info("Added torrent from watch folder, and moved torrent file") + } + } + }) +} + //RefreshRSSCron refreshes all of the RSS feeds on an hourly basis -func RefreshRSSCron(c *cron.Cron, db *storm.DB, tclient *torrent.Client, torrentLocalStorage Storage.TorrentLocal, dataDir string) { +func RefreshRSSCron(c *cron.Cron, db *storm.DB, tclient *torrent.Client, torrentLocalStorage Storage.TorrentLocal, config FullClientSettings) { c.AddFunc("@hourly", func() { torrentHashHistory := Storage.FetchHashHistory(db) RSSFeedStore := Storage.FetchRSSFeeds(db) @@ -48,7 +81,7 @@ func RefreshRSSCron(c *cron.Cron, db *storm.DB, tclient *torrent.Client, torrent Logger.WithFields(logrus.Fields{"err": err, "Torrent": RSSTorrent.Title}).Warn("Unable to add torrent to torrent client!") break //break out of the loop entirely for this message since we hit an error } - StartTorrent(clientTorrent, torrentLocalStorage, db, dataDir, "magnet", "", dataDir) //TODO let user specify torrent default storage location and let change on fly + StartTorrent(clientTorrent, torrentLocalStorage, db, config.TorrentConfig.DataDir, "magnet", "", config.DefaultMoveFolder) //TODO let user specify torrent default storage location and let change on fly singleFeed.Torrents = append(singleFeed.Torrents, singleRSSTorrent) } diff --git a/engine/engineMaths.go b/engine/engineHelpers.go similarity index 84% rename from engine/engineMaths.go rename to engine/engineHelpers.go index 3dc0c2c2..58375cd0 100644 --- a/engine/engineMaths.go +++ b/engine/engineHelpers.go @@ -2,10 +2,13 @@ package engine import ( "fmt" + "io" + "os" "time" "github.com/anacrolix/torrent" "github.com/deranjer/goTorrent/storage" + "github.com/sirupsen/logrus" ) func secondsToMinutes(inSeconds int64) string { @@ -35,6 +38,25 @@ func HumanizeBytes(bytes float32) string { return pBytes } +//CopyFile takes a source file string and a destination file string and copies the file +func CopyFile(srcFile string, destFile string) { + fileContents, err := os.Open(srcFile) + defer fileContents.Close() + if err != nil { + Logger.WithFields(logrus.Fields{"File": srcFile, "Error": err}).Error("Cannot open source file") + } + outfileContents, err := os.Open(destFile) + defer outfileContents.Close() + if err != nil { + Logger.WithFields(logrus.Fields{"File": destFile, "Error": err}).Error("Cannot open destination file") + } + _, err = io.Copy(outfileContents, fileContents) + if err != nil { + Logger.WithFields(logrus.Fields{"Source File": srcFile, "Destination File": destFile, "Error": err}).Error("Cannot write contents to destination file") + } + +} + //CalculateTorrentSpeed is used to calculate the torrent upload and download speed over time c is current clientdb, oc is last client db to calculate speed over time func CalculateTorrentSpeed(t *torrent.Torrent, c *ClientDB, oc ClientDB) { now := time.Now() diff --git a/engine/settings.go b/engine/settings.go index e2bab239..f9b92486 100644 --- a/engine/settings.go +++ b/engine/settings.go @@ -13,15 +13,16 @@ import ( //FullClientSettings contains all of the settings for our entire application type FullClientSettings struct { - LoggingLevel logrus.Level - LoggingOutput string - HTTPAddr string - Version int - TorrentConfig torrent.Config - TFileUploadFolder string - SeedRatioStop float64 - PushBulletToken string - DefaultMoveFolder string + LoggingLevel logrus.Level + LoggingOutput string + HTTPAddr string + Version int + TorrentConfig torrent.Config + TFileUploadFolder string + SeedRatioStop float64 + PushBulletToken string + DefaultMoveFolder string + TorrentWatchFolder string } //default is called if there is a parsing error @@ -71,6 +72,11 @@ func FullClientSettingsNew() FullClientSettings { if err != nil { fmt.Println("Failed creating absolute path for defaultMoveFolder", err) } + torrentWatchFolder := filepath.ToSlash(viper.GetString("serverConfig.TorrentWatchFolder")) + torrentWatchFolderAbs, err := filepath.Abs(torrentWatchFolder) + if err != nil { + fmt.Println("Failed creating absolute path for torrentWatchFolderAbs", err) + } dataDir := filepath.ToSlash(viper.GetString("torrentClientConfig.DownloadDir")) //Converting the string literal into a filepath dataDirAbs, err := filepath.Abs(dataDir) //Converting to an absolute file path @@ -149,14 +155,15 @@ func FullClientSettingsNew() FullClientSettings { } Config := FullClientSettings{ - LoggingLevel: logLevel, - LoggingOutput: logOutput, - SeedRatioStop: seedRatioStop, - HTTPAddr: httpAddr, - TorrentConfig: tConfig, - TFileUploadFolder: "uploadedTorrents", - PushBulletToken: pushBulletToken, - DefaultMoveFolder: defaultMoveFolderAbs, + LoggingLevel: logLevel, + LoggingOutput: logOutput, + SeedRatioStop: seedRatioStop, + HTTPAddr: httpAddr, + TorrentConfig: tConfig, + TFileUploadFolder: "uploadedTorrents", + PushBulletToken: pushBulletToken, + DefaultMoveFolder: defaultMoveFolderAbs, + TorrentWatchFolder: torrentWatchFolderAbs, } return Config diff --git a/goTorrentWebUI/node_modules/attr-accept/package.json b/goTorrentWebUI/node_modules/attr-accept/package.json index bcbbeeab..fefb7662 100644 --- a/goTorrentWebUI/node_modules/attr-accept/package.json +++ b/goTorrentWebUI/node_modules/attr-accept/package.json @@ -22,8 +22,7 @@ "fetchSpec": "1.1.0" }, "_requiredBy": [ - "/", - "/react-dropzone" + "/" ], "_resolved": "https://registry.npmjs.org/attr-accept/-/attr-accept-1.1.0.tgz", "_spec": "1.1.0", diff --git a/goTorrentWebUI/node_modules/react-toastify/.eslintignore b/goTorrentWebUI/node_modules/react-toastify/.eslintignore new file mode 100644 index 00000000..6de001d8 --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/.eslintignore @@ -0,0 +1 @@ +webpack.config.js diff --git a/goTorrentWebUI/node_modules/react-toastify/.travis.yml b/goTorrentWebUI/node_modules/react-toastify/.travis.yml new file mode 100644 index 00000000..2648d71e --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - "8" +script: + - yarn lint && yarn test:coverage \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/LICENSE b/goTorrentWebUI/node_modules/react-toastify/LICENSE new file mode 100644 index 00000000..8561b316 --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Fadi Khadra + +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. \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/README.md b/goTorrentWebUI/node_modules/react-toastify/README.md new file mode 100644 index 00000000..3933aaf5 --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/README.md @@ -0,0 +1,1093 @@ +# React Toastify [![Build Status](https://travis-ci.org/fkhadra/react-toastify.svg?branch=master)](https://travis-ci.org/fkhadra/react-toastify) [![npm](https://img.shields.io/npm/dm/react-toastify.svg)]() [![npm](https://img.shields.io/npm/v/react-toastify.svg)]() [![license](https://img.shields.io/github/license/fkhadra/react-toastify.svg?maxAge=2592000)]() [![Coverage Status](https://coveralls.io/repos/github/fkhadra/react-toastify/badge.svg?branch=master)](https://coveralls.io/github/fkhadra/react-toastify?branch=master) + +![React toastify](https://user-images.githubusercontent.com/5574267/28753331-1380a2f0-7534-11e7-8456-0b32e959db07.gif "React toastify") + + +🎉 React-Toastify allow you to add notification to your app with ease. No bullshit ! + +* [Demo](#demo) +* [Installation](#installation) +* [Features](#features) +* [Migrate from v2 to v3](#migrate-from-v2-to-v3) +* [Usage](#usage) + + [One component to rule them all](#one-component-to-rule-them-all) + + [Positioning toast](#positioning-toast) + + [Set autoclose delay or disable it](#set-autoclose-delay-or-disable-it) + + [Render a component](#render-a-component) + + [Remove a toast programmatically](#remove-a-toast-programmatically) + + [Prevent duplicate](#prevent-duplicate) + + [Update a toast](#update-a-toast) + - [Basic example](#basic-example) + - [Update the content](#update-the-content) + - [ :sparkles: Apply a transition](#apply-a-transition) + - [Reset option or inherit from ToastContainer](#reset-option-or-inherit-from-ToastContainer) + + [Define hook](#define-hook) + + [Set a custom close button or simply remove it](#set-a-custom-close-button-or-simply-remove-it) + - [Override the default one](#override-the-default-one) + - [Define it per toast](#define-it-per-toast) + - [Remove it](#remove-it) + + [Add an undo option to a toast](#add-an-undo-option-to-a-toast) + + [ :sparkles: Define a custom enter and exit transition](#define-a-custom-enter-and-exit-transition) + + [Le style](#le-style) + - [Replace default style](#replace-default-style) + - [Style with className](#style-with-classname) + + [Mobile](#mobile) +* [Api](#api) + + [ToastContainer](#toastcontainer) + + [toast](#toast) +* [Browser Support](#browser-support) +* [Release Notes](#release-notes) +* [Contribute](#contribute) +* [License](#license) + +## Demo + +[A demo is worth thousand word](https://fkhadra.github.io/react-toastify/) + +## Installation + +``` +$ npm install --save react-toastify +$ yarn add react-toastify +``` + +## Features + +- Easy to setup for real, you can make it works in less than 10sec ! +- Super easy to customize +- Can display a react component inside the toast ! +- Don't rely on `findDOMNode` or any DOM hack +- Has ```onOpen``` and ```onClose``` hooks. Both can access the props passed to the react component rendered inside the toast +- Can remove a toast programmatically +- Define behavior per toast +- Use glamor for styling 💅 +- Pause toast when the browser is not visible thanks to visibility api +- Fancy progress bar to display the remaining time +- Possibility to update a toast + +## Migrate from v2 to v3 + +The v3 rely on glamor for styling. Using css classes is still fine but +you may need to replace your css classes by a glamor rule in some case. + +No more css file to import ! + +A style helper has been added to mimic the old sass variables. + +## Usage + +### One component to rule them all + +By default all toasts will inherits ToastContainer's props. **Props defined on toast supersede ToastContainer's props.** + +```javascript + import React, { Component } from 'react'; + import { ToastContainer, toast } from 'react-toastify'; + + class App extends Component { + notify = () => toast("Wow so easy !"); + + render(){ + return ( +
+ + +
+ ); + } + } +``` + +### Positioning toast + +By default all the toasts will be positionned on the top right of your browser. If a position is set on a toast, the one defined on ToastContainer will be replaced. + +The following values are allowed: **top-right, top-center, top-left, bottom-right, bottom-center, bottom-left** + +For convenience, toast expose a POSITION property to avoid any typo. + +```javascript + // toast.POSITION.TOP_LEFT, toast.POSITION.TOP_RIGHT, toast.POSITION.TOP_CENTER + // toast.POSITION.BOTTOM_LEFT,toast.POSITION.BOTTOM_RIGHT, toast.POSITION.BOTTOM_CENTER + + import React, { Component } from 'react'; + import { toast } from 'react-toastify'; + import { css } from 'glamor'; + + class Position extends Component { + notify = () => { + toast("Default Notification !"); + toast.success("Success Notification !", { + position: toast.POSITION.TOP_CENTER + }); + toast.error("Error Notification !", { + position: toast.POSITION.TOP_LEFT + }); + toast.warn("Warning Notification !", { + position: toast.POSITION.BOTTOM_LEFT + }); + toast.info("Info Notification !", { + position: toast.POSITION.BOTTOM_CENTER + }); + toast("Custom Style Notification !", { + position: toast.POSITION.BOTTOM_RIGHT, + className: css({ + background: "black" + }) + }); + }; + + render(){ + return ; + } + } +``` + +### Set autoclose delay or disable it + +- Set the default delay + +```js + import React from 'react'; + import { ToastContainer } from 'react-toastify'; + + // close toast after 8 seconds + const App = () => ( + + ); +``` + +- Set the delay per toast for more control + +```js + import React from 'react'; + import { ToastContainer } from 'react-toastify'; + + class App extends Component { + closeAfter15 = () => toast("YOLO", { autoClose: 15000 }); + + closeAfter7 = () => toast("7 Kingdoms", { autoClose: 15000 }) + + render(){ + return ( +
+ + + +
+ ); + } + } +``` + +- Disable it by default + +```js + {/* Some components */} + + {/* Some components */} +``` + +- Disable it per toast + +```js + {/* Some components */} + toast("hello", { + autoClose: false + }) + {/* Some components */} +``` + +### Render a component + +When you render a component, a `closeToast` function is passed as a props. That way you can close the toast on user interaction for example. + +```js +import React from 'react'; +import { ToastContainer, toast } from "react-toastify"; + +const Msg = ({ closeToast }) => ( +
+ Lorem ipsum dolor + + +
+) + +const App = () => ( +
+ + +
+); +``` + +Use could also render a component using a function. More or less like a "render props": + +```js +toast(({ closeToast }) =>
Functional swag 😎
); +``` + +### Remove a toast programmatically + +An id is returned each time you display a toast, use it to remove a given toast programmatically by calling ```toast.dismiss(id)``` + +Without args, all the displayed toasts will be removed. + +```javascript + import React, { Component } from 'react'; + import { toast } from 'react-toastify'; + + class Example extends Component { + toastId = null; + + notify = () => this.toastId = toast("Lorem ipsum dolor"); + + dismiss = () => toast.dismiss(this.toastId); + + dismissAll = () => toast.dismiss(); + + render(){ + return ( +
+ + + +
+ ); + } + } +``` + +### Prevent duplicate + +To prevent duplicates, you can check if a given toast is active by calling `toast.isActive(id)` like the snippet below. With this approach, you can decide with more precision whether or not you want to display a toast. + +```javascript + import React, { Component } from 'react'; + import { toast } from 'react-toastify'; + + class Example extends Component { + toastId = null; + + notify = () => { + if (! toast.isActive(this.toastId)) { + this.toastId = toast("I cannot be duplicated !"); + } + } + + render(){ + return ( +
+ +
+ ); + } + } +``` + +### Update a toast + +When you update a toast, the toast options and the content are inherited but don't worry you can update them. + +![update-without-transition](https://user-images.githubusercontent.com/5574267/33761953-1ce2e0ea-dc0b-11e7-8967-a63c1185ce0e.gif) + +#### Basic example + +```js +import React, { Component } from 'react'; +import { toast } from 'react-toastify'; + +class Update extends Component { + toastId = null; + + notify = () => this.toastId = toast("Hello", { autoClose: false }); + + update = () => toast.update(this.toastId, { type: toast.TYPE.INFO, autoClose: 5000 }); + + render(){ + return ( +
+ + +
+ ) + } +} +``` + +#### Update the content + +If you want to change the content it's straightforward as well. You can render any valid element including a react component. Pass your value to a `render` option as follow: + +```js + // With a string + toast.update(this.toastId, { + render: "New content" + type: toast.TYPE.INFO, + autoClose: 5000 + }); + +// Or with a component +toast.update(this.toastId, { + render: + type: toast.TYPE.INFO, + autoClose: 5000 + }); + + +``` + +#### Apply a transition + +By default, when you update a toast, there is no transition applied. You can easily change this behavior by taking advantage of the `className` option. Lets rotate the toast on update: + +![update-with-transition](https://user-images.githubusercontent.com/5574267/33761952-1cc9d55a-dc0b-11e7-9a05-29186ea1c1f0.gif) + +```js +toast.update(this.toastId, { + render: "New Content", + type: toast.TYPE.INFO, + //Here the magic + className: css({ + transform: "rotateY(360deg)", + transition: "transform 0.6s" + }) +}) +``` + +#### Reset option or inherit from ToastContainer + +If you want to inherit props from the `ToastContainer`, you can reset an option by passing null. +It's particulary usefull when you remove the `closeButton` from a toast and you want it back during the update: + +```js +class Update extends Component { + toastId = null; + + notify = () => this.toastId = toast("Hello", { + autoClose: false, + closeButton: false // Remove the closeButton + }); + + update = () => toast.update(this.toastId, { + type: toast.TYPE.INFO, + autoClose: 5000, + closeButton: null // The closeButton defined on ToastContainer will be used + }); + + render(){ + return ( +
+ + +
+ ) + } +} +``` + +### Define hook + +You can define two hooks on toast. Hooks are really useful when the toast are not used only to display messages. + +- onOpen is called inside componentDidMount +- onClose is called inside componentWillUnmount + +```javascript + import React, { Component } from 'react'; + import { toast } from 'react-toastify'; + + class Hook extends Component { + notify = () => toast(, { + onOpen: ({ foo }) => window.alert('I counted to infinity once then..'), + onClose: ({ foo }) => window.alert('I counted to infinity twice') + }); + + render(){ + return ; + } + } +``` + +### Set a custom close button or simply remove it + +#### Override the default one + +You can pass a custom close button to the `ToastContainer` to replace the default one. + +⚠️ **When you use a custom close button, your button will receive a ```closeToast``` function. +You need to call it in order to close the toast.** ⚠️ + +```javascript + import React, { Component } from 'react'; + import { toast, ToastContainer } from 'react-toastify'; + + const CloseButton = ({ YouCanPassAnyProps, closeToast }) => ( + + delete + + ); + + class CustomClose extends Component { + notify = () => { + toast("The close button change when Chuck Norris display a toast"); + }; + + render(){ + return ( +
+ ; + } /> +
+ ); + } + } +``` + +#### Define it per toast + +```javascript + import React, { Component } from 'react'; + import { toast } from 'react-toastify'; + + // Let's use the closeButton we defined on the previous example + class CustomClose extends Component { + notify = () => { + toast("The close button change when Chuck Norris display a toast",{ + closeButton: + }); + }; + + render(){ + return ; + } + } +``` + +#### Remove it + +Sometimes you don't want to display a close button. It can be removed globally or per toast. Simply pass +`false` to `closeButton` props: + +- remove it by default + +```js + {/* Some components */} + + {/* Some components */} +``` + +- remove it per toast + +```js + {/* Some components */} + toast("hello", { + closeButton: false + }) + {/* Some components */} +``` + +### Add an undo option to a toast + +See it in action: + +[![Edit l2qkywz7xl](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/l2qkywz7xl) + +```javascript +const ToastUndo = ({ id, undo, closeToast }) => { + function handleClick(){ + undo(id); + closeToast(); + } + + return ( +
+

+ Row Deleted +

+
+ ); +} + +class App extends Component { + state = { + collection: data, + // Buffer + toRemove: [] + }; + + // Remove the row id from the buffer + undo = id => { + this.setState({ + toRemove: this.state.toRemove.filter(v => v !== id) + }); + } + + // Remove definetly + cleanCollection = () => this.setState({ + // Return element which are not included in toRemove + collection: this.state.collection.filter(v => !this.state.toRemove.includes(v.id)), + //Cleanup the buffer + toRemove: [] + }); + + // Remove row from render process + // then display the toast with undo action available + removeRow = e => { + const id = e.target.dataset.rowId; + this.setState({ + toRemove: [...this.state.toRemove, id] + }); + toast(, { + // hook will be called whent the component unmount + onClose: this.cleanCollection + }); + }; + + renderRows() { + const { collection, toRemove } = this.state; + + // Render all the element wich are not present in toRemove + // Im using data-attribute to grab the row id + return collection.filter(v => !toRemove.includes(v.id)).map(v => ( + + {v.firstName} + {v.lastName} + {v.email} + + + + + )); + } + + render() { + // Dont close the toast on click + return ( +
+ + + + + + + + {this.renderRows()} + +
namefirstnamegender +
+ +
+ ); + } +} +``` + +### Define a custom enter and exit transition + +The toast rely on `react-transition-group` for the enter and exit transition. + +![toastify_custom_trans](https://user-images.githubusercontent.com/5574267/31049179-0d52e14c-a62e-11e7-9abd-b0d169a0fadc.gif) + +I'll use the zoom animation from animate.css. Of course, you could create the animation using glamor. + +```css +/* style.css*/ +@keyframes zoomIn { + from { + opacity: 0; + transform: scale3d(.3, .3, .3); + } + + 50% { + opacity: 1; + } +} + +.zoomIn { + animation-name: zoomIn; +} + +@keyframes zoomOut { + from { + opacity: 1; + } + + 50% { + opacity: 0; + transform: scale3d(.3, .3, .3); + } + + to { + opacity: 0; + } +} + +.zoomOut { + animation-name: zoomOut; +} + +.animate{ + animation-duration: 800ms; +} +``` + +- Create a transition and apply it + +```js +import React, { Component } from 'react'; +import { toast } from 'react-toastify'; +import Transition from 'react-transition-group/Transition'; +import './style.css'; + +// Any transition created with react-transition-group/Transition will work ! +const ZoomInAndOut = ({ children, position, ...props }) => ( + node.classList.add('zoomIn', 'animate')} + onExit={node => { + node.classList.remove('zoomIn', 'animate'); + node.classList.add('zoomOut', 'animate'); + }} + > + {children} + +); + +class App extends Component { + notify = () => { + toast("ZoomIn and ZoomOut", { + transition: ZoomInAndOut, + autoClose: 5000 + }); + }; + + render(){ + return ; + } +} + +``` + +- Or pass your transition to the ToastContainer to replace the default one. + +```js +render(){ + return( + {/*Component*/} + + {/*Component*/} + ); +} +``` + +### Le style + +#### Replace default style + +You could use the style helper to replace the variable listed below: + +```javascript +import { style } from "react-toastify"; + +style({ + width: "320px", + colorDefault: "#fff", + colorInfo: "#3498db", + colorSuccess: "#07bc0c", + colorWarning: "#f1c40f", + colorError: "#e74c3c", + colorProgressDefault: "linear-gradient(to right, #4cd964, #5ac8fa, #007aff, #34aadc, #5856d6, #ff2d55)", + mobile: "only screen and (max-width : 480px)", + fontFamily: "sans-serif", + zIndex: 9999, + TOP_LEFT: { + top: '1em', + left: '1em' + }, + TOP_CENTER: { + top: '1em', + marginLeft: `-${320/2}px`, + left: '50%' + }, + TOP_RIGHT: { + top: '1em', + right: '1em' + }, + BOTTOM_LEFT: { + bottom: '1em', + left: '1em' + }, + BOTTOM_CENTER: { + bottom: '1em', + marginLeft: `-${320/2}px`, + left: '50%' + }, + BOTTOM_RIGHT: { + bottom: '1em', + right: '1em' + } +}); +``` + +#### Style with className + +All className like props can be a css class or a glamor rule. + +⚠️ Use a glamor rule rather than a css class when you want to override a property cause glamor stylesheet +will be injected last ⚠️ + +```javascript + import React, { Component } from 'react'; + import { toast } from 'react-toastify'; + import { css } from 'glamor'; + + class Style extends Component { + notify = () => { + toast("Dark style notification with default type progress bar",{ + className: css({ + background: "black" + }), + bodyClassName: "grow-font-size" + }); + + toast("Fancy progress bar.",{ + progressClassName: css({ + background: "repeating-radial-gradient(circle at center, red 0, blue, green 30px)" + }) + }); + }; + + render(){ + return ; + } + } +``` + +You could define your style globally: + + +```javascript + render(){ + return( + {/*Component*/} + + {/*Component*/} + ); + } +``` + +### Mobile + +On mobile the toast will take all the width available. + +![react toastiy mobile](https://user-images.githubusercontent.com/5574267/28754040-ae7195ea-753d-11e7-86e1-f23c5e6bc531.gif) + +## Api + +### ToastContainer + +| Props | Type | Default | Description | +| ----------------- | -------------- | --------- | --------------------------------------------------------------- | +| position | string | top-right | One of top-right, top-center, top-left, bottom-right, bottom-center, bottom-left | +| autoClose | false or int | 5000 | Delay in ms to close the toast. If set to false, the notification need to be closed manualy | +| closeButton | React Element or false | - | A React Component to replace the default close button or `false` to hide the button | +| transition | function | - | A reference to a valid react-transition-group/Transition component | +| hideProgressBar | bool | false | Display or not the progress bar below the toast(remaining time) | +| pauseOnHover | bool | true | Keep the timer running or not on hover | +| closeOnClick | bool | true | Dismiss toast on click | +| newestOnTop | bool | false | Display newest toast on top | +| className | string\|glamor rule | - | Add optional classes to the container | +| style | object | - | Add optional inline style to the container | +| toastClassName | string\|glamor rule | - | Add optional classes to the toast | +| bodyClassName | string\|glamor rule | - | Add optional classes to the toast body | +| progressClassName | string\|glamor rule | - | Add optional classes to the progress bar | + + +### toast + +All the method of toast return a **toastId** except `dismiss` and `isActive`. +The **toastId** can be used to remove a toast programmatically or to check if the toast is displayed. + + +| Parameter | Type | Required | Description | +| --------- | ------- | ------------- | ------------------------------------------------------------- | +| content | string or React Element | ✓ | Element that will be displayed | +| options | object | ✘ | Possible keys : autoClose, type, closeButton, hideProgressBar | | + +- Available options : + - `type`: Kind of notification. One of "default", "success", "info", "warning", "error". You can use `toast.TYPE.SUCCESS` and so on to avoid any typo. + - `onOpen`: Called inside componentDidMount + - `onClose`: Called inside componentWillUnmount + - `autoClose`: same as ToastContainer. + - `closeButton`: same as ToastContainer. + - `transition`: same as ToastContainer. + - `closeOnClick`: same as ToastContainer. + - `hideProgressBar`: same as ToastContainer. + - `position`: same as ToastContainer + - `pauseOnHover`: same as ToastContainer + - `className`: same as ToastContainer toastClassName + - `bodyClassName`: same as ToastContainer + - `progressClassName`: same as ToastContainer + - `render`: string or React Element, only available when calling update + +:warning:️ *Toast options supersede ToastContainer props* :warning: + +```javascript +const Img = ({ src }) =>
; +const options = { + onOpen: props => console.log(props.foo), + onClose: props => console.log(props.foo), + autoClose: 6000, + closeButton: , + type: toast.TYPE.INFO, + hideProgressBar: false, + position: toast.POSITION.TOP_LEFT, + pauseOnHover: true, + transition: MyCustomTransition +}; + +const toastId = toast(, options) // default, type: 'default' +toast(({ closeToast }) =>
Render props like
, options); +toast.success("Hello", options) // add type: 'success' to options +toast.info("World", options) // add type: 'info' to options +toast.warn(, options) // add type: 'warning' to options +toast.error(, options) // add type: 'error' to options +toast.dismiss() // Remove all toasts ! +toast.dismiss(toastId) // Remove given toast +toast.isActive(toastId) //Check if a toast is displayed or not +toast.update(toastId, { + type: toast.TYPE.INFO, + render: +}); +``` + +## Browser Support + +![IE](https://cloud.githubusercontent.com/assets/398893/3528325/20373e76-078e-11e4-8e3a-1cb86cf506f0.png) | ![Chrome](https://cloud.githubusercontent.com/assets/398893/3528328/23bc7bc4-078e-11e4-8752-ba2809bf5cce.png) | ![Firefox](https://cloud.githubusercontent.com/assets/398893/3528329/26283ab0-078e-11e4-84d4-db2cf1009953.png) | ![Opera](https://cloud.githubusercontent.com/assets/398893/3528330/27ec9fa8-078e-11e4-95cb-709fd11dac16.png) | ![Safari](https://cloud.githubusercontent.com/assets/398893/3528331/29df8618-078e-11e4-8e3e-ed8ac738693f.png) | ![Edge](https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png) +--- | --- | --- | --- | --- | --- | +IE 11+ ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | + +## Release Notes + +### V3.2.2 + +- Add comment to typescript definition. + +### V3.2.1 + +- Fix typescript definition. Relate to [issue #110](https://github.com/fkhadra/react-toastify/issues/110) + +### V3.2.0 + +- Allow "render props" rendering. Relate to [issue #106](https://github.com/fkhadra/react-toastify/issues/106) +- Can set fontFamily via the style helper. Relate to [issue #107](https://github.com/fkhadra/react-toastify/issues/107) +- Can override position default values via style helper. Realte to [issue #108](https://github.com/fkhadra/react-toastify/issues/108) + +### V3.1.2 +- Fix [issue #103](https://github.com/fkhadra/react-toastify/issues/103) for real... +- Fix [issue #104](https://github.com/fkhadra/react-toastify/issues/104) Incorrect TS definition for `toast.dismiss` + +### V3.1.1 + +- Fix [issue #103](https://github.com/fkhadra/react-toastify/issues/103) + +### V3.1.0 + +- Add ability to update an existing toast +- Allow to define the zIndex via the style helper +- Get rid of all inline style + +### V3.0.0 + +- Switched to styled component with glamor +- Added style helper to replace sass variables +- Test suite improved +- Typescript definition improved + +### V2.2.1 + +- Fix [issue #71](https://github.com/fkhadra/react-toastify/issues/71) + +### V2.2.0 + +- Sass variables are now namespaced + +### V2.1.7 + +- Can now use [sass variable default](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#Variable_Defaults___default) thanks to [vikpe](https://github.com/vikpe) +### V2.1.5 + +- Test suites improved + +### V2.1.4 + +- Fix broken typescript dependencies + +### V2.1.3 + +- Added typescript definition +- Toast will pause when page is not visible thanks to page visibility api. + +### V2.1.2 + +- Previous version was breaking compatibility with react < 16 +### V2.1.1 + +#### Bugfix + +- Remove toast from react dom when not displayed. Because of that the `onClose` callback on the toast was never called. Relate to [issue #50](https://github.com/fkhadra/react-toastify/issues/50) + +### V2.1.0 + +#### New Features + +- Can set a custom transition when the toat enter and exit the screen :sparkles: + +#### Others + +- Upgrade to react v16 +- Upgrade to enzyme v3 +- Switched to react-app preset for eslint +- Upgrade to webpack v3 +- Upgrade to react-transition-group v2 + + +### V2.0.0 + +This version may introduce breaking changes due to redesign. My apologies. + +But, it brings a lots of new and exciting features ! + +#### New Features + +- The default design has been reviewed. The component is now usable out of the box without the need to touch the css. Relate to [issue #28](https://github.com/fkhadra/react-toastify/issues/28) +- The toast timer can keep running on hover. [issue #33](https://github.com/fkhadra/react-toastify/issues/33) +- Added a possibility to check if a given toast is displayed or not. By using that method we can prevent duplicate. [issue #3](https://github.com/fkhadra/react-toastify/issues/3) +- Can decide to close the toast on click +- Can show newest toast on top +- Can define additionnal className for toast[issue #21](https://github.com/fkhadra/react-toastify/issues/21) +- Much more mobile ready than the past + +#### Bug Fixes + +- The space in of left boxes from window & right boxes from window is different.[issue #25](https://github.com/fkhadra/react-toastify/issues/25) +- Partial support of ie11. I still need to fix the animation but I need a computer with ie11 for that xD [issue #26](https://github.com/fkhadra/react-toastify/issues/26) + +### v1.7.0 + +#### New Features + +- Toast can now be positioned individually ! + +### v1.6.0 + +#### New Features + +- Can now remove a toast programmatically. When you display a toast, the function return a **toastId**. You can use it +as follow to remove a given toast `toast.dismiss(toastId)` +- If the container is not mounted, the notification will be added to a queue and dispatched as soon as the container is mounted. +For more details check [issue #4](https://github.com/fkhadra/react-toastify/issues/4) + +#### Others + +- Added --no-idents flag to cssnano to avoid animation name collision with others libs. +- Tests are no longer transpiled + +### v1.5.0 + +- That version does not bring any features but it brings tests made with the amazing jest and aslo Travis CI integration. + +### v1.4.3 + +- React and react-dom are now peer dependencies + +### v1.4.2 + +- Don't try to pass down the props when we render a string like so : `toast(
hello
)` + +#### Bug fix + +- Fixed the test to check if the toast can be rendered + +### v1.4.0 + +- React v16 ready : moving to prop-types and react-transition-group +- Internal rewrite of components. The implementation wasn't bad but it wasn't good either. A better props validation has been added has well. +- Removed useless dependencies. I was using the Object.values polyfill when a one line forEach can do the same is my case. +- Now I believe it's even easier to style the components. The sass sources files are now included when you install the package via yarn or npm +- The default close button has been replaced. + +#### New Features + +- A progress bar is now visible to track the remaining time before the notification is closed. Of course if you don't like it, you are free to disable it. +- You can choose to display a close button or not. +- Event pointer is set to none to avoid losing pointer events on everything beneath the toast container when no toast are displayed +- The `closeToast` callback is also passed down to your component. + +### v1.3.0 + +- PropTypes package update +- Dead code elimination + +#### New Features + +- Possibility to use a custom close button. Check the api docs of ToastContainer and toast. + +### v1.2.2 + +I was storing react component into state which is a bad practice. [What should Go in State](http://web.archive.org/web/20150419023006/http://facebook.github.io/react/docs/interactivity-and-dynamic-uis.html) +This is no more the case now. The separation of concern between the data and the view is respected. + +#### Bug fix + +- Was calling cloneElement on undefined which cause your console bleed. See issue [#2](https://github.com/fkhadra/react-toastify/issues/2) + + +### v1.2.1 + +#### Bug fix + +- Added Object.values polyfill otherwise won't work with IE or EDGE. I ♥ IE. + +### v1.1.1 + +#### Bug fix + +- OnClose and OnOpen can access all the props passed to the component. Before +only the props passed using toast options were accessible + +#### New Features + +- Passing prop using toast option will be removed at the next release. It doesn't +make sense to keep both way to pass props. Use the react way instead + +### v1.1.0 + +#### New Features + +- Added onOpen callback +- Added onClose callback + +## Contribute + +Show your ❤️ and support by giving a ⭐. Any suggestions and pull request are welcome ! + +## License + +Licensed under MIT diff --git a/goTorrentWebUI/node_modules/react-toastify/index.d.ts b/goTorrentWebUI/node_modules/react-toastify/index.d.ts new file mode 100644 index 00000000..55f69b3a --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/index.d.ts @@ -0,0 +1,272 @@ +import * as React from 'react'; +import Transition from 'react-transition-group/Transition'; + +type ToastType = 'info' | 'success' | 'warning' | 'error' | 'default'; + +type ToastContent = React.ReactNode | { (): void }; + +interface styleProps { + /** + * Set the default toast width. + * Default: '320px' + */ + width?: string; + + /** + * Set the toast color when no type is provided. + * Default: '#fff' + */ + colorDefault?: string; + + /** + * Set the toast color when the type is INFO. + * Default: '#3498db' + */ + colorInfo?: string; + + /** + * Set the toast color when the type is SUCCESS. + * Default: '#07bc0c' + */ + colorSuccess?: string; + + /** + * Set the toast color when the type is WARNING. + * Default: '#f1c40f' + */ + colorWarning?: string; + + /** + * Set the toast color when the type is ERROR. + * Default: '#e74c3c' + */ + colorError?: string; + + /** + * Set the progress bar color when no type is provided. + * Default: 'linear-gradient(to right, #4cd964, #5ac8fa, #007aff, #34aadc, #5856d6, #ff2d55)' + */ + colorProgressDefault?: string; + + /** + * Media query to apply mobile style. + * Default: 'only screen and (max-width : 480px)' + */ + mobile?: string; + + /** + * Set the z-index for the ToastContainer. + * Default: 9999 + */ + zIndex?: string | number; + + /** + * Override the default position. + * Default: { + * top: '1em', + * left: '1em' + * } + */ + TOP_LEFT?: object; + + /** + * Override the default position. + * Default: { + * top: '1em', + * left: '50%' + * } + */ + TOP_CENTER?: object; + + /** + * Override the default position. + * Default: { + * top: '1em', + * right: '1em' + *} + */ + TOP_RIGHT?: object; + + /** + * Override the default position. + * Default: { + * bottom: '1em', + * left: '1em' + * } + */ + BOTTOM_LEFT?: object; + + /** + * Override the default position. + * Default: { + * bottom: '1em', + * left: '50%' + *} + */ + BOTTOM_CENTER?: object; + + /** + * Override the default position. + * Default: { + * bottom: '1em', + * right: '1em' + *} + */ + BOTTOM_RIGHT?: object; +} + +interface CommonOptions { + /** + * Pause the timer when the mouse hover the toast. + */ + pauseOnHover?: boolean; + + /** + * Remove the toast when clicked. + */ + closeOnClick?: boolean; + + /** + * Set the delay in ms to close the toast automatically. + * Use `false` to prevent the toast from closing. + */ + autoClose?: number | false; + + /** + * Set the default position to use. + * One of: 'top-right', 'top-center', 'top-left', 'bottom-right', 'bottom-center', 'bottom-left' + */ + position?: string; + + /** + * Pass a custom close button. + * To remove the close button pass `false` + */ + closeButton?: React.ReactNode | false; + + /** + * An optional css class to set for the progress bar. It can be a glamor rule + * or a css class name. + */ + progressClassName?: string | object; + + /** + * An optional css class to set. It can be a glamor rule + * or a css class name. + */ + className?: string | object; + + /** + * An optional css class to set for the toast content. It can be a glamor rule + * or a css class name. + */ + bodyClassName?: string | object; + + /** + * Show or not the progress bar. + */ + hideProgressBar?: boolean; + + /** + * Pass a custom transition built with react-transition-group. + */ + transition?: Transition; +} + +interface ToastOptions extends CommonOptions { + /** + * Called inside componentDidMount. + */ + onOpen?: () => void; + + /** + * Called inside componentWillUnMount. + */ + onClose?: () => void; + + /** + * Set the toast type. + * One of: 'info', 'success', 'warning', 'error', 'default'. + */ + type?: ToastType; +} + +interface UpdateOptions extends ToastOptions { + /** + * Used to update a toast. + * Pass any valid ReactNode(string, number, component) + */ + render?: ToastContent; +} + +interface ToastContainerProps extends CommonOptions { + /** + * Whether or not to display the newest toast on top. + * Default: false + */ + newestOnTop?: boolean; + + /** + * An optional inline style to apply. + */ + style?: object; + + /** + * An optional css class to set. It can be a glamor rule + * or a css class name. + */ + toastClassName?: string | object; +} + +interface Toast { + /** + * Shorthand to display toast of type 'success'. + */ + success(content: ToastContent, options?: ToastOptions): number; + + /** + * Shorthand to display toast of type 'info'. + */ + info(content: ToastContent, options?: ToastOptions): number; + + /** + * Shorthand to display toast of type 'warning'. + */ + warn(content: ToastContent, options?: ToastOptions): number; + + /** + * Shorthand to display toast of type 'error'. + */ + error(content: ToastContent, options?: ToastOptions): number; + + /** + * Check if a toast is active by passing the `toastId`. + * Each time you display a toast you receive a `toastId`. + */ + isActive(toastId: number): boolean; + + /** + * Remove a toast. If no `toastId` is used, all the active toast + * will be removed. + */ + dismiss(toastId?: number): void; + + /** + * Update an existing toast. By default, we keep the initial content and options of the toast. + */ + update(toastId: number, options?: UpdateOptions): number; + + /** + * Display a toast without a specific type. + */ + (content: ToastContent, options?: ToastOptions): number; +} + +export class ToastContainer extends React.Component {} + +/** + * Helper to override the global style. + */ +export function style(props: styleProps): void; + +export let toast: Toast; diff --git a/goTorrentWebUI/node_modules/react-toastify/lib/DefaultCloseButton.js b/goTorrentWebUI/node_modules/react-toastify/lib/DefaultCloseButton.js new file mode 100644 index 00000000..488716a6 --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/lib/DefaultCloseButton.js @@ -0,0 +1,56 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _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; }; /* eslint react/require-default-props: 0 */ + + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _glamor = require('glamor'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var rule = function rule(isDefault) { + return (0, _glamor.css)({ + color: isDefault ? '#000' : '#fff', + fontWeight: 'bold', + fontSize: '14px', + background: 'transparent', + outline: 'none', + border: 'none', + padding: 0, + cursor: 'pointer', + opacity: isDefault ? '0.3' : '0.7', + transition: '.3s ease', + alignSelf: 'flex-start', + ':hover, :focus': { + opacity: 1 + } + }); +}; + +function DefaultCloseButton(_ref) { + var closeToast = _ref.closeToast, + type = _ref.type; + + return _react2.default.createElement( + 'button', + _extends({}, rule(type === 'default'), { type: 'button', onClick: closeToast }), + '\u2716' + ); +} + +DefaultCloseButton.propTypes = { + closeToast: _propTypes2.default.func +}; + +exports.default = DefaultCloseButton; \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/lib/DefaultTransition.js b/goTorrentWebUI/node_modules/react-toastify/lib/DefaultTransition.js new file mode 100644 index 00000000..da5e666d --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/lib/DefaultTransition.js @@ -0,0 +1,77 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _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; }; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _Transition = require('react-transition-group/Transition'); + +var _Transition2 = _interopRequireDefault(_Transition); + +var _glamor = require('glamor'); + +var _animation2 = require('./animation'); + +var _animation3 = _interopRequireDefault(_animation2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } + +var animate = { + animationDuration: '0.75s', + animationFillMode: 'both' +}; + +var animation = function animation(pos) { + var _getAnimation = (0, _animation3.default)(pos), + enter = _getAnimation.enter, + exit = _getAnimation.exit; + + var enterAnimation = _glamor.css.keyframes('enter', _extends({ + 'from, 60%, 75%, 90%, to': { + animationTimingFunction: 'cubic-bezier(0.215, 0.610, 0.355, 1.000)' + } + }, enter)); + var exitAnimation = _glamor.css.keyframes('exit', exit); + + return { + enter: (0, _glamor.css)(_extends({}, animate, { animationName: enterAnimation })), + exit: (0, _glamor.css)(_extends({}, animate, { animationName: exitAnimation })) + }; +}; + +function DefaultTransition(_ref) { + var children = _ref.children, + position = _ref.position, + props = _objectWithoutProperties(_ref, ['children', 'position']); + + var _animation = animation(position), + enter = _animation.enter, + exit = _animation.exit; + + return _react2.default.createElement( + _Transition2.default, + _extends({}, props, { + timeout: 750, + onEnter: function onEnter(node) { + return node.classList.add(enter); + }, + onEntered: function onEntered(node) { + return node.classList.remove(enter); + }, + onExit: function onExit(node) { + return node.classList.add(exit); + } + }), + children + ); +} + +exports.default = DefaultTransition; \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/lib/ProgressBar.js b/goTorrentWebUI/node_modules/react-toastify/lib/ProgressBar.js new file mode 100644 index 00000000..7d598ace --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/lib/ProgressBar.js @@ -0,0 +1,99 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _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; }; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _glamor = require('glamor'); + +var _constant = require('./constant'); + +var _style = require('./style'); + +var _style2 = _interopRequireDefault(_style); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var trackProgress = _glamor.css.keyframes('track-progress', { + '0%': { width: '100%' }, + '100%': { width: 0 } +}); + +var progress = function progress(type, isRunning, hide, delay) { + return (0, _glamor.css)(_extends({ + position: 'absolute', + bottom: 0, + left: 0, + width: 0, + height: '5px', + zIndex: _style2.default.zIndex, + opacity: hide ? 0 : 0.7, + animation: trackProgress + ' linear 1', + animationPlayState: isRunning ? 'running' : 'paused', + animationDuration: delay + 'ms', + backgroundColor: 'rgba(255,255,255,.7)' + }, type === 'default' ? { background: _style2.default.colorProgressDefault } : {})); +}; + +function ProgressBar(_ref) { + var delay = _ref.delay, + isRunning = _ref.isRunning, + closeToast = _ref.closeToast, + type = _ref.type, + hide = _ref.hide, + className = _ref.className; + + return _react2.default.createElement('div', _extends({}, typeof className !== 'string' ? (0, _glamor.css)(progress(type, isRunning, hide, delay), className) : progress(type, isRunning, hide, delay), typeof className === 'string' && { className: className }, { + onAnimationEnd: closeToast + })); +} + +ProgressBar.propTypes = { + /** + * The animation delay which determine when to close the toast + */ + delay: _propTypes2.default.number.isRequired, + + /** + * Whether or not the animation is running or paused + */ + isRunning: _propTypes2.default.bool.isRequired, + + /** + * Func to close the current toast + */ + closeToast: _propTypes2.default.func.isRequired, + + /** + * Optional type : info, success ... + */ + type: _propTypes2.default.string, + + /** + * Hide or not the progress bar + */ + hide: _propTypes2.default.bool, + + /** + * Optionnal className + */ + className: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object]) +}; + +ProgressBar.defaultProps = { + type: _constant.TYPE.DEFAULT, + hide: false, + className: '' +}; + +exports.default = ProgressBar; \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/lib/Toast.js b/goTorrentWebUI/node_modules/react-toastify/lib/Toast.js new file mode 100644 index 00000000..1ffbc351 --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/lib/Toast.js @@ -0,0 +1,217 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _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; }; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _glamor = require('glamor'); + +var _ProgressBar = require('./ProgressBar'); + +var _ProgressBar2 = _interopRequireDefault(_ProgressBar); + +var _constant = require('./constant'); + +var _style = require('./style'); + +var _style2 = _interopRequireDefault(_style); + +var _propValidator = require('./util/propValidator'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +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; } + +var toast = function toast(type) { + return (0, _glamor.css)(_extends({ + position: 'relative', + minHeight: '48px', + marginBottom: '1rem', + padding: '8px', + borderRadius: '1px', + boxShadow: '0 1px 10px 0 rgba(0, 0, 0, .1), 0 2px 15px 0 rgba(0, 0, 0, .05)', + display: 'flex', + justifyContent: 'space-between', + maxHeight: '800px', + overflow: 'hidden', + fontFamily: _style2.default.fontFamily, + cursor: 'pointer', + background: _style2.default['color' + type.charAt(0).toUpperCase() + type.slice(1)] + }, type === 'default' ? { color: '#aaa' } : {}, _defineProperty({}, '@media ' + _style2.default.mobile, { + marginBottom: 0 + }))); +}; + +var body = (0, _glamor.css)({ + margin: 'auto 0', + flex: 1 +}); + +var Toast = function (_Component) { + _inherits(Toast, _Component); + + function Toast() { + var _ref; + + var _temp, _this, _ret; + + _classCallCheck(this, Toast); + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Toast.__proto__ || Object.getPrototypeOf(Toast)).call.apply(_ref, [this].concat(args))), _this), _this.state = { + isRunning: true + }, _this.pauseToast = function () { + _this.setState({ isRunning: false }); + }, _this.playToast = function () { + _this.setState({ isRunning: true }); + }, _temp), _possibleConstructorReturn(_this, _ret); + } + + _createClass(Toast, [{ + key: 'componentDidMount', + value: function componentDidMount() { + this.props.onOpen !== null && this.props.onOpen(this.getChildrenProps()); + } + }, { + key: 'componentWillReceiveProps', + value: function componentWillReceiveProps(nextProps) { + if (this.props.isDocumentHidden !== nextProps.isDocumentHidden) { + this.setState({ + isRunning: !nextProps.isDocumentHidden + }); + } + } + }, { + key: 'componentWillUnmount', + value: function componentWillUnmount() { + this.props.onClose !== null && this.props.onClose(this.getChildrenProps()); + } + }, { + key: 'getChildrenProps', + value: function getChildrenProps() { + return this.props.children.props; + } + }, { + key: 'getToastProps', + value: function getToastProps() { + var toastProps = {}; + + if (this.props.autoClose !== false && this.props.pauseOnHover === true) { + toastProps.onMouseEnter = this.pauseToast; + toastProps.onMouseLeave = this.playToast; + } + typeof this.props.className === 'string' && (toastProps.className = this.props.className); + this.props.closeOnClick && (toastProps.onClick = this.props.closeToast); + + return toastProps; + } + }, { + key: 'render', + value: function render() { + var _props = this.props, + closeButton = _props.closeButton, + children = _props.children, + autoClose = _props.autoClose, + type = _props.type, + hideProgressBar = _props.hideProgressBar, + closeToast = _props.closeToast, + Transition = _props.transition, + position = _props.position, + onExited = _props.onExited, + className = _props.className, + bodyClassName = _props.bodyClassName, + progressClassName = _props.progressClassName, + updateId = _props.updateId; + + + return _react2.default.createElement( + Transition, + { + 'in': this.props.in, + appear: true, + unmountOnExit: true, + onExited: onExited, + position: position + }, + _react2.default.createElement( + 'div', + _extends({}, typeof className !== 'string' ? (0, _glamor.css)(toast(type), className) : toast(type), this.getToastProps()), + _react2.default.createElement( + 'div', + _extends({}, typeof bodyClassName !== 'string' ? (0, _glamor.css)(body, bodyClassName) : body, typeof bodyClassName === 'string' && { + className: bodyClassName + }), + children + ), + closeButton !== false && closeButton, + autoClose !== false && _react2.default.createElement(_ProgressBar2.default, { + key: 'pb-' + updateId, + delay: autoClose, + isRunning: this.state.isRunning, + closeToast: closeToast, + hide: hideProgressBar, + type: type, + className: progressClassName + }) + ) + ); + } + }]); + + return Toast; +}(_react.Component); + +Toast.propTypes = { + closeButton: _propValidator.falseOrElement.isRequired, + autoClose: _propValidator.falseOrDelay.isRequired, + children: _propTypes2.default.node.isRequired, + closeToast: _propTypes2.default.func.isRequired, + position: _propTypes2.default.oneOf((0, _propValidator.objectValues)(_constant.POSITION)).isRequired, + pauseOnHover: _propTypes2.default.bool.isRequired, + closeOnClick: _propTypes2.default.bool.isRequired, + transition: _propTypes2.default.func.isRequired, + isDocumentHidden: _propTypes2.default.bool.isRequired, + in: _propTypes2.default.bool, + onExited: _propTypes2.default.func, + hideProgressBar: _propTypes2.default.bool, + onOpen: _propTypes2.default.func, + onClose: _propTypes2.default.func, + type: _propTypes2.default.oneOf((0, _propValidator.objectValues)(_constant.TYPE)), + className: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object]), + bodyClassName: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object]), + progressClassName: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object]), + updateId: _propTypes2.default.number +}; +Toast.defaultProps = { + type: _constant.TYPE.DEFAULT, + in: true, + hideProgressBar: false, + onOpen: null, + onClose: null, + className: '', + bodyClassName: '', + progressClassName: '', + updateId: null +}; +exports.default = Toast; \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/lib/ToastContainer.js b/goTorrentWebUI/node_modules/react-toastify/lib/ToastContainer.js new file mode 100644 index 00000000..c230395e --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/lib/ToastContainer.js @@ -0,0 +1,399 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _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; }; + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +var _glamor = require('glamor'); + +var _TransitionGroup = require('react-transition-group/TransitionGroup'); + +var _TransitionGroup2 = _interopRequireDefault(_TransitionGroup); + +var _Toast = require('./Toast'); + +var _Toast2 = _interopRequireDefault(_Toast); + +var _DefaultCloseButton = require('./DefaultCloseButton'); + +var _DefaultCloseButton2 = _interopRequireDefault(_DefaultCloseButton); + +var _DefaultTransition = require('./DefaultTransition'); + +var _DefaultTransition2 = _interopRequireDefault(_DefaultTransition); + +var _constant = require('./constant'); + +var _style = require('./style'); + +var _style2 = _interopRequireDefault(_style); + +var _EventManager = require('./util/EventManager'); + +var _EventManager2 = _interopRequireDefault(_EventManager); + +var _propValidator = require('./util/propValidator'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +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; } + +var toastPosition = function toastPosition(pos) { + var positionKey = pos.toUpperCase().replace('-', '_'); + var positionRule = typeof _constant.POSITION[positionKey] !== 'undefined' ? _style2.default[positionKey] : _style2.default.TOP_RIGHT; + + /** define margin for center toast based on toast witdh */ + if (positionKey.indexOf('CENTER') !== -1 && typeof positionRule.marginLeft === 'undefined') { + positionRule.marginLeft = '-' + parseInt(_style2.default.width, 10) / 2 + 'px'; + } + + return (0, _glamor.css)(positionRule, (0, _glamor.css)(_defineProperty({}, '@media ' + _style2.default.mobile, _extends({ + left: 0, + margin: 0, + position: 'fixed' + }, pos.substring(0, 3) === 'top' ? { top: 0 } : { bottom: 0 })))); +}; + +var container = function container(disablePointer, position) { + return (0, _glamor.css)(_extends({ + zIndex: _style2.default.zIndex, + position: 'fixed', + padding: '4px', + width: _style2.default.width, + boxSizing: 'border-box', + color: '#fff' + }, disablePointer ? { pointerEvents: 'none' } : {}, _defineProperty({}, '@media ' + _style2.default.mobile, { + width: '100vw', + padding: 0 + })), toastPosition(position)); +}; + +var ToastContainer = function (_Component) { + _inherits(ToastContainer, _Component); + + function ToastContainer() { + var _ref; + + var _temp, _this, _ret; + + _classCallCheck(this, ToastContainer); + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = ToastContainer.__proto__ || Object.getPrototypeOf(ToastContainer)).call.apply(_ref, [this].concat(args))), _this), _this.state = { + toast: [], + isDocumentHidden: false + }, _this.collection = {}, _this.isDocumentHidden = function () { + return _this.setState({ isDocumentHidden: document.hidden }); + }, _this.isToastActive = function (id) { + return _this.state.toast.indexOf(parseInt(id, 10)) !== -1; + }, _temp), _possibleConstructorReturn(_this, _ret); + } + + /** + * Hold toast ids + */ + + + /** + * Hold toast's informations: + * - what to render + * - position + * - raw content + * - options + */ + + + _createClass(ToastContainer, [{ + key: 'componentDidMount', + value: function componentDidMount() { + var _this2 = this; + + var SHOW = _constant.ACTION.SHOW, + CLEAR = _constant.ACTION.CLEAR, + MOUNTED = _constant.ACTION.MOUNTED; + + _EventManager2.default.on(SHOW, function (content, options) { + return _this2.show(content, options); + }).on(CLEAR, function (id) { + return id !== null ? _this2.removeToast(id) : _this2.clear(); + }).emit(MOUNTED, this); + document.addEventListener('visibilitychange', this.isDocumentHidden); + } + }, { + key: 'componentWillUnmount', + value: function componentWillUnmount() { + _EventManager2.default.off(_constant.ACTION.SHOW); + _EventManager2.default.off(_constant.ACTION.CLEAR); + document.removeEventListener('visibilitychange', this.isDocumentHidden); + } + }, { + key: 'removeToast', + value: function removeToast(id) { + this.setState({ + toast: this.state.toast.filter(function (v) { + return v !== parseInt(id, 10); + }) + }); + } + }, { + key: 'makeCloseButton', + value: function makeCloseButton(toastClose, toastId, type) { + var _this3 = this; + + var closeButton = this.props.closeButton; + + if ((0, _react.isValidElement)(toastClose) || toastClose === false) { + closeButton = toastClose; + } + + return closeButton === false ? false : (0, _react.cloneElement)(closeButton, { + closeToast: function closeToast() { + return _this3.removeToast(toastId); + }, + type: type + }); + } + }, { + key: 'getAutoCloseDelay', + value: function getAutoCloseDelay(toastAutoClose) { + return toastAutoClose === false || (0, _propValidator.isValidDelay)(toastAutoClose) ? toastAutoClose : this.props.autoClose; + } + }, { + key: 'isFunction', + value: function isFunction(object) { + return !!(object && object.constructor && object.call && object.apply); + } + }, { + key: 'canBeRendered', + value: function canBeRendered(content) { + return (0, _react.isValidElement)(content) || typeof content === 'string' || typeof content === 'number' || this.isFunction(content); + } + }, { + key: 'show', + value: function show(content, options) { + var _this4 = this; + + if (!this.canBeRendered(content)) { + throw new Error('The element you provided cannot be rendered. You provided an element of type ' + (typeof content === 'undefined' ? 'undefined' : _typeof(content))); + } + var toastId = options.toastId; + var closeToast = function closeToast() { + return _this4.removeToast(toastId); + }; + var toastOptions = { + id: toastId, + type: options.type, + closeToast: closeToast, + updateId: options.updateId, + position: options.position || this.props.position, + transition: options.transition || this.props.transition, + className: options.className || this.props.toastClassName, + bodyClassName: options.bodyClassName || this.props.bodyClassName, + closeButton: this.makeCloseButton(options.closeButton, toastId, options.type), + pauseOnHover: options.pauseOnHover !== null ? options.pauseOnHover : this.props.pauseOnHover, + closeOnClick: options.closeOnClick !== null ? options.closeOnClick : this.props.closeOnClick, + progressClassName: options.progressClassName || this.props.progressClassName, + autoClose: this.getAutoCloseDelay(options.autoClose !== false ? parseInt(options.autoClose, 10) : options.autoClose), + hideProgressBar: typeof options.hideProgressBar === 'boolean' ? options.hideProgressBar : this.props.hideProgressBar + }; + + this.isFunction(options.onOpen) && (toastOptions.onOpen = options.onOpen); + + this.isFunction(options.onClose) && (toastOptions.onClose = options.onClose); + + /** + * add closeToast function to react component only + */ + if ((0, _react.isValidElement)(content) && typeof content.type !== 'string' && typeof content.type !== 'number') { + content = (0, _react.cloneElement)(content, { + closeToast: closeToast + }); + } else if (this.isFunction(content)) { + content = content({ closeToast: closeToast }); + } + + this.collection = _extends({}, this.collection, _defineProperty({}, toastId, { + position: toastOptions.position, + options: toastOptions, + content: content + })); + + this.setState({ + toast: toastOptions.updateId !== null ? [].concat(_toConsumableArray(this.state.toast)) : [].concat(_toConsumableArray(this.state.toast), [toastId]) + }); + } + }, { + key: 'makeToast', + value: function makeToast(content, options) { + return _react2.default.createElement( + _Toast2.default, + _extends({}, options, { + isDocumentHidden: this.state.isDocumentHidden, + key: 'toast-' + options.id + }), + content + ); + } + }, { + key: 'clear', + value: function clear() { + this.setState({ toast: [] }); + } + }, { + key: 'renderToast', + value: function renderToast() { + var _this5 = this; + + var toastToRender = {}; + var _props = this.props, + className = _props.className, + style = _props.style, + newestOnTop = _props.newestOnTop; + + var collection = newestOnTop ? Object.keys(this.collection).reverse() : Object.keys(this.collection); + + collection.forEach(function (toastId) { + var item = _this5.collection[toastId]; + toastToRender[item.position] || (toastToRender[item.position] = []); + + if (_this5.state.toast.indexOf(parseInt(toastId, 10)) !== -1) { + toastToRender[item.position].push(_this5.makeToast(item.content, item.options)); + } else { + toastToRender[item.position].push(null); + delete _this5.collection[toastId]; + } + }); + + return Object.keys(toastToRender).map(function (position) { + var disablePointer = toastToRender[position].length === 1 && toastToRender[position][0] === null; + + return _react2.default.createElement( + _TransitionGroup2.default, + _extends({}, typeof className !== 'string' ? (0, _glamor.css)(container(disablePointer, position), className) : container(disablePointer, position), typeof className === 'string' && { className: className }, style !== null && { style: style }, { + key: 'container-' + position + }), + toastToRender[position] + ); + }); + } + }, { + key: 'render', + value: function render() { + return _react2.default.createElement( + 'div', + null, + this.renderToast() + ); + } + }]); + + return ToastContainer; +}(_react.Component); + +ToastContainer.propTypes = { + /** + * Set toast position + */ + position: _propTypes2.default.oneOf((0, _propValidator.objectValues)(_constant.POSITION)), + + /** + * Disable or set autoClose delay + */ + autoClose: _propValidator.falseOrDelay, + + /** + * Disable or set a custom react element for the close button + */ + closeButton: _propValidator.falseOrElement, + + /** + * Hide or not progress bar when autoClose is enabled + */ + hideProgressBar: _propTypes2.default.bool, + + /** + * Pause toast duration on hover + */ + pauseOnHover: _propTypes2.default.bool, + + /** + * Dismiss toast on click + */ + closeOnClick: _propTypes2.default.bool, + + /** + * Newest on top + */ + newestOnTop: _propTypes2.default.bool, + + /** + * An optional className + */ + className: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object]), + + /** + * An optional style + */ + style: _propTypes2.default.object, + + /** + * An optional className for the toast + */ + toastClassName: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object]), + + /** + * An optional className for the toast body + */ + bodyClassName: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object]), + + /** + * An optional className for the toast progress bar + */ + progressClassName: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object]), + + /** + * Define enter and exit transition using react-transition-group + */ + transition: _propTypes2.default.func +}; +ToastContainer.defaultProps = { + position: _constant.POSITION.TOP_RIGHT, + transition: _DefaultTransition2.default, + autoClose: 5000, + hideProgressBar: false, + closeButton: _react2.default.createElement(_DefaultCloseButton2.default, null), + pauseOnHover: true, + closeOnClick: true, + newestOnTop: false, + className: null, + style: null, + toastClassName: '', + bodyClassName: '', + progressClassName: '' +}; +exports.default = ToastContainer; \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/lib/animation.js b/goTorrentWebUI/node_modules/react-toastify/lib/animation.js new file mode 100644 index 00000000..3857b1fd --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/lib/animation.js @@ -0,0 +1,150 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = getAnimation; + +var _constant = require('./constant'); + +function getAnimation(pos) { + switch (pos) { + case _constant.POSITION.TOP_RIGHT: + case _constant.POSITION.BOTTOM_RIGHT: + default: + return { + enter: { + from: { + opacity: 0, + transform: 'translate3d(3000px, 0, 0)' + }, + '60%': { + opacity: 1, + transform: 'translate3d(-25px, 0, 0)' + }, + '75%': { + transform: 'translate3d(10px, 0, 0)' + }, + '90%': { + transform: 'translate3d(-5px, 0, 0)' + }, + to: { + transform: 'none' + } + }, + exit: { + '20%': { + opacity: 1, + transform: 'translate3d(-20px, 0, 0)' + }, + to: { + opacity: 0, + transform: 'translate3d(2000px, 0, 0)' + } + } + }; + case _constant.POSITION.TOP_LEFT: + case _constant.POSITION.BOTTOM_LEFT: + return { + enter: { + '0%': { + opacity: 0, + transform: 'translate3d(-3000px, 0, 0)' + }, + '60%': { + opacity: 1, + transform: 'translate3d(25px, 0, 0)' + }, + '75%': { + transform: 'translate3d(-10px, 0, 0)' + }, + '90%': { + transform: 'translate3d(5px, 0, 0)' + }, + to: { + transform: 'none' + } + }, + exit: { + '20%': { + opacity: 1, + transform: 'translate3d(20px, 0, 0)' + }, + to: { + opacity: 0, + transform: 'translate3d(-2000px, 0, 0)' + } + } + }; + case _constant.POSITION.BOTTOM_CENTER: + return { + enter: { + from: { + opacity: 0, + transform: 'translate3d(0, 3000px, 0)' + }, + '60%': { + opacity: 1, + transform: 'translate3d(0, -20px, 0)' + }, + '75%': { + transform: 'translate3d(0, 10px, 0)' + }, + '90%': { + transform: 'translate3d(0, -5px, 0)' + }, + to: { + transform: 'translate3d(0, 0, 0)' + } + }, + exit: { + '20%': { + transform: 'translate3d(0, 10px, 0)' + }, + '40%, 45%': { + opacity: 1, + transform: 'translate3d(0, -20px, 0)' + }, + to: { + opacity: 0, + transform: 'translate3d(0, 2000px, 0)' + } + } + }; + case _constant.POSITION.TOP_CENTER: + return { + enter: { + '0%': { + opacity: 0, + transform: 'translate3d(0, -3000px, 0)' + }, + '60%': { + opacity: 1, + transform: 'translate3d(0, 25px, 0)' + }, + '75%': { + transform: 'translate3d(0, -10px, 0)' + }, + '90%': { + transform: 'translate3d(0, 5px, 0)' + }, + to: { + transform: 'none' + } + }, + exit: { + '20%': { + transform: 'translate3d(0, -10px, 0)' + }, + '40%, 45%': { + opacity: 1, + transform: 'translate3d(0, 20px, 0)' + }, + to: { + opacity: 0, + transform: 'translate3d(0, -2000px, 0)' + } + } + }; + } +} \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/lib/config.js b/goTorrentWebUI/node_modules/react-toastify/lib/config.js new file mode 100644 index 00000000..413f9636 --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/lib/config.js @@ -0,0 +1,18 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = { + width: "320px", + background: "#ffffff", + fontColor: "#999", + fontSize: "13px", + colorDefault: "#fff", + colorInfo: "#3498db", + colorSuccess: "#07bc0c", + colorWarning: "#f1c40f", + colorError: "#e74c3c", + colorProgressDefault: "linear-gradient(to right, #4cd964, #5ac8fa, #007aff, #34aadc, #5856d6, #ff2d55)", + smartphonePortrait: "only screen and (max-width : 480px)" +}; \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/lib/constant.js b/goTorrentWebUI/node_modules/react-toastify/lib/constant.js new file mode 100644 index 00000000..8905d75b --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/lib/constant.js @@ -0,0 +1,26 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +var POSITION = exports.POSITION = { + TOP_LEFT: 'top-left', + TOP_RIGHT: 'top-right', + TOP_CENTER: 'top-center', + BOTTOM_LEFT: 'bottom-left', + BOTTOM_RIGHT: 'bottom-right', + BOTTOM_CENTER: 'bottom-center' +}; + +var TYPE = exports.TYPE = { + INFO: 'info', + SUCCESS: 'success', + WARNING: 'warning', + ERROR: 'error', + DEFAULT: 'default' +}; +var ACTION = exports.ACTION = { + SHOW: 'SHOW_TOAST', + CLEAR: 'CLEAR_TOAST', + MOUNTED: 'CONTAINER_MOUNTED' +}; \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/lib/index.js b/goTorrentWebUI/node_modules/react-toastify/lib/index.js new file mode 100644 index 00000000..069dd12d --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/lib/index.js @@ -0,0 +1,22 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.style = exports.toast = exports.ToastContainer = undefined; + +var _ToastContainer = require('./ToastContainer'); + +var _ToastContainer2 = _interopRequireDefault(_ToastContainer); + +var _toaster = require('./toaster'); + +var _toaster2 = _interopRequireDefault(_toaster); + +var _style = require('./style'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.ToastContainer = _ToastContainer2.default; +exports.toast = _toaster2.default; +exports.style = _style.defineStyle; \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/lib/style.js b/goTorrentWebUI/node_modules/react-toastify/lib/style.js new file mode 100644 index 00000000..e275ae85 --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/lib/style.js @@ -0,0 +1,50 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.defineStyle = defineStyle; +var style = { + width: '320px', + colorDefault: '#fff', + colorInfo: '#3498db', + colorSuccess: '#07bc0c', + colorWarning: '#f1c40f', + colorError: '#e74c3c', + colorProgressDefault: 'linear-gradient(to right, #4cd964, #5ac8fa, #007aff, #34aadc, #5856d6, #ff2d55)', + mobile: 'only screen and (max-width : 480px)', + fontFamily: 'sans-serif', + zIndex: 9999, + TOP_LEFT: { + top: '1em', + left: '1em' + }, + TOP_CENTER: { + top: '1em', + left: '50%' + }, + TOP_RIGHT: { + top: '1em', + right: '1em' + }, + BOTTOM_LEFT: { + bottom: '1em', + left: '1em' + }, + BOTTOM_CENTER: { + bottom: '1em', + left: '50%' + }, + BOTTOM_RIGHT: { + bottom: '1em', + right: '1em' + } +}; + +function defineStyle(props) { + for (var prop in props) { + style[prop] = props[prop]; + } +} + +exports.default = style; \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/lib/toaster.js b/goTorrentWebUI/node_modules/react-toastify/lib/toaster.js new file mode 100644 index 00000000..f12f440f --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/lib/toaster.js @@ -0,0 +1,129 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _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; }; + +var _EventManager = require('./util/EventManager'); + +var _EventManager2 = _interopRequireDefault(_EventManager); + +var _constant = require('./constant'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var defaultOptions = { + type: _constant.TYPE.DEFAULT, + autoClose: null, + closeButton: null, + hideProgressBar: null, + position: null, + pauseOnHover: null, + closeOnClick: null, + className: null, + bodyClassName: null, + progressClassName: null, + transition: null, + updateId: null +}; + +var container = null; +var queue = []; +var toastId = 0; + +/** + * Merge provided options with the defaults settings and generate the toastId + * @param {*} options + */ +function mergeOptions(options, type) { + return _extends({}, defaultOptions, options, { + type: type, + toastId: ++toastId + }); +} + +/** + * Dispatch toast. If the container is not mounted, the toast is enqueued + * @param {*} content + * @param {*} options + */ +function emitEvent(content, options) { + if (container !== null) { + _EventManager2.default.emit(_constant.ACTION.SHOW, content, options); + } else { + queue.push({ action: _constant.ACTION.SHOW, content: content, options: options }); + } + + return options.toastId; +} + +var toaster = _extends(function (content, options) { + return emitEvent(content, mergeOptions(options, options && options.type || _constant.TYPE.DEFAULT)); +}, { + success: function success(content, options) { + return emitEvent(content, mergeOptions(options, _constant.TYPE.SUCCESS)); + }, + info: function info(content, options) { + return emitEvent(content, mergeOptions(options, _constant.TYPE.INFO)); + }, + warn: function warn(content, options) { + return emitEvent(content, mergeOptions(options, _constant.TYPE.WARNING)); + }, + warning: function warning(content, options) { + return emitEvent(content, mergeOptions(options, _constant.TYPE.WARNING)); + }, + error: function error(content, options) { + return emitEvent(content, mergeOptions(options, _constant.TYPE.ERROR)); + }, + dismiss: function dismiss() { + var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; + return container && _EventManager2.default.emit(_constant.ACTION.CLEAR, id); + }, + isActive: function isActive() { + return false; + }, + update: function update(id, options) { + if (container && typeof container.collection[id] !== 'undefined') { + var _container$collection = container.collection[id], + oldOptions = _container$collection.options, + oldContent = _container$collection.content; + + var updateId = oldOptions.updateId !== null ? oldOptions.updateId + 1 : 1; + + var nextOptions = _extends({}, oldOptions, options, { + toastId: id, + updateId: updateId + }); + var content = typeof nextOptions.render !== 'undefined' ? nextOptions.render : oldContent; + delete nextOptions.render; + + return emitEvent(content, nextOptions); + } + + return false; + } +}, { + POSITION: _constant.POSITION, + TYPE: _constant.TYPE +}); + +/** + * Wait until the ToastContainer is mounted to dispatch the toast + * and attach isActive method + */ +_EventManager2.default.on(_constant.ACTION.MOUNTED, function (containerInstance) { + container = containerInstance; + + toaster.isActive = function (id) { + return container.isToastActive(id); + }; + + queue.forEach(function (item) { + _EventManager2.default.emit(item.action, item.content, item.options); + }); + queue = []; +}); + +exports.default = toaster; \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/lib/util/EventManager.js b/goTorrentWebUI/node_modules/react-toastify/lib/util/EventManager.js new file mode 100644 index 00000000..e2314bc7 --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/lib/util/EventManager.js @@ -0,0 +1,47 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +var eventManager = { + eventList: new Map(), + + on: function on(event, callback) { + this.eventList.has(event) || this.eventList.set(event, []); + + this.eventList.get(event).push(callback); + + return this; + }, + off: function off() { + var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; + + return this.eventList.delete(event); + }, + emit: function emit(event) { + var _this = this; + + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + if (!this.eventList.has(event)) { + /* eslint no-console: 0 */ + console.warn("<" + event + "> Event is not registered. Did you forgot to bind the event ?"); + return false; + } + + this.eventList.get(event).forEach(function (callback) { + return setTimeout(function () { + return callback.call.apply(callback, [_this].concat(_toConsumableArray(args))); + }, 0); + }); + + return true; + } +}; + +exports.default = eventManager; \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/lib/util/objectValues.js b/goTorrentWebUI/node_modules/react-toastify/lib/util/objectValues.js new file mode 100644 index 00000000..15954359 --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/lib/util/objectValues.js @@ -0,0 +1,11 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +exports.default = function (obj) { + return Object.keys(obj).map(function (key) { + return obj[key]; + }); +}; \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/lib/util/propValidator.js b/goTorrentWebUI/node_modules/react-toastify/lib/util/propValidator.js new file mode 100644 index 00000000..792e176b --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/lib/util/propValidator.js @@ -0,0 +1,53 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.falseOrElement = exports.falseOrDelay = undefined; +exports.isValidDelay = isValidDelay; +exports.objectValues = objectValues; + +var _react = require('react'); + +function isValidDelay(val) { + return typeof val === 'number' && !isNaN(val) && val > 0; +} + +function objectValues(obj) { + return Object.keys(obj).map(function (key) { + return obj[key]; + }); +} + +function withRequired(fn) { + fn.isRequired = function (props, propName, componentName) { + var prop = props[propName]; + + if (typeof prop === 'undefined') { + return new Error('The prop ' + propName + ' is marked as required in \n ' + componentName + ', but its value is undefined.'); + } + + fn(props, propName, componentName); + }; + return fn; +} + +var falseOrDelay = exports.falseOrDelay = withRequired(function (props, propName, componentName) { + var prop = props[propName]; + + if (prop !== false && !isValidDelay(prop)) { + return new Error(componentName + ' expect ' + propName + ' \n to be a valid Number > 0 or equal to false. ' + prop + ' given.'); + } + + return null; +}); + +var falseOrElement = exports.falseOrElement = withRequired(function (props, propName, componentName) { + var prop = props[propName]; + + if (prop !== false && !(0, _react.isValidElement)(prop)) { + return new Error(componentName + ' expect ' + propName + ' \n to be a valid react element or equal to false. ' + prop + ' given.'); + } + + return null; +}); \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/node_modules/.bin/loose-envify b/goTorrentWebUI/node_modules/react-toastify/node_modules/.bin/loose-envify new file mode 100644 index 00000000..0939216f --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/node_modules/.bin/loose-envify @@ -0,0 +1,15 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + "$basedir/node" "$basedir/../loose-envify/cli.js" "$@" + ret=$? +else + node "$basedir/../loose-envify/cli.js" "$@" + ret=$? +fi +exit $ret diff --git a/goTorrentWebUI/node_modules/react-toastify/node_modules/.bin/loose-envify.cmd b/goTorrentWebUI/node_modules/react-toastify/node_modules/.bin/loose-envify.cmd new file mode 100644 index 00000000..6238bbb2 --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/node_modules/.bin/loose-envify.cmd @@ -0,0 +1,7 @@ +@IF EXIST "%~dp0\node.exe" ( + "%~dp0\node.exe" "%~dp0\..\loose-envify\cli.js" %* +) ELSE ( + @SETLOCAL + @SET PATHEXT=%PATHEXT:;.JS;=;% + node "%~dp0\..\loose-envify\cli.js" %* +) \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/node_modules/asap/CHANGES.md b/goTorrentWebUI/node_modules/react-toastify/node_modules/asap/CHANGES.md new file mode 100644 index 00000000..f105b919 --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/node_modules/asap/CHANGES.md @@ -0,0 +1,70 @@ + +## 2.0.6 + +Version 2.0.4 adds support for React Native by clarifying in package.json that +the browser environment does not support Node.js domains. +Why this is necessary, we leave as an exercise for the user. + +## 2.0.3 + +Version 2.0.3 fixes a bug when adjusting the capacity of the task queue. + +## 2.0.1-2.02 + +Version 2.0.1 fixes a bug in the way redirects were expressed that affected the +function of Browserify, but which Mr would tolerate. + +## 2.0.0 + +Version 2 of ASAP is a full rewrite with a few salient changes. +First, the ASAP source is CommonJS only and designed with [Browserify][] and +[Browserify-compatible][Mr] module loaders in mind. + +[Browserify]: https://github.com/substack/node-browserify +[Mr]: https://github.com/montagejs/mr + +The new version has been refactored in two dimensions. +Support for Node.js and browsers have been separated, using Browserify +redirects and ASAP has been divided into two modules. +The "raw" layer depends on the tasks to catch thrown exceptions and unravel +Node.js domains. + +The full implementation of ASAP is loadable as `require("asap")` in both Node.js +and browsers. + +The raw layer that lacks exception handling overhead is loadable as +`require("asap/raw")`. +The interface is the same for both layers. + +Tasks are no longer required to be functions, but can rather be any object that +implements `task.call()`. +With this feature you can recycle task objects to avoid garbage collector churn +and avoid closures in general. + +The implementation has been rigorously documented so that our successors can +understand the scope of the problem that this module solves and all of its +nuances, ensuring that the next generation of implementations know what details +are essential. + +- [asap.js](https://github.com/kriskowal/asap/blob/master/asap.js) +- [raw.js](https://github.com/kriskowal/asap/blob/master/raw.js) +- [browser-asap.js](https://github.com/kriskowal/asap/blob/master/browser-asap.js) +- [browser-raw.js](https://github.com/kriskowal/asap/blob/master/browser-raw.js) + +The new version has also been rigorously tested across a broad spectrum of +browsers, in both the window and worker context. +The following charts capture the browser test results for the most recent +release. +The first chart shows test results for ASAP running in the main window context. +The second chart shows test results for ASAP running in a web worker context. +Test results are inconclusive (grey) on browsers that do not support web +workers. +These data are captured automatically by [Continuous +Integration][]. + +![Browser Compatibility](http://kriskowal-asap.s3-website-us-west-2.amazonaws.com/train/integration-2/saucelabs-results-matrix.svg) + +![Compatibility in Web Workers](http://kriskowal-asap.s3-website-us-west-2.amazonaws.com/train/integration-2/saucelabs-worker-results-matrix.svg) + +[Continuous Integration]: https://github.com/kriskowal/asap/blob/master/CONTRIBUTING.md + diff --git a/goTorrentWebUI/node_modules/react-toastify/node_modules/asap/LICENSE.md b/goTorrentWebUI/node_modules/react-toastify/node_modules/asap/LICENSE.md new file mode 100644 index 00000000..ba18c613 --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/node_modules/asap/LICENSE.md @@ -0,0 +1,21 @@ + +Copyright 2009–2014 Contributors. All rights reserved. + +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. + diff --git a/goTorrentWebUI/node_modules/react-toastify/node_modules/asap/README.md b/goTorrentWebUI/node_modules/react-toastify/node_modules/asap/README.md new file mode 100644 index 00000000..452fd8c2 --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/node_modules/asap/README.md @@ -0,0 +1,237 @@ +# ASAP + +[![Build Status](https://travis-ci.org/kriskowal/asap.png?branch=master)](https://travis-ci.org/kriskowal/asap) + +Promise and asynchronous observer libraries, as well as hand-rolled callback +programs and libraries, often need a mechanism to postpone the execution of a +callback until the next available event. +(See [Designing API’s for Asynchrony][Zalgo].) +The `asap` function executes a task **as soon as possible** but not before it +returns, waiting only for the completion of the current event and previously +scheduled tasks. + +```javascript +asap(function () { + // ... +}); +``` + +[Zalgo]: http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony + +This CommonJS package provides an `asap` module that exports a function that +executes a task function *as soon as possible*. + +ASAP strives to schedule events to occur before yielding for IO, reflow, +or redrawing. +Each event receives an independent stack, with only platform code in parent +frames and the events run in the order they are scheduled. + +ASAP provides a fast event queue that will execute tasks until it is +empty before yielding to the JavaScript engine's underlying event-loop. +When a task gets added to a previously empty event queue, ASAP schedules a flush +event, preferring for that event to occur before the JavaScript engine has an +opportunity to perform IO tasks or rendering, thus making the first task and +subsequent tasks semantically indistinguishable. +ASAP uses a variety of techniques to preserve this invariant on different +versions of browsers and Node.js. + +By design, ASAP prevents input events from being handled until the task +queue is empty. +If the process is busy enough, this may cause incoming connection requests to be +dropped, and may cause existing connections to inform the sender to reduce the +transmission rate or stall. +ASAP allows this on the theory that, if there is enough work to do, there is no +sense in looking for trouble. +As a consequence, ASAP can interfere with smooth animation. +If your task should be tied to the rendering loop, consider using +`requestAnimationFrame` instead. +A long sequence of tasks can also effect the long running script dialog. +If this is a problem, you may be able to use ASAP’s cousin `setImmediate` to +break long processes into shorter intervals and periodically allow the browser +to breathe. +`setImmediate` will yield for IO, reflow, and repaint events. +It also returns a handler and can be canceled. +For a `setImmediate` shim, consider [YuzuJS setImmediate][setImmediate]. + +[setImmediate]: https://github.com/YuzuJS/setImmediate + +Take care. +ASAP can sustain infinite recursive calls without warning. +It will not halt from a stack overflow, and it will not consume unbounded +memory. +This is behaviorally equivalent to an infinite loop. +Just as with infinite loops, you can monitor a Node.js process for this behavior +with a heart-beat signal. +As with infinite loops, a very small amount of caution goes a long way to +avoiding problems. + +```javascript +function loop() { + asap(loop); +} +loop(); +``` + +In browsers, if a task throws an exception, it will not interrupt the flushing +of high-priority tasks. +The exception will be postponed to a later, low-priority event to avoid +slow-downs. +In Node.js, if a task throws an exception, ASAP will resume flushing only if—and +only after—the error is handled by `domain.on("error")` or +`process.on("uncaughtException")`. + +## Raw ASAP + +Checking for exceptions comes at a cost. +The package also provides an `asap/raw` module that exports the underlying +implementation which is faster but stalls if a task throws an exception. +This internal version of the ASAP function does not check for errors. +If a task does throw an error, it will stall the event queue unless you manually +call `rawAsap.requestFlush()` before throwing the error, or any time after. + +In Node.js, `asap/raw` also runs all tasks outside any domain. +If you need a task to be bound to your domain, you will have to do it manually. + +```js +if (process.domain) { + task = process.domain.bind(task); +} +rawAsap(task); +``` + +## Tasks + +A task may be any object that implements `call()`. +A function will suffice, but closures tend not to be reusable and can cause +garbage collector churn. +Both `asap` and `rawAsap` accept task objects to give you the option of +recycling task objects or using higher callable object abstractions. +See the `asap` source for an illustration. + + +## Compatibility + +ASAP is tested on Node.js v0.10 and in a broad spectrum of web browsers. +The following charts capture the browser test results for the most recent +release. +The first chart shows test results for ASAP running in the main window context. +The second chart shows test results for ASAP running in a web worker context. +Test results are inconclusive (grey) on browsers that do not support web +workers. +These data are captured automatically by [Continuous +Integration][]. + +[Continuous Integration]: https://github.com/kriskowal/asap/blob/master/CONTRIBUTING.md + +![Browser Compatibility](http://kriskowal-asap.s3-website-us-west-2.amazonaws.com/train/integration-2/saucelabs-results-matrix.svg) + +![Compatibility in Web Workers](http://kriskowal-asap.s3-website-us-west-2.amazonaws.com/train/integration-2/saucelabs-worker-results-matrix.svg) + +## Caveats + +When a task is added to an empty event queue, it is not always possible to +guarantee that the task queue will begin flushing immediately after the current +event. +However, once the task queue begins flushing, it will not yield until the queue +is empty, even if the queue grows while executing tasks. + +The following browsers allow the use of [DOM mutation observers][] to access +the HTML [microtask queue][], and thus begin flushing ASAP's task queue +immediately at the end of the current event loop turn, before any rendering or +IO: + +[microtask queue]: http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#microtask-queue +[DOM mutation observers]: http://dom.spec.whatwg.org/#mutation-observers + +- Android 4–4.3 +- Chrome 26–34 +- Firefox 14–29 +- Internet Explorer 11 +- iPad Safari 6–7.1 +- iPhone Safari 7–7.1 +- Safari 6–7 + +In the absense of mutation observers, there are a few browsers, and situations +like web workers in some of the above browsers, where [message channels][] +would be a useful way to avoid falling back to timers. +Message channels give direct access to the HTML [task queue][], so the ASAP +task queue would flush after any already queued rendering and IO tasks, but +without having the minimum delay imposed by timers. +However, among these browsers, Internet Explorer 10 and Safari do not reliably +dispatch messages, so they are not worth the trouble to implement. + +[message channels]: http://www.whatwg.org/specs/web-apps/current-work/multipage/web-messaging.html#message-channels +[task queue]: http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#concept-task + +- Internet Explorer 10 +- Safair 5.0-1 +- Opera 11-12 + +In the absense of mutation observers, these browsers and the following browsers +all fall back to using `setTimeout` and `setInterval` to ensure that a `flush` +occurs. +The implementation uses both and cancels whatever handler loses the race, since +`setTimeout` tends to occasionally skip tasks in unisolated circumstances. +Timers generally delay the flushing of ASAP's task queue for four milliseconds. + +- Firefox 3–13 +- Internet Explorer 6–10 +- iPad Safari 4.3 +- Lynx 2.8.7 + + +## Heritage + +ASAP has been factored out of the [Q][] asynchronous promise library. +It originally had a naïve implementation in terms of `setTimeout`, but +[Malte Ubl][NonBlocking] provided an insight that `postMessage` might be +useful for creating a high-priority, no-delay event dispatch hack. +Since then, Internet Explorer proposed and implemented `setImmediate`. +Robert Katić began contributing to Q by measuring the performance of +the internal implementation of `asap`, paying particular attention to +error recovery. +Domenic, Robert, and Kris Kowal collectively settled on the current strategy of +unrolling the high-priority event queue internally regardless of what strategy +we used to dispatch the potentially lower-priority flush event. +Domenic went on to make ASAP cooperate with Node.js domains. + +[Q]: https://github.com/kriskowal/q +[NonBlocking]: http://www.nonblocking.io/2011/06/windownexttick.html + +For further reading, Nicholas Zakas provided a thorough article on [The +Case for setImmediate][NCZ]. + +[NCZ]: http://www.nczonline.net/blog/2013/07/09/the-case-for-setimmediate/ + +Ember’s RSVP promise implementation later [adopted][RSVP ASAP] the name ASAP but +further developed the implentation. +Particularly, The `MessagePort` implementation was abandoned due to interaction +[problems with Mobile Internet Explorer][IE Problems] in favor of an +implementation backed on the newer and more reliable DOM `MutationObserver` +interface. +These changes were back-ported into this library. + +[IE Problems]: https://github.com/cujojs/when/issues/197 +[RSVP ASAP]: https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js + +In addition, ASAP factored into `asap` and `asap/raw`, such that `asap` remained +exception-safe, but `asap/raw` provided a tight kernel that could be used for +tasks that guaranteed that they would not throw exceptions. +This core is useful for promise implementations that capture thrown errors in +rejected promises and do not need a second safety net. +At the same time, the exception handling in `asap` was factored into separate +implementations for Node.js and browsers, using the the [Browserify][Browser +Config] `browser` property in `package.json` to instruct browser module loaders +and bundlers, including [Browserify][], [Mr][], and [Mop][], to use the +browser-only implementation. + +[Browser Config]: https://gist.github.com/defunctzombie/4339901 +[Browserify]: https://github.com/substack/node-browserify +[Mr]: https://github.com/montagejs/mr +[Mop]: https://github.com/montagejs/mop + +## License + +Copyright 2009-2014 by Contributors +MIT License (enclosed) + diff --git a/goTorrentWebUI/node_modules/react-toastify/node_modules/asap/asap.js b/goTorrentWebUI/node_modules/react-toastify/node_modules/asap/asap.js new file mode 100644 index 00000000..f04fcd58 --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/node_modules/asap/asap.js @@ -0,0 +1,65 @@ +"use strict"; + +var rawAsap = require("./raw"); +var freeTasks = []; + +/** + * Calls a task as soon as possible after returning, in its own event, with + * priority over IO events. An exception thrown in a task can be handled by + * `process.on("uncaughtException") or `domain.on("error")`, but will otherwise + * crash the process. If the error is handled, all subsequent tasks will + * resume. + * + * @param {{call}} task A callable object, typically a function that takes no + * arguments. + */ +module.exports = asap; +function asap(task) { + var rawTask; + if (freeTasks.length) { + rawTask = freeTasks.pop(); + } else { + rawTask = new RawTask(); + } + rawTask.task = task; + rawTask.domain = process.domain; + rawAsap(rawTask); +} + +function RawTask() { + this.task = null; + this.domain = null; +} + +RawTask.prototype.call = function () { + if (this.domain) { + this.domain.enter(); + } + var threw = true; + try { + this.task.call(); + threw = false; + // If the task throws an exception (presumably) Node.js restores the + // domain stack for the next event. + if (this.domain) { + this.domain.exit(); + } + } finally { + // We use try/finally and a threw flag to avoid messing up stack traces + // when we catch and release errors. + if (threw) { + // In Node.js, uncaught exceptions are considered fatal errors. + // Re-throw them to interrupt flushing! + // Ensure that flushing continues if an uncaught exception is + // suppressed listening process.on("uncaughtException") or + // domain.on("error"). + rawAsap.requestFlush(); + } + // If the task threw an error, we do not want to exit the domain here. + // Exiting the domain would prevent the domain from catching the error. + this.task = null; + this.domain = null; + freeTasks.push(this); + } +}; + diff --git a/goTorrentWebUI/node_modules/react-toastify/node_modules/asap/browser-asap.js b/goTorrentWebUI/node_modules/react-toastify/node_modules/asap/browser-asap.js new file mode 100644 index 00000000..805c9824 --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/node_modules/asap/browser-asap.js @@ -0,0 +1,66 @@ +"use strict"; + +// rawAsap provides everything we need except exception management. +var rawAsap = require("./raw"); +// RawTasks are recycled to reduce GC churn. +var freeTasks = []; +// We queue errors to ensure they are thrown in right order (FIFO). +// Array-as-queue is good enough here, since we are just dealing with exceptions. +var pendingErrors = []; +var requestErrorThrow = rawAsap.makeRequestCallFromTimer(throwFirstError); + +function throwFirstError() { + if (pendingErrors.length) { + throw pendingErrors.shift(); + } +} + +/** + * Calls a task as soon as possible after returning, in its own event, with priority + * over other events like animation, reflow, and repaint. An error thrown from an + * event will not interrupt, nor even substantially slow down the processing of + * other events, but will be rather postponed to a lower priority event. + * @param {{call}} task A callable object, typically a function that takes no + * arguments. + */ +module.exports = asap; +function asap(task) { + var rawTask; + if (freeTasks.length) { + rawTask = freeTasks.pop(); + } else { + rawTask = new RawTask(); + } + rawTask.task = task; + rawAsap(rawTask); +} + +// We wrap tasks with recyclable task objects. A task object implements +// `call`, just like a function. +function RawTask() { + this.task = null; +} + +// The sole purpose of wrapping the task is to catch the exception and recycle +// the task object after its single use. +RawTask.prototype.call = function () { + try { + this.task.call(); + } catch (error) { + if (asap.onerror) { + // This hook exists purely for testing purposes. + // Its name will be periodically randomized to break any code that + // depends on its existence. + asap.onerror(error); + } else { + // In a web browser, exceptions are not fatal. However, to avoid + // slowing down the queue of pending tasks, we rethrow the error in a + // lower priority turn. + pendingErrors.push(error); + requestErrorThrow(); + } + } finally { + this.task = null; + freeTasks[freeTasks.length] = this; + } +}; diff --git a/goTorrentWebUI/node_modules/react-toastify/node_modules/asap/browser-raw.js b/goTorrentWebUI/node_modules/react-toastify/node_modules/asap/browser-raw.js new file mode 100644 index 00000000..9cee7e32 --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/node_modules/asap/browser-raw.js @@ -0,0 +1,223 @@ +"use strict"; + +// Use the fastest means possible to execute a task in its own turn, with +// priority over other events including IO, animation, reflow, and redraw +// events in browsers. +// +// An exception thrown by a task will permanently interrupt the processing of +// subsequent tasks. The higher level `asap` function ensures that if an +// exception is thrown by a task, that the task queue will continue flushing as +// soon as possible, but if you use `rawAsap` directly, you are responsible to +// either ensure that no exceptions are thrown from your task, or to manually +// call `rawAsap.requestFlush` if an exception is thrown. +module.exports = rawAsap; +function rawAsap(task) { + if (!queue.length) { + requestFlush(); + flushing = true; + } + // Equivalent to push, but avoids a function call. + queue[queue.length] = task; +} + +var queue = []; +// Once a flush has been requested, no further calls to `requestFlush` are +// necessary until the next `flush` completes. +var flushing = false; +// `requestFlush` is an implementation-specific method that attempts to kick +// off a `flush` event as quickly as possible. `flush` will attempt to exhaust +// the event queue before yielding to the browser's own event loop. +var requestFlush; +// The position of the next task to execute in the task queue. This is +// preserved between calls to `flush` so that it can be resumed if +// a task throws an exception. +var index = 0; +// If a task schedules additional tasks recursively, the task queue can grow +// unbounded. To prevent memory exhaustion, the task queue will periodically +// truncate already-completed tasks. +var capacity = 1024; + +// The flush function processes all tasks that have been scheduled with +// `rawAsap` unless and until one of those tasks throws an exception. +// If a task throws an exception, `flush` ensures that its state will remain +// consistent and will resume where it left off when called again. +// However, `flush` does not make any arrangements to be called again if an +// exception is thrown. +function flush() { + while (index < queue.length) { + var currentIndex = index; + // Advance the index before calling the task. This ensures that we will + // begin flushing on the next task the task throws an error. + index = index + 1; + queue[currentIndex].call(); + // Prevent leaking memory for long chains of recursive calls to `asap`. + // If we call `asap` within tasks scheduled by `asap`, the queue will + // grow, but to avoid an O(n) walk for every task we execute, we don't + // shift tasks off the queue after they have been executed. + // Instead, we periodically shift 1024 tasks off the queue. + if (index > capacity) { + // Manually shift all values starting at the index back to the + // beginning of the queue. + for (var scan = 0, newLength = queue.length - index; scan < newLength; scan++) { + queue[scan] = queue[scan + index]; + } + queue.length -= index; + index = 0; + } + } + queue.length = 0; + index = 0; + flushing = false; +} + +// `requestFlush` is implemented using a strategy based on data collected from +// every available SauceLabs Selenium web driver worker at time of writing. +// https://docs.google.com/spreadsheets/d/1mG-5UYGup5qxGdEMWkhP6BWCz053NUb2E1QoUTU16uA/edit#gid=783724593 + +// Safari 6 and 6.1 for desktop, iPad, and iPhone are the only browsers that +// have WebKitMutationObserver but not un-prefixed MutationObserver. +// Must use `global` or `self` instead of `window` to work in both frames and web +// workers. `global` is a provision of Browserify, Mr, Mrs, or Mop. + +/* globals self */ +var scope = typeof global !== "undefined" ? global : self; +var BrowserMutationObserver = scope.MutationObserver || scope.WebKitMutationObserver; + +// MutationObservers are desirable because they have high priority and work +// reliably everywhere they are implemented. +// They are implemented in all modern browsers. +// +// - Android 4-4.3 +// - Chrome 26-34 +// - Firefox 14-29 +// - Internet Explorer 11 +// - iPad Safari 6-7.1 +// - iPhone Safari 7-7.1 +// - Safari 6-7 +if (typeof BrowserMutationObserver === "function") { + requestFlush = makeRequestCallFromMutationObserver(flush); + +// MessageChannels are desirable because they give direct access to the HTML +// task queue, are implemented in Internet Explorer 10, Safari 5.0-1, and Opera +// 11-12, and in web workers in many engines. +// Although message channels yield to any queued rendering and IO tasks, they +// would be better than imposing the 4ms delay of timers. +// However, they do not work reliably in Internet Explorer or Safari. + +// Internet Explorer 10 is the only browser that has setImmediate but does +// not have MutationObservers. +// Although setImmediate yields to the browser's renderer, it would be +// preferrable to falling back to setTimeout since it does not have +// the minimum 4ms penalty. +// Unfortunately there appears to be a bug in Internet Explorer 10 Mobile (and +// Desktop to a lesser extent) that renders both setImmediate and +// MessageChannel useless for the purposes of ASAP. +// https://github.com/kriskowal/q/issues/396 + +// Timers are implemented universally. +// We fall back to timers in workers in most engines, and in foreground +// contexts in the following browsers. +// However, note that even this simple case requires nuances to operate in a +// broad spectrum of browsers. +// +// - Firefox 3-13 +// - Internet Explorer 6-9 +// - iPad Safari 4.3 +// - Lynx 2.8.7 +} else { + requestFlush = makeRequestCallFromTimer(flush); +} + +// `requestFlush` requests that the high priority event queue be flushed as +// soon as possible. +// This is useful to prevent an error thrown in a task from stalling the event +// queue if the exception handled by Node.js’s +// `process.on("uncaughtException")` or by a domain. +rawAsap.requestFlush = requestFlush; + +// To request a high priority event, we induce a mutation observer by toggling +// the text of a text node between "1" and "-1". +function makeRequestCallFromMutationObserver(callback) { + var toggle = 1; + var observer = new BrowserMutationObserver(callback); + var node = document.createTextNode(""); + observer.observe(node, {characterData: true}); + return function requestCall() { + toggle = -toggle; + node.data = toggle; + }; +} + +// The message channel technique was discovered by Malte Ubl and was the +// original foundation for this library. +// http://www.nonblocking.io/2011/06/windownexttick.html + +// Safari 6.0.5 (at least) intermittently fails to create message ports on a +// page's first load. Thankfully, this version of Safari supports +// MutationObservers, so we don't need to fall back in that case. + +// function makeRequestCallFromMessageChannel(callback) { +// var channel = new MessageChannel(); +// channel.port1.onmessage = callback; +// return function requestCall() { +// channel.port2.postMessage(0); +// }; +// } + +// For reasons explained above, we are also unable to use `setImmediate` +// under any circumstances. +// Even if we were, there is another bug in Internet Explorer 10. +// It is not sufficient to assign `setImmediate` to `requestFlush` because +// `setImmediate` must be called *by name* and therefore must be wrapped in a +// closure. +// Never forget. + +// function makeRequestCallFromSetImmediate(callback) { +// return function requestCall() { +// setImmediate(callback); +// }; +// } + +// Safari 6.0 has a problem where timers will get lost while the user is +// scrolling. This problem does not impact ASAP because Safari 6.0 supports +// mutation observers, so that implementation is used instead. +// However, if we ever elect to use timers in Safari, the prevalent work-around +// is to add a scroll event listener that calls for a flush. + +// `setTimeout` does not call the passed callback if the delay is less than +// approximately 7 in web workers in Firefox 8 through 18, and sometimes not +// even then. + +function makeRequestCallFromTimer(callback) { + return function requestCall() { + // We dispatch a timeout with a specified delay of 0 for engines that + // can reliably accommodate that request. This will usually be snapped + // to a 4 milisecond delay, but once we're flushing, there's no delay + // between events. + var timeoutHandle = setTimeout(handleTimer, 0); + // However, since this timer gets frequently dropped in Firefox + // workers, we enlist an interval handle that will try to fire + // an event 20 times per second until it succeeds. + var intervalHandle = setInterval(handleTimer, 50); + + function handleTimer() { + // Whichever timer succeeds will cancel both timers and + // execute the callback. + clearTimeout(timeoutHandle); + clearInterval(intervalHandle); + callback(); + } + }; +} + +// This is for `asap.js` only. +// Its name will be periodically randomized to break any code that depends on +// its existence. +rawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer; + +// ASAP was originally a nextTick shim included in Q. This was factored out +// into this ASAP package. It was later adapted to RSVP which made further +// amendments. These decisions, particularly to marginalize MessageChannel and +// to capture the MutationObserver implementation in a closure, were integrated +// back into ASAP proper. +// https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js diff --git a/goTorrentWebUI/node_modules/react-toastify/node_modules/asap/package.json b/goTorrentWebUI/node_modules/react-toastify/node_modules/asap/package.json new file mode 100644 index 00000000..48fd32cc --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/node_modules/asap/package.json @@ -0,0 +1,87 @@ +{ + "_from": "asap@~2.0.3", + "_id": "asap@2.0.6", + "_inBundle": false, + "_integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=", + "_location": "/react-toastify/asap", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "asap@~2.0.3", + "name": "asap", + "escapedName": "asap", + "rawSpec": "~2.0.3", + "saveSpec": null, + "fetchSpec": "~2.0.3" + }, + "_requiredBy": [ + "/react-toastify/promise" + ], + "_resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "_shasum": "e50347611d7e690943208bbdafebcbc2fb866d46", + "_spec": "asap@~2.0.3", + "_where": "C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\goTorrentWebUI\\node_modules\\react-toastify\\node_modules\\promise", + "browser": { + "./asap": "./browser-asap.js", + "./asap.js": "./browser-asap.js", + "./raw": "./browser-raw.js", + "./raw.js": "./browser-raw.js", + "./test/domain.js": "./test/browser-domain.js" + }, + "bugs": { + "url": "https://github.com/kriskowal/asap/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "High-priority task queue for Node.js and browsers", + "devDependencies": { + "benchmark": "^1.0.0", + "events": "^1.0.1", + "jshint": "^2.5.1", + "knox": "^0.8.10", + "mr": "^2.0.5", + "opener": "^1.3.0", + "q": "^2.0.3", + "q-io": "^2.0.3", + "saucelabs": "^0.1.1", + "wd": "^0.2.21", + "weak-map": "^1.0.5" + }, + "files": [ + "raw.js", + "asap.js", + "browser-raw.js", + "browser-asap.js" + ], + "homepage": "https://github.com/kriskowal/asap#readme", + "keywords": [ + "event", + "task", + "queue" + ], + "license": "MIT", + "main": "./asap.js", + "name": "asap", + "react-native": { + "domain": false + }, + "repository": { + "type": "git", + "url": "git+https://github.com/kriskowal/asap.git" + }, + "scripts": { + "benchmarks": "node benchmarks", + "lint": "jshint raw.js asap.js browser-raw.js browser-asap.js $(find scripts -name '*.js' | grep -v gauntlet)", + "test": "npm run lint && npm run test-node", + "test-browser": "node scripts/publish-bundle.js test/asap-test.js | xargs opener", + "test-node": "node test/asap-test.js", + "test-publish": "node scripts/publish-bundle.js test/asap-test.js | pbcopy", + "test-saucelabs": "node scripts/saucelabs.js test/asap-test.js scripts/saucelabs-spot-configurations.json", + "test-saucelabs-all": "node scripts/saucelabs.js test/asap-test.js scripts/saucelabs-all-configurations.json", + "test-saucelabs-worker": "node scripts/saucelabs-worker-test.js scripts/saucelabs-spot-configurations.json", + "test-saucelabs-worker-all": "node scripts/saucelabs-worker-test.js scripts/saucelabs-all-configurations.json", + "test-travis": "npm run lint && npm run test-node && npm run test-saucelabs && npm run test-saucelabs-worker" + }, + "version": "2.0.6" +} diff --git a/goTorrentWebUI/node_modules/react-toastify/node_modules/asap/raw.js b/goTorrentWebUI/node_modules/react-toastify/node_modules/asap/raw.js new file mode 100644 index 00000000..ae3b8923 --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/node_modules/asap/raw.js @@ -0,0 +1,101 @@ +"use strict"; + +var domain; // The domain module is executed on demand +var hasSetImmediate = typeof setImmediate === "function"; + +// Use the fastest means possible to execute a task in its own turn, with +// priority over other events including network IO events in Node.js. +// +// An exception thrown by a task will permanently interrupt the processing of +// subsequent tasks. The higher level `asap` function ensures that if an +// exception is thrown by a task, that the task queue will continue flushing as +// soon as possible, but if you use `rawAsap` directly, you are responsible to +// either ensure that no exceptions are thrown from your task, or to manually +// call `rawAsap.requestFlush` if an exception is thrown. +module.exports = rawAsap; +function rawAsap(task) { + if (!queue.length) { + requestFlush(); + flushing = true; + } + // Avoids a function call + queue[queue.length] = task; +} + +var queue = []; +// Once a flush has been requested, no further calls to `requestFlush` are +// necessary until the next `flush` completes. +var flushing = false; +// The position of the next task to execute in the task queue. This is +// preserved between calls to `flush` so that it can be resumed if +// a task throws an exception. +var index = 0; +// If a task schedules additional tasks recursively, the task queue can grow +// unbounded. To prevent memory excaustion, the task queue will periodically +// truncate already-completed tasks. +var capacity = 1024; + +// The flush function processes all tasks that have been scheduled with +// `rawAsap` unless and until one of those tasks throws an exception. +// If a task throws an exception, `flush` ensures that its state will remain +// consistent and will resume where it left off when called again. +// However, `flush` does not make any arrangements to be called again if an +// exception is thrown. +function flush() { + while (index < queue.length) { + var currentIndex = index; + // Advance the index before calling the task. This ensures that we will + // begin flushing on the next task the task throws an error. + index = index + 1; + queue[currentIndex].call(); + // Prevent leaking memory for long chains of recursive calls to `asap`. + // If we call `asap` within tasks scheduled by `asap`, the queue will + // grow, but to avoid an O(n) walk for every task we execute, we don't + // shift tasks off the queue after they have been executed. + // Instead, we periodically shift 1024 tasks off the queue. + if (index > capacity) { + // Manually shift all values starting at the index back to the + // beginning of the queue. + for (var scan = 0, newLength = queue.length - index; scan < newLength; scan++) { + queue[scan] = queue[scan + index]; + } + queue.length -= index; + index = 0; + } + } + queue.length = 0; + index = 0; + flushing = false; +} + +rawAsap.requestFlush = requestFlush; +function requestFlush() { + // Ensure flushing is not bound to any domain. + // It is not sufficient to exit the domain, because domains exist on a stack. + // To execute code outside of any domain, the following dance is necessary. + var parentDomain = process.domain; + if (parentDomain) { + if (!domain) { + // Lazy execute the domain module. + // Only employed if the user elects to use domains. + domain = require("domain"); + } + domain.active = process.domain = null; + } + + // `setImmediate` is slower that `process.nextTick`, but `process.nextTick` + // cannot handle recursion. + // `requestFlush` will only be called recursively from `asap.js`, to resume + // flushing after an error is thrown into a domain. + // Conveniently, `setImmediate` was introduced in the same version + // `process.nextTick` started throwing recursion errors. + if (flushing && hasSetImmediate) { + setImmediate(flush); + } else { + process.nextTick(flush); + } + + if (parentDomain) { + domain.active = process.domain = parentDomain; + } +} diff --git a/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.editorconfig b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.editorconfig new file mode 100644 index 00000000..a11eb44b --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.editorconfig @@ -0,0 +1,17 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true + +[{*.js,*.md}] +charset = utf-8 +indent_style = space +indent_size = 2 + +[Makefile] +indent_style = tab + +[{package.json,.travis.yml}] +indent_style = space +indent_size = 2 diff --git a/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/.name b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/.name new file mode 100644 index 00000000..3e2e4036 --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/.name @@ -0,0 +1 @@ +bowser \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/bowser.iml b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/bowser.iml new file mode 100644 index 00000000..c956989b --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/bowser.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/encodings.xml b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/encodings.xml new file mode 100644 index 00000000..97626ba4 --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/inspectionProfiles/Project_Default.xml b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 00000000..c6cc8c81 --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/jsLibraryMappings.xml b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/jsLibraryMappings.xml new file mode 100644 index 00000000..9bd3e336 --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/jsLibraryMappings.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/markdown-exported-files.xml b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/markdown-exported-files.xml new file mode 100644 index 00000000..5d1f1293 --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/markdown-exported-files.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/markdown-navigator.xml b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/markdown-navigator.xml new file mode 100644 index 00000000..05e6c4b6 --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/markdown-navigator.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/markdown-navigator/profiles_settings.xml b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/markdown-navigator/profiles_settings.xml new file mode 100644 index 00000000..57927c5a --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/markdown-navigator/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/misc.xml b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/misc.xml new file mode 100644 index 00000000..28a804d8 --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/modules.xml b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/modules.xml new file mode 100644 index 00000000..d90ae6dd --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/vcs.xml b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/vcs.xml new file mode 100644 index 00000000..94a25f7f --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/watcherTasks.xml b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/watcherTasks.xml new file mode 100644 index 00000000..9338ba68 --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/watcherTasks.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/workspace.xml b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/workspace.xml new file mode 100644 index 00000000..56c48de2 --- /dev/null +++ b/goTorrentWebUI/node_modules/react-toastify/node_modules/bowser/.idea/workspace.xml @@ -0,0 +1,745 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + amazon Silk + load + parseFile + default + Windows Phone + Webos + Mozilla/5.0 (Linux; U; Android 4.4.2; de-de; Nexus 7 Build/KOT49H) AppleWebKit/537.16 (KHTML, like Gecko) Version/4.0 Mobile Safari/537.16 + like + Mozilla/5.0 (Maemo; Linux; U; Jolla; Sailfish; Mobile; rv:26.0) Gecko/26.0 Firefox/26.0 SailfishBrowser/1.0 like Safari/538.1 + Sa + Sailfish + Firefox + sailfish + boos + opera m + Mozilla/5.0 (Linux; U; Android 6.0; R1 HD Build/MRA58K; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/52.0.2743.98 Mobile Safari/537.36 OPR/18.0.2254.106542 + isUnsup + name: '[a-zA-Z ]+'\s+, + Chrome + OPR + ios + safari + iphone + chromium: true + flag + msedge + edge + Mozilla/5.0 (Linux; Android 8.0; Pixel XL Build/OPP3.170518.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.0 Mobile Safari/537.36 EdgA/41.1.35.1 + version: "" + Mozilla/5.0 (iPod touch; CPU iPhone OS 9_3_4 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) OPiOS/14.0.0.104835 Mobile/13G35 Safari/9537.53 + + + descript + describe + (\d+(\.?_?\d+)+) + + + + + + + + + + + + + false + + false + false + true + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +