├── .babelrc ├── .editorconfig ├── .eslintignore ├── .eslintrc ├── .gitattributes ├── .gitignore ├── .stylelintrc ├── LICENSE ├── README.md ├── gulpfile.js ├── package-lock.json ├── package.json ├── src ├── app.css ├── app.js ├── app.json ├── images │ └── wechat.jpg ├── lib │ ├── immutable.js │ ├── redux-act-reducer │ │ ├── createAction.js │ │ ├── createActionAsync.js │ │ ├── createReducer.js │ │ └── index.js │ ├── redux-immutable.js │ ├── redux-thunk.js │ ├── redux.js │ ├── regenerator-runtime │ │ └── runtime.js │ ├── reselect.js │ └── wx-app-redux │ │ └── index.js ├── pages │ ├── about │ │ ├── about.css │ │ ├── about.js │ │ ├── about.json │ │ └── about.xml │ └── index │ │ ├── actions.js │ │ ├── api.js │ │ ├── index.css │ │ ├── index.js │ │ ├── index.xml │ │ ├── reducer.js │ │ └── selectors.js ├── reducers.js ├── sitemap.json ├── store.js └── utils │ └── request.js └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["@babel/env"] 3 | } 4 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | indent_size = 2 8 | indent_style = space 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | 12 | [*.md] 13 | max_line_length = 0 14 | trim_trailing_whitespace = false 15 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | src/lib 4 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "airbnb-base", 3 | "env": { 4 | "es6": true, 5 | "node": true 6 | }, 7 | "plugins": ["import"], 8 | "rules": { 9 | "comma-dangle": ["warn", "only-multiline"], 10 | "indent": [2, 2, {"SwitchCase": 1}], 11 | "no-console": 0, 12 | "no-alert": 0, 13 | "global-require": 0, 14 | "object-shorthand": [2, "always", { "avoidQuotes": false }], 15 | "import/no-extraneous-dependencies": 0, 16 | "prefer-destructuring": 0, 17 | "function-paren-newline": 0, 18 | "max-len": [2, 250], 19 | "class-methods-use-this": 0, 20 | "object-curly-newline": 0, 21 | "prefer-promise-reject-errors": 0, 22 | "no-else-return": 0, 23 | "import/no-cycle": 0, 24 | "arrow-parens": ["error", "as-needed"], 25 | "no-plusplus": ["error", { "allowForLoopAfterthoughts": true }], 26 | "import/prefer-default-export": 0, 27 | "no-unused-vars": ["error", { "varsIgnorePattern": "regeneratorRuntime" }] 28 | }, 29 | "globals": { 30 | "App": true, 31 | "Page": true, 32 | "wx": true, 33 | "getApp": true 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Enforce Unix newlines 2 | *.css text eol=lf 3 | *.html text eol=lf 4 | *.js text eol=lf 5 | *.json text eol=lf 6 | *.less text eol=lf 7 | *.md text eol=lf 8 | *.svg text eol=lf 9 | *.yml text eol=lf 10 | *.txt text eol=lf 11 | *.xml text eol=lf 12 | *.wxml text eol=lf 13 | *.wxss text eol=lf 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | logs 2 | *.log 3 | npm-debug.log* 4 | node_modules 5 | .npm 6 | coverage 7 | build 8 | stats.json 9 | .module-cache 10 | 11 | .DS_Store 12 | .idea 13 | *.iml 14 | .vscode 15 | dist 16 | public 17 | 18 | webpack-assets.json 19 | webpack-stats.json 20 | -------------------------------------------------------------------------------- /.stylelintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "stylelint-config-standard", 3 | "rules": { 4 | "selector-pseudo-class-no-unknown": [true, { 5 | "ignorePseudoClasses": [ 6 | "export", 7 | "import", 8 | "global", 9 | "local" 10 | ] 11 | }], 12 | "unit-no-unknown": [true, { 13 | "ignoreUnits": [ 14 | "rpx" 15 | ] 16 | }] 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Ray Guo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # wxapp-boilerplate 🗜🖖 2 | 微信小程序开发脚手架 (ES6, Redux, Immutable-js, Async/await, Promise, Reselect, Babel, ESLint, Stylelint, Gulp ... ) 3 | 4 | 支持[Yarn](https://yarnpkg.com/),所以npm的命令可以使用yarn的相关命令替换 5 | 6 | ## 安装 7 | 首先需要有 [Node.js](https://nodejs.org) 环境. 8 | ````javascript 9 | $ git clone https://github.com/ihahoo/wxapp-boilerplate.git 10 | $ npm install 11 | ```` 12 | 13 | ## 启动开发环境 14 | ````javascript 15 | $ npm run dev 16 | ```` 17 | 注:会自动监视 `src/` 文件夹,有代码变动会自动生成到 `dist/` 文件夹。请将微信的开发者工具的项目目录设置为 `dist/` 文件夹,就会自动刷新调试界面。 18 | 19 | > 如果在开发中,发现没有及时更新,可尝试停止并重新运行此命令,或者尝试在微信开发者工具中刷新一下。 20 | 21 | ## 构建发布用的文件 22 | ````javascript 23 | $ npm run build 24 | ```` 25 | 会使用 `uglify` 对js代码压缩,也会调用不同的压缩工具对wxss, wxml, json 和图片进行压缩。 26 | 27 | ## 微信开发者工具新建项目 28 | 请将 `项目目录` 设置到你项目所在目录的 `dist/` 目录下。因为最终构建的目标代码会发布到这里,如果还没有 `dist/` 这个文件夹,你可以手动创建或者运行 `npm run dev` 后自动创建。 29 | 30 | ## 说明 31 | ### 开发方式 32 | 使用你喜欢的编辑器编写代码 <=> 微信官方的开发者工具预览调试和发布 33 | 34 | ### 注意 35 | 请在微信官方的开发者工具的 `项目` 下将 `开启ES6转ES5` 设置为关闭,这里使用 `Gulp` 和 `Babel` 进行转换。在开发目录 `src/` 可使用 `.xml` 替代 `.wxml`,`.css` 替代 `.wxss`,会通过构建工具自动转换到目标文件夹 `dist/` 中。(主要为了编辑器对扩展名的识别,方便开发使用) 36 | 37 | ### 目录结构 38 | - `src/` 开发目录 39 | - `src/lib` 引用的模块库目录,由于微信小程序不支持 `node_modules` 使用npm安装的库无法直接使用,这里放置了转换后的库。以下是整合的一些库,当然你可以根据自己喜欢重新整合。 40 | - `src/lib/redux-act-reducer/` [redux-act-reducer](https://github.com/hahoocn/redux-act-reducer) 是本人开发的创建redux action和reducer的工具。 41 | - `src/lib/regenerator-runtime/` 使用async/await用到的库 42 | - `src/lib/wx-app-redux/` 本人开发的类似于 [react-redux](https://github.com/reactjs/react-redux) 的Redux数据绑定工具。将`Page()` 下的 `data` 与redux绑定。 43 | - `src/lib/immutable.js` 从官方[immutable-js](http://facebook.github.io/immutable-js/)生成的文件。 44 | - `src/lib/redux-immutable.js` 为了支持immutable,替换了redux下的 `combineReducers` 45 | - `src/lib/redux-thunk.js` 支持redux的异步通信 46 | - `src/lib/redux.js` 从官方[redux](https://github.com/reactjs/redux)生成的可直接调用的库。 47 | - `reselect.js` [Reselect](https://github.com/reactjs/reselect) 是为了提高性能而用到的redux state选择工具。 48 | - `src/pages/` 微信小程序的页面 49 | - `src/utils/request.js` 对 `wx.request` 的一个封装,返回 `Promise` ,所以方便使用 `async/await` 方式调用,为了让一套request代码,可以方便的用到各个端(比如web,服务器渲染,或者app),所以抽象了一个封装,这样可以方便代码的重用,当然你可以根据自己需要选择不使用或者自行封装。具体使用参数请看这里:https://github.com/hahoocn/hahoorequest#usage 50 | - `dist/` 将 `src/` 下的文件通过 `Gulp` 构建工具转化生成的可让微信小程序运行环境解读的目标文件。 51 | 52 | ### 支持的语法 53 | 支持 `ES6` 相关语法,支持 `Promise`,支持 `async/await`,支持 `import` 和 `export` 54 | 55 | ### async/await 使用注意 56 | 请在使用了 `async/await` 的页面顶部加入以下代码: 57 | ```javascript 58 | import regeneratorRuntime from '../../lib/regenerator-runtime/runtime-module'; 59 | ``` 60 | 61 | ### 关于代码规范的统一 62 | 使用 `eslint` 、 `stylelint` 和 `editorconfig` 可以对编码进行规范,特别是多人合作情况下,使用统一规范很重要。所以请将代码编辑器增加对`eslint` 、 `stylelint` 和 `editorconfig` 的插件和支持,在编码的同时,即可提示错误和警示。可以通过 `.eslintrc` 配置js规范的规则,通过`.stylelintrc` 配置样式表的规范规则,通过 `.editorconfig` 配置编辑器编码的一些规则。 63 | 64 | ### 关于Redux、Immutable-js等相关工具 65 | `Redux` 做为管理数据流的工具,可以用到各种前端框架中。比如`React`,`Vue`,`React Native`等,当然微信小程序也可使用。Redux和Immutable-js在初步使用的时候,会觉得有点麻烦或难理解,不过对于数据流的管理或构建复杂的项目会更好,性能也不错。其实这里与微信小程序框架结合的Redux相关技术栈和我使用React下的Redux相关技术栈是一样的,所以可以方便代码的重用。在构建h5应用,小程序,pc软件,app等都可以用上Redux、Immutable-js等相关技术栈。 66 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | const gulp = require('gulp'); 2 | const babel = require('gulp-babel'); 3 | const sourcemaps = require('gulp-sourcemaps'); 4 | const jsonminify = require('gulp-jsonminify'); 5 | const rename = require('gulp-rename'); 6 | const htmlmin = require('gulp-htmlmin'); 7 | const imagemin = require('gulp-imagemin'); 8 | const del = require('del'); 9 | const gulpif = require('gulp-if'); 10 | const uglify = require('gulp-uglify'); 11 | const postcss = require('gulp-postcss'); 12 | const cssnano = require('cssnano'); 13 | 14 | const isProd = () => process.env.NODE_ENV === 'production'; 15 | 16 | gulp.task('js', () => gulp.src(['src/**/*.js']) 17 | .pipe(gulpif(!isProd, sourcemaps.init())) 18 | .pipe(babel()) 19 | .pipe(gulpif(isProd, uglify())) 20 | .pipe(gulpif(!isProd, sourcemaps.write('.'))) 21 | .pipe(gulp.dest('dist')) 22 | ); 23 | 24 | gulp.task('wxml', () => gulp.src(['src/**/*.{wxml,xml,html}']) 25 | .pipe(gulpif(isProd, htmlmin({ 26 | collapseWhitespace: true, 27 | includeAutoGeneratedTags: false, 28 | keepClosingSlash: true, 29 | removeComments: true, 30 | removeEmptyAttributes: true, 31 | removeScriptTypeAttributes: true, 32 | removeStyleLinkTypeAttributes: true, 33 | }))) 34 | .pipe(rename({ extname: '.wxml' })) 35 | .pipe(gulp.dest('dist')) 36 | ); 37 | 38 | gulp.task('wxss', () => gulp.src(['src/**/*.{wxss,css}']) 39 | .pipe(gulpif(isProd, postcss([cssnano()]))) 40 | .pipe(rename({ extname: '.wxss' })) 41 | .pipe(gulp.dest('dist')) 42 | ); 43 | 44 | gulp.task('json', () => gulp.src(['src/**/*.json']) 45 | .pipe(gulpif(isProd, jsonminify())) 46 | .pipe(gulp.dest('dist')) 47 | ); 48 | 49 | gulp.task('image', () => gulp.src(['src/**/*.{jpg,jpeg,png,gif,svg}']) 50 | .pipe(gulpif(isProd, imagemin())) 51 | .pipe(gulp.dest('dist')) 52 | ); 53 | 54 | gulp.task('extras', () => gulp.src(['src/**/*.*', '!src/**/*.{js,wxml,xml,html,wxss,json,css,jpg,jpeg,png,gif,svg}']) 55 | .pipe(gulp.dest('dist')) 56 | ); 57 | 58 | gulp.task('clean', () => del(['dist/*'])); 59 | 60 | gulp.task('build', gulp.series('clean', gulp.parallel('js', 'wxml', 'wxss', 'json', 'image', 'extras'))); 61 | 62 | gulp.task('watch', gulp.series('build', () => { 63 | gulp.watch('src/**/*.js', gulp.series('js')); 64 | gulp.watch('src/**/*.{wxml,xml,html}', gulp.series('wxml')); 65 | gulp.watch('src/**/*.{wxss,css}', gulp.series('wxss')); 66 | gulp.watch('src/**/*.json', gulp.series('json')); 67 | gulp.watch('src/**/*.{jpg,jpeg,png,gif,svg}', gulp.series('image')); 68 | gulp.watch(['src/**/*.*', '!src/**/*.{js,wxml,xml,html,wxss,json,css,jpg,jpeg,png,gif,svg}'], gulp.series('extras')); 69 | })); 70 | 71 | gulp.task('default', gulp.series('watch')); 72 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wxapp-boilerplate", 3 | "version": "0.2.0", 4 | "description": "微信小程序开发脚手架 (Redux, Immutable-js, Reselect, Babel, ESLint, Stylelint, Gulp ... )", 5 | "scripts": { 6 | "dev": "cross-env NODE_ENV=development gulp watch", 7 | "build": "cross-env NODE_ENV=production gulp build", 8 | "clean": "gulp clean" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/ihahoo/wxapp-boilerplate.git" 13 | }, 14 | "keywords": [ 15 | "weapp", 16 | "wxapp", 17 | "wechat", 18 | "app", 19 | "boilerplate" 20 | ], 21 | "author": "Ray Guo", 22 | "license": "MIT", 23 | "bugs": { 24 | "url": "https://github.com/ihahoo/wxapp-boilerplate/issues" 25 | }, 26 | "homepage": "https://github.com/ihahoo/wxapp-boilerplate#readme", 27 | "devDependencies": { 28 | "@babel/cli": "^7.10.5", 29 | "@babel/core": "^7.11.1", 30 | "@babel/preset-env": "^7.11.0", 31 | "cross-env": "^7.0.2", 32 | "cssnano": "^4.1.10", 33 | "del": "^5.1.0", 34 | "eslint": "^7.7.0", 35 | "eslint-config-airbnb-base": "^14.2.0", 36 | "eslint-plugin-import": "^2.22.0", 37 | "gulp": "^4.0.2", 38 | "gulp-babel": "^8.0.0", 39 | "gulp-htmlmin": "^5.0.1", 40 | "gulp-if": "^3.0.0", 41 | "gulp-imagemin": "^7.1.0", 42 | "gulp-jsonminify": "^1.1.0", 43 | "gulp-postcss": "^8.0.0", 44 | "gulp-rename": "^2.0.0", 45 | "gulp-sourcemaps": "^2.6.5", 46 | "gulp-uglify": "^3.0.2", 47 | "stylelint": "^13.6.1", 48 | "stylelint-config-standard": "^20.0.0" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/app.css: -------------------------------------------------------------------------------- 1 | .container { 2 | height: 100%; 3 | display: flex; 4 | flex-direction: column; 5 | align-items: center; 6 | justify-content: space-between; 7 | padding: 200rpx 0; 8 | box-sizing: border-box; 9 | } 10 | -------------------------------------------------------------------------------- /src/app.js: -------------------------------------------------------------------------------- 1 | import configureStore from './store'; 2 | 3 | const store = configureStore(); 4 | 5 | App({ 6 | store 7 | }); 8 | -------------------------------------------------------------------------------- /src/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages":[ 3 | "pages/index/index", 4 | "pages/about/about" 5 | ], 6 | "window":{ 7 | "backgroundTextStyle":"light", 8 | "navigationBarBackgroundColor": "#fff", 9 | "navigationBarTitleText": "App", 10 | "navigationBarTextStyle":"black" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/images/wechat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ihahoo/wxapp-boilerplate/158ac16a383d78effecf2b30254a6b5e8eb2e51a/src/images/wechat.jpg -------------------------------------------------------------------------------- /src/lib/immutable.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Immutable={})}(this,function(t){"use strict";function e(){return{value:!1}}function r(t){t&&(t.value=!0)}function n(){}function i(t){return void 0===t.size&&(t.size=t.__iterate(u)),t.size}function o(t,e){if("number"!=typeof e){var r=e>>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?i(t)+e:e}function u(){return!0}function s(t,e,r){return(0===t&&!h(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function a(t,e){return f(t,e,0)}function c(t,e){return f(t,e,e)}function f(t,e,r){return void 0===t?r:h(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function h(t){return t<0||0===t&&1/t==-(1/0)}function p(t){return!(!t||!t[fr])}function _(t){return!(!t||!t[hr])}function l(t){return!(!t||!t[pr])}function v(t){return _(t)||l(t)}function y(t){return!(!t||!t[dr])}function d(t){return!(!t||!t[gr])}function g(t){return p(t)||d(t)}function m(t){return!(!t||!t[mr])}function w(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function z(){return{value:void 0,done:!0}}function S(t){return!!O(t)}function I(t){return t&&"function"==typeof t.next}function b(t){var e=O(t);return e&&e.call(t)}function O(t){var e=t&&(Ir&&t[Ir]||t[br]);if("function"==typeof e)return e}function E(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}function M(){return Rr||(Rr=new xr([]))}function q(t){var e=Array.isArray(t)?new xr(t):S(t)?new Kr(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new kr(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function D(t){var e=j(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function A(t){var e=j(t);if(e)return e;if("object"==typeof t)return new kr(t) 8 | ;throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function j(t){return E(t)?new xr(t):S(t)?new Kr(t):void 0}function x(t){return!(!t||!t[Tr])}function k(t){return x(t)&&m(t)}function R(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function U(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return!!(R(t)&&R(e)&&t.equals(e))}function K(t){return t>>>1&1073741824|3221225471&t}function T(t){switch(typeof t){case"boolean":return t?1108378657:1108378656;case"number":return L(t);case"string":return t.length>Jr?C(t):B(t);case"object":case"function":return null===t?1108378658:"function"==typeof t.hashCode?K(t.hashCode(t)):(t.valueOf!==Cr&&"function"==typeof t.valueOf&&(t=t.valueOf(t)),W(t));case"undefined":return 1108378659;default:if("function"==typeof t.toString)return B(""+t);throw Error("Value type "+typeof t+" cannot be hashed.")}}function L(t){if(t!==t||t===1/0)return 0;var e=0|t;for(e!==t&&(e^=4294967295*t);t>4294967295;)t/=4294967295,e^=t;return K(e)}function C(t){var e=Qr[t];return void 0===e&&(e=B(t),Yr===Vr&&(Yr=0,Qr={}),Yr++,Qr[t]=e),e}function B(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function P(t){var e=ct(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=ft,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===Sr){var n=t.__iterator(e,r);return new Er(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===zr?wr:zr,r)},e}function H(t,e,r){var n=ct(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,cr);return o===cr?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(Sr,i);return new Er(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return w(n,s,e.call(r,u[1],s,t),i)})},n}function J(t,e){var r=this,n=ct(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var e=P(t);return e.reverse=function(){return t.flip()},e}),n.get=function(r,n){return t.get(e?r:-1-r,n)},n.has=function(r){return t.has(e?r:-1-r)},n.includes=function(e){return t.includes(e)},n.cacheResult=ft,n.__iterate=function(r,n){var o=this,u=0;return n&&i(t),t.__iterate(function(t,i){return r(t,e?i:n?o.size-++u:u++,o)},!n)},n.__iterator=function(n,o){var u=0;o&&i(t);var s=t.__iterator(Sr,!o);return new Er(function(){var t=s.next();if(t.done)return t;var i=t.value;return w(n,e?i[0]:o?r.size-++u:u++,i[1],t)})},n}function V(t,e,r,n){var i=ct(t);return n&&(i.has=function(n){var i=t.get(n,cr) 10 | ;return i!==cr&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,cr);return o!==cr&&e.call(r,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(e.call(r,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Sr,o),s=0;return new Er(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],f=a[1];if(e.call(r,f,c,t))return w(i,n?c:s++,f,o)}})},i}function Y(t,e,r){var n=$r().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function Q(t,e,r){var n=_(t),i=(m(t)?gn():$r()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=at(t);return i.map(function(e){return ut(t,o(e))}).asImmutable()}function X(t,e,r,n){var i=t.size;if(s(e,r,i))return t;var u=a(e,i),f=c(r,i);if(u!==u||f!==f)return X(t.toSeq().cacheResult(),e,r,n);var h,p=f-u;p===p&&(h=p<0?0:p);var _=ct(t);return _.size=0===h?h:t.size&&h||void 0,!n&&y(t)&&h>=0&&(_.get=function(e,r){return e=o(this,e),e>=0&&eh)return z();var t=i.next();return n||e===zr||t.done?t:e===wr?w(e,s-1,void 0,t):w(e,s-1,t.value[1],t)})},_}function F(t,e,r){var n=ct(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Sr,i),s=!0;return new Er(function(){if(!s)return z() 11 | ;var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return e.call(r,c,a,o)?n===Sr?t:w(n,a,c,t):(s=!1,z())})},n}function G(t,e,r,n){var i=ct(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(Sr,o),a=!0,c=0;return new Er(function(){var t,o,f;do{if(t=s.next(),t.done)return n||i===zr?t:i===wr?w(i,c++,void 0,t):w(i,c++,t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===Sr?t:w(i,o,f,t)})},i}function Z(t,e){var r=_(t),n=[t].concat(e).map(function(t){return p(t)?r&&(t=lr(t)):t=r?q(t):D(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&_(i)||l(t)&&l(i))return i}var o=new xr(n);return r?o=o.toKeyedSeq():l(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function $(t,e,r){var n=ct(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!e||c0}function ot(t,e,r,n){var i=ct(t),o=new xr(r).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(zr,e),i=0;!(r=n.next()).done&&t(r.value,i++,this)!==!1;);return i},i.__iteratorUncached=function(t,i){var o=r.map(function(t){return t=_r(t),b(i?t.reverse():t)}),u=0,s=!1;return new Er(function(){var r;return s||(r=o.map(function(t){return t.next()}),s=n?r.every(function(t){return t.done}):r.some(function(t){return t.done})),s?z():w(t,u++,e.apply(null,r.map(function(t){return t.value})))})},i}function ut(t,e){return t===e?t:y(t)?e:t.constructor(e)}function st(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function at(t){return _(t)?lr:l(t)?vr:yr}function ct(t){return Object.create((_(t)?Dr:l(t)?Ar:jr).prototype)}function ft(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):qr.prototype.cacheResult.call(this)}function ht(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return Ut(this,e,t)}function Ut(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Wt(t,e)}function Tt(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Wt(e,r,t)}function Lt(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Bt(t,e)}function Ct(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Bt(e,r,t)}function Bt(t,e,r){return Wt(t,e,Nt(r))}function Wt(t,e,r){if(!dt(t))throw new TypeError("Cannot merge into non-data-structure value: "+t);if(g(t))return"function"==typeof r&&t.mergeWith?t.mergeWith.apply(t,[r].concat(e)):t.merge?t.merge.apply(t,e):t.concat.apply(t,e);for(var n=Array.isArray(t),i=t,o=n?vr:lr,u=n?function(e){i===t&&(i=zt(i)),i.push(e)}:function(e,n){var o=Mr.call(i,n),u=o&&r?r(i[n],e,n):e;o&&u===i[n]||(i===t&&(i=zt(i)),i[n]=u)},s=0;s0;)e[r]=arguments[r+1];return Bt(this,e,t)}function Jt(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return bt(this,t,te(),function(t){return Wt(t,e)})}function Vt(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return bt(this,t,te(),function(t){return Bt(t,e)})}function Yt(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Qt(){ 15 | return this.__ownerID?this:this.__ensureOwner(new n)}function Xt(){return this.__ensureOwner()}function Ft(){return this.__altered}function Gt(t,e){return w(t,e[0],e[1])}function Zt(t,e){return{node:t,index:0,__prev:e}}function $t(t,e,r,n){var i=Object.create(tn);return i.size=t,i._root=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function te(){return sn||(sn=$t(0))}function ee(t,r,n){var i,o;if(t._root){var u=e(),s=e();if(i=re(t._root,t.__ownerID,0,void 0,r,n,u,s),!s.value)return t;o=t.size+(u.value?n===cr?-1:1:0)}else{if(n===cr)return t;o=1,i=new en(t.__ownerID,[[r,n]])}return t.__ownerID?(t.size=o,t._root=i,t.__hash=void 0,t.__altered=!0,t):i?$t(o,i):te()}function re(t,e,n,i,o,u,s,a){return t?t.update(e,n,i,o,u,s,a):u===cr?t:(r(a),r(s),new un(e,i,[o,u]))}function ne(t){return t.constructor===un||t.constructor===on}function ie(t,e,r,n,i){if(t.keyHash===n)return new on(e,n,[t.entry,i]);var o,u=(0===r?t.keyHash:t.keyHash>>>r)&ar,s=(0===r?n:n>>>r)&ar;return new rn(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new nn(t,o+1,u)}function ae(t){return t-=t>>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function ce(t,e,r,n){var i=n?t:pt(t);return i[e]=r,i}function fe(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>sr&&(c=sr),function(){if(i===c)return dn;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,f=1+(u-i>>n);return f>sr&&(f=sr),function(){for(;;){if(s){var t=s();if(t!==dn)return t;s=null}if(c===f)return dn;var o=e?--f:c++;s=r(a&&a[o],n-ur,i+(o<=t.size||r<0)return t.withMutations(function(t){r<0?we(t,r).set(0,n):we(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,u=t._root,s=e();return r>=ze(t._capacity)?i=de(i,t.__ownerID,0,r,n,s):u=de(u,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=u,t._tail=i,t.__hash=void 0,t.__altered=!0,t):le(t._origin,t._capacity,t._level,u,i):t}function de(t,e,n,i,o,u){var s=i>>>n&ar,a=t&&s0){var f=t&&t.array[s],h=de(f,e,n-ur,i,o,u);return h===f?t:(c=ge(t,e),c.array[s]=h,c)}return a&&t.array[s]===o?t:(u&&r(u),c=ge(t,e),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function ge(t,e){return e&&t&&e===t.ownerID?t:new vn(t?t.array.slice():[],e)}function me(t,e){if(e>=ze(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&ar],n-=ur;return r}}function we(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:r<0?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,f=t._root,h=0;s+h<0;)f=new vn(f&&f.array.length?[void 0,f]:[],i),c+=ur,h+=1<=1<p?new vn([],i):l;if(l&&_>p&&sur;d-=ur){var g=p>>>d&ar;y=y.array[g]=ge(y.array[g],i)}y.array[p>>>ur&ar]=l}if(a=_)s-=_,a-=_,c=ur,f=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&ar;if(m!==_>>>c&ar)break;m&&(h+=(1<o&&(f=f.removeBefore(i,c,s-h)),f&&_>>ur<=sr&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):Se(n,i)}function Oe(t){return!(!t||!t[wn])}function Ee(t,e,r,n){var i=Object.create(Sn);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Me(){return In||(In=Ee(0))}function qe(t){return!(!t||!t[bn])}function De(t){return qe(t)&&m(t)}function Ae(t,e){if(t===e)return!0;if(!p(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||_(t)!==_(e)||l(t)!==l(e)||m(t)!==m(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!v(t);if(m(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&U(i[1],t)&&(r||U(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){ 18 | if(r?!t.has(e):i?!U(e,t.get(n,cr)):!U(t.get(n,cr),e))return u=!1,!1});return u&&t.size===s}function je(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function xe(t){if(!t||"object"!=typeof t)return t;if(!p(t)){if(!dt(t))return t;t=qr(t)}if(_(t)){var e={};return t.__iterate(function(t,r){e[r]=xe(t)}),e}var r=[];return t.__iterate(function(t){r.push(xe(t))}),r}function ke(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function Re(t,e){var r=Object.create(En);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function Ue(){return Mn||(Mn=Re(te()))}function Ke(t,e,r){for(var n=vt(e),i=0;i!==n.length;)if((t=wt(t,n[i++],cr))===cr)return r;return t}function Te(t,e){return Ke(this,t,e)}function Le(t,e){return Ke(t,e,cr)!==cr}function Ce(t){return Le(this,t)}function Be(){lt(this.size);var t={};return this.__iterate(function(e,r){t[r]=e}),t}function We(t,e,r,n,i,o){return lt(t.size),t.__iterate(function(t,o,u){i?(i=!1,r=t):r=e.call(n,r,t,o,u)},o),r}function Ne(t,e){return e}function Pe(t,e){return[e,t]}function He(t){return function(){return!t.apply(this,arguments)}}function Je(t){return function(){return-t.apply(this,arguments)}}function Ve(){return pt(arguments)}function Ye(t,e){return te?-1:0}function Qe(t){if(t.size===1/0)return 0;var e=m(t),r=_(t),n=e?1:0;return Xe(t.__iterate(r?e?function(t,e){n=31*n+Fe(T(t),T(e))|0}:function(t,e){n=n+Fe(T(t),T(e))|0}:e?function(t){n=31*n+T(t)|0}:function(t){n=n+T(t)|0}),n)}function Xe(t,e){return e=Lr(e,3432918353),e=Lr(e<<15|e>>>-15,461845907),e=Lr(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=Lr(e^e>>>16,2246822507),e=Lr(e^e>>>13,3266489909),e=K(e^e>>>16)}function Fe(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}function Ge(t,e){var r=Object.create(Rn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function Ze(){return Un||(Un=Ge(Ie()))}function $e(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._values=e, 19 | n.__ownerID=r,n}function tr(t){return t.constructor.displayName||t.constructor.name||"Record"}function er(t){return q(t._keys.map(function(e){return[e,t.get(e)]}))}function rr(t,e){try{Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){_t(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch(t){}}function nr(t,e){return ir([],e||or,t,"",e&&e.length>2?[]:void 0,{"":t})}function ir(t,e,r,n,i,o){var u=Array.isArray(r)?Ar:yt(r)?Dr:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return ir(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function or(t,e){return _(e)?e.toMap():e.toList()}var ur=5,sr=1<>>16)*n+r*(e>>>16)<<16>>>0)|0},Cr=Object.prototype.valueOf,Br=Object.isExtensible,Wr=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),Nr="function"==typeof WeakMap;Nr&&(Ur=new WeakMap);var Pr=0,Hr="__immutablehash__";"function"==typeof Symbol&&(Hr=Symbol(Hr));var Jr=16,Vr=255,Yr=0,Qr={},Xr=function(t){function e(t,e){this._iter=t,this._useKeys=e,this.size=t.size} 22 | return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this._iter.get(t,e)},e.prototype.has=function(t){return this._iter.has(t)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){var t=this,e=J(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},e.prototype.map=function(t,e){var r=this,n=H(this,t,e);return this._useKeys||(n.valueSeq=function(){return r._iter.toSeq().map(t,e)}),n},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e,n){return t(e,n,r)},e)},e.prototype.__iterator=function(t,e){return this._iter.__iterator(t,e)},e}(Dr);Xr.prototype[mr]=!0;var Fr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.includes=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this,n=0;return e&&i(this),this._iter.__iterate(function(i){return t(i,e?r.size-++n:n++,r)},e)},e.prototype.__iterator=function(t,e){var r=this,n=this._iter.__iterator(zr,e),o=0;return e&&i(this),new Er(function(){var i=n.next();return i.done?i:w(t,e?r.size-++o:o++,i.value,i)})},e}(Ar),Gr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.has=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(zr,e);return new Er(function(){var e=r.next();return e.done?e:w(t,e.value,e.value,e)})},e}(jr),Zr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.entrySeq=function(){return this._iter.toSeq()},e.prototype.__iterate=function(t,e){var r=this 23 | ;return this._iter.__iterate(function(e){if(e){st(e);var n=p(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(zr,e);return new Er(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){st(n);var i=p(n);return w(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},e}(Dr);Fr.prototype.cacheResult=Xr.prototype.cacheResult=Gr.prototype.cacheResult=Zr.prototype.cacheResult=ft;var $r=function(t){function e(e){return null===e||void 0===e?te():x(e)&&!m(e)?e:te().withMutations(function(r){var n=t(e);lt(n.size),n.forEach(function(t,e){return r.set(e,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return te().withMutations(function(e){for(var r=0;r=t.length)throw Error("Missing value for key: "+t[r]);e.set(t[r],t[r+1])}})},e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return ee(this,t,e)},e.prototype.remove=function(t){return ee(this,t,cr)},e.prototype.deleteAll=function(t){var e=_r(t);return 0===e.size?this:this.withMutations(function(t){e.forEach(function(e){return t.remove(e)})})},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):te()},e.prototype.sort=function(t){return gn(rt(this,t))},e.prototype.sortBy=function(t,e){return gn(rt(this,e,t))},e.prototype.map=function(t,e){return this.withMutations(function(r){r.forEach(function(n,i){r.set(i,t.call(e,n,i,r))})})},e.prototype.__iterator=function(t,e){return new an(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},e.prototype.__ensureOwner=function(t){ 24 | return t===this.__ownerID?this:t?$t(this.size,this._root,t,this.__hash):0===this.size?te():(this.__ownerID=t,this.__altered=!1,this)},e}(lr);$r.isMap=x;var tn=$r.prototype;tn[Tr]=!0,tn.delete=tn.remove,tn.removeAll=tn.deleteAll,tn.setIn=Mt,tn.removeIn=tn.deleteIn=Dt,tn.update=jt,tn.updateIn=xt,tn.merge=tn.concat=kt,tn.mergeWith=Rt,tn.mergeDeep=Pt,tn.mergeDeepWith=Ht,tn.mergeIn=Jt,tn.mergeDeepIn=Vt,tn.withMutations=Yt,tn.wasAltered=Ft,tn.asImmutable=Xt,tn["@@transducer/init"]=tn.asMutable=Qt,tn["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},tn["@@transducer/result"]=function(t){return t.asImmutable()};var en=function(t,e){this.ownerID=t,this.entries=e};en.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=cn)return oe(t,c,i,o);var _=t&&t===this.ownerID,l=_?c:pt(c);return p?a?f===h-1?l.pop():l[f]=l.pop():l[f]=[i,o]:l.push([i,o]),_?(this.entries=l,this):new en(t,l)}};var rn=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};rn.prototype.get=function(t,e,r,n){void 0===e&&(e=T(r));var i=1<<((0===t?e:e>>>t)&ar),o=this.bitmap;return 0==(o&i)?n:this.nodes[ae(o&i-1)].get(t+ur,e,r,n)},rn.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=T(n));var s=(0===e?r:r>>>e)&ar,a=1<=fn)return se(t,p,c,s,l);if(f&&!l&&2===p.length&&ne(p[1^h]))return p[1^h];if(f&&l&&1===p.length&&ne(l))return l;var v=t&&t===this.ownerID,y=f?l?c:c^a:c|a,d=f?l?ce(p,h,l,v):he(p,h,v):fe(p,h,l,v);return v?(this.bitmap=y,this.nodes=d,this):new rn(t,y,d)};var nn=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};nn.prototype.get=function(t,e,r,n){void 0===e&&(e=T(r)) 25 | ;var i=(0===t?e:e>>>t)&ar,o=this.nodes[i];return o?o.get(t+ur,e,r,n):n},nn.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=T(n));var s=(0===e?r:r>>>e)&ar,a=i===cr,c=this.nodes,f=c[s];if(a&&!f)return this;var h=re(f,t,e+ur,r,n,i,o,u);if(h===f)return this;var p=this.count;if(f){if(!h&&--p0&&i=0&&t>>e&ar;if(n>=this.array.length)return new vn([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-ur,r))===u&&o)return this}if(o&&!i)return this;var s=ge(this,t);if(!o)for(var a=0;a>>e&ar;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-ur,r))===o&&n===this.array.length-1)return this}var u=ge(this,t) 28 | ;return u.array.splice(n+1),i&&(u.array[n]=i),u};var yn,dn={},gn=function(t){function e(t){return null===t||void 0===t?Ie():k(t)?t:Ie().withMutations(function(e){var r=lr(t);lt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Ie()},e.prototype.set=function(t,e){return be(this,t,e)},e.prototype.remove=function(t){return be(this,t,cr)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Se(e,r,t,this.__hash):0===this.size?Ie():(this.__ownerID=t,this._map=e,this._list=r,this)},e}($r);gn.isOrderedMap=k,gn.prototype[mr]=!0,gn.prototype.delete=gn.prototype.remove;var mn,wn="@@__IMMUTABLE_STACK__@@",zn=function(t){function e(t){return null===t||void 0===t?Me():Oe(t)?t:Me().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=o(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={ 29 | value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Ee(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&Oe(e))return e;lt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Ee(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Me()},e.prototype.slice=function(e,r){if(s(e,r,this.size))return this;var n=a(e,this.size);if(c(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Ee(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ee(this.size,this._head,t,this.__hash):0===this.size?Me():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new xr(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,this)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new xr(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Er(function(){if(n){var e=n.value;return n=n.next,w(t,r++,e)}return z()})},e}(vr);zn.isStack=Oe;var Sn=zn.prototype;Sn[wn]=!0,Sn.shift=Sn.pop,Sn.unshift=Sn.push,Sn.unshiftAll=Sn.pushAll,Sn.withMutations=Yt,Sn.wasAltered=Ft,Sn.asImmutable=Xt,Sn["@@transducer/init"]=Sn.asMutable=Qt,Sn["@@transducer/step"]=function(t,e){return t.unshift(e)},Sn["@@transducer/result"]=function(t){return t.asImmutable()};var In,bn="@@__IMMUTABLE_SET__@@",On=function(t){function e(e){return null===e||void 0===e?Ue():qe(e)&&!m(e)?e:Ue().withMutations(function(r){var n=t(e);lt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t), 30 | e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(lr(t).keySeq())},e.intersect=function(t){return t=_r(t).toArray(),t.length?En.intersect.apply(e(t.pop()),t):Ue()},e.union=function(t){return t=_r(t).toArray(),t.length?En.union.apply(e(t.pop()),t):Ue()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return ke(this,this._map.set(t,t))},e.prototype.remove=function(t){return ke(this,this._map.remove(t))},e.prototype.clear=function(){return ke(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=[],i=[];return this.forEach(function(o){var u=t.call(e,o,o,r);u!==o&&(n.push(o),i.push(u))}),this.withMutations(function(t){n.forEach(function(e){return t.remove(e)}),i.forEach(function(e){return t.add(e)})})},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=o(this,t))>=0&&(void 0!==this.size?this.size===1/0||t 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 8 | argNames[_key - 1] = arguments[_key]; 9 | } 10 | 11 | if (argNames.length > 0) { 12 | return function () { 13 | for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 14 | args[_key2] = arguments[_key2]; 15 | } 16 | 17 | var action = {}; 18 | argNames.forEach(function (arg, index) { 19 | action[argNames[index]] = args[index]; 20 | }); 21 | action.type = type; 22 | return action; 23 | }; 24 | } 25 | 26 | return function (data) { 27 | var action = void 0; 28 | if (data) { 29 | action = Object.assign(data, { type: type }); 30 | } else { 31 | action = { type: type }; 32 | } 33 | return action; 34 | }; 35 | } 36 | 37 | exports.default = createAction; -------------------------------------------------------------------------------- /src/lib/redux-act-reducer/createActionAsync.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import regeneratorRuntime from '../regenerator-runtime/runtime'; 4 | 5 | Object.defineProperty(exports, "__esModule", { 6 | value: true 7 | }); 8 | 9 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; 10 | 11 | function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } 12 | 13 | function createActionAsync(type, api, options) { 14 | var _this = this; 15 | 16 | return function () { 17 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { 18 | args[_key] = arguments[_key]; 19 | } 20 | 21 | return function () { 22 | var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(dispatch, getState) { 23 | var defaultOpts, actionObj, res; 24 | return regeneratorRuntime.wrap(function _callee$(_context) { 25 | while (1) { 26 | switch (_context.prev = _context.next) { 27 | case 0: 28 | defaultOpts = { 29 | name: type, 30 | isCreateRequest: true, 31 | isCreateSuccess: true, 32 | isCreateFailure: true, 33 | onRequest: undefined, 34 | onSuccess: undefined, 35 | onFailure: undefined 36 | }; 37 | 38 | 39 | if (options && (typeof options === 'undefined' ? 'undefined' : _typeof(options)) === 'object') { 40 | Object.assign(defaultOpts, options); 41 | } 42 | if (options && typeof options === 'string') { 43 | Object.assign(defaultOpts, { name: options }); 44 | } 45 | 46 | actionObj = {}; 47 | 48 | 49 | if (defaultOpts.isCreateRequest) { 50 | actionObj.request = { 51 | type: type, 52 | subType: 'REQUEST', 53 | async: { isAsync: true, name: defaultOpts.name } 54 | }; 55 | dispatch(actionObj.request); 56 | } 57 | if (defaultOpts.onRequest && typeof defaultOpts.onRequest === 'function') { 58 | defaultOpts.onRequest(dispatch, getState); 59 | } 60 | 61 | _context.prev = 6; 62 | _context.next = 9; 63 | return api.apply(undefined, args.concat([dispatch, getState])); 64 | 65 | case 9: 66 | res = _context.sent; 67 | 68 | if (defaultOpts.isCreateSuccess) { 69 | actionObj.success = { 70 | type: type, 71 | subType: 'SUCCESS', 72 | async: { isAsync: true, name: defaultOpts.name }, 73 | res: res 74 | }; 75 | dispatch(actionObj.success); 76 | } 77 | if (defaultOpts.onSuccess && typeof defaultOpts.onSuccess === 'function') { 78 | defaultOpts.onSuccess(dispatch, getState, res); 79 | } 80 | _context.next = 19; 81 | break; 82 | 83 | case 14: 84 | _context.prev = 14; 85 | _context.t0 = _context['catch'](6); 86 | 87 | if (defaultOpts.isCreateFailure) { 88 | actionObj.failure = { 89 | type: type, 90 | subType: 'FAILURE', 91 | async: { isAsync: true, name: defaultOpts.name }, 92 | err: _context.t0 93 | }; 94 | dispatch(actionObj.failure); 95 | } 96 | if (defaultOpts.onFailure && typeof defaultOpts.onFailure === 'function') { 97 | defaultOpts.onFailure(dispatch, getState, _context.t0); 98 | } 99 | 100 | return _context.abrupt('return', Promise.reject(actionObj)); 101 | 102 | case 19: 103 | return _context.abrupt('return', Promise.resolve(actionObj)); 104 | 105 | case 20: 106 | case 'end': 107 | return _context.stop(); 108 | } 109 | } 110 | }, _callee, _this, [[6, 14]]); 111 | })); 112 | 113 | return function (_x, _x2) { 114 | return _ref.apply(this, arguments); 115 | }; 116 | }(); 117 | }; 118 | } 119 | exports.default = createActionAsync; 120 | -------------------------------------------------------------------------------- /src/lib/redux-act-reducer/createReducer.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | 7 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; 8 | 9 | function createReducer(handlers, defaultState, options) { 10 | var opts = { 11 | autoAssign: false 12 | }; 13 | if (options) { 14 | Object.assign(opts, options); 15 | } 16 | return function () { 17 | var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultState; 18 | var action = arguments[1]; 19 | 20 | if (action.type) { 21 | var handler = handlers[action.type]; 22 | if (typeof handler === 'function') { 23 | if (!action.subType) { 24 | if (opts.autoAssign) { 25 | return Object.assign({}, state, handler(state, action)); 26 | } 27 | return handler(state, action); 28 | } 29 | 30 | if (opts.autoAssign && action.async && action.async.isAsync) { 31 | if (action.subType === 'REQUEST' && !handler.toString().includes('function REQUEST()')) { 32 | var obj = {}; 33 | obj[action.async.name] = { 34 | isFetching: true, 35 | err: undefined 36 | }; 37 | return Object.assign({}, state, { 38 | asyncStatus: Object.assign({}, state.asyncStatus, _extends({}, obj)) 39 | }); 40 | } 41 | if (action.subType === 'FAILURE' && !handler.toString().includes('function FAILURE()')) { 42 | var _obj = {}; 43 | _obj[action.async.name] = { 44 | isFetching: false, 45 | err: action.err 46 | }; 47 | return Object.assign({}, state, { 48 | asyncStatus: Object.assign({}, state.asyncStatus, _extends({}, _obj)) 49 | }); 50 | } 51 | } 52 | 53 | var subHandlers = handler(state, action); 54 | var subHandler = subHandlers[action.subType]; 55 | if (opts.autoAssign && action.async && action.async.isAsync && action.subType === 'SUCCESS') { 56 | var _obj2 = {}; 57 | if (state.asyncStatus && state.asyncStatus[action.async.name]) { 58 | _obj2[action.async.name] = { 59 | isFetching: false, 60 | err: undefined 61 | }; 62 | } 63 | var newState = void 0; 64 | if (typeof subHandler === 'function') { 65 | if (state.asyncStatus && state.asyncStatus[action.async.name]) { 66 | newState = Object.assign({}, state, _extends({ 67 | asyncStatus: Object.assign({}, state.asyncStatus, _extends({}, _obj2)) 68 | }, subHandler(state, action))); 69 | } else { 70 | newState = Object.assign({}, state, _extends({}, subHandler(state, action))); 71 | } 72 | } else if (state.asyncStatus && state.asyncStatus[action.async.name]) { 73 | newState = Object.assign({}, state, _extends({ 74 | asyncStatus: Object.assign({}, state.asyncStatus, _extends({}, _obj2)) 75 | }, subHandlers)); 76 | } else { 77 | newState = Object.assign({}, state, _extends({}, subHandlers)); 78 | } 79 | 80 | return newState; 81 | } 82 | 83 | if (typeof subHandler === 'function') { 84 | if (opts.autoAssign) { 85 | return Object.assign({}, state, subHandler(state, action)); 86 | } 87 | return subHandler(state, action); 88 | } 89 | } 90 | } 91 | return state; 92 | }; 93 | } 94 | 95 | exports.default = createReducer; -------------------------------------------------------------------------------- /src/lib/redux-act-reducer/index.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | exports.createActionAsync = exports.createReducer = exports.createAction = undefined; 7 | 8 | var _createAction = require('./createAction'); 9 | 10 | var _createAction2 = _interopRequireDefault(_createAction); 11 | 12 | var _createReducer = require('./createReducer'); 13 | 14 | var _createReducer2 = _interopRequireDefault(_createReducer); 15 | 16 | var _createActionAsync = require('./createActionAsync'); 17 | 18 | var _createActionAsync2 = _interopRequireDefault(_createActionAsync); 19 | 20 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 21 | 22 | exports.createAction = _createAction2.default; 23 | exports.createReducer = _createReducer2.default; 24 | exports.createActionAsync = _createActionAsync2.default; 25 | -------------------------------------------------------------------------------- /src/lib/redux-immutable.js: -------------------------------------------------------------------------------- 1 | import Immutable from './immutable'; 2 | 3 | const validateNextState = (nextState, reducerName, action) => { 4 | if (nextState === undefined) { 5 | throw new Error(`Reducer ${reducerName} returned undefined when handling ${action.type} action. To ignore an action, you must explicitly return the previous state.`); 6 | } 7 | }; 8 | 9 | const combineReducers = (reducers, getDefaultState = Immutable.Map) => { 10 | const reducerKeys = Object.keys(reducers); 11 | return (inputState = getDefaultState(), action) => inputState 12 | .withMutations((temporaryState) => { 13 | reducerKeys.forEach((reducerName) => { 14 | const reducer = reducers[reducerName]; 15 | const currentDomainState = temporaryState.get(reducerName); 16 | const nextDomainState = reducer(currentDomainState, action); 17 | 18 | validateNextState(nextDomainState, reducerName, action); 19 | 20 | temporaryState.set(reducerName, nextDomainState); 21 | }); 22 | }); 23 | }; 24 | 25 | export { combineReducers }; 26 | -------------------------------------------------------------------------------- /src/lib/redux-thunk.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | exports.__esModule = true; 4 | function createThunkMiddleware(extraArgument) { 5 | return function (_ref) { 6 | var dispatch = _ref.dispatch, 7 | getState = _ref.getState; 8 | return function (next) { 9 | return function (action) { 10 | if (typeof action === 'function') { 11 | return action(dispatch, getState, extraArgument); 12 | } 13 | 14 | return next(action); 15 | }; 16 | }; 17 | }; 18 | } 19 | 20 | var thunk = createThunkMiddleware(); 21 | thunk.withExtraArgument = createThunkMiddleware; 22 | 23 | exports['default'] = thunk; -------------------------------------------------------------------------------- /src/lib/redux.js: -------------------------------------------------------------------------------- 1 | !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.Redux={})}(this,function(e){"use strict";var t=function(e){var t,r=e.Symbol;return"function"==typeof r?r.observable?t=r.observable:(t=r("observable"),r.observable=t):t="@@observable",t}("undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof module?module:Function("return this")()),r=function(){return Math.random().toString(36).substring(7).split("").join(".")},n={INIT:"@@redux/INIT"+r(),REPLACE:"@@redux/REPLACE"+r(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+r()}};function o(e,t){var r=t&&t.type;return"Given "+(r&&'action "'+r+'"'||"an action")+', reducer "'+e+'" 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.'}function i(e,t){return function(){return t(e.apply(this,arguments))}}function u(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(){for(var e=arguments.length,t=Array(e),r=0;e>r;r++)t[r]=arguments[r];return 0===t.length?function(e){return e}:1===t.length?t[0]:t.reduce(function(e,t){return function(){return e(t.apply(void 0,arguments))}})}e.createStore=function e(r,o,i){var u;if("function"==typeof o&&"function"==typeof i||"function"==typeof i&&"function"==typeof arguments[3])throw Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function");if("function"==typeof o&&void 0===i&&(i=o,o=void 0),void 0!==i){if("function"!=typeof i)throw Error("Expected the enhancer to be a function.");return i(e)(r,o)}if("function"!=typeof r)throw Error("Expected the reducer to be a function.");var a=r,c=o,f=[],s=f,d=!1;function l(){s===f&&(s=f.slice())}function p(){if(d)throw 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 c}function h(e){if("function"!=typeof e)throw Error("Expected the listener to be a function.");if(d)throw 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-reference/store#subscribe(listener) for more details.");var t=!0;return l(),s.push(e),function(){if(t){if(d)throw Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api-reference/store#subscribe(listener) for more details.");t=!1,l();var r=s.indexOf(e);s.splice(r,1)}}}function y(e){if(!function(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}(e))throw Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===e.type)throw Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(d)throw Error("Reducers may not dispatch actions.");try{d=!0,c=a(c,e)}finally{d=!1}for(var t=f=s,r=0;t.length>r;r++)(0,t[r])();return e}return y({type:n.INIT}),(u={dispatch:y,subscribe:h,getState:p,replaceReducer:function(e){if("function"!=typeof e)throw Error("Expected the nextReducer to be a function.");a=e,y({type:n.REPLACE})}})[t]=function(){var e,r=h;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new TypeError("Expected the observer to be an object.");function t(){e.next&&e.next(p())}return t(),{unsubscribe:r(t)}}})[t]=function(){return this},e},u},e.combineReducers=function(e){for(var t=Object.keys(e),r={},i=0;t.length>i;i++){var u=t[i];"function"==typeof e[u]&&(r[u]=e[u])}var a,c=Object.keys(r);try{!function(e){Object.keys(e).forEach(function(t){var r=e[t];if(void 0===r(void 0,{type:n.INIT}))throw Error('Reducer "'+t+"\" 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(void 0===r(void 0,{type:n.PROBE_UNKNOWN_ACTION()}))throw Error('Reducer "'+t+"\" returned undefined when probed with a random type. Don't try to handle "+n.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.')})}(r)}catch(e){a=e}return function(e,t){if(void 0===e&&(e={}),a)throw a;for(var n=!1,i={},u=0;c.length>u;u++){var f=c[u],s=e[f],d=(0,r[f])(s,t);if(void 0===d){var l=o(f,t);throw Error(l)}i[f]=d,n=n||d!==s}return n?i:e}},e.bindActionCreators=function(e,t){if("function"==typeof e)return i(e,t);if("object"!=typeof e||null===e)throw Error("bindActionCreators expected an object or a function, instead received "+(null===e?"null":typeof e)+'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');for(var r=Object.keys(e),n={},o=0;r.length>o;o++){var u=r[o],a=e[u];"function"==typeof a&&(n[u]=i(a,t))}return n},e.applyMiddleware=function(){for(var e=arguments.length,t=Array(e),r=0;e>r;r++)t[r]=arguments[r];return function(e){return function(){var r=e.apply(void 0,arguments),n=function(){throw Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},o={getState:r.getState,dispatch:function(){return n.apply(void 0,arguments)}},i=t.map(function(e){return e(o)});return function(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){u(e,t,r[t])})}return e}({},r,{dispatch:n=a.apply(void 0,i)(r.dispatch)})}}},e.compose=a,e.__DO_NOT_USE__ActionTypes=n,Object.defineProperty(e,"__esModule",{value:!0})}); 2 | -------------------------------------------------------------------------------- /src/lib/regenerator-runtime/runtime.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014-present, Facebook, Inc. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | var regeneratorRuntime = (function (exports) { 9 | "use strict"; 10 | 11 | var Op = Object.prototype; 12 | var hasOwn = Op.hasOwnProperty; 13 | var undefined; // More compressible than void 0. 14 | var $Symbol = typeof Symbol === "function" ? Symbol : {}; 15 | var iteratorSymbol = $Symbol.iterator || "@@iterator"; 16 | var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; 17 | var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; 18 | 19 | function wrap(innerFn, outerFn, self, tryLocsList) { 20 | // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. 21 | var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; 22 | var generator = Object.create(protoGenerator.prototype); 23 | var context = new Context(tryLocsList || []); 24 | 25 | // The ._invoke method unifies the implementations of the .next, 26 | // .throw, and .return methods. 27 | generator._invoke = makeInvokeMethod(innerFn, self, context); 28 | 29 | return generator; 30 | } 31 | exports.wrap = wrap; 32 | 33 | // Try/catch helper to minimize deoptimizations. Returns a completion 34 | // record like context.tryEntries[i].completion. This interface could 35 | // have been (and was previously) designed to take a closure to be 36 | // invoked without arguments, but in all the cases we care about we 37 | // already have an existing method we want to call, so there's no need 38 | // to create a new function object. We can even get away with assuming 39 | // the method takes exactly one argument, since that happens to be true 40 | // in every case, so we don't have to touch the arguments object. The 41 | // only additional allocation required is the completion record, which 42 | // has a stable shape and so hopefully should be cheap to allocate. 43 | function tryCatch(fn, obj, arg) { 44 | try { 45 | return { type: "normal", arg: fn.call(obj, arg) }; 46 | } catch (err) { 47 | return { type: "throw", arg: err }; 48 | } 49 | } 50 | 51 | var GenStateSuspendedStart = "suspendedStart"; 52 | var GenStateSuspendedYield = "suspendedYield"; 53 | var GenStateExecuting = "executing"; 54 | var GenStateCompleted = "completed"; 55 | 56 | // Returning this object from the innerFn has the same effect as 57 | // breaking out of the dispatch switch statement. 58 | var ContinueSentinel = {}; 59 | 60 | // Dummy constructor functions that we use as the .constructor and 61 | // .constructor.prototype properties for functions that return Generator 62 | // objects. For full spec compliance, you may wish to configure your 63 | // minifier not to mangle the names of these two functions. 64 | function Generator() {} 65 | function GeneratorFunction() {} 66 | function GeneratorFunctionPrototype() {} 67 | 68 | // This is a polyfill for %IteratorPrototype% for environments that 69 | // don't natively support it. 70 | var IteratorPrototype = {}; 71 | IteratorPrototype[iteratorSymbol] = function () { 72 | return this; 73 | }; 74 | 75 | var getProto = Object.getPrototypeOf; 76 | var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); 77 | if (NativeIteratorPrototype && 78 | NativeIteratorPrototype !== Op && 79 | hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { 80 | // This environment has a native %IteratorPrototype%; use it instead 81 | // of the polyfill. 82 | IteratorPrototype = NativeIteratorPrototype; 83 | } 84 | 85 | var Gp = GeneratorFunctionPrototype.prototype = 86 | Generator.prototype = Object.create(IteratorPrototype); 87 | GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; 88 | GeneratorFunctionPrototype.constructor = GeneratorFunction; 89 | GeneratorFunctionPrototype[toStringTagSymbol] = 90 | GeneratorFunction.displayName = "GeneratorFunction"; 91 | 92 | // Helper for defining the .next, .throw, and .return methods of the 93 | // Iterator interface in terms of a single ._invoke method. 94 | function defineIteratorMethods(prototype) { 95 | ["next", "throw", "return"].forEach(function(method) { 96 | prototype[method] = function(arg) { 97 | return this._invoke(method, arg); 98 | }; 99 | }); 100 | } 101 | 102 | exports.isGeneratorFunction = function(genFun) { 103 | var ctor = typeof genFun === "function" && genFun.constructor; 104 | return ctor 105 | ? ctor === GeneratorFunction || 106 | // For the native GeneratorFunction constructor, the best we can 107 | // do is to check its .name property. 108 | (ctor.displayName || ctor.name) === "GeneratorFunction" 109 | : false; 110 | }; 111 | 112 | exports.mark = function(genFun) { 113 | if (Object.setPrototypeOf) { 114 | Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); 115 | } else { 116 | genFun.__proto__ = GeneratorFunctionPrototype; 117 | if (!(toStringTagSymbol in genFun)) { 118 | genFun[toStringTagSymbol] = "GeneratorFunction"; 119 | } 120 | } 121 | genFun.prototype = Object.create(Gp); 122 | return genFun; 123 | }; 124 | 125 | // Within the body of any async function, `await x` is transformed to 126 | // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test 127 | // `hasOwn.call(value, "__await")` to determine if the yielded value is 128 | // meant to be awaited. 129 | exports.awrap = function(arg) { 130 | return { __await: arg }; 131 | }; 132 | 133 | function AsyncIterator(generator) { 134 | function invoke(method, arg, resolve, reject) { 135 | var record = tryCatch(generator[method], generator, arg); 136 | if (record.type === "throw") { 137 | reject(record.arg); 138 | } else { 139 | var result = record.arg; 140 | var value = result.value; 141 | if (value && 142 | typeof value === "object" && 143 | hasOwn.call(value, "__await")) { 144 | return Promise.resolve(value.__await).then(function(value) { 145 | invoke("next", value, resolve, reject); 146 | }, function(err) { 147 | invoke("throw", err, resolve, reject); 148 | }); 149 | } 150 | 151 | return Promise.resolve(value).then(function(unwrapped) { 152 | // When a yielded Promise is resolved, its final value becomes 153 | // the .value of the Promise<{value,done}> result for the 154 | // current iteration. 155 | result.value = unwrapped; 156 | resolve(result); 157 | }, function(error) { 158 | // If a rejected Promise was yielded, throw the rejection back 159 | // into the async generator function so it can be handled there. 160 | return invoke("throw", error, resolve, reject); 161 | }); 162 | } 163 | } 164 | 165 | var previousPromise; 166 | 167 | function enqueue(method, arg) { 168 | function callInvokeWithMethodAndArg() { 169 | return new Promise(function(resolve, reject) { 170 | invoke(method, arg, resolve, reject); 171 | }); 172 | } 173 | 174 | return previousPromise = 175 | // If enqueue has been called before, then we want to wait until 176 | // all previous Promises have been resolved before calling invoke, 177 | // so that results are always delivered in the correct order. If 178 | // enqueue has not been called before, then it is important to 179 | // call invoke immediately, without waiting on a callback to fire, 180 | // so that the async generator function has the opportunity to do 181 | // any necessary setup in a predictable way. This predictability 182 | // is why the Promise constructor synchronously invokes its 183 | // executor callback, and why async functions synchronously 184 | // execute code before the first await. Since we implement simple 185 | // async functions in terms of async generators, it is especially 186 | // important to get this right, even though it requires care. 187 | previousPromise ? previousPromise.then( 188 | callInvokeWithMethodAndArg, 189 | // Avoid propagating failures to Promises returned by later 190 | // invocations of the iterator. 191 | callInvokeWithMethodAndArg 192 | ) : callInvokeWithMethodAndArg(); 193 | } 194 | 195 | // Define the unified helper method that is used to implement .next, 196 | // .throw, and .return (see defineIteratorMethods). 197 | this._invoke = enqueue; 198 | } 199 | 200 | defineIteratorMethods(AsyncIterator.prototype); 201 | AsyncIterator.prototype[asyncIteratorSymbol] = function () { 202 | return this; 203 | }; 204 | exports.AsyncIterator = AsyncIterator; 205 | 206 | // Note that simple async functions are implemented on top of 207 | // AsyncIterator objects; they just return a Promise for the value of 208 | // the final result produced by the iterator. 209 | exports.async = function(innerFn, outerFn, self, tryLocsList) { 210 | var iter = new AsyncIterator( 211 | wrap(innerFn, outerFn, self, tryLocsList) 212 | ); 213 | 214 | return exports.isGeneratorFunction(outerFn) 215 | ? iter // If outerFn is a generator, return the full iterator. 216 | : iter.next().then(function(result) { 217 | return result.done ? result.value : iter.next(); 218 | }); 219 | }; 220 | 221 | function makeInvokeMethod(innerFn, self, context) { 222 | var state = GenStateSuspendedStart; 223 | 224 | return function invoke(method, arg) { 225 | if (state === GenStateExecuting) { 226 | throw new Error("Generator is already running"); 227 | } 228 | 229 | if (state === GenStateCompleted) { 230 | if (method === "throw") { 231 | throw arg; 232 | } 233 | 234 | // Be forgiving, per 25.3.3.3.3 of the spec: 235 | // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume 236 | return doneResult(); 237 | } 238 | 239 | context.method = method; 240 | context.arg = arg; 241 | 242 | while (true) { 243 | var delegate = context.delegate; 244 | if (delegate) { 245 | var delegateResult = maybeInvokeDelegate(delegate, context); 246 | if (delegateResult) { 247 | if (delegateResult === ContinueSentinel) continue; 248 | return delegateResult; 249 | } 250 | } 251 | 252 | if (context.method === "next") { 253 | // Setting context._sent for legacy support of Babel's 254 | // function.sent implementation. 255 | context.sent = context._sent = context.arg; 256 | 257 | } else if (context.method === "throw") { 258 | if (state === GenStateSuspendedStart) { 259 | state = GenStateCompleted; 260 | throw context.arg; 261 | } 262 | 263 | context.dispatchException(context.arg); 264 | 265 | } else if (context.method === "return") { 266 | context.abrupt("return", context.arg); 267 | } 268 | 269 | state = GenStateExecuting; 270 | 271 | var record = tryCatch(innerFn, self, context); 272 | if (record.type === "normal") { 273 | // If an exception is thrown from innerFn, we leave state === 274 | // GenStateExecuting and loop back for another invocation. 275 | state = context.done 276 | ? GenStateCompleted 277 | : GenStateSuspendedYield; 278 | 279 | if (record.arg === ContinueSentinel) { 280 | continue; 281 | } 282 | 283 | return { 284 | value: record.arg, 285 | done: context.done 286 | }; 287 | 288 | } else if (record.type === "throw") { 289 | state = GenStateCompleted; 290 | // Dispatch the exception by looping back around to the 291 | // context.dispatchException(context.arg) call above. 292 | context.method = "throw"; 293 | context.arg = record.arg; 294 | } 295 | } 296 | }; 297 | } 298 | 299 | // Call delegate.iterator[context.method](context.arg) and handle the 300 | // result, either by returning a { value, done } result from the 301 | // delegate iterator, or by modifying context.method and context.arg, 302 | // setting context.delegate to null, and returning the ContinueSentinel. 303 | function maybeInvokeDelegate(delegate, context) { 304 | var method = delegate.iterator[context.method]; 305 | if (method === undefined) { 306 | // A .throw or .return when the delegate iterator has no .throw 307 | // method always terminates the yield* loop. 308 | context.delegate = null; 309 | 310 | if (context.method === "throw") { 311 | // Note: ["return"] must be used for ES3 parsing compatibility. 312 | if (delegate.iterator["return"]) { 313 | // If the delegate iterator has a return method, give it a 314 | // chance to clean up. 315 | context.method = "return"; 316 | context.arg = undefined; 317 | maybeInvokeDelegate(delegate, context); 318 | 319 | if (context.method === "throw") { 320 | // If maybeInvokeDelegate(context) changed context.method from 321 | // "return" to "throw", let that override the TypeError below. 322 | return ContinueSentinel; 323 | } 324 | } 325 | 326 | context.method = "throw"; 327 | context.arg = new TypeError( 328 | "The iterator does not provide a 'throw' method"); 329 | } 330 | 331 | return ContinueSentinel; 332 | } 333 | 334 | var record = tryCatch(method, delegate.iterator, context.arg); 335 | 336 | if (record.type === "throw") { 337 | context.method = "throw"; 338 | context.arg = record.arg; 339 | context.delegate = null; 340 | return ContinueSentinel; 341 | } 342 | 343 | var info = record.arg; 344 | 345 | if (! info) { 346 | context.method = "throw"; 347 | context.arg = new TypeError("iterator result is not an object"); 348 | context.delegate = null; 349 | return ContinueSentinel; 350 | } 351 | 352 | if (info.done) { 353 | // Assign the result of the finished delegate to the temporary 354 | // variable specified by delegate.resultName (see delegateYield). 355 | context[delegate.resultName] = info.value; 356 | 357 | // Resume execution at the desired location (see delegateYield). 358 | context.next = delegate.nextLoc; 359 | 360 | // If context.method was "throw" but the delegate handled the 361 | // exception, let the outer generator proceed normally. If 362 | // context.method was "next", forget context.arg since it has been 363 | // "consumed" by the delegate iterator. If context.method was 364 | // "return", allow the original .return call to continue in the 365 | // outer generator. 366 | if (context.method !== "return") { 367 | context.method = "next"; 368 | context.arg = undefined; 369 | } 370 | 371 | } else { 372 | // Re-yield the result returned by the delegate method. 373 | return info; 374 | } 375 | 376 | // The delegate iterator is finished, so forget it and continue with 377 | // the outer generator. 378 | context.delegate = null; 379 | return ContinueSentinel; 380 | } 381 | 382 | // Define Generator.prototype.{next,throw,return} in terms of the 383 | // unified ._invoke helper method. 384 | defineIteratorMethods(Gp); 385 | 386 | Gp[toStringTagSymbol] = "Generator"; 387 | 388 | // A Generator should always return itself as the iterator object when the 389 | // @@iterator function is called on it. Some browsers' implementations of the 390 | // iterator prototype chain incorrectly implement this, causing the Generator 391 | // object to not be returned from this call. This ensures that doesn't happen. 392 | // See https://github.com/facebook/regenerator/issues/274 for more details. 393 | Gp[iteratorSymbol] = function() { 394 | return this; 395 | }; 396 | 397 | Gp.toString = function() { 398 | return "[object Generator]"; 399 | }; 400 | 401 | function pushTryEntry(locs) { 402 | var entry = { tryLoc: locs[0] }; 403 | 404 | if (1 in locs) { 405 | entry.catchLoc = locs[1]; 406 | } 407 | 408 | if (2 in locs) { 409 | entry.finallyLoc = locs[2]; 410 | entry.afterLoc = locs[3]; 411 | } 412 | 413 | this.tryEntries.push(entry); 414 | } 415 | 416 | function resetTryEntry(entry) { 417 | var record = entry.completion || {}; 418 | record.type = "normal"; 419 | delete record.arg; 420 | entry.completion = record; 421 | } 422 | 423 | function Context(tryLocsList) { 424 | // The root entry object (effectively a try statement without a catch 425 | // or a finally block) gives us a place to store values thrown from 426 | // locations where there is no enclosing try statement. 427 | this.tryEntries = [{ tryLoc: "root" }]; 428 | tryLocsList.forEach(pushTryEntry, this); 429 | this.reset(true); 430 | } 431 | 432 | exports.keys = function(object) { 433 | var keys = []; 434 | for (var key in object) { 435 | keys.push(key); 436 | } 437 | keys.reverse(); 438 | 439 | // Rather than returning an object with a next method, we keep 440 | // things simple and return the next function itself. 441 | return function next() { 442 | while (keys.length) { 443 | var key = keys.pop(); 444 | if (key in object) { 445 | next.value = key; 446 | next.done = false; 447 | return next; 448 | } 449 | } 450 | 451 | // To avoid creating an additional object, we just hang the .value 452 | // and .done properties off the next function object itself. This 453 | // also ensures that the minifier will not anonymize the function. 454 | next.done = true; 455 | return next; 456 | }; 457 | }; 458 | 459 | function values(iterable) { 460 | if (iterable) { 461 | var iteratorMethod = iterable[iteratorSymbol]; 462 | if (iteratorMethod) { 463 | return iteratorMethod.call(iterable); 464 | } 465 | 466 | if (typeof iterable.next === "function") { 467 | return iterable; 468 | } 469 | 470 | if (!isNaN(iterable.length)) { 471 | var i = -1, next = function next() { 472 | while (++i < iterable.length) { 473 | if (hasOwn.call(iterable, i)) { 474 | next.value = iterable[i]; 475 | next.done = false; 476 | return next; 477 | } 478 | } 479 | 480 | next.value = undefined; 481 | next.done = true; 482 | 483 | return next; 484 | }; 485 | 486 | return next.next = next; 487 | } 488 | } 489 | 490 | // Return an iterator with no values. 491 | return { next: doneResult }; 492 | } 493 | exports.values = values; 494 | 495 | function doneResult() { 496 | return { value: undefined, done: true }; 497 | } 498 | 499 | Context.prototype = { 500 | constructor: Context, 501 | 502 | reset: function(skipTempReset) { 503 | this.prev = 0; 504 | this.next = 0; 505 | // Resetting context._sent for legacy support of Babel's 506 | // function.sent implementation. 507 | this.sent = this._sent = undefined; 508 | this.done = false; 509 | this.delegate = null; 510 | 511 | this.method = "next"; 512 | this.arg = undefined; 513 | 514 | this.tryEntries.forEach(resetTryEntry); 515 | 516 | if (!skipTempReset) { 517 | for (var name in this) { 518 | // Not sure about the optimal order of these conditions: 519 | if (name.charAt(0) === "t" && 520 | hasOwn.call(this, name) && 521 | !isNaN(+name.slice(1))) { 522 | this[name] = undefined; 523 | } 524 | } 525 | } 526 | }, 527 | 528 | stop: function() { 529 | this.done = true; 530 | 531 | var rootEntry = this.tryEntries[0]; 532 | var rootRecord = rootEntry.completion; 533 | if (rootRecord.type === "throw") { 534 | throw rootRecord.arg; 535 | } 536 | 537 | return this.rval; 538 | }, 539 | 540 | dispatchException: function(exception) { 541 | if (this.done) { 542 | throw exception; 543 | } 544 | 545 | var context = this; 546 | function handle(loc, caught) { 547 | record.type = "throw"; 548 | record.arg = exception; 549 | context.next = loc; 550 | 551 | if (caught) { 552 | // If the dispatched exception was caught by a catch block, 553 | // then let that catch block handle the exception normally. 554 | context.method = "next"; 555 | context.arg = undefined; 556 | } 557 | 558 | return !! caught; 559 | } 560 | 561 | for (var i = this.tryEntries.length - 1; i >= 0; --i) { 562 | var entry = this.tryEntries[i]; 563 | var record = entry.completion; 564 | 565 | if (entry.tryLoc === "root") { 566 | // Exception thrown outside of any try block that could handle 567 | // it, so set the completion value of the entire function to 568 | // throw the exception. 569 | return handle("end"); 570 | } 571 | 572 | if (entry.tryLoc <= this.prev) { 573 | var hasCatch = hasOwn.call(entry, "catchLoc"); 574 | var hasFinally = hasOwn.call(entry, "finallyLoc"); 575 | 576 | if (hasCatch && hasFinally) { 577 | if (this.prev < entry.catchLoc) { 578 | return handle(entry.catchLoc, true); 579 | } else if (this.prev < entry.finallyLoc) { 580 | return handle(entry.finallyLoc); 581 | } 582 | 583 | } else if (hasCatch) { 584 | if (this.prev < entry.catchLoc) { 585 | return handle(entry.catchLoc, true); 586 | } 587 | 588 | } else if (hasFinally) { 589 | if (this.prev < entry.finallyLoc) { 590 | return handle(entry.finallyLoc); 591 | } 592 | 593 | } else { 594 | throw new Error("try statement without catch or finally"); 595 | } 596 | } 597 | } 598 | }, 599 | 600 | abrupt: function(type, arg) { 601 | for (var i = this.tryEntries.length - 1; i >= 0; --i) { 602 | var entry = this.tryEntries[i]; 603 | if (entry.tryLoc <= this.prev && 604 | hasOwn.call(entry, "finallyLoc") && 605 | this.prev < entry.finallyLoc) { 606 | var finallyEntry = entry; 607 | break; 608 | } 609 | } 610 | 611 | if (finallyEntry && 612 | (type === "break" || 613 | type === "continue") && 614 | finallyEntry.tryLoc <= arg && 615 | arg <= finallyEntry.finallyLoc) { 616 | // Ignore the finally entry if control is not jumping to a 617 | // location outside the try/catch block. 618 | finallyEntry = null; 619 | } 620 | 621 | var record = finallyEntry ? finallyEntry.completion : {}; 622 | record.type = type; 623 | record.arg = arg; 624 | 625 | if (finallyEntry) { 626 | this.method = "next"; 627 | this.next = finallyEntry.finallyLoc; 628 | return ContinueSentinel; 629 | } 630 | 631 | return this.complete(record); 632 | }, 633 | 634 | complete: function(record, afterLoc) { 635 | if (record.type === "throw") { 636 | throw record.arg; 637 | } 638 | 639 | if (record.type === "break" || 640 | record.type === "continue") { 641 | this.next = record.arg; 642 | } else if (record.type === "return") { 643 | this.rval = this.arg = record.arg; 644 | this.method = "return"; 645 | this.next = "end"; 646 | } else if (record.type === "normal" && afterLoc) { 647 | this.next = afterLoc; 648 | } 649 | 650 | return ContinueSentinel; 651 | }, 652 | 653 | finish: function(finallyLoc) { 654 | for (var i = this.tryEntries.length - 1; i >= 0; --i) { 655 | var entry = this.tryEntries[i]; 656 | if (entry.finallyLoc === finallyLoc) { 657 | this.complete(entry.completion, entry.afterLoc); 658 | resetTryEntry(entry); 659 | return ContinueSentinel; 660 | } 661 | } 662 | }, 663 | 664 | "catch": function(tryLoc) { 665 | for (var i = this.tryEntries.length - 1; i >= 0; --i) { 666 | var entry = this.tryEntries[i]; 667 | if (entry.tryLoc === tryLoc) { 668 | var record = entry.completion; 669 | if (record.type === "throw") { 670 | var thrown = record.arg; 671 | resetTryEntry(entry); 672 | } 673 | return thrown; 674 | } 675 | } 676 | 677 | // The context.catch method must only be called with a location 678 | // argument that corresponds to a known catch block. 679 | throw new Error("illegal catch attempt"); 680 | }, 681 | 682 | delegateYield: function(iterable, resultName, nextLoc) { 683 | this.delegate = { 684 | iterator: values(iterable), 685 | resultName: resultName, 686 | nextLoc: nextLoc 687 | }; 688 | 689 | if (this.method === "next") { 690 | // Deliberately forget the last sent value so that we don't 691 | // accidentally pass it on to the delegate. 692 | this.arg = undefined; 693 | } 694 | 695 | return ContinueSentinel; 696 | } 697 | }; 698 | 699 | // Regardless of whether this script is executing as a CommonJS module 700 | // or not, return the runtime object so that we can declare the variable 701 | // regeneratorRuntime in the outer scope, which allows this module to be 702 | // injected easily by `bin/regenerator --include-runtime script.js`. 703 | return exports; 704 | 705 | }( 706 | // If this script is executing as a CommonJS module, use module.exports 707 | // as the regeneratorRuntime namespace. Otherwise create a new empty 708 | // object. Either way, the resulting object will be used to initialize 709 | // the regeneratorRuntime variable at the top of this file. 710 | typeof module === "object" ? module.exports : {} 711 | )); 712 | -------------------------------------------------------------------------------- /src/lib/reselect.js: -------------------------------------------------------------------------------- 1 | (function (global, factory) { 2 | if (typeof define === "function" && define.amd) { 3 | define('Reselect', ['exports'], factory); 4 | } else if (typeof exports !== "undefined") { 5 | factory(exports); 6 | } else { 7 | var mod = { 8 | exports: {} 9 | }; 10 | factory(mod.exports); 11 | global.Reselect = mod.exports; 12 | } 13 | })(this, function (exports) { 14 | 'use strict'; 15 | 16 | exports.__esModule = true; 17 | exports.defaultMemoize = defaultMemoize; 18 | exports.createSelectorCreator = createSelectorCreator; 19 | exports.createStructuredSelector = createStructuredSelector; 20 | function defaultEqualityCheck(a, b) { 21 | return a === b; 22 | } 23 | 24 | function areArgumentsShallowlyEqual(equalityCheck, prev, next) { 25 | if (prev === null || next === null || prev.length !== next.length) { 26 | return false; 27 | } 28 | 29 | // Do this in a for loop (and not a `forEach` or an `every`) so we can determine equality as fast as possible. 30 | var length = prev.length; 31 | for (var i = 0; i < length; i++) { 32 | if (!equalityCheck(prev[i], next[i])) { 33 | return false; 34 | } 35 | } 36 | 37 | return true; 38 | } 39 | 40 | function defaultMemoize(func) { 41 | var equalityCheck = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultEqualityCheck; 42 | 43 | var lastArgs = null; 44 | var lastResult = null; 45 | // we reference arguments instead of spreading them for performance reasons 46 | return function () { 47 | if (!areArgumentsShallowlyEqual(equalityCheck, lastArgs, arguments)) { 48 | // apply arguments instead of spreading for performance. 49 | lastResult = func.apply(null, arguments); 50 | } 51 | 52 | lastArgs = arguments; 53 | return lastResult; 54 | }; 55 | } 56 | 57 | function getDependencies(funcs) { 58 | var dependencies = Array.isArray(funcs[0]) ? funcs[0] : funcs; 59 | 60 | if (!dependencies.every(function (dep) { 61 | return typeof dep === 'function'; 62 | })) { 63 | var dependencyTypes = dependencies.map(function (dep) { 64 | return typeof dep; 65 | }).join(', '); 66 | throw new Error('Selector creators expect all input-selectors to be functions, ' + ('instead received the following types: [' + dependencyTypes + ']')); 67 | } 68 | 69 | return dependencies; 70 | } 71 | 72 | function createSelectorCreator(memoize) { 73 | for (var _len = arguments.length, memoizeOptions = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 74 | memoizeOptions[_key - 1] = arguments[_key]; 75 | } 76 | 77 | return function () { 78 | for (var _len2 = arguments.length, funcs = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 79 | funcs[_key2] = arguments[_key2]; 80 | } 81 | 82 | var recomputations = 0; 83 | var resultFunc = funcs.pop(); 84 | var dependencies = getDependencies(funcs); 85 | 86 | var memoizedResultFunc = memoize.apply(undefined, [function () { 87 | recomputations++; 88 | // apply arguments instead of spreading for performance. 89 | return resultFunc.apply(null, arguments); 90 | }].concat(memoizeOptions)); 91 | 92 | // If a selector is called with the exact same arguments we don't need to traverse our dependencies again. 93 | var selector = memoize(function () { 94 | var params = []; 95 | var length = dependencies.length; 96 | 97 | for (var i = 0; i < length; i++) { 98 | // apply arguments instead of spreading and mutate a local list of params for performance. 99 | params.push(dependencies[i].apply(null, arguments)); 100 | } 101 | 102 | // apply arguments instead of spreading for performance. 103 | return memoizedResultFunc.apply(null, params); 104 | }); 105 | 106 | selector.resultFunc = resultFunc; 107 | selector.dependencies = dependencies; 108 | selector.recomputations = function () { 109 | return recomputations; 110 | }; 111 | selector.resetRecomputations = function () { 112 | return recomputations = 0; 113 | }; 114 | return selector; 115 | }; 116 | } 117 | 118 | var createSelector = exports.createSelector = createSelectorCreator(defaultMemoize); 119 | 120 | function createStructuredSelector(selectors) { 121 | var selectorCreator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : createSelector; 122 | 123 | if (typeof selectors !== 'object') { 124 | throw new Error('createStructuredSelector expects first argument to be an object ' + ('where each property is a selector, instead received a ' + typeof selectors)); 125 | } 126 | var objectKeys = Object.keys(selectors); 127 | return selectorCreator(objectKeys.map(function (key) { 128 | return selectors[key]; 129 | }), function () { 130 | for (var _len3 = arguments.length, values = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { 131 | values[_key3] = arguments[_key3]; 132 | } 133 | 134 | return values.reduce(function (composition, value, index) { 135 | composition[objectKeys[index]] = value; 136 | return composition; 137 | }, {}); 138 | }); 139 | } 140 | }); 141 | -------------------------------------------------------------------------------- /src/lib/wx-app-redux/index.js: -------------------------------------------------------------------------------- 1 | import { bindActionCreators } from '../redux'; 2 | 3 | const hasOwn = Object.prototype.hasOwnProperty; 4 | 5 | const is = (x, y) => { 6 | if (x === y) { 7 | return x !== 0 || y !== 0 || 1 / x === 1 / y; 8 | } 9 | return x !== x && y !== y; 10 | }; 11 | 12 | const shallowEqual = (objA, objB) => { 13 | if (is(objA, objB)) return true; 14 | 15 | if (typeof objA !== 'object' || objA === null || 16 | typeof objB !== 'object' || objB === null) { 17 | return false; 18 | } 19 | 20 | const keysA = Object.keys(objA); 21 | const keysB = Object.keys(objB); 22 | 23 | if (keysA.length !== keysB.length) return false; 24 | 25 | for (let i = 0; i < keysA.length; i++) { 26 | if (!hasOwn.call(objB, keysA[i]) || 27 | !is(objA[keysA[i]], objB[keysA[i]])) { 28 | return false; 29 | } 30 | } 31 | 32 | return true; 33 | }; 34 | 35 | const defaultMapStateToProps = () => ({}); 36 | const defaultMapDispatchToProps = dispatch => ({ dispatch }); 37 | 38 | const createConnect = (mapStateToProps, mapDispatchToProps) => { 39 | const app = getApp(); 40 | const mapState = mapStateToProps || defaultMapStateToProps; 41 | const mapDispatch = mapDispatchToProps && typeof mapDispatchToProps === 'object' ? 42 | dispatch => bindActionCreators(mapDispatchToProps, dispatch) : defaultMapDispatchToProps; 43 | 44 | return (page) => { 45 | function onStateChange() { 46 | if (this.unsubscribe) { 47 | const state = app.store.getState(); 48 | const mappedState = mapState(state); 49 | if (!shallowEqual(this.data, mappedState)) { 50 | this.setData(mappedState); 51 | if (page.onStateChange && typeof page.onStateChange === 'function') page.onStateChange.call(this); 52 | } 53 | } 54 | } 55 | 56 | function onLoad(options) { 57 | const isMapStateToProps = Boolean(mapStateToProps); 58 | if (isMapStateToProps) { 59 | this.unsubscribe = app.store.subscribe(onStateChange.bind(this)); 60 | onStateChange.apply(this); 61 | } 62 | if (page.onLoad && typeof page.onLoad === 'function') page.onLoad.call(this, options); 63 | } 64 | 65 | function onUnload() { 66 | if (page.onUnload && typeof page.onUnload === 'function') page.onUnload.call(this); 67 | if (this.unsubscribe) { 68 | this.unsubscribe(); 69 | this.unsubscribe = null; 70 | } 71 | } 72 | 73 | return Object.assign({}, page, mapDispatch(app.store.dispatch), { onLoad, onUnload }); 74 | }; 75 | }; 76 | 77 | module.exports = { 78 | connect: createConnect 79 | }; 80 | -------------------------------------------------------------------------------- /src/pages/about/about.css: -------------------------------------------------------------------------------- 1 | .content { 2 | text-align: left; 3 | margin: 40rpx; 4 | line-height: 20px; 5 | font-size: 16px; 6 | } 7 | -------------------------------------------------------------------------------- /src/pages/about/about.js: -------------------------------------------------------------------------------- 1 | Page({}); 2 | -------------------------------------------------------------------------------- /src/pages/about/about.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "About" 3 | } 4 | -------------------------------------------------------------------------------- /src/pages/about/about.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 微信小程序开发脚手架 (Redux, Immutable-js, Reselect, Babel, ESLint, Stylelint, Gulp ... ) 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/pages/index/actions.js: -------------------------------------------------------------------------------- 1 | import { createAction, createActionAsync } from '../../lib/redux-act-reducer/index'; 2 | import { showMoviesApi } from './api'; 3 | 4 | const prefix = 'HOME'; 5 | 6 | export const SHOW_HELLO = `${prefix}_SHOW_HELLO`; 7 | export const SHOW_MOVIES_ASYNC = `${prefix}_SHOW_MOVIES_ASYNC`; 8 | 9 | export const showHello = createAction(SHOW_HELLO, 'info'); 10 | export const showMoviesAsync = createActionAsync(SHOW_MOVIES_ASYNC, showMoviesApi); 11 | -------------------------------------------------------------------------------- /src/pages/index/api.js: -------------------------------------------------------------------------------- 1 | import request from '../../utils/request'; 2 | import regeneratorRuntime from '../../lib/regenerator-runtime/runtime'; 3 | 4 | const showMoviesApi = async () => { 5 | try { 6 | const res = await request({ 7 | url: 'https://raw.githubusercontent.com/ihahoo/doc/master/MoviesExample.json', 8 | method: 'GET', 9 | }); 10 | return Promise.resolve(res); 11 | } catch (err) { 12 | return Promise.reject(err); 13 | } 14 | }; 15 | 16 | export { showMoviesApi }; 17 | -------------------------------------------------------------------------------- /src/pages/index/index.css: -------------------------------------------------------------------------------- 1 | .info { 2 | display: flex; 3 | flex-direction: column; 4 | align-items: center; 5 | } 6 | 7 | .info-logo { 8 | width: 150rpx; 9 | margin: 20rpx; 10 | } 11 | 12 | .info-name { 13 | color: #aaa; 14 | } 15 | 16 | .txt { 17 | display: flex; 18 | flex-direction: column; 19 | align-items: center; 20 | margin: 200px 20px 0; 21 | line-height: 30px; 22 | } 23 | -------------------------------------------------------------------------------- /src/pages/index/index.js: -------------------------------------------------------------------------------- 1 | import { showHello, showMoviesAsync } from './actions'; 2 | import { connect } from '../../lib/wx-app-redux/index'; 3 | import { selectHome, selectMoviesTotal } from './selectors'; 4 | 5 | const page = { 6 | data: { 7 | motto: '请关闭开发者工具“ES6转ES5”' 8 | }, 9 | bindViewTap() { 10 | wx.navigateTo({ 11 | url: '../about/about' 12 | }); 13 | }, 14 | onLoad() { 15 | const { dispatch } = this; 16 | dispatch(showHello('Hello World')); 17 | dispatch(showMoviesAsync()); 18 | } 19 | }; 20 | 21 | const mapState = state => ({ 22 | home: selectHome(state), 23 | moviesTotal: selectMoviesTotal(state) 24 | }); 25 | 26 | Page(connect(mapState)(page)); 27 | -------------------------------------------------------------------------------- /src/pages/index/index.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | wxapp-boilerplate 5 | 6 | 7 | {{motto}} 8 | 异步获取的数据:(电影数量{{moviesTotal}}) 9 | {{home.info}} 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/pages/index/reducer.js: -------------------------------------------------------------------------------- 1 | import { fromJS } from '../../lib/immutable'; 2 | import { createReducer } from '../../lib/redux-act-reducer/index'; 3 | import { SHOW_HELLO, SHOW_MOVIES_ASYNC } from './actions'; 4 | 5 | const defaultState = fromJS({ 6 | info: 'hello', 7 | isFetching: false, 8 | error: undefined, 9 | moviesTotal: 0 10 | }); 11 | 12 | export default createReducer({ 13 | [SHOW_HELLO](state, action) { 14 | return state.set('info', action.info); 15 | }, 16 | [SHOW_MOVIES_ASYNC](state, action) { 17 | return { 18 | 'REQUEST'() { 19 | return state.merge({ 20 | isFetching: true, 21 | error: undefined 22 | }); 23 | }, 24 | 'SUCCESS'() { 25 | return state.merge({ 26 | isFetching: false, 27 | error: undefined, 28 | moviesTotal: action.res.body.total 29 | }); 30 | }, 31 | 'FAILURE'() { 32 | return state.merge({ 33 | isFetching: false, 34 | error: action.err.errmsg 35 | }); 36 | } 37 | }; 38 | }, 39 | }, defaultState); 40 | -------------------------------------------------------------------------------- /src/pages/index/selectors.js: -------------------------------------------------------------------------------- 1 | import { createSelector } from '../../lib/reselect'; 2 | 3 | const selectHome = state => state.get('home'); 4 | 5 | const selectMoviesTotal = createSelector( 6 | selectHome, 7 | homeState => homeState.get('moviesTotal') 8 | ); 9 | 10 | export { selectHome, selectMoviesTotal }; 11 | -------------------------------------------------------------------------------- /src/reducers.js: -------------------------------------------------------------------------------- 1 | import { combineReducers } from './lib/redux-immutable'; 2 | import home from './pages/index/reducer'; 3 | 4 | const rootReducer = combineReducers({ 5 | home, 6 | }); 7 | 8 | export default rootReducer; 9 | -------------------------------------------------------------------------------- /src/sitemap.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules":[ 3 | { 4 | "action": "allow", 5 | "page": "pages/index/index" 6 | }, 7 | { 8 | "action": "allow", 9 | "page": "pages/about/about" 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /src/store.js: -------------------------------------------------------------------------------- 1 | import { fromJS } from './lib/immutable'; 2 | import { createStore, applyMiddleware, compose } from './lib/redux'; 3 | import thunk from './lib/redux-thunk'; 4 | import rootReducer from './reducers'; 5 | 6 | const configureStore = (initialState = {}) => { 7 | const middleware = compose( 8 | applyMiddleware(thunk) 9 | ); 10 | 11 | const store = createStore(rootReducer, fromJS(initialState), middleware); 12 | return store; 13 | }; 14 | 15 | export default configureStore; 16 | -------------------------------------------------------------------------------- /src/utils/request.js: -------------------------------------------------------------------------------- 1 | const makeOptions = (url, options) => { 2 | const defaultoptions = { 3 | url: undefined, 4 | method: 'GET', 5 | qs: undefined, 6 | body: undefined, 7 | headers: undefined, 8 | type: 'json', 9 | contentType: 'application/json', 10 | crossOrigin: true, 11 | credentials: undefined 12 | }; 13 | 14 | let thisoptions = {}; 15 | if (!options) { 16 | thisoptions = url; 17 | } else { 18 | thisoptions = options; 19 | if (url) { 20 | thisoptions.url = url; 21 | } 22 | } 23 | thisoptions = Object.assign({}, defaultoptions, thisoptions); 24 | 25 | return thisoptions; 26 | }; 27 | 28 | const addQs = (url, qs) => { 29 | let queryString = ''; 30 | let newUrl = url; 31 | if (qs && typeof qs === 'object') { 32 | /* eslint no-restricted-syntax: 0 */ 33 | for (const k of Object.keys(qs)) { 34 | queryString += `&${k}=${qs[k]}`; 35 | } 36 | if (queryString.length > 0) { 37 | if (url.split('?').length < 2) { 38 | queryString = queryString.substring(1); 39 | } else if (url.split('?')[1].length === 0) { 40 | queryString = queryString.substring(1); 41 | } 42 | } 43 | 44 | if (url.indexOf('?') === -1) { 45 | newUrl = `${url}?${queryString}`; 46 | } else { 47 | newUrl = `${url}${queryString}`; 48 | } 49 | } 50 | 51 | return newUrl; 52 | }; 53 | 54 | const request = (url, options) => { 55 | const opts = makeOptions(url, options); 56 | const { method, body, headers, qs, type, contentType } = opts; 57 | 58 | let requestUrl = opts.url; 59 | if (qs) requestUrl = addQs(requestUrl, qs); 60 | 61 | let header = headers; 62 | if ((!headers || !headers['content-type']) && contentType) { 63 | header = Object.assign({}, headers, { 'content-type': contentType }); 64 | } 65 | return new Promise((resolve, reject) => { 66 | wx.request({ 67 | url: requestUrl, 68 | method, 69 | data: body, 70 | header, 71 | dataType: type, 72 | success: (response) => { 73 | let res = { 74 | status: response.statusCode, 75 | statusText: response.errMsg, 76 | body: response.data 77 | }; 78 | if (response.statusCode < 200 || response.statusCode >= 300) { 79 | let errors = { 80 | errcode: response.statusCode, 81 | errmsg: response.errMsg 82 | }; 83 | if (response.data && typeof response.data === 'object') { 84 | errors = Object.assign({}, errors, response.data); 85 | } 86 | if (response.data && typeof response.data === 'string') { 87 | errors = Object.assign({}, errors, { errmsg: response.data }); 88 | } 89 | res = Object.assign({}, res, errors); 90 | reject(res); 91 | } 92 | 93 | resolve(res); 94 | }, 95 | fail: (err) => { 96 | reject({ status: 0, statusText: '', errcode: -1, errmsg: `${err.errMsg}` }); 97 | } 98 | }); 99 | }); 100 | }; 101 | 102 | export default request; 103 | --------------------------------------------------------------------------------