mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 13:42:20 +00:00
0.2.0 - Mid migration
This commit is contained in:
parent
139e6a915e
commit
7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions
21
web/node_modules/redux/LICENSE.md
generated
vendored
Normal file
21
web/node_modules/redux/LICENSE.md
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-present Dan Abramov
|
||||
|
||||
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.
|
322
web/node_modules/redux/README.md
generated
vendored
Normal file
322
web/node_modules/redux/README.md
generated
vendored
Normal file
|
@ -0,0 +1,322 @@
|
|||
# <a href='http://redux.js.org'><img src='https://camo.githubusercontent.com/f28b5bc7822f1b7bb28a96d8d09e7d79169248fc/687474703a2f2f692e696d6775722e636f6d2f4a65567164514d2e706e67' height='60' alt='Redux Logo' aria-label='redux.js.org' /></a>
|
||||
|
||||
Redux is a predictable state container for JavaScript apps.
|
||||
(Not to be confused with a WordPress framework – [Redux Framework](https://reduxframework.com/).)
|
||||
|
||||
It helps you write applications that behave consistently, run in different environments (client, server, and native), and are easy to test. On top of that, it provides a great developer experience, such as [live code editing combined with a time traveling debugger](https://github.com/reduxjs/redux-devtools).
|
||||
|
||||
You can use Redux together with [React](https://reactjs.org), or with any other view library.
|
||||
It is tiny (2kB, including dependencies).
|
||||
|
||||
> **Note**: We are currently planning a rewrite of the Redux docs. Please take some time to **[fill out this survey on what content is most important in a docs site](https://docs.google.com/forms/d/e/1FAIpQLSfzIkY3fXZ8PrQKScYMK0YoEgALfAK2qQ0mOj1_ibKv2qDTuQ/viewform)**. Thanks!
|
||||
|
||||
[](https://travis-ci.org/reduxjs/redux)
|
||||
[](https://www.npmjs.com/package/redux)
|
||||
[](https://www.npmjs.com/package/redux)
|
||||
[](https://discord.gg/0ZcbPKXt5bZ6au5t)
|
||||
[](https://changelog.com/187)
|
||||
|
||||
## Learn Redux
|
||||
|
||||
We have a variety of resources available to help you learn Redux, no matter what your background or learning style is.
|
||||
|
||||
### Just the Basics
|
||||
|
||||
If you're brand new to Redux and want to understand the basic concepts, see:
|
||||
|
||||
- The **[Motivation](https://redux.js.org/introduction/motivation)** behind building Redux, the **[Core Concepts](https://redux.js.org/introduction/coreconcepts)**, and the **[Three Principles](https://redux.js.org/introduction/threeprinciples)**.
|
||||
- The **[basic tutorial in the Redux docs](https://redux.js.org/basics)**
|
||||
- Redux creator Dan Abramov's **free ["Getting Started with Redux" video series](https://egghead.io/series/getting-started-with-redux)** on Egghead.io
|
||||
- Redux co-maintainer Mark Erikson's **["Redux Fundamentals" slideshow](http://blog.isquaredsoftware.com/2018/03/presentation-reactathon-redux-fundamentals/)** and **[list of suggested resources for learning Redux](http://blog.isquaredsoftware.com/2017/12/blogged-answers-learn-redux/)**
|
||||
- If you learn best by looking at code and playing with it, check out our list of **[Redux example applications](https://redux.js.org/introduction/examples)**, available as separate projects in the Redux repo, and also as interactive online examples on CodeSandbox.
|
||||
- The **[Redux Tutorials](https://github.com/markerikson/react-redux-links/blob/master/redux-tutorials.md)** section of the **[React/Redux links list](https://github.com/markerikson/react-redux-links)**. Here's a top list of our recommended tutorials:
|
||||
- Dave Ceddia's posts [What Does Redux Do? (and when should you use it?)](https://daveceddia.com/what-does-redux-do/) and [How Redux Works: A Counter-Example](https://daveceddia.com/how-does-redux-work/) are a great intro to the basics of Redux and how to use it with React, as is this post on [React and Redux: An Introduction](http://jakesidsmith.com/blog/post/2017-11-18-redux-and-react-an-introduction/).
|
||||
- Valentino Gagliardi's post [React Redux Tutorial for Beginners: Learning Redux in 2018](https://www.valentinog.com/blog/react-redux-tutorial-beginners/) is an excellent extended introduction to many aspects of using Redux.
|
||||
- The CSS Tricks article [Leveling Up with React: Redux](https://css-tricks.com/learning-react-redux/) covers the Redux basics well.
|
||||
- This [DevGuides: Introduction to Redux](http://devguides.io/redux/) tutorial covers several aspects of Redux, including actions, reducers, usage with React, and middleware.
|
||||
|
||||
### Intermediate Concepts
|
||||
|
||||
Once you've picked up the basics of working with actions, reducers, and the store, you may have questions about topics like working with asynchronous logic and AJAX requests, connecting a UI framework like React to your Redux store, and setting up an application to use Redux:
|
||||
|
||||
- The **["Advanced" docs section](https://redux.js.org/advanced)** covers working with async logic, middleware, routing.
|
||||
- The Redux docs **["Learning Resources"](https://redux.js.org/introduction/learning-resources)** page points to recommended articles on a variety of Redux-related topics.
|
||||
- Sophie DeBenedetto's 8-part **[Building a Simple CRUD App with React + Redux](http://www.thegreatcodeadventure.com/building-a-simple-crud-app-with-react-redux-part-1/)** series shows how to put together a basic CRUD app from scratch.
|
||||
|
||||
### Real-World Usage
|
||||
|
||||
Going from a TodoMVC app to a real production application can be a big jump, but we've got plenty of resources to help:
|
||||
|
||||
- Redux creator Dan Abramov's **[free "Building React Applications with Idiomatic Redux" video series](https://egghead.io/courses/building-react-applications-with-idiomatic-redux)** builds on his first video series and covers topics like middleware, routing, and persistence.
|
||||
- The **[Redux FAQ](https://redux.js.org/faq)** answers many common questions about how to use Redux, and the **["Recipes" docs section](https://redux.js.org/recipes)** has information on handling derived data, testing, structuring reducer logic, and reducing boilerplate.
|
||||
- Redux co-maintainer Mark Erikson's **["Practical Redux" tutorial series](http://blog.isquaredsoftware.com/series/practical-redux/)** demonstrates real-world intermediate and advanced techniques for working with React and Redux (also available as **[an interactive course on Educative.io](https://www.educative.io/collection/5687753853370368/5707702298738688)**).
|
||||
- The **[React/Redux links list](https://github.com/markerikson/react-redux-links)** has categorized articles on working with [reducers and selectors](https://github.com/markerikson/react-redux-links/blob/master/redux-reducers-selectors.md), [managing side effects](https://github.com/markerikson/react-redux-links/blob/master/redux-side-effects.md), [Redux architecture and best practices](https://github.com/markerikson/react-redux-links/blob/master/redux-architecture.md), and more.
|
||||
- Our community has created thousands of Redux-related libraries, addons, and tools. The **["Ecosystem" docs page](https://redux.js.org/introduction/ecosystem)** lists our recommendations, and there's a complete listing available in the **[Redux addons catalog](https://github.com/markerikson/redux-ecosystem-links)**.
|
||||
- If you're looking to learn from actual application codebases, the addons catalog also has a list of **[purpose-built examples and real-world applications](https://github.com/markerikson/redux-ecosystem-links/blob/master/apps-and-examples.md)**.
|
||||
|
||||
Finally, Mark Erikson is teaching a series of **[Redux workshops through Workshop.me](#redux-workshops)**. Check the [workshop schedule](https://workshop.me/?a=mark) for upcoming dates and locations.
|
||||
|
||||
### Help and Discussion
|
||||
|
||||
The **[#redux channel](https://discord.gg/0ZcbPKXt5bZ6au5t)** of the **[Reactiflux Discord community](http://www.reactiflux.com)** is our official resource for all questions related to learning and using Redux. Reactiflux is a great place to hang out, ask questions, and learn - come join us!
|
||||
|
||||
## Before Proceeding Further
|
||||
|
||||
Redux is a valuable tool for organizing your state, but you should also consider whether it's appropriate for your situation. Don't use Redux just because someone said you should - take some time to understand the potential benefits and tradeoffs of using it.
|
||||
|
||||
Here are some suggestions on when it makes sense to use Redux:
|
||||
|
||||
- You have reasonable amounts of data changing over time
|
||||
- You need a single source of truth for your state
|
||||
- You find that keeping all your state in a top-level component is no longer sufficient
|
||||
|
||||
Yes, these guidelines are subjective and vague, but this is for good reason. The point at which you should integrate Redux into your application is different for every user and different for every application.
|
||||
|
||||
> **For more thoughts on how Redux is meant to be used, see:**<br>
|
||||
>
|
||||
> - **[You Might Not Need Redux](https://medium.com/@dan_abramov/you-might-not-need-redux-be46360cf367)**<br>
|
||||
> - **[The Tao of Redux, Part 1 - Implementation and Intent](http://blog.isquaredsoftware.com/2017/05/idiomatic-redux-tao-of-redux-part-1/)**<br>
|
||||
> - **[The Tao of Redux, Part 2 - Practice and Philosophy](http://blog.isquaredsoftware.com/2017/05/idiomatic-redux-tao-of-redux-part-2/)**
|
||||
> - **[Redux FAQ](https://redux.js.org/faq)**
|
||||
|
||||
## Developer Experience
|
||||
|
||||
Dan Abramov (author of Redux) wrote Redux while working on his React Europe talk called [“Hot Reloading with Time Travel”](https://www.youtube.com/watch?v=xsSnOQynTHs). His goal was to create a state management library with a minimal API but completely predictable behavior. Redux makes it possible to implement logging, hot reloading, time travel, universal apps, record and replay, without any buy-in from the developer.
|
||||
|
||||
## Influences
|
||||
|
||||
Redux evolves the ideas of [Flux](http://facebook.github.io/flux/), but avoids its complexity by taking cues from [Elm](https://github.com/evancz/elm-architecture-tutorial/).
|
||||
Even if you haven't used Flux or Elm, Redux only takes a few minutes to get started with.
|
||||
|
||||
## Installation
|
||||
|
||||
To install the stable version:
|
||||
|
||||
```sh
|
||||
npm install --save redux
|
||||
```
|
||||
|
||||
This assumes you are using [npm](https://www.npmjs.com/) as your package manager.
|
||||
|
||||
If you're not, you can [access these files on unpkg](https://unpkg.com/redux/), download them, or point your package manager to them.
|
||||
|
||||
Most commonly, people consume Redux as a collection of [CommonJS](https://github.com/webpack/docs/wiki/commonjs) modules. These modules are what you get when you import `redux` in a [Webpack](https://webpack.js.org/), [Browserify](http://browserify.org/), or a Node environment. If you like to live on the edge and use [Rollup](https://rollupjs.org), we support that as well.
|
||||
|
||||
If you don't use a module bundler, it's also fine. The `redux` npm package includes precompiled production and development [UMD](https://github.com/umdjs/umd) builds in the [`dist` folder](https://unpkg.com/redux/dist/). They can be used directly without a bundler and are thus compatible with many popular JavaScript module loaders and environments. For example, you can drop a UMD build as a [`<script>` tag](https://unpkg.com/redux/dist/redux.js) on the page, or [tell Bower to install it](https://github.com/reduxjs/redux/pull/1181#issuecomment-167361975). The UMD builds make Redux available as a `window.Redux` global variable.
|
||||
|
||||
The Redux source code is written in ES2015 but we precompile both CommonJS and UMD builds to ES5 so they work in [any modern browser](http://caniuse.com/#feat=es5). You don't need to use Babel or a module bundler to [get started with Redux](https://github.com/reduxjs/redux/blob/master/examples/counter-vanilla/index.html). You can even use the ES module build that's available at [`es/redux.mjs`](https://unpkg.com/redux/es/) which can be referenced using `type="module"` in your `script` tag or as a standard `import`.
|
||||
|
||||
### Complementary Packages
|
||||
|
||||
Most likely, you'll also need [the React bindings](https://github.com/reduxjs/react-redux) and [the developer tools](https://github.com/reduxjs/redux-devtools).
|
||||
|
||||
```sh
|
||||
npm install --save react-redux
|
||||
npm install --save-dev redux-devtools
|
||||
```
|
||||
|
||||
Note that unlike Redux itself, many packages in the Redux ecosystem don't provide UMD builds, so we recommend using CommonJS module bundlers like [Webpack](https://webpack.js.org/) and [Browserify](http://browserify.org/) for the most comfortable development experience.
|
||||
|
||||
## The Gist
|
||||
|
||||
The whole state of your app is stored in an object tree inside a single _store_.
|
||||
The only way to change the state tree is to emit an _action_, an object describing what happened.
|
||||
To specify how the actions transform the state tree, you write pure _reducers_.
|
||||
|
||||
That's it!
|
||||
|
||||
```js
|
||||
import { createStore } from 'redux'
|
||||
|
||||
/**
|
||||
* This is a reducer, a pure function with (state, action) => state signature.
|
||||
* It describes how an action transforms the state into the next state.
|
||||
*
|
||||
* The shape of the state is up to you: it can be a primitive, an array, an object,
|
||||
* or even an Immutable.js data structure. The only important part is that you should
|
||||
* not mutate the state object, but return a new object if the state changes.
|
||||
*
|
||||
* In this example, we use a `switch` statement and strings, but you can use a helper that
|
||||
* follows a different convention (such as function maps) if it makes sense for your
|
||||
* project.
|
||||
*/
|
||||
function counter(state = 0, action) {
|
||||
switch (action.type) {
|
||||
case 'INCREMENT':
|
||||
return state + 1
|
||||
case 'DECREMENT':
|
||||
return state - 1
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
|
||||
// Create a Redux store holding the state of your app.
|
||||
// Its API is { subscribe, dispatch, getState }.
|
||||
let store = createStore(counter)
|
||||
|
||||
// You can use subscribe() to update the UI in response to state changes.
|
||||
// Normally you'd use a view binding library (e.g. React Redux) rather than subscribe() directly.
|
||||
// However it can also be handy to persist the current state in the localStorage.
|
||||
|
||||
store.subscribe(() => console.log(store.getState()))
|
||||
|
||||
// The only way to mutate the internal state is to dispatch an action.
|
||||
// The actions can be serialized, logged or stored and later replayed.
|
||||
store.dispatch({ type: 'INCREMENT' })
|
||||
// 1
|
||||
store.dispatch({ type: 'INCREMENT' })
|
||||
// 2
|
||||
store.dispatch({ type: 'DECREMENT' })
|
||||
// 1
|
||||
```
|
||||
|
||||
Instead of mutating the state directly, you specify the mutations you want to happen with plain objects called _actions_. Then you write a special function called a _reducer_ to decide how every action transforms the entire application's state.
|
||||
|
||||
If you're coming from Flux, there is a single important difference you need to understand. Redux doesn't have a Dispatcher or support many stores. Instead, there is just a single store with a single root reducing function. As your app grows, instead of adding stores, you split the root reducer into smaller reducers independently operating on the different parts of the state tree. This is exactly like how there is just one root component in a React app, but it is composed out of many small components.
|
||||
|
||||
This architecture might seem like an overkill for a counter app, but the beauty of this pattern is how well it scales to large and complex apps. It also enables very powerful developer tools, because it is possible to trace every mutation to the action that caused it. You can record user sessions and reproduce them just by replaying every action.
|
||||
|
||||
## Learn Redux from Its Authors
|
||||
|
||||
### Redux Video Tutorials by Dan Abramov
|
||||
|
||||
#### Getting Started with Redux
|
||||
|
||||
**[Getting Started with Redux](https://egghead.io/series/getting-started-with-redux)** is a video course consisting of 30 videos narrated by [Dan Abramov](https://twitter.com/dan_abramov), author of Redux. It is designed to complement the “Basics” part of the docs while bringing additional insights about immutability, testing, Redux best practices, and using Redux with React. **This course is free and will always be.**
|
||||
|
||||
> [“Great course on egghead.io by @dan_abramov - instead of just showing you how to use #redux, it also shows how and why redux was built!”](https://twitter.com/sandrinodm/status/670548531422326785)
|
||||
> Sandrino Di Mattia
|
||||
|
||||
> [“Plowing through @dan_abramov 'Getting Started with Redux' - its amazing how much simpler concepts get with video.”](https://twitter.com/chrisdhanaraj/status/670328025553219584)
|
||||
> Chris Dhanaraj
|
||||
|
||||
> [“This video series on Redux by @dan_abramov on @eggheadio is spectacular!”](https://twitter.com/eddiezane/status/670333133242408960)
|
||||
> Eddie Zaneski
|
||||
|
||||
> [“Come for the name hype. Stay for the rock solid fundamentals. (Thanks, and great job @dan_abramov and @eggheadio!)”](https://twitter.com/danott/status/669909126554607617)
|
||||
> Dan
|
||||
|
||||
> [“This series of videos on Redux by @dan_abramov is repeatedly blowing my mind - gunna do some serious refactoring”](https://twitter.com/gelatindesign/status/669658358643892224)
|
||||
> Laurence Roberts
|
||||
|
||||
So, what are you waiting for?
|
||||
|
||||
#### [Watch the free "Getting Started with Redux" video series](https://egghead.io/series/getting-started-with-redux)
|
||||
|
||||
> Note: If you enjoyed Dan's course, consider supporting Egghead by [buying a subscription](https://egghead.io/pricing). Subscribers have access to the source code of every example in my videos and tons of advanced lessons on other topics, including JavaScript in depth, React, Angular, and more. Many [Egghead instructors](https://egghead.io/instructors) are also open source library authors, so buying a subscription is a nice way to thank them for the work that they've done.
|
||||
|
||||
#### Building React Applications with Idiomatic Redux
|
||||
|
||||
The **[Building React Applications with Idiomatic Redux](https://egghead.io/courses/building-react-applications-with-idiomatic-redux)** course is a second free video series by Dan Abramov. It picks up where the first series left off, and covers practical production ready techniques for building your React and Redux applications: advanced state management, middleware, React Router integration, and other common problems you are likely to encounter while building applications for your clients and customers. As with the first series, **this course will always be free**.
|
||||
|
||||
#### [Watch the free "Idiomatic Redux" video series](https://egghead.io/courses/building-react-applications-with-idiomatic-redux)
|
||||
|
||||
### Practical Redux course
|
||||
|
||||
**[Practical Redux](https://www.educative.io/collection/5687753853370368/5707702298738688/)** is a paid interactive course by Redux co-maintainer [Mark Erikson](https://twitter.com/acemarke). The course is designed to show how to apply the basic concepts of Redux to building something larger than a TodoMVC application. It includes real-world topics like:
|
||||
|
||||
- Adding Redux to a new Create-React-App project and configuring Hot Module Replacement for faster development
|
||||
- Controlling your UI behavior with Redux
|
||||
- Using the Redux-ORM library to manage relational data in your Redux store
|
||||
- Building a master/detail view to display and edit data
|
||||
- Writing custom advanced Redux reducer logic to solve specific problems
|
||||
- Optimizing performance of Redux-connected form inputs
|
||||
|
||||
And much more!
|
||||
|
||||
The course is based on Mark's original free **["Practical Redux" blog tutorial series](http://blog.isquaredsoftware.com/series/practical-redux/)**, but with updated and improved content.
|
||||
|
||||
### Redux Fundamentals Workshop
|
||||
|
||||
Redux co-maintainer [Mark Erikson](https://twitter.com/acemarke) has put together a [**Redux Fundamentals workshop**, and slides are available here](https://blog.isquaredsoftware.com/2018/06/redux-fundamentals-workshop-slides/). They cover:
|
||||
|
||||
- The history and purpose of Redux
|
||||
- Reducers and actions, and working with a Redux store
|
||||
- Using Redux with React
|
||||
- Using and writing Redux middleware
|
||||
- Working with AJAX calls and other side effects
|
||||
- Unit testing Redux apps
|
||||
- Real-world Redux app structure and development
|
||||
|
||||
## Documentation
|
||||
|
||||
- [Introduction](http://redux.js.org/introduction)
|
||||
- [Basics](http://redux.js.org/basics)
|
||||
- [Advanced](http://redux.js.org/advanced)
|
||||
- [Recipes](http://redux.js.org/recipes)
|
||||
- [FAQ](http://redux.js.org/faq)
|
||||
- [Troubleshooting](http://redux.js.org/troubleshooting)
|
||||
- [Glossary](http://redux.js.org/glossary)
|
||||
- [API Reference](http://redux.js.org/api)
|
||||
|
||||
For PDF, ePub, and MOBI exports for offline reading, and instructions on how to create them, please see: [paulkogel/redux-offline-docs](https://github.com/paulkogel/redux-offline-docs).
|
||||
|
||||
For Offline docs, please see: [devdocs](http://devdocs.io/redux/)
|
||||
|
||||
## Examples
|
||||
|
||||
Almost all examples have a corresponding CodeSandbox sandbox. This is an interactive version of the code that you can play with online.
|
||||
|
||||
- [**Counter Vanilla**](https://redux.js.org/introduction/examples#counter-vanilla): [Source](https://github.com/reduxjs/redux/tree/master/examples/counter-vanilla)
|
||||
- [**Counter**](https://redux.js.org/introduction/examples#counter): [Source](https://github.com/reduxjs/redux/tree/master/examples/counter) | [Sandbox](https://codesandbox.io/s/github/reduxjs/redux/tree/master/examples/counter)
|
||||
- [**Todos**](https://redux.js.org/introduction/examples#todos): [Source](https://github.com/reduxjs/redux/tree/master/examples/todos) | [Sandbox](https://codesandbox.io/s/github/reduxjs/redux/tree/master/examples/todos)
|
||||
- [**Todos with Undo**](https://redux.js.org/introduction/examples#todos-with-undo): [Source](https://github.com/reduxjs/redux/tree/master/examples/todos-with-undo) | [Sandbox](https://codesandbox.io/s/github/reduxjs/redux/tree/master/examples/todos-with-undo)
|
||||
- [**Todos w/ Flow**](https://redux.js.org/introduction/examples#todos-flow): [Source](https://github.com/reduxjs/redux/tree/master/examples/todos-flow)
|
||||
- [**TodoMVC**](https://redux.js.org/introduction/examples#todomvc): [Source](https://github.com/reduxjs/redux/tree/master/examples/todomvc) | [Sandbox](https://codesandbox.io/s/github/reduxjs/redux/tree/master/examples/todomvc)
|
||||
- [**Shopping Cart**](https://redux.js.org/introduction/examples#shopping-cart): [Source](https://github.com/reduxjs/redux/tree/master/examples/shopping-cart) | [Sandbox](https://codesandbox.io/s/github/reduxjs/redux/tree/master/examples/shopping-cart)
|
||||
- [**Tree View**](https://redux.js.org/introduction/examples#tree-view): [Source](https://github.com/reduxjs/redux/tree/master/examples/tree-view) | [Sandbox](https://codesandbox.io/s/github/reduxjs/redux/tree/master/examples/tree-view)
|
||||
- [**Async**](https://redux.js.org/introduction/examples#async): [Source](https://github.com/reduxjs/redux/tree/master/examples/async) | [Sandbox](https://codesandbox.io/s/github/reduxjs/redux/tree/master/examples/async)
|
||||
- [**Universal**](https://redux.js.org/introduction/examples#universal): [Source](https://github.com/reduxjs/redux/tree/master/examples/universal)
|
||||
- [**Real World**](https://redux.js.org/introduction/examples#real-world): [Source](https://github.com/reduxjs/redux/tree/master/examples/real-world) | [Sandbox](https://codesandbox.io/s/github/reduxjs/redux/tree/master/examples/real-world)
|
||||
|
||||
If you're new to the NPM ecosystem and have troubles getting a project up and running, or aren't sure where to paste the gist above, check out [simplest-redux-example](https://github.com/jackielii/simplest-redux-example) that uses Redux together with React and Browserify.
|
||||
|
||||
## Testimonials
|
||||
|
||||
> [“Love what you're doing with Redux”](https://twitter.com/jingc/status/616608251463909376)
|
||||
> Jing Chen, creator of Flux
|
||||
|
||||
> [“I asked for comments on Redux in FB's internal JS discussion group, and it was universally praised. Really awesome work.”](https://twitter.com/fisherwebdev/status/616286955693682688)
|
||||
> Bill Fisher, author of Flux documentation
|
||||
|
||||
> [“It's cool that you are inventing a better Flux by not doing Flux at all.”](https://twitter.com/andrestaltz/status/616271392930201604)
|
||||
> André Staltz, creator of Cycle
|
||||
|
||||
## Thanks
|
||||
|
||||
- [The Elm Architecture](https://github.com/evancz/elm-architecture-tutorial) for a great intro to modeling state updates with reducers;
|
||||
- [Turning the database inside-out](https://www.confluent.io/blog/turning-the-database-inside-out-with-apache-samza/) for blowing my mind;
|
||||
- [Developing ClojureScript with Figwheel](https://www.youtube.com/watch?v=j-kj2qwJa_E) for convincing me that re-evaluation should “just work”;
|
||||
- [Webpack](https://webpack.js.org/concepts/hot-module-replacement/) for Hot Module Replacement;
|
||||
- [Flummox](https://github.com/acdlite/flummox) for teaching me to approach Flux without boilerplate or singletons;
|
||||
- [disto](https://github.com/threepointone/disto) for a proof of concept of hot reloadable Stores;
|
||||
- [NuclearJS](https://github.com/optimizely/nuclear-js) for proving this architecture can be performant;
|
||||
- [Om](https://github.com/omcljs/om) for popularizing the idea of a single state atom;
|
||||
- [Cycle](https://github.com/cyclejs/cycle-core) for showing how often a function is the best tool;
|
||||
- [React](https://github.com/facebook/react) for the pragmatic innovation.
|
||||
|
||||
Special thanks to [Jamie Paton](http://jdpaton.github.io) for handing over the `redux` NPM package name.
|
||||
|
||||
## Logo
|
||||
|
||||
You can find the official logo [on GitHub](https://github.com/reduxjs/redux/tree/master/logo).
|
||||
|
||||
## Change Log
|
||||
|
||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
Every release, along with the migration instructions, is documented on the GitHub [Releases](https://github.com/reduxjs/redux/releases) page.
|
||||
|
||||
## Patrons
|
||||
|
||||
The work on Redux was [funded by the community](https://www.patreon.com/reactdx).
|
||||
Meet some of the outstanding companies that made it possible:
|
||||
|
||||
- [Webflow](https://github.com/webflow)
|
||||
- [Ximedes](https://www.ximedes.com/)
|
||||
|
||||
[See the full list of Redux patrons](PATRONS.md), as well as the always-growing list of [people and companies that use Redux](https://github.com/reduxjs/redux/issues/310).
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE.md)
|
735
web/node_modules/redux/dist/redux.js
generated
vendored
Normal file
735
web/node_modules/redux/dist/redux.js
generated
vendored
Normal file
|
@ -0,0 +1,735 @@
|
|||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Redux = {}));
|
||||
}(this, (function (exports) { 'use strict';
|
||||
|
||||
// Inlined version of the `symbol-observable` polyfill
|
||||
var $$observable = (function () {
|
||||
return typeof Symbol === 'function' && Symbol.observable || '@@observable';
|
||||
})();
|
||||
|
||||
/**
|
||||
* These are private action types reserved by Redux.
|
||||
* For any unknown actions, you must return the current state.
|
||||
* If the current state is undefined, you must return the initial state.
|
||||
* Do not reference these action types directly in your code.
|
||||
*/
|
||||
var randomString = function randomString() {
|
||||
return Math.random().toString(36).substring(7).split('').join('.');
|
||||
};
|
||||
|
||||
var ActionTypes = {
|
||||
INIT: "@@redux/INIT" + randomString(),
|
||||
REPLACE: "@@redux/REPLACE" + randomString(),
|
||||
PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
|
||||
return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {any} obj The object to inspect.
|
||||
* @returns {boolean} True if the argument appears to be a plain object.
|
||||
*/
|
||||
function isPlainObject(obj) {
|
||||
if (typeof obj !== 'object' || obj === null) return false;
|
||||
var proto = obj;
|
||||
|
||||
while (Object.getPrototypeOf(proto) !== null) {
|
||||
proto = Object.getPrototypeOf(proto);
|
||||
}
|
||||
|
||||
return Object.getPrototypeOf(obj) === proto;
|
||||
}
|
||||
|
||||
// Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
|
||||
function miniKindOf(val) {
|
||||
if (val === void 0) return 'undefined';
|
||||
if (val === null) return 'null';
|
||||
var type = typeof val;
|
||||
|
||||
switch (type) {
|
||||
case 'boolean':
|
||||
case 'string':
|
||||
case 'number':
|
||||
case 'symbol':
|
||||
case 'function':
|
||||
{
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
if (Array.isArray(val)) return 'array';
|
||||
if (isDate(val)) return 'date';
|
||||
if (isError(val)) return 'error';
|
||||
var constructorName = ctorName(val);
|
||||
|
||||
switch (constructorName) {
|
||||
case 'Symbol':
|
||||
case 'Promise':
|
||||
case 'WeakMap':
|
||||
case 'WeakSet':
|
||||
case 'Map':
|
||||
case 'Set':
|
||||
return constructorName;
|
||||
} // other
|
||||
|
||||
|
||||
return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
|
||||
}
|
||||
|
||||
function ctorName(val) {
|
||||
return typeof val.constructor === 'function' ? val.constructor.name : null;
|
||||
}
|
||||
|
||||
function isError(val) {
|
||||
return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
|
||||
}
|
||||
|
||||
function isDate(val) {
|
||||
if (val instanceof Date) return true;
|
||||
return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
|
||||
}
|
||||
|
||||
function kindOf(val) {
|
||||
var typeOfVal = typeof val;
|
||||
|
||||
{
|
||||
typeOfVal = miniKindOf(val);
|
||||
}
|
||||
|
||||
return typeOfVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Redux store that holds the state tree.
|
||||
* The only way to change the data in the store is to call `dispatch()` on it.
|
||||
*
|
||||
* There should only be a single store in your app. To specify how different
|
||||
* parts of the state tree respond to actions, you may combine several reducers
|
||||
* into a single reducer function by using `combineReducers`.
|
||||
*
|
||||
* @param {Function} reducer A function that returns the next state tree, given
|
||||
* the current state tree and the action to handle.
|
||||
*
|
||||
* @param {any} [preloadedState] The initial state. You may optionally specify it
|
||||
* to hydrate the state from the server in universal apps, or to restore a
|
||||
* previously serialized user session.
|
||||
* If you use `combineReducers` to produce the root reducer function, this must be
|
||||
* an object with the same shape as `combineReducers` keys.
|
||||
*
|
||||
* @param {Function} [enhancer] The store enhancer. You may optionally specify it
|
||||
* to enhance the store with third-party capabilities such as middleware,
|
||||
* time travel, persistence, etc. The only store enhancer that ships with Redux
|
||||
* is `applyMiddleware()`.
|
||||
*
|
||||
* @returns {Store} A Redux store that lets you read the state, dispatch actions
|
||||
* and subscribe to changes.
|
||||
*/
|
||||
|
||||
function createStore(reducer, preloadedState, enhancer) {
|
||||
var _ref2;
|
||||
|
||||
if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
|
||||
throw new Error('It looks like you are passing several store enhancers to ' + 'createStore(). This is not supported. Instead, compose them ' + 'together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.');
|
||||
}
|
||||
|
||||
if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
|
||||
enhancer = preloadedState;
|
||||
preloadedState = undefined;
|
||||
}
|
||||
|
||||
if (typeof enhancer !== 'undefined') {
|
||||
if (typeof enhancer !== 'function') {
|
||||
throw new Error("Expected the enhancer to be a function. Instead, received: '" + kindOf(enhancer) + "'");
|
||||
}
|
||||
|
||||
return enhancer(createStore)(reducer, preloadedState);
|
||||
}
|
||||
|
||||
if (typeof reducer !== 'function') {
|
||||
throw new Error("Expected the root reducer to be a function. Instead, received: '" + kindOf(reducer) + "'");
|
||||
}
|
||||
|
||||
var currentReducer = reducer;
|
||||
var currentState = preloadedState;
|
||||
var currentListeners = [];
|
||||
var nextListeners = currentListeners;
|
||||
var isDispatching = false;
|
||||
/**
|
||||
* This makes a shallow copy of currentListeners so we can use
|
||||
* nextListeners as a temporary list while dispatching.
|
||||
*
|
||||
* This prevents any bugs around consumers calling
|
||||
* subscribe/unsubscribe in the middle of a dispatch.
|
||||
*/
|
||||
|
||||
function ensureCanMutateNextListeners() {
|
||||
if (nextListeners === currentListeners) {
|
||||
nextListeners = currentListeners.slice();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Reads the state tree managed by the store.
|
||||
*
|
||||
* @returns {any} The current state tree of your application.
|
||||
*/
|
||||
|
||||
|
||||
function getState() {
|
||||
if (isDispatching) {
|
||||
throw new Error('You may not call store.getState() while the reducer is executing. ' + 'The reducer has already received the state as an argument. ' + 'Pass it down from the top reducer instead of reading it from the store.');
|
||||
}
|
||||
|
||||
return currentState;
|
||||
}
|
||||
/**
|
||||
* Adds a change listener. It will be called any time an action is dispatched,
|
||||
* and some part of the state tree may potentially have changed. You may then
|
||||
* call `getState()` to read the current state tree inside the callback.
|
||||
*
|
||||
* You may call `dispatch()` from a change listener, with the following
|
||||
* caveats:
|
||||
*
|
||||
* 1. The subscriptions are snapshotted just before every `dispatch()` call.
|
||||
* If you subscribe or unsubscribe while the listeners are being invoked, this
|
||||
* will not have any effect on the `dispatch()` that is currently in progress.
|
||||
* However, the next `dispatch()` call, whether nested or not, will use a more
|
||||
* recent snapshot of the subscription list.
|
||||
*
|
||||
* 2. The listener should not expect to see all state changes, as the state
|
||||
* might have been updated multiple times during a nested `dispatch()` before
|
||||
* the listener is called. It is, however, guaranteed that all subscribers
|
||||
* registered before the `dispatch()` started will be called with the latest
|
||||
* state by the time it exits.
|
||||
*
|
||||
* @param {Function} listener A callback to be invoked on every dispatch.
|
||||
* @returns {Function} A function to remove this change listener.
|
||||
*/
|
||||
|
||||
|
||||
function subscribe(listener) {
|
||||
if (typeof listener !== 'function') {
|
||||
throw new Error("Expected the listener to be a function. Instead, received: '" + kindOf(listener) + "'");
|
||||
}
|
||||
|
||||
if (isDispatching) {
|
||||
throw new Error('You may not call store.subscribe() while the reducer is executing. ' + 'If you would like to be notified after the store has been updated, subscribe from a ' + 'component and invoke store.getState() in the callback to access the latest state. ' + 'See https://redux.js.org/api/store#subscribelistener for more details.');
|
||||
}
|
||||
|
||||
var isSubscribed = true;
|
||||
ensureCanMutateNextListeners();
|
||||
nextListeners.push(listener);
|
||||
return function unsubscribe() {
|
||||
if (!isSubscribed) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isDispatching) {
|
||||
throw new Error('You may not unsubscribe from a store listener while the reducer is executing. ' + 'See https://redux.js.org/api/store#subscribelistener for more details.');
|
||||
}
|
||||
|
||||
isSubscribed = false;
|
||||
ensureCanMutateNextListeners();
|
||||
var index = nextListeners.indexOf(listener);
|
||||
nextListeners.splice(index, 1);
|
||||
currentListeners = null;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Dispatches an action. It is the only way to trigger a state change.
|
||||
*
|
||||
* The `reducer` function, used to create the store, will be called with the
|
||||
* current state tree and the given `action`. Its return value will
|
||||
* be considered the **next** state of the tree, and the change listeners
|
||||
* will be notified.
|
||||
*
|
||||
* The base implementation only supports plain object actions. If you want to
|
||||
* dispatch a Promise, an Observable, a thunk, or something else, you need to
|
||||
* wrap your store creating function into the corresponding middleware. For
|
||||
* example, see the documentation for the `redux-thunk` package. Even the
|
||||
* middleware will eventually dispatch plain object actions using this method.
|
||||
*
|
||||
* @param {Object} action A plain object representing “what changed”. It is
|
||||
* a good idea to keep actions serializable so you can record and replay user
|
||||
* sessions, or use the time travelling `redux-devtools`. An action must have
|
||||
* a `type` property which may not be `undefined`. It is a good idea to use
|
||||
* string constants for action types.
|
||||
*
|
||||
* @returns {Object} For convenience, the same action object you dispatched.
|
||||
*
|
||||
* Note that, if you use a custom middleware, it may wrap `dispatch()` to
|
||||
* return something else (for example, a Promise you can await).
|
||||
*/
|
||||
|
||||
|
||||
function dispatch(action) {
|
||||
if (!isPlainObject(action)) {
|
||||
throw new Error("Actions must be plain objects. Instead, the actual type was: '" + kindOf(action) + "'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.");
|
||||
}
|
||||
|
||||
if (typeof action.type === 'undefined') {
|
||||
throw new Error('Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');
|
||||
}
|
||||
|
||||
if (isDispatching) {
|
||||
throw new Error('Reducers may not dispatch actions.');
|
||||
}
|
||||
|
||||
try {
|
||||
isDispatching = true;
|
||||
currentState = currentReducer(currentState, action);
|
||||
} finally {
|
||||
isDispatching = false;
|
||||
}
|
||||
|
||||
var listeners = currentListeners = nextListeners;
|
||||
|
||||
for (var i = 0; i < listeners.length; i++) {
|
||||
var listener = listeners[i];
|
||||
listener();
|
||||
}
|
||||
|
||||
return action;
|
||||
}
|
||||
/**
|
||||
* Replaces the reducer currently used by the store to calculate the state.
|
||||
*
|
||||
* You might need this if your app implements code splitting and you want to
|
||||
* load some of the reducers dynamically. You might also need this if you
|
||||
* implement a hot reloading mechanism for Redux.
|
||||
*
|
||||
* @param {Function} nextReducer The reducer for the store to use instead.
|
||||
* @returns {void}
|
||||
*/
|
||||
|
||||
|
||||
function replaceReducer(nextReducer) {
|
||||
if (typeof nextReducer !== 'function') {
|
||||
throw new Error("Expected the nextReducer to be a function. Instead, received: '" + kindOf(nextReducer));
|
||||
}
|
||||
|
||||
currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
|
||||
// Any reducers that existed in both the new and old rootReducer
|
||||
// will receive the previous state. This effectively populates
|
||||
// the new state tree with any relevant data from the old one.
|
||||
|
||||
dispatch({
|
||||
type: ActionTypes.REPLACE
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Interoperability point for observable/reactive libraries.
|
||||
* @returns {observable} A minimal observable of state changes.
|
||||
* For more information, see the observable proposal:
|
||||
* https://github.com/tc39/proposal-observable
|
||||
*/
|
||||
|
||||
|
||||
function observable() {
|
||||
var _ref;
|
||||
|
||||
var outerSubscribe = subscribe;
|
||||
return _ref = {
|
||||
/**
|
||||
* The minimal observable subscription method.
|
||||
* @param {Object} observer Any object that can be used as an observer.
|
||||
* The observer object should have a `next` method.
|
||||
* @returns {subscription} An object with an `unsubscribe` method that can
|
||||
* be used to unsubscribe the observable from the store, and prevent further
|
||||
* emission of values from the observable.
|
||||
*/
|
||||
subscribe: function subscribe(observer) {
|
||||
if (typeof observer !== 'object' || observer === null) {
|
||||
throw new Error("Expected the observer to be an object. Instead, received: '" + kindOf(observer) + "'");
|
||||
}
|
||||
|
||||
function observeState() {
|
||||
if (observer.next) {
|
||||
observer.next(getState());
|
||||
}
|
||||
}
|
||||
|
||||
observeState();
|
||||
var unsubscribe = outerSubscribe(observeState);
|
||||
return {
|
||||
unsubscribe: unsubscribe
|
||||
};
|
||||
}
|
||||
}, _ref[$$observable] = function () {
|
||||
return this;
|
||||
}, _ref;
|
||||
} // When a store is created, an "INIT" action is dispatched so that every
|
||||
// reducer returns their initial state. This effectively populates
|
||||
// the initial state tree.
|
||||
|
||||
|
||||
dispatch({
|
||||
type: ActionTypes.INIT
|
||||
});
|
||||
return _ref2 = {
|
||||
dispatch: dispatch,
|
||||
subscribe: subscribe,
|
||||
getState: getState,
|
||||
replaceReducer: replaceReducer
|
||||
}, _ref2[$$observable] = observable, _ref2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a warning in the console if it exists.
|
||||
*
|
||||
* @param {String} message The warning message.
|
||||
* @returns {void}
|
||||
*/
|
||||
function warning(message) {
|
||||
/* eslint-disable no-console */
|
||||
if (typeof console !== 'undefined' && typeof console.error === 'function') {
|
||||
console.error(message);
|
||||
}
|
||||
/* eslint-enable no-console */
|
||||
|
||||
|
||||
try {
|
||||
// This error was thrown as a convenience so that if you enable
|
||||
// "break on all exceptions" in your console,
|
||||
// it would pause the execution at this line.
|
||||
throw new Error(message);
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
|
||||
}
|
||||
|
||||
function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
|
||||
var reducerKeys = Object.keys(reducers);
|
||||
var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
|
||||
|
||||
if (reducerKeys.length === 0) {
|
||||
return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
|
||||
}
|
||||
|
||||
if (!isPlainObject(inputState)) {
|
||||
return "The " + argumentName + " has unexpected type of \"" + kindOf(inputState) + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\"");
|
||||
}
|
||||
|
||||
var unexpectedKeys = Object.keys(inputState).filter(function (key) {
|
||||
return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
|
||||
});
|
||||
unexpectedKeys.forEach(function (key) {
|
||||
unexpectedKeyCache[key] = true;
|
||||
});
|
||||
if (action && action.type === ActionTypes.REPLACE) return;
|
||||
|
||||
if (unexpectedKeys.length > 0) {
|
||||
return "Unexpected " + (unexpectedKeys.length > 1 ? 'keys' : 'key') + " " + ("\"" + unexpectedKeys.join('", "') + "\" found in " + argumentName + ". ") + "Expected to find one of the known reducer keys instead: " + ("\"" + reducerKeys.join('", "') + "\". Unexpected keys will be ignored.");
|
||||
}
|
||||
}
|
||||
|
||||
function assertReducerShape(reducers) {
|
||||
Object.keys(reducers).forEach(function (key) {
|
||||
var reducer = reducers[key];
|
||||
var initialState = reducer(undefined, {
|
||||
type: ActionTypes.INIT
|
||||
});
|
||||
|
||||
if (typeof initialState === 'undefined') {
|
||||
throw new Error("The slice reducer for key \"" + key + "\" returned undefined during initialization. " + "If the state passed to the reducer is undefined, you must " + "explicitly return the initial state. The initial state may " + "not be undefined. If you don't want to set a value for this reducer, " + "you can use null instead of undefined.");
|
||||
}
|
||||
|
||||
if (typeof reducer(undefined, {
|
||||
type: ActionTypes.PROBE_UNKNOWN_ACTION()
|
||||
}) === 'undefined') {
|
||||
throw new Error("The slice reducer for key \"" + key + "\" returned undefined when probed with a random type. " + ("Don't try to handle '" + ActionTypes.INIT + "' or other actions in \"redux/*\" ") + "namespace. They are considered private. Instead, you must return the " + "current state for any unknown actions, unless it is undefined, " + "in which case you must return the initial state, regardless of the " + "action type. The initial state may not be undefined, but can be null.");
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Turns an object whose values are different reducer functions, into a single
|
||||
* reducer function. It will call every child reducer, and gather their results
|
||||
* into a single state object, whose keys correspond to the keys of the passed
|
||||
* reducer functions.
|
||||
*
|
||||
* @param {Object} reducers An object whose values correspond to different
|
||||
* reducer functions that need to be combined into one. One handy way to obtain
|
||||
* it is to use ES6 `import * as reducers` syntax. The reducers may never return
|
||||
* undefined for any action. Instead, they should return their initial state
|
||||
* if the state passed to them was undefined, and the current state for any
|
||||
* unrecognized action.
|
||||
*
|
||||
* @returns {Function} A reducer function that invokes every reducer inside the
|
||||
* passed object, and builds a state object with the same shape.
|
||||
*/
|
||||
|
||||
|
||||
function combineReducers(reducers) {
|
||||
var reducerKeys = Object.keys(reducers);
|
||||
var finalReducers = {};
|
||||
|
||||
for (var i = 0; i < reducerKeys.length; i++) {
|
||||
var key = reducerKeys[i];
|
||||
|
||||
{
|
||||
if (typeof reducers[key] === 'undefined') {
|
||||
warning("No reducer provided for key \"" + key + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof reducers[key] === 'function') {
|
||||
finalReducers[key] = reducers[key];
|
||||
}
|
||||
}
|
||||
|
||||
var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
|
||||
// keys multiple times.
|
||||
|
||||
var unexpectedKeyCache;
|
||||
|
||||
{
|
||||
unexpectedKeyCache = {};
|
||||
}
|
||||
|
||||
var shapeAssertionError;
|
||||
|
||||
try {
|
||||
assertReducerShape(finalReducers);
|
||||
} catch (e) {
|
||||
shapeAssertionError = e;
|
||||
}
|
||||
|
||||
return function combination(state, action) {
|
||||
if (state === void 0) {
|
||||
state = {};
|
||||
}
|
||||
|
||||
if (shapeAssertionError) {
|
||||
throw shapeAssertionError;
|
||||
}
|
||||
|
||||
{
|
||||
var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
|
||||
|
||||
if (warningMessage) {
|
||||
warning(warningMessage);
|
||||
}
|
||||
}
|
||||
|
||||
var hasChanged = false;
|
||||
var nextState = {};
|
||||
|
||||
for (var _i = 0; _i < finalReducerKeys.length; _i++) {
|
||||
var _key = finalReducerKeys[_i];
|
||||
var reducer = finalReducers[_key];
|
||||
var previousStateForKey = state[_key];
|
||||
var nextStateForKey = reducer(previousStateForKey, action);
|
||||
|
||||
if (typeof nextStateForKey === 'undefined') {
|
||||
var actionType = action && action.type;
|
||||
throw new Error("When called with an action of type " + (actionType ? "\"" + String(actionType) + "\"" : '(unknown type)') + ", the slice reducer for key \"" + _key + "\" returned undefined. " + "To ignore an action, you must explicitly return the previous state. " + "If you want this reducer to hold no value, you can return null instead of undefined.");
|
||||
}
|
||||
|
||||
nextState[_key] = nextStateForKey;
|
||||
hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
|
||||
}
|
||||
|
||||
hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
|
||||
return hasChanged ? nextState : state;
|
||||
};
|
||||
}
|
||||
|
||||
function bindActionCreator(actionCreator, dispatch) {
|
||||
return function () {
|
||||
return dispatch(actionCreator.apply(this, arguments));
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Turns an object whose values are action creators, into an object with the
|
||||
* same keys, but with every function wrapped into a `dispatch` call so they
|
||||
* may be invoked directly. This is just a convenience method, as you can call
|
||||
* `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
|
||||
*
|
||||
* For convenience, you can also pass an action creator as the first argument,
|
||||
* and get a dispatch wrapped function in return.
|
||||
*
|
||||
* @param {Function|Object} actionCreators An object whose values are action
|
||||
* creator functions. One handy way to obtain it is to use ES6 `import * as`
|
||||
* syntax. You may also pass a single function.
|
||||
*
|
||||
* @param {Function} dispatch The `dispatch` function available on your Redux
|
||||
* store.
|
||||
*
|
||||
* @returns {Function|Object} The object mimicking the original object, but with
|
||||
* every action creator wrapped into the `dispatch` call. If you passed a
|
||||
* function as `actionCreators`, the return value will also be a single
|
||||
* function.
|
||||
*/
|
||||
|
||||
|
||||
function bindActionCreators(actionCreators, dispatch) {
|
||||
if (typeof actionCreators === 'function') {
|
||||
return bindActionCreator(actionCreators, dispatch);
|
||||
}
|
||||
|
||||
if (typeof actionCreators !== 'object' || actionCreators === null) {
|
||||
throw new Error("bindActionCreators expected an object or a function, but instead received: '" + kindOf(actionCreators) + "'. " + "Did you write \"import ActionCreators from\" instead of \"import * as ActionCreators from\"?");
|
||||
}
|
||||
|
||||
var boundActionCreators = {};
|
||||
|
||||
for (var key in actionCreators) {
|
||||
var actionCreator = actionCreators[key];
|
||||
|
||||
if (typeof actionCreator === 'function') {
|
||||
boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
|
||||
}
|
||||
}
|
||||
|
||||
return boundActionCreators;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
function ownKeys(object, enumerableOnly) {
|
||||
var keys = Object.keys(object);
|
||||
|
||||
if (Object.getOwnPropertySymbols) {
|
||||
var symbols = Object.getOwnPropertySymbols(object);
|
||||
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
||||
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
||||
});
|
||||
keys.push.apply(keys, symbols);
|
||||
}
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
function _objectSpread2(target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i] != null ? arguments[i] : {};
|
||||
|
||||
if (i % 2) {
|
||||
ownKeys(Object(source), true).forEach(function (key) {
|
||||
_defineProperty(target, key, source[key]);
|
||||
});
|
||||
} else if (Object.getOwnPropertyDescriptors) {
|
||||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
||||
} else {
|
||||
ownKeys(Object(source)).forEach(function (key) {
|
||||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Composes single-argument functions from right to left. The rightmost
|
||||
* function can take multiple arguments as it provides the signature for
|
||||
* the resulting composite function.
|
||||
*
|
||||
* @param {...Function} funcs The functions to compose.
|
||||
* @returns {Function} A function obtained by composing the argument functions
|
||||
* from right to left. For example, compose(f, g, h) is identical to doing
|
||||
* (...args) => f(g(h(...args))).
|
||||
*/
|
||||
function compose() {
|
||||
for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
funcs[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
if (funcs.length === 0) {
|
||||
return function (arg) {
|
||||
return arg;
|
||||
};
|
||||
}
|
||||
|
||||
if (funcs.length === 1) {
|
||||
return funcs[0];
|
||||
}
|
||||
|
||||
return funcs.reduce(function (a, b) {
|
||||
return function () {
|
||||
return a(b.apply(void 0, arguments));
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a store enhancer that applies middleware to the dispatch method
|
||||
* of the Redux store. This is handy for a variety of tasks, such as expressing
|
||||
* asynchronous actions in a concise manner, or logging every action payload.
|
||||
*
|
||||
* See `redux-thunk` package as an example of the Redux middleware.
|
||||
*
|
||||
* Because middleware is potentially asynchronous, this should be the first
|
||||
* store enhancer in the composition chain.
|
||||
*
|
||||
* Note that each middleware will be given the `dispatch` and `getState` functions
|
||||
* as named arguments.
|
||||
*
|
||||
* @param {...Function} middlewares The middleware chain to be applied.
|
||||
* @returns {Function} A store enhancer applying the middleware.
|
||||
*/
|
||||
|
||||
function applyMiddleware() {
|
||||
for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
middlewares[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return function (createStore) {
|
||||
return function () {
|
||||
var store = createStore.apply(void 0, arguments);
|
||||
|
||||
var _dispatch = function dispatch() {
|
||||
throw new Error('Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.');
|
||||
};
|
||||
|
||||
var middlewareAPI = {
|
||||
getState: store.getState,
|
||||
dispatch: function dispatch() {
|
||||
return _dispatch.apply(void 0, arguments);
|
||||
}
|
||||
};
|
||||
var chain = middlewares.map(function (middleware) {
|
||||
return middleware(middlewareAPI);
|
||||
});
|
||||
_dispatch = compose.apply(void 0, chain)(store.dispatch);
|
||||
return _objectSpread2(_objectSpread2({}, store), {}, {
|
||||
dispatch: _dispatch
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
* This is a dummy function to check if the function name has been altered by minification.
|
||||
* If the function has been minified and NODE_ENV !== 'production', warn the user.
|
||||
*/
|
||||
|
||||
function isCrushed() {}
|
||||
|
||||
if (typeof isCrushed.name === 'string' && isCrushed.name !== 'isCrushed') {
|
||||
warning('You are currently using minified code outside of NODE_ENV === "production". ' + 'This means that you are running a slower development build of Redux. ' + 'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + 'or setting mode to production in webpack (https://webpack.js.org/concepts/mode/) ' + 'to ensure you have the correct code for your production build.');
|
||||
}
|
||||
|
||||
exports.__DO_NOT_USE__ActionTypes = ActionTypes;
|
||||
exports.applyMiddleware = applyMiddleware;
|
||||
exports.bindActionCreators = bindActionCreators;
|
||||
exports.combineReducers = combineReducers;
|
||||
exports.compose = compose;
|
||||
exports.createStore = createStore;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
1
web/node_modules/redux/dist/redux.min.js
generated
vendored
Normal file
1
web/node_modules/redux/dist/redux.min.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((r="undefined"!=typeof globalThis?globalThis:r||self).Redux={})}(this,(function(r){"use strict";function t(r){return"Minified Redux error #"+r+"; visit https://redux.js.org/Errors?code="+r+" for the full message or use the non-minified dev environment for full errors. "}var e="function"==typeof Symbol&&Symbol.observable||"@@observable",n=function(){return Math.random().toString(36).substring(7).split("").join(".")},o={INIT:"@@redux/INIT"+n(),REPLACE:"@@redux/REPLACE"+n(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+n()}};function i(r){if("object"!=typeof r||null===r)return!1;for(var t=r;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(r)===t}function f(r,t){return function(){return t(r.apply(this,arguments))}}function u(r,t,e){return t in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function c(r,t){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),e.push.apply(e,n)}return e}function p(r){for(var t=1;arguments.length>t;t++){var e=null!=arguments[t]?arguments[t]:{};t%2?c(Object(e),!0).forEach((function(t){u(r,t,e[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):c(Object(e)).forEach((function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(e,t))}))}return r}function a(){for(var r=arguments.length,t=Array(r),e=0;r>e;e++)t[e]=arguments[e];return 0===t.length?function(r){return r}:1===t.length?t[0]:t.reduce((function(r,t){return function(){return r(t.apply(void 0,arguments))}}))}r.__DO_NOT_USE__ActionTypes=o,r.applyMiddleware=function(){for(var r=arguments.length,e=Array(r),n=0;r>n;n++)e[n]=arguments[n];return function(r){return function(){var n=r.apply(void 0,arguments),o=function(){throw Error(t(15))},i={getState:n.getState,dispatch:function(){return o.apply(void 0,arguments)}},f=e.map((function(r){return r(i)}));return o=a.apply(void 0,f)(n.dispatch),p(p({},n),{},{dispatch:o})}}},r.bindActionCreators=function(r,e){if("function"==typeof r)return f(r,e);if("object"!=typeof r||null===r)throw Error(t(16));var n={};for(var o in r){var i=r[o];"function"==typeof i&&(n[o]=f(i,e))}return n},r.combineReducers=function(r){for(var e=Object.keys(r),n={},i=0;e.length>i;i++){var f=e[i];"function"==typeof r[f]&&(n[f]=r[f])}var u,c=Object.keys(n);try{!function(r){Object.keys(r).forEach((function(e){var n=r[e];if(void 0===n(void 0,{type:o.INIT}))throw Error(t(12));if(void 0===n(void 0,{type:o.PROBE_UNKNOWN_ACTION()}))throw Error(t(13))}))}(n)}catch(r){u=r}return function(r,e){if(void 0===r&&(r={}),u)throw u;for(var o=!1,i={},f=0;c.length>f;f++){var p=c[f],a=r[p],l=(0,n[p])(a,e);if(void 0===l)throw Error(t(14));i[p]=l,o=o||l!==a}return(o=o||c.length!==Object.keys(r).length)?i:r}},r.compose=a,r.createStore=function r(n,f,u){var c;if("function"==typeof f&&"function"==typeof u||"function"==typeof u&&"function"==typeof arguments[3])throw Error(t(0));if("function"==typeof f&&void 0===u&&(u=f,f=void 0),void 0!==u){if("function"!=typeof u)throw Error(t(1));return u(r)(n,f)}if("function"!=typeof n)throw Error(t(2));var p=n,a=f,l=[],y=l,s=!1;function d(){y===l&&(y=l.slice())}function b(){if(s)throw Error(t(3));return a}function h(r){if("function"!=typeof r)throw Error(t(4));if(s)throw Error(t(5));var e=!0;return d(),y.push(r),function(){if(e){if(s)throw Error(t(6));e=!1,d();var n=y.indexOf(r);y.splice(n,1),l=null}}}function v(r){if(!i(r))throw Error(t(7));if(void 0===r.type)throw Error(t(8));if(s)throw Error(t(9));try{s=!0,a=p(a,r)}finally{s=!1}for(var e=l=y,n=0;e.length>n;n++){(0,e[n])()}return r}function O(r){if("function"!=typeof r)throw Error(t(10));p=r,v({type:o.REPLACE})}function E(){var r,n=h;return(r={subscribe:function(r){if("object"!=typeof r||null===r)throw Error(t(11));function e(){r.next&&r.next(b())}return e(),{unsubscribe:n(e)}}})[e]=function(){return this},r}return v({type:o.INIT}),(c={dispatch:v,subscribe:h,getState:b,replaceReducer:O})[e]=E,c},Object.defineProperty(r,"__esModule",{value:!0})}));
|
684
web/node_modules/redux/es/redux.js
generated
vendored
Normal file
684
web/node_modules/redux/es/redux.js
generated
vendored
Normal file
|
@ -0,0 +1,684 @@
|
|||
import _objectSpread from '@babel/runtime/helpers/esm/objectSpread2';
|
||||
|
||||
/**
|
||||
* Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
|
||||
*
|
||||
* Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
|
||||
* during build.
|
||||
* @param {number} code
|
||||
*/
|
||||
function formatProdErrorMessage(code) {
|
||||
return "Minified Redux error #" + code + "; visit https://redux.js.org/Errors?code=" + code + " for the full message or " + 'use the non-minified dev environment for full errors. ';
|
||||
}
|
||||
|
||||
// Inlined version of the `symbol-observable` polyfill
|
||||
var $$observable = (function () {
|
||||
return typeof Symbol === 'function' && Symbol.observable || '@@observable';
|
||||
})();
|
||||
|
||||
/**
|
||||
* These are private action types reserved by Redux.
|
||||
* For any unknown actions, you must return the current state.
|
||||
* If the current state is undefined, you must return the initial state.
|
||||
* Do not reference these action types directly in your code.
|
||||
*/
|
||||
var randomString = function randomString() {
|
||||
return Math.random().toString(36).substring(7).split('').join('.');
|
||||
};
|
||||
|
||||
var ActionTypes = {
|
||||
INIT: "@@redux/INIT" + randomString(),
|
||||
REPLACE: "@@redux/REPLACE" + randomString(),
|
||||
PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
|
||||
return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {any} obj The object to inspect.
|
||||
* @returns {boolean} True if the argument appears to be a plain object.
|
||||
*/
|
||||
function isPlainObject(obj) {
|
||||
if (typeof obj !== 'object' || obj === null) return false;
|
||||
var proto = obj;
|
||||
|
||||
while (Object.getPrototypeOf(proto) !== null) {
|
||||
proto = Object.getPrototypeOf(proto);
|
||||
}
|
||||
|
||||
return Object.getPrototypeOf(obj) === proto;
|
||||
}
|
||||
|
||||
// Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
|
||||
function miniKindOf(val) {
|
||||
if (val === void 0) return 'undefined';
|
||||
if (val === null) return 'null';
|
||||
var type = typeof val;
|
||||
|
||||
switch (type) {
|
||||
case 'boolean':
|
||||
case 'string':
|
||||
case 'number':
|
||||
case 'symbol':
|
||||
case 'function':
|
||||
{
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
if (Array.isArray(val)) return 'array';
|
||||
if (isDate(val)) return 'date';
|
||||
if (isError(val)) return 'error';
|
||||
var constructorName = ctorName(val);
|
||||
|
||||
switch (constructorName) {
|
||||
case 'Symbol':
|
||||
case 'Promise':
|
||||
case 'WeakMap':
|
||||
case 'WeakSet':
|
||||
case 'Map':
|
||||
case 'Set':
|
||||
return constructorName;
|
||||
} // other
|
||||
|
||||
|
||||
return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
|
||||
}
|
||||
|
||||
function ctorName(val) {
|
||||
return typeof val.constructor === 'function' ? val.constructor.name : null;
|
||||
}
|
||||
|
||||
function isError(val) {
|
||||
return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
|
||||
}
|
||||
|
||||
function isDate(val) {
|
||||
if (val instanceof Date) return true;
|
||||
return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
|
||||
}
|
||||
|
||||
function kindOf(val) {
|
||||
var typeOfVal = typeof val;
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
typeOfVal = miniKindOf(val);
|
||||
}
|
||||
|
||||
return typeOfVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Redux store that holds the state tree.
|
||||
* The only way to change the data in the store is to call `dispatch()` on it.
|
||||
*
|
||||
* There should only be a single store in your app. To specify how different
|
||||
* parts of the state tree respond to actions, you may combine several reducers
|
||||
* into a single reducer function by using `combineReducers`.
|
||||
*
|
||||
* @param {Function} reducer A function that returns the next state tree, given
|
||||
* the current state tree and the action to handle.
|
||||
*
|
||||
* @param {any} [preloadedState] The initial state. You may optionally specify it
|
||||
* to hydrate the state from the server in universal apps, or to restore a
|
||||
* previously serialized user session.
|
||||
* If you use `combineReducers` to produce the root reducer function, this must be
|
||||
* an object with the same shape as `combineReducers` keys.
|
||||
*
|
||||
* @param {Function} [enhancer] The store enhancer. You may optionally specify it
|
||||
* to enhance the store with third-party capabilities such as middleware,
|
||||
* time travel, persistence, etc. The only store enhancer that ships with Redux
|
||||
* is `applyMiddleware()`.
|
||||
*
|
||||
* @returns {Store} A Redux store that lets you read the state, dispatch actions
|
||||
* and subscribe to changes.
|
||||
*/
|
||||
|
||||
function createStore(reducer, preloadedState, enhancer) {
|
||||
var _ref2;
|
||||
|
||||
if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(0) : 'It looks like you are passing several store enhancers to ' + 'createStore(). This is not supported. Instead, compose them ' + 'together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.');
|
||||
}
|
||||
|
||||
if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
|
||||
enhancer = preloadedState;
|
||||
preloadedState = undefined;
|
||||
}
|
||||
|
||||
if (typeof enhancer !== 'undefined') {
|
||||
if (typeof enhancer !== 'function') {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(1) : "Expected the enhancer to be a function. Instead, received: '" + kindOf(enhancer) + "'");
|
||||
}
|
||||
|
||||
return enhancer(createStore)(reducer, preloadedState);
|
||||
}
|
||||
|
||||
if (typeof reducer !== 'function') {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(2) : "Expected the root reducer to be a function. Instead, received: '" + kindOf(reducer) + "'");
|
||||
}
|
||||
|
||||
var currentReducer = reducer;
|
||||
var currentState = preloadedState;
|
||||
var currentListeners = [];
|
||||
var nextListeners = currentListeners;
|
||||
var isDispatching = false;
|
||||
/**
|
||||
* This makes a shallow copy of currentListeners so we can use
|
||||
* nextListeners as a temporary list while dispatching.
|
||||
*
|
||||
* This prevents any bugs around consumers calling
|
||||
* subscribe/unsubscribe in the middle of a dispatch.
|
||||
*/
|
||||
|
||||
function ensureCanMutateNextListeners() {
|
||||
if (nextListeners === currentListeners) {
|
||||
nextListeners = currentListeners.slice();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Reads the state tree managed by the store.
|
||||
*
|
||||
* @returns {any} The current state tree of your application.
|
||||
*/
|
||||
|
||||
|
||||
function getState() {
|
||||
if (isDispatching) {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(3) : 'You may not call store.getState() while the reducer is executing. ' + 'The reducer has already received the state as an argument. ' + 'Pass it down from the top reducer instead of reading it from the store.');
|
||||
}
|
||||
|
||||
return currentState;
|
||||
}
|
||||
/**
|
||||
* Adds a change listener. It will be called any time an action is dispatched,
|
||||
* and some part of the state tree may potentially have changed. You may then
|
||||
* call `getState()` to read the current state tree inside the callback.
|
||||
*
|
||||
* You may call `dispatch()` from a change listener, with the following
|
||||
* caveats:
|
||||
*
|
||||
* 1. The subscriptions are snapshotted just before every `dispatch()` call.
|
||||
* If you subscribe or unsubscribe while the listeners are being invoked, this
|
||||
* will not have any effect on the `dispatch()` that is currently in progress.
|
||||
* However, the next `dispatch()` call, whether nested or not, will use a more
|
||||
* recent snapshot of the subscription list.
|
||||
*
|
||||
* 2. The listener should not expect to see all state changes, as the state
|
||||
* might have been updated multiple times during a nested `dispatch()` before
|
||||
* the listener is called. It is, however, guaranteed that all subscribers
|
||||
* registered before the `dispatch()` started will be called with the latest
|
||||
* state by the time it exits.
|
||||
*
|
||||
* @param {Function} listener A callback to be invoked on every dispatch.
|
||||
* @returns {Function} A function to remove this change listener.
|
||||
*/
|
||||
|
||||
|
||||
function subscribe(listener) {
|
||||
if (typeof listener !== 'function') {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(4) : "Expected the listener to be a function. Instead, received: '" + kindOf(listener) + "'");
|
||||
}
|
||||
|
||||
if (isDispatching) {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(5) : 'You may not call store.subscribe() while the reducer is executing. ' + 'If you would like to be notified after the store has been updated, subscribe from a ' + 'component and invoke store.getState() in the callback to access the latest state. ' + 'See https://redux.js.org/api/store#subscribelistener for more details.');
|
||||
}
|
||||
|
||||
var isSubscribed = true;
|
||||
ensureCanMutateNextListeners();
|
||||
nextListeners.push(listener);
|
||||
return function unsubscribe() {
|
||||
if (!isSubscribed) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isDispatching) {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(6) : 'You may not unsubscribe from a store listener while the reducer is executing. ' + 'See https://redux.js.org/api/store#subscribelistener for more details.');
|
||||
}
|
||||
|
||||
isSubscribed = false;
|
||||
ensureCanMutateNextListeners();
|
||||
var index = nextListeners.indexOf(listener);
|
||||
nextListeners.splice(index, 1);
|
||||
currentListeners = null;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Dispatches an action. It is the only way to trigger a state change.
|
||||
*
|
||||
* The `reducer` function, used to create the store, will be called with the
|
||||
* current state tree and the given `action`. Its return value will
|
||||
* be considered the **next** state of the tree, and the change listeners
|
||||
* will be notified.
|
||||
*
|
||||
* The base implementation only supports plain object actions. If you want to
|
||||
* dispatch a Promise, an Observable, a thunk, or something else, you need to
|
||||
* wrap your store creating function into the corresponding middleware. For
|
||||
* example, see the documentation for the `redux-thunk` package. Even the
|
||||
* middleware will eventually dispatch plain object actions using this method.
|
||||
*
|
||||
* @param {Object} action A plain object representing “what changed”. It is
|
||||
* a good idea to keep actions serializable so you can record and replay user
|
||||
* sessions, or use the time travelling `redux-devtools`. An action must have
|
||||
* a `type` property which may not be `undefined`. It is a good idea to use
|
||||
* string constants for action types.
|
||||
*
|
||||
* @returns {Object} For convenience, the same action object you dispatched.
|
||||
*
|
||||
* Note that, if you use a custom middleware, it may wrap `dispatch()` to
|
||||
* return something else (for example, a Promise you can await).
|
||||
*/
|
||||
|
||||
|
||||
function dispatch(action) {
|
||||
if (!isPlainObject(action)) {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(7) : "Actions must be plain objects. Instead, the actual type was: '" + kindOf(action) + "'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.");
|
||||
}
|
||||
|
||||
if (typeof action.type === 'undefined') {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(8) : 'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');
|
||||
}
|
||||
|
||||
if (isDispatching) {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(9) : 'Reducers may not dispatch actions.');
|
||||
}
|
||||
|
||||
try {
|
||||
isDispatching = true;
|
||||
currentState = currentReducer(currentState, action);
|
||||
} finally {
|
||||
isDispatching = false;
|
||||
}
|
||||
|
||||
var listeners = currentListeners = nextListeners;
|
||||
|
||||
for (var i = 0; i < listeners.length; i++) {
|
||||
var listener = listeners[i];
|
||||
listener();
|
||||
}
|
||||
|
||||
return action;
|
||||
}
|
||||
/**
|
||||
* Replaces the reducer currently used by the store to calculate the state.
|
||||
*
|
||||
* You might need this if your app implements code splitting and you want to
|
||||
* load some of the reducers dynamically. You might also need this if you
|
||||
* implement a hot reloading mechanism for Redux.
|
||||
*
|
||||
* @param {Function} nextReducer The reducer for the store to use instead.
|
||||
* @returns {void}
|
||||
*/
|
||||
|
||||
|
||||
function replaceReducer(nextReducer) {
|
||||
if (typeof nextReducer !== 'function') {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(10) : "Expected the nextReducer to be a function. Instead, received: '" + kindOf(nextReducer));
|
||||
}
|
||||
|
||||
currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
|
||||
// Any reducers that existed in both the new and old rootReducer
|
||||
// will receive the previous state. This effectively populates
|
||||
// the new state tree with any relevant data from the old one.
|
||||
|
||||
dispatch({
|
||||
type: ActionTypes.REPLACE
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Interoperability point for observable/reactive libraries.
|
||||
* @returns {observable} A minimal observable of state changes.
|
||||
* For more information, see the observable proposal:
|
||||
* https://github.com/tc39/proposal-observable
|
||||
*/
|
||||
|
||||
|
||||
function observable() {
|
||||
var _ref;
|
||||
|
||||
var outerSubscribe = subscribe;
|
||||
return _ref = {
|
||||
/**
|
||||
* The minimal observable subscription method.
|
||||
* @param {Object} observer Any object that can be used as an observer.
|
||||
* The observer object should have a `next` method.
|
||||
* @returns {subscription} An object with an `unsubscribe` method that can
|
||||
* be used to unsubscribe the observable from the store, and prevent further
|
||||
* emission of values from the observable.
|
||||
*/
|
||||
subscribe: function subscribe(observer) {
|
||||
if (typeof observer !== 'object' || observer === null) {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(11) : "Expected the observer to be an object. Instead, received: '" + kindOf(observer) + "'");
|
||||
}
|
||||
|
||||
function observeState() {
|
||||
if (observer.next) {
|
||||
observer.next(getState());
|
||||
}
|
||||
}
|
||||
|
||||
observeState();
|
||||
var unsubscribe = outerSubscribe(observeState);
|
||||
return {
|
||||
unsubscribe: unsubscribe
|
||||
};
|
||||
}
|
||||
}, _ref[$$observable] = function () {
|
||||
return this;
|
||||
}, _ref;
|
||||
} // When a store is created, an "INIT" action is dispatched so that every
|
||||
// reducer returns their initial state. This effectively populates
|
||||
// the initial state tree.
|
||||
|
||||
|
||||
dispatch({
|
||||
type: ActionTypes.INIT
|
||||
});
|
||||
return _ref2 = {
|
||||
dispatch: dispatch,
|
||||
subscribe: subscribe,
|
||||
getState: getState,
|
||||
replaceReducer: replaceReducer
|
||||
}, _ref2[$$observable] = observable, _ref2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a warning in the console if it exists.
|
||||
*
|
||||
* @param {String} message The warning message.
|
||||
* @returns {void}
|
||||
*/
|
||||
function warning(message) {
|
||||
/* eslint-disable no-console */
|
||||
if (typeof console !== 'undefined' && typeof console.error === 'function') {
|
||||
console.error(message);
|
||||
}
|
||||
/* eslint-enable no-console */
|
||||
|
||||
|
||||
try {
|
||||
// This error was thrown as a convenience so that if you enable
|
||||
// "break on all exceptions" in your console,
|
||||
// it would pause the execution at this line.
|
||||
throw new Error(message);
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
|
||||
}
|
||||
|
||||
function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
|
||||
var reducerKeys = Object.keys(reducers);
|
||||
var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
|
||||
|
||||
if (reducerKeys.length === 0) {
|
||||
return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
|
||||
}
|
||||
|
||||
if (!isPlainObject(inputState)) {
|
||||
return "The " + argumentName + " has unexpected type of \"" + kindOf(inputState) + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\"");
|
||||
}
|
||||
|
||||
var unexpectedKeys = Object.keys(inputState).filter(function (key) {
|
||||
return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
|
||||
});
|
||||
unexpectedKeys.forEach(function (key) {
|
||||
unexpectedKeyCache[key] = true;
|
||||
});
|
||||
if (action && action.type === ActionTypes.REPLACE) return;
|
||||
|
||||
if (unexpectedKeys.length > 0) {
|
||||
return "Unexpected " + (unexpectedKeys.length > 1 ? 'keys' : 'key') + " " + ("\"" + unexpectedKeys.join('", "') + "\" found in " + argumentName + ". ") + "Expected to find one of the known reducer keys instead: " + ("\"" + reducerKeys.join('", "') + "\". Unexpected keys will be ignored.");
|
||||
}
|
||||
}
|
||||
|
||||
function assertReducerShape(reducers) {
|
||||
Object.keys(reducers).forEach(function (key) {
|
||||
var reducer = reducers[key];
|
||||
var initialState = reducer(undefined, {
|
||||
type: ActionTypes.INIT
|
||||
});
|
||||
|
||||
if (typeof initialState === 'undefined') {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(12) : "The slice reducer for key \"" + key + "\" returned undefined during initialization. " + "If the state passed to the reducer is undefined, you must " + "explicitly return the initial state. The initial state may " + "not be undefined. If you don't want to set a value for this reducer, " + "you can use null instead of undefined.");
|
||||
}
|
||||
|
||||
if (typeof reducer(undefined, {
|
||||
type: ActionTypes.PROBE_UNKNOWN_ACTION()
|
||||
}) === 'undefined') {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(13) : "The slice reducer for key \"" + key + "\" returned undefined when probed with a random type. " + ("Don't try to handle '" + ActionTypes.INIT + "' or other actions in \"redux/*\" ") + "namespace. They are considered private. Instead, you must return the " + "current state for any unknown actions, unless it is undefined, " + "in which case you must return the initial state, regardless of the " + "action type. The initial state may not be undefined, but can be null.");
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Turns an object whose values are different reducer functions, into a single
|
||||
* reducer function. It will call every child reducer, and gather their results
|
||||
* into a single state object, whose keys correspond to the keys of the passed
|
||||
* reducer functions.
|
||||
*
|
||||
* @param {Object} reducers An object whose values correspond to different
|
||||
* reducer functions that need to be combined into one. One handy way to obtain
|
||||
* it is to use ES6 `import * as reducers` syntax. The reducers may never return
|
||||
* undefined for any action. Instead, they should return their initial state
|
||||
* if the state passed to them was undefined, and the current state for any
|
||||
* unrecognized action.
|
||||
*
|
||||
* @returns {Function} A reducer function that invokes every reducer inside the
|
||||
* passed object, and builds a state object with the same shape.
|
||||
*/
|
||||
|
||||
|
||||
function combineReducers(reducers) {
|
||||
var reducerKeys = Object.keys(reducers);
|
||||
var finalReducers = {};
|
||||
|
||||
for (var i = 0; i < reducerKeys.length; i++) {
|
||||
var key = reducerKeys[i];
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (typeof reducers[key] === 'undefined') {
|
||||
warning("No reducer provided for key \"" + key + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof reducers[key] === 'function') {
|
||||
finalReducers[key] = reducers[key];
|
||||
}
|
||||
}
|
||||
|
||||
var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
|
||||
// keys multiple times.
|
||||
|
||||
var unexpectedKeyCache;
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
unexpectedKeyCache = {};
|
||||
}
|
||||
|
||||
var shapeAssertionError;
|
||||
|
||||
try {
|
||||
assertReducerShape(finalReducers);
|
||||
} catch (e) {
|
||||
shapeAssertionError = e;
|
||||
}
|
||||
|
||||
return function combination(state, action) {
|
||||
if (state === void 0) {
|
||||
state = {};
|
||||
}
|
||||
|
||||
if (shapeAssertionError) {
|
||||
throw shapeAssertionError;
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
|
||||
|
||||
if (warningMessage) {
|
||||
warning(warningMessage);
|
||||
}
|
||||
}
|
||||
|
||||
var hasChanged = false;
|
||||
var nextState = {};
|
||||
|
||||
for (var _i = 0; _i < finalReducerKeys.length; _i++) {
|
||||
var _key = finalReducerKeys[_i];
|
||||
var reducer = finalReducers[_key];
|
||||
var previousStateForKey = state[_key];
|
||||
var nextStateForKey = reducer(previousStateForKey, action);
|
||||
|
||||
if (typeof nextStateForKey === 'undefined') {
|
||||
var actionType = action && action.type;
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(14) : "When called with an action of type " + (actionType ? "\"" + String(actionType) + "\"" : '(unknown type)') + ", the slice reducer for key \"" + _key + "\" returned undefined. " + "To ignore an action, you must explicitly return the previous state. " + "If you want this reducer to hold no value, you can return null instead of undefined.");
|
||||
}
|
||||
|
||||
nextState[_key] = nextStateForKey;
|
||||
hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
|
||||
}
|
||||
|
||||
hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
|
||||
return hasChanged ? nextState : state;
|
||||
};
|
||||
}
|
||||
|
||||
function bindActionCreator(actionCreator, dispatch) {
|
||||
return function () {
|
||||
return dispatch(actionCreator.apply(this, arguments));
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Turns an object whose values are action creators, into an object with the
|
||||
* same keys, but with every function wrapped into a `dispatch` call so they
|
||||
* may be invoked directly. This is just a convenience method, as you can call
|
||||
* `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
|
||||
*
|
||||
* For convenience, you can also pass an action creator as the first argument,
|
||||
* and get a dispatch wrapped function in return.
|
||||
*
|
||||
* @param {Function|Object} actionCreators An object whose values are action
|
||||
* creator functions. One handy way to obtain it is to use ES6 `import * as`
|
||||
* syntax. You may also pass a single function.
|
||||
*
|
||||
* @param {Function} dispatch The `dispatch` function available on your Redux
|
||||
* store.
|
||||
*
|
||||
* @returns {Function|Object} The object mimicking the original object, but with
|
||||
* every action creator wrapped into the `dispatch` call. If you passed a
|
||||
* function as `actionCreators`, the return value will also be a single
|
||||
* function.
|
||||
*/
|
||||
|
||||
|
||||
function bindActionCreators(actionCreators, dispatch) {
|
||||
if (typeof actionCreators === 'function') {
|
||||
return bindActionCreator(actionCreators, dispatch);
|
||||
}
|
||||
|
||||
if (typeof actionCreators !== 'object' || actionCreators === null) {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(16) : "bindActionCreators expected an object or a function, but instead received: '" + kindOf(actionCreators) + "'. " + "Did you write \"import ActionCreators from\" instead of \"import * as ActionCreators from\"?");
|
||||
}
|
||||
|
||||
var boundActionCreators = {};
|
||||
|
||||
for (var key in actionCreators) {
|
||||
var actionCreator = actionCreators[key];
|
||||
|
||||
if (typeof actionCreator === 'function') {
|
||||
boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
|
||||
}
|
||||
}
|
||||
|
||||
return boundActionCreators;
|
||||
}
|
||||
|
||||
/**
|
||||
* Composes single-argument functions from right to left. The rightmost
|
||||
* function can take multiple arguments as it provides the signature for
|
||||
* the resulting composite function.
|
||||
*
|
||||
* @param {...Function} funcs The functions to compose.
|
||||
* @returns {Function} A function obtained by composing the argument functions
|
||||
* from right to left. For example, compose(f, g, h) is identical to doing
|
||||
* (...args) => f(g(h(...args))).
|
||||
*/
|
||||
function compose() {
|
||||
for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
funcs[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
if (funcs.length === 0) {
|
||||
return function (arg) {
|
||||
return arg;
|
||||
};
|
||||
}
|
||||
|
||||
if (funcs.length === 1) {
|
||||
return funcs[0];
|
||||
}
|
||||
|
||||
return funcs.reduce(function (a, b) {
|
||||
return function () {
|
||||
return a(b.apply(void 0, arguments));
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a store enhancer that applies middleware to the dispatch method
|
||||
* of the Redux store. This is handy for a variety of tasks, such as expressing
|
||||
* asynchronous actions in a concise manner, or logging every action payload.
|
||||
*
|
||||
* See `redux-thunk` package as an example of the Redux middleware.
|
||||
*
|
||||
* Because middleware is potentially asynchronous, this should be the first
|
||||
* store enhancer in the composition chain.
|
||||
*
|
||||
* Note that each middleware will be given the `dispatch` and `getState` functions
|
||||
* as named arguments.
|
||||
*
|
||||
* @param {...Function} middlewares The middleware chain to be applied.
|
||||
* @returns {Function} A store enhancer applying the middleware.
|
||||
*/
|
||||
|
||||
function applyMiddleware() {
|
||||
for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
middlewares[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return function (createStore) {
|
||||
return function () {
|
||||
var store = createStore.apply(void 0, arguments);
|
||||
|
||||
var _dispatch = function dispatch() {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(15) : 'Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.');
|
||||
};
|
||||
|
||||
var middlewareAPI = {
|
||||
getState: store.getState,
|
||||
dispatch: function dispatch() {
|
||||
return _dispatch.apply(void 0, arguments);
|
||||
}
|
||||
};
|
||||
var chain = middlewares.map(function (middleware) {
|
||||
return middleware(middlewareAPI);
|
||||
});
|
||||
_dispatch = compose.apply(void 0, chain)(store.dispatch);
|
||||
return _objectSpread(_objectSpread({}, store), {}, {
|
||||
dispatch: _dispatch
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
* This is a dummy function to check if the function name has been altered by minification.
|
||||
* If the function has been minified and NODE_ENV !== 'production', warn the user.
|
||||
*/
|
||||
|
||||
function isCrushed() {}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && typeof isCrushed.name === 'string' && isCrushed.name !== 'isCrushed') {
|
||||
warning('You are currently using minified code outside of NODE_ENV === "production". ' + 'This means that you are running a slower development build of Redux. ' + 'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + 'or setting mode to production in webpack (https://webpack.js.org/concepts/mode/) ' + 'to ensure you have the correct code for your production build.');
|
||||
}
|
||||
|
||||
export { ActionTypes as __DO_NOT_USE__ActionTypes, applyMiddleware, bindActionCreators, combineReducers, compose, createStore };
|
1
web/node_modules/redux/es/redux.mjs
generated
vendored
Normal file
1
web/node_modules/redux/es/redux.mjs
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
function r(r){return"Minified Redux error #"+r+"; visit https://redux.js.org/Errors?code="+r+" for the full message or use the non-minified dev environment for full errors. "}var t="function"==typeof Symbol&&Symbol.observable||"@@observable",n=function(){return Math.random().toString(36).substring(7).split("").join(".")},e={INIT:"@@redux/INIT"+n(),REPLACE:"@@redux/REPLACE"+n(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+n()}};function o(r){if("object"!=typeof r||null===r)return!1;for(var t=r;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(r)===t}function i(n,f,u){var c;if("function"==typeof f&&"function"==typeof u||"function"==typeof u&&"function"==typeof arguments[3])throw Error(r(0));if("function"==typeof f&&void 0===u&&(u=f,f=void 0),void 0!==u){if("function"!=typeof u)throw Error(r(1));return u(i)(n,f)}if("function"!=typeof n)throw Error(r(2));var p=n,a=f,y=[],l=y,s=!1;function h(){l===y&&(l=y.slice())}function v(){if(s)throw Error(r(3));return a}function b(t){if("function"!=typeof t)throw Error(r(4));if(s)throw Error(r(5));var n=!0;return h(),l.push(t),function(){if(n){if(s)throw Error(r(6));n=!1,h();var e=l.indexOf(t);l.splice(e,1),y=null}}}function O(t){if(!o(t))throw Error(r(7));if(void 0===t.type)throw Error(r(8));if(s)throw Error(r(9));try{s=!0,a=p(a,t)}finally{s=!1}for(var n=y=l,e=0;n.length>e;e++){(0,n[e])()}return t}function d(t){if("function"!=typeof t)throw Error(r(10));p=t,O({type:e.REPLACE})}function E(){var n,e=b;return(n={subscribe:function(t){if("object"!=typeof t||null===t)throw Error(r(11));function n(){t.next&&t.next(v())}return n(),{unsubscribe:e(n)}}})[t]=function(){return this},n}return O({type:e.INIT}),(c={dispatch:O,subscribe:b,getState:v,replaceReducer:d})[t]=E,c}function f(t){for(var n=Object.keys(t),o={},i=0;n.length>i;i++){var f=n[i];"function"==typeof t[f]&&(o[f]=t[f])}var u,c=Object.keys(o);try{!function(t){Object.keys(t).forEach((function(n){var o=t[n];if(void 0===o(void 0,{type:e.INIT}))throw Error(r(12));if(void 0===o(void 0,{type:e.PROBE_UNKNOWN_ACTION()}))throw Error(r(13))}))}(o)}catch(r){u=r}return function(t,n){if(void 0===t&&(t={}),u)throw u;for(var e=!1,i={},f=0;c.length>f;f++){var p=c[f],a=t[p],y=(0,o[p])(a,n);if(void 0===y)throw Error(r(14));i[p]=y,e=e||y!==a}return(e=e||c.length!==Object.keys(t).length)?i:t}}function u(r,t){return function(){return t(r.apply(this,arguments))}}function c(t,n){if("function"==typeof t)return u(t,n);if("object"!=typeof t||null===t)throw Error(r(16));var e={};for(var o in t){var i=t[o];"function"==typeof i&&(e[o]=u(i,n))}return e}function p(r,t,n){return t in r?Object.defineProperty(r,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[t]=n,r}function a(r,t){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(r);t&&(e=e.filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),n.push.apply(n,e)}return n}function y(r){for(var t=1;arguments.length>t;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){p(r,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(n,t))}))}return r}function l(){for(var r=arguments.length,t=Array(r),n=0;r>n;n++)t[n]=arguments[n];return 0===t.length?function(r){return r}:1===t.length?t[0]:t.reduce((function(r,t){return function(){return r(t.apply(void 0,arguments))}}))}function s(){for(var t=arguments.length,n=Array(t),e=0;t>e;e++)n[e]=arguments[e];return function(t){return function(){var e=t.apply(void 0,arguments),o=function(){throw Error(r(15))},i={getState:e.getState,dispatch:function(){return o.apply(void 0,arguments)}},f=n.map((function(r){return r(i)}));return o=l.apply(void 0,f)(e.dispatch),y(y({},e),{},{dispatch:o})}}}export{e as __DO_NOT_USE__ActionTypes,s as applyMiddleware,c as bindActionCreators,f as combineReducers,l as compose,i as createStore};
|
676
web/node_modules/redux/index.d.ts
generated
vendored
Normal file
676
web/node_modules/redux/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,676 @@
|
|||
/**
|
||||
* An *action* is a plain object that represents an intention to change the
|
||||
* state. Actions are the only way to get data into the store. Any data,
|
||||
* whether from UI events, network callbacks, or other sources such as
|
||||
* WebSockets needs to eventually be dispatched as actions.
|
||||
*
|
||||
* Actions must have a `type` field that indicates the type of action being
|
||||
* performed. Types can be defined as constants and imported from another
|
||||
* module. It's better to use strings for `type` than Symbols because strings
|
||||
* are serializable.
|
||||
*
|
||||
* Other than `type`, the structure of an action object is really up to you.
|
||||
* If you're interested, check out Flux Standard Action for recommendations on
|
||||
* how actions should be constructed.
|
||||
*
|
||||
* @template T the type of the action's `type` tag.
|
||||
*/
|
||||
export interface Action<T = any> {
|
||||
type: T
|
||||
}
|
||||
|
||||
/**
|
||||
* An Action type which accepts any other properties.
|
||||
* This is mainly for the use of the `Reducer` type.
|
||||
* This is not part of `Action` itself to prevent types that extend `Action` from
|
||||
* having an index signature.
|
||||
*/
|
||||
export interface AnyAction extends Action {
|
||||
// Allows any extra properties to be defined in an action.
|
||||
[extraProps: string]: any
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal "virtual" symbol used to make the `CombinedState` type unique.
|
||||
*/
|
||||
declare const $CombinedState: unique symbol
|
||||
|
||||
/**
|
||||
* State base type for reducers created with `combineReducers()`.
|
||||
*
|
||||
* This type allows the `createStore()` method to infer which levels of the
|
||||
* preloaded state can be partial.
|
||||
*
|
||||
* Because Typescript is really duck-typed, a type needs to have some
|
||||
* identifying property to differentiate it from other types with matching
|
||||
* prototypes for type checking purposes. That's why this type has the
|
||||
* `$CombinedState` symbol property. Without the property, this type would
|
||||
* match any object. The symbol doesn't really exist because it's an internal
|
||||
* (i.e. not exported), and internally we never check its value. Since it's a
|
||||
* symbol property, it's not expected to be unumerable, and the value is
|
||||
* typed as always undefined, so its never expected to have a meaningful
|
||||
* value anyway. It just makes this type distinquishable from plain `{}`.
|
||||
*/
|
||||
interface EmptyObject {
|
||||
readonly [$CombinedState]?: undefined
|
||||
}
|
||||
export type CombinedState<S> = EmptyObject & S
|
||||
|
||||
/**
|
||||
* Recursively makes combined state objects partial. Only combined state _root
|
||||
* objects_ (i.e. the generated higher level object with keys mapping to
|
||||
* individual reducers) are partial.
|
||||
*/
|
||||
export type PreloadedState<S> = Required<S> extends EmptyObject
|
||||
? S extends CombinedState<infer S1>
|
||||
? {
|
||||
[K in keyof S1]?: S1[K] extends object ? PreloadedState<S1[K]> : S1[K]
|
||||
}
|
||||
: never
|
||||
: {
|
||||
[K in keyof S]: S[K] extends string | number | boolean | symbol
|
||||
? S[K]
|
||||
: PreloadedState<S[K]>
|
||||
}
|
||||
|
||||
/* reducers */
|
||||
|
||||
/**
|
||||
* A *reducer* (also called a *reducing function*) is a function that accepts
|
||||
* an accumulation and a value and returns a new accumulation. They are used
|
||||
* to reduce a collection of values down to a single value
|
||||
*
|
||||
* Reducers are not unique to Redux—they are a fundamental concept in
|
||||
* functional programming. Even most non-functional languages, like
|
||||
* JavaScript, have a built-in API for reducing. In JavaScript, it's
|
||||
* `Array.prototype.reduce()`.
|
||||
*
|
||||
* In Redux, the accumulated value is the state object, and the values being
|
||||
* accumulated are actions. Reducers calculate a new state given the previous
|
||||
* state and an action. They must be *pure functions*—functions that return
|
||||
* the exact same output for given inputs. They should also be free of
|
||||
* side-effects. This is what enables exciting features like hot reloading and
|
||||
* time travel.
|
||||
*
|
||||
* Reducers are the most important concept in Redux.
|
||||
*
|
||||
* *Do not put API calls into reducers.*
|
||||
*
|
||||
* @template S The type of state consumed and produced by this reducer.
|
||||
* @template A The type of actions the reducer can potentially respond to.
|
||||
*/
|
||||
export type Reducer<S = any, A extends Action = AnyAction> = (
|
||||
state: S | undefined,
|
||||
action: A
|
||||
) => S
|
||||
|
||||
/**
|
||||
* Object whose values correspond to different reducer functions.
|
||||
*
|
||||
* @template A The type of actions the reducers can potentially respond to.
|
||||
*/
|
||||
export type ReducersMapObject<S = any, A extends Action = Action> = {
|
||||
[K in keyof S]: Reducer<S[K], A>
|
||||
}
|
||||
|
||||
/**
|
||||
* Infer a combined state shape from a `ReducersMapObject`.
|
||||
*
|
||||
* @template M Object map of reducers as provided to `combineReducers(map: M)`.
|
||||
*/
|
||||
export type StateFromReducersMapObject<M> = M extends ReducersMapObject<
|
||||
any,
|
||||
any
|
||||
>
|
||||
? { [P in keyof M]: M[P] extends Reducer<infer S, any> ? S : never }
|
||||
: never
|
||||
|
||||
/**
|
||||
* Infer reducer union type from a `ReducersMapObject`.
|
||||
*
|
||||
* @template M Object map of reducers as provided to `combineReducers(map: M)`.
|
||||
*/
|
||||
export type ReducerFromReducersMapObject<M> = M extends {
|
||||
[P in keyof M]: infer R
|
||||
}
|
||||
? R extends Reducer<any, any>
|
||||
? R
|
||||
: never
|
||||
: never
|
||||
|
||||
/**
|
||||
* Infer action type from a reducer function.
|
||||
*
|
||||
* @template R Type of reducer.
|
||||
*/
|
||||
export type ActionFromReducer<R> = R extends Reducer<any, infer A> ? A : never
|
||||
|
||||
/**
|
||||
* Infer action union type from a `ReducersMapObject`.
|
||||
*
|
||||
* @template M Object map of reducers as provided to `combineReducers(map: M)`.
|
||||
*/
|
||||
export type ActionFromReducersMapObject<M> = M extends ReducersMapObject<
|
||||
any,
|
||||
any
|
||||
>
|
||||
? ActionFromReducer<ReducerFromReducersMapObject<M>>
|
||||
: never
|
||||
|
||||
/**
|
||||
* Turns an object whose values are different reducer functions, into a single
|
||||
* reducer function. It will call every child reducer, and gather their results
|
||||
* into a single state object, whose keys correspond to the keys of the passed
|
||||
* reducer functions.
|
||||
*
|
||||
* @template S Combined state object type.
|
||||
*
|
||||
* @param reducers An object whose values correspond to different reducer
|
||||
* functions that need to be combined into one. One handy way to obtain it
|
||||
* is to use ES6 `import * as reducers` syntax. The reducers may never
|
||||
* return undefined for any action. Instead, they should return their
|
||||
* initial state if the state passed to them was undefined, and the current
|
||||
* state for any unrecognized action.
|
||||
*
|
||||
* @returns A reducer function that invokes every reducer inside the passed
|
||||
* object, and builds a state object with the same shape.
|
||||
*/
|
||||
export function combineReducers<S>(
|
||||
reducers: ReducersMapObject<S, any>
|
||||
): Reducer<CombinedState<S>>
|
||||
export function combineReducers<S, A extends Action = AnyAction>(
|
||||
reducers: ReducersMapObject<S, A>
|
||||
): Reducer<CombinedState<S>, A>
|
||||
export function combineReducers<M extends ReducersMapObject<any, any>>(
|
||||
reducers: M
|
||||
): Reducer<
|
||||
CombinedState<StateFromReducersMapObject<M>>,
|
||||
ActionFromReducersMapObject<M>
|
||||
>
|
||||
|
||||
/* store */
|
||||
|
||||
/**
|
||||
* A *dispatching function* (or simply *dispatch function*) is a function that
|
||||
* accepts an action or an async action; it then may or may not dispatch one
|
||||
* or more actions to the store.
|
||||
*
|
||||
* We must distinguish between dispatching functions in general and the base
|
||||
* `dispatch` function provided by the store instance without any middleware.
|
||||
*
|
||||
* The base dispatch function *always* synchronously sends an action to the
|
||||
* store's reducer, along with the previous state returned by the store, to
|
||||
* calculate a new state. It expects actions to be plain objects ready to be
|
||||
* consumed by the reducer.
|
||||
*
|
||||
* Middleware wraps the base dispatch function. It allows the dispatch
|
||||
* function to handle async actions in addition to actions. Middleware may
|
||||
* transform, delay, ignore, or otherwise interpret actions or async actions
|
||||
* before passing them to the next middleware.
|
||||
*
|
||||
* @template A The type of things (actions or otherwise) which may be
|
||||
* dispatched.
|
||||
*/
|
||||
export interface Dispatch<A extends Action = AnyAction> {
|
||||
<T extends A>(action: T): T
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to remove listener added by `Store.subscribe()`.
|
||||
*/
|
||||
export interface Unsubscribe {
|
||||
(): void
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface SymbolConstructor {
|
||||
readonly observable: symbol
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A minimal observable of state changes.
|
||||
* For more information, see the observable proposal:
|
||||
* https://github.com/tc39/proposal-observable
|
||||
*/
|
||||
export type Observable<T> = {
|
||||
/**
|
||||
* The minimal observable subscription method.
|
||||
* @param {Object} observer Any object that can be used as an observer.
|
||||
* The observer object should have a `next` method.
|
||||
* @returns {subscription} An object with an `unsubscribe` method that can
|
||||
* be used to unsubscribe the observable from the store, and prevent further
|
||||
* emission of values from the observable.
|
||||
*/
|
||||
subscribe: (observer: Observer<T>) => { unsubscribe: Unsubscribe }
|
||||
[Symbol.observable](): Observable<T>
|
||||
}
|
||||
|
||||
/**
|
||||
* An Observer is used to receive data from an Observable, and is supplied as
|
||||
* an argument to subscribe.
|
||||
*/
|
||||
export type Observer<T> = {
|
||||
next?(value: T): void
|
||||
}
|
||||
|
||||
/**
|
||||
* A store is an object that holds the application's state tree.
|
||||
* There should only be a single store in a Redux app, as the composition
|
||||
* happens on the reducer level.
|
||||
*
|
||||
* @template S The type of state held by this store.
|
||||
* @template A the type of actions which may be dispatched by this store.
|
||||
*/
|
||||
export interface Store<S = any, A extends Action = AnyAction> {
|
||||
/**
|
||||
* Dispatches an action. It is the only way to trigger a state change.
|
||||
*
|
||||
* The `reducer` function, used to create the store, will be called with the
|
||||
* current state tree and the given `action`. Its return value will be
|
||||
* considered the **next** state of the tree, and the change listeners will
|
||||
* be notified.
|
||||
*
|
||||
* The base implementation only supports plain object actions. If you want
|
||||
* to dispatch a Promise, an Observable, a thunk, or something else, you
|
||||
* need to wrap your store creating function into the corresponding
|
||||
* middleware. For example, see the documentation for the `redux-thunk`
|
||||
* package. Even the middleware will eventually dispatch plain object
|
||||
* actions using this method.
|
||||
*
|
||||
* @param action A plain object representing “what changed”. It is a good
|
||||
* idea to keep actions serializable so you can record and replay user
|
||||
* sessions, or use the time travelling `redux-devtools`. An action must
|
||||
* have a `type` property which may not be `undefined`. It is a good idea
|
||||
* to use string constants for action types.
|
||||
*
|
||||
* @returns For convenience, the same action object you dispatched.
|
||||
*
|
||||
* Note that, if you use a custom middleware, it may wrap `dispatch()` to
|
||||
* return something else (for example, a Promise you can await).
|
||||
*/
|
||||
dispatch: Dispatch<A>
|
||||
|
||||
/**
|
||||
* Reads the state tree managed by the store.
|
||||
*
|
||||
* @returns The current state tree of your application.
|
||||
*/
|
||||
getState(): S
|
||||
|
||||
/**
|
||||
* Adds a change listener. It will be called any time an action is
|
||||
* dispatched, and some part of the state tree may potentially have changed.
|
||||
* You may then call `getState()` to read the current state tree inside the
|
||||
* callback.
|
||||
*
|
||||
* You may call `dispatch()` from a change listener, with the following
|
||||
* caveats:
|
||||
*
|
||||
* 1. The subscriptions are snapshotted just before every `dispatch()` call.
|
||||
* If you subscribe or unsubscribe while the listeners are being invoked,
|
||||
* this will not have any effect on the `dispatch()` that is currently in
|
||||
* progress. However, the next `dispatch()` call, whether nested or not,
|
||||
* will use a more recent snapshot of the subscription list.
|
||||
*
|
||||
* 2. The listener should not expect to see all states changes, as the state
|
||||
* might have been updated multiple times during a nested `dispatch()` before
|
||||
* the listener is called. It is, however, guaranteed that all subscribers
|
||||
* registered before the `dispatch()` started will be called with the latest
|
||||
* state by the time it exits.
|
||||
*
|
||||
* @param listener A callback to be invoked on every dispatch.
|
||||
* @returns A function to remove this change listener.
|
||||
*/
|
||||
subscribe(listener: () => void): Unsubscribe
|
||||
|
||||
/**
|
||||
* Replaces the reducer currently used by the store to calculate the state.
|
||||
*
|
||||
* You might need this if your app implements code splitting and you want to
|
||||
* load some of the reducers dynamically. You might also need this if you
|
||||
* implement a hot reloading mechanism for Redux.
|
||||
*
|
||||
* @param nextReducer The reducer for the store to use instead.
|
||||
*/
|
||||
replaceReducer(nextReducer: Reducer<S, A>): void
|
||||
|
||||
/**
|
||||
* Interoperability point for observable/reactive libraries.
|
||||
* @returns {observable} A minimal observable of state changes.
|
||||
* For more information, see the observable proposal:
|
||||
* https://github.com/tc39/proposal-observable
|
||||
*/
|
||||
[Symbol.observable](): Observable<S>
|
||||
}
|
||||
|
||||
export type DeepPartial<T> = {
|
||||
[K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K]
|
||||
}
|
||||
|
||||
/**
|
||||
* A store creator is a function that creates a Redux store. Like with
|
||||
* dispatching function, we must distinguish the base store creator,
|
||||
* `createStore(reducer, preloadedState)` exported from the Redux package, from
|
||||
* store creators that are returned from the store enhancers.
|
||||
*
|
||||
* @template S The type of state to be held by the store.
|
||||
* @template A The type of actions which may be dispatched.
|
||||
* @template Ext Store extension that is mixed in to the Store type.
|
||||
* @template StateExt State extension that is mixed into the state type.
|
||||
*/
|
||||
export interface StoreCreator {
|
||||
<S, A extends Action, Ext, StateExt>(
|
||||
reducer: Reducer<S, A>,
|
||||
enhancer?: StoreEnhancer<Ext, StateExt>
|
||||
): Store<S & StateExt, A> & Ext
|
||||
<S, A extends Action, Ext, StateExt>(
|
||||
reducer: Reducer<S, A>,
|
||||
preloadedState?: PreloadedState<S>,
|
||||
enhancer?: StoreEnhancer<Ext>
|
||||
): Store<S & StateExt, A> & Ext
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Redux store that holds the state tree.
|
||||
* The only way to change the data in the store is to call `dispatch()` on it.
|
||||
*
|
||||
* There should only be a single store in your app. To specify how different
|
||||
* parts of the state tree respond to actions, you may combine several
|
||||
* reducers
|
||||
* into a single reducer function by using `combineReducers`.
|
||||
*
|
||||
* @template S State object type.
|
||||
*
|
||||
* @param reducer A function that returns the next state tree, given the
|
||||
* current state tree and the action to handle.
|
||||
*
|
||||
* @param [preloadedState] The initial state. You may optionally specify it to
|
||||
* hydrate the state from the server in universal apps, or to restore a
|
||||
* previously serialized user session. If you use `combineReducers` to
|
||||
* produce the root reducer function, this must be an object with the same
|
||||
* shape as `combineReducers` keys.
|
||||
*
|
||||
* @param [enhancer] The store enhancer. You may optionally specify it to
|
||||
* enhance the store with third-party capabilities such as middleware, time
|
||||
* travel, persistence, etc. The only store enhancer that ships with Redux
|
||||
* is `applyMiddleware()`.
|
||||
*
|
||||
* @returns A Redux store that lets you read the state, dispatch actions and
|
||||
* subscribe to changes.
|
||||
*/
|
||||
export const createStore: StoreCreator
|
||||
|
||||
/**
|
||||
* A store enhancer is a higher-order function that composes a store creator
|
||||
* to return a new, enhanced store creator. This is similar to middleware in
|
||||
* that it allows you to alter the store interface in a composable way.
|
||||
*
|
||||
* Store enhancers are much the same concept as higher-order components in
|
||||
* React, which are also occasionally called “component enhancers”.
|
||||
*
|
||||
* Because a store is not an instance, but rather a plain-object collection of
|
||||
* functions, copies can be easily created and modified without mutating the
|
||||
* original store. There is an example in `compose` documentation
|
||||
* demonstrating that.
|
||||
*
|
||||
* Most likely you'll never write a store enhancer, but you may use the one
|
||||
* provided by the developer tools. It is what makes time travel possible
|
||||
* without the app being aware it is happening. Amusingly, the Redux
|
||||
* middleware implementation is itself a store enhancer.
|
||||
*
|
||||
* @template Ext Store extension that is mixed into the Store type.
|
||||
* @template StateExt State extension that is mixed into the state type.
|
||||
*/
|
||||
export type StoreEnhancer<Ext = {}, StateExt = {}> = (
|
||||
next: StoreEnhancerStoreCreator
|
||||
) => StoreEnhancerStoreCreator<Ext, StateExt>
|
||||
export type StoreEnhancerStoreCreator<Ext = {}, StateExt = {}> = <
|
||||
S = any,
|
||||
A extends Action = AnyAction
|
||||
>(
|
||||
reducer: Reducer<S, A>,
|
||||
preloadedState?: PreloadedState<S>
|
||||
) => Store<S & StateExt, A> & Ext
|
||||
|
||||
/* middleware */
|
||||
|
||||
export interface MiddlewareAPI<D extends Dispatch = Dispatch, S = any> {
|
||||
dispatch: D
|
||||
getState(): S
|
||||
}
|
||||
|
||||
/**
|
||||
* A middleware is a higher-order function that composes a dispatch function
|
||||
* to return a new dispatch function. It often turns async actions into
|
||||
* actions.
|
||||
*
|
||||
* Middleware is composable using function composition. It is useful for
|
||||
* logging actions, performing side effects like routing, or turning an
|
||||
* asynchronous API call into a series of synchronous actions.
|
||||
*
|
||||
* @template DispatchExt Extra Dispatch signature added by this middleware.
|
||||
* @template S The type of the state supported by this middleware.
|
||||
* @template D The type of Dispatch of the store where this middleware is
|
||||
* installed.
|
||||
*/
|
||||
export interface Middleware<
|
||||
DispatchExt = {},
|
||||
S = any,
|
||||
D extends Dispatch = Dispatch
|
||||
> {
|
||||
(api: MiddlewareAPI<D, S>): (
|
||||
next: Dispatch<AnyAction>
|
||||
) => (action: any) => any
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a store enhancer that applies middleware to the dispatch method
|
||||
* of the Redux store. This is handy for a variety of tasks, such as
|
||||
* expressing asynchronous actions in a concise manner, or logging every
|
||||
* action payload.
|
||||
*
|
||||
* See `redux-thunk` package as an example of the Redux middleware.
|
||||
*
|
||||
* Because middleware is potentially asynchronous, this should be the first
|
||||
* store enhancer in the composition chain.
|
||||
*
|
||||
* Note that each middleware will be given the `dispatch` and `getState`
|
||||
* functions as named arguments.
|
||||
*
|
||||
* @param middlewares The middleware chain to be applied.
|
||||
* @returns A store enhancer applying the middleware.
|
||||
*
|
||||
* @template Ext Dispatch signature added by a middleware.
|
||||
* @template S The type of the state supported by a middleware.
|
||||
*/
|
||||
export function applyMiddleware(): StoreEnhancer
|
||||
export function applyMiddleware<Ext1, S>(
|
||||
middleware1: Middleware<Ext1, S, any>
|
||||
): StoreEnhancer<{ dispatch: Ext1 }>
|
||||
export function applyMiddleware<Ext1, Ext2, S>(
|
||||
middleware1: Middleware<Ext1, S, any>,
|
||||
middleware2: Middleware<Ext2, S, any>
|
||||
): StoreEnhancer<{ dispatch: Ext1 & Ext2 }>
|
||||
export function applyMiddleware<Ext1, Ext2, Ext3, S>(
|
||||
middleware1: Middleware<Ext1, S, any>,
|
||||
middleware2: Middleware<Ext2, S, any>,
|
||||
middleware3: Middleware<Ext3, S, any>
|
||||
): StoreEnhancer<{ dispatch: Ext1 & Ext2 & Ext3 }>
|
||||
export function applyMiddleware<Ext1, Ext2, Ext3, Ext4, S>(
|
||||
middleware1: Middleware<Ext1, S, any>,
|
||||
middleware2: Middleware<Ext2, S, any>,
|
||||
middleware3: Middleware<Ext3, S, any>,
|
||||
middleware4: Middleware<Ext4, S, any>
|
||||
): StoreEnhancer<{ dispatch: Ext1 & Ext2 & Ext3 & Ext4 }>
|
||||
export function applyMiddleware<Ext1, Ext2, Ext3, Ext4, Ext5, S>(
|
||||
middleware1: Middleware<Ext1, S, any>,
|
||||
middleware2: Middleware<Ext2, S, any>,
|
||||
middleware3: Middleware<Ext3, S, any>,
|
||||
middleware4: Middleware<Ext4, S, any>,
|
||||
middleware5: Middleware<Ext5, S, any>
|
||||
): StoreEnhancer<{ dispatch: Ext1 & Ext2 & Ext3 & Ext4 & Ext5 }>
|
||||
export function applyMiddleware<Ext, S = any>(
|
||||
...middlewares: Middleware<any, S, any>[]
|
||||
): StoreEnhancer<{ dispatch: Ext }>
|
||||
|
||||
/* action creators */
|
||||
|
||||
/**
|
||||
* An *action creator* is, quite simply, a function that creates an action. Do
|
||||
* not confuse the two terms—again, an action is a payload of information, and
|
||||
* an action creator is a factory that creates an action.
|
||||
*
|
||||
* Calling an action creator only produces an action, but does not dispatch
|
||||
* it. You need to call the store's `dispatch` function to actually cause the
|
||||
* mutation. Sometimes we say *bound action creators* to mean functions that
|
||||
* call an action creator and immediately dispatch its result to a specific
|
||||
* store instance.
|
||||
*
|
||||
* If an action creator needs to read the current state, perform an API call,
|
||||
* or cause a side effect, like a routing transition, it should return an
|
||||
* async action instead of an action.
|
||||
*
|
||||
* @template A Returned action type.
|
||||
*/
|
||||
export interface ActionCreator<A> {
|
||||
(...args: any[]): A
|
||||
}
|
||||
|
||||
/**
|
||||
* Object whose values are action creator functions.
|
||||
*/
|
||||
export interface ActionCreatorsMapObject<A = any> {
|
||||
[key: string]: ActionCreator<A>
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns an object whose values are action creators, into an object with the
|
||||
* same keys, but with every function wrapped into a `dispatch` call so they
|
||||
* may be invoked directly. This is just a convenience method, as you can call
|
||||
* `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
|
||||
*
|
||||
* For convenience, you can also pass a single function as the first argument,
|
||||
* and get a function in return.
|
||||
*
|
||||
* @param actionCreator An object whose values are action creator functions.
|
||||
* One handy way to obtain it is to use ES6 `import * as` syntax. You may
|
||||
* also pass a single function.
|
||||
*
|
||||
* @param dispatch The `dispatch` function available on your Redux store.
|
||||
*
|
||||
* @returns The object mimicking the original object, but with every action
|
||||
* creator wrapped into the `dispatch` call. If you passed a function as
|
||||
* `actionCreator`, the return value will also be a single function.
|
||||
*/
|
||||
export function bindActionCreators<A, C extends ActionCreator<A>>(
|
||||
actionCreator: C,
|
||||
dispatch: Dispatch
|
||||
): C
|
||||
|
||||
export function bindActionCreators<
|
||||
A extends ActionCreator<any>,
|
||||
B extends ActionCreator<any>
|
||||
>(actionCreator: A, dispatch: Dispatch): B
|
||||
|
||||
export function bindActionCreators<A, M extends ActionCreatorsMapObject<A>>(
|
||||
actionCreators: M,
|
||||
dispatch: Dispatch
|
||||
): M
|
||||
|
||||
export function bindActionCreators<
|
||||
M extends ActionCreatorsMapObject<any>,
|
||||
N extends ActionCreatorsMapObject<any>
|
||||
>(actionCreators: M, dispatch: Dispatch): N
|
||||
|
||||
/* compose */
|
||||
|
||||
type Func0<R> = () => R
|
||||
type Func1<T1, R> = (a1: T1) => R
|
||||
type Func2<T1, T2, R> = (a1: T1, a2: T2) => R
|
||||
type Func3<T1, T2, T3, R> = (a1: T1, a2: T2, a3: T3, ...args: any[]) => R
|
||||
|
||||
/**
|
||||
* Composes single-argument functions from right to left. The rightmost
|
||||
* function can take multiple arguments as it provides the signature for the
|
||||
* resulting composite function.
|
||||
*
|
||||
* @param funcs The functions to compose.
|
||||
* @returns R function obtained by composing the argument functions from right
|
||||
* to left. For example, `compose(f, g, h)` is identical to doing
|
||||
* `(...args) => f(g(h(...args)))`.
|
||||
*/
|
||||
export function compose(): <R>(a: R) => R
|
||||
|
||||
export function compose<F extends Function>(f: F): F
|
||||
|
||||
/* two functions */
|
||||
export function compose<A, R>(f1: (b: A) => R, f2: Func0<A>): Func0<R>
|
||||
export function compose<A, T1, R>(
|
||||
f1: (b: A) => R,
|
||||
f2: Func1<T1, A>
|
||||
): Func1<T1, R>
|
||||
export function compose<A, T1, T2, R>(
|
||||
f1: (b: A) => R,
|
||||
f2: Func2<T1, T2, A>
|
||||
): Func2<T1, T2, R>
|
||||
export function compose<A, T1, T2, T3, R>(
|
||||
f1: (b: A) => R,
|
||||
f2: Func3<T1, T2, T3, A>
|
||||
): Func3<T1, T2, T3, R>
|
||||
|
||||
/* three functions */
|
||||
export function compose<A, B, R>(
|
||||
f1: (b: B) => R,
|
||||
f2: (a: A) => B,
|
||||
f3: Func0<A>
|
||||
): Func0<R>
|
||||
export function compose<A, B, T1, R>(
|
||||
f1: (b: B) => R,
|
||||
f2: (a: A) => B,
|
||||
f3: Func1<T1, A>
|
||||
): Func1<T1, R>
|
||||
export function compose<A, B, T1, T2, R>(
|
||||
f1: (b: B) => R,
|
||||
f2: (a: A) => B,
|
||||
f3: Func2<T1, T2, A>
|
||||
): Func2<T1, T2, R>
|
||||
export function compose<A, B, T1, T2, T3, R>(
|
||||
f1: (b: B) => R,
|
||||
f2: (a: A) => B,
|
||||
f3: Func3<T1, T2, T3, A>
|
||||
): Func3<T1, T2, T3, R>
|
||||
|
||||
/* four functions */
|
||||
export function compose<A, B, C, R>(
|
||||
f1: (b: C) => R,
|
||||
f2: (a: B) => C,
|
||||
f3: (a: A) => B,
|
||||
f4: Func0<A>
|
||||
): Func0<R>
|
||||
export function compose<A, B, C, T1, R>(
|
||||
f1: (b: C) => R,
|
||||
f2: (a: B) => C,
|
||||
f3: (a: A) => B,
|
||||
f4: Func1<T1, A>
|
||||
): Func1<T1, R>
|
||||
export function compose<A, B, C, T1, T2, R>(
|
||||
f1: (b: C) => R,
|
||||
f2: (a: B) => C,
|
||||
f3: (a: A) => B,
|
||||
f4: Func2<T1, T2, A>
|
||||
): Func2<T1, T2, R>
|
||||
export function compose<A, B, C, T1, T2, T3, R>(
|
||||
f1: (b: C) => R,
|
||||
f2: (a: B) => C,
|
||||
f3: (a: A) => B,
|
||||
f4: Func3<T1, T2, T3, A>
|
||||
): Func3<T1, T2, T3, R>
|
||||
|
||||
/* rest */
|
||||
export function compose<R>(
|
||||
f1: (b: any) => R,
|
||||
...funcs: Function[]
|
||||
): (...args: any[]) => R
|
||||
|
||||
export function compose<R>(...funcs: Function[]): (...args: any[]) => R
|
697
web/node_modules/redux/lib/redux.js
generated
vendored
Normal file
697
web/node_modules/redux/lib/redux.js
generated
vendored
Normal file
|
@ -0,0 +1,697 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
||||
|
||||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
||||
|
||||
var _objectSpread__default = /*#__PURE__*/_interopDefaultLegacy(_objectSpread);
|
||||
|
||||
/**
|
||||
* Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
|
||||
*
|
||||
* Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
|
||||
* during build.
|
||||
* @param {number} code
|
||||
*/
|
||||
function formatProdErrorMessage(code) {
|
||||
return "Minified Redux error #" + code + "; visit https://redux.js.org/Errors?code=" + code + " for the full message or " + 'use the non-minified dev environment for full errors. ';
|
||||
}
|
||||
|
||||
// Inlined version of the `symbol-observable` polyfill
|
||||
var $$observable = (function () {
|
||||
return typeof Symbol === 'function' && Symbol.observable || '@@observable';
|
||||
})();
|
||||
|
||||
/**
|
||||
* These are private action types reserved by Redux.
|
||||
* For any unknown actions, you must return the current state.
|
||||
* If the current state is undefined, you must return the initial state.
|
||||
* Do not reference these action types directly in your code.
|
||||
*/
|
||||
var randomString = function randomString() {
|
||||
return Math.random().toString(36).substring(7).split('').join('.');
|
||||
};
|
||||
|
||||
var ActionTypes = {
|
||||
INIT: "@@redux/INIT" + randomString(),
|
||||
REPLACE: "@@redux/REPLACE" + randomString(),
|
||||
PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
|
||||
return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {any} obj The object to inspect.
|
||||
* @returns {boolean} True if the argument appears to be a plain object.
|
||||
*/
|
||||
function isPlainObject(obj) {
|
||||
if (typeof obj !== 'object' || obj === null) return false;
|
||||
var proto = obj;
|
||||
|
||||
while (Object.getPrototypeOf(proto) !== null) {
|
||||
proto = Object.getPrototypeOf(proto);
|
||||
}
|
||||
|
||||
return Object.getPrototypeOf(obj) === proto;
|
||||
}
|
||||
|
||||
// Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
|
||||
function miniKindOf(val) {
|
||||
if (val === void 0) return 'undefined';
|
||||
if (val === null) return 'null';
|
||||
var type = typeof val;
|
||||
|
||||
switch (type) {
|
||||
case 'boolean':
|
||||
case 'string':
|
||||
case 'number':
|
||||
case 'symbol':
|
||||
case 'function':
|
||||
{
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
if (Array.isArray(val)) return 'array';
|
||||
if (isDate(val)) return 'date';
|
||||
if (isError(val)) return 'error';
|
||||
var constructorName = ctorName(val);
|
||||
|
||||
switch (constructorName) {
|
||||
case 'Symbol':
|
||||
case 'Promise':
|
||||
case 'WeakMap':
|
||||
case 'WeakSet':
|
||||
case 'Map':
|
||||
case 'Set':
|
||||
return constructorName;
|
||||
} // other
|
||||
|
||||
|
||||
return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
|
||||
}
|
||||
|
||||
function ctorName(val) {
|
||||
return typeof val.constructor === 'function' ? val.constructor.name : null;
|
||||
}
|
||||
|
||||
function isError(val) {
|
||||
return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
|
||||
}
|
||||
|
||||
function isDate(val) {
|
||||
if (val instanceof Date) return true;
|
||||
return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
|
||||
}
|
||||
|
||||
function kindOf(val) {
|
||||
var typeOfVal = typeof val;
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
typeOfVal = miniKindOf(val);
|
||||
}
|
||||
|
||||
return typeOfVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Redux store that holds the state tree.
|
||||
* The only way to change the data in the store is to call `dispatch()` on it.
|
||||
*
|
||||
* There should only be a single store in your app. To specify how different
|
||||
* parts of the state tree respond to actions, you may combine several reducers
|
||||
* into a single reducer function by using `combineReducers`.
|
||||
*
|
||||
* @param {Function} reducer A function that returns the next state tree, given
|
||||
* the current state tree and the action to handle.
|
||||
*
|
||||
* @param {any} [preloadedState] The initial state. You may optionally specify it
|
||||
* to hydrate the state from the server in universal apps, or to restore a
|
||||
* previously serialized user session.
|
||||
* If you use `combineReducers` to produce the root reducer function, this must be
|
||||
* an object with the same shape as `combineReducers` keys.
|
||||
*
|
||||
* @param {Function} [enhancer] The store enhancer. You may optionally specify it
|
||||
* to enhance the store with third-party capabilities such as middleware,
|
||||
* time travel, persistence, etc. The only store enhancer that ships with Redux
|
||||
* is `applyMiddleware()`.
|
||||
*
|
||||
* @returns {Store} A Redux store that lets you read the state, dispatch actions
|
||||
* and subscribe to changes.
|
||||
*/
|
||||
|
||||
function createStore(reducer, preloadedState, enhancer) {
|
||||
var _ref2;
|
||||
|
||||
if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(0) : 'It looks like you are passing several store enhancers to ' + 'createStore(). This is not supported. Instead, compose them ' + 'together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.');
|
||||
}
|
||||
|
||||
if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
|
||||
enhancer = preloadedState;
|
||||
preloadedState = undefined;
|
||||
}
|
||||
|
||||
if (typeof enhancer !== 'undefined') {
|
||||
if (typeof enhancer !== 'function') {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(1) : "Expected the enhancer to be a function. Instead, received: '" + kindOf(enhancer) + "'");
|
||||
}
|
||||
|
||||
return enhancer(createStore)(reducer, preloadedState);
|
||||
}
|
||||
|
||||
if (typeof reducer !== 'function') {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(2) : "Expected the root reducer to be a function. Instead, received: '" + kindOf(reducer) + "'");
|
||||
}
|
||||
|
||||
var currentReducer = reducer;
|
||||
var currentState = preloadedState;
|
||||
var currentListeners = [];
|
||||
var nextListeners = currentListeners;
|
||||
var isDispatching = false;
|
||||
/**
|
||||
* This makes a shallow copy of currentListeners so we can use
|
||||
* nextListeners as a temporary list while dispatching.
|
||||
*
|
||||
* This prevents any bugs around consumers calling
|
||||
* subscribe/unsubscribe in the middle of a dispatch.
|
||||
*/
|
||||
|
||||
function ensureCanMutateNextListeners() {
|
||||
if (nextListeners === currentListeners) {
|
||||
nextListeners = currentListeners.slice();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Reads the state tree managed by the store.
|
||||
*
|
||||
* @returns {any} The current state tree of your application.
|
||||
*/
|
||||
|
||||
|
||||
function getState() {
|
||||
if (isDispatching) {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(3) : 'You may not call store.getState() while the reducer is executing. ' + 'The reducer has already received the state as an argument. ' + 'Pass it down from the top reducer instead of reading it from the store.');
|
||||
}
|
||||
|
||||
return currentState;
|
||||
}
|
||||
/**
|
||||
* Adds a change listener. It will be called any time an action is dispatched,
|
||||
* and some part of the state tree may potentially have changed. You may then
|
||||
* call `getState()` to read the current state tree inside the callback.
|
||||
*
|
||||
* You may call `dispatch()` from a change listener, with the following
|
||||
* caveats:
|
||||
*
|
||||
* 1. The subscriptions are snapshotted just before every `dispatch()` call.
|
||||
* If you subscribe or unsubscribe while the listeners are being invoked, this
|
||||
* will not have any effect on the `dispatch()` that is currently in progress.
|
||||
* However, the next `dispatch()` call, whether nested or not, will use a more
|
||||
* recent snapshot of the subscription list.
|
||||
*
|
||||
* 2. The listener should not expect to see all state changes, as the state
|
||||
* might have been updated multiple times during a nested `dispatch()` before
|
||||
* the listener is called. It is, however, guaranteed that all subscribers
|
||||
* registered before the `dispatch()` started will be called with the latest
|
||||
* state by the time it exits.
|
||||
*
|
||||
* @param {Function} listener A callback to be invoked on every dispatch.
|
||||
* @returns {Function} A function to remove this change listener.
|
||||
*/
|
||||
|
||||
|
||||
function subscribe(listener) {
|
||||
if (typeof listener !== 'function') {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(4) : "Expected the listener to be a function. Instead, received: '" + kindOf(listener) + "'");
|
||||
}
|
||||
|
||||
if (isDispatching) {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(5) : 'You may not call store.subscribe() while the reducer is executing. ' + 'If you would like to be notified after the store has been updated, subscribe from a ' + 'component and invoke store.getState() in the callback to access the latest state. ' + 'See https://redux.js.org/api/store#subscribelistener for more details.');
|
||||
}
|
||||
|
||||
var isSubscribed = true;
|
||||
ensureCanMutateNextListeners();
|
||||
nextListeners.push(listener);
|
||||
return function unsubscribe() {
|
||||
if (!isSubscribed) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isDispatching) {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(6) : 'You may not unsubscribe from a store listener while the reducer is executing. ' + 'See https://redux.js.org/api/store#subscribelistener for more details.');
|
||||
}
|
||||
|
||||
isSubscribed = false;
|
||||
ensureCanMutateNextListeners();
|
||||
var index = nextListeners.indexOf(listener);
|
||||
nextListeners.splice(index, 1);
|
||||
currentListeners = null;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Dispatches an action. It is the only way to trigger a state change.
|
||||
*
|
||||
* The `reducer` function, used to create the store, will be called with the
|
||||
* current state tree and the given `action`. Its return value will
|
||||
* be considered the **next** state of the tree, and the change listeners
|
||||
* will be notified.
|
||||
*
|
||||
* The base implementation only supports plain object actions. If you want to
|
||||
* dispatch a Promise, an Observable, a thunk, or something else, you need to
|
||||
* wrap your store creating function into the corresponding middleware. For
|
||||
* example, see the documentation for the `redux-thunk` package. Even the
|
||||
* middleware will eventually dispatch plain object actions using this method.
|
||||
*
|
||||
* @param {Object} action A plain object representing “what changed”. It is
|
||||
* a good idea to keep actions serializable so you can record and replay user
|
||||
* sessions, or use the time travelling `redux-devtools`. An action must have
|
||||
* a `type` property which may not be `undefined`. It is a good idea to use
|
||||
* string constants for action types.
|
||||
*
|
||||
* @returns {Object} For convenience, the same action object you dispatched.
|
||||
*
|
||||
* Note that, if you use a custom middleware, it may wrap `dispatch()` to
|
||||
* return something else (for example, a Promise you can await).
|
||||
*/
|
||||
|
||||
|
||||
function dispatch(action) {
|
||||
if (!isPlainObject(action)) {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(7) : "Actions must be plain objects. Instead, the actual type was: '" + kindOf(action) + "'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.");
|
||||
}
|
||||
|
||||
if (typeof action.type === 'undefined') {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(8) : 'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');
|
||||
}
|
||||
|
||||
if (isDispatching) {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(9) : 'Reducers may not dispatch actions.');
|
||||
}
|
||||
|
||||
try {
|
||||
isDispatching = true;
|
||||
currentState = currentReducer(currentState, action);
|
||||
} finally {
|
||||
isDispatching = false;
|
||||
}
|
||||
|
||||
var listeners = currentListeners = nextListeners;
|
||||
|
||||
for (var i = 0; i < listeners.length; i++) {
|
||||
var listener = listeners[i];
|
||||
listener();
|
||||
}
|
||||
|
||||
return action;
|
||||
}
|
||||
/**
|
||||
* Replaces the reducer currently used by the store to calculate the state.
|
||||
*
|
||||
* You might need this if your app implements code splitting and you want to
|
||||
* load some of the reducers dynamically. You might also need this if you
|
||||
* implement a hot reloading mechanism for Redux.
|
||||
*
|
||||
* @param {Function} nextReducer The reducer for the store to use instead.
|
||||
* @returns {void}
|
||||
*/
|
||||
|
||||
|
||||
function replaceReducer(nextReducer) {
|
||||
if (typeof nextReducer !== 'function') {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(10) : "Expected the nextReducer to be a function. Instead, received: '" + kindOf(nextReducer));
|
||||
}
|
||||
|
||||
currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
|
||||
// Any reducers that existed in both the new and old rootReducer
|
||||
// will receive the previous state. This effectively populates
|
||||
// the new state tree with any relevant data from the old one.
|
||||
|
||||
dispatch({
|
||||
type: ActionTypes.REPLACE
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Interoperability point for observable/reactive libraries.
|
||||
* @returns {observable} A minimal observable of state changes.
|
||||
* For more information, see the observable proposal:
|
||||
* https://github.com/tc39/proposal-observable
|
||||
*/
|
||||
|
||||
|
||||
function observable() {
|
||||
var _ref;
|
||||
|
||||
var outerSubscribe = subscribe;
|
||||
return _ref = {
|
||||
/**
|
||||
* The minimal observable subscription method.
|
||||
* @param {Object} observer Any object that can be used as an observer.
|
||||
* The observer object should have a `next` method.
|
||||
* @returns {subscription} An object with an `unsubscribe` method that can
|
||||
* be used to unsubscribe the observable from the store, and prevent further
|
||||
* emission of values from the observable.
|
||||
*/
|
||||
subscribe: function subscribe(observer) {
|
||||
if (typeof observer !== 'object' || observer === null) {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(11) : "Expected the observer to be an object. Instead, received: '" + kindOf(observer) + "'");
|
||||
}
|
||||
|
||||
function observeState() {
|
||||
if (observer.next) {
|
||||
observer.next(getState());
|
||||
}
|
||||
}
|
||||
|
||||
observeState();
|
||||
var unsubscribe = outerSubscribe(observeState);
|
||||
return {
|
||||
unsubscribe: unsubscribe
|
||||
};
|
||||
}
|
||||
}, _ref[$$observable] = function () {
|
||||
return this;
|
||||
}, _ref;
|
||||
} // When a store is created, an "INIT" action is dispatched so that every
|
||||
// reducer returns their initial state. This effectively populates
|
||||
// the initial state tree.
|
||||
|
||||
|
||||
dispatch({
|
||||
type: ActionTypes.INIT
|
||||
});
|
||||
return _ref2 = {
|
||||
dispatch: dispatch,
|
||||
subscribe: subscribe,
|
||||
getState: getState,
|
||||
replaceReducer: replaceReducer
|
||||
}, _ref2[$$observable] = observable, _ref2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a warning in the console if it exists.
|
||||
*
|
||||
* @param {String} message The warning message.
|
||||
* @returns {void}
|
||||
*/
|
||||
function warning(message) {
|
||||
/* eslint-disable no-console */
|
||||
if (typeof console !== 'undefined' && typeof console.error === 'function') {
|
||||
console.error(message);
|
||||
}
|
||||
/* eslint-enable no-console */
|
||||
|
||||
|
||||
try {
|
||||
// This error was thrown as a convenience so that if you enable
|
||||
// "break on all exceptions" in your console,
|
||||
// it would pause the execution at this line.
|
||||
throw new Error(message);
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
|
||||
}
|
||||
|
||||
function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
|
||||
var reducerKeys = Object.keys(reducers);
|
||||
var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
|
||||
|
||||
if (reducerKeys.length === 0) {
|
||||
return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
|
||||
}
|
||||
|
||||
if (!isPlainObject(inputState)) {
|
||||
return "The " + argumentName + " has unexpected type of \"" + kindOf(inputState) + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\"");
|
||||
}
|
||||
|
||||
var unexpectedKeys = Object.keys(inputState).filter(function (key) {
|
||||
return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
|
||||
});
|
||||
unexpectedKeys.forEach(function (key) {
|
||||
unexpectedKeyCache[key] = true;
|
||||
});
|
||||
if (action && action.type === ActionTypes.REPLACE) return;
|
||||
|
||||
if (unexpectedKeys.length > 0) {
|
||||
return "Unexpected " + (unexpectedKeys.length > 1 ? 'keys' : 'key') + " " + ("\"" + unexpectedKeys.join('", "') + "\" found in " + argumentName + ". ") + "Expected to find one of the known reducer keys instead: " + ("\"" + reducerKeys.join('", "') + "\". Unexpected keys will be ignored.");
|
||||
}
|
||||
}
|
||||
|
||||
function assertReducerShape(reducers) {
|
||||
Object.keys(reducers).forEach(function (key) {
|
||||
var reducer = reducers[key];
|
||||
var initialState = reducer(undefined, {
|
||||
type: ActionTypes.INIT
|
||||
});
|
||||
|
||||
if (typeof initialState === 'undefined') {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(12) : "The slice reducer for key \"" + key + "\" returned undefined during initialization. " + "If the state passed to the reducer is undefined, you must " + "explicitly return the initial state. The initial state may " + "not be undefined. If you don't want to set a value for this reducer, " + "you can use null instead of undefined.");
|
||||
}
|
||||
|
||||
if (typeof reducer(undefined, {
|
||||
type: ActionTypes.PROBE_UNKNOWN_ACTION()
|
||||
}) === 'undefined') {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(13) : "The slice reducer for key \"" + key + "\" returned undefined when probed with a random type. " + ("Don't try to handle '" + ActionTypes.INIT + "' or other actions in \"redux/*\" ") + "namespace. They are considered private. Instead, you must return the " + "current state for any unknown actions, unless it is undefined, " + "in which case you must return the initial state, regardless of the " + "action type. The initial state may not be undefined, but can be null.");
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Turns an object whose values are different reducer functions, into a single
|
||||
* reducer function. It will call every child reducer, and gather their results
|
||||
* into a single state object, whose keys correspond to the keys of the passed
|
||||
* reducer functions.
|
||||
*
|
||||
* @param {Object} reducers An object whose values correspond to different
|
||||
* reducer functions that need to be combined into one. One handy way to obtain
|
||||
* it is to use ES6 `import * as reducers` syntax. The reducers may never return
|
||||
* undefined for any action. Instead, they should return their initial state
|
||||
* if the state passed to them was undefined, and the current state for any
|
||||
* unrecognized action.
|
||||
*
|
||||
* @returns {Function} A reducer function that invokes every reducer inside the
|
||||
* passed object, and builds a state object with the same shape.
|
||||
*/
|
||||
|
||||
|
||||
function combineReducers(reducers) {
|
||||
var reducerKeys = Object.keys(reducers);
|
||||
var finalReducers = {};
|
||||
|
||||
for (var i = 0; i < reducerKeys.length; i++) {
|
||||
var key = reducerKeys[i];
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (typeof reducers[key] === 'undefined') {
|
||||
warning("No reducer provided for key \"" + key + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof reducers[key] === 'function') {
|
||||
finalReducers[key] = reducers[key];
|
||||
}
|
||||
}
|
||||
|
||||
var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
|
||||
// keys multiple times.
|
||||
|
||||
var unexpectedKeyCache;
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
unexpectedKeyCache = {};
|
||||
}
|
||||
|
||||
var shapeAssertionError;
|
||||
|
||||
try {
|
||||
assertReducerShape(finalReducers);
|
||||
} catch (e) {
|
||||
shapeAssertionError = e;
|
||||
}
|
||||
|
||||
return function combination(state, action) {
|
||||
if (state === void 0) {
|
||||
state = {};
|
||||
}
|
||||
|
||||
if (shapeAssertionError) {
|
||||
throw shapeAssertionError;
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
|
||||
|
||||
if (warningMessage) {
|
||||
warning(warningMessage);
|
||||
}
|
||||
}
|
||||
|
||||
var hasChanged = false;
|
||||
var nextState = {};
|
||||
|
||||
for (var _i = 0; _i < finalReducerKeys.length; _i++) {
|
||||
var _key = finalReducerKeys[_i];
|
||||
var reducer = finalReducers[_key];
|
||||
var previousStateForKey = state[_key];
|
||||
var nextStateForKey = reducer(previousStateForKey, action);
|
||||
|
||||
if (typeof nextStateForKey === 'undefined') {
|
||||
var actionType = action && action.type;
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(14) : "When called with an action of type " + (actionType ? "\"" + String(actionType) + "\"" : '(unknown type)') + ", the slice reducer for key \"" + _key + "\" returned undefined. " + "To ignore an action, you must explicitly return the previous state. " + "If you want this reducer to hold no value, you can return null instead of undefined.");
|
||||
}
|
||||
|
||||
nextState[_key] = nextStateForKey;
|
||||
hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
|
||||
}
|
||||
|
||||
hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
|
||||
return hasChanged ? nextState : state;
|
||||
};
|
||||
}
|
||||
|
||||
function bindActionCreator(actionCreator, dispatch) {
|
||||
return function () {
|
||||
return dispatch(actionCreator.apply(this, arguments));
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Turns an object whose values are action creators, into an object with the
|
||||
* same keys, but with every function wrapped into a `dispatch` call so they
|
||||
* may be invoked directly. This is just a convenience method, as you can call
|
||||
* `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
|
||||
*
|
||||
* For convenience, you can also pass an action creator as the first argument,
|
||||
* and get a dispatch wrapped function in return.
|
||||
*
|
||||
* @param {Function|Object} actionCreators An object whose values are action
|
||||
* creator functions. One handy way to obtain it is to use ES6 `import * as`
|
||||
* syntax. You may also pass a single function.
|
||||
*
|
||||
* @param {Function} dispatch The `dispatch` function available on your Redux
|
||||
* store.
|
||||
*
|
||||
* @returns {Function|Object} The object mimicking the original object, but with
|
||||
* every action creator wrapped into the `dispatch` call. If you passed a
|
||||
* function as `actionCreators`, the return value will also be a single
|
||||
* function.
|
||||
*/
|
||||
|
||||
|
||||
function bindActionCreators(actionCreators, dispatch) {
|
||||
if (typeof actionCreators === 'function') {
|
||||
return bindActionCreator(actionCreators, dispatch);
|
||||
}
|
||||
|
||||
if (typeof actionCreators !== 'object' || actionCreators === null) {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(16) : "bindActionCreators expected an object or a function, but instead received: '" + kindOf(actionCreators) + "'. " + "Did you write \"import ActionCreators from\" instead of \"import * as ActionCreators from\"?");
|
||||
}
|
||||
|
||||
var boundActionCreators = {};
|
||||
|
||||
for (var key in actionCreators) {
|
||||
var actionCreator = actionCreators[key];
|
||||
|
||||
if (typeof actionCreator === 'function') {
|
||||
boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
|
||||
}
|
||||
}
|
||||
|
||||
return boundActionCreators;
|
||||
}
|
||||
|
||||
/**
|
||||
* Composes single-argument functions from right to left. The rightmost
|
||||
* function can take multiple arguments as it provides the signature for
|
||||
* the resulting composite function.
|
||||
*
|
||||
* @param {...Function} funcs The functions to compose.
|
||||
* @returns {Function} A function obtained by composing the argument functions
|
||||
* from right to left. For example, compose(f, g, h) is identical to doing
|
||||
* (...args) => f(g(h(...args))).
|
||||
*/
|
||||
function compose() {
|
||||
for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
funcs[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
if (funcs.length === 0) {
|
||||
return function (arg) {
|
||||
return arg;
|
||||
};
|
||||
}
|
||||
|
||||
if (funcs.length === 1) {
|
||||
return funcs[0];
|
||||
}
|
||||
|
||||
return funcs.reduce(function (a, b) {
|
||||
return function () {
|
||||
return a(b.apply(void 0, arguments));
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a store enhancer that applies middleware to the dispatch method
|
||||
* of the Redux store. This is handy for a variety of tasks, such as expressing
|
||||
* asynchronous actions in a concise manner, or logging every action payload.
|
||||
*
|
||||
* See `redux-thunk` package as an example of the Redux middleware.
|
||||
*
|
||||
* Because middleware is potentially asynchronous, this should be the first
|
||||
* store enhancer in the composition chain.
|
||||
*
|
||||
* Note that each middleware will be given the `dispatch` and `getState` functions
|
||||
* as named arguments.
|
||||
*
|
||||
* @param {...Function} middlewares The middleware chain to be applied.
|
||||
* @returns {Function} A store enhancer applying the middleware.
|
||||
*/
|
||||
|
||||
function applyMiddleware() {
|
||||
for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
middlewares[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return function (createStore) {
|
||||
return function () {
|
||||
var store = createStore.apply(void 0, arguments);
|
||||
|
||||
var _dispatch = function dispatch() {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(15) : 'Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.');
|
||||
};
|
||||
|
||||
var middlewareAPI = {
|
||||
getState: store.getState,
|
||||
dispatch: function dispatch() {
|
||||
return _dispatch.apply(void 0, arguments);
|
||||
}
|
||||
};
|
||||
var chain = middlewares.map(function (middleware) {
|
||||
return middleware(middlewareAPI);
|
||||
});
|
||||
_dispatch = compose.apply(void 0, chain)(store.dispatch);
|
||||
return _objectSpread__default['default'](_objectSpread__default['default']({}, store), {}, {
|
||||
dispatch: _dispatch
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
* This is a dummy function to check if the function name has been altered by minification.
|
||||
* If the function has been minified and NODE_ENV !== 'production', warn the user.
|
||||
*/
|
||||
|
||||
function isCrushed() {}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && typeof isCrushed.name === 'string' && isCrushed.name !== 'isCrushed') {
|
||||
warning('You are currently using minified code outside of NODE_ENV === "production". ' + 'This means that you are running a slower development build of Redux. ' + 'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + 'or setting mode to production in webpack (https://webpack.js.org/concepts/mode/) ' + 'to ensure you have the correct code for your production build.');
|
||||
}
|
||||
|
||||
exports.__DO_NOT_USE__ActionTypes = ActionTypes;
|
||||
exports.applyMiddleware = applyMiddleware;
|
||||
exports.bindActionCreators = bindActionCreators;
|
||||
exports.combineReducers = combineReducers;
|
||||
exports.compose = compose;
|
||||
exports.createStore = createStore;
|
108
web/node_modules/redux/package.json
generated
vendored
Normal file
108
web/node_modules/redux/package.json
generated
vendored
Normal file
|
@ -0,0 +1,108 @@
|
|||
{
|
||||
"name": "redux",
|
||||
"version": "4.1.1",
|
||||
"description": "Predictable state container for JavaScript apps",
|
||||
"license": "MIT",
|
||||
"homepage": "http://redux.js.org",
|
||||
"repository": "github:reduxjs/redux",
|
||||
"bugs": "https://github.com/reduxjs/redux/issues",
|
||||
"keywords": [
|
||||
"redux",
|
||||
"reducer",
|
||||
"state",
|
||||
"predictable",
|
||||
"functional",
|
||||
"immutable",
|
||||
"hot",
|
||||
"live",
|
||||
"replay",
|
||||
"flux",
|
||||
"elm"
|
||||
],
|
||||
"authors": [
|
||||
"Dan Abramov <dan.abramov@me.com> (https://github.com/gaearon)",
|
||||
"Andrew Clark <acdlite@me.com> (https://github.com/acdlite)"
|
||||
],
|
||||
"main": "lib/redux.js",
|
||||
"unpkg": "dist/redux.js",
|
||||
"module": "es/redux.js",
|
||||
"typings": "./index.d.ts",
|
||||
"files": [
|
||||
"dist",
|
||||
"lib",
|
||||
"es",
|
||||
"src",
|
||||
"index.d.ts"
|
||||
],
|
||||
"scripts": {
|
||||
"clean": "rimraf lib dist es coverage",
|
||||
"format": "prettier --write \"{src,test}/**/*.{js,ts}\" index.d.ts \"**/*.md\"",
|
||||
"format:check": "prettier --list-different \"{src,test}/**/*.{js,ts}\" index.d.ts \"**/*.md\"",
|
||||
"lint": "eslint src test",
|
||||
"test": "jest",
|
||||
"test:watch": "npm test -- --watch",
|
||||
"test:cov": "npm test -- --coverage",
|
||||
"build": "rollup -c",
|
||||
"pretest": "npm run build",
|
||||
"prepublishOnly": "npm run clean && npm run format:check && npm run lint && npm test",
|
||||
"examples:lint": "eslint examples",
|
||||
"examples:test": "cross-env CI=true babel-node examples/testAll.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.9.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.8.4",
|
||||
"@babel/core": "^7.9.0",
|
||||
"@babel/node": "^7.8.7",
|
||||
"@babel/plugin-external-helpers": "^7.8.3",
|
||||
"@babel/plugin-proposal-object-rest-spread": "^7.9.5",
|
||||
"@babel/plugin-transform-runtime": "^7.9.0",
|
||||
"@babel/preset-env": "^7.9.5",
|
||||
"@babel/preset-flow": "^7.9.0",
|
||||
"@babel/preset-typescript": "^7.9.0",
|
||||
"@babel/register": "^7.9.0",
|
||||
"@rollup/plugin-babel": "^5.3.0",
|
||||
"@rollup/plugin-node-resolve": "^7.1.3",
|
||||
"@rollup/plugin-replace": "^2.3.2",
|
||||
"@types/jest": "^25.2.1",
|
||||
"@types/node": "^13.13.4",
|
||||
"@typescript-eslint/eslint-plugin": "^2.29.0",
|
||||
"@typescript-eslint/parser": "^2.29.0",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"babel-jest": "^25.4.0",
|
||||
"cross-env": "^7.0.2",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-config-react-app": "^5.2.1",
|
||||
"eslint-import-resolver-typescript": "^2.0.0",
|
||||
"eslint-plugin-flowtype": "^4.7.0",
|
||||
"eslint-plugin-import": "^2.20.2",
|
||||
"eslint-plugin-jsx-a11y": "^6.2.3",
|
||||
"eslint-plugin-react": "^7.19.0",
|
||||
"eslint-plugin-react-hooks": "^3.0.0",
|
||||
"glob": "^7.1.6",
|
||||
"jest": "^25.4.0",
|
||||
"prettier": "^2.0.5",
|
||||
"rimraf": "^3.0.2",
|
||||
"rollup": "^2.7.2",
|
||||
"rollup-plugin-terser": "^5.3.0",
|
||||
"rollup-plugin-typescript2": "^0.27.0",
|
||||
"rxjs": "^6.5.5",
|
||||
"typescript": "^3.8.3",
|
||||
"typings-tester": "^0.3.2"
|
||||
},
|
||||
"npmName": "redux",
|
||||
"npmFileMap": [
|
||||
{
|
||||
"basePath": "/dist/",
|
||||
"files": [
|
||||
"*.js"
|
||||
]
|
||||
}
|
||||
],
|
||||
"jest": {
|
||||
"testRegex": "(/test/.*\\.spec\\.[tj]s)$",
|
||||
"coverageProvider": "v8"
|
||||
},
|
||||
"sideEffects": false
|
||||
}
|
41
web/node_modules/redux/src/applyMiddleware.js
generated
vendored
Normal file
41
web/node_modules/redux/src/applyMiddleware.js
generated
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
import compose from './compose'
|
||||
|
||||
/**
|
||||
* Creates a store enhancer that applies middleware to the dispatch method
|
||||
* of the Redux store. This is handy for a variety of tasks, such as expressing
|
||||
* asynchronous actions in a concise manner, or logging every action payload.
|
||||
*
|
||||
* See `redux-thunk` package as an example of the Redux middleware.
|
||||
*
|
||||
* Because middleware is potentially asynchronous, this should be the first
|
||||
* store enhancer in the composition chain.
|
||||
*
|
||||
* Note that each middleware will be given the `dispatch` and `getState` functions
|
||||
* as named arguments.
|
||||
*
|
||||
* @param {...Function} middlewares The middleware chain to be applied.
|
||||
* @returns {Function} A store enhancer applying the middleware.
|
||||
*/
|
||||
export default function applyMiddleware(...middlewares) {
|
||||
return (createStore) => (...args) => {
|
||||
const store = createStore(...args)
|
||||
let dispatch = () => {
|
||||
throw new Error(
|
||||
'Dispatching while constructing your middleware is not allowed. ' +
|
||||
'Other middleware would not be applied to this dispatch.'
|
||||
)
|
||||
}
|
||||
|
||||
const middlewareAPI = {
|
||||
getState: store.getState,
|
||||
dispatch: (...args) => dispatch(...args),
|
||||
}
|
||||
const chain = middlewares.map((middleware) => middleware(middlewareAPI))
|
||||
dispatch = compose(...chain)(store.dispatch)
|
||||
|
||||
return {
|
||||
...store,
|
||||
dispatch,
|
||||
}
|
||||
}
|
||||
}
|
52
web/node_modules/redux/src/bindActionCreators.js
generated
vendored
Normal file
52
web/node_modules/redux/src/bindActionCreators.js
generated
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
import { kindOf } from './utils/kindOf'
|
||||
|
||||
function bindActionCreator(actionCreator, dispatch) {
|
||||
return function () {
|
||||
return dispatch(actionCreator.apply(this, arguments))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns an object whose values are action creators, into an object with the
|
||||
* same keys, but with every function wrapped into a `dispatch` call so they
|
||||
* may be invoked directly. This is just a convenience method, as you can call
|
||||
* `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
|
||||
*
|
||||
* For convenience, you can also pass an action creator as the first argument,
|
||||
* and get a dispatch wrapped function in return.
|
||||
*
|
||||
* @param {Function|Object} actionCreators An object whose values are action
|
||||
* creator functions. One handy way to obtain it is to use ES6 `import * as`
|
||||
* syntax. You may also pass a single function.
|
||||
*
|
||||
* @param {Function} dispatch The `dispatch` function available on your Redux
|
||||
* store.
|
||||
*
|
||||
* @returns {Function|Object} The object mimicking the original object, but with
|
||||
* every action creator wrapped into the `dispatch` call. If you passed a
|
||||
* function as `actionCreators`, the return value will also be a single
|
||||
* function.
|
||||
*/
|
||||
export default function bindActionCreators(actionCreators, dispatch) {
|
||||
if (typeof actionCreators === 'function') {
|
||||
return bindActionCreator(actionCreators, dispatch)
|
||||
}
|
||||
|
||||
if (typeof actionCreators !== 'object' || actionCreators === null) {
|
||||
throw new Error(
|
||||
`bindActionCreators expected an object or a function, but instead received: '${kindOf(
|
||||
actionCreators
|
||||
)}'. ` +
|
||||
`Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?`
|
||||
)
|
||||
}
|
||||
|
||||
const boundActionCreators = {}
|
||||
for (const key in actionCreators) {
|
||||
const actionCreator = actionCreators[key]
|
||||
if (typeof actionCreator === 'function') {
|
||||
boundActionCreators[key] = bindActionCreator(actionCreator, dispatch)
|
||||
}
|
||||
}
|
||||
return boundActionCreators
|
||||
}
|
175
web/node_modules/redux/src/combineReducers.js
generated
vendored
Normal file
175
web/node_modules/redux/src/combineReducers.js
generated
vendored
Normal file
|
@ -0,0 +1,175 @@
|
|||
import ActionTypes from './utils/actionTypes'
|
||||
import warning from './utils/warning'
|
||||
import isPlainObject from './utils/isPlainObject'
|
||||
import { kindOf } from './utils/kindOf'
|
||||
|
||||
function getUnexpectedStateShapeWarningMessage(
|
||||
inputState,
|
||||
reducers,
|
||||
action,
|
||||
unexpectedKeyCache
|
||||
) {
|
||||
const reducerKeys = Object.keys(reducers)
|
||||
const argumentName =
|
||||
action && action.type === ActionTypes.INIT
|
||||
? 'preloadedState argument passed to createStore'
|
||||
: 'previous state received by the reducer'
|
||||
|
||||
if (reducerKeys.length === 0) {
|
||||
return (
|
||||
'Store does not have a valid reducer. Make sure the argument passed ' +
|
||||
'to combineReducers is an object whose values are reducers.'
|
||||
)
|
||||
}
|
||||
|
||||
if (!isPlainObject(inputState)) {
|
||||
return (
|
||||
`The ${argumentName} has unexpected type of "${kindOf(
|
||||
inputState
|
||||
)}". Expected argument to be an object with the following ` +
|
||||
`keys: "${reducerKeys.join('", "')}"`
|
||||
)
|
||||
}
|
||||
|
||||
const unexpectedKeys = Object.keys(inputState).filter(
|
||||
(key) => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]
|
||||
)
|
||||
|
||||
unexpectedKeys.forEach((key) => {
|
||||
unexpectedKeyCache[key] = true
|
||||
})
|
||||
|
||||
if (action && action.type === ActionTypes.REPLACE) return
|
||||
|
||||
if (unexpectedKeys.length > 0) {
|
||||
return (
|
||||
`Unexpected ${unexpectedKeys.length > 1 ? 'keys' : 'key'} ` +
|
||||
`"${unexpectedKeys.join('", "')}" found in ${argumentName}. ` +
|
||||
`Expected to find one of the known reducer keys instead: ` +
|
||||
`"${reducerKeys.join('", "')}". Unexpected keys will be ignored.`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function assertReducerShape(reducers) {
|
||||
Object.keys(reducers).forEach((key) => {
|
||||
const reducer = reducers[key]
|
||||
const initialState = reducer(undefined, { type: ActionTypes.INIT })
|
||||
|
||||
if (typeof initialState === 'undefined') {
|
||||
throw new Error(
|
||||
`The slice reducer for key "${key}" returned undefined during initialization. ` +
|
||||
`If the state passed to the reducer is undefined, you must ` +
|
||||
`explicitly return the initial state. The initial state may ` +
|
||||
`not be undefined. If you don't want to set a value for this reducer, ` +
|
||||
`you can use null instead of undefined.`
|
||||
)
|
||||
}
|
||||
|
||||
if (
|
||||
typeof reducer(undefined, {
|
||||
type: ActionTypes.PROBE_UNKNOWN_ACTION(),
|
||||
}) === 'undefined'
|
||||
) {
|
||||
throw new Error(
|
||||
`The slice reducer for key "${key}" returned undefined when probed with a random type. ` +
|
||||
`Don't try to handle '${ActionTypes.INIT}' or other actions in "redux/*" ` +
|
||||
`namespace. They are considered private. Instead, you must return the ` +
|
||||
`current state for any unknown actions, unless it is undefined, ` +
|
||||
`in which case you must return the initial state, regardless of the ` +
|
||||
`action type. The initial state may not be undefined, but can be null.`
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns an object whose values are different reducer functions, into a single
|
||||
* reducer function. It will call every child reducer, and gather their results
|
||||
* into a single state object, whose keys correspond to the keys of the passed
|
||||
* reducer functions.
|
||||
*
|
||||
* @param {Object} reducers An object whose values correspond to different
|
||||
* reducer functions that need to be combined into one. One handy way to obtain
|
||||
* it is to use ES6 `import * as reducers` syntax. The reducers may never return
|
||||
* undefined for any action. Instead, they should return their initial state
|
||||
* if the state passed to them was undefined, and the current state for any
|
||||
* unrecognized action.
|
||||
*
|
||||
* @returns {Function} A reducer function that invokes every reducer inside the
|
||||
* passed object, and builds a state object with the same shape.
|
||||
*/
|
||||
export default function combineReducers(reducers) {
|
||||
const reducerKeys = Object.keys(reducers)
|
||||
const finalReducers = {}
|
||||
for (let i = 0; i < reducerKeys.length; i++) {
|
||||
const key = reducerKeys[i]
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (typeof reducers[key] === 'undefined') {
|
||||
warning(`No reducer provided for key "${key}"`)
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof reducers[key] === 'function') {
|
||||
finalReducers[key] = reducers[key]
|
||||
}
|
||||
}
|
||||
const finalReducerKeys = Object.keys(finalReducers)
|
||||
|
||||
// This is used to make sure we don't warn about the same
|
||||
// keys multiple times.
|
||||
let unexpectedKeyCache
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
unexpectedKeyCache = {}
|
||||
}
|
||||
|
||||
let shapeAssertionError
|
||||
try {
|
||||
assertReducerShape(finalReducers)
|
||||
} catch (e) {
|
||||
shapeAssertionError = e
|
||||
}
|
||||
|
||||
return function combination(state = {}, action) {
|
||||
if (shapeAssertionError) {
|
||||
throw shapeAssertionError
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
const warningMessage = getUnexpectedStateShapeWarningMessage(
|
||||
state,
|
||||
finalReducers,
|
||||
action,
|
||||
unexpectedKeyCache
|
||||
)
|
||||
if (warningMessage) {
|
||||
warning(warningMessage)
|
||||
}
|
||||
}
|
||||
|
||||
let hasChanged = false
|
||||
const nextState = {}
|
||||
for (let i = 0; i < finalReducerKeys.length; i++) {
|
||||
const key = finalReducerKeys[i]
|
||||
const reducer = finalReducers[key]
|
||||
const previousStateForKey = state[key]
|
||||
const nextStateForKey = reducer(previousStateForKey, action)
|
||||
if (typeof nextStateForKey === 'undefined') {
|
||||
const actionType = action && action.type
|
||||
throw new Error(
|
||||
`When called with an action of type ${
|
||||
actionType ? `"${String(actionType)}"` : '(unknown type)'
|
||||
}, the slice reducer for key "${key}" returned undefined. ` +
|
||||
`To ignore an action, you must explicitly return the previous state. ` +
|
||||
`If you want this reducer to hold no value, you can return null instead of undefined.`
|
||||
)
|
||||
}
|
||||
nextState[key] = nextStateForKey
|
||||
hasChanged = hasChanged || nextStateForKey !== previousStateForKey
|
||||
}
|
||||
hasChanged =
|
||||
hasChanged || finalReducerKeys.length !== Object.keys(state).length
|
||||
return hasChanged ? nextState : state
|
||||
}
|
||||
}
|
22
web/node_modules/redux/src/compose.js
generated
vendored
Normal file
22
web/node_modules/redux/src/compose.js
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* Composes single-argument functions from right to left. The rightmost
|
||||
* function can take multiple arguments as it provides the signature for
|
||||
* the resulting composite function.
|
||||
*
|
||||
* @param {...Function} funcs The functions to compose.
|
||||
* @returns {Function} A function obtained by composing the argument functions
|
||||
* from right to left. For example, compose(f, g, h) is identical to doing
|
||||
* (...args) => f(g(h(...args))).
|
||||
*/
|
||||
|
||||
export default function compose(...funcs) {
|
||||
if (funcs.length === 0) {
|
||||
return (arg) => arg
|
||||
}
|
||||
|
||||
if (funcs.length === 1) {
|
||||
return funcs[0]
|
||||
}
|
||||
|
||||
return funcs.reduce((a, b) => (...args) => a(b(...args)))
|
||||
}
|
315
web/node_modules/redux/src/createStore.js
generated
vendored
Normal file
315
web/node_modules/redux/src/createStore.js
generated
vendored
Normal file
|
@ -0,0 +1,315 @@
|
|||
import $$observable from './utils/symbol-observable'
|
||||
|
||||
import ActionTypes from './utils/actionTypes'
|
||||
import isPlainObject from './utils/isPlainObject'
|
||||
import { kindOf } from './utils/kindOf'
|
||||
|
||||
/**
|
||||
* Creates a Redux store that holds the state tree.
|
||||
* The only way to change the data in the store is to call `dispatch()` on it.
|
||||
*
|
||||
* There should only be a single store in your app. To specify how different
|
||||
* parts of the state tree respond to actions, you may combine several reducers
|
||||
* into a single reducer function by using `combineReducers`.
|
||||
*
|
||||
* @param {Function} reducer A function that returns the next state tree, given
|
||||
* the current state tree and the action to handle.
|
||||
*
|
||||
* @param {any} [preloadedState] The initial state. You may optionally specify it
|
||||
* to hydrate the state from the server in universal apps, or to restore a
|
||||
* previously serialized user session.
|
||||
* If you use `combineReducers` to produce the root reducer function, this must be
|
||||
* an object with the same shape as `combineReducers` keys.
|
||||
*
|
||||
* @param {Function} [enhancer] The store enhancer. You may optionally specify it
|
||||
* to enhance the store with third-party capabilities such as middleware,
|
||||
* time travel, persistence, etc. The only store enhancer that ships with Redux
|
||||
* is `applyMiddleware()`.
|
||||
*
|
||||
* @returns {Store} A Redux store that lets you read the state, dispatch actions
|
||||
* and subscribe to changes.
|
||||
*/
|
||||
export default function createStore(reducer, preloadedState, enhancer) {
|
||||
if (
|
||||
(typeof preloadedState === 'function' && typeof enhancer === 'function') ||
|
||||
(typeof enhancer === 'function' && typeof arguments[3] === 'function')
|
||||
) {
|
||||
throw new Error(
|
||||
'It looks like you are passing several store enhancers to ' +
|
||||
'createStore(). This is not supported. Instead, compose them ' +
|
||||
'together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.'
|
||||
)
|
||||
}
|
||||
|
||||
if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
|
||||
enhancer = preloadedState
|
||||
preloadedState = undefined
|
||||
}
|
||||
|
||||
if (typeof enhancer !== 'undefined') {
|
||||
if (typeof enhancer !== 'function') {
|
||||
throw new Error(
|
||||
`Expected the enhancer to be a function. Instead, received: '${kindOf(
|
||||
enhancer
|
||||
)}'`
|
||||
)
|
||||
}
|
||||
|
||||
return enhancer(createStore)(reducer, preloadedState)
|
||||
}
|
||||
|
||||
if (typeof reducer !== 'function') {
|
||||
throw new Error(
|
||||
`Expected the root reducer to be a function. Instead, received: '${kindOf(
|
||||
reducer
|
||||
)}'`
|
||||
)
|
||||
}
|
||||
|
||||
let currentReducer = reducer
|
||||
let currentState = preloadedState
|
||||
let currentListeners = []
|
||||
let nextListeners = currentListeners
|
||||
let isDispatching = false
|
||||
|
||||
/**
|
||||
* This makes a shallow copy of currentListeners so we can use
|
||||
* nextListeners as a temporary list while dispatching.
|
||||
*
|
||||
* This prevents any bugs around consumers calling
|
||||
* subscribe/unsubscribe in the middle of a dispatch.
|
||||
*/
|
||||
function ensureCanMutateNextListeners() {
|
||||
if (nextListeners === currentListeners) {
|
||||
nextListeners = currentListeners.slice()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the state tree managed by the store.
|
||||
*
|
||||
* @returns {any} The current state tree of your application.
|
||||
*/
|
||||
function getState() {
|
||||
if (isDispatching) {
|
||||
throw new Error(
|
||||
'You may not call store.getState() while the reducer is executing. ' +
|
||||
'The reducer has already received the state as an argument. ' +
|
||||
'Pass it down from the top reducer instead of reading it from the store.'
|
||||
)
|
||||
}
|
||||
|
||||
return currentState
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a change listener. It will be called any time an action is dispatched,
|
||||
* and some part of the state tree may potentially have changed. You may then
|
||||
* call `getState()` to read the current state tree inside the callback.
|
||||
*
|
||||
* You may call `dispatch()` from a change listener, with the following
|
||||
* caveats:
|
||||
*
|
||||
* 1. The subscriptions are snapshotted just before every `dispatch()` call.
|
||||
* If you subscribe or unsubscribe while the listeners are being invoked, this
|
||||
* will not have any effect on the `dispatch()` that is currently in progress.
|
||||
* However, the next `dispatch()` call, whether nested or not, will use a more
|
||||
* recent snapshot of the subscription list.
|
||||
*
|
||||
* 2. The listener should not expect to see all state changes, as the state
|
||||
* might have been updated multiple times during a nested `dispatch()` before
|
||||
* the listener is called. It is, however, guaranteed that all subscribers
|
||||
* registered before the `dispatch()` started will be called with the latest
|
||||
* state by the time it exits.
|
||||
*
|
||||
* @param {Function} listener A callback to be invoked on every dispatch.
|
||||
* @returns {Function} A function to remove this change listener.
|
||||
*/
|
||||
function subscribe(listener) {
|
||||
if (typeof listener !== 'function') {
|
||||
throw new Error(
|
||||
`Expected the listener to be a function. Instead, received: '${kindOf(
|
||||
listener
|
||||
)}'`
|
||||
)
|
||||
}
|
||||
|
||||
if (isDispatching) {
|
||||
throw new Error(
|
||||
'You may not call store.subscribe() while the reducer is executing. ' +
|
||||
'If you would like to be notified after the store has been updated, subscribe from a ' +
|
||||
'component and invoke store.getState() in the callback to access the latest state. ' +
|
||||
'See https://redux.js.org/api/store#subscribelistener for more details.'
|
||||
)
|
||||
}
|
||||
|
||||
let isSubscribed = true
|
||||
|
||||
ensureCanMutateNextListeners()
|
||||
nextListeners.push(listener)
|
||||
|
||||
return function unsubscribe() {
|
||||
if (!isSubscribed) {
|
||||
return
|
||||
}
|
||||
|
||||
if (isDispatching) {
|
||||
throw new Error(
|
||||
'You may not unsubscribe from a store listener while the reducer is executing. ' +
|
||||
'See https://redux.js.org/api/store#subscribelistener for more details.'
|
||||
)
|
||||
}
|
||||
|
||||
isSubscribed = false
|
||||
|
||||
ensureCanMutateNextListeners()
|
||||
const index = nextListeners.indexOf(listener)
|
||||
nextListeners.splice(index, 1)
|
||||
currentListeners = null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches an action. It is the only way to trigger a state change.
|
||||
*
|
||||
* The `reducer` function, used to create the store, will be called with the
|
||||
* current state tree and the given `action`. Its return value will
|
||||
* be considered the **next** state of the tree, and the change listeners
|
||||
* will be notified.
|
||||
*
|
||||
* The base implementation only supports plain object actions. If you want to
|
||||
* dispatch a Promise, an Observable, a thunk, or something else, you need to
|
||||
* wrap your store creating function into the corresponding middleware. For
|
||||
* example, see the documentation for the `redux-thunk` package. Even the
|
||||
* middleware will eventually dispatch plain object actions using this method.
|
||||
*
|
||||
* @param {Object} action A plain object representing “what changed”. It is
|
||||
* a good idea to keep actions serializable so you can record and replay user
|
||||
* sessions, or use the time travelling `redux-devtools`. An action must have
|
||||
* a `type` property which may not be `undefined`. It is a good idea to use
|
||||
* string constants for action types.
|
||||
*
|
||||
* @returns {Object} For convenience, the same action object you dispatched.
|
||||
*
|
||||
* Note that, if you use a custom middleware, it may wrap `dispatch()` to
|
||||
* return something else (for example, a Promise you can await).
|
||||
*/
|
||||
function dispatch(action) {
|
||||
if (!isPlainObject(action)) {
|
||||
throw new Error(
|
||||
`Actions must be plain objects. Instead, the actual type was: '${kindOf(
|
||||
action
|
||||
)}'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.`
|
||||
)
|
||||
}
|
||||
|
||||
if (typeof action.type === 'undefined') {
|
||||
throw new Error(
|
||||
'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.'
|
||||
)
|
||||
}
|
||||
|
||||
if (isDispatching) {
|
||||
throw new Error('Reducers may not dispatch actions.')
|
||||
}
|
||||
|
||||
try {
|
||||
isDispatching = true
|
||||
currentState = currentReducer(currentState, action)
|
||||
} finally {
|
||||
isDispatching = false
|
||||
}
|
||||
|
||||
const listeners = (currentListeners = nextListeners)
|
||||
for (let i = 0; i < listeners.length; i++) {
|
||||
const listener = listeners[i]
|
||||
listener()
|
||||
}
|
||||
|
||||
return action
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the reducer currently used by the store to calculate the state.
|
||||
*
|
||||
* You might need this if your app implements code splitting and you want to
|
||||
* load some of the reducers dynamically. You might also need this if you
|
||||
* implement a hot reloading mechanism for Redux.
|
||||
*
|
||||
* @param {Function} nextReducer The reducer for the store to use instead.
|
||||
* @returns {void}
|
||||
*/
|
||||
function replaceReducer(nextReducer) {
|
||||
if (typeof nextReducer !== 'function') {
|
||||
throw new Error(
|
||||
`Expected the nextReducer to be a function. Instead, received: '${kindOf(
|
||||
nextReducer
|
||||
)}`
|
||||
)
|
||||
}
|
||||
|
||||
currentReducer = nextReducer
|
||||
|
||||
// This action has a similiar effect to ActionTypes.INIT.
|
||||
// Any reducers that existed in both the new and old rootReducer
|
||||
// will receive the previous state. This effectively populates
|
||||
// the new state tree with any relevant data from the old one.
|
||||
dispatch({ type: ActionTypes.REPLACE })
|
||||
}
|
||||
|
||||
/**
|
||||
* Interoperability point for observable/reactive libraries.
|
||||
* @returns {observable} A minimal observable of state changes.
|
||||
* For more information, see the observable proposal:
|
||||
* https://github.com/tc39/proposal-observable
|
||||
*/
|
||||
function observable() {
|
||||
const outerSubscribe = subscribe
|
||||
return {
|
||||
/**
|
||||
* The minimal observable subscription method.
|
||||
* @param {Object} observer Any object that can be used as an observer.
|
||||
* The observer object should have a `next` method.
|
||||
* @returns {subscription} An object with an `unsubscribe` method that can
|
||||
* be used to unsubscribe the observable from the store, and prevent further
|
||||
* emission of values from the observable.
|
||||
*/
|
||||
subscribe(observer) {
|
||||
if (typeof observer !== 'object' || observer === null) {
|
||||
throw new TypeError(
|
||||
`Expected the observer to be an object. Instead, received: '${kindOf(
|
||||
observer
|
||||
)}'`
|
||||
)
|
||||
}
|
||||
|
||||
function observeState() {
|
||||
if (observer.next) {
|
||||
observer.next(getState())
|
||||
}
|
||||
}
|
||||
|
||||
observeState()
|
||||
const unsubscribe = outerSubscribe(observeState)
|
||||
return { unsubscribe }
|
||||
},
|
||||
|
||||
[$$observable]() {
|
||||
return this
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// When a store is created, an "INIT" action is dispatched so that every
|
||||
// reducer returns their initial state. This effectively populates
|
||||
// the initial state tree.
|
||||
dispatch({ type: ActionTypes.INIT })
|
||||
|
||||
return {
|
||||
dispatch,
|
||||
subscribe,
|
||||
getState,
|
||||
replaceReducer,
|
||||
[$$observable]: observable,
|
||||
}
|
||||
}
|
36
web/node_modules/redux/src/index.js
generated
vendored
Normal file
36
web/node_modules/redux/src/index.js
generated
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
import createStore from './createStore'
|
||||
import combineReducers from './combineReducers'
|
||||
import bindActionCreators from './bindActionCreators'
|
||||
import applyMiddleware from './applyMiddleware'
|
||||
import compose from './compose'
|
||||
import warning from './utils/warning'
|
||||
import __DO_NOT_USE__ActionTypes from './utils/actionTypes'
|
||||
|
||||
/*
|
||||
* This is a dummy function to check if the function name has been altered by minification.
|
||||
* If the function has been minified and NODE_ENV !== 'production', warn the user.
|
||||
*/
|
||||
function isCrushed() {}
|
||||
|
||||
if (
|
||||
process.env.NODE_ENV !== 'production' &&
|
||||
typeof isCrushed.name === 'string' &&
|
||||
isCrushed.name !== 'isCrushed'
|
||||
) {
|
||||
warning(
|
||||
'You are currently using minified code outside of NODE_ENV === "production". ' +
|
||||
'This means that you are running a slower development build of Redux. ' +
|
||||
'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' +
|
||||
'or setting mode to production in webpack (https://webpack.js.org/concepts/mode/) ' +
|
||||
'to ensure you have the correct code for your production build.'
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
createStore,
|
||||
combineReducers,
|
||||
bindActionCreators,
|
||||
applyMiddleware,
|
||||
compose,
|
||||
__DO_NOT_USE__ActionTypes,
|
||||
}
|
17
web/node_modules/redux/src/utils/actionTypes.js
generated
vendored
Normal file
17
web/node_modules/redux/src/utils/actionTypes.js
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
* These are private action types reserved by Redux.
|
||||
* For any unknown actions, you must return the current state.
|
||||
* If the current state is undefined, you must return the initial state.
|
||||
* Do not reference these action types directly in your code.
|
||||
*/
|
||||
|
||||
const randomString = () =>
|
||||
Math.random().toString(36).substring(7).split('').join('.')
|
||||
|
||||
const ActionTypes = {
|
||||
INIT: `@@redux/INIT${randomString()}`,
|
||||
REPLACE: `@@redux/REPLACE${randomString()}`,
|
||||
PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`,
|
||||
}
|
||||
|
||||
export default ActionTypes
|
15
web/node_modules/redux/src/utils/formatProdErrorMessage.js
generated
vendored
Normal file
15
web/node_modules/redux/src/utils/formatProdErrorMessage.js
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
* Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
|
||||
*
|
||||
* Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
|
||||
* during build.
|
||||
* @param {number} code
|
||||
*/
|
||||
function formatProdErrorMessage(code) {
|
||||
return (
|
||||
`Minified Redux error #${code}; visit https://redux.js.org/Errors?code=${code} for the full message or ` +
|
||||
'use the non-minified dev environment for full errors. '
|
||||
)
|
||||
}
|
||||
|
||||
export default formatProdErrorMessage
|
14
web/node_modules/redux/src/utils/isPlainObject.js
generated
vendored
Normal file
14
web/node_modules/redux/src/utils/isPlainObject.js
generated
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* @param {any} obj The object to inspect.
|
||||
* @returns {boolean} True if the argument appears to be a plain object.
|
||||
*/
|
||||
export default function isPlainObject(obj) {
|
||||
if (typeof obj !== 'object' || obj === null) return false
|
||||
|
||||
let proto = obj
|
||||
while (Object.getPrototypeOf(proto) !== null) {
|
||||
proto = Object.getPrototypeOf(proto)
|
||||
}
|
||||
|
||||
return Object.getPrototypeOf(obj) === proto
|
||||
}
|
70
web/node_modules/redux/src/utils/kindOf.js
generated
vendored
Normal file
70
web/node_modules/redux/src/utils/kindOf.js
generated
vendored
Normal file
|
@ -0,0 +1,70 @@
|
|||
// Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
|
||||
function miniKindOf(val) {
|
||||
if (val === void 0) return 'undefined'
|
||||
if (val === null) return 'null'
|
||||
|
||||
const type = typeof val
|
||||
switch (type) {
|
||||
case 'boolean':
|
||||
case 'string':
|
||||
case 'number':
|
||||
case 'symbol':
|
||||
case 'function': {
|
||||
return type
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
if (Array.isArray(val)) return 'array'
|
||||
if (isDate(val)) return 'date'
|
||||
if (isError(val)) return 'error'
|
||||
|
||||
const constructorName = ctorName(val)
|
||||
switch (constructorName) {
|
||||
case 'Symbol':
|
||||
case 'Promise':
|
||||
case 'WeakMap':
|
||||
case 'WeakSet':
|
||||
case 'Map':
|
||||
case 'Set':
|
||||
return constructorName
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
// other
|
||||
return type.slice(8, -1).toLowerCase().replace(/\s/g, '')
|
||||
}
|
||||
|
||||
function ctorName(val) {
|
||||
return typeof val.constructor === 'function' ? val.constructor.name : null
|
||||
}
|
||||
|
||||
function isError(val) {
|
||||
return (
|
||||
val instanceof Error ||
|
||||
(typeof val.message === 'string' &&
|
||||
val.constructor &&
|
||||
typeof val.constructor.stackTraceLimit === 'number')
|
||||
)
|
||||
}
|
||||
|
||||
function isDate(val) {
|
||||
if (val instanceof Date) return true
|
||||
return (
|
||||
typeof val.toDateString === 'function' &&
|
||||
typeof val.getDate === 'function' &&
|
||||
typeof val.setDate === 'function'
|
||||
)
|
||||
}
|
||||
|
||||
export function kindOf(val) {
|
||||
let typeOfVal = typeof val
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
typeOfVal = miniKindOf(val)
|
||||
}
|
||||
|
||||
return typeOfVal
|
||||
}
|
3
web/node_modules/redux/src/utils/symbol-observable.js
generated
vendored
Normal file
3
web/node_modules/redux/src/utils/symbol-observable.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
// Inlined version of the `symbol-observable` polyfill
|
||||
export default (() =>
|
||||
(typeof Symbol === 'function' && Symbol.observable) || '@@observable')()
|
19
web/node_modules/redux/src/utils/warning.js
generated
vendored
Normal file
19
web/node_modules/redux/src/utils/warning.js
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
/**
|
||||
* Prints a warning in the console if it exists.
|
||||
*
|
||||
* @param {String} message The warning message.
|
||||
* @returns {void}
|
||||
*/
|
||||
export default function warning(message) {
|
||||
/* eslint-disable no-console */
|
||||
if (typeof console !== 'undefined' && typeof console.error === 'function') {
|
||||
console.error(message)
|
||||
}
|
||||
/* eslint-enable no-console */
|
||||
try {
|
||||
// This error was thrown as a convenience so that if you enable
|
||||
// "break on all exceptions" in your console,
|
||||
// it would pause the execution at this line.
|
||||
throw new Error(message)
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue