diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..da969d2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Tuya + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..8e13484 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Tuya_Wechat_Devtools +This project is developed using Tuya SDK, which enables you to quickly develop branded apps connecting and controlling smart scenarios of many devices.For more information, please check Tuya Developer Website. + +![智能插座open.png](https://github.com/1115332213/tuya_project/raw/main/image/open.png) +![智能插座close.png](https://github.com/1115332213/tuya_project/raw/main/image/close.png) \ No newline at end of file diff --git a/README.zh.md b/README.zh.md new file mode 100644 index 0000000..2865fb0 --- /dev/null +++ b/README.zh.md @@ -0,0 +1,80 @@ + +## 注意:当前仓库继承自即将被废弃的涂鸦Github仓库:xxxxxx,请使用当前 Github 仓库进行涂鸦 SDK相关开发。更换远程Github仓库URL的教程,可以参考:https://github.com/TuyaInc/tuya-weapp-demo + +## 概述 + +这个一个简易版快速接入[涂鸦的小程序 SDK](https://developer.tuya.com/cn/docs/iot/app-development/mini-programs/overview/applet-ecology?id=K9ptacgp94o5d),[配网插件](https://developer.tuya.com/cn/docs/iot/app-development/mini-programs/tuya-applet-with-web-plugin/distribution-network-plugin?id=K9lq218xn0wn8) 和 MQTT 的连接的Demo,目前趋于稳定。后续还会有新功能的更新。 + +## 体验 + +如果需要在自己的小程序中嵌入小程序配网的功能,可以通过接入小程序 SDK,获取自己的票据信息,然后调用小程序插件,完成配网,配网成功后重新调用获取设备信息的接口即可。 + +如果需要在自己的小程序中开发设备控制,场景联动、自动化等功能,可以通过小程序 SDK 调用相应的接口即可。 + +如果需要涂鸦公版小程序来支持您的设备,可以联系我们。公版小程序的您可以扫码下面的二维码体验: + +

+ +

+ +如果在设备列表中显示没有设备,可以点击 “添加设备”,选择“扫码配网”,扫描下面的二维码,即可体验设备。 +

+ +

香薰机

+

+ +

+ +

空气净化器

+

+ +

+ +

空调

+

+ +

+ +

窗帘电机

+

+ +

+ +

智能灯

+

+ +## Demo 目录 + +``` +├── cloudfunctions // 云函数目录 +│   ├── ty-service // SDK +├── miniprogram // 小程序主目录 +│   ├── image // 图片库 +│   ├── libs // 第三方库 +│   ├── pages // 具体页面的目录 +│   ├── app.js // 小程序入口 +│   ├── app.json // 配置文件 +├── project.config.json // 项目配置文件 +└── README.md // 说明文件 +``` + +## Demo 说明 + +- 设备配网: + + 直接点击按钮进行配网:目前支持 AP 配网、扫码配网、蓝牙配网、zigbee 配网 + +- 体验设备功能: + + 添加设备完成后,可以点击设备开启开关进行设备 MQTT 消息推送调试,建议先使用 api.js 文件中的 getDeviceSpecifications 函数获取指令集,防止出现 dp 点字段名称可能不一致的情况。正常下发指令后页面上会显示出推送消息的内容 + +- 完整版Demo + 目前支持设备控制,消息推送,添加设备(配网), 家庭模块 + +## 技术支持 + +

+ drawing +

+ + 文档看了这么多,还是有很多疑问?需要有技术支持?对我们的小程序有建议?有吐槽?有需求?可以添加上面的微信为好友,随时答疑解惑(验证消息中写明:技术交流,不然没法通过)。 \ No newline at end of file diff --git a/app.js b/app.js new file mode 100644 index 0000000..a1f012c --- /dev/null +++ b/app.js @@ -0,0 +1,23 @@ +//app.js +import wxMqtt from './utils/mqtt/wxMqtt' +import { Provider } from './libs/wechat-weapp-redux.min'; +import { configStore } from './utils/store/store'; + +const store = configStore(); + +App(Provider(store)({ + onLaunch: async function() { + // wx.cloud.init() + // wxMqtt.connectMqtt() + + wxMqtt.on('close', (errorMsg) => { + wxMqtt.connectMqtt() + console.log('errorMsg: mqttClose', errorMsg); + }) + + wxMqtt.on('error', (errorMsg) => { + wxMqtt.connectMqtt() + console.log('errorMsg: mqttError', errorMsg); + }) + } +})) \ No newline at end of file diff --git a/app.json b/app.json new file mode 100644 index 0000000..10a7981 --- /dev/null +++ b/app.json @@ -0,0 +1,25 @@ +{ + "pages": [ + "pages/guide/index", + "pages/home_center/device_list/index", + "pages/home_center/common_panel/index", + "pages/home_center/device_manage/index", + "pages/cloud_check/index", + "pages/function_center/device_connect/index", + "pages/web_view/index", + "pages/base_function/index" + ], + "window": { + "backgroundTextStyle": "light", + "navigationBarBackgroundColor": "#fff", + "navigationBarTitleText": "WeChat", + "navigationBarTextStyle": "black" + }, + "plugins": { + "tuya-ap-plugin": { + "version": "3.3.9", + "provider": "wxd2aa51ffacc3ff86" + } + }, + "sitemapLocation": "sitemap.json" +} \ No newline at end of file diff --git a/app.wxss b/app.wxss new file mode 100644 index 0000000..97362b8 --- /dev/null +++ b/app.wxss @@ -0,0 +1,9 @@ +/**app.wxss**/ +page { + background-color: #f6f6f6; + display: flex; + flex-direction: column; + justify-content: flex-start; + overflow: scroll; +} + diff --git a/components/t_navbar/index.js b/components/t_navbar/index.js new file mode 100644 index 0000000..e084b08 --- /dev/null +++ b/components/t_navbar/index.js @@ -0,0 +1,41 @@ +// components/t_navbar/index.js +Component({ + /** + * 组件的属性列表 + */ + properties: { + device_name: String, + device_id: String + }, + + /** + * 组件的初始数据 + */ + data: { + device_name: '未获取到名称', + marginTop: '20px', + height: 'auto', + }, + + lifetimes: { + attached: function () { + const { statusBarHeight, system } = wx.getSystemInfoSync(); + const height = system.indexOf('iOS') > -1 ? '44px' : '48px' + this.setData({ height, marginTop: `${statusBarHeight}px` }) + } + }, + + /** + * 组件的方法列表 + */ + methods: { + backPage: function () { + wx.navigateBack({ + delta: 1, + }) + }, + jumpEditPage: function() { + this.triggerEvent('jumpTodeviceEditPage',{}) + } + } +}) diff --git a/components/t_navbar/index.json b/components/t_navbar/index.json new file mode 100644 index 0000000..6f50345 --- /dev/null +++ b/components/t_navbar/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "@vant/weapp/icon/index" + } +} \ No newline at end of file diff --git a/components/t_navbar/index.wxml b/components/t_navbar/index.wxml new file mode 100644 index 0000000..52b4533 --- /dev/null +++ b/components/t_navbar/index.wxml @@ -0,0 +1,8 @@ + + + + + {{device_name}} + + + \ No newline at end of file diff --git a/components/t_navbar/index.wxss b/components/t_navbar/index.wxss new file mode 100644 index 0000000..a80efc6 --- /dev/null +++ b/components/t_navbar/index.wxss @@ -0,0 +1,30 @@ +/* components/t_navbar/index.wxss */ +.custom-header { + display: flex; + justify-content: center; + align-items: center; + width: 100%; +} + +.custom-header-block { + display: flex; +} + +.custom-header-back { + position: absolute; + left: 16px; +} + +.custom-header-name { + z-index: 1; + width: 80px; + height: 25px; + font-family: PingFangSC-Medium; + font-size: 17px; + text-align: center; + line-height: 24px; + color: #fff; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} \ No newline at end of file diff --git a/image/addDevicebtn@2x.png b/image/addDevicebtn@2x.png new file mode 100644 index 0000000..1135b37 Binary files /dev/null and b/image/addDevicebtn@2x.png differ diff --git a/image/close.png b/image/close.png new file mode 100644 index 0000000..ccd5663 Binary files /dev/null and b/image/close.png differ diff --git a/image/forest@2x.png b/image/forest@2x.png new file mode 100644 index 0000000..03a7662 Binary files /dev/null and b/image/forest@2x.png differ diff --git a/image/hym_countdown.png b/image/hym_countdown.png new file mode 100644 index 0000000..7a2e321 Binary files /dev/null and b/image/hym_countdown.png differ diff --git a/image/hym_electricity.png b/image/hym_electricity.png new file mode 100644 index 0000000..a43ad93 Binary files /dev/null and b/image/hym_electricity.png differ diff --git a/image/hym_socket.png b/image/hym_socket.png new file mode 100644 index 0000000..334e27e Binary files /dev/null and b/image/hym_socket.png differ diff --git a/image/hym_switch_on.png b/image/hym_switch_on.png new file mode 100644 index 0000000..9e69185 Binary files /dev/null and b/image/hym_switch_on.png differ diff --git a/image/hym_timing.png b/image/hym_timing.png new file mode 100644 index 0000000..3c885b5 Binary files /dev/null and b/image/hym_timing.png differ diff --git a/image/index.js b/image/index.js new file mode 100644 index 0000000..e69de29 diff --git a/image/open.png b/image/open.png new file mode 100644 index 0000000..49f92a0 Binary files /dev/null and b/image/open.png differ diff --git a/image/tuya.jpg b/image/tuya.jpg new file mode 100644 index 0000000..6724097 Binary files /dev/null and b/image/tuya.jpg differ diff --git a/libs/ctypto-js.js b/libs/ctypto-js.js new file mode 100644 index 0000000..04e5a8c --- /dev/null +++ b/libs/ctypto-js.js @@ -0,0 +1,6726 @@ +module.exports = (function() { +var __MODS__ = {}; +var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; }; +var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; }; +var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } }; +var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; }; +__DEFINE__(1594611128923, function(require, module, exports) { +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./x64-core"), require("./lib-typedarrays"), require("./enc-utf16"), require("./enc-base64"), require("./md5"), require("./sha1"), require("./sha256"), require("./sha224"), require("./sha512"), require("./sha384"), require("./sha3"), require("./ripemd160"), require("./hmac"), require("./pbkdf2"), require("./evpkdf"), require("./cipher-core"), require("./mode-cfb"), require("./mode-ctr"), require("./mode-ctr-gladman"), require("./mode-ofb"), require("./mode-ecb"), require("./pad-ansix923"), require("./pad-iso10126"), require("./pad-iso97971"), require("./pad-zeropadding"), require("./pad-nopadding"), require("./format-hex"), require("./aes"), require("./tripledes"), require("./rc4"), require("./rabbit"), require("./rabbit-legacy")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./x64-core", "./lib-typedarrays", "./enc-utf16", "./enc-base64", "./md5", "./sha1", "./sha256", "./sha224", "./sha512", "./sha384", "./sha3", "./ripemd160", "./hmac", "./pbkdf2", "./evpkdf", "./cipher-core", "./mode-cfb", "./mode-ctr", "./mode-ctr-gladman", "./mode-ofb", "./mode-ecb", "./pad-ansix923", "./pad-iso10126", "./pad-iso97971", "./pad-zeropadding", "./pad-nopadding", "./format-hex", "./aes", "./tripledes", "./rc4", "./rabbit", "./rabbit-legacy"], factory); + } + else { + // Global (browser) + root.CryptoJS = factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + return CryptoJS; + +})); +}, function(modId) {var map = {"./core":1594611128924,"./x64-core":1594611128925,"./lib-typedarrays":1594611128926,"./enc-utf16":1594611128927,"./enc-base64":1594611128928,"./md5":1594611128929,"./sha1":1594611128930,"./sha256":1594611128931,"./sha224":1594611128932,"./sha512":1594611128933,"./sha384":1594611128934,"./sha3":1594611128935,"./ripemd160":1594611128936,"./hmac":1594611128937,"./pbkdf2":1594611128938,"./evpkdf":1594611128939,"./cipher-core":1594611128940,"./mode-cfb":1594611128941,"./mode-ctr":1594611128942,"./mode-ctr-gladman":1594611128943,"./mode-ofb":1594611128944,"./mode-ecb":1594611128945,"./pad-ansix923":1594611128946,"./pad-iso10126":1594611128947,"./pad-iso97971":1594611128948,"./pad-zeropadding":1594611128949,"./pad-nopadding":1594611128950,"./format-hex":1594611128951,"./aes":1594611128952,"./tripledes":1594611128953,"./rc4":1594611128954,"./rabbit":1594611128955,"./rabbit-legacy":1594611128956}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128924, function(require, module, exports) { +;(function (root, factory) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(); + } + else if (typeof define === "function" && define.amd) { + // AMD + define([], factory); + } + else { + // Global (browser) + root.CryptoJS = factory(); + } +}(this, function () { + + /*globals window, global, require*/ + + /** + * CryptoJS core components. + */ + var CryptoJS = CryptoJS || (function (Math, undefined) { + + var crypto; + + // Native crypto from window (Browser) + if (typeof window !== 'undefined' && window.crypto) { + crypto = window.crypto; + } + + // Native (experimental IE 11) crypto from window (Browser) + if (!crypto && typeof window !== 'undefined' && window.msCrypto) { + crypto = window.msCrypto; + } + + // Native crypto from global (NodeJS) + if (!crypto && typeof global !== 'undefined' && global.crypto) { + crypto = global.crypto; + } + + // Native crypto import via require (NodeJS) + if (!crypto && typeof require === 'function') { + try { + crypto = require('crypto'); + } catch (err) {} + } + + /* + * Cryptographically secure pseudorandom number generator + * + * As Math.random() is cryptographically not safe to use + */ + var cryptoSecureRandomInt = function () { + if (crypto) { + // Use getRandomValues method (Browser) + if (typeof crypto.getRandomValues === 'function') { + try { + return crypto.getRandomValues(new Uint32Array(1))[0]; + } catch (err) {} + } + + // Use randomBytes method (NodeJS) + if (typeof crypto.randomBytes === 'function') { + try { + return crypto.randomBytes(4).readInt32LE(); + } catch (err) {} + } + } + + throw new Error('Native crypto module could not be used to get secure random number.'); + }; + + /* + * Local polyfill of Object.create + + */ + var create = Object.create || (function () { + function F() {} + + return function (obj) { + var subtype; + + F.prototype = obj; + + subtype = new F(); + + F.prototype = null; + + return subtype; + }; + }()) + + /** + * CryptoJS namespace. + */ + var C = {}; + + /** + * Library namespace. + */ + var C_lib = C.lib = {}; + + /** + * Base object for prototypal inheritance. + */ + var Base = C_lib.Base = (function () { + + + return { + /** + * Creates a new object that inherits from this object. + * + * @param {Object} overrides Properties to copy into the new object. + * + * @return {Object} The new object. + * + * @static + * + * @example + * + * var MyType = CryptoJS.lib.Base.extend({ + * field: 'value', + * + * method: function () { + * } + * }); + */ + extend: function (overrides) { + // Spawn + var subtype = create(this); + + // Augment + if (overrides) { + subtype.mixIn(overrides); + } + + // Create default initializer + if (!subtype.hasOwnProperty('init') || this.init === subtype.init) { + subtype.init = function () { + subtype.$super.init.apply(this, arguments); + }; + } + + // Initializer's prototype is the subtype object + subtype.init.prototype = subtype; + + // Reference supertype + subtype.$super = this; + + return subtype; + }, + + /** + * Extends this object and runs the init method. + * Arguments to create() will be passed to init(). + * + * @return {Object} The new object. + * + * @static + * + * @example + * + * var instance = MyType.create(); + */ + create: function () { + var instance = this.extend(); + instance.init.apply(instance, arguments); + + return instance; + }, + + /** + * Initializes a newly created object. + * Override this method to add some logic when your objects are created. + * + * @example + * + * var MyType = CryptoJS.lib.Base.extend({ + * init: function () { + * // ... + * } + * }); + */ + init: function () { + }, + + /** + * Copies properties into this object. + * + * @param {Object} properties The properties to mix in. + * + * @example + * + * MyType.mixIn({ + * field: 'value' + * }); + */ + mixIn: function (properties) { + for (var propertyName in properties) { + if (properties.hasOwnProperty(propertyName)) { + this[propertyName] = properties[propertyName]; + } + } + + // IE won't copy toString using the loop above + if (properties.hasOwnProperty('toString')) { + this.toString = properties.toString; + } + }, + + /** + * Creates a copy of this object. + * + * @return {Object} The clone. + * + * @example + * + * var clone = instance.clone(); + */ + clone: function () { + return this.init.prototype.extend(this); + } + }; + }()); + + /** + * An array of 32-bit words. + * + * @property {Array} words The array of 32-bit words. + * @property {number} sigBytes The number of significant bytes in this word array. + */ + var WordArray = C_lib.WordArray = Base.extend({ + /** + * Initializes a newly created word array. + * + * @param {Array} words (Optional) An array of 32-bit words. + * @param {number} sigBytes (Optional) The number of significant bytes in the words. + * + * @example + * + * var wordArray = CryptoJS.lib.WordArray.create(); + * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]); + * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6); + */ + init: function (words, sigBytes) { + words = this.words = words || []; + + if (sigBytes != undefined) { + this.sigBytes = sigBytes; + } else { + this.sigBytes = words.length * 4; + } + }, + + /** + * Converts this word array to a string. + * + * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex + * + * @return {string} The stringified word array. + * + * @example + * + * var string = wordArray + ''; + * var string = wordArray.toString(); + * var string = wordArray.toString(CryptoJS.enc.Utf8); + */ + toString: function (encoder) { + return (encoder || Hex).stringify(this); + }, + + /** + * Concatenates a word array to this word array. + * + * @param {WordArray} wordArray The word array to append. + * + * @return {WordArray} This word array. + * + * @example + * + * wordArray1.concat(wordArray2); + */ + concat: function (wordArray) { + // Shortcuts + var thisWords = this.words; + var thatWords = wordArray.words; + var thisSigBytes = this.sigBytes; + var thatSigBytes = wordArray.sigBytes; + + // Clamp excess bits + this.clamp(); + + // Concat + if (thisSigBytes % 4) { + // Copy one byte at a time + for (var i = 0; i < thatSigBytes; i++) { + var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; + thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8); + } + } else { + // Copy one word at a time + for (var i = 0; i < thatSigBytes; i += 4) { + thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2]; + } + } + this.sigBytes += thatSigBytes; + + // Chainable + return this; + }, + + /** + * Removes insignificant bits. + * + * @example + * + * wordArray.clamp(); + */ + clamp: function () { + // Shortcuts + var words = this.words; + var sigBytes = this.sigBytes; + + // Clamp + words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8); + words.length = Math.ceil(sigBytes / 4); + }, + + /** + * Creates a copy of this word array. + * + * @return {WordArray} The clone. + * + * @example + * + * var clone = wordArray.clone(); + */ + clone: function () { + var clone = Base.clone.call(this); + clone.words = this.words.slice(0); + + return clone; + }, + + /** + * Creates a word array filled with random bytes. + * + * @param {number} nBytes The number of random bytes to generate. + * + * @return {WordArray} The random word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.lib.WordArray.random(16); + */ + random: function (nBytes) { + var words = []; + + for (var i = 0; i < nBytes; i += 4) { + words.push(cryptoSecureRandomInt()); + } + + return new WordArray.init(words, nBytes); + } + }); + + /** + * Encoder namespace. + */ + var C_enc = C.enc = {}; + + /** + * Hex encoding strategy. + */ + var Hex = C_enc.Hex = { + /** + * Converts a word array to a hex string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The hex string. + * + * @static + * + * @example + * + * var hexString = CryptoJS.enc.Hex.stringify(wordArray); + */ + stringify: function (wordArray) { + // Shortcuts + var words = wordArray.words; + var sigBytes = wordArray.sigBytes; + + // Convert + var hexChars = []; + for (var i = 0; i < sigBytes; i++) { + var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; + hexChars.push((bite >>> 4).toString(16)); + hexChars.push((bite & 0x0f).toString(16)); + } + + return hexChars.join(''); + }, + + /** + * Converts a hex string to a word array. + * + * @param {string} hexStr The hex string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.enc.Hex.parse(hexString); + */ + parse: function (hexStr) { + // Shortcut + var hexStrLength = hexStr.length; + + // Convert + var words = []; + for (var i = 0; i < hexStrLength; i += 2) { + words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4); + } + + return new WordArray.init(words, hexStrLength / 2); + } + }; + + /** + * Latin1 encoding strategy. + */ + var Latin1 = C_enc.Latin1 = { + /** + * Converts a word array to a Latin1 string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The Latin1 string. + * + * @static + * + * @example + * + * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray); + */ + stringify: function (wordArray) { + // Shortcuts + var words = wordArray.words; + var sigBytes = wordArray.sigBytes; + + // Convert + var latin1Chars = []; + for (var i = 0; i < sigBytes; i++) { + var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; + latin1Chars.push(String.fromCharCode(bite)); + } + + return latin1Chars.join(''); + }, + + /** + * Converts a Latin1 string to a word array. + * + * @param {string} latin1Str The Latin1 string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.enc.Latin1.parse(latin1String); + */ + parse: function (latin1Str) { + // Shortcut + var latin1StrLength = latin1Str.length; + + // Convert + var words = []; + for (var i = 0; i < latin1StrLength; i++) { + words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8); + } + + return new WordArray.init(words, latin1StrLength); + } + }; + + /** + * UTF-8 encoding strategy. + */ + var Utf8 = C_enc.Utf8 = { + /** + * Converts a word array to a UTF-8 string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The UTF-8 string. + * + * @static + * + * @example + * + * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray); + */ + stringify: function (wordArray) { + try { + return decodeURIComponent(escape(Latin1.stringify(wordArray))); + } catch (e) { + throw new Error('Malformed UTF-8 data'); + } + }, + + /** + * Converts a UTF-8 string to a word array. + * + * @param {string} utf8Str The UTF-8 string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.enc.Utf8.parse(utf8String); + */ + parse: function (utf8Str) { + return Latin1.parse(unescape(encodeURIComponent(utf8Str))); + } + }; + + /** + * Abstract buffered block algorithm template. + * + * The property blockSize must be implemented in a concrete subtype. + * + * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0 + */ + var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({ + /** + * Resets this block algorithm's data buffer to its initial state. + * + * @example + * + * bufferedBlockAlgorithm.reset(); + */ + reset: function () { + // Initial values + this._data = new WordArray.init(); + this._nDataBytes = 0; + }, + + /** + * Adds new data to this block algorithm's buffer. + * + * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8. + * + * @example + * + * bufferedBlockAlgorithm._append('data'); + * bufferedBlockAlgorithm._append(wordArray); + */ + _append: function (data) { + // Convert string to WordArray, else assume WordArray already + if (typeof data == 'string') { + data = Utf8.parse(data); + } + + // Append + this._data.concat(data); + this._nDataBytes += data.sigBytes; + }, + + /** + * Processes available data blocks. + * + * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype. + * + * @param {boolean} doFlush Whether all blocks and partial blocks should be processed. + * + * @return {WordArray} The processed data. + * + * @example + * + * var processedData = bufferedBlockAlgorithm._process(); + * var processedData = bufferedBlockAlgorithm._process(!!'flush'); + */ + _process: function (doFlush) { + var processedWords; + + // Shortcuts + var data = this._data; + var dataWords = data.words; + var dataSigBytes = data.sigBytes; + var blockSize = this.blockSize; + var blockSizeBytes = blockSize * 4; + + // Count blocks ready + var nBlocksReady = dataSigBytes / blockSizeBytes; + if (doFlush) { + // Round up to include partial blocks + nBlocksReady = Math.ceil(nBlocksReady); + } else { + // Round down to include only full blocks, + // less the number of blocks that must remain in the buffer + nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0); + } + + // Count words ready + var nWordsReady = nBlocksReady * blockSize; + + // Count bytes ready + var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes); + + // Process blocks + if (nWordsReady) { + for (var offset = 0; offset < nWordsReady; offset += blockSize) { + // Perform concrete-algorithm logic + this._doProcessBlock(dataWords, offset); + } + + // Remove processed words + processedWords = dataWords.splice(0, nWordsReady); + data.sigBytes -= nBytesReady; + } + + // Return processed words + return new WordArray.init(processedWords, nBytesReady); + }, + + /** + * Creates a copy of this object. + * + * @return {Object} The clone. + * + * @example + * + * var clone = bufferedBlockAlgorithm.clone(); + */ + clone: function () { + var clone = Base.clone.call(this); + clone._data = this._data.clone(); + + return clone; + }, + + _minBufferSize: 0 + }); + + /** + * Abstract hasher template. + * + * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits) + */ + var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({ + /** + * Configuration options. + */ + cfg: Base.extend(), + + /** + * Initializes a newly created hasher. + * + * @param {Object} cfg (Optional) The configuration options to use for this hash computation. + * + * @example + * + * var hasher = CryptoJS.algo.SHA256.create(); + */ + init: function (cfg) { + // Apply config defaults + this.cfg = this.cfg.extend(cfg); + + // Set initial values + this.reset(); + }, + + /** + * Resets this hasher to its initial state. + * + * @example + * + * hasher.reset(); + */ + reset: function () { + // Reset data buffer + BufferedBlockAlgorithm.reset.call(this); + + // Perform concrete-hasher logic + this._doReset(); + }, + + /** + * Updates this hasher with a message. + * + * @param {WordArray|string} messageUpdate The message to append. + * + * @return {Hasher} This hasher. + * + * @example + * + * hasher.update('message'); + * hasher.update(wordArray); + */ + update: function (messageUpdate) { + // Append + this._append(messageUpdate); + + // Update the hash + this._process(); + + // Chainable + return this; + }, + + /** + * Finalizes the hash computation. + * Note that the finalize operation is effectively a destructive, read-once operation. + * + * @param {WordArray|string} messageUpdate (Optional) A final message update. + * + * @return {WordArray} The hash. + * + * @example + * + * var hash = hasher.finalize(); + * var hash = hasher.finalize('message'); + * var hash = hasher.finalize(wordArray); + */ + finalize: function (messageUpdate) { + // Final message update + if (messageUpdate) { + this._append(messageUpdate); + } + + // Perform concrete-hasher logic + var hash = this._doFinalize(); + + return hash; + }, + + blockSize: 512/32, + + /** + * Creates a shortcut function to a hasher's object interface. + * + * @param {Hasher} hasher The hasher to create a helper for. + * + * @return {Function} The shortcut function. + * + * @static + * + * @example + * + * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256); + */ + _createHelper: function (hasher) { + return function (message, cfg) { + return new hasher.init(cfg).finalize(message); + }; + }, + + /** + * Creates a shortcut function to the HMAC's object interface. + * + * @param {Hasher} hasher The hasher to use in this HMAC helper. + * + * @return {Function} The shortcut function. + * + * @static + * + * @example + * + * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256); + */ + _createHmacHelper: function (hasher) { + return function (message, key) { + return new C_algo.HMAC.init(hasher, key).finalize(message); + }; + } + }); + + /** + * Algorithm namespace. + */ + var C_algo = C.algo = {}; + + return C; + }(Math)); + + + return CryptoJS; + +})); +}, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128925, function(require, module, exports) { +;(function (root, factory) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function (undefined) { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var Base = C_lib.Base; + var X32WordArray = C_lib.WordArray; + + /** + * x64 namespace. + */ + var C_x64 = C.x64 = {}; + + /** + * A 64-bit word. + */ + var X64Word = C_x64.Word = Base.extend({ + /** + * Initializes a newly created 64-bit word. + * + * @param {number} high The high 32 bits. + * @param {number} low The low 32 bits. + * + * @example + * + * var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607); + */ + init: function (high, low) { + this.high = high; + this.low = low; + } + + /** + * Bitwise NOTs this word. + * + * @return {X64Word} A new x64-Word object after negating. + * + * @example + * + * var negated = x64Word.not(); + */ + // not: function () { + // var high = ~this.high; + // var low = ~this.low; + + // return X64Word.create(high, low); + // }, + + /** + * Bitwise ANDs this word with the passed word. + * + * @param {X64Word} word The x64-Word to AND with this word. + * + * @return {X64Word} A new x64-Word object after ANDing. + * + * @example + * + * var anded = x64Word.and(anotherX64Word); + */ + // and: function (word) { + // var high = this.high & word.high; + // var low = this.low & word.low; + + // return X64Word.create(high, low); + // }, + + /** + * Bitwise ORs this word with the passed word. + * + * @param {X64Word} word The x64-Word to OR with this word. + * + * @return {X64Word} A new x64-Word object after ORing. + * + * @example + * + * var ored = x64Word.or(anotherX64Word); + */ + // or: function (word) { + // var high = this.high | word.high; + // var low = this.low | word.low; + + // return X64Word.create(high, low); + // }, + + /** + * Bitwise XORs this word with the passed word. + * + * @param {X64Word} word The x64-Word to XOR with this word. + * + * @return {X64Word} A new x64-Word object after XORing. + * + * @example + * + * var xored = x64Word.xor(anotherX64Word); + */ + // xor: function (word) { + // var high = this.high ^ word.high; + // var low = this.low ^ word.low; + + // return X64Word.create(high, low); + // }, + + /** + * Shifts this word n bits to the left. + * + * @param {number} n The number of bits to shift. + * + * @return {X64Word} A new x64-Word object after shifting. + * + * @example + * + * var shifted = x64Word.shiftL(25); + */ + // shiftL: function (n) { + // if (n < 32) { + // var high = (this.high << n) | (this.low >>> (32 - n)); + // var low = this.low << n; + // } else { + // var high = this.low << (n - 32); + // var low = 0; + // } + + // return X64Word.create(high, low); + // }, + + /** + * Shifts this word n bits to the right. + * + * @param {number} n The number of bits to shift. + * + * @return {X64Word} A new x64-Word object after shifting. + * + * @example + * + * var shifted = x64Word.shiftR(7); + */ + // shiftR: function (n) { + // if (n < 32) { + // var low = (this.low >>> n) | (this.high << (32 - n)); + // var high = this.high >>> n; + // } else { + // var low = this.high >>> (n - 32); + // var high = 0; + // } + + // return X64Word.create(high, low); + // }, + + /** + * Rotates this word n bits to the left. + * + * @param {number} n The number of bits to rotate. + * + * @return {X64Word} A new x64-Word object after rotating. + * + * @example + * + * var rotated = x64Word.rotL(25); + */ + // rotL: function (n) { + // return this.shiftL(n).or(this.shiftR(64 - n)); + // }, + + /** + * Rotates this word n bits to the right. + * + * @param {number} n The number of bits to rotate. + * + * @return {X64Word} A new x64-Word object after rotating. + * + * @example + * + * var rotated = x64Word.rotR(7); + */ + // rotR: function (n) { + // return this.shiftR(n).or(this.shiftL(64 - n)); + // }, + + /** + * Adds this word with the passed word. + * + * @param {X64Word} word The x64-Word to add with this word. + * + * @return {X64Word} A new x64-Word object after adding. + * + * @example + * + * var added = x64Word.add(anotherX64Word); + */ + // add: function (word) { + // var low = (this.low + word.low) | 0; + // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0; + // var high = (this.high + word.high + carry) | 0; + + // return X64Word.create(high, low); + // } + }); + + /** + * An array of 64-bit words. + * + * @property {Array} words The array of CryptoJS.x64.Word objects. + * @property {number} sigBytes The number of significant bytes in this word array. + */ + var X64WordArray = C_x64.WordArray = Base.extend({ + /** + * Initializes a newly created word array. + * + * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects. + * @param {number} sigBytes (Optional) The number of significant bytes in the words. + * + * @example + * + * var wordArray = CryptoJS.x64.WordArray.create(); + * + * var wordArray = CryptoJS.x64.WordArray.create([ + * CryptoJS.x64.Word.create(0x00010203, 0x04050607), + * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) + * ]); + * + * var wordArray = CryptoJS.x64.WordArray.create([ + * CryptoJS.x64.Word.create(0x00010203, 0x04050607), + * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) + * ], 10); + */ + init: function (words, sigBytes) { + words = this.words = words || []; + + if (sigBytes != undefined) { + this.sigBytes = sigBytes; + } else { + this.sigBytes = words.length * 8; + } + }, + + /** + * Converts this 64-bit word array to a 32-bit word array. + * + * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array. + * + * @example + * + * var x32WordArray = x64WordArray.toX32(); + */ + toX32: function () { + // Shortcuts + var x64Words = this.words; + var x64WordsLength = x64Words.length; + + // Convert + var x32Words = []; + for (var i = 0; i < x64WordsLength; i++) { + var x64Word = x64Words[i]; + x32Words.push(x64Word.high); + x32Words.push(x64Word.low); + } + + return X32WordArray.create(x32Words, this.sigBytes); + }, + + /** + * Creates a copy of this word array. + * + * @return {X64WordArray} The clone. + * + * @example + * + * var clone = x64WordArray.clone(); + */ + clone: function () { + var clone = Base.clone.call(this); + + // Clone "words" array + var words = clone.words = this.words.slice(0); + + // Clone each X64Word object + var wordsLength = words.length; + for (var i = 0; i < wordsLength; i++) { + words[i] = words[i].clone(); + } + + return clone; + } + }); + }()); + + + return CryptoJS; + +})); +}, function(modId) { var map = {"./core":1594611128924}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128926, function(require, module, exports) { +;(function (root, factory) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function () { + // Check if typed arrays are supported + if (typeof ArrayBuffer != 'function') { + return; + } + + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + + // Reference original init + var superInit = WordArray.init; + + // Augment WordArray.init to handle typed arrays + var subInit = WordArray.init = function (typedArray) { + // Convert buffers to uint8 + if (typedArray instanceof ArrayBuffer) { + typedArray = new Uint8Array(typedArray); + } + + // Convert other array views to uint8 + if ( + typedArray instanceof Int8Array || + (typeof Uint8ClampedArray !== "undefined" && typedArray instanceof Uint8ClampedArray) || + typedArray instanceof Int16Array || + typedArray instanceof Uint16Array || + typedArray instanceof Int32Array || + typedArray instanceof Uint32Array || + typedArray instanceof Float32Array || + typedArray instanceof Float64Array + ) { + typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength); + } + + // Handle Uint8Array + if (typedArray instanceof Uint8Array) { + // Shortcut + var typedArrayByteLength = typedArray.byteLength; + + // Extract bytes + var words = []; + for (var i = 0; i < typedArrayByteLength; i++) { + words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8); + } + + // Initialize this word array + superInit.call(this, words, typedArrayByteLength); + } else { + // Else call normal init + superInit.apply(this, arguments); + } + }; + + subInit.prototype = WordArray; + }()); + + + return CryptoJS.lib.WordArray; + +})); +}, function(modId) { var map = {"./core":1594611128924}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128927, function(require, module, exports) { +;(function (root, factory) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var C_enc = C.enc; + + /** + * UTF-16 BE encoding strategy. + */ + var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = { + /** + * Converts a word array to a UTF-16 BE string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The UTF-16 BE string. + * + * @static + * + * @example + * + * var utf16String = CryptoJS.enc.Utf16.stringify(wordArray); + */ + stringify: function (wordArray) { + // Shortcuts + var words = wordArray.words; + var sigBytes = wordArray.sigBytes; + + // Convert + var utf16Chars = []; + for (var i = 0; i < sigBytes; i += 2) { + var codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff; + utf16Chars.push(String.fromCharCode(codePoint)); + } + + return utf16Chars.join(''); + }, + + /** + * Converts a UTF-16 BE string to a word array. + * + * @param {string} utf16Str The UTF-16 BE string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.enc.Utf16.parse(utf16String); + */ + parse: function (utf16Str) { + // Shortcut + var utf16StrLength = utf16Str.length; + + // Convert + var words = []; + for (var i = 0; i < utf16StrLength; i++) { + words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16); + } + + return WordArray.create(words, utf16StrLength * 2); + } + }; + + /** + * UTF-16 LE encoding strategy. + */ + C_enc.Utf16LE = { + /** + * Converts a word array to a UTF-16 LE string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The UTF-16 LE string. + * + * @static + * + * @example + * + * var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray); + */ + stringify: function (wordArray) { + // Shortcuts + var words = wordArray.words; + var sigBytes = wordArray.sigBytes; + + // Convert + var utf16Chars = []; + for (var i = 0; i < sigBytes; i += 2) { + var codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff); + utf16Chars.push(String.fromCharCode(codePoint)); + } + + return utf16Chars.join(''); + }, + + /** + * Converts a UTF-16 LE string to a word array. + * + * @param {string} utf16Str The UTF-16 LE string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str); + */ + parse: function (utf16Str) { + // Shortcut + var utf16StrLength = utf16Str.length; + + // Convert + var words = []; + for (var i = 0; i < utf16StrLength; i++) { + words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16)); + } + + return WordArray.create(words, utf16StrLength * 2); + } + }; + + function swapEndian(word) { + return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff); + } + }()); + + + return CryptoJS.enc.Utf16; + +})); +}, function(modId) { var map = {"./core":1594611128924}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128928, function(require, module, exports) { +;(function (root, factory) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var C_enc = C.enc; + + /** + * Base64 encoding strategy. + */ + var Base64 = C_enc.Base64 = { + /** + * Converts a word array to a Base64 string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The Base64 string. + * + * @static + * + * @example + * + * var base64String = CryptoJS.enc.Base64.stringify(wordArray); + */ + stringify: function (wordArray) { + // Shortcuts + var words = wordArray.words; + var sigBytes = wordArray.sigBytes; + var map = this._map; + + // Clamp excess bits + wordArray.clamp(); + + // Convert + var base64Chars = []; + for (var i = 0; i < sigBytes; i += 3) { + var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; + var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff; + var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff; + + var triplet = (byte1 << 16) | (byte2 << 8) | byte3; + + for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) { + base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f)); + } + } + + // Add padding + var paddingChar = map.charAt(64); + if (paddingChar) { + while (base64Chars.length % 4) { + base64Chars.push(paddingChar); + } + } + + return base64Chars.join(''); + }, + + /** + * Converts a Base64 string to a word array. + * + * @param {string} base64Str The Base64 string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.enc.Base64.parse(base64String); + */ + parse: function (base64Str) { + // Shortcuts + var base64StrLength = base64Str.length; + var map = this._map; + var reverseMap = this._reverseMap; + + if (!reverseMap) { + reverseMap = this._reverseMap = []; + for (var j = 0; j < map.length; j++) { + reverseMap[map.charCodeAt(j)] = j; + } + } + + // Ignore padding + var paddingChar = map.charAt(64); + if (paddingChar) { + var paddingIndex = base64Str.indexOf(paddingChar); + if (paddingIndex !== -1) { + base64StrLength = paddingIndex; + } + } + + // Convert + return parseLoop(base64Str, base64StrLength, reverseMap); + + }, + + _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=' + }; + + function parseLoop(base64Str, base64StrLength, reverseMap) { + var words = []; + var nBytes = 0; + for (var i = 0; i < base64StrLength; i++) { + if (i % 4) { + var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2); + var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2); + var bitsCombined = bits1 | bits2; + words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8); + nBytes++; + } + } + return WordArray.create(words, nBytes); + } + }()); + + + return CryptoJS.enc.Base64; + +})); +}, function(modId) { var map = {"./core":1594611128924}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128929, function(require, module, exports) { +;(function (root, factory) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function (Math) { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var Hasher = C_lib.Hasher; + var C_algo = C.algo; + + // Constants table + var T = []; + + // Compute constants + (function () { + for (var i = 0; i < 64; i++) { + T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0; + } + }()); + + /** + * MD5 hash algorithm. + */ + var MD5 = C_algo.MD5 = Hasher.extend({ + _doReset: function () { + this._hash = new WordArray.init([ + 0x67452301, 0xefcdab89, + 0x98badcfe, 0x10325476 + ]); + }, + + _doProcessBlock: function (M, offset) { + // Swap endian + for (var i = 0; i < 16; i++) { + // Shortcuts + var offset_i = offset + i; + var M_offset_i = M[offset_i]; + + M[offset_i] = ( + (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) | + (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00) + ); + } + + // Shortcuts + var H = this._hash.words; + + var M_offset_0 = M[offset + 0]; + var M_offset_1 = M[offset + 1]; + var M_offset_2 = M[offset + 2]; + var M_offset_3 = M[offset + 3]; + var M_offset_4 = M[offset + 4]; + var M_offset_5 = M[offset + 5]; + var M_offset_6 = M[offset + 6]; + var M_offset_7 = M[offset + 7]; + var M_offset_8 = M[offset + 8]; + var M_offset_9 = M[offset + 9]; + var M_offset_10 = M[offset + 10]; + var M_offset_11 = M[offset + 11]; + var M_offset_12 = M[offset + 12]; + var M_offset_13 = M[offset + 13]; + var M_offset_14 = M[offset + 14]; + var M_offset_15 = M[offset + 15]; + + // Working varialbes + var a = H[0]; + var b = H[1]; + var c = H[2]; + var d = H[3]; + + // Computation + a = FF(a, b, c, d, M_offset_0, 7, T[0]); + d = FF(d, a, b, c, M_offset_1, 12, T[1]); + c = FF(c, d, a, b, M_offset_2, 17, T[2]); + b = FF(b, c, d, a, M_offset_3, 22, T[3]); + a = FF(a, b, c, d, M_offset_4, 7, T[4]); + d = FF(d, a, b, c, M_offset_5, 12, T[5]); + c = FF(c, d, a, b, M_offset_6, 17, T[6]); + b = FF(b, c, d, a, M_offset_7, 22, T[7]); + a = FF(a, b, c, d, M_offset_8, 7, T[8]); + d = FF(d, a, b, c, M_offset_9, 12, T[9]); + c = FF(c, d, a, b, M_offset_10, 17, T[10]); + b = FF(b, c, d, a, M_offset_11, 22, T[11]); + a = FF(a, b, c, d, M_offset_12, 7, T[12]); + d = FF(d, a, b, c, M_offset_13, 12, T[13]); + c = FF(c, d, a, b, M_offset_14, 17, T[14]); + b = FF(b, c, d, a, M_offset_15, 22, T[15]); + + a = GG(a, b, c, d, M_offset_1, 5, T[16]); + d = GG(d, a, b, c, M_offset_6, 9, T[17]); + c = GG(c, d, a, b, M_offset_11, 14, T[18]); + b = GG(b, c, d, a, M_offset_0, 20, T[19]); + a = GG(a, b, c, d, M_offset_5, 5, T[20]); + d = GG(d, a, b, c, M_offset_10, 9, T[21]); + c = GG(c, d, a, b, M_offset_15, 14, T[22]); + b = GG(b, c, d, a, M_offset_4, 20, T[23]); + a = GG(a, b, c, d, M_offset_9, 5, T[24]); + d = GG(d, a, b, c, M_offset_14, 9, T[25]); + c = GG(c, d, a, b, M_offset_3, 14, T[26]); + b = GG(b, c, d, a, M_offset_8, 20, T[27]); + a = GG(a, b, c, d, M_offset_13, 5, T[28]); + d = GG(d, a, b, c, M_offset_2, 9, T[29]); + c = GG(c, d, a, b, M_offset_7, 14, T[30]); + b = GG(b, c, d, a, M_offset_12, 20, T[31]); + + a = HH(a, b, c, d, M_offset_5, 4, T[32]); + d = HH(d, a, b, c, M_offset_8, 11, T[33]); + c = HH(c, d, a, b, M_offset_11, 16, T[34]); + b = HH(b, c, d, a, M_offset_14, 23, T[35]); + a = HH(a, b, c, d, M_offset_1, 4, T[36]); + d = HH(d, a, b, c, M_offset_4, 11, T[37]); + c = HH(c, d, a, b, M_offset_7, 16, T[38]); + b = HH(b, c, d, a, M_offset_10, 23, T[39]); + a = HH(a, b, c, d, M_offset_13, 4, T[40]); + d = HH(d, a, b, c, M_offset_0, 11, T[41]); + c = HH(c, d, a, b, M_offset_3, 16, T[42]); + b = HH(b, c, d, a, M_offset_6, 23, T[43]); + a = HH(a, b, c, d, M_offset_9, 4, T[44]); + d = HH(d, a, b, c, M_offset_12, 11, T[45]); + c = HH(c, d, a, b, M_offset_15, 16, T[46]); + b = HH(b, c, d, a, M_offset_2, 23, T[47]); + + a = II(a, b, c, d, M_offset_0, 6, T[48]); + d = II(d, a, b, c, M_offset_7, 10, T[49]); + c = II(c, d, a, b, M_offset_14, 15, T[50]); + b = II(b, c, d, a, M_offset_5, 21, T[51]); + a = II(a, b, c, d, M_offset_12, 6, T[52]); + d = II(d, a, b, c, M_offset_3, 10, T[53]); + c = II(c, d, a, b, M_offset_10, 15, T[54]); + b = II(b, c, d, a, M_offset_1, 21, T[55]); + a = II(a, b, c, d, M_offset_8, 6, T[56]); + d = II(d, a, b, c, M_offset_15, 10, T[57]); + c = II(c, d, a, b, M_offset_6, 15, T[58]); + b = II(b, c, d, a, M_offset_13, 21, T[59]); + a = II(a, b, c, d, M_offset_4, 6, T[60]); + d = II(d, a, b, c, M_offset_11, 10, T[61]); + c = II(c, d, a, b, M_offset_2, 15, T[62]); + b = II(b, c, d, a, M_offset_9, 21, T[63]); + + // Intermediate hash value + H[0] = (H[0] + a) | 0; + H[1] = (H[1] + b) | 0; + H[2] = (H[2] + c) | 0; + H[3] = (H[3] + d) | 0; + }, + + _doFinalize: function () { + // Shortcuts + var data = this._data; + var dataWords = data.words; + + var nBitsTotal = this._nDataBytes * 8; + var nBitsLeft = data.sigBytes * 8; + + // Add padding + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); + + var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000); + var nBitsTotalL = nBitsTotal; + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = ( + (((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) | + (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00) + ); + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = ( + (((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) | + (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00) + ); + + data.sigBytes = (dataWords.length + 1) * 4; + + // Hash final blocks + this._process(); + + // Shortcuts + var hash = this._hash; + var H = hash.words; + + // Swap endian + for (var i = 0; i < 4; i++) { + // Shortcut + var H_i = H[i]; + + H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) | + (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00); + } + + // Return final computed hash + return hash; + }, + + clone: function () { + var clone = Hasher.clone.call(this); + clone._hash = this._hash.clone(); + + return clone; + } + }); + + function FF(a, b, c, d, x, s, t) { + var n = a + ((b & c) | (~b & d)) + x + t; + return ((n << s) | (n >>> (32 - s))) + b; + } + + function GG(a, b, c, d, x, s, t) { + var n = a + ((b & d) | (c & ~d)) + x + t; + return ((n << s) | (n >>> (32 - s))) + b; + } + + function HH(a, b, c, d, x, s, t) { + var n = a + (b ^ c ^ d) + x + t; + return ((n << s) | (n >>> (32 - s))) + b; + } + + function II(a, b, c, d, x, s, t) { + var n = a + (c ^ (b | ~d)) + x + t; + return ((n << s) | (n >>> (32 - s))) + b; + } + + /** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.MD5('message'); + * var hash = CryptoJS.MD5(wordArray); + */ + C.MD5 = Hasher._createHelper(MD5); + + /** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacMD5(message, key); + */ + C.HmacMD5 = Hasher._createHmacHelper(MD5); + }(Math)); + + + return CryptoJS.MD5; + +})); +}, function(modId) { var map = {"./core":1594611128924}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128930, function(require, module, exports) { +;(function (root, factory) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var Hasher = C_lib.Hasher; + var C_algo = C.algo; + + // Reusable object + var W = []; + + /** + * SHA-1 hash algorithm. + */ + var SHA1 = C_algo.SHA1 = Hasher.extend({ + _doReset: function () { + this._hash = new WordArray.init([ + 0x67452301, 0xefcdab89, + 0x98badcfe, 0x10325476, + 0xc3d2e1f0 + ]); + }, + + _doProcessBlock: function (M, offset) { + // Shortcut + var H = this._hash.words; + + // Working variables + var a = H[0]; + var b = H[1]; + var c = H[2]; + var d = H[3]; + var e = H[4]; + + // Computation + for (var i = 0; i < 80; i++) { + if (i < 16) { + W[i] = M[offset + i] | 0; + } else { + var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]; + W[i] = (n << 1) | (n >>> 31); + } + + var t = ((a << 5) | (a >>> 27)) + e + W[i]; + if (i < 20) { + t += ((b & c) | (~b & d)) + 0x5a827999; + } else if (i < 40) { + t += (b ^ c ^ d) + 0x6ed9eba1; + } else if (i < 60) { + t += ((b & c) | (b & d) | (c & d)) - 0x70e44324; + } else /* if (i < 80) */ { + t += (b ^ c ^ d) - 0x359d3e2a; + } + + e = d; + d = c; + c = (b << 30) | (b >>> 2); + b = a; + a = t; + } + + // Intermediate hash value + H[0] = (H[0] + a) | 0; + H[1] = (H[1] + b) | 0; + H[2] = (H[2] + c) | 0; + H[3] = (H[3] + d) | 0; + H[4] = (H[4] + e) | 0; + }, + + _doFinalize: function () { + // Shortcuts + var data = this._data; + var dataWords = data.words; + + var nBitsTotal = this._nDataBytes * 8; + var nBitsLeft = data.sigBytes * 8; + + // Add padding + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000); + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal; + data.sigBytes = dataWords.length * 4; + + // Hash final blocks + this._process(); + + // Return final computed hash + return this._hash; + }, + + clone: function () { + var clone = Hasher.clone.call(this); + clone._hash = this._hash.clone(); + + return clone; + } + }); + + /** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.SHA1('message'); + * var hash = CryptoJS.SHA1(wordArray); + */ + C.SHA1 = Hasher._createHelper(SHA1); + + /** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacSHA1(message, key); + */ + C.HmacSHA1 = Hasher._createHmacHelper(SHA1); + }()); + + + return CryptoJS.SHA1; + +})); +}, function(modId) { var map = {"./core":1594611128924}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128931, function(require, module, exports) { +;(function (root, factory) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function (Math) { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var Hasher = C_lib.Hasher; + var C_algo = C.algo; + + // Initialization and round constants tables + var H = []; + var K = []; + + // Compute constants + (function () { + function isPrime(n) { + var sqrtN = Math.sqrt(n); + for (var factor = 2; factor <= sqrtN; factor++) { + if (!(n % factor)) { + return false; + } + } + + return true; + } + + function getFractionalBits(n) { + return ((n - (n | 0)) * 0x100000000) | 0; + } + + var n = 2; + var nPrime = 0; + while (nPrime < 64) { + if (isPrime(n)) { + if (nPrime < 8) { + H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2)); + } + K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3)); + + nPrime++; + } + + n++; + } + }()); + + // Reusable object + var W = []; + + /** + * SHA-256 hash algorithm. + */ + var SHA256 = C_algo.SHA256 = Hasher.extend({ + _doReset: function () { + this._hash = new WordArray.init(H.slice(0)); + }, + + _doProcessBlock: function (M, offset) { + // Shortcut + var H = this._hash.words; + + // Working variables + var a = H[0]; + var b = H[1]; + var c = H[2]; + var d = H[3]; + var e = H[4]; + var f = H[5]; + var g = H[6]; + var h = H[7]; + + // Computation + for (var i = 0; i < 64; i++) { + if (i < 16) { + W[i] = M[offset + i] | 0; + } else { + var gamma0x = W[i - 15]; + var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^ + ((gamma0x << 14) | (gamma0x >>> 18)) ^ + (gamma0x >>> 3); + + var gamma1x = W[i - 2]; + var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^ + ((gamma1x << 13) | (gamma1x >>> 19)) ^ + (gamma1x >>> 10); + + W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]; + } + + var ch = (e & f) ^ (~e & g); + var maj = (a & b) ^ (a & c) ^ (b & c); + + var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22)); + var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25)); + + var t1 = h + sigma1 + ch + K[i] + W[i]; + var t2 = sigma0 + maj; + + h = g; + g = f; + f = e; + e = (d + t1) | 0; + d = c; + c = b; + b = a; + a = (t1 + t2) | 0; + } + + // Intermediate hash value + H[0] = (H[0] + a) | 0; + H[1] = (H[1] + b) | 0; + H[2] = (H[2] + c) | 0; + H[3] = (H[3] + d) | 0; + H[4] = (H[4] + e) | 0; + H[5] = (H[5] + f) | 0; + H[6] = (H[6] + g) | 0; + H[7] = (H[7] + h) | 0; + }, + + _doFinalize: function () { + // Shortcuts + var data = this._data; + var dataWords = data.words; + + var nBitsTotal = this._nDataBytes * 8; + var nBitsLeft = data.sigBytes * 8; + + // Add padding + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000); + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal; + data.sigBytes = dataWords.length * 4; + + // Hash final blocks + this._process(); + + // Return final computed hash + return this._hash; + }, + + clone: function () { + var clone = Hasher.clone.call(this); + clone._hash = this._hash.clone(); + + return clone; + } + }); + + /** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.SHA256('message'); + * var hash = CryptoJS.SHA256(wordArray); + */ + C.SHA256 = Hasher._createHelper(SHA256); + + /** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacSHA256(message, key); + */ + C.HmacSHA256 = Hasher._createHmacHelper(SHA256); + }(Math)); + + + return CryptoJS.SHA256; + +})); +}, function(modId) { var map = {"./core":1594611128924}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128932, function(require, module, exports) { +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./sha256")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./sha256"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var C_algo = C.algo; + var SHA256 = C_algo.SHA256; + + /** + * SHA-224 hash algorithm. + */ + var SHA224 = C_algo.SHA224 = SHA256.extend({ + _doReset: function () { + this._hash = new WordArray.init([ + 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, + 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 + ]); + }, + + _doFinalize: function () { + var hash = SHA256._doFinalize.call(this); + + hash.sigBytes -= 4; + + return hash; + } + }); + + /** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.SHA224('message'); + * var hash = CryptoJS.SHA224(wordArray); + */ + C.SHA224 = SHA256._createHelper(SHA224); + + /** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacSHA224(message, key); + */ + C.HmacSHA224 = SHA256._createHmacHelper(SHA224); + }()); + + + return CryptoJS.SHA224; + +})); +}, function(modId) { var map = {"./core":1594611128924,"./sha256":1594611128931}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128933, function(require, module, exports) { +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./x64-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./x64-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var Hasher = C_lib.Hasher; + var C_x64 = C.x64; + var X64Word = C_x64.Word; + var X64WordArray = C_x64.WordArray; + var C_algo = C.algo; + + function X64Word_create() { + return X64Word.create.apply(X64Word, arguments); + } + + // Constants + var K = [ + X64Word_create(0x428a2f98, 0xd728ae22), X64Word_create(0x71374491, 0x23ef65cd), + X64Word_create(0xb5c0fbcf, 0xec4d3b2f), X64Word_create(0xe9b5dba5, 0x8189dbbc), + X64Word_create(0x3956c25b, 0xf348b538), X64Word_create(0x59f111f1, 0xb605d019), + X64Word_create(0x923f82a4, 0xaf194f9b), X64Word_create(0xab1c5ed5, 0xda6d8118), + X64Word_create(0xd807aa98, 0xa3030242), X64Word_create(0x12835b01, 0x45706fbe), + X64Word_create(0x243185be, 0x4ee4b28c), X64Word_create(0x550c7dc3, 0xd5ffb4e2), + X64Word_create(0x72be5d74, 0xf27b896f), X64Word_create(0x80deb1fe, 0x3b1696b1), + X64Word_create(0x9bdc06a7, 0x25c71235), X64Word_create(0xc19bf174, 0xcf692694), + X64Word_create(0xe49b69c1, 0x9ef14ad2), X64Word_create(0xefbe4786, 0x384f25e3), + X64Word_create(0x0fc19dc6, 0x8b8cd5b5), X64Word_create(0x240ca1cc, 0x77ac9c65), + X64Word_create(0x2de92c6f, 0x592b0275), X64Word_create(0x4a7484aa, 0x6ea6e483), + X64Word_create(0x5cb0a9dc, 0xbd41fbd4), X64Word_create(0x76f988da, 0x831153b5), + X64Word_create(0x983e5152, 0xee66dfab), X64Word_create(0xa831c66d, 0x2db43210), + X64Word_create(0xb00327c8, 0x98fb213f), X64Word_create(0xbf597fc7, 0xbeef0ee4), + X64Word_create(0xc6e00bf3, 0x3da88fc2), X64Word_create(0xd5a79147, 0x930aa725), + X64Word_create(0x06ca6351, 0xe003826f), X64Word_create(0x14292967, 0x0a0e6e70), + X64Word_create(0x27b70a85, 0x46d22ffc), X64Word_create(0x2e1b2138, 0x5c26c926), + X64Word_create(0x4d2c6dfc, 0x5ac42aed), X64Word_create(0x53380d13, 0x9d95b3df), + X64Word_create(0x650a7354, 0x8baf63de), X64Word_create(0x766a0abb, 0x3c77b2a8), + X64Word_create(0x81c2c92e, 0x47edaee6), X64Word_create(0x92722c85, 0x1482353b), + X64Word_create(0xa2bfe8a1, 0x4cf10364), X64Word_create(0xa81a664b, 0xbc423001), + X64Word_create(0xc24b8b70, 0xd0f89791), X64Word_create(0xc76c51a3, 0x0654be30), + X64Word_create(0xd192e819, 0xd6ef5218), X64Word_create(0xd6990624, 0x5565a910), + X64Word_create(0xf40e3585, 0x5771202a), X64Word_create(0x106aa070, 0x32bbd1b8), + X64Word_create(0x19a4c116, 0xb8d2d0c8), X64Word_create(0x1e376c08, 0x5141ab53), + X64Word_create(0x2748774c, 0xdf8eeb99), X64Word_create(0x34b0bcb5, 0xe19b48a8), + X64Word_create(0x391c0cb3, 0xc5c95a63), X64Word_create(0x4ed8aa4a, 0xe3418acb), + X64Word_create(0x5b9cca4f, 0x7763e373), X64Word_create(0x682e6ff3, 0xd6b2b8a3), + X64Word_create(0x748f82ee, 0x5defb2fc), X64Word_create(0x78a5636f, 0x43172f60), + X64Word_create(0x84c87814, 0xa1f0ab72), X64Word_create(0x8cc70208, 0x1a6439ec), + X64Word_create(0x90befffa, 0x23631e28), X64Word_create(0xa4506ceb, 0xde82bde9), + X64Word_create(0xbef9a3f7, 0xb2c67915), X64Word_create(0xc67178f2, 0xe372532b), + X64Word_create(0xca273ece, 0xea26619c), X64Word_create(0xd186b8c7, 0x21c0c207), + X64Word_create(0xeada7dd6, 0xcde0eb1e), X64Word_create(0xf57d4f7f, 0xee6ed178), + X64Word_create(0x06f067aa, 0x72176fba), X64Word_create(0x0a637dc5, 0xa2c898a6), + X64Word_create(0x113f9804, 0xbef90dae), X64Word_create(0x1b710b35, 0x131c471b), + X64Word_create(0x28db77f5, 0x23047d84), X64Word_create(0x32caab7b, 0x40c72493), + X64Word_create(0x3c9ebe0a, 0x15c9bebc), X64Word_create(0x431d67c4, 0x9c100d4c), + X64Word_create(0x4cc5d4be, 0xcb3e42b6), X64Word_create(0x597f299c, 0xfc657e2a), + X64Word_create(0x5fcb6fab, 0x3ad6faec), X64Word_create(0x6c44198c, 0x4a475817) + ]; + + // Reusable objects + var W = []; + (function () { + for (var i = 0; i < 80; i++) { + W[i] = X64Word_create(); + } + }()); + + /** + * SHA-512 hash algorithm. + */ + var SHA512 = C_algo.SHA512 = Hasher.extend({ + _doReset: function () { + this._hash = new X64WordArray.init([ + new X64Word.init(0x6a09e667, 0xf3bcc908), new X64Word.init(0xbb67ae85, 0x84caa73b), + new X64Word.init(0x3c6ef372, 0xfe94f82b), new X64Word.init(0xa54ff53a, 0x5f1d36f1), + new X64Word.init(0x510e527f, 0xade682d1), new X64Word.init(0x9b05688c, 0x2b3e6c1f), + new X64Word.init(0x1f83d9ab, 0xfb41bd6b), new X64Word.init(0x5be0cd19, 0x137e2179) + ]); + }, + + _doProcessBlock: function (M, offset) { + // Shortcuts + var H = this._hash.words; + + var H0 = H[0]; + var H1 = H[1]; + var H2 = H[2]; + var H3 = H[3]; + var H4 = H[4]; + var H5 = H[5]; + var H6 = H[6]; + var H7 = H[7]; + + var H0h = H0.high; + var H0l = H0.low; + var H1h = H1.high; + var H1l = H1.low; + var H2h = H2.high; + var H2l = H2.low; + var H3h = H3.high; + var H3l = H3.low; + var H4h = H4.high; + var H4l = H4.low; + var H5h = H5.high; + var H5l = H5.low; + var H6h = H6.high; + var H6l = H6.low; + var H7h = H7.high; + var H7l = H7.low; + + // Working variables + var ah = H0h; + var al = H0l; + var bh = H1h; + var bl = H1l; + var ch = H2h; + var cl = H2l; + var dh = H3h; + var dl = H3l; + var eh = H4h; + var el = H4l; + var fh = H5h; + var fl = H5l; + var gh = H6h; + var gl = H6l; + var hh = H7h; + var hl = H7l; + + // Rounds + for (var i = 0; i < 80; i++) { + var Wil; + var Wih; + + // Shortcut + var Wi = W[i]; + + // Extend message + if (i < 16) { + Wih = Wi.high = M[offset + i * 2] | 0; + Wil = Wi.low = M[offset + i * 2 + 1] | 0; + } else { + // Gamma0 + var gamma0x = W[i - 15]; + var gamma0xh = gamma0x.high; + var gamma0xl = gamma0x.low; + var gamma0h = ((gamma0xh >>> 1) | (gamma0xl << 31)) ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) ^ (gamma0xh >>> 7); + var gamma0l = ((gamma0xl >>> 1) | (gamma0xh << 31)) ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) ^ ((gamma0xl >>> 7) | (gamma0xh << 25)); + + // Gamma1 + var gamma1x = W[i - 2]; + var gamma1xh = gamma1x.high; + var gamma1xl = gamma1x.low; + var gamma1h = ((gamma1xh >>> 19) | (gamma1xl << 13)) ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6); + var gamma1l = ((gamma1xl >>> 19) | (gamma1xh << 13)) ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26)); + + // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16] + var Wi7 = W[i - 7]; + var Wi7h = Wi7.high; + var Wi7l = Wi7.low; + + var Wi16 = W[i - 16]; + var Wi16h = Wi16.high; + var Wi16l = Wi16.low; + + Wil = gamma0l + Wi7l; + Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0); + Wil = Wil + gamma1l; + Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0); + Wil = Wil + Wi16l; + Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0); + + Wi.high = Wih; + Wi.low = Wil; + } + + var chh = (eh & fh) ^ (~eh & gh); + var chl = (el & fl) ^ (~el & gl); + var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch); + var majl = (al & bl) ^ (al & cl) ^ (bl & cl); + + var sigma0h = ((ah >>> 28) | (al << 4)) ^ ((ah << 30) | (al >>> 2)) ^ ((ah << 25) | (al >>> 7)); + var sigma0l = ((al >>> 28) | (ah << 4)) ^ ((al << 30) | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7)); + var sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9)); + var sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9)); + + // t1 = h + sigma1 + ch + K[i] + W[i] + var Ki = K[i]; + var Kih = Ki.high; + var Kil = Ki.low; + + var t1l = hl + sigma1l; + var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0); + var t1l = t1l + chl; + var t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0); + var t1l = t1l + Kil; + var t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0); + var t1l = t1l + Wil; + var t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0); + + // t2 = sigma0 + maj + var t2l = sigma0l + majl; + var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0); + + // Update working variables + hh = gh; + hl = gl; + gh = fh; + gl = fl; + fh = eh; + fl = el; + el = (dl + t1l) | 0; + eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0; + dh = ch; + dl = cl; + ch = bh; + cl = bl; + bh = ah; + bl = al; + al = (t1l + t2l) | 0; + ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0; + } + + // Intermediate hash value + H0l = H0.low = (H0l + al); + H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0)); + H1l = H1.low = (H1l + bl); + H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0)); + H2l = H2.low = (H2l + cl); + H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0)); + H3l = H3.low = (H3l + dl); + H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0)); + H4l = H4.low = (H4l + el); + H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0)); + H5l = H5.low = (H5l + fl); + H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0)); + H6l = H6.low = (H6l + gl); + H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0)); + H7l = H7.low = (H7l + hl); + H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0)); + }, + + _doFinalize: function () { + // Shortcuts + var data = this._data; + var dataWords = data.words; + + var nBitsTotal = this._nDataBytes * 8; + var nBitsLeft = data.sigBytes * 8; + + // Add padding + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); + dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000); + dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal; + data.sigBytes = dataWords.length * 4; + + // Hash final blocks + this._process(); + + // Convert hash to 32-bit word array before returning + var hash = this._hash.toX32(); + + // Return final computed hash + return hash; + }, + + clone: function () { + var clone = Hasher.clone.call(this); + clone._hash = this._hash.clone(); + + return clone; + }, + + blockSize: 1024/32 + }); + + /** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.SHA512('message'); + * var hash = CryptoJS.SHA512(wordArray); + */ + C.SHA512 = Hasher._createHelper(SHA512); + + /** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacSHA512(message, key); + */ + C.HmacSHA512 = Hasher._createHmacHelper(SHA512); + }()); + + + return CryptoJS.SHA512; + +})); +}, function(modId) { var map = {"./core":1594611128924,"./x64-core":1594611128925}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128934, function(require, module, exports) { +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./x64-core"), require("./sha512")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./x64-core", "./sha512"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function () { + // Shortcuts + var C = CryptoJS; + var C_x64 = C.x64; + var X64Word = C_x64.Word; + var X64WordArray = C_x64.WordArray; + var C_algo = C.algo; + var SHA512 = C_algo.SHA512; + + /** + * SHA-384 hash algorithm. + */ + var SHA384 = C_algo.SHA384 = SHA512.extend({ + _doReset: function () { + this._hash = new X64WordArray.init([ + new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507), + new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939), + new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511), + new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4) + ]); + }, + + _doFinalize: function () { + var hash = SHA512._doFinalize.call(this); + + hash.sigBytes -= 16; + + return hash; + } + }); + + /** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.SHA384('message'); + * var hash = CryptoJS.SHA384(wordArray); + */ + C.SHA384 = SHA512._createHelper(SHA384); + + /** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacSHA384(message, key); + */ + C.HmacSHA384 = SHA512._createHmacHelper(SHA384); + }()); + + + return CryptoJS.SHA384; + +})); +}, function(modId) { var map = {"./core":1594611128924,"./x64-core":1594611128925,"./sha512":1594611128933}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128935, function(require, module, exports) { +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./x64-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./x64-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function (Math) { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var Hasher = C_lib.Hasher; + var C_x64 = C.x64; + var X64Word = C_x64.Word; + var C_algo = C.algo; + + // Constants tables + var RHO_OFFSETS = []; + var PI_INDEXES = []; + var ROUND_CONSTANTS = []; + + // Compute Constants + (function () { + // Compute rho offset constants + var x = 1, y = 0; + for (var t = 0; t < 24; t++) { + RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64; + + var newX = y % 5; + var newY = (2 * x + 3 * y) % 5; + x = newX; + y = newY; + } + + // Compute pi index constants + for (var x = 0; x < 5; x++) { + for (var y = 0; y < 5; y++) { + PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5; + } + } + + // Compute round constants + var LFSR = 0x01; + for (var i = 0; i < 24; i++) { + var roundConstantMsw = 0; + var roundConstantLsw = 0; + + for (var j = 0; j < 7; j++) { + if (LFSR & 0x01) { + var bitPosition = (1 << j) - 1; + if (bitPosition < 32) { + roundConstantLsw ^= 1 << bitPosition; + } else /* if (bitPosition >= 32) */ { + roundConstantMsw ^= 1 << (bitPosition - 32); + } + } + + // Compute next LFSR + if (LFSR & 0x80) { + // Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1 + LFSR = (LFSR << 1) ^ 0x71; + } else { + LFSR <<= 1; + } + } + + ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw); + } + }()); + + // Reusable objects for temporary values + var T = []; + (function () { + for (var i = 0; i < 25; i++) { + T[i] = X64Word.create(); + } + }()); + + /** + * SHA-3 hash algorithm. + */ + var SHA3 = C_algo.SHA3 = Hasher.extend({ + /** + * Configuration options. + * + * @property {number} outputLength + * The desired number of bits in the output hash. + * Only values permitted are: 224, 256, 384, 512. + * Default: 512 + */ + cfg: Hasher.cfg.extend({ + outputLength: 512 + }), + + _doReset: function () { + var state = this._state = [] + for (var i = 0; i < 25; i++) { + state[i] = new X64Word.init(); + } + + this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32; + }, + + _doProcessBlock: function (M, offset) { + // Shortcuts + var state = this._state; + var nBlockSizeLanes = this.blockSize / 2; + + // Absorb + for (var i = 0; i < nBlockSizeLanes; i++) { + // Shortcuts + var M2i = M[offset + 2 * i]; + var M2i1 = M[offset + 2 * i + 1]; + + // Swap endian + M2i = ( + (((M2i << 8) | (M2i >>> 24)) & 0x00ff00ff) | + (((M2i << 24) | (M2i >>> 8)) & 0xff00ff00) + ); + M2i1 = ( + (((M2i1 << 8) | (M2i1 >>> 24)) & 0x00ff00ff) | + (((M2i1 << 24) | (M2i1 >>> 8)) & 0xff00ff00) + ); + + // Absorb message into state + var lane = state[i]; + lane.high ^= M2i1; + lane.low ^= M2i; + } + + // Rounds + for (var round = 0; round < 24; round++) { + // Theta + for (var x = 0; x < 5; x++) { + // Mix column lanes + var tMsw = 0, tLsw = 0; + for (var y = 0; y < 5; y++) { + var lane = state[x + 5 * y]; + tMsw ^= lane.high; + tLsw ^= lane.low; + } + + // Temporary values + var Tx = T[x]; + Tx.high = tMsw; + Tx.low = tLsw; + } + for (var x = 0; x < 5; x++) { + // Shortcuts + var Tx4 = T[(x + 4) % 5]; + var Tx1 = T[(x + 1) % 5]; + var Tx1Msw = Tx1.high; + var Tx1Lsw = Tx1.low; + + // Mix surrounding columns + var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31)); + var tLsw = Tx4.low ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31)); + for (var y = 0; y < 5; y++) { + var lane = state[x + 5 * y]; + lane.high ^= tMsw; + lane.low ^= tLsw; + } + } + + // Rho Pi + for (var laneIndex = 1; laneIndex < 25; laneIndex++) { + var tMsw; + var tLsw; + + // Shortcuts + var lane = state[laneIndex]; + var laneMsw = lane.high; + var laneLsw = lane.low; + var rhoOffset = RHO_OFFSETS[laneIndex]; + + // Rotate lanes + if (rhoOffset < 32) { + tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset)); + tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset)); + } else /* if (rhoOffset >= 32) */ { + tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset)); + tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset)); + } + + // Transpose lanes + var TPiLane = T[PI_INDEXES[laneIndex]]; + TPiLane.high = tMsw; + TPiLane.low = tLsw; + } + + // Rho pi at x = y = 0 + var T0 = T[0]; + var state0 = state[0]; + T0.high = state0.high; + T0.low = state0.low; + + // Chi + for (var x = 0; x < 5; x++) { + for (var y = 0; y < 5; y++) { + // Shortcuts + var laneIndex = x + 5 * y; + var lane = state[laneIndex]; + var TLane = T[laneIndex]; + var Tx1Lane = T[((x + 1) % 5) + 5 * y]; + var Tx2Lane = T[((x + 2) % 5) + 5 * y]; + + // Mix rows + lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high); + lane.low = TLane.low ^ (~Tx1Lane.low & Tx2Lane.low); + } + } + + // Iota + var lane = state[0]; + var roundConstant = ROUND_CONSTANTS[round]; + lane.high ^= roundConstant.high; + lane.low ^= roundConstant.low; + } + }, + + _doFinalize: function () { + // Shortcuts + var data = this._data; + var dataWords = data.words; + var nBitsTotal = this._nDataBytes * 8; + var nBitsLeft = data.sigBytes * 8; + var blockSizeBits = this.blockSize * 32; + + // Add padding + dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32); + dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80; + data.sigBytes = dataWords.length * 4; + + // Hash final blocks + this._process(); + + // Shortcuts + var state = this._state; + var outputLengthBytes = this.cfg.outputLength / 8; + var outputLengthLanes = outputLengthBytes / 8; + + // Squeeze + var hashWords = []; + for (var i = 0; i < outputLengthLanes; i++) { + // Shortcuts + var lane = state[i]; + var laneMsw = lane.high; + var laneLsw = lane.low; + + // Swap endian + laneMsw = ( + (((laneMsw << 8) | (laneMsw >>> 24)) & 0x00ff00ff) | + (((laneMsw << 24) | (laneMsw >>> 8)) & 0xff00ff00) + ); + laneLsw = ( + (((laneLsw << 8) | (laneLsw >>> 24)) & 0x00ff00ff) | + (((laneLsw << 24) | (laneLsw >>> 8)) & 0xff00ff00) + ); + + // Squeeze state to retrieve hash + hashWords.push(laneLsw); + hashWords.push(laneMsw); + } + + // Return final computed hash + return new WordArray.init(hashWords, outputLengthBytes); + }, + + clone: function () { + var clone = Hasher.clone.call(this); + + var state = clone._state = this._state.slice(0); + for (var i = 0; i < 25; i++) { + state[i] = state[i].clone(); + } + + return clone; + } + }); + + /** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.SHA3('message'); + * var hash = CryptoJS.SHA3(wordArray); + */ + C.SHA3 = Hasher._createHelper(SHA3); + + /** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacSHA3(message, key); + */ + C.HmacSHA3 = Hasher._createHmacHelper(SHA3); + }(Math)); + + + return CryptoJS.SHA3; + +})); +}, function(modId) { var map = {"./core":1594611128924,"./x64-core":1594611128925}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128936, function(require, module, exports) { +;(function (root, factory) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + /** @preserve + (c) 2012 by Cédric Mesnil. All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + (function (Math) { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var Hasher = C_lib.Hasher; + var C_algo = C.algo; + + // Constants table + var _zl = WordArray.create([ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, + 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, + 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, + 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]); + var _zr = WordArray.create([ + 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, + 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, + 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, + 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, + 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]); + var _sl = WordArray.create([ + 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, + 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, + 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, + 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, + 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 ]); + var _sr = WordArray.create([ + 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, + 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, + 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, + 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, + 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]); + + var _hl = WordArray.create([ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]); + var _hr = WordArray.create([ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]); + + /** + * RIPEMD160 hash algorithm. + */ + var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({ + _doReset: function () { + this._hash = WordArray.create([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]); + }, + + _doProcessBlock: function (M, offset) { + + // Swap endian + for (var i = 0; i < 16; i++) { + // Shortcuts + var offset_i = offset + i; + var M_offset_i = M[offset_i]; + + // Swap + M[offset_i] = ( + (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) | + (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00) + ); + } + // Shortcut + var H = this._hash.words; + var hl = _hl.words; + var hr = _hr.words; + var zl = _zl.words; + var zr = _zr.words; + var sl = _sl.words; + var sr = _sr.words; + + // Working variables + var al, bl, cl, dl, el; + var ar, br, cr, dr, er; + + ar = al = H[0]; + br = bl = H[1]; + cr = cl = H[2]; + dr = dl = H[3]; + er = el = H[4]; + // Computation + var t; + for (var i = 0; i < 80; i += 1) { + t = (al + M[offset+zl[i]])|0; + if (i<16){ + t += f1(bl,cl,dl) + hl[0]; + } else if (i<32) { + t += f2(bl,cl,dl) + hl[1]; + } else if (i<48) { + t += f3(bl,cl,dl) + hl[2]; + } else if (i<64) { + t += f4(bl,cl,dl) + hl[3]; + } else {// if (i<80) { + t += f5(bl,cl,dl) + hl[4]; + } + t = t|0; + t = rotl(t,sl[i]); + t = (t+el)|0; + al = el; + el = dl; + dl = rotl(cl, 10); + cl = bl; + bl = t; + + t = (ar + M[offset+zr[i]])|0; + if (i<16){ + t += f5(br,cr,dr) + hr[0]; + } else if (i<32) { + t += f4(br,cr,dr) + hr[1]; + } else if (i<48) { + t += f3(br,cr,dr) + hr[2]; + } else if (i<64) { + t += f2(br,cr,dr) + hr[3]; + } else {// if (i<80) { + t += f1(br,cr,dr) + hr[4]; + } + t = t|0; + t = rotl(t,sr[i]) ; + t = (t+er)|0; + ar = er; + er = dr; + dr = rotl(cr, 10); + cr = br; + br = t; + } + // Intermediate hash value + t = (H[1] + cl + dr)|0; + H[1] = (H[2] + dl + er)|0; + H[2] = (H[3] + el + ar)|0; + H[3] = (H[4] + al + br)|0; + H[4] = (H[0] + bl + cr)|0; + H[0] = t; + }, + + _doFinalize: function () { + // Shortcuts + var data = this._data; + var dataWords = data.words; + + var nBitsTotal = this._nDataBytes * 8; + var nBitsLeft = data.sigBytes * 8; + + // Add padding + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = ( + (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) | + (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00) + ); + data.sigBytes = (dataWords.length + 1) * 4; + + // Hash final blocks + this._process(); + + // Shortcuts + var hash = this._hash; + var H = hash.words; + + // Swap endian + for (var i = 0; i < 5; i++) { + // Shortcut + var H_i = H[i]; + + // Swap + H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) | + (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00); + } + + // Return final computed hash + return hash; + }, + + clone: function () { + var clone = Hasher.clone.call(this); + clone._hash = this._hash.clone(); + + return clone; + } + }); + + + function f1(x, y, z) { + return ((x) ^ (y) ^ (z)); + + } + + function f2(x, y, z) { + return (((x)&(y)) | ((~x)&(z))); + } + + function f3(x, y, z) { + return (((x) | (~(y))) ^ (z)); + } + + function f4(x, y, z) { + return (((x) & (z)) | ((y)&(~(z)))); + } + + function f5(x, y, z) { + return ((x) ^ ((y) |(~(z)))); + + } + + function rotl(x,n) { + return (x<>>(32-n)); + } + + + /** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.RIPEMD160('message'); + * var hash = CryptoJS.RIPEMD160(wordArray); + */ + C.RIPEMD160 = Hasher._createHelper(RIPEMD160); + + /** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacRIPEMD160(message, key); + */ + C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160); + }(Math)); + + + return CryptoJS.RIPEMD160; + +})); +}, function(modId) { var map = {"./core":1594611128924}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128937, function(require, module, exports) { +;(function (root, factory) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var Base = C_lib.Base; + var C_enc = C.enc; + var Utf8 = C_enc.Utf8; + var C_algo = C.algo; + + /** + * HMAC algorithm. + */ + var HMAC = C_algo.HMAC = Base.extend({ + /** + * Initializes a newly created HMAC. + * + * @param {Hasher} hasher The hash algorithm to use. + * @param {WordArray|string} key The secret key. + * + * @example + * + * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key); + */ + init: function (hasher, key) { + // Init hasher + hasher = this._hasher = new hasher.init(); + + // Convert string to WordArray, else assume WordArray already + if (typeof key == 'string') { + key = Utf8.parse(key); + } + + // Shortcuts + var hasherBlockSize = hasher.blockSize; + var hasherBlockSizeBytes = hasherBlockSize * 4; + + // Allow arbitrary length keys + if (key.sigBytes > hasherBlockSizeBytes) { + key = hasher.finalize(key); + } + + // Clamp excess bits + key.clamp(); + + // Clone key for inner and outer pads + var oKey = this._oKey = key.clone(); + var iKey = this._iKey = key.clone(); + + // Shortcuts + var oKeyWords = oKey.words; + var iKeyWords = iKey.words; + + // XOR keys with pad constants + for (var i = 0; i < hasherBlockSize; i++) { + oKeyWords[i] ^= 0x5c5c5c5c; + iKeyWords[i] ^= 0x36363636; + } + oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes; + + // Set initial values + this.reset(); + }, + + /** + * Resets this HMAC to its initial state. + * + * @example + * + * hmacHasher.reset(); + */ + reset: function () { + // Shortcut + var hasher = this._hasher; + + // Reset + hasher.reset(); + hasher.update(this._iKey); + }, + + /** + * Updates this HMAC with a message. + * + * @param {WordArray|string} messageUpdate The message to append. + * + * @return {HMAC} This HMAC instance. + * + * @example + * + * hmacHasher.update('message'); + * hmacHasher.update(wordArray); + */ + update: function (messageUpdate) { + this._hasher.update(messageUpdate); + + // Chainable + return this; + }, + + /** + * Finalizes the HMAC computation. + * Note that the finalize operation is effectively a destructive, read-once operation. + * + * @param {WordArray|string} messageUpdate (Optional) A final message update. + * + * @return {WordArray} The HMAC. + * + * @example + * + * var hmac = hmacHasher.finalize(); + * var hmac = hmacHasher.finalize('message'); + * var hmac = hmacHasher.finalize(wordArray); + */ + finalize: function (messageUpdate) { + // Shortcut + var hasher = this._hasher; + + // Compute HMAC + var innerHash = hasher.finalize(messageUpdate); + hasher.reset(); + var hmac = hasher.finalize(this._oKey.clone().concat(innerHash)); + + return hmac; + } + }); + }()); + + +})); +}, function(modId) { var map = {"./core":1594611128924}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128938, function(require, module, exports) { +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./sha1"), require("./hmac")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./sha1", "./hmac"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var Base = C_lib.Base; + var WordArray = C_lib.WordArray; + var C_algo = C.algo; + var SHA1 = C_algo.SHA1; + var HMAC = C_algo.HMAC; + + /** + * Password-Based Key Derivation Function 2 algorithm. + */ + var PBKDF2 = C_algo.PBKDF2 = Base.extend({ + /** + * Configuration options. + * + * @property {number} keySize The key size in words to generate. Default: 4 (128 bits) + * @property {Hasher} hasher The hasher to use. Default: SHA1 + * @property {number} iterations The number of iterations to perform. Default: 1 + */ + cfg: Base.extend({ + keySize: 128/32, + hasher: SHA1, + iterations: 1 + }), + + /** + * Initializes a newly created key derivation function. + * + * @param {Object} cfg (Optional) The configuration options to use for the derivation. + * + * @example + * + * var kdf = CryptoJS.algo.PBKDF2.create(); + * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 }); + * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 }); + */ + init: function (cfg) { + this.cfg = this.cfg.extend(cfg); + }, + + /** + * Computes the Password-Based Key Derivation Function 2. + * + * @param {WordArray|string} password The password. + * @param {WordArray|string} salt A salt. + * + * @return {WordArray} The derived key. + * + * @example + * + * var key = kdf.compute(password, salt); + */ + compute: function (password, salt) { + // Shortcut + var cfg = this.cfg; + + // Init HMAC + var hmac = HMAC.create(cfg.hasher, password); + + // Initial values + var derivedKey = WordArray.create(); + var blockIndex = WordArray.create([0x00000001]); + + // Shortcuts + var derivedKeyWords = derivedKey.words; + var blockIndexWords = blockIndex.words; + var keySize = cfg.keySize; + var iterations = cfg.iterations; + + // Generate key + while (derivedKeyWords.length < keySize) { + var block = hmac.update(salt).finalize(blockIndex); + hmac.reset(); + + // Shortcuts + var blockWords = block.words; + var blockWordsLength = blockWords.length; + + // Iterations + var intermediate = block; + for (var i = 1; i < iterations; i++) { + intermediate = hmac.finalize(intermediate); + hmac.reset(); + + // Shortcut + var intermediateWords = intermediate.words; + + // XOR intermediate with block + for (var j = 0; j < blockWordsLength; j++) { + blockWords[j] ^= intermediateWords[j]; + } + } + + derivedKey.concat(block); + blockIndexWords[0]++; + } + derivedKey.sigBytes = keySize * 4; + + return derivedKey; + } + }); + + /** + * Computes the Password-Based Key Derivation Function 2. + * + * @param {WordArray|string} password The password. + * @param {WordArray|string} salt A salt. + * @param {Object} cfg (Optional) The configuration options to use for this computation. + * + * @return {WordArray} The derived key. + * + * @static + * + * @example + * + * var key = CryptoJS.PBKDF2(password, salt); + * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 }); + * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 }); + */ + C.PBKDF2 = function (password, salt, cfg) { + return PBKDF2.create(cfg).compute(password, salt); + }; + }()); + + + return CryptoJS.PBKDF2; + +})); +}, function(modId) { var map = {"./core":1594611128924,"./sha1":1594611128930,"./hmac":1594611128937}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128939, function(require, module, exports) { +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./sha1"), require("./hmac")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./sha1", "./hmac"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var Base = C_lib.Base; + var WordArray = C_lib.WordArray; + var C_algo = C.algo; + var MD5 = C_algo.MD5; + + /** + * This key derivation function is meant to conform with EVP_BytesToKey. + * www.openssl.org/docs/crypto/EVP_BytesToKey.html + */ + var EvpKDF = C_algo.EvpKDF = Base.extend({ + /** + * Configuration options. + * + * @property {number} keySize The key size in words to generate. Default: 4 (128 bits) + * @property {Hasher} hasher The hash algorithm to use. Default: MD5 + * @property {number} iterations The number of iterations to perform. Default: 1 + */ + cfg: Base.extend({ + keySize: 128/32, + hasher: MD5, + iterations: 1 + }), + + /** + * Initializes a newly created key derivation function. + * + * @param {Object} cfg (Optional) The configuration options to use for the derivation. + * + * @example + * + * var kdf = CryptoJS.algo.EvpKDF.create(); + * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 }); + * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 }); + */ + init: function (cfg) { + this.cfg = this.cfg.extend(cfg); + }, + + /** + * Derives a key from a password. + * + * @param {WordArray|string} password The password. + * @param {WordArray|string} salt A salt. + * + * @return {WordArray} The derived key. + * + * @example + * + * var key = kdf.compute(password, salt); + */ + compute: function (password, salt) { + var block; + + // Shortcut + var cfg = this.cfg; + + // Init hasher + var hasher = cfg.hasher.create(); + + // Initial values + var derivedKey = WordArray.create(); + + // Shortcuts + var derivedKeyWords = derivedKey.words; + var keySize = cfg.keySize; + var iterations = cfg.iterations; + + // Generate key + while (derivedKeyWords.length < keySize) { + if (block) { + hasher.update(block); + } + block = hasher.update(password).finalize(salt); + hasher.reset(); + + // Iterations + for (var i = 1; i < iterations; i++) { + block = hasher.finalize(block); + hasher.reset(); + } + + derivedKey.concat(block); + } + derivedKey.sigBytes = keySize * 4; + + return derivedKey; + } + }); + + /** + * Derives a key from a password. + * + * @param {WordArray|string} password The password. + * @param {WordArray|string} salt A salt. + * @param {Object} cfg (Optional) The configuration options to use for this computation. + * + * @return {WordArray} The derived key. + * + * @static + * + * @example + * + * var key = CryptoJS.EvpKDF(password, salt); + * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 }); + * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 }); + */ + C.EvpKDF = function (password, salt, cfg) { + return EvpKDF.create(cfg).compute(password, salt); + }; + }()); + + + return CryptoJS.EvpKDF; + +})); +}, function(modId) { var map = {"./core":1594611128924,"./sha1":1594611128930,"./hmac":1594611128937}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128940, function(require, module, exports) { +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./evpkdf")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./evpkdf"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + /** + * Cipher core components. + */ + CryptoJS.lib.Cipher || (function (undefined) { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var Base = C_lib.Base; + var WordArray = C_lib.WordArray; + var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm; + var C_enc = C.enc; + var Utf8 = C_enc.Utf8; + var Base64 = C_enc.Base64; + var C_algo = C.algo; + var EvpKDF = C_algo.EvpKDF; + + /** + * Abstract base cipher template. + * + * @property {number} keySize This cipher's key size. Default: 4 (128 bits) + * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits) + * @property {number} _ENC_XFORM_MODE A constant representing encryption mode. + * @property {number} _DEC_XFORM_MODE A constant representing decryption mode. + */ + var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({ + /** + * Configuration options. + * + * @property {WordArray} iv The IV to use for this operation. + */ + cfg: Base.extend(), + + /** + * Creates this cipher in encryption mode. + * + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {Cipher} A cipher instance. + * + * @static + * + * @example + * + * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray }); + */ + createEncryptor: function (key, cfg) { + return this.create(this._ENC_XFORM_MODE, key, cfg); + }, + + /** + * Creates this cipher in decryption mode. + * + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {Cipher} A cipher instance. + * + * @static + * + * @example + * + * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray }); + */ + createDecryptor: function (key, cfg) { + return this.create(this._DEC_XFORM_MODE, key, cfg); + }, + + /** + * Initializes a newly created cipher. + * + * @param {number} xformMode Either the encryption or decryption transormation mode constant. + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @example + * + * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray }); + */ + init: function (xformMode, key, cfg) { + // Apply config defaults + this.cfg = this.cfg.extend(cfg); + + // Store transform mode and key + this._xformMode = xformMode; + this._key = key; + + // Set initial values + this.reset(); + }, + + /** + * Resets this cipher to its initial state. + * + * @example + * + * cipher.reset(); + */ + reset: function () { + // Reset data buffer + BufferedBlockAlgorithm.reset.call(this); + + // Perform concrete-cipher logic + this._doReset(); + }, + + /** + * Adds data to be encrypted or decrypted. + * + * @param {WordArray|string} dataUpdate The data to encrypt or decrypt. + * + * @return {WordArray} The data after processing. + * + * @example + * + * var encrypted = cipher.process('data'); + * var encrypted = cipher.process(wordArray); + */ + process: function (dataUpdate) { + // Append + this._append(dataUpdate); + + // Process available blocks + return this._process(); + }, + + /** + * Finalizes the encryption or decryption process. + * Note that the finalize operation is effectively a destructive, read-once operation. + * + * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt. + * + * @return {WordArray} The data after final processing. + * + * @example + * + * var encrypted = cipher.finalize(); + * var encrypted = cipher.finalize('data'); + * var encrypted = cipher.finalize(wordArray); + */ + finalize: function (dataUpdate) { + // Final data update + if (dataUpdate) { + this._append(dataUpdate); + } + + // Perform concrete-cipher logic + var finalProcessedData = this._doFinalize(); + + return finalProcessedData; + }, + + keySize: 128/32, + + ivSize: 128/32, + + _ENC_XFORM_MODE: 1, + + _DEC_XFORM_MODE: 2, + + /** + * Creates shortcut functions to a cipher's object interface. + * + * @param {Cipher} cipher The cipher to create a helper for. + * + * @return {Object} An object with encrypt and decrypt shortcut functions. + * + * @static + * + * @example + * + * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES); + */ + _createHelper: (function () { + function selectCipherStrategy(key) { + if (typeof key == 'string') { + return PasswordBasedCipher; + } else { + return SerializableCipher; + } + } + + return function (cipher) { + return { + encrypt: function (message, key, cfg) { + return selectCipherStrategy(key).encrypt(cipher, message, key, cfg); + }, + + decrypt: function (ciphertext, key, cfg) { + return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg); + } + }; + }; + }()) + }); + + /** + * Abstract base stream cipher template. + * + * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits) + */ + var StreamCipher = C_lib.StreamCipher = Cipher.extend({ + _doFinalize: function () { + // Process partial blocks + var finalProcessedBlocks = this._process(!!'flush'); + + return finalProcessedBlocks; + }, + + blockSize: 1 + }); + + /** + * Mode namespace. + */ + var C_mode = C.mode = {}; + + /** + * Abstract base block cipher mode template. + */ + var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({ + /** + * Creates this mode for encryption. + * + * @param {Cipher} cipher A block cipher instance. + * @param {Array} iv The IV words. + * + * @static + * + * @example + * + * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words); + */ + createEncryptor: function (cipher, iv) { + return this.Encryptor.create(cipher, iv); + }, + + /** + * Creates this mode for decryption. + * + * @param {Cipher} cipher A block cipher instance. + * @param {Array} iv The IV words. + * + * @static + * + * @example + * + * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words); + */ + createDecryptor: function (cipher, iv) { + return this.Decryptor.create(cipher, iv); + }, + + /** + * Initializes a newly created mode. + * + * @param {Cipher} cipher A block cipher instance. + * @param {Array} iv The IV words. + * + * @example + * + * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words); + */ + init: function (cipher, iv) { + this._cipher = cipher; + this._iv = iv; + } + }); + + /** + * Cipher Block Chaining mode. + */ + var CBC = C_mode.CBC = (function () { + /** + * Abstract base CBC mode. + */ + var CBC = BlockCipherMode.extend(); + + /** + * CBC encryptor. + */ + CBC.Encryptor = CBC.extend({ + /** + * Processes the data block at offset. + * + * @param {Array} words The data words to operate on. + * @param {number} offset The offset where the block starts. + * + * @example + * + * mode.processBlock(data.words, offset); + */ + processBlock: function (words, offset) { + // Shortcuts + var cipher = this._cipher; + var blockSize = cipher.blockSize; + + // XOR and encrypt + xorBlock.call(this, words, offset, blockSize); + cipher.encryptBlock(words, offset); + + // Remember this block to use with next block + this._prevBlock = words.slice(offset, offset + blockSize); + } + }); + + /** + * CBC decryptor. + */ + CBC.Decryptor = CBC.extend({ + /** + * Processes the data block at offset. + * + * @param {Array} words The data words to operate on. + * @param {number} offset The offset where the block starts. + * + * @example + * + * mode.processBlock(data.words, offset); + */ + processBlock: function (words, offset) { + // Shortcuts + var cipher = this._cipher; + var blockSize = cipher.blockSize; + + // Remember this block to use with next block + var thisBlock = words.slice(offset, offset + blockSize); + + // Decrypt and XOR + cipher.decryptBlock(words, offset); + xorBlock.call(this, words, offset, blockSize); + + // This block becomes the previous block + this._prevBlock = thisBlock; + } + }); + + function xorBlock(words, offset, blockSize) { + var block; + + // Shortcut + var iv = this._iv; + + // Choose mixing block + if (iv) { + block = iv; + + // Remove IV for subsequent blocks + this._iv = undefined; + } else { + block = this._prevBlock; + } + + // XOR blocks + for (var i = 0; i < blockSize; i++) { + words[offset + i] ^= block[i]; + } + } + + return CBC; + }()); + + /** + * Padding namespace. + */ + var C_pad = C.pad = {}; + + /** + * PKCS #5/7 padding strategy. + */ + var Pkcs7 = C_pad.Pkcs7 = { + /** + * Pads data using the algorithm defined in PKCS #5/7. + * + * @param {WordArray} data The data to pad. + * @param {number} blockSize The multiple that the data should be padded to. + * + * @static + * + * @example + * + * CryptoJS.pad.Pkcs7.pad(wordArray, 4); + */ + pad: function (data, blockSize) { + // Shortcut + var blockSizeBytes = blockSize * 4; + + // Count padding bytes + var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes; + + // Create padding word + var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes; + + // Create padding + var paddingWords = []; + for (var i = 0; i < nPaddingBytes; i += 4) { + paddingWords.push(paddingWord); + } + var padding = WordArray.create(paddingWords, nPaddingBytes); + + // Add padding + data.concat(padding); + }, + + /** + * Unpads data that had been padded using the algorithm defined in PKCS #5/7. + * + * @param {WordArray} data The data to unpad. + * + * @static + * + * @example + * + * CryptoJS.pad.Pkcs7.unpad(wordArray); + */ + unpad: function (data) { + // Get number of padding bytes from last byte + var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff; + + // Remove padding + data.sigBytes -= nPaddingBytes; + } + }; + + /** + * Abstract base block cipher template. + * + * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits) + */ + var BlockCipher = C_lib.BlockCipher = Cipher.extend({ + /** + * Configuration options. + * + * @property {Mode} mode The block mode to use. Default: CBC + * @property {Padding} padding The padding strategy to use. Default: Pkcs7 + */ + cfg: Cipher.cfg.extend({ + mode: CBC, + padding: Pkcs7 + }), + + reset: function () { + var modeCreator; + + // Reset cipher + Cipher.reset.call(this); + + // Shortcuts + var cfg = this.cfg; + var iv = cfg.iv; + var mode = cfg.mode; + + // Reset block mode + if (this._xformMode == this._ENC_XFORM_MODE) { + modeCreator = mode.createEncryptor; + } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ { + modeCreator = mode.createDecryptor; + // Keep at least one block in the buffer for unpadding + this._minBufferSize = 1; + } + + if (this._mode && this._mode.__creator == modeCreator) { + this._mode.init(this, iv && iv.words); + } else { + this._mode = modeCreator.call(mode, this, iv && iv.words); + this._mode.__creator = modeCreator; + } + }, + + _doProcessBlock: function (words, offset) { + this._mode.processBlock(words, offset); + }, + + _doFinalize: function () { + var finalProcessedBlocks; + + // Shortcut + var padding = this.cfg.padding; + + // Finalize + if (this._xformMode == this._ENC_XFORM_MODE) { + // Pad data + padding.pad(this._data, this.blockSize); + + // Process final blocks + finalProcessedBlocks = this._process(!!'flush'); + } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ { + // Process final blocks + finalProcessedBlocks = this._process(!!'flush'); + + // Unpad data + padding.unpad(finalProcessedBlocks); + } + + return finalProcessedBlocks; + }, + + blockSize: 128/32 + }); + + /** + * A collection of cipher parameters. + * + * @property {WordArray} ciphertext The raw ciphertext. + * @property {WordArray} key The key to this ciphertext. + * @property {WordArray} iv The IV used in the ciphering operation. + * @property {WordArray} salt The salt used with a key derivation function. + * @property {Cipher} algorithm The cipher algorithm. + * @property {Mode} mode The block mode used in the ciphering operation. + * @property {Padding} padding The padding scheme used in the ciphering operation. + * @property {number} blockSize The block size of the cipher. + * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string. + */ + var CipherParams = C_lib.CipherParams = Base.extend({ + /** + * Initializes a newly created cipher params object. + * + * @param {Object} cipherParams An object with any of the possible cipher parameters. + * + * @example + * + * var cipherParams = CryptoJS.lib.CipherParams.create({ + * ciphertext: ciphertextWordArray, + * key: keyWordArray, + * iv: ivWordArray, + * salt: saltWordArray, + * algorithm: CryptoJS.algo.AES, + * mode: CryptoJS.mode.CBC, + * padding: CryptoJS.pad.PKCS7, + * blockSize: 4, + * formatter: CryptoJS.format.OpenSSL + * }); + */ + init: function (cipherParams) { + this.mixIn(cipherParams); + }, + + /** + * Converts this cipher params object to a string. + * + * @param {Format} formatter (Optional) The formatting strategy to use. + * + * @return {string} The stringified cipher params. + * + * @throws Error If neither the formatter nor the default formatter is set. + * + * @example + * + * var string = cipherParams + ''; + * var string = cipherParams.toString(); + * var string = cipherParams.toString(CryptoJS.format.OpenSSL); + */ + toString: function (formatter) { + return (formatter || this.formatter).stringify(this); + } + }); + + /** + * Format namespace. + */ + var C_format = C.format = {}; + + /** + * OpenSSL formatting strategy. + */ + var OpenSSLFormatter = C_format.OpenSSL = { + /** + * Converts a cipher params object to an OpenSSL-compatible string. + * + * @param {CipherParams} cipherParams The cipher params object. + * + * @return {string} The OpenSSL-compatible string. + * + * @static + * + * @example + * + * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams); + */ + stringify: function (cipherParams) { + var wordArray; + + // Shortcuts + var ciphertext = cipherParams.ciphertext; + var salt = cipherParams.salt; + + // Format + if (salt) { + wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext); + } else { + wordArray = ciphertext; + } + + return wordArray.toString(Base64); + }, + + /** + * Converts an OpenSSL-compatible string to a cipher params object. + * + * @param {string} openSSLStr The OpenSSL-compatible string. + * + * @return {CipherParams} The cipher params object. + * + * @static + * + * @example + * + * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString); + */ + parse: function (openSSLStr) { + var salt; + + // Parse base64 + var ciphertext = Base64.parse(openSSLStr); + + // Shortcut + var ciphertextWords = ciphertext.words; + + // Test for salt + if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) { + // Extract salt + salt = WordArray.create(ciphertextWords.slice(2, 4)); + + // Remove salt from ciphertext + ciphertextWords.splice(0, 4); + ciphertext.sigBytes -= 16; + } + + return CipherParams.create({ ciphertext: ciphertext, salt: salt }); + } + }; + + /** + * A cipher wrapper that returns ciphertext as a serializable cipher params object. + */ + var SerializableCipher = C_lib.SerializableCipher = Base.extend({ + /** + * Configuration options. + * + * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL + */ + cfg: Base.extend({ + format: OpenSSLFormatter + }), + + /** + * Encrypts a message. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {WordArray|string} message The message to encrypt. + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {CipherParams} A cipher params object. + * + * @static + * + * @example + * + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key); + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv }); + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + */ + encrypt: function (cipher, message, key, cfg) { + // Apply config defaults + cfg = this.cfg.extend(cfg); + + // Encrypt + var encryptor = cipher.createEncryptor(key, cfg); + var ciphertext = encryptor.finalize(message); + + // Shortcut + var cipherCfg = encryptor.cfg; + + // Create and return serializable cipher params + return CipherParams.create({ + ciphertext: ciphertext, + key: key, + iv: cipherCfg.iv, + algorithm: cipher, + mode: cipherCfg.mode, + padding: cipherCfg.padding, + blockSize: cipher.blockSize, + formatter: cfg.format + }); + }, + + /** + * Decrypts serialized ciphertext. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {CipherParams|string} ciphertext The ciphertext to decrypt. + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {WordArray} The plaintext. + * + * @static + * + * @example + * + * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + */ + decrypt: function (cipher, ciphertext, key, cfg) { + // Apply config defaults + cfg = this.cfg.extend(cfg); + + // Convert string to CipherParams + ciphertext = this._parse(ciphertext, cfg.format); + + // Decrypt + var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext); + + return plaintext; + }, + + /** + * Converts serialized ciphertext to CipherParams, + * else assumed CipherParams already and returns ciphertext unchanged. + * + * @param {CipherParams|string} ciphertext The ciphertext. + * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext. + * + * @return {CipherParams} The unserialized ciphertext. + * + * @static + * + * @example + * + * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format); + */ + _parse: function (ciphertext, format) { + if (typeof ciphertext == 'string') { + return format.parse(ciphertext, this); + } else { + return ciphertext; + } + } + }); + + /** + * Key derivation function namespace. + */ + var C_kdf = C.kdf = {}; + + /** + * OpenSSL key derivation function. + */ + var OpenSSLKdf = C_kdf.OpenSSL = { + /** + * Derives a key and IV from a password. + * + * @param {string} password The password to derive from. + * @param {number} keySize The size in words of the key to generate. + * @param {number} ivSize The size in words of the IV to generate. + * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly. + * + * @return {CipherParams} A cipher params object with the key, IV, and salt. + * + * @static + * + * @example + * + * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32); + * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt'); + */ + execute: function (password, keySize, ivSize, salt) { + // Generate random salt + if (!salt) { + salt = WordArray.random(64/8); + } + + // Derive key and IV + var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt); + + // Separate key and IV + var iv = WordArray.create(key.words.slice(keySize), ivSize * 4); + key.sigBytes = keySize * 4; + + // Return params + return CipherParams.create({ key: key, iv: iv, salt: salt }); + } + }; + + /** + * A serializable cipher wrapper that derives the key from a password, + * and returns ciphertext as a serializable cipher params object. + */ + var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({ + /** + * Configuration options. + * + * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL + */ + cfg: SerializableCipher.cfg.extend({ + kdf: OpenSSLKdf + }), + + /** + * Encrypts a message using a password. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {WordArray|string} message The message to encrypt. + * @param {string} password The password. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {CipherParams} A cipher params object. + * + * @static + * + * @example + * + * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password'); + * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL }); + */ + encrypt: function (cipher, message, password, cfg) { + // Apply config defaults + cfg = this.cfg.extend(cfg); + + // Derive key and other params + var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize); + + // Add IV to config + cfg.iv = derivedParams.iv; + + // Encrypt + var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg); + + // Mix in derived params + ciphertext.mixIn(derivedParams); + + return ciphertext; + }, + + /** + * Decrypts serialized ciphertext using a password. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {CipherParams|string} ciphertext The ciphertext to decrypt. + * @param {string} password The password. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {WordArray} The plaintext. + * + * @static + * + * @example + * + * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL }); + * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL }); + */ + decrypt: function (cipher, ciphertext, password, cfg) { + // Apply config defaults + cfg = this.cfg.extend(cfg); + + // Convert string to CipherParams + ciphertext = this._parse(ciphertext, cfg.format); + + // Derive key and other params + var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt); + + // Add IV to config + cfg.iv = derivedParams.iv; + + // Decrypt + var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg); + + return plaintext; + } + }); + }()); + + +})); +}, function(modId) { var map = {"./core":1594611128924,"./evpkdf":1594611128939}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128941, function(require, module, exports) { +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + /** + * Cipher Feedback block mode. + */ + CryptoJS.mode.CFB = (function () { + var CFB = CryptoJS.lib.BlockCipherMode.extend(); + + CFB.Encryptor = CFB.extend({ + processBlock: function (words, offset) { + // Shortcuts + var cipher = this._cipher; + var blockSize = cipher.blockSize; + + generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher); + + // Remember this block to use with next block + this._prevBlock = words.slice(offset, offset + blockSize); + } + }); + + CFB.Decryptor = CFB.extend({ + processBlock: function (words, offset) { + // Shortcuts + var cipher = this._cipher; + var blockSize = cipher.blockSize; + + // Remember this block to use with next block + var thisBlock = words.slice(offset, offset + blockSize); + + generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher); + + // This block becomes the previous block + this._prevBlock = thisBlock; + } + }); + + function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) { + var keystream; + + // Shortcut + var iv = this._iv; + + // Generate keystream + if (iv) { + keystream = iv.slice(0); + + // Remove IV for subsequent blocks + this._iv = undefined; + } else { + keystream = this._prevBlock; + } + cipher.encryptBlock(keystream, 0); + + // Encrypt + for (var i = 0; i < blockSize; i++) { + words[offset + i] ^= keystream[i]; + } + } + + return CFB; + }()); + + + return CryptoJS.mode.CFB; + +})); +}, function(modId) { var map = {"./core":1594611128924,"./cipher-core":1594611128940}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128942, function(require, module, exports) { +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + /** + * Counter block mode. + */ + CryptoJS.mode.CTR = (function () { + var CTR = CryptoJS.lib.BlockCipherMode.extend(); + + var Encryptor = CTR.Encryptor = CTR.extend({ + processBlock: function (words, offset) { + // Shortcuts + var cipher = this._cipher + var blockSize = cipher.blockSize; + var iv = this._iv; + var counter = this._counter; + + // Generate keystream + if (iv) { + counter = this._counter = iv.slice(0); + + // Remove IV for subsequent blocks + this._iv = undefined; + } + var keystream = counter.slice(0); + cipher.encryptBlock(keystream, 0); + + // Increment counter + counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0 + + // Encrypt + for (var i = 0; i < blockSize; i++) { + words[offset + i] ^= keystream[i]; + } + } + }); + + CTR.Decryptor = Encryptor; + + return CTR; + }()); + + + return CryptoJS.mode.CTR; + +})); +}, function(modId) { var map = {"./core":1594611128924,"./cipher-core":1594611128940}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128943, function(require, module, exports) { +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + /** @preserve + * Counter block mode compatible with Dr Brian Gladman fileenc.c + * derived from CryptoJS.mode.CTR + * Jan Hruby jhruby.web@gmail.com + */ + CryptoJS.mode.CTRGladman = (function () { + var CTRGladman = CryptoJS.lib.BlockCipherMode.extend(); + + function incWord(word) + { + if (((word >> 24) & 0xff) === 0xff) { //overflow + var b1 = (word >> 16)&0xff; + var b2 = (word >> 8)&0xff; + var b3 = word & 0xff; + + if (b1 === 0xff) // overflow b1 + { + b1 = 0; + if (b2 === 0xff) + { + b2 = 0; + if (b3 === 0xff) + { + b3 = 0; + } + else + { + ++b3; + } + } + else + { + ++b2; + } + } + else + { + ++b1; + } + + word = 0; + word += (b1 << 16); + word += (b2 << 8); + word += b3; + } + else + { + word += (0x01 << 24); + } + return word; + } + + function incCounter(counter) + { + if ((counter[0] = incWord(counter[0])) === 0) + { + // encr_data in fileenc.c from Dr Brian Gladman's counts only with DWORD j < 8 + counter[1] = incWord(counter[1]); + } + return counter; + } + + var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({ + processBlock: function (words, offset) { + // Shortcuts + var cipher = this._cipher + var blockSize = cipher.blockSize; + var iv = this._iv; + var counter = this._counter; + + // Generate keystream + if (iv) { + counter = this._counter = iv.slice(0); + + // Remove IV for subsequent blocks + this._iv = undefined; + } + + incCounter(counter); + + var keystream = counter.slice(0); + cipher.encryptBlock(keystream, 0); + + // Encrypt + for (var i = 0; i < blockSize; i++) { + words[offset + i] ^= keystream[i]; + } + } + }); + + CTRGladman.Decryptor = Encryptor; + + return CTRGladman; + }()); + + + + + return CryptoJS.mode.CTRGladman; + +})); +}, function(modId) { var map = {"./core":1594611128924,"./cipher-core":1594611128940}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128944, function(require, module, exports) { +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + /** + * Output Feedback block mode. + */ + CryptoJS.mode.OFB = (function () { + var OFB = CryptoJS.lib.BlockCipherMode.extend(); + + var Encryptor = OFB.Encryptor = OFB.extend({ + processBlock: function (words, offset) { + // Shortcuts + var cipher = this._cipher + var blockSize = cipher.blockSize; + var iv = this._iv; + var keystream = this._keystream; + + // Generate keystream + if (iv) { + keystream = this._keystream = iv.slice(0); + + // Remove IV for subsequent blocks + this._iv = undefined; + } + cipher.encryptBlock(keystream, 0); + + // Encrypt + for (var i = 0; i < blockSize; i++) { + words[offset + i] ^= keystream[i]; + } + } + }); + + OFB.Decryptor = Encryptor; + + return OFB; + }()); + + + return CryptoJS.mode.OFB; + +})); +}, function(modId) { var map = {"./core":1594611128924,"./cipher-core":1594611128940}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128945, function(require, module, exports) { +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + /** + * Electronic Codebook block mode. + */ + CryptoJS.mode.ECB = (function () { + var ECB = CryptoJS.lib.BlockCipherMode.extend(); + + ECB.Encryptor = ECB.extend({ + processBlock: function (words, offset) { + this._cipher.encryptBlock(words, offset); + } + }); + + ECB.Decryptor = ECB.extend({ + processBlock: function (words, offset) { + this._cipher.decryptBlock(words, offset); + } + }); + + return ECB; + }()); + + + return CryptoJS.mode.ECB; + +})); +}, function(modId) { var map = {"./core":1594611128924,"./cipher-core":1594611128940}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128946, function(require, module, exports) { +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + /** + * ANSI X.923 padding strategy. + */ + CryptoJS.pad.AnsiX923 = { + pad: function (data, blockSize) { + // Shortcuts + var dataSigBytes = data.sigBytes; + var blockSizeBytes = blockSize * 4; + + // Count padding bytes + var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes; + + // Compute last byte position + var lastBytePos = dataSigBytes + nPaddingBytes - 1; + + // Pad + data.clamp(); + data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8); + data.sigBytes += nPaddingBytes; + }, + + unpad: function (data) { + // Get number of padding bytes from last byte + var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff; + + // Remove padding + data.sigBytes -= nPaddingBytes; + } + }; + + + return CryptoJS.pad.Ansix923; + +})); +}, function(modId) { var map = {"./core":1594611128924,"./cipher-core":1594611128940}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128947, function(require, module, exports) { +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + /** + * ISO 10126 padding strategy. + */ + CryptoJS.pad.Iso10126 = { + pad: function (data, blockSize) { + // Shortcut + var blockSizeBytes = blockSize * 4; + + // Count padding bytes + var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes; + + // Pad + data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes - 1)). + concat(CryptoJS.lib.WordArray.create([nPaddingBytes << 24], 1)); + }, + + unpad: function (data) { + // Get number of padding bytes from last byte + var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff; + + // Remove padding + data.sigBytes -= nPaddingBytes; + } + }; + + + return CryptoJS.pad.Iso10126; + +})); +}, function(modId) { var map = {"./core":1594611128924,"./cipher-core":1594611128940}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128948, function(require, module, exports) { +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + /** + * ISO/IEC 9797-1 Padding Method 2. + */ + CryptoJS.pad.Iso97971 = { + pad: function (data, blockSize) { + // Add 0x80 byte + data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1)); + + // Zero pad the rest + CryptoJS.pad.ZeroPadding.pad(data, blockSize); + }, + + unpad: function (data) { + // Remove zero padding + CryptoJS.pad.ZeroPadding.unpad(data); + + // Remove one more byte -- the 0x80 byte + data.sigBytes--; + } + }; + + + return CryptoJS.pad.Iso97971; + +})); +}, function(modId) { var map = {"./core":1594611128924,"./cipher-core":1594611128940}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128949, function(require, module, exports) { +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + /** + * Zero padding strategy. + */ + CryptoJS.pad.ZeroPadding = { + pad: function (data, blockSize) { + // Shortcut + var blockSizeBytes = blockSize * 4; + + // Pad + data.clamp(); + data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes); + }, + + unpad: function (data) { + // Shortcut + var dataWords = data.words; + + // Unpad + var i = data.sigBytes - 1; + for (var i = data.sigBytes - 1; i >= 0; i--) { + if (((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) { + data.sigBytes = i + 1; + break; + } + } + } + }; + + + return CryptoJS.pad.ZeroPadding; + +})); +}, function(modId) { var map = {"./core":1594611128924,"./cipher-core":1594611128940}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128950, function(require, module, exports) { +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + /** + * A noop padding strategy. + */ + CryptoJS.pad.NoPadding = { + pad: function () { + }, + + unpad: function () { + } + }; + + + return CryptoJS.pad.NoPadding; + +})); +}, function(modId) { var map = {"./core":1594611128924,"./cipher-core":1594611128940}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128951, function(require, module, exports) { +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function (undefined) { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var CipherParams = C_lib.CipherParams; + var C_enc = C.enc; + var Hex = C_enc.Hex; + var C_format = C.format; + + var HexFormatter = C_format.Hex = { + /** + * Converts the ciphertext of a cipher params object to a hexadecimally encoded string. + * + * @param {CipherParams} cipherParams The cipher params object. + * + * @return {string} The hexadecimally encoded string. + * + * @static + * + * @example + * + * var hexString = CryptoJS.format.Hex.stringify(cipherParams); + */ + stringify: function (cipherParams) { + return cipherParams.ciphertext.toString(Hex); + }, + + /** + * Converts a hexadecimally encoded ciphertext string to a cipher params object. + * + * @param {string} input The hexadecimally encoded string. + * + * @return {CipherParams} The cipher params object. + * + * @static + * + * @example + * + * var cipherParams = CryptoJS.format.Hex.parse(hexString); + */ + parse: function (input) { + var ciphertext = Hex.parse(input); + return CipherParams.create({ ciphertext: ciphertext }); + } + }; + }()); + + + return CryptoJS.format.Hex; + +})); +}, function(modId) { var map = {"./core":1594611128924,"./cipher-core":1594611128940}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128952, function(require, module, exports) { +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var BlockCipher = C_lib.BlockCipher; + var C_algo = C.algo; + + // Lookup tables + var SBOX = []; + var INV_SBOX = []; + var SUB_MIX_0 = []; + var SUB_MIX_1 = []; + var SUB_MIX_2 = []; + var SUB_MIX_3 = []; + var INV_SUB_MIX_0 = []; + var INV_SUB_MIX_1 = []; + var INV_SUB_MIX_2 = []; + var INV_SUB_MIX_3 = []; + + // Compute lookup tables + (function () { + // Compute double table + var d = []; + for (var i = 0; i < 256; i++) { + if (i < 128) { + d[i] = i << 1; + } else { + d[i] = (i << 1) ^ 0x11b; + } + } + + // Walk GF(2^8) + var x = 0; + var xi = 0; + for (var i = 0; i < 256; i++) { + // Compute sbox + var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4); + sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63; + SBOX[x] = sx; + INV_SBOX[sx] = x; + + // Compute multiplication + var x2 = d[x]; + var x4 = d[x2]; + var x8 = d[x4]; + + // Compute sub bytes, mix columns tables + var t = (d[sx] * 0x101) ^ (sx * 0x1010100); + SUB_MIX_0[x] = (t << 24) | (t >>> 8); + SUB_MIX_1[x] = (t << 16) | (t >>> 16); + SUB_MIX_2[x] = (t << 8) | (t >>> 24); + SUB_MIX_3[x] = t; + + // Compute inv sub bytes, inv mix columns tables + var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100); + INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8); + INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16); + INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24); + INV_SUB_MIX_3[sx] = t; + + // Compute next counter + if (!x) { + x = xi = 1; + } else { + x = x2 ^ d[d[d[x8 ^ x2]]]; + xi ^= d[d[xi]]; + } + } + }()); + + // Precomputed Rcon lookup + var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36]; + + /** + * AES block cipher algorithm. + */ + var AES = C_algo.AES = BlockCipher.extend({ + _doReset: function () { + var t; + + // Skip reset of nRounds has been set before and key did not change + if (this._nRounds && this._keyPriorReset === this._key) { + return; + } + + // Shortcuts + var key = this._keyPriorReset = this._key; + var keyWords = key.words; + var keySize = key.sigBytes / 4; + + // Compute number of rounds + var nRounds = this._nRounds = keySize + 6; + + // Compute number of key schedule rows + var ksRows = (nRounds + 1) * 4; + + // Compute key schedule + var keySchedule = this._keySchedule = []; + for (var ksRow = 0; ksRow < ksRows; ksRow++) { + if (ksRow < keySize) { + keySchedule[ksRow] = keyWords[ksRow]; + } else { + t = keySchedule[ksRow - 1]; + + if (!(ksRow % keySize)) { + // Rot word + t = (t << 8) | (t >>> 24); + + // Sub word + t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff]; + + // Mix Rcon + t ^= RCON[(ksRow / keySize) | 0] << 24; + } else if (keySize > 6 && ksRow % keySize == 4) { + // Sub word + t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff]; + } + + keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t; + } + } + + // Compute inv key schedule + var invKeySchedule = this._invKeySchedule = []; + for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) { + var ksRow = ksRows - invKsRow; + + if (invKsRow % 4) { + var t = keySchedule[ksRow]; + } else { + var t = keySchedule[ksRow - 4]; + } + + if (invKsRow < 4 || ksRow <= 4) { + invKeySchedule[invKsRow] = t; + } else { + invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^ + INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]]; + } + } + }, + + encryptBlock: function (M, offset) { + this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX); + }, + + decryptBlock: function (M, offset) { + // Swap 2nd and 4th rows + var t = M[offset + 1]; + M[offset + 1] = M[offset + 3]; + M[offset + 3] = t; + + this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX); + + // Inv swap 2nd and 4th rows + var t = M[offset + 1]; + M[offset + 1] = M[offset + 3]; + M[offset + 3] = t; + }, + + _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) { + // Shortcut + var nRounds = this._nRounds; + + // Get input, add round key + var s0 = M[offset] ^ keySchedule[0]; + var s1 = M[offset + 1] ^ keySchedule[1]; + var s2 = M[offset + 2] ^ keySchedule[2]; + var s3 = M[offset + 3] ^ keySchedule[3]; + + // Key schedule row counter + var ksRow = 4; + + // Rounds + for (var round = 1; round < nRounds; round++) { + // Shift rows, sub bytes, mix columns, add round key + var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++]; + var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++]; + var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++]; + var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++]; + + // Update state + s0 = t0; + s1 = t1; + s2 = t2; + s3 = t3; + } + + // Shift rows, sub bytes, add round key + var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++]; + var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++]; + var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++]; + var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++]; + + // Set output + M[offset] = t0; + M[offset + 1] = t1; + M[offset + 2] = t2; + M[offset + 3] = t3; + }, + + keySize: 256/32 + }); + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg); + * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg); + */ + C.AES = BlockCipher._createHelper(AES); + }()); + + + return CryptoJS.AES; + +})); +}, function(modId) { var map = {"./core":1594611128924,"./enc-base64":1594611128928,"./md5":1594611128929,"./evpkdf":1594611128939,"./cipher-core":1594611128940}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128953, function(require, module, exports) { +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var BlockCipher = C_lib.BlockCipher; + var C_algo = C.algo; + + // Permuted Choice 1 constants + var PC1 = [ + 57, 49, 41, 33, 25, 17, 9, 1, + 58, 50, 42, 34, 26, 18, 10, 2, + 59, 51, 43, 35, 27, 19, 11, 3, + 60, 52, 44, 36, 63, 55, 47, 39, + 31, 23, 15, 7, 62, 54, 46, 38, + 30, 22, 14, 6, 61, 53, 45, 37, + 29, 21, 13, 5, 28, 20, 12, 4 + ]; + + // Permuted Choice 2 constants + var PC2 = [ + 14, 17, 11, 24, 1, 5, + 3, 28, 15, 6, 21, 10, + 23, 19, 12, 4, 26, 8, + 16, 7, 27, 20, 13, 2, + 41, 52, 31, 37, 47, 55, + 30, 40, 51, 45, 33, 48, + 44, 49, 39, 56, 34, 53, + 46, 42, 50, 36, 29, 32 + ]; + + // Cumulative bit shift constants + var BIT_SHIFTS = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28]; + + // SBOXes and round permutation constants + var SBOX_P = [ + { + 0x0: 0x808200, + 0x10000000: 0x8000, + 0x20000000: 0x808002, + 0x30000000: 0x2, + 0x40000000: 0x200, + 0x50000000: 0x808202, + 0x60000000: 0x800202, + 0x70000000: 0x800000, + 0x80000000: 0x202, + 0x90000000: 0x800200, + 0xa0000000: 0x8200, + 0xb0000000: 0x808000, + 0xc0000000: 0x8002, + 0xd0000000: 0x800002, + 0xe0000000: 0x0, + 0xf0000000: 0x8202, + 0x8000000: 0x0, + 0x18000000: 0x808202, + 0x28000000: 0x8202, + 0x38000000: 0x8000, + 0x48000000: 0x808200, + 0x58000000: 0x200, + 0x68000000: 0x808002, + 0x78000000: 0x2, + 0x88000000: 0x800200, + 0x98000000: 0x8200, + 0xa8000000: 0x808000, + 0xb8000000: 0x800202, + 0xc8000000: 0x800002, + 0xd8000000: 0x8002, + 0xe8000000: 0x202, + 0xf8000000: 0x800000, + 0x1: 0x8000, + 0x10000001: 0x2, + 0x20000001: 0x808200, + 0x30000001: 0x800000, + 0x40000001: 0x808002, + 0x50000001: 0x8200, + 0x60000001: 0x200, + 0x70000001: 0x800202, + 0x80000001: 0x808202, + 0x90000001: 0x808000, + 0xa0000001: 0x800002, + 0xb0000001: 0x8202, + 0xc0000001: 0x202, + 0xd0000001: 0x800200, + 0xe0000001: 0x8002, + 0xf0000001: 0x0, + 0x8000001: 0x808202, + 0x18000001: 0x808000, + 0x28000001: 0x800000, + 0x38000001: 0x200, + 0x48000001: 0x8000, + 0x58000001: 0x800002, + 0x68000001: 0x2, + 0x78000001: 0x8202, + 0x88000001: 0x8002, + 0x98000001: 0x800202, + 0xa8000001: 0x202, + 0xb8000001: 0x808200, + 0xc8000001: 0x800200, + 0xd8000001: 0x0, + 0xe8000001: 0x8200, + 0xf8000001: 0x808002 + }, + { + 0x0: 0x40084010, + 0x1000000: 0x4000, + 0x2000000: 0x80000, + 0x3000000: 0x40080010, + 0x4000000: 0x40000010, + 0x5000000: 0x40084000, + 0x6000000: 0x40004000, + 0x7000000: 0x10, + 0x8000000: 0x84000, + 0x9000000: 0x40004010, + 0xa000000: 0x40000000, + 0xb000000: 0x84010, + 0xc000000: 0x80010, + 0xd000000: 0x0, + 0xe000000: 0x4010, + 0xf000000: 0x40080000, + 0x800000: 0x40004000, + 0x1800000: 0x84010, + 0x2800000: 0x10, + 0x3800000: 0x40004010, + 0x4800000: 0x40084010, + 0x5800000: 0x40000000, + 0x6800000: 0x80000, + 0x7800000: 0x40080010, + 0x8800000: 0x80010, + 0x9800000: 0x0, + 0xa800000: 0x4000, + 0xb800000: 0x40080000, + 0xc800000: 0x40000010, + 0xd800000: 0x84000, + 0xe800000: 0x40084000, + 0xf800000: 0x4010, + 0x10000000: 0x0, + 0x11000000: 0x40080010, + 0x12000000: 0x40004010, + 0x13000000: 0x40084000, + 0x14000000: 0x40080000, + 0x15000000: 0x10, + 0x16000000: 0x84010, + 0x17000000: 0x4000, + 0x18000000: 0x4010, + 0x19000000: 0x80000, + 0x1a000000: 0x80010, + 0x1b000000: 0x40000010, + 0x1c000000: 0x84000, + 0x1d000000: 0x40004000, + 0x1e000000: 0x40000000, + 0x1f000000: 0x40084010, + 0x10800000: 0x84010, + 0x11800000: 0x80000, + 0x12800000: 0x40080000, + 0x13800000: 0x4000, + 0x14800000: 0x40004000, + 0x15800000: 0x40084010, + 0x16800000: 0x10, + 0x17800000: 0x40000000, + 0x18800000: 0x40084000, + 0x19800000: 0x40000010, + 0x1a800000: 0x40004010, + 0x1b800000: 0x80010, + 0x1c800000: 0x0, + 0x1d800000: 0x4010, + 0x1e800000: 0x40080010, + 0x1f800000: 0x84000 + }, + { + 0x0: 0x104, + 0x100000: 0x0, + 0x200000: 0x4000100, + 0x300000: 0x10104, + 0x400000: 0x10004, + 0x500000: 0x4000004, + 0x600000: 0x4010104, + 0x700000: 0x4010000, + 0x800000: 0x4000000, + 0x900000: 0x4010100, + 0xa00000: 0x10100, + 0xb00000: 0x4010004, + 0xc00000: 0x4000104, + 0xd00000: 0x10000, + 0xe00000: 0x4, + 0xf00000: 0x100, + 0x80000: 0x4010100, + 0x180000: 0x4010004, + 0x280000: 0x0, + 0x380000: 0x4000100, + 0x480000: 0x4000004, + 0x580000: 0x10000, + 0x680000: 0x10004, + 0x780000: 0x104, + 0x880000: 0x4, + 0x980000: 0x100, + 0xa80000: 0x4010000, + 0xb80000: 0x10104, + 0xc80000: 0x10100, + 0xd80000: 0x4000104, + 0xe80000: 0x4010104, + 0xf80000: 0x4000000, + 0x1000000: 0x4010100, + 0x1100000: 0x10004, + 0x1200000: 0x10000, + 0x1300000: 0x4000100, + 0x1400000: 0x100, + 0x1500000: 0x4010104, + 0x1600000: 0x4000004, + 0x1700000: 0x0, + 0x1800000: 0x4000104, + 0x1900000: 0x4000000, + 0x1a00000: 0x4, + 0x1b00000: 0x10100, + 0x1c00000: 0x4010000, + 0x1d00000: 0x104, + 0x1e00000: 0x10104, + 0x1f00000: 0x4010004, + 0x1080000: 0x4000000, + 0x1180000: 0x104, + 0x1280000: 0x4010100, + 0x1380000: 0x0, + 0x1480000: 0x10004, + 0x1580000: 0x4000100, + 0x1680000: 0x100, + 0x1780000: 0x4010004, + 0x1880000: 0x10000, + 0x1980000: 0x4010104, + 0x1a80000: 0x10104, + 0x1b80000: 0x4000004, + 0x1c80000: 0x4000104, + 0x1d80000: 0x4010000, + 0x1e80000: 0x4, + 0x1f80000: 0x10100 + }, + { + 0x0: 0x80401000, + 0x10000: 0x80001040, + 0x20000: 0x401040, + 0x30000: 0x80400000, + 0x40000: 0x0, + 0x50000: 0x401000, + 0x60000: 0x80000040, + 0x70000: 0x400040, + 0x80000: 0x80000000, + 0x90000: 0x400000, + 0xa0000: 0x40, + 0xb0000: 0x80001000, + 0xc0000: 0x80400040, + 0xd0000: 0x1040, + 0xe0000: 0x1000, + 0xf0000: 0x80401040, + 0x8000: 0x80001040, + 0x18000: 0x40, + 0x28000: 0x80400040, + 0x38000: 0x80001000, + 0x48000: 0x401000, + 0x58000: 0x80401040, + 0x68000: 0x0, + 0x78000: 0x80400000, + 0x88000: 0x1000, + 0x98000: 0x80401000, + 0xa8000: 0x400000, + 0xb8000: 0x1040, + 0xc8000: 0x80000000, + 0xd8000: 0x400040, + 0xe8000: 0x401040, + 0xf8000: 0x80000040, + 0x100000: 0x400040, + 0x110000: 0x401000, + 0x120000: 0x80000040, + 0x130000: 0x0, + 0x140000: 0x1040, + 0x150000: 0x80400040, + 0x160000: 0x80401000, + 0x170000: 0x80001040, + 0x180000: 0x80401040, + 0x190000: 0x80000000, + 0x1a0000: 0x80400000, + 0x1b0000: 0x401040, + 0x1c0000: 0x80001000, + 0x1d0000: 0x400000, + 0x1e0000: 0x40, + 0x1f0000: 0x1000, + 0x108000: 0x80400000, + 0x118000: 0x80401040, + 0x128000: 0x0, + 0x138000: 0x401000, + 0x148000: 0x400040, + 0x158000: 0x80000000, + 0x168000: 0x80001040, + 0x178000: 0x40, + 0x188000: 0x80000040, + 0x198000: 0x1000, + 0x1a8000: 0x80001000, + 0x1b8000: 0x80400040, + 0x1c8000: 0x1040, + 0x1d8000: 0x80401000, + 0x1e8000: 0x400000, + 0x1f8000: 0x401040 + }, + { + 0x0: 0x80, + 0x1000: 0x1040000, + 0x2000: 0x40000, + 0x3000: 0x20000000, + 0x4000: 0x20040080, + 0x5000: 0x1000080, + 0x6000: 0x21000080, + 0x7000: 0x40080, + 0x8000: 0x1000000, + 0x9000: 0x20040000, + 0xa000: 0x20000080, + 0xb000: 0x21040080, + 0xc000: 0x21040000, + 0xd000: 0x0, + 0xe000: 0x1040080, + 0xf000: 0x21000000, + 0x800: 0x1040080, + 0x1800: 0x21000080, + 0x2800: 0x80, + 0x3800: 0x1040000, + 0x4800: 0x40000, + 0x5800: 0x20040080, + 0x6800: 0x21040000, + 0x7800: 0x20000000, + 0x8800: 0x20040000, + 0x9800: 0x0, + 0xa800: 0x21040080, + 0xb800: 0x1000080, + 0xc800: 0x20000080, + 0xd800: 0x21000000, + 0xe800: 0x1000000, + 0xf800: 0x40080, + 0x10000: 0x40000, + 0x11000: 0x80, + 0x12000: 0x20000000, + 0x13000: 0x21000080, + 0x14000: 0x1000080, + 0x15000: 0x21040000, + 0x16000: 0x20040080, + 0x17000: 0x1000000, + 0x18000: 0x21040080, + 0x19000: 0x21000000, + 0x1a000: 0x1040000, + 0x1b000: 0x20040000, + 0x1c000: 0x40080, + 0x1d000: 0x20000080, + 0x1e000: 0x0, + 0x1f000: 0x1040080, + 0x10800: 0x21000080, + 0x11800: 0x1000000, + 0x12800: 0x1040000, + 0x13800: 0x20040080, + 0x14800: 0x20000000, + 0x15800: 0x1040080, + 0x16800: 0x80, + 0x17800: 0x21040000, + 0x18800: 0x40080, + 0x19800: 0x21040080, + 0x1a800: 0x0, + 0x1b800: 0x21000000, + 0x1c800: 0x1000080, + 0x1d800: 0x40000, + 0x1e800: 0x20040000, + 0x1f800: 0x20000080 + }, + { + 0x0: 0x10000008, + 0x100: 0x2000, + 0x200: 0x10200000, + 0x300: 0x10202008, + 0x400: 0x10002000, + 0x500: 0x200000, + 0x600: 0x200008, + 0x700: 0x10000000, + 0x800: 0x0, + 0x900: 0x10002008, + 0xa00: 0x202000, + 0xb00: 0x8, + 0xc00: 0x10200008, + 0xd00: 0x202008, + 0xe00: 0x2008, + 0xf00: 0x10202000, + 0x80: 0x10200000, + 0x180: 0x10202008, + 0x280: 0x8, + 0x380: 0x200000, + 0x480: 0x202008, + 0x580: 0x10000008, + 0x680: 0x10002000, + 0x780: 0x2008, + 0x880: 0x200008, + 0x980: 0x2000, + 0xa80: 0x10002008, + 0xb80: 0x10200008, + 0xc80: 0x0, + 0xd80: 0x10202000, + 0xe80: 0x202000, + 0xf80: 0x10000000, + 0x1000: 0x10002000, + 0x1100: 0x10200008, + 0x1200: 0x10202008, + 0x1300: 0x2008, + 0x1400: 0x200000, + 0x1500: 0x10000000, + 0x1600: 0x10000008, + 0x1700: 0x202000, + 0x1800: 0x202008, + 0x1900: 0x0, + 0x1a00: 0x8, + 0x1b00: 0x10200000, + 0x1c00: 0x2000, + 0x1d00: 0x10002008, + 0x1e00: 0x10202000, + 0x1f00: 0x200008, + 0x1080: 0x8, + 0x1180: 0x202000, + 0x1280: 0x200000, + 0x1380: 0x10000008, + 0x1480: 0x10002000, + 0x1580: 0x2008, + 0x1680: 0x10202008, + 0x1780: 0x10200000, + 0x1880: 0x10202000, + 0x1980: 0x10200008, + 0x1a80: 0x2000, + 0x1b80: 0x202008, + 0x1c80: 0x200008, + 0x1d80: 0x0, + 0x1e80: 0x10000000, + 0x1f80: 0x10002008 + }, + { + 0x0: 0x100000, + 0x10: 0x2000401, + 0x20: 0x400, + 0x30: 0x100401, + 0x40: 0x2100401, + 0x50: 0x0, + 0x60: 0x1, + 0x70: 0x2100001, + 0x80: 0x2000400, + 0x90: 0x100001, + 0xa0: 0x2000001, + 0xb0: 0x2100400, + 0xc0: 0x2100000, + 0xd0: 0x401, + 0xe0: 0x100400, + 0xf0: 0x2000000, + 0x8: 0x2100001, + 0x18: 0x0, + 0x28: 0x2000401, + 0x38: 0x2100400, + 0x48: 0x100000, + 0x58: 0x2000001, + 0x68: 0x2000000, + 0x78: 0x401, + 0x88: 0x100401, + 0x98: 0x2000400, + 0xa8: 0x2100000, + 0xb8: 0x100001, + 0xc8: 0x400, + 0xd8: 0x2100401, + 0xe8: 0x1, + 0xf8: 0x100400, + 0x100: 0x2000000, + 0x110: 0x100000, + 0x120: 0x2000401, + 0x130: 0x2100001, + 0x140: 0x100001, + 0x150: 0x2000400, + 0x160: 0x2100400, + 0x170: 0x100401, + 0x180: 0x401, + 0x190: 0x2100401, + 0x1a0: 0x100400, + 0x1b0: 0x1, + 0x1c0: 0x0, + 0x1d0: 0x2100000, + 0x1e0: 0x2000001, + 0x1f0: 0x400, + 0x108: 0x100400, + 0x118: 0x2000401, + 0x128: 0x2100001, + 0x138: 0x1, + 0x148: 0x2000000, + 0x158: 0x100000, + 0x168: 0x401, + 0x178: 0x2100400, + 0x188: 0x2000001, + 0x198: 0x2100000, + 0x1a8: 0x0, + 0x1b8: 0x2100401, + 0x1c8: 0x100401, + 0x1d8: 0x400, + 0x1e8: 0x2000400, + 0x1f8: 0x100001 + }, + { + 0x0: 0x8000820, + 0x1: 0x20000, + 0x2: 0x8000000, + 0x3: 0x20, + 0x4: 0x20020, + 0x5: 0x8020820, + 0x6: 0x8020800, + 0x7: 0x800, + 0x8: 0x8020000, + 0x9: 0x8000800, + 0xa: 0x20800, + 0xb: 0x8020020, + 0xc: 0x820, + 0xd: 0x0, + 0xe: 0x8000020, + 0xf: 0x20820, + 0x80000000: 0x800, + 0x80000001: 0x8020820, + 0x80000002: 0x8000820, + 0x80000003: 0x8000000, + 0x80000004: 0x8020000, + 0x80000005: 0x20800, + 0x80000006: 0x20820, + 0x80000007: 0x20, + 0x80000008: 0x8000020, + 0x80000009: 0x820, + 0x8000000a: 0x20020, + 0x8000000b: 0x8020800, + 0x8000000c: 0x0, + 0x8000000d: 0x8020020, + 0x8000000e: 0x8000800, + 0x8000000f: 0x20000, + 0x10: 0x20820, + 0x11: 0x8020800, + 0x12: 0x20, + 0x13: 0x800, + 0x14: 0x8000800, + 0x15: 0x8000020, + 0x16: 0x8020020, + 0x17: 0x20000, + 0x18: 0x0, + 0x19: 0x20020, + 0x1a: 0x8020000, + 0x1b: 0x8000820, + 0x1c: 0x8020820, + 0x1d: 0x20800, + 0x1e: 0x820, + 0x1f: 0x8000000, + 0x80000010: 0x20000, + 0x80000011: 0x800, + 0x80000012: 0x8020020, + 0x80000013: 0x20820, + 0x80000014: 0x20, + 0x80000015: 0x8020000, + 0x80000016: 0x8000000, + 0x80000017: 0x8000820, + 0x80000018: 0x8020820, + 0x80000019: 0x8000020, + 0x8000001a: 0x8000800, + 0x8000001b: 0x0, + 0x8000001c: 0x20800, + 0x8000001d: 0x820, + 0x8000001e: 0x20020, + 0x8000001f: 0x8020800 + } + ]; + + // Masks that select the SBOX input + var SBOX_MASK = [ + 0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000, + 0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f + ]; + + /** + * DES block cipher algorithm. + */ + var DES = C_algo.DES = BlockCipher.extend({ + _doReset: function () { + // Shortcuts + var key = this._key; + var keyWords = key.words; + + // Select 56 bits according to PC1 + var keyBits = []; + for (var i = 0; i < 56; i++) { + var keyBitPos = PC1[i] - 1; + keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1; + } + + // Assemble 16 subkeys + var subKeys = this._subKeys = []; + for (var nSubKey = 0; nSubKey < 16; nSubKey++) { + // Create subkey + var subKey = subKeys[nSubKey] = []; + + // Shortcut + var bitShift = BIT_SHIFTS[nSubKey]; + + // Select 48 bits according to PC2 + for (var i = 0; i < 24; i++) { + // Select from the left 28 key bits + subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6); + + // Select from the right 28 key bits + subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6); + } + + // Since each subkey is applied to an expanded 32-bit input, + // the subkey can be broken into 8 values scaled to 32-bits, + // which allows the key to be used without expansion + subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31); + for (var i = 1; i < 7; i++) { + subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3); + } + subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27); + } + + // Compute inverse subkeys + var invSubKeys = this._invSubKeys = []; + for (var i = 0; i < 16; i++) { + invSubKeys[i] = subKeys[15 - i]; + } + }, + + encryptBlock: function (M, offset) { + this._doCryptBlock(M, offset, this._subKeys); + }, + + decryptBlock: function (M, offset) { + this._doCryptBlock(M, offset, this._invSubKeys); + }, + + _doCryptBlock: function (M, offset, subKeys) { + // Get input + this._lBlock = M[offset]; + this._rBlock = M[offset + 1]; + + // Initial permutation + exchangeLR.call(this, 4, 0x0f0f0f0f); + exchangeLR.call(this, 16, 0x0000ffff); + exchangeRL.call(this, 2, 0x33333333); + exchangeRL.call(this, 8, 0x00ff00ff); + exchangeLR.call(this, 1, 0x55555555); + + // Rounds + for (var round = 0; round < 16; round++) { + // Shortcuts + var subKey = subKeys[round]; + var lBlock = this._lBlock; + var rBlock = this._rBlock; + + // Feistel function + var f = 0; + for (var i = 0; i < 8; i++) { + f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0]; + } + this._lBlock = rBlock; + this._rBlock = lBlock ^ f; + } + + // Undo swap from last round + var t = this._lBlock; + this._lBlock = this._rBlock; + this._rBlock = t; + + // Final permutation + exchangeLR.call(this, 1, 0x55555555); + exchangeRL.call(this, 8, 0x00ff00ff); + exchangeRL.call(this, 2, 0x33333333); + exchangeLR.call(this, 16, 0x0000ffff); + exchangeLR.call(this, 4, 0x0f0f0f0f); + + // Set output + M[offset] = this._lBlock; + M[offset + 1] = this._rBlock; + }, + + keySize: 64/32, + + ivSize: 64/32, + + blockSize: 64/32 + }); + + // Swap bits across the left and right words + function exchangeLR(offset, mask) { + var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask; + this._rBlock ^= t; + this._lBlock ^= t << offset; + } + + function exchangeRL(offset, mask) { + var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask; + this._lBlock ^= t; + this._rBlock ^= t << offset; + } + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.DES.encrypt(message, key, cfg); + * var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg); + */ + C.DES = BlockCipher._createHelper(DES); + + /** + * Triple-DES block cipher algorithm. + */ + var TripleDES = C_algo.TripleDES = BlockCipher.extend({ + _doReset: function () { + // Shortcuts + var key = this._key; + var keyWords = key.words; + // Make sure the key length is valid (64, 128 or >= 192 bit) + if (keyWords.length !== 2 && keyWords.length !== 4 && keyWords.length < 6) { + throw new Error('Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.'); + } + + // Extend the key according to the keying options defined in 3DES standard + var key1 = keyWords.slice(0, 2); + var key2 = keyWords.length < 4 ? keyWords.slice(0, 2) : keyWords.slice(2, 4); + var key3 = keyWords.length < 6 ? keyWords.slice(0, 2) : keyWords.slice(4, 6); + + // Create DES instances + this._des1 = DES.createEncryptor(WordArray.create(key1)); + this._des2 = DES.createEncryptor(WordArray.create(key2)); + this._des3 = DES.createEncryptor(WordArray.create(key3)); + }, + + encryptBlock: function (M, offset) { + this._des1.encryptBlock(M, offset); + this._des2.decryptBlock(M, offset); + this._des3.encryptBlock(M, offset); + }, + + decryptBlock: function (M, offset) { + this._des3.decryptBlock(M, offset); + this._des2.encryptBlock(M, offset); + this._des1.decryptBlock(M, offset); + }, + + keySize: 192/32, + + ivSize: 64/32, + + blockSize: 64/32 + }); + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg); + * var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg); + */ + C.TripleDES = BlockCipher._createHelper(TripleDES); + }()); + + + return CryptoJS.TripleDES; + +})); +}, function(modId) { var map = {"./core":1594611128924,"./enc-base64":1594611128928,"./md5":1594611128929,"./evpkdf":1594611128939,"./cipher-core":1594611128940}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128954, function(require, module, exports) { +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var StreamCipher = C_lib.StreamCipher; + var C_algo = C.algo; + + /** + * RC4 stream cipher algorithm. + */ + var RC4 = C_algo.RC4 = StreamCipher.extend({ + _doReset: function () { + // Shortcuts + var key = this._key; + var keyWords = key.words; + var keySigBytes = key.sigBytes; + + // Init sbox + var S = this._S = []; + for (var i = 0; i < 256; i++) { + S[i] = i; + } + + // Key setup + for (var i = 0, j = 0; i < 256; i++) { + var keyByteIndex = i % keySigBytes; + var keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff; + + j = (j + S[i] + keyByte) % 256; + + // Swap + var t = S[i]; + S[i] = S[j]; + S[j] = t; + } + + // Counters + this._i = this._j = 0; + }, + + _doProcessBlock: function (M, offset) { + M[offset] ^= generateKeystreamWord.call(this); + }, + + keySize: 256/32, + + ivSize: 0 + }); + + function generateKeystreamWord() { + // Shortcuts + var S = this._S; + var i = this._i; + var j = this._j; + + // Generate keystream word + var keystreamWord = 0; + for (var n = 0; n < 4; n++) { + i = (i + 1) % 256; + j = (j + S[i]) % 256; + + // Swap + var t = S[i]; + S[i] = S[j]; + S[j] = t; + + keystreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8); + } + + // Update counters + this._i = i; + this._j = j; + + return keystreamWord; + } + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg); + * var plaintext = CryptoJS.RC4.decrypt(ciphertext, key, cfg); + */ + C.RC4 = StreamCipher._createHelper(RC4); + + /** + * Modified RC4 stream cipher algorithm. + */ + var RC4Drop = C_algo.RC4Drop = RC4.extend({ + /** + * Configuration options. + * + * @property {number} drop The number of keystream words to drop. Default 192 + */ + cfg: RC4.cfg.extend({ + drop: 192 + }), + + _doReset: function () { + RC4._doReset.call(this); + + // Drop + for (var i = this.cfg.drop; i > 0; i--) { + generateKeystreamWord.call(this); + } + } + }); + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg); + * var plaintext = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg); + */ + C.RC4Drop = StreamCipher._createHelper(RC4Drop); + }()); + + + return CryptoJS.RC4; + +})); +}, function(modId) { var map = {"./core":1594611128924,"./enc-base64":1594611128928,"./md5":1594611128929,"./evpkdf":1594611128939,"./cipher-core":1594611128940}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128955, function(require, module, exports) { +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var StreamCipher = C_lib.StreamCipher; + var C_algo = C.algo; + + // Reusable objects + var S = []; + var C_ = []; + var G = []; + + /** + * Rabbit stream cipher algorithm + */ + var Rabbit = C_algo.Rabbit = StreamCipher.extend({ + _doReset: function () { + // Shortcuts + var K = this._key.words; + var iv = this.cfg.iv; + + // Swap endian + for (var i = 0; i < 4; i++) { + K[i] = (((K[i] << 8) | (K[i] >>> 24)) & 0x00ff00ff) | + (((K[i] << 24) | (K[i] >>> 8)) & 0xff00ff00); + } + + // Generate initial state values + var X = this._X = [ + K[0], (K[3] << 16) | (K[2] >>> 16), + K[1], (K[0] << 16) | (K[3] >>> 16), + K[2], (K[1] << 16) | (K[0] >>> 16), + K[3], (K[2] << 16) | (K[1] >>> 16) + ]; + + // Generate initial counter values + var C = this._C = [ + (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff), + (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff), + (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff), + (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff) + ]; + + // Carry bit + this._b = 0; + + // Iterate the system four times + for (var i = 0; i < 4; i++) { + nextState.call(this); + } + + // Modify the counters + for (var i = 0; i < 8; i++) { + C[i] ^= X[(i + 4) & 7]; + } + + // IV setup + if (iv) { + // Shortcuts + var IV = iv.words; + var IV_0 = IV[0]; + var IV_1 = IV[1]; + + // Generate four subvectors + var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00); + var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00); + var i1 = (i0 >>> 16) | (i2 & 0xffff0000); + var i3 = (i2 << 16) | (i0 & 0x0000ffff); + + // Modify counter values + C[0] ^= i0; + C[1] ^= i1; + C[2] ^= i2; + C[3] ^= i3; + C[4] ^= i0; + C[5] ^= i1; + C[6] ^= i2; + C[7] ^= i3; + + // Iterate the system four times + for (var i = 0; i < 4; i++) { + nextState.call(this); + } + } + }, + + _doProcessBlock: function (M, offset) { + // Shortcut + var X = this._X; + + // Iterate the system + nextState.call(this); + + // Generate four keystream words + S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16); + S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16); + S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16); + S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16); + + for (var i = 0; i < 4; i++) { + // Swap endian + S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) | + (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00); + + // Encrypt + M[offset + i] ^= S[i]; + } + }, + + blockSize: 128/32, + + ivSize: 64/32 + }); + + function nextState() { + // Shortcuts + var X = this._X; + var C = this._C; + + // Save old counter values + for (var i = 0; i < 8; i++) { + C_[i] = C[i]; + } + + // Calculate new counter values + C[0] = (C[0] + 0x4d34d34d + this._b) | 0; + C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0; + C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0; + C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0; + C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0; + C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0; + C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0; + C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0; + this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0; + + // Calculate the g-values + for (var i = 0; i < 8; i++) { + var gx = X[i] + C[i]; + + // Construct high and low argument for squaring + var ga = gx & 0xffff; + var gb = gx >>> 16; + + // Calculate high and low result of squaring + var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb; + var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0); + + // High XOR low + G[i] = gh ^ gl; + } + + // Calculate new state values + X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0; + X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0; + X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0; + X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0; + X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0; + X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0; + X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0; + X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0; + } + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg); + * var plaintext = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg); + */ + C.Rabbit = StreamCipher._createHelper(Rabbit); + }()); + + + return CryptoJS.Rabbit; + +})); +}, function(modId) { var map = {"./core":1594611128924,"./enc-base64":1594611128928,"./md5":1594611128929,"./evpkdf":1594611128939,"./cipher-core":1594611128940}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1594611128956, function(require, module, exports) { +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var StreamCipher = C_lib.StreamCipher; + var C_algo = C.algo; + + // Reusable objects + var S = []; + var C_ = []; + var G = []; + + /** + * Rabbit stream cipher algorithm. + * + * This is a legacy version that neglected to convert the key to little-endian. + * This error doesn't affect the cipher's security, + * but it does affect its compatibility with other implementations. + */ + var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({ + _doReset: function () { + // Shortcuts + var K = this._key.words; + var iv = this.cfg.iv; + + // Generate initial state values + var X = this._X = [ + K[0], (K[3] << 16) | (K[2] >>> 16), + K[1], (K[0] << 16) | (K[3] >>> 16), + K[2], (K[1] << 16) | (K[0] >>> 16), + K[3], (K[2] << 16) | (K[1] >>> 16) + ]; + + // Generate initial counter values + var C = this._C = [ + (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff), + (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff), + (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff), + (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff) + ]; + + // Carry bit + this._b = 0; + + // Iterate the system four times + for (var i = 0; i < 4; i++) { + nextState.call(this); + } + + // Modify the counters + for (var i = 0; i < 8; i++) { + C[i] ^= X[(i + 4) & 7]; + } + + // IV setup + if (iv) { + // Shortcuts + var IV = iv.words; + var IV_0 = IV[0]; + var IV_1 = IV[1]; + + // Generate four subvectors + var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00); + var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00); + var i1 = (i0 >>> 16) | (i2 & 0xffff0000); + var i3 = (i2 << 16) | (i0 & 0x0000ffff); + + // Modify counter values + C[0] ^= i0; + C[1] ^= i1; + C[2] ^= i2; + C[3] ^= i3; + C[4] ^= i0; + C[5] ^= i1; + C[6] ^= i2; + C[7] ^= i3; + + // Iterate the system four times + for (var i = 0; i < 4; i++) { + nextState.call(this); + } + } + }, + + _doProcessBlock: function (M, offset) { + // Shortcut + var X = this._X; + + // Iterate the system + nextState.call(this); + + // Generate four keystream words + S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16); + S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16); + S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16); + S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16); + + for (var i = 0; i < 4; i++) { + // Swap endian + S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) | + (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00); + + // Encrypt + M[offset + i] ^= S[i]; + } + }, + + blockSize: 128/32, + + ivSize: 64/32 + }); + + function nextState() { + // Shortcuts + var X = this._X; + var C = this._C; + + // Save old counter values + for (var i = 0; i < 8; i++) { + C_[i] = C[i]; + } + + // Calculate new counter values + C[0] = (C[0] + 0x4d34d34d + this._b) | 0; + C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0; + C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0; + C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0; + C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0; + C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0; + C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0; + C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0; + this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0; + + // Calculate the g-values + for (var i = 0; i < 8; i++) { + var gx = X[i] + C[i]; + + // Construct high and low argument for squaring + var ga = gx & 0xffff; + var gb = gx >>> 16; + + // Calculate high and low result of squaring + var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb; + var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0); + + // High XOR low + G[i] = gh ^ gl; + } + + // Calculate new state values + X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0; + X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0; + X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0; + X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0; + X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0; + X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0; + X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0; + X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0; + } + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg); + * var plaintext = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg); + */ + C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy); + }()); + + + return CryptoJS.RabbitLegacy; + +})); +}, function(modId) { var map = {"./core":1594611128924,"./enc-base64":1594611128928,"./md5":1594611128929,"./evpkdf":1594611128939,"./cipher-core":1594611128940}; return __REQUIRE__(map[modId], modId); }) +return __REQUIRE__(1594611128923); +})() +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/libs/events.js b/libs/events.js new file mode 100644 index 0000000..9bd831a --- /dev/null +++ b/libs/events.js @@ -0,0 +1,458 @@ +module.exports = (function() { +var __MODS__ = {}; +var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; }; +var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; }; +var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } }; +var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; }; +__DEFINE__(1594695691622, function(require, module, exports) { +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + + + +var R = typeof Reflect === 'object' ? Reflect : null +var ReflectApply = R && typeof R.apply === 'function' + ? R.apply + : function ReflectApply(target, receiver, args) { + return Function.prototype.apply.call(target, receiver, args); + } + +var ReflectOwnKeys +if (R && typeof R.ownKeys === 'function') { + ReflectOwnKeys = R.ownKeys +} else if (Object.getOwnPropertySymbols) { + ReflectOwnKeys = function ReflectOwnKeys(target) { + return Object.getOwnPropertyNames(target) + .concat(Object.getOwnPropertySymbols(target)); + }; +} else { + ReflectOwnKeys = function ReflectOwnKeys(target) { + return Object.getOwnPropertyNames(target); + }; +} + +function ProcessEmitWarning(warning) { + if (console && console.warn) console.warn(warning); +} + +var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) { + return value !== value; +} + +function EventEmitter() { + EventEmitter.init.call(this); +} +module.exports = EventEmitter; + +// Backwards-compat with node 0.10.x +EventEmitter.EventEmitter = EventEmitter; + +EventEmitter.prototype._events = undefined; +EventEmitter.prototype._eventsCount = 0; +EventEmitter.prototype._maxListeners = undefined; + +// By default EventEmitters will print a warning if more than 10 listeners are +// added to it. This is a useful default which helps finding memory leaks. +var defaultMaxListeners = 10; + +function checkListener(listener) { + if (typeof listener !== 'function') { + throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener); + } +} + +Object.defineProperty(EventEmitter, 'defaultMaxListeners', { + enumerable: true, + get: function() { + return defaultMaxListeners; + }, + set: function(arg) { + if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) { + throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.'); + } + defaultMaxListeners = arg; + } +}); + +EventEmitter.init = function() { + + if (this._events === undefined || + this._events === Object.getPrototypeOf(this)._events) { + this._events = Object.create(null); + this._eventsCount = 0; + } + + this._maxListeners = this._maxListeners || undefined; +}; + +// Obviously not all Emitters should be limited to 10. This function allows +// that to be increased. Set to zero for unlimited. +EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { + if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) { + throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.'); + } + this._maxListeners = n; + return this; +}; + +function _getMaxListeners(that) { + if (that._maxListeners === undefined) + return EventEmitter.defaultMaxListeners; + return that._maxListeners; +} + +EventEmitter.prototype.getMaxListeners = function getMaxListeners() { + return _getMaxListeners(this); +}; + +EventEmitter.prototype.emit = function emit(type) { + var args = []; + for (var i = 1; i < arguments.length; i++) args.push(arguments[i]); + var doError = (type === 'error'); + + var events = this._events; + if (events !== undefined) + doError = (doError && events.error === undefined); + else if (!doError) + return false; + + // If there is no 'error' event listener then throw. + if (doError) { + var er; + if (args.length > 0) + er = args[0]; + if (er instanceof Error) { + // Note: The comments on the `throw` lines are intentional, they show + // up in Node's output if this results in an unhandled exception. + throw er; // Unhandled 'error' event + } + // At least give some kind of context to the user + var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : '')); + err.context = er; + throw err; // Unhandled 'error' event + } + + var handler = events[type]; + + if (handler === undefined) + return false; + + if (typeof handler === 'function') { + ReflectApply(handler, this, args); + } else { + var len = handler.length; + var listeners = arrayClone(handler, len); + for (var i = 0; i < len; ++i) + ReflectApply(listeners[i], this, args); + } + + return true; +}; + +function _addListener(target, type, listener, prepend) { + var m; + var events; + var existing; + + checkListener(listener); + + events = target._events; + if (events === undefined) { + events = target._events = Object.create(null); + target._eventsCount = 0; + } else { + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (events.newListener !== undefined) { + target.emit('newListener', type, + listener.listener ? listener.listener : listener); + + // Re-assign `events` because a newListener handler could have caused the + // this._events to be assigned to a new object + events = target._events; + } + existing = events[type]; + } + + if (existing === undefined) { + // Optimize the case of one listener. Don't need the extra array object. + existing = events[type] = listener; + ++target._eventsCount; + } else { + if (typeof existing === 'function') { + // Adding the second element, need to change to array. + existing = events[type] = + prepend ? [listener, existing] : [existing, listener]; + // If we've already got an array, just append. + } else if (prepend) { + existing.unshift(listener); + } else { + existing.push(listener); + } + + // Check for listener leak + m = _getMaxListeners(target); + if (m > 0 && existing.length > m && !existing.warned) { + existing.warned = true; + // No error code for this since it is a Warning + // eslint-disable-next-line no-restricted-syntax + var w = new Error('Possible EventEmitter memory leak detected. ' + + existing.length + ' ' + String(type) + ' listeners ' + + 'added. Use emitter.setMaxListeners() to ' + + 'increase limit'); + w.name = 'MaxListenersExceededWarning'; + w.emitter = target; + w.type = type; + w.count = existing.length; + ProcessEmitWarning(w); + } + } + + return target; +} + +EventEmitter.prototype.addListener = function addListener(type, listener) { + return _addListener(this, type, listener, false); +}; + +EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +EventEmitter.prototype.prependListener = + function prependListener(type, listener) { + return _addListener(this, type, listener, true); + }; + +function onceWrapper() { + if (!this.fired) { + this.target.removeListener(this.type, this.wrapFn); + this.fired = true; + if (arguments.length === 0) + return this.listener.call(this.target); + return this.listener.apply(this.target, arguments); + } +} + +function _onceWrap(target, type, listener) { + var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener }; + var wrapped = onceWrapper.bind(state); + wrapped.listener = listener; + state.wrapFn = wrapped; + return wrapped; +} + +EventEmitter.prototype.once = function once(type, listener) { + checkListener(listener); + this.on(type, _onceWrap(this, type, listener)); + return this; +}; + +EventEmitter.prototype.prependOnceListener = + function prependOnceListener(type, listener) { + checkListener(listener); + this.prependListener(type, _onceWrap(this, type, listener)); + return this; + }; + +// Emits a 'removeListener' event if and only if the listener was removed. +EventEmitter.prototype.removeListener = + function removeListener(type, listener) { + var list, events, position, i, originalListener; + + checkListener(listener); + + events = this._events; + if (events === undefined) + return this; + + list = events[type]; + if (list === undefined) + return this; + + if (list === listener || list.listener === listener) { + if (--this._eventsCount === 0) + this._events = Object.create(null); + else { + delete events[type]; + if (events.removeListener) + this.emit('removeListener', type, list.listener || listener); + } + } else if (typeof list !== 'function') { + position = -1; + + for (i = list.length - 1; i >= 0; i--) { + if (list[i] === listener || list[i].listener === listener) { + originalListener = list[i].listener; + position = i; + break; + } + } + + if (position < 0) + return this; + + if (position === 0) + list.shift(); + else { + spliceOne(list, position); + } + + if (list.length === 1) + events[type] = list[0]; + + if (events.removeListener !== undefined) + this.emit('removeListener', type, originalListener || listener); + } + + return this; + }; + +EventEmitter.prototype.off = EventEmitter.prototype.removeListener; + +EventEmitter.prototype.removeAllListeners = + function removeAllListeners(type) { + var listeners, events, i; + + events = this._events; + if (events === undefined) + return this; + + // not listening for removeListener, no need to emit + if (events.removeListener === undefined) { + if (arguments.length === 0) { + this._events = Object.create(null); + this._eventsCount = 0; + } else if (events[type] !== undefined) { + if (--this._eventsCount === 0) + this._events = Object.create(null); + else + delete events[type]; + } + return this; + } + + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + var keys = Object.keys(events); + var key; + for (i = 0; i < keys.length; ++i) { + key = keys[i]; + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = Object.create(null); + this._eventsCount = 0; + return this; + } + + listeners = events[type]; + + if (typeof listeners === 'function') { + this.removeListener(type, listeners); + } else if (listeners !== undefined) { + // LIFO order + for (i = listeners.length - 1; i >= 0; i--) { + this.removeListener(type, listeners[i]); + } + } + + return this; + }; + +function _listeners(target, type, unwrap) { + var events = target._events; + + if (events === undefined) + return []; + + var evlistener = events[type]; + if (evlistener === undefined) + return []; + + if (typeof evlistener === 'function') + return unwrap ? [evlistener.listener || evlistener] : [evlistener]; + + return unwrap ? + unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length); +} + +EventEmitter.prototype.listeners = function listeners(type) { + return _listeners(this, type, true); +}; + +EventEmitter.prototype.rawListeners = function rawListeners(type) { + return _listeners(this, type, false); +}; + +EventEmitter.listenerCount = function(emitter, type) { + if (typeof emitter.listenerCount === 'function') { + return emitter.listenerCount(type); + } else { + return listenerCount.call(emitter, type); + } +}; + +EventEmitter.prototype.listenerCount = listenerCount; +function listenerCount(type) { + var events = this._events; + + if (events !== undefined) { + var evlistener = events[type]; + + if (typeof evlistener === 'function') { + return 1; + } else if (evlistener !== undefined) { + return evlistener.length; + } + } + + return 0; +} + +EventEmitter.prototype.eventNames = function eventNames() { + return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : []; +}; + +function arrayClone(arr, n) { + var copy = new Array(n); + for (var i = 0; i < n; ++i) + copy[i] = arr[i]; + return copy; +} + +function spliceOne(list, index) { + for (; index + 1 < list.length; index++) + list[index] = list[index + 1]; + list.pop(); +} + +function unwrapListeners(arr) { + var ret = new Array(arr.length); + for (var i = 0; i < ret.length; ++i) { + ret[i] = arr[i].listener || arr[i]; + } + return ret; +} + +}, function(modId) {var map = {}; return __REQUIRE__(map[modId], modId); }) +return __REQUIRE__(1594695691622); +})() +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/libs/mqtt.min.js b/libs/mqtt.min.js new file mode 100644 index 0000000..c72188e --- /dev/null +++ b/libs/mqtt.min.js @@ -0,0 +1 @@ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).mqtt=e()}}(function(){return function(){return function e(t,r,n){function i(s,a){if(!r[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=r[s]={exports:{}};t[s][0].call(l.exports,function(e){return i(t[s][1][e]||e)},l,l.exports,e,t,r,n)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;sthis.emit("error",new Error("Packet has no Authentication Method"))),this;if(this.options.properties.authenticationMethod&&this.options.authPacket&&"object"==typeof this.options.authPacket)y(this,f({cmd:"auth",reasonCode:0},this.options.authPacket))}this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout(function(){p("!!connectTimeout hit!! Calling _cleanUp with force `true`"),t._cleanUp(!0)},this.options.connectTimeout)},v.prototype._handlePacket=function(e,t){var r=this.options;if(5===r.protocolVersion&&r.properties&&r.properties.maximumPacketSize&&r.properties.maximumPacketSizeo.properties.topicAliasMaximum||!o.properties.topicAliasMaximum&&r.properties.topicAlias))&&delete i.properties.topicAlias),p("publish :: qos",r.qos),r.qos){case 1:case 2:this.outgoing[i.messageId]={volatile:!1,cb:n||_},this._storeProcessing?(p("_storeProcessing enabled"),this._packetIdsDuringStoreProcessing[i.messageId]=!1,this._storePacket(i,void 0,r.cbStorePut)):(p("MqttClient:publish: packet cmd: %s",i.cmd),this._sendPacket(i,void 0,r.cbStorePut));break;default:this._storeProcessing?(p("_storeProcessing enabled"),this._storePacket(i,n,r.cbStorePut)):(p("MqttClient:publish: packet cmd: %s",i.cmd),this._sendPacket(i,n,r.cbStorePut))}return this},v.prototype.subscribe=function(){for(var e,t=new Array(arguments.length),r=0;r0){var t={qos:e.qos};5===d&&(t.nl=e.nl||!1,t.rap=e.rap||!1,t.rh=e.rh||0,t.properties=e.properties),c._resubscribeTopics[e.topic]=t,b.push(e.topic)}}),c.messageIdToTopic[e.messageId]=b}return this.outgoing[e.messageId]={volatile:!0,cb:function(e,t){if(!e)for(var r=t.granted,n=0;n{p("end :: finish :: calling process.nextTick on closeStores"),r.nextTick(function(){p("end :: closeStores: closing incoming and outgoing stores"),i.disconnected=!0,i.incomingStore.close(function(){i.outgoingStore.close(function(){p("end :: closeStores: emitting end"),i.emit("end"),n&&(p("end :: closeStores: invoking callback with args"),n())})}),i._deferredReconnect&&i._deferredReconnect()}.bind(i))},t)}return p("end :: (%s)",this.options.clientId),null!=e&&"boolean"==typeof e||(n=t||_,t=e,e=!1,"object"!=typeof t&&(n=t,t=null,"function"!=typeof n&&(n=_))),"object"!=typeof t&&(n=t,t=null),p("end :: cb? %s",!!n),n=n||_,this.disconnecting?(n(),this):(this._clearReconnect(),this.disconnecting=!0,!e&&Object.keys(this.outgoing).length>0?(p("end :: (%s) :: calling finish in 10ms once outgoing is empty",i.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,o,10))):(p("end :: (%s) :: immediately calling finish",i.options.clientId),o()),this)},v.prototype.removeOutgoingMessage=function(e){var t=this.outgoing[e]?this.outgoing[e].cb:null;return delete this.outgoing[e],this.outgoingStore.del({messageId:e},function(){t(new Error("Message removed"))}),this},v.prototype.reconnect=function(e){p("client reconnect");var t=this,r=function(){e?(t.options.incomingStore=e.incomingStore,t.options.outgoingStore=e.outgoingStore):(t.options.incomingStore=null,t.options.outgoingStore=null),t.incomingStore=t.options.incomingStore||new o,t.outgoingStore=t.options.outgoingStore||new o,t.disconnecting=!1,t.disconnected=!1,t._deferredReconnect=null,t._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=r:r(),this},v.prototype._reconnect=function(){p("_reconnect: emitting reconnect to client"),this.emit("reconnect"),p("_reconnect: calling _setupStream"),this._setupStream()},v.prototype._setupReconnect=function(){var e=this;!e.disconnecting&&!e.reconnectTimer&&e.options.reconnectPeriod>0?(this.reconnecting||(p("_setupReconnect :: emit `offline` state"),this.emit("offline"),p("_setupReconnect :: set `reconnecting` to `true`"),this.reconnecting=!0),p("_setupReconnect :: setting reconnectTimer for %d ms",e.options.reconnectPeriod),e.reconnectTimer=setInterval(function(){p("reconnectTimer :: reconnect triggered!"),e._reconnect()},e.options.reconnectPeriod)):p("_setupReconnect :: doing nothing...")},v.prototype._clearReconnect=function(){p("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},v.prototype._cleanUp=function(e,t){var r,n=arguments[2];if(t&&(p("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",t)),p("_cleanUp :: forced? %s",e),e)0===this.options.reconnectPeriod&&this.options.clean&&(r=this.outgoing)&&(p("flush: queue exists? %b",!!r),Object.keys(r).forEach(function(e){"function"==typeof r[e].cb&&(r[e].cb(new Error("Connection closed")),delete r[e])})),p("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{var i=f({cmd:"disconnect"},n);p("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(i,h.bind(null,this.stream.end.bind(this.stream)))}this.disconnecting||(p("_cleanUp :: client not disconnecting. Clearing and resetting reconnect."),this._clearReconnect(),this._setupReconnect()),null!==this.pingTimer&&(p("_cleanUp :: clearing pingTimer"),this.pingTimer.clear(),this.pingTimer=null),t&&!this.connected&&(p("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener("close",t),t())},v.prototype._sendPacket=function(e,t,r){if(p("_sendPacket :: (%s) :: start",this.options.clientId),r=r||_,!this.connected)return p("_sendPacket :: client not connected. Storing packet offline."),void this._storePacket(e,t,r);switch(this._shiftPingInterval(),e.cmd){case"publish":break;case"pubrel":return void m(this,e,t,r);default:return void y(this,e,t)}switch(e.qos){case 2:case 1:m(this,e,t,r);break;case 0:default:y(this,e,t)}p("_sendPacket :: (%s) :: end",this.options.clientId)},v.prototype._storePacket=function(e,t,r){p("_storePacket :: packet: %o",e),p("_storePacket :: cb? %s",!!t),r=r||_,0===(e.qos||0)&&this.queueQoSZero||"publish"!==e.cmd?this.queue.push({packet:e,cb:t}):e.qos>0?(t=this.outgoing[e.messageId]?this.outgoing[e.messageId].cb:null,this.outgoingStore.put(e,function(e){if(e)return t&&t(e);r()})):t&&t(new Error("No connection to broker"))},v.prototype._setupPingTimer=function(){p("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive);var e=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=c(function(){e._checkPing()},1e3*this.options.keepalive))},v.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive)},v.prototype._checkPing=function(){p("_checkPing :: checking ping..."),this.pingResp?(p("_checkPing :: ping response received. Clearing flag and sending `pingreq`"),this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):(p("_checkPing :: calling _cleanUp with force true"),this._cleanUp(!0))},v.prototype._handlePingresp=function(){this.pingResp=!0},v.prototype._handleConnack=function(e){p("_handleConnack");var t=this.options,r=5===t.protocolVersion?e.reasonCode:e.returnCode;if(clearTimeout(this.connackTimer),e.properties&&(e.properties.topicAliasMaximum&&(t.properties||(t.properties={}),t.properties.topicAliasMaximum=e.properties.topicAliasMaximum),e.properties.serverKeepAlive&&t.keepalive&&(t.keepalive=e.properties.serverKeepAlive,this._shiftPingInterval()),e.properties.maximumPacketSize&&(t.properties||(t.properties={}),t.properties.maximumPacketSize=e.properties.maximumPacketSize)),0===r)this.reconnecting=!1,this._onConnect(e);else if(r>0){var n=new Error("Connection refused: "+b[r]);n.code=r,this.emit("error",n)}},v.prototype._handlePublish=function(e,t){p("_handlePublish: packet %o",e),t=void 0!==t?t:_;var r=e.topic.toString(),n=e.payload,i=e.qos,o=e.messageId,s=this,a=this.options,u=[0,16,128,131,135,144,145,151,153];switch(p("_handlePublish: qos %d",i),i){case 2:a.customHandleAcks(r,n,e,function(r,n){return r instanceof Error||(n=r,r=null),r?s.emit("error",r):-1===u.indexOf(n)?s.emit("error",new Error("Wrong reason code for pubrec")):void(n?s._sendPacket({cmd:"pubrec",messageId:o,reasonCode:n},t):s.incomingStore.put(e,function(){s._sendPacket({cmd:"pubrec",messageId:o},t)}))});break;case 1:a.customHandleAcks(r,n,e,function(i,a){return i instanceof Error||(a=i,i=null),i?s.emit("error",i):-1===u.indexOf(a)?s.emit("error",new Error("Wrong reason code for puback")):(a||s.emit("message",r,n,e),void s.handleMessage(e,function(e){if(e)return t&&t(e);s._sendPacket({cmd:"puback",messageId:o,reasonCode:a},t)}))});break;case 0:this.emit("message",r,n,e),this.handleMessage(e,t);break;default:p("_handlePublish: unknown QoS. Doing nothing.")}},v.prototype.handleMessage=function(e,t){t()},v.prototype._handleAck=function(e){var t,r=e.messageId,n=e.cmd,i=null,o=this.outgoing[r]?this.outgoing[r].cb:null,s=this;if(o){switch(p("_handleAck :: packet type",n),n){case"pubcomp":case"puback":var a=e.reasonCode;a&&a>0&&16!==a&&((t=new Error("Publish error: "+b[a])).code=a,o(t,e)),delete this.outgoing[r],this.outgoingStore.del(e,o);break;case"pubrec":i={cmd:"pubrel",qos:2,messageId:r};var u=e.reasonCode;u&&u>0&&16!==u?((t=new Error("Publish error: "+b[u])).code=u,o(t,e)):this._sendPacket(i);break;case"suback":delete this.outgoing[r];for(var c=0;c0)if(this.options.resubscribe)if(5===this.options.protocolVersion){p("_resubscribe: protocolVersion 5");for(var r=0;r0?n-4:n,f=0;f>16&255,a[u++]=t>>8&255,a[u++]=255&t;2===s&&(t=i[e.charCodeAt(f)]<<2|i[e.charCodeAt(f+1)]>>4,a[u++]=255&t);1===s&&(t=i[e.charCodeAt(f)]<<10|i[e.charCodeAt(f+1)]<<4|i[e.charCodeAt(f+2)]>>2,a[u++]=t>>8&255,a[u++]=255&t);return a},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o=[],s=0,a=r-i;sa?a:s+16383));1===i?(t=e[r-1],o.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],o.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function l(e,t,r){for(var i,o,s=[],a=t;a>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],11:[function(e,t,r){},{}],12:[function(e,t,r){(function(t){"use strict";var n=e("base64-js"),i=e("ieee754");r.Buffer=t,r.SlowBuffer=function(e){+e!=e&&(e=0);return t.alloc(+e)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function s(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');var r=new Uint8Array(e);return r.__proto__=t.prototype,r}function t(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return c(e)}return a(e,t,r)}function a(e,r,n){if("string"==typeof e)return function(e,r){"string"==typeof r&&""!==r||(r="utf8");if(!t.isEncoding(r))throw new TypeError("Unknown encoding: "+r);var n=0|p(e,r),i=s(n),o=i.write(e,r);o!==n&&(i=i.slice(0,o));return i}(e,r);if(ArrayBuffer.isView(e))return l(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(q(e,ArrayBuffer)||e&&q(e.buffer,ArrayBuffer))return function(e,r,n){if(r<0||e.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function p(e,r){if(t.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||q(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var n=e.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===n)return 0;for(var o=!1;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return U(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return N(e).length;default:if(o)return i?-1:U(e).length;r=(""+r).toLowerCase(),o=!0}}function h(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function d(e,r,n,i,o){if(0===e.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),F(n=+n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof r&&(r=t.from(r,i)),t.isBuffer(r))return 0===r.length?-1:g(e,r,n,i,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,r,n):Uint8Array.prototype.lastIndexOf.call(e,r,n):g(e,[r],n,i,o);throw new TypeError("val must be string, number or Buffer")}function g(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var l=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var f=!0,p=0;pi&&(n=i):n=i;var o=t.length;n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function S(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function x(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:c>223?3:c>191?2:1;if(i+f<=r)switch(f){case 1:c<128&&(l=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(l=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(l=u)}null===l?(l=65533,f=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),i+=f}return function(e){var t=e.length;if(t<=k)return String.fromCharCode.apply(String,e);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return C(this,t,r);case"utf8":case"utf-8":return x(this,t,r);case"ascii":return E(this,t,r);case"latin1":case"binary":return I(this,t,r);case"base64":return S(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}.apply(this,arguments)},t.prototype.toLocaleString=t.prototype.toString,t.prototype.equals=function(e){if(!t.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===t.compare(this,e)},t.prototype.inspect=function(){var e="",t=r.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),""},t.prototype.compare=function(e,r,n,i,o){if(q(e,Uint8Array)&&(e=t.from(e,e.offset,e.byteLength)),!t.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===r&&(r=0),void 0===n&&(n=e?e.length:0),void 0===i&&(i=0),void 0===o&&(o=this.length),r<0||n>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===e)return 0;for(var s=o-i,a=n-r,u=Math.min(s,a),c=this.slice(i,o),l=e.slice(r,n),f=0;f>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return b(this,e,t,r);case"utf8":case"utf-8":return y(this,e,t,r);case"ascii":return m(this,e,t,r);case"latin1":case"binary":return _(this,e,t,r);case"base64":return v(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},t.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function E(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function T(e,r,n,i,o,s){if(!t.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>o||re.length)throw new RangeError("Index out of range")}function A(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function P(e,t,r,n,o){return t=+t,r>>>=0,o||A(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function M(e,t,r,n,o){return t=+t,r>>>=0,o||A(e,0,r,8),i.write(e,t,r,n,52,8),r+8}t.prototype.slice=function(e,r){var n=this.length;e=~~e,r=void 0===r?n:~~r,e<0?(e+=n)<0&&(e=0):e>n&&(e=n),r<0?(r+=n)<0&&(r=0):r>n&&(r=n),r>>=0,t>>>=0,r||j(e,t,this.length);for(var n=this[e],i=1,o=0;++o>>=0,t>>>=0,r||j(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},t.prototype.readUInt8=function(e,t){return e>>>=0,t||j(e,1,this.length),this[e]},t.prototype.readUInt16LE=function(e,t){return e>>>=0,t||j(e,2,this.length),this[e]|this[e+1]<<8},t.prototype.readUInt16BE=function(e,t){return e>>>=0,t||j(e,2,this.length),this[e]<<8|this[e+1]},t.prototype.readUInt32LE=function(e,t){return e>>>=0,t||j(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},t.prototype.readUInt32BE=function(e,t){return e>>>=0,t||j(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},t.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||j(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},t.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||j(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},t.prototype.readInt8=function(e,t){return e>>>=0,t||j(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},t.prototype.readInt16LE=function(e,t){e>>>=0,t||j(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},t.prototype.readInt16BE=function(e,t){e>>>=0,t||j(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},t.prototype.readInt32LE=function(e,t){return e>>>=0,t||j(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},t.prototype.readInt32BE=function(e,t){return e>>>=0,t||j(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},t.prototype.readFloatLE=function(e,t){return e>>>=0,t||j(e,4,this.length),i.read(this,e,!0,23,4)},t.prototype.readFloatBE=function(e,t){return e>>>=0,t||j(e,4,this.length),i.read(this,e,!1,23,4)},t.prototype.readDoubleLE=function(e,t){return e>>>=0,t||j(e,8,this.length),i.read(this,e,!0,52,8)},t.prototype.readDoubleBE=function(e,t){return e>>>=0,t||j(e,8,this.length),i.read(this,e,!1,52,8)},t.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t>>>=0,r>>>=0,n)||T(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o>>=0,r>>>=0,n)||T(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},t.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||T(this,e,t,1,255,0),this[t]=255&e,t+1},t.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||T(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},t.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||T(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},t.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||T(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},t.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||T(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},t.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);T(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},t.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);T(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},t.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||T(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},t.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||T(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},t.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||T(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},t.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||T(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},t.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||T(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},t.prototype.writeFloatLE=function(e,t,r){return P(this,e,t,!0,r)},t.prototype.writeFloatBE=function(e,t,r){return P(this,e,t,!1,r)},t.prototype.writeDoubleLE=function(e,t,r){return M(this,e,t,!0,r)},t.prototype.writeDoubleBE=function(e,t,r){return M(this,e,t,!1,r)},t.prototype.copy=function(e,r,n,i){if(!t.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),i||0===i||(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r=0;--s)e[s+r]=this[s+n];else Uint8Array.prototype.set.call(e,this.subarray(n,i),r);return o},t.prototype.fill=function(e,r,n,i){if("string"==typeof e){if("string"==typeof r?(i=r,r=0,n=this.length):"string"==typeof n&&(i=n,n=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!t.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===e.length){var o=e.charCodeAt(0);("utf8"===i&&o<128||"latin1"===i)&&(e=o)}}else"number"==typeof e&&(e&=255);if(r<0||this.length>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(s=r;s55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function N(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(B,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function L(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function q(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function F(e){return e!=e}}).call(this,e("buffer").Buffer)},{"base64-js":10,buffer:12,ieee754:87}],13:[function(e,t,r){(function(e){function t(e){return Object.prototype.toString.call(e)}r.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===t(e)},r.isBoolean=function(e){return"boolean"==typeof e},r.isNull=function(e){return null===e},r.isNullOrUndefined=function(e){return null==e},r.isNumber=function(e){return"number"==typeof e},r.isString=function(e){return"string"==typeof e},r.isSymbol=function(e){return"symbol"==typeof e},r.isUndefined=function(e){return void 0===e},r.isRegExp=function(e){return"[object RegExp]"===t(e)},r.isObject=function(e){return"object"==typeof e&&null!==e},r.isDate=function(e){return"[object Date]"===t(e)},r.isError=function(e){return"[object Error]"===t(e)||e instanceof Error},r.isFunction=function(e){return"function"==typeof e},r.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},r.isBuffer=e.isBuffer}).call(this,{isBuffer:e("../../is-buffer/index.js")})},{"../../is-buffer/index.js":89}],14:[function(e,t,r){"use strict";var n,i=e("type/value/is"),o=e("type/value/ensure"),s=e("type/plain-function/ensure"),a=e("es5-ext/object/copy"),u=e("es5-ext/object/normalize-options"),c=e("es5-ext/object/map"),l=Function.prototype.bind,f=Object.defineProperty,p=Object.prototype.hasOwnProperty;n=function(e,t,r){var n,i=o(t)&&s(t.value);return delete(n=a(t)).writable,delete n.value,n.get=function(){return!r.overwriteDefinition&&p.call(this,e)?i:(t.value=l.call(i,r.resolveContext?r.resolveContext(this):this),f(this,e,t),this[e])},n},t.exports=function(e){var t=u(arguments[1]);return i(t.resolveContext)&&s(t.resolveContext),c(e,function(e,r){return n(r,e,t)})}},{"es5-ext/object/copy":41,"es5-ext/object/map":49,"es5-ext/object/normalize-options":50,"type/plain-function/ensure":126,"type/value/ensure":130,"type/value/is":131}],15:[function(e,t,r){"use strict";var n=e("type/value/is"),i=e("type/plain-function/is"),o=e("es5-ext/object/assign"),s=e("es5-ext/object/normalize-options"),a=e("es5-ext/string/#/contains");(t.exports=function(e,t){var r,i,u,c,l;return arguments.length<2||"string"!=typeof e?(c=t,t=e,e=null):c=arguments[2],n(e)?(r=a.call(e,"c"),i=a.call(e,"e"),u=a.call(e,"w")):(r=u=!0,i=!1),l={value:t,configurable:r,enumerable:i,writable:u},c?o(s(c),l):l}).gs=function(e,t,r){var u,c,l,f;return"string"!=typeof e?(l=r,r=t,t=e,e=null):l=arguments[3],n(t)?i(t)?n(r)?i(r)||(l=r,r=void 0):r=void 0:(l=t,t=r=void 0):t=void 0,n(e)?(u=a.call(e,"c"),c=a.call(e,"e")):(u=!0,c=!1),f={get:t,set:r,configurable:u,enumerable:c},l?o(s(l),f):f}},{"es5-ext/object/assign":38,"es5-ext/object/normalize-options":50,"es5-ext/string/#/contains":57,"type/plain-function/is":127,"type/value/is":131}],16:[function(e,t,r){var n=1e3,i=60*n,o=60*i,s=24*o,a=7*s,u=365.25*s;function c(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}t.exports=function(e,t){t=t||{};var r=typeof e;if("string"===r&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*u;case"weeks":case"week":case"w":return r*a;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o;case"minutes":case"minute":case"mins":case"min":case"m":return r*i;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===r&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=s)return c(e,t,s,"day");if(t>=o)return c(e,t,o,"hour");if(t>=i)return c(e,t,i,"minute");if(t>=n)return c(e,t,n,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=s)return Math.round(e/s)+"d";if(t>=o)return Math.round(e/o)+"h";if(t>=i)return Math.round(e/i)+"m";if(t>=n)return Math.round(e/n)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],17:[function(e,t,r){(function(n){r.log=function(...e){return"object"==typeof console&&console.log&&console.log(...e)},r.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;e.splice(1,0,r,"color: inherit");let n=0,i=0;e[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&"%c"===e&&(i=++n)}),e.splice(i,0,r)},r.save=function(e){try{e?r.storage.setItem("debug",e):r.storage.removeItem("debug")}catch(e){}},r.load=function(){let e;try{e=r.storage.getItem("debug")}catch(e){}!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG);return e},r.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},r.storage=function(){try{return localStorage}catch(e){}}(),r.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.exports=e("./common")(r);const{formatters:i}=t.exports;i.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,e("_process"))},{"./common":18,_process:100}],18:[function(e,t,r){t.exports=function(t){function r(e){let t=0;for(let r=0;r{if("%%"===t)return t;a++;const o=n.formatters[i];if("function"==typeof o){const n=e[a];t=o.call(r,n),e.splice(a,1),a--}return t}),n.formatArgs.call(r,e),(r.log||n.log).apply(r,e)}return s.namespace=e,s.enabled=n.enabled(e),s.useColors=n.useColors(),s.color=r(e),s.destroy=i,s.extend=o,"function"==typeof n.init&&n.init(s),n.instances.push(s),s}function i(){const e=n.instances.indexOf(this);return-1!==e&&(n.instances.splice(e,1),!0)}function o(e,t){const r=n(this.namespace+(void 0===t?":":t)+e);return r.log=this.log,r}function s(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return n.debug=n,n.default=n,n.coerce=function(e){return e instanceof Error?e.stack||e.message:e},n.disable=function(){const e=[...n.names.map(s),...n.skips.map(s).map(e=>"-"+e)].join(",");return n.enable(""),e},n.enable=function(e){let t;n.save(e),n.names=[],n.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),i=r.length;for(t=0;t{n[e]=t[e]}),n.instances=[],n.names=[],n.skips=[],n.formatters={},n.selectColor=r,n.enable(n.load()),n}},{ms:16}],19:[function(e,t,r){(function(r,n){var i=e("readable-stream"),o=e("end-of-stream"),s=e("inherits"),a=e("stream-shift"),u=n.from&&n.from!==Uint8Array.from?n.from([0]):new n([0]),c=function(e,t){e._corked?e.once("uncork",t):t()},l=function(e,t){return function(r){r?function(e,t){e._autoDestroy&&e.destroy(t)}(e,"premature close"===r.message?null:r):t&&!e._ended&&e.end()}},f=function(e,t,r){if(!(this instanceof f))return new f(e,t,r);i.Duplex.call(this,r),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!r||!1!==r.autoDestroy,this._forwardDestroy=!r||!1!==r.destroy,this._forwardEnd=!r||!1!==r.end,this._corked=1,this._ondrain=null,this._drained=!1,this._forwarding=!1,this._unwrite=null,this._unread=null,this._ended=!1,this.destroyed=!1,e&&this.setWritable(e),t&&this.setReadable(t)};s(f,i.Duplex),f.obj=function(e,t,r){return r||(r={}),r.objectMode=!0,r.highWaterMark=16,new f(e,t,r)},f.prototype.cork=function(){1==++this._corked&&this.emit("cork")},f.prototype.uncork=function(){this._corked&&0==--this._corked&&this.emit("uncork")},f.prototype.setWritable=function(e){if(this._unwrite&&this._unwrite(),this.destroyed)e&&e.destroy&&e.destroy();else if(null!==e&&!1!==e){var t=this,n=o(e,{writable:!0,readable:!1},l(this,this._forwardEnd)),i=function(){var e=t._ondrain;t._ondrain=null,e&&e()};this._unwrite&&r.nextTick(i),this._writable=e,this._writable.on("drain",i),this._unwrite=function(){t._writable.removeListener("drain",i),n()},this.uncork()}else this.end()},f.prototype.setReadable=function(e){if(this._unread&&this._unread(),this.destroyed)e&&e.destroy&&e.destroy();else{if(null===e||!1===e)return this.push(null),void this.resume();var t,r=this,n=o(e,{writable:!1,readable:!0},l(this)),s=function(){r._forward()},a=function(){r.push(null)};this._drained=!0,this._readable=e,this._readable2=e._readableState?e:(t=e,new i.Readable({objectMode:!0,highWaterMark:16}).wrap(t)),this._readable2.on("readable",s),this._readable2.on("end",a),this._unread=function(){r._readable2.removeListener("readable",s),r._readable2.removeListener("end",a),n()},this._forward()}},f.prototype._read=function(){this._drained=!0,this._forward()},f.prototype._forward=function(){if(!this._forwarding&&this._readable2&&this._drained){var e;for(this._forwarding=!0;this._drained&&null!==(e=a(this._readable2));)this.destroyed||(this._drained=this.push(e));this._forwarding=!1}},f.prototype.destroy=function(e){if(!this.destroyed){this.destroyed=!0;var t=this;r.nextTick(function(){t._destroy(e)})}},f.prototype._destroy=function(e){if(e){var t=this._ondrain;this._ondrain=null,t?t(e):this.emit("error",e)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")},f.prototype._write=function(e,t,r){return this.destroyed?r():this._corked?c(this,this._write.bind(this,e,t,r)):e===u?this._finish(r):this._writable?void(!1===this._writable.write(e)?this._ondrain=r:r()):r()},f.prototype._finish=function(e){var t=this;this.emit("preend"),c(this,function(){var r,n;r=t._forwardEnd&&t._writable,n=function(){!1===t._writableState.prefinished&&(t._writableState.prefinished=!0),t.emit("prefinish"),c(t,e)},r?r._writableState&&r._writableState.finished?n():r._writableState?r.end(n):(r.end(),n()):n()})},f.prototype.end=function(e,t,r){return"function"==typeof e?this.end(null,null,e):"function"==typeof t?this.end(e,null,t):(this._ended=!0,e&&this.write(e),this._writableState.ending||this.write(u),i.Writable.prototype.end.call(this,r))},t.exports=f}).call(this,e("_process"),e("buffer").Buffer)},{_process:100,buffer:12,"end-of-stream":20,inherits:88,"readable-stream":116,"stream-shift":119}],20:[function(e,t,r){var n=e("once"),i=function(){},o=function(e,t,r){if("function"==typeof t)return o(e,null,t);t||(t={}),r=n(r||i);var s=e._writableState,a=e._readableState,u=t.readable||!1!==t.readable&&e.readable,c=t.writable||!1!==t.writable&&e.writable,l=function(){e.writable||f()},f=function(){c=!1,u||r.call(e)},p=function(){u=!1,c||r.call(e)},h=function(t){r.call(e,t?new Error("exited with error code: "+t):null)},d=function(t){r.call(e,t)},g=function(){return(!u||a&&a.ended)&&(!c||s&&s.ended)?void 0:r.call(e,new Error("premature close"))},b=function(){e.req.on("finish",f)};return!function(e){return e.setHeader&&"function"==typeof e.abort}(e)?c&&!s&&(e.on("end",l),e.on("close",l)):(e.on("complete",f),e.on("abort",g),e.req?b():e.on("request",b)),function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length}(e)&&e.on("exit",h),e.on("end",p),e.on("finish",f),!1!==t.error&&e.on("error",d),e.on("close",g),function(){e.removeListener("complete",f),e.removeListener("abort",g),e.removeListener("request",b),e.req&&e.req.removeListener("finish",f),e.removeListener("end",l),e.removeListener("close",l),e.removeListener("finish",f),e.removeListener("exit",h),e.removeListener("end",p),e.removeListener("error",d),e.removeListener("close",g)}};t.exports=o},{once:98}],21:[function(e,t,r){"use strict";var n=e("../../object/valid-value");t.exports=function(){return n(this).length=0,this}},{"../../object/valid-value":56}],22:[function(e,t,r){"use strict";var n=e("../../number/is-nan"),i=e("../../number/to-pos-integer"),o=e("../../object/valid-value"),s=Array.prototype.indexOf,a=Object.prototype.hasOwnProperty,u=Math.abs,c=Math.floor;t.exports=function(e){var t,r,l,f;if(!n(e))return s.apply(this,arguments);for(r=i(o(this).length),l=arguments[1],t=l=isNaN(l)?0:l>=0?c(l):i(this.length)-c(u(l));t=55296&&m<=56319&&(S+=e[++r]),S=x?p.call(x,k,S,g):S,t?(h.value=S,d(b,g,h)):b[g]=S,++g;y=g}if(void 0===y)for(y=s(e.length),t&&(b=new t(y)),r=0;r0?1:-1}},{}],32:[function(e,t,r){"use strict";t.exports=e("./is-implemented")()?Number.isNaN:e("./shim")},{"./is-implemented":33,"./shim":34}],33:[function(e,t,r){"use strict";t.exports=function(){var e=Number.isNaN;return"function"==typeof e&&(!e({})&&e(NaN)&&!e(34))}},{}],34:[function(e,t,r){"use strict";t.exports=function(e){return e!=e}},{}],35:[function(e,t,r){"use strict";var n=e("../math/sign"),i=Math.abs,o=Math.floor;t.exports=function(e){return isNaN(e)?0:0!==(e=Number(e))&&isFinite(e)?n(e)*o(i(e)):e}},{"../math/sign":29}],36:[function(e,t,r){"use strict";var n=e("./to-integer"),i=Math.max;t.exports=function(e){return i(0,n(e))}},{"./to-integer":35}],37:[function(e,t,r){"use strict";var n=e("./valid-callable"),i=e("./valid-value"),o=Function.prototype.bind,s=Function.prototype.call,a=Object.keys,u=Object.prototype.propertyIsEnumerable;t.exports=function(e,t){return function(r,c){var l,f=arguments[2],p=arguments[3];return r=Object(i(r)),n(c),l=a(r),p&&l.sort("function"==typeof p?o.call(p,r):void 0),"function"!=typeof e&&(e=l[e]),s.call(e,l,function(e,n){return u.call(r,e)?s.call(c,f,r[e],e,r,n):t})}}},{"./valid-callable":55,"./valid-value":56}],38:[function(e,t,r){"use strict";t.exports=e("./is-implemented")()?Object.assign:e("./shim")},{"./is-implemented":39,"./shim":40}],39:[function(e,t,r){"use strict";t.exports=function(){var e,t=Object.assign;return"function"==typeof t&&(t(e={foo:"raz"},{bar:"dwa"},{trzy:"trzy"}),e.foo+e.bar+e.trzy==="razdwatrzy")}},{}],40:[function(e,t,r){"use strict";var n=e("../keys"),i=e("../valid-value"),o=Math.max;t.exports=function(e,t){var r,s,a,u=o(arguments.length,2);for(e=Object(i(e)),a=function(n){try{e[n]=t[n]}catch(e){r||(r=e)}},s=1;s-1}},{}],60:[function(e,t,r){"use strict";var n=Object.prototype.toString,i=n.call("");t.exports=function(e){return"string"==typeof e||e&&"object"==typeof e&&(e instanceof String||n.call(e)===i)||!1}},{}],61:[function(e,t,r){"use strict";var n,i=e("es5-ext/object/set-prototype-of"),o=e("es5-ext/string/#/contains"),s=e("d"),a=e("es6-symbol"),u=e("./"),c=Object.defineProperty;n=t.exports=function(e,t){if(!(this instanceof n))throw new TypeError("Constructor requires 'new'");u.call(this,e),t=t?o.call(t,"key+value")?"key+value":o.call(t,"key")?"key":"value":"value",c(this,"__kind__",s("",t))},i&&i(n,u),delete n.prototype.constructor,n.prototype=Object.create(u.prototype,{_resolve:s(function(e){return"value"===this.__kind__?this.__list__[e]:"key+value"===this.__kind__?[e,this.__list__[e]]:e})}),c(n.prototype,a.toStringTag,s("c","Array Iterator"))},{"./":64,d:15,"es5-ext/object/set-prototype-of":52,"es5-ext/string/#/contains":57,"es6-symbol":74}],62:[function(e,t,r){"use strict";var n=e("es5-ext/function/is-arguments"),i=e("es5-ext/object/valid-callable"),o=e("es5-ext/string/is-string"),s=e("./get"),a=Array.isArray,u=Function.prototype.call,c=Array.prototype.some;t.exports=function(e,t){var r,l,f,p,h,d,g,b,y=arguments[2];if(a(e)||n(e)?r="array":o(e)?r="string":e=s(e),i(t),f=function(){p=!0},"array"!==r)if("string"!==r)for(l=e.next();!l.done;){if(u.call(t,y,l.value,f),p)return;l=e.next()}else for(d=e.length,h=0;h=55296&&b<=56319&&(g+=e[++h]),u.call(t,y,g,f),!p);++h);else c.call(e,function(e){return u.call(t,y,e,f),p})}},{"./get":63,"es5-ext/function/is-arguments":26,"es5-ext/object/valid-callable":55,"es5-ext/string/is-string":60}],63:[function(e,t,r){"use strict";var n=e("es5-ext/function/is-arguments"),i=e("es5-ext/string/is-string"),o=e("./array"),s=e("./string"),a=e("./valid-iterable"),u=e("es6-symbol").iterator;t.exports=function(e){return"function"==typeof a(e)[u]?e[u]():n(e)?new o(e):i(e)?new s(e):new o(e)}},{"./array":61,"./string":66,"./valid-iterable":67,"es5-ext/function/is-arguments":26,"es5-ext/string/is-string":60,"es6-symbol":74}],64:[function(e,t,r){"use strict";var n,i=e("es5-ext/array/#/clear"),o=e("es5-ext/object/assign"),s=e("es5-ext/object/valid-callable"),a=e("es5-ext/object/valid-value"),u=e("d"),c=e("d/auto-bind"),l=e("es6-symbol"),f=Object.defineProperty,p=Object.defineProperties;t.exports=n=function(e,t){if(!(this instanceof n))throw new TypeError("Constructor requires 'new'");p(this,{__list__:u("w",a(e)),__context__:u("w",t),__nextIndex__:u("w",0)}),t&&(s(t.on),t.on("_add",this._onAdd),t.on("_delete",this._onDelete),t.on("_clear",this._onClear))},delete n.prototype.constructor,p(n.prototype,o({_next:u(function(){var e;if(this.__list__)return this.__redo__&&void 0!==(e=this.__redo__.shift())?e:this.__nextIndex__=this.__nextIndex__||(++this.__nextIndex__,this.__redo__?(this.__redo__.forEach(function(t,r){t>=e&&(this.__redo__[r]=++t)},this),this.__redo__.push(e)):f(this,"__redo__",u("c",[e])))}),_onDelete:u(function(e){var t;e>=this.__nextIndex__||(--this.__nextIndex__,this.__redo__&&(-1!==(t=this.__redo__.indexOf(e))&&this.__redo__.splice(t,1),this.__redo__.forEach(function(t,r){t>e&&(this.__redo__[r]=--t)},this)))}),_onClear:u(function(){this.__redo__&&i.call(this.__redo__),this.__nextIndex__=0})}))),f(n.prototype,l.iterator,u(function(){return this}))},{d:15,"d/auto-bind":14,"es5-ext/array/#/clear":21,"es5-ext/object/assign":38,"es5-ext/object/valid-callable":55,"es5-ext/object/valid-value":56,"es6-symbol":74}],65:[function(e,t,r){"use strict";var n=e("es5-ext/function/is-arguments"),i=e("es5-ext/object/is-value"),o=e("es5-ext/string/is-string"),s=e("es6-symbol").iterator,a=Array.isArray;t.exports=function(e){return!!i(e)&&(!!a(e)||(!!o(e)||(!!n(e)||"function"==typeof e[s])))}},{"es5-ext/function/is-arguments":26,"es5-ext/object/is-value":45,"es5-ext/string/is-string":60,"es6-symbol":74}],66:[function(e,t,r){"use strict";var n,i=e("es5-ext/object/set-prototype-of"),o=e("d"),s=e("es6-symbol"),a=e("./"),u=Object.defineProperty;n=t.exports=function(e){if(!(this instanceof n))throw new TypeError("Constructor requires 'new'");e=String(e),a.call(this,e),u(this,"__length__",o("",e.length))},i&&i(n,a),delete n.prototype.constructor,n.prototype=Object.create(a.prototype,{_next:o(function(){if(this.__list__)return this.__nextIndex__=55296&&t<=56319?r+this.__list__[this.__nextIndex__++]:r})}),u(n.prototype,s.toStringTag,o("c","String Iterator"))},{"./":64,d:15,"es5-ext/object/set-prototype-of":52,"es6-symbol":74}],67:[function(e,t,r){"use strict";var n=e("./is-iterable");t.exports=function(e){if(!n(e))throw new TypeError(e+" is not iterable");return e}},{"./is-iterable":65}],68:[function(e,t,r){"use strict";t.exports=e("./is-implemented")()?Map:e("./polyfill")},{"./is-implemented":69,"./polyfill":73}],69:[function(e,t,r){"use strict";t.exports=function(){var e,t;if("function"!=typeof Map)return!1;try{e=new Map([["raz","one"],["dwa","two"],["trzy","three"]])}catch(e){return!1}return"[object Map]"===String(e)&&(3===e.size&&("function"==typeof e.clear&&("function"==typeof e.delete&&("function"==typeof e.entries&&("function"==typeof e.forEach&&("function"==typeof e.get&&("function"==typeof e.has&&("function"==typeof e.keys&&("function"==typeof e.set&&("function"==typeof e.values&&(!1===(t=e.entries().next()).done&&(!!t.value&&("raz"===t.value[0]&&"one"===t.value[1])))))))))))))}},{}],70:[function(e,t,r){"use strict";t.exports="undefined"!=typeof Map&&"[object Map]"===Object.prototype.toString.call(new Map)},{}],71:[function(e,t,r){"use strict";t.exports=e("es5-ext/object/primitive-set")("key","value","key+value")},{"es5-ext/object/primitive-set":51}],72:[function(e,t,r){"use strict";var n,i=e("es5-ext/object/set-prototype-of"),o=e("d"),s=e("es6-iterator"),a=e("es6-symbol").toStringTag,u=e("./iterator-kinds"),c=Object.defineProperties,l=s.prototype._unBind;n=t.exports=function(e,t){if(!(this instanceof n))return new n(e,t);s.call(this,e.__mapKeysData__,e),t&&u[t]||(t="key+value"),c(this,{__kind__:o("",t),__values__:o("w",e.__mapValuesData__)})},i&&i(n,s),n.prototype=Object.create(s.prototype,{constructor:o(n),_resolve:o(function(e){return"value"===this.__kind__?this.__values__[e]:"key"===this.__kind__?this.__list__[e]:[this.__list__[e],this.__values__[e]]}),_unBind:o(function(){this.__values__=null,l.call(this)}),toString:o(function(){return"[object Map Iterator]"})}),Object.defineProperty(n.prototype,a,o("c","Map Iterator"))},{"./iterator-kinds":71,d:15,"es5-ext/object/set-prototype-of":52,"es6-iterator":64,"es6-symbol":74}],73:[function(e,t,r){"use strict";var n,i=e("es5-ext/array/#/clear"),o=e("es5-ext/array/#/e-index-of"),s=e("es5-ext/object/set-prototype-of"),a=e("es5-ext/object/valid-callable"),u=e("es5-ext/object/valid-value"),c=e("d"),l=e("event-emitter"),f=e("es6-symbol"),p=e("es6-iterator/valid-iterable"),h=e("es6-iterator/for-of"),d=e("./lib/iterator"),g=e("./is-native-implemented"),b=Function.prototype.call,y=Object.defineProperties,m=Object.getPrototypeOf;t.exports=n=function(){var e,t,r,i=arguments[0];if(!(this instanceof n))throw new TypeError("Constructor requires 'new'");return r=g&&s&&Map!==n?s(new Map,m(this)):this,null!=i&&p(i),y(r,{__mapKeysData__:c("c",e=[]),__mapValuesData__:c("c",t=[])}),i?(h(i,function(r){var n=u(r)[0];r=r[1],-1===o.call(e,n)&&(e.push(n),t.push(r))},r),r):r},g&&(s&&s(n,Map),n.prototype=Object.create(Map.prototype,{constructor:c(n)})),l(y(n.prototype,{clear:c(function(){this.__mapKeysData__.length&&(i.call(this.__mapKeysData__),i.call(this.__mapValuesData__),this.emit("_clear"))}),delete:c(function(e){var t=o.call(this.__mapKeysData__,e);return-1!==t&&(this.__mapKeysData__.splice(t,1),this.__mapValuesData__.splice(t,1),this.emit("_delete",t,e),!0)}),entries:c(function(){return new d(this,"key+value")}),forEach:c(function(e){var t,r,n=arguments[1];for(a(e),r=(t=this.entries())._next();void 0!==r;)b.call(e,n,this.__mapValuesData__[r],this.__mapKeysData__[r],this),r=t._next()}),get:c(function(e){var t=o.call(this.__mapKeysData__,e);if(-1!==t)return this.__mapValuesData__[t]}),has:c(function(e){return-1!==o.call(this.__mapKeysData__,e)}),keys:c(function(){return new d(this,"key")}),set:c(function(e,t){var r,n=o.call(this.__mapKeysData__,e);return-1===n&&(n=this.__mapKeysData__.push(e)-1,r=!0),this.__mapValuesData__[n]=t,r&&this.emit("_add",n,e),this}),size:c.gs(function(){return this.__mapKeysData__.length}),values:c(function(){return new d(this,"value")}),toString:c(function(){return"[object Map]"})})),Object.defineProperty(n.prototype,f.iterator,c(function(){return this.entries()})),Object.defineProperty(n.prototype,f.toStringTag,c("c","Map"))},{"./is-native-implemented":70,"./lib/iterator":72,d:15,"es5-ext/array/#/clear":21,"es5-ext/array/#/e-index-of":22,"es5-ext/object/set-prototype-of":52,"es5-ext/object/valid-callable":55,"es5-ext/object/valid-value":56,"es6-iterator/for-of":62,"es6-iterator/valid-iterable":67,"es6-symbol":74,"event-emitter":82}],74:[function(e,t,r){"use strict";t.exports=e("./is-implemented")()?e("ext/global-this").Symbol:e("./polyfill")},{"./is-implemented":75,"./polyfill":80,"ext/global-this":85}],75:[function(e,t,r){"use strict";var n=e("ext/global-this"),i={object:!0,symbol:!0};t.exports=function(){var e,t=n.Symbol;if("function"!=typeof t)return!1;e=t("test symbol");try{String(e)}catch(e){return!1}return!!i[typeof t.iterator]&&(!!i[typeof t.toPrimitive]&&!!i[typeof t.toStringTag])}},{"ext/global-this":85}],76:[function(e,t,r){"use strict";t.exports=function(e){return!!e&&("symbol"==typeof e||!!e.constructor&&("Symbol"===e.constructor.name&&"Symbol"===e[e.constructor.toStringTag]))}},{}],77:[function(e,t,r){"use strict";var n=e("d"),i=Object.create,o=Object.defineProperty,s=Object.prototype,a=i(null);t.exports=function(e){for(var t,r,i=0;a[e+(i||"")];)++i;return a[e+=i||""]=!0,o(s,t="@@"+e,n.gs(null,function(e){r||(r=!0,o(this,t,n(e)),r=!1)})),t}},{d:15}],78:[function(e,t,r){"use strict";var n=e("d"),i=e("ext/global-this").Symbol;t.exports=function(e){return Object.defineProperties(e,{hasInstance:n("",i&&i.hasInstance||e("hasInstance")),isConcatSpreadable:n("",i&&i.isConcatSpreadable||e("isConcatSpreadable")),iterator:n("",i&&i.iterator||e("iterator")),match:n("",i&&i.match||e("match")),replace:n("",i&&i.replace||e("replace")),search:n("",i&&i.search||e("search")),species:n("",i&&i.species||e("species")),split:n("",i&&i.split||e("split")),toPrimitive:n("",i&&i.toPrimitive||e("toPrimitive")),toStringTag:n("",i&&i.toStringTag||e("toStringTag")),unscopables:n("",i&&i.unscopables||e("unscopables"))})}},{d:15,"ext/global-this":85}],79:[function(e,t,r){"use strict";var n=e("d"),i=e("../../../validate-symbol"),o=Object.create(null);t.exports=function(e){return Object.defineProperties(e,{for:n(function(t){return o[t]?o[t]:o[t]=e(String(t))}),keyFor:n(function(e){var t;for(t in i(e),o)if(o[t]===e)return t})})}},{"../../../validate-symbol":81,d:15}],80:[function(e,t,r){"use strict";var n,i,o,s=e("d"),a=e("./validate-symbol"),u=e("ext/global-this").Symbol,c=e("./lib/private/generate-name"),l=e("./lib/private/setup/standard-symbols"),f=e("./lib/private/setup/symbol-registry"),p=Object.create,h=Object.defineProperties,d=Object.defineProperty;if("function"==typeof u)try{String(u()),o=!0}catch(e){}else u=null;i=function(e){if(this instanceof i)throw new TypeError("Symbol is not a constructor");return n(e)},t.exports=n=function e(t){var r;if(this instanceof e)throw new TypeError("Symbol is not a constructor");return o?u(t):(r=p(i.prototype),t=void 0===t?"":String(t),h(r,{__description__:s("",t),__name__:s("",c(t))}))},l(n),f(n),h(i.prototype,{constructor:s(n),toString:s("",function(){return this.__name__})}),h(n.prototype,{toString:s(function(){return"Symbol ("+a(this).__description__+")"}),valueOf:s(function(){return a(this)})}),d(n.prototype,n.toPrimitive,s("",function(){var e=a(this);return"symbol"==typeof e?e:e.toString()})),d(n.prototype,n.toStringTag,s("c","Symbol")),d(i.prototype,n.toStringTag,s("c",n.prototype[n.toStringTag])),d(i.prototype,n.toPrimitive,s("c",n.prototype[n.toPrimitive]))},{"./lib/private/generate-name":77,"./lib/private/setup/standard-symbols":78,"./lib/private/setup/symbol-registry":79,"./validate-symbol":81,d:15,"ext/global-this":85}],81:[function(e,t,r){"use strict";var n=e("./is-symbol");t.exports=function(e){if(!n(e))throw new TypeError(e+" is not a symbol");return e}},{"./is-symbol":76}],82:[function(e,t,r){"use strict";var n,i,o,s,a,u,c,l=e("d"),f=e("es5-ext/object/valid-callable"),p=Function.prototype.apply,h=Function.prototype.call,d=Object.create,g=Object.defineProperty,b=Object.defineProperties,y=Object.prototype.hasOwnProperty,m={configurable:!0,enumerable:!1,writable:!0};a={on:n=function(e,t){var r;return f(t),y.call(this,"__ee__")?r=this.__ee__:(r=m.value=d(null),g(this,"__ee__",m),m.value=null),r[e]?"object"==typeof r[e]?r[e].push(t):r[e]=[r[e],t]:r[e]=t,this},once:i=function(e,t){var r,i;return f(t),i=this,n.call(this,e,r=function(){o.call(i,e,r),p.call(t,this,arguments)}),r.__eeOnceListener__=t,this},off:o=function(e,t){var r,n,i,o;if(f(t),!y.call(this,"__ee__"))return this;if(!(r=this.__ee__)[e])return this;if("object"==typeof(n=r[e]))for(o=0;i=n[o];++o)i!==t&&i.__eeOnceListener__!==t||(2===n.length?r[e]=n[o?0:1]:n.splice(o,1));else n!==t&&n.__eeOnceListener__!==t||delete r[e];return this},emit:s=function(e){var t,r,n,i,o;if(y.call(this,"__ee__")&&(i=this.__ee__[e]))if("object"==typeof i){for(r=arguments.length,o=new Array(r-1),t=1;t0&&a.length>o){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",u.name,u.message)}}else a=s[t]=r,++e._eventsCount;return e}function p(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;t1&&(t=arguments[1]),t instanceof Error)throw t;var u=new Error('Unhandled "error" event. ('+t+")");throw u.context=t,u}if(!(r=s[e]))return!1;var c="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=b(e,n),o=0;o=0;s--)if(r[s]===t||r[s].listener===t){a=r[s].listener,o=s;break}if(o<0)return this;0===o?r.shift():function(e,t){for(var r=t,n=r+1,i=e.length;n=0;o--)this.removeListener(e,t[o]);return this},s.prototype.listeners=function(e){return d(this,e,!0)},s.prototype.rawListeners=function(e){return d(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):g.call(e,t)},s.prototype.listenerCount=g,s.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],84:[function(e,t,r){var n=function(){if("object"==typeof self&&self)return self;if("object"==typeof window&&window)return window;throw new Error("Unable to resolve global `this`")};t.exports=function(){if(this)return this;try{Object.defineProperty(Object.prototype,"__global__",{get:function(){return this},configurable:!0})}catch(e){return n()}try{return __global__||n()}finally{delete Object.prototype.__global__}}()},{}],85:[function(e,t,r){"use strict";t.exports=e("./is-implemented")()?globalThis:e("./implementation")},{"./implementation":84,"./is-implemented":86}],86:[function(e,t,r){"use strict";t.exports=function(){return"object"==typeof globalThis&&(!!globalThis&&globalThis.Array===Array)}},{}],87:[function(e,t,r){r.read=function(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,l=-7,f=r?i-1:0,p=r?-1:1,h=e[t+f];for(f+=p,o=h&(1<<-l)-1,h>>=-l,l+=a;l>0;o=256*o+e[t+f],f+=p,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=n;l>0;s=256*s+e[t+f],f+=p,l-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,n),o-=c}return(h?-1:1)*s*Math.pow(2,o-n)},r.write=function(e,t,r,n,i,o){var s,a,u,c=8*o-i-1,l=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:o-1,d=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+f>=1?p/u:p*Math.pow(2,1-f))*u>=2&&(s++,u/=2),s+f>=l?(a=0,s=l):s+f>=1?(a=(t*u-1)*Math.pow(2,i),s+=f):(a=t*Math.pow(2,f-1)*Math.pow(2,i),s=0));i>=8;e[r+h]=255&a,h+=d,a/=256,i-=8);for(s=s<0;e[r+h]=255&s,h+=d,s/=256,c-=8);e[r+h-d]|=128*g}},{}],88:[function(e,t,r){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}},{}],89:[function(e,t,r){function n(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}t.exports=function(e){return null!=e&&(n(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&n(e.slice(0,0))}(e)||!!e._isBuffer)}},{}],90:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=t.exports;for(var o in i.types={0:"reserved",1:"connect",2:"connack",3:"publish",4:"puback",5:"pubrec",6:"pubrel",7:"pubcomp",8:"subscribe",9:"suback",10:"unsubscribe",11:"unsuback",12:"pingreq",13:"pingresp",14:"disconnect",15:"auth"},i.codes={},i.types){var s=i.types[o];i.codes[s]=o}for(var a in i.CMD_SHIFT=4,i.CMD_MASK=240,i.DUP_MASK=8,i.QOS_MASK=3,i.QOS_SHIFT=1,i.RETAIN_MASK=1,i.LENGTH_MASK=127,i.LENGTH_FIN_MASK=128,i.SESSIONPRESENT_MASK=1,i.SESSIONPRESENT_HEADER=n.from([i.SESSIONPRESENT_MASK]),i.CONNACK_HEADER=n.from([i.codes.connack<this.length)&&(n=this.length),r>=this.length)return e||o.alloc(0);if(n<=0)return e||o.alloc(0);var i,s,a=!!e,u=this._offset(r),c=n-r,l=c,f=a&&t||0,p=u[1];if(0===r&&n==this.length){if(!a)return 1===this._bufs.length?this._bufs[0]:o.concat(this._bufs,this.length);for(s=0;s(i=this._bufs[s].length-p))){this._bufs[s].copy(e,f,p,p+l);break}this._bufs[s].copy(e,f,p),f+=i,l-=i,p&&(p=0)}return e},s.prototype.shallowSlice=function(e,t){e=e||0,t=t||this.length,e<0&&(e+=this.length),t<0&&(t+=this.length);var r=this._offset(e),n=this._offset(t),i=this._bufs.slice(r[0],n[0]+1);return 0==n[1]?i.pop():i[i.length-1]=i[i.length-1].slice(0,n[1]),0!=r[1]&&(i[0]=i[0].slice(r[1])),new s(i)},s.prototype.toString=function(e,t,r){return this.slice(t,r).toString(e)},s.prototype.consume=function(e){for(;this._bufs.length;){if(!(e>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},s.prototype.duplicate=function(){for(var e=0,t=new s;e>8,0),t.writeUInt8(255&e,1),t}t.exports={cache:o,generateCache:function(){for(var e=0;e=0&&e<128?1:e>=128&&e<16384?2:e>=16384&&e<2097152?3:e>=2097152&&e<268435456?4:0}(e),o=n.allocUnsafe(i);do{t=e%128|0,(e=e/128|0)>0&&(t|=128),o.writeUInt8(t,r++)}while(e>0);return{data:o,length:i}},generate4ByteBuffer:function(e){var t=n.allocUnsafe(4);return t.writeUInt32BE(e,0),t}}},{"safe-buffer":118}],95:[function(e,t,r){t.exports=function(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}},{}],96:[function(e,t,r){"use strict";var n=e("bl"),i=e("inherits"),o=e("events").EventEmitter,s=e("./packet"),a=e("./constants");function u(e){if(!(this instanceof u))return new u(e);this.settings=e||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState()}i(u,o),u.prototype._resetState=function(){this.packet=new s,this.error=null,this._list=n(),this._stateCounter=0},u.prototype.parse=function(e){for(this.error&&this._resetState(),this._list.append(e);(-1!==this.packet.length||this._list.length>0)&&this[this._states[this._stateCounter]]()&&!this.error;)this._stateCounter++,this._stateCounter>=this._states.length&&(this._stateCounter=0);return this._list.length},u.prototype._parseHeader=function(){var e=this._list.readUInt8(0);return this.packet.cmd=a.types[e>>a.CMD_SHIFT],this.packet.retain=0!=(e&a.RETAIN_MASK),this.packet.qos=e>>a.QOS_SHIFT&a.QOS_MASK,this.packet.dup=0!=(e&a.DUP_MASK),this._list.consume(1),!0},u.prototype._parseLength=function(){var e=this._parseVarByteNum(!0);return e&&(this.packet.length=e.value,this._list.consume(e.bytes)),!!e},u.prototype._parsePayload=function(){var e=!1;if(0===this.packet.length||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseConfirmation();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":break;case"disconnect":this._parseDisconnect();break;case"auth":this._parseAuth();break;default:this._emitError(new Error("Not supported"))}e=!0}return e},u.prototype._parseConnect=function(){var e,t,r,n,i,o,s={},u=this.packet;if(null===(e=this._parseString()))return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==e&&"MQIsdp"!==e)return this._emitError(new Error("Invalid protocolId"));if(u.protocolId=e,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(u.protocolVersion=this._list.readUInt8(this._pos),3!==u.protocolVersion&&4!==u.protocolVersion&&5!==u.protocolVersion)return this._emitError(new Error("Invalid protocol version"));if(this._pos++,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(s.username=this._list.readUInt8(this._pos)&a.USERNAME_MASK,s.password=this._list.readUInt8(this._pos)&a.PASSWORD_MASK,s.will=this._list.readUInt8(this._pos)&a.WILL_FLAG_MASK,s.will&&(u.will={},u.will.retain=0!=(this._list.readUInt8(this._pos)&a.WILL_RETAIN_MASK),u.will.qos=(this._list.readUInt8(this._pos)&a.WILL_QOS_MASK)>>a.WILL_QOS_SHIFT),u.clean=0!=(this._list.readUInt8(this._pos)&a.CLEAN_SESSION_MASK),this._pos++,u.keepalive=this._parseNum(),-1===u.keepalive)return this._emitError(new Error("Packet too short"));if(5===u.protocolVersion){var c=this._parseProperties();Object.getOwnPropertyNames(c).length&&(u.properties=c)}if(null===(t=this._parseString()))return this._emitError(new Error("Packet too short"));if(u.clientId=t,s.will){if(5===u.protocolVersion){var l=this._parseProperties();Object.getOwnPropertyNames(l).length&&(u.will.properties=l)}if(null===(r=this._parseString()))return this._emitError(new Error("Cannot parse will topic"));if(u.will.topic=r,null===(n=this._parseBuffer()))return this._emitError(new Error("Cannot parse will payload"));u.will.payload=n}if(s.username){if(null===(o=this._parseString()))return this._emitError(new Error("Cannot parse username"));u.username=o}if(s.password){if(null===(i=this._parseBuffer()))return this._emitError(new Error("Cannot parse password"));u.password=i}return this.settings=u,u},u.prototype._parseConnack=function(){var e=this.packet;if(this._list.length<2)return null;if(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&a.SESSIONPRESENT_MASK),5===this.settings.protocolVersion?e.reasonCode=this._list.readUInt8(this._pos++):e.returnCode=this._list.readUInt8(this._pos++),-1===e.returnCode||-1===e.reasonCode)return this._emitError(new Error("Cannot parse return code"));if(5===this.settings.protocolVersion){var t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}},u.prototype._parsePublish=function(){var e=this.packet;if(e.topic=this._parseString(),null===e.topic)return this._emitError(new Error("Cannot parse topic"));if(!(e.qos>0)||this._parseMessageId()){if(5===this.settings.protocolVersion){var t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}e.payload=this._list.slice(this._pos,e.length)}},u.prototype._parseSubscribe=function(){var e,t,r,n,i,o,s,u=this.packet;if(1!==u.qos)return this._emitError(new Error("Wrong subscribe header"));if(u.subscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){var c=this._parseProperties();Object.getOwnPropertyNames(c).length&&(u.properties=c)}for(;this._pos>a.SUBSCRIBE_OPTIONS_NL_SHIFT&a.SUBSCRIBE_OPTIONS_NL_MASK),i=0!=(t>>a.SUBSCRIBE_OPTIONS_RAP_SHIFT&a.SUBSCRIBE_OPTIONS_RAP_MASK),n=t>>a.SUBSCRIBE_OPTIONS_RH_SHIFT&a.SUBSCRIBE_OPTIONS_RH_MASK,s={topic:e,qos:r},5===this.settings.protocolVersion&&(s.nl=o,s.rap=i,s.rh=n),u.subscriptions.push(s)}}},u.prototype._parseSuback=function(){var e=this.packet;if(this.packet.granted=[],this._parseMessageId()){if(5===this.settings.protocolVersion){var t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos2){e.reasonCode=this._parseByte();var t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return!0},u.prototype._parseDisconnect=function(){var e=this.packet;if(5===this.settings.protocolVersion){e.reasonCode=this._parseByte();var t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return!0},u.prototype._parseAuth=function(){var e=this.packet;if(5!==this.settings.protocolVersion)return this._emitError(new Error("Not supported auth packet for this version MQTT"));e.reasonCode=this._parseByte();var t=this._parseProperties();return Object.getOwnPropertyNames(t).length&&(e.properties=t),!0},u.prototype._parseMessageId=function(){var e=this.packet;return e.messageId=this._parseNum(),null!==e.messageId||(this._emitError(new Error("Cannot parse messageId")),!1)},u.prototype._parseString=function(e){var t,r=this._parseNum(),n=r+this._pos;return-1===r||n>this._list.length||n>this.packet.length?null:(t=this._list.toString("utf8",this._pos,n),this._pos+=r,t)},u.prototype._parseStringPair=function(){return{name:this._parseString(),value:this._parseString()}},u.prototype._parseBuffer=function(){var e,t=this._parseNum(),r=t+this._pos;return-1===t||r>this._list.length||r>this.packet.length?null:(e=this._list.slice(this._pos,r),this._pos+=t,e)},u.prototype._parseNum=function(){if(this._list.length-this._pos<2)return-1;var e=this._list.readUInt16BE(this._pos);return this._pos+=2,e},u.prototype._parse4ByteNum=function(){if(this._list.length-this._pos<4)return-1;var e=this._list.readUInt32BE(this._pos);return this._pos+=4,e},u.prototype._parseVarByteNum=function(e){for(var t,r=0,n=1,i=0,o=!0,s=this._pos?this._pos:0;r<5&&(i+=n*((t=this._list.readUInt8(s+r++))&a.LENGTH_MASK),n*=128,0!=(t&a.LENGTH_FIN_MASK));)if(this._list.length<=r){o=!1;break}return s&&(this._pos+=r),o=!!o&&(e?{bytes:r,value:i}:i)},u.prototype._parseByte=function(){var e=this._list.readUInt8(this._pos);return this._pos++,e},u.prototype._parseByType=function(e){switch(e){case"byte":return 0!==this._parseByte();case"int8":return this._parseByte();case"int16":return this._parseNum();case"int32":return this._parse4ByteNum();case"var":return this._parseVarByteNum();case"string":return this._parseString();case"pair":return this._parseStringPair();case"binary":return this._parseBuffer()}},u.prototype._parseProperties=function(){for(var e=this._parseVarByteNum(),t=this._pos+e,r={};this._pos65535||l%1!=0)return t.emit("error",new Error("Invalid keepalive")),!1;b+=2;if(b+=1,5===a){var y=I(t,g);b+=y.length}if(u){if("object"!=typeof u)return t.emit("error",new Error("Invalid will")),!1;if(!u.topic||"string"!=typeof u.topic)return t.emit("error",new Error("Invalid will topic")),!1;if(b+=i.byteLength(u.topic)+2,u.payload){if(!(u.payload.length>=0))return t.emit("error",new Error("Invalid will payload")),!1;"string"==typeof u.payload?b+=i.byteLength(u.payload)+2:b+=u.payload.length+2;var m={};5===a&&(m=I(t,u.properties),b+=m.length)}}var w=!1;if(null!=p){if(!T(p))return t.emit("error",new Error("Invalid username")),!1;w=!0,b+=i.byteLength(p)+2}if(null!=h){if(!w)return t.emit("error",new Error("Username is required to use password")),!1;if(!T(h))return t.emit("error",new Error("Invalid password")),!1;b+=j(h)+2}t.write(n.CONNECT_HEADER),_(t,b),E(t,s),t.write(4===a?n.VERSION4:5===a?n.VERSION5:n.VERSION3);var S=0;S|=null!=p?n.USERNAME_MASK:0,S|=null!=h?n.PASSWORD_MASK:0,S|=u&&u.retain?n.WILL_RETAIN_MASK:0,S|=u&&u.qos?u.qos<0&&d(t,p);null!=b&&b.write();return t.write(f)}(e,t,r);case"puback":case"pubrec":case"pubrel":case"pubcomp":return function(e,t,r){var o=r?r.protocolVersion:4,s=e||{},a=s.cmd||"puback",u=s.messageId,c=s.dup&&"pubrel"===a?n.DUP_MASK:0,l=0,f=s.reasonCode,p=s.properties,h=5===o?3:2;"pubrel"===a&&(l=1);if("number"!=typeof u)return t.emit("error",new Error("Invalid messageId")),!1;var g=null;if(5===o){if(!(g=C(t,p,r,h)))return!1;h+=g.length}t.write(n.ACKS[a][l][c][0]),_(t,h),d(t,u),5===o&&t.write(i.from([f]));null!==g&&g.write();return!0}(e,t,r);case"subscribe":return function(e,t,r){var o=r?r.protocolVersion:4,s=e||{},a=s.dup?n.DUP_MASK:0,u=s.messageId,c=s.subscriptions,l=s.properties,f=0;if("number"!=typeof u)return t.emit("error",new Error("Invalid messageId")),!1;f+=2;var p=null;5===o&&(p=I(t,l),f+=p.length);if("object"!=typeof c||!c.length)return t.emit("error",new Error("Invalid subscriptions")),!1;for(var h=0;h2)return t.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}f+=i.byteLength(g)+2+1}t.write(n.SUBSCRIBE_HEADER[1][a?1:0][0]),_(t,f),d(t,u),null!==p&&p.write();for(var S=!0,x=0;xo;){var a=i.shift();if(!a||!t[a])return!1;delete t[a],s=I(e,t)}return s}function O(e,t,r){for(var o in _(e,r),t)if(t.hasOwnProperty(o)&&null!==t[o]){var s=t[o];switch(n.propertiesTypes[o]){case"byte":e.write(i.from([n.properties[o]])),e.write(i.from([+s]));break;case"int8":e.write(i.from([n.properties[o]])),e.write(i.from([s]));break;case"binary":e.write(i.from([n.properties[o]])),E(e,s);break;case"int16":e.write(i.from([n.properties[o]])),d(e,s);break;case"int32":e.write(i.from([n.properties[o]])),k(e,s);break;case"var":e.write(i.from([n.properties[o]])),_(e,s);break;case"string":e.write(i.from([n.properties[o]])),v(e,s);break;case"pair":Object.getOwnPropertyNames(s).forEach(function(t){e.write(i.from([n.properties[o]])),w(e,t.toString(),s[t].toString())});break;default:return e.emit("error",new Error("Invalid property "+o)),!1}}}function j(e){return e?e instanceof i?e.length:i.byteLength(e):0}function T(e){return"string"==typeof e||e instanceof i}t.exports=b},{"./constants":90,"./numbers":94,"process-nextick-args":99,"safe-buffer":118}],98:[function(e,t,r){var n=e("wrappy");function i(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function o(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},r=e.name||"Function wrapped with `once`";return t.onceError=r+" shouldn't be called more than once",t.called=!1,t}t.exports=n(i),t.exports.strict=n(o),i.proto=i(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return i(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return o(this)},configurable:!0})})},{wrappy:139}],99:[function(e,t,r){(function(e){"use strict";void 0===e||!e.version||0===e.version.indexOf("v0.")||0===e.version.indexOf("v1.")&&0!==e.version.indexOf("v1.8.")?t.exports={nextTick:function(t,r,n,i){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick(function(){t.call(null,r)});case 3:return e.nextTick(function(){t.call(null,r,n)});case 4:return e.nextTick(function(){t.call(null,r,n,i)});default:for(o=new Array(a-1),s=0;s1)for(var r=1;r= 0x80 (not a basic code point)","invalid-input":"Invalid input"},S=l-f,x=Math.floor,k=String.fromCharCode;function E(e){throw new RangeError(w[e])}function I(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}function C(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),n+I((e=e.replace(v,".")).split("."),t).join(".")}function O(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i65535&&(t+=k((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=k(e)}).join("")}function T(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function A(e,t,r){var n=0;for(e=r?x(e/d):e>>1,e+=x(e/t);e>S*p>>1;n+=l)e=x(e/S);return x(n+(S+1)*e/(e+h))}function P(e){var t,r,n,i,o,s,a,u,h,d,m,_=[],v=e.length,w=0,S=b,k=g;for((r=e.lastIndexOf(y))<0&&(r=0),n=0;n=128&&E("not-basic"),_.push(e.charCodeAt(n));for(i=r>0?r+1:0;i=v&&E("invalid-input"),((u=(m=e.charCodeAt(i++))-48<10?m-22:m-65<26?m-65:m-97<26?m-97:l)>=l||u>x((c-w)/s))&&E("overflow"),w+=u*s,!(u<(h=a<=k?f:a>=k+p?p:a-k));a+=l)s>x(c/(d=l-h))&&E("overflow"),s*=d;k=A(w-o,t=_.length+1,0==o),x(w/t)>c-S&&E("overflow"),S+=x(w/t),w%=t,_.splice(w++,0,S)}return j(_)}function M(e){var t,r,n,i,o,s,a,u,h,d,m,_,v,w,S,I=[];for(_=(e=O(e)).length,t=b,r=0,o=g,s=0;s<_;++s)(m=e[s])<128&&I.push(k(m));for(n=i=I.length,i&&I.push(y);n<_;){for(a=c,s=0;s<_;++s)(m=e[s])>=t&&mx((c-r)/(v=n+1))&&E("overflow"),r+=(a-t)*v,t=a,s=0;s<_;++s)if((m=e[s])c&&E("overflow"),m==t){for(u=r,h=l;!(u<(d=h<=o?f:h>=o+p?p:h-o));h+=l)S=u-d,w=l-d,I.push(k(T(d+S%w,0))),u=x(S/w);I.push(k(T(u,0))),o=A(r,v,n==i),r=0,++n}++r,++t}return I.join("")}if(a={version:"1.4.1",ucs2:{decode:O,encode:j},decode:P,encode:M,toASCII:function(e){return C(e,function(e){return _.test(e)?"xn--"+M(e):e})},toUnicode:function(e){return C(e,function(e){return m.test(e)?P(e.slice(4).toLowerCase()):e})}},i&&o)if(t.exports==i)o.exports=a;else for(u in a)a.hasOwnProperty(u)&&(i[u]=a[u]);else n.punycode=a}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],102:[function(e,t,r){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,r,o){t=t||"&",r=r||"=";var s={};if("string"!=typeof e||0===e.length)return s;var a=/\+/g;e=e.split(t);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var c=e.length;u>0&&c>u&&(c=u);for(var l=0;l=0?(f=g.substr(0,b),p=g.substr(b+1)):(f=g,p=""),h=decodeURIComponent(f),d=decodeURIComponent(p),n(s,h)?i(s[h])?s[h].push(d):s[h]=[s[h],d]:s[h]=d}return s};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],103:[function(e,t,r){"use strict";var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,r,a){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?o(s(e),function(s){var a=encodeURIComponent(n(s))+r;return i(e[s])?o(e[s],function(e){return a+encodeURIComponent(n(e))}).join(t):a+encodeURIComponent(n(e[s]))}).join(t):a?encodeURIComponent(n(a))+r+encodeURIComponent(n(e)):""};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function o(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===c.prototype||(t=function(e){return c.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):w(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?w(e,s,t,!1):I(e,s)):w(e,s,t,!1))):n||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=S?e=S:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function k(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(h("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i.nextTick(E,e):E(e))}function E(e){h("emit readable"),e.emit("readable"),T(e)}function I(e,t){t.readingMore||(t.readingMore=!0,i.nextTick(C,e,t))}function C(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=c.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function P(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i.nextTick(M,t,e))}function M(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function B(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return h("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?P(this):k(this),null;if(0===(e=x(e,t))&&t.ended)return 0===t.length&&P(this),null;var n,i=t.needReadable;return h("need readable",i),(0===t.length||t.length-e0?A(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&P(this)),null!==n&&this.emit("data",n),n},_.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},_.prototype.pipe=function(e,t){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,h("pipe count=%d opts=%j",o.pipesCount,t);var u=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr?l:_;function c(t,r){h("onunpipe"),t===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,h("cleanup"),e.removeListener("close",y),e.removeListener("finish",m),e.removeListener("drain",f),e.removeListener("error",b),e.removeListener("unpipe",c),n.removeListener("end",l),n.removeListener("end",_),n.removeListener("data",g),p=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||f())}function l(){h("onend"),e.end()}o.endEmitted?i.nextTick(u):n.once("end",u),e.on("unpipe",c);var f=function(e){return function(){var t=e._readableState;h("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&a(e,"data")&&(t.flowing=!0,T(e))}}(n);e.on("drain",f);var p=!1;var d=!1;function g(t){h("ondata"),d=!1,!1!==e.write(t)||d||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==B(o.pipes,e))&&!p&&(h("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,d=!0),n.pause())}function b(t){h("onerror",t),_(),e.removeListener("error",b),0===a(e,"error")&&e.emit("error",t)}function y(){e.removeListener("finish",m),_()}function m(){h("onfinish"),e.removeListener("close",y),_()}function _(){h("unpipe"),n.unpipe(e)}return n.on("data",g),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?s(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",b),e.once("close",y),e.once("finish",m),e.emit("pipe",n),o.flowing||(h("pipe resume"),n.resume()),e},_.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1?i:o.nextTick;m.WritableState=y;var c=e("core-util-is");c.inherits=e("inherits");var l={deprecate:e("util-deprecate")},f=e("./internal/streams/stream"),p=e("safe-buffer").Buffer,h=n.Uint8Array||function(){};var d,g=e("./internal/streams/destroy");function b(){}function y(t,r){a=a||e("./_stream_duplex"),t=t||{};var n=r instanceof a;this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var i=t.highWaterMark,c=t.writableHighWaterMark,l=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(c||0===c)?c:l,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var f=!1===t.decodeStrings;this.decodeStrings=!f,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,i){--t.pendingcb,r?(o.nextTick(i,n),o.nextTick(k,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),k(e,t))}(e,r,n,t,i);else{var s=S(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||w(e,r),n?u(v,e,r,s,i):v(e,r,s,i)}}(r,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function m(t){if(a=a||e("./_stream_duplex"),!(d.call(m,this)||this instanceof a))return new m(t);this._writableState=new y(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),f.call(this)}function _(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function v(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),k(e,t)}function w(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var a=0,u=!0;r;)i[a]=r,r.isBuf||(u=!1),r=r.next,a+=1;i.allBuffers=u,_(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new s(t),t.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,l=r.encoding,f=r.callback;if(_(e,t,!1,t.objectMode?1:c.length,c,l,f),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function S(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function x(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),k(e,t)})}function k(e,t){var r=S(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,o.nextTick(x,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}c.inherits(m,f),y.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(y.prototype,"buffer",{get:l.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(m,Symbol.hasInstance,{value:function(e){return!!d.call(this,e)||this===m&&(e&&e._writableState instanceof y)}})):d=function(e){return e instanceof this},m.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},m.prototype.write=function(e,t,r){var n,i=this._writableState,s=!1,a=!i.objectMode&&(n=e,p.isBuffer(n)||n instanceof h);return a&&!p.isBuffer(e)&&(e=function(e){return p.from(e)}(e)),"function"==typeof t&&(r=t,t=null),a?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=b),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),o.nextTick(t,r)}(this,r):(a||function(e,t,r,n){var i=!0,s=!1;return null===r?s=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(e.emit("error",s),o.nextTick(n,s),i=!1),i}(this,i,e,r))&&(i.pendingcb++,s=function(e,t,r,n,i,o){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=p.from(t,r));return t}(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(m.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),m.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},m.prototype._writev=null,m.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!==e&&void 0!==e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,k(e,t),r&&(t.finished?o.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),m.prototype.destroy=g.destroy,m.prototype._undestroy=g.undestroy,m.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("timers").setImmediate)},{"./_stream_duplex":106,"./internal/streams/destroy":112,"./internal/streams/stream":113,_process:100,"core-util-is":13,inherits:88,"process-nextick-args":99,"safe-buffer":118,timers:120,"util-deprecate":134}],111:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=e("util");t.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return n.alloc(0);if(1===this.length)return this.head.data;for(var t,r,i,o=n.allocUnsafe(e>>>0),s=this.head,a=0;s;)t=s.data,r=o,i=a,t.copy(r,i),a+=s.data.length,s=s.next;return o},e}(),i&&i.inspect&&i.inspect.custom&&(t.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},{"safe-buffer":118,util:11}],112:[function(e,t,r){"use strict";var n=e("process-nextick-args");function i(e,t){e.emit("error",t)}t.exports={destroy:function(e,t){var r=this,o=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return o||s?(t?t(e):!e||this._writableState&&this._writableState.errorEmitted||n.nextTick(i,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?(n.nextTick(i,r,e),r._writableState&&(r._writableState.errorEmitted=!0)):t&&t(e)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":99}],113:[function(e,t,r){t.exports=e("events").EventEmitter},{events:83}],114:[function(e,t,r){var n={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},{}],115:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=u,this.end=c,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=l,this.end=f,t=3;break;default:return this.write=p,void(this.end=h)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function s(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function u(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function l(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function f(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function p(e){return e.toString(this.encoding)}function h(e){return e&&e.length?this.write(e):""}r.StringDecoder=o,o.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":118}],116:[function(e,t,r){(r=t.exports=e("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=e("./lib/_stream_writable.js"),r.Duplex=e("./lib/_stream_duplex.js"),r.Transform=e("./lib/_stream_transform.js"),r.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":106,"./lib/_stream_passthrough.js":107,"./lib/_stream_readable.js":108,"./lib/_stream_transform.js":109,"./lib/_stream_writable.js":110}],117:[function(e,t,r){"use strict";t.exports=function(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("interval needed");var e;if(arguments.length>0){e=new Array(arguments.length-2);for(var t=0;t=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},r.setImmediate="function"==typeof t?t:function(e){var t=u++,n=!(arguments.length<2)&&s.call(arguments,1);return a[t]=!0,i(function(){a[t]&&(n?e.apply(null,n):e.call(null),r.clearImmediate(t))}),t},r.clearImmediate="function"==typeof n?n:function(e){delete a[e]}}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{"process/browser.js":100,timers:120}],121:[function(e,t,r){"use strict";var n=e("../prototype/is");t.exports=function(e){if("function"!=typeof e)return!1;if(!hasOwnProperty.call(e,"length"))return!1;try{if("number"!=typeof e.length)return!1;if("function"!=typeof e.call)return!1;if("function"!=typeof e.apply)return!1}catch(e){return!1}return!n(e)}},{"../prototype/is":128}],122:[function(e,t,r){"use strict";var n=e("../value/is"),i=e("../object/is"),o=e("../string/coerce"),s=e("./to-short-string"),a=function(e,t){return e.replace("%v",s(t))};t.exports=function(e,t,r){if(!i(r))throw new TypeError(a(t,e));if(!n(e)){if("default"in r)return r.default;if(r.isOptional)return null}var s=o(r.errorMessage);throw n(s)||(s=t),new TypeError(a(s,e))}},{"../object/is":125,"../string/coerce":129,"../value/is":131,"./to-short-string":124}],123:[function(e,t,r){"use strict";t.exports=function(e){try{return e.toString()}catch(t){try{return String(e)}catch(e){return null}}}},{}],124:[function(e,t,r){"use strict";var n=e("./safe-to-string"),i=/[\n\r\u2028\u2029]/g;t.exports=function(e){var t=n(e);return null===t?"":(t.length>100&&(t=t.slice(0,99)+"…"),t=t.replace(i,function(e){switch(e){case"\n":return"\\n";case"\r":return"\\r";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";default:throw new Error("Unexpected character")}}))}},{"./safe-to-string":123}],125:[function(e,t,r){"use strict";var n=e("../value/is"),i={object:!0,function:!0,undefined:!0};t.exports=function(e){return!!n(e)&&hasOwnProperty.call(i,typeof e)}},{"../value/is":131}],126:[function(e,t,r){"use strict";var n=e("../lib/resolve-exception"),i=e("./is");t.exports=function(e){return i(e)?e:n(e,"%v is not a plain function",arguments[1])}},{"../lib/resolve-exception":122,"./is":127}],127:[function(e,t,r){"use strict";var n=e("../function/is"),i=/^\s*class[\s{/}]/,o=Function.prototype.toString;t.exports=function(e){return!!n(e)&&!i.test(o.call(e))}},{"../function/is":121}],128:[function(e,t,r){"use strict";var n=e("../object/is");t.exports=function(e){if(!n(e))return!1;try{return!!e.constructor&&e.constructor.prototype===e}catch(e){return!1}}},{"../object/is":125}],129:[function(e,t,r){"use strict";var n=e("../value/is"),i=e("../object/is"),o=Object.prototype.toString;t.exports=function(e){if(!n(e))return null;if(i(e)){var t=e.toString;if("function"!=typeof t)return null;if(t===o)return null}try{return""+e}catch(e){return null}}},{"../object/is":125,"../value/is":131}],130:[function(e,t,r){"use strict";var n=e("../lib/resolve-exception"),i=e("./is");t.exports=function(e){return i(e)?e:n(e,"Cannot use %v",arguments[1])}},{"../lib/resolve-exception":122,"./is":131}],131:[function(e,t,r){"use strict";t.exports=function(e){return void 0!==e&&null!==e}},{}],132:[function(e,t,r){"use strict";var n=e("punycode"),i=e("./util");function o(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}r.parse=_,r.resolve=function(e,t){return _(e,!1,!0).resolve(t)},r.resolveObject=function(e,t){return e?_(e,!1,!0).resolveObject(t):t},r.format=function(e){i.isString(e)&&(e=_(e));return e instanceof o?e.format():o.prototype.format.call(e)},r.Url=o;var s=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,u=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,c=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),l=["'"].concat(c),f=["%","/","?",";","#"].concat(l),p=["/","?","#"],h=/^[+a-z0-9A-Z_-]{0,63}$/,d=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:!0,"javascript:":!0},b={javascript:!0,"javascript:":!0},y={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},m=e("querystring");function _(e,t,r){if(e&&i.isObject(e)&&e instanceof o)return e;var n=new o;return n.parse(e,t,r),n}o.prototype.parse=function(e,t,r){if(!i.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),a=-1!==o&&o127?M+="x":M+=P[B];if(!M.match(h)){var U=T.slice(0,C),N=T.slice(C+1),L=P.match(d);L&&(U.push(L[1]),N.unshift(L[2])),N.length&&(_="/"+N.join(".")+_),this.hostname=U.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),j||(this.hostname=n.toASCII(this.hostname));var q=this.port?":"+this.port:"",F=this.hostname||"";this.host=F+q,this.href+=this.host,j&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==_[0]&&(_="/"+_))}if(!g[S])for(C=0,A=l.length;C0)&&r.host.split("@"))&&(r.auth=j.shift(),r.host=r.hostname=j.shift());return r.search=e.search,r.query=e.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!x.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var E=x.slice(-1)[0],I=(r.host||e.host||x.length>1)&&("."===E||".."===E)||""===E,C=0,O=x.length;O>=0;O--)"."===(E=x[O])?x.splice(O,1):".."===E?(x.splice(O,1),C++):C&&(x.splice(O,1),C--);if(!w&&!S)for(;C--;C)x.unshift("..");!w||""===x[0]||x[0]&&"/"===x[0].charAt(0)||x.unshift(""),I&&"/"!==x.join("/").substr(-1)&&x.push("");var j,T=""===x[0]||x[0]&&"/"===x[0].charAt(0);k&&(r.hostname=r.host=T?"":x.length?x.shift():"",(j=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=j.shift(),r.host=r.hostname=j.shift()));return(w=w||r.host&&x.length)&&!T&&x.unshift(""),x.length?r.pathname=x.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var e=this.host,t=a.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":133,punycode:101,querystring:104}],133:[function(e,t,r){"use strict";t.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},{}],134:[function(e,t,r){(function(e){function r(t){try{if(!e.localStorage)return!1}catch(e){return!1}var r=e.localStorage[t];return null!=r&&"true"===String(r).toLowerCase()}t.exports=function(e,t){if(r("noDeprecation"))return e;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],135:[function(e,t,r){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],136:[function(e,t,r){(function(t,n){var i=/%[sdj%]/g;r.format=function(e){if(!y(e)){for(var t=[],r=0;r=o)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),d(t)?n.showHidden=t:t&&r._extend(n,t),m(n.showHidden)&&(n.showHidden=!1),m(n.depth)&&(n.depth=2),m(n.colors)&&(n.colors=!1),m(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),l(n,e,n.depth)}function u(e,t){var r=a.styles[t];return r?"["+a.colors[r][0]+"m"+e+"["+a.colors[r][1]+"m":e}function c(e,t){return e}function l(e,t,n){if(e.customInspect&&t&&x(t.inspect)&&t.inspect!==r.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(n,e);return y(i)||(i=l(e,i,n)),i}var o=function(e,t){if(m(t))return e.stylize("undefined","undefined");if(y(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(b(t))return e.stylize(""+t,"number");if(d(t))return e.stylize(""+t,"boolean");if(g(t))return e.stylize("null","null")}(e,t);if(o)return o;var s=Object.keys(t),a=function(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(t)),S(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return f(t);if(0===s.length){if(x(t)){var u=t.name?": "+t.name:"";return e.stylize("[Function"+u+"]","special")}if(_(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(w(t))return e.stylize(Date.prototype.toString.call(t),"date");if(S(t))return f(t)}var c,v="",k=!1,E=["{","}"];(h(t)&&(k=!0,E=["[","]"]),x(t))&&(v=" [Function"+(t.name?": "+t.name:"")+"]");return _(t)&&(v=" "+RegExp.prototype.toString.call(t)),w(t)&&(v=" "+Date.prototype.toUTCString.call(t)),S(t)&&(v=" "+f(t)),0!==s.length||k&&0!=t.length?n<0?_(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),c=k?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(c,v,E)):E[0]+v+E[1]}function f(e){return"["+Error.prototype.toString.call(e)+"]"}function p(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),C(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=g(r)?l(e,u.value,null):l(e,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+a.split("\n").map(function(e){return" "+e}).join("\n")):a=e.stylize("[Circular]","special")),m(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function h(e){return Array.isArray(e)}function d(e){return"boolean"==typeof e}function g(e){return null===e}function b(e){return"number"==typeof e}function y(e){return"string"==typeof e}function m(e){return void 0===e}function _(e){return v(e)&&"[object RegExp]"===k(e)}function v(e){return"object"==typeof e&&null!==e}function w(e){return v(e)&&"[object Date]"===k(e)}function S(e){return v(e)&&("[object Error]"===k(e)||e instanceof Error)}function x(e){return"function"==typeof e}function k(e){return Object.prototype.toString.call(e)}function E(e){return e<10?"0"+e.toString(10):e.toString(10)}r.debuglog=function(e){if(m(o)&&(o=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!s[e])if(new RegExp("\\b"+e+"\\b","i").test(o)){var n=t.pid;s[e]=function(){var t=r.format.apply(r,arguments);console.error("%s %d: %s",e,n,t)}}else s[e]=function(){};return s[e]},r.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=h,r.isBoolean=d,r.isNull=g,r.isNullOrUndefined=function(e){return null==e},r.isNumber=b,r.isString=y,r.isSymbol=function(e){return"symbol"==typeof e},r.isUndefined=m,r.isRegExp=_,r.isObject=v,r.isDate=w,r.isError=S,r.isFunction=x,r.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},r.isBuffer=e("./support/isBuffer");var I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function C(e,t){return Object.prototype.hasOwnProperty.call(e,t)}r.log=function(){var e,t;console.log("%s - %s",(e=new Date,t=[E(e.getHours()),E(e.getMinutes()),E(e.getSeconds())].join(":"),[e.getDate(),I[e.getMonth()],t].join(" ")),r.format.apply(r,arguments))},r.inherits=e("inherits"),r._extend=function(e,t){if(!t||!v(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":135,_process:100,inherits:88}],137:[function(e,t,r){(function(r,n){"use strict";var i=e("readable-stream").Transform,o=e("duplexify"),s=e("ws"),a=e("safe-buffer").Buffer;t.exports=function(e,t,u){var c,l,f="browser"===r.title,p=!!n.WebSocket,h=f?function e(t,r,n){if(l.bufferedAmount>g)return void setTimeout(e,b,t,r,n);y&&"string"==typeof t&&(t=a.from(t,"utf8"));try{l.send(t)}catch(e){return n(e)}n()}:function(e,t,r){if(l.readyState!==l.OPEN)return void r();y&&"string"==typeof e&&(e=a.from(e,"utf8"));l.send(e,r)};t&&!Array.isArray(t)&&"object"==typeof t&&(u=t,t=null,("string"==typeof u.protocol||Array.isArray(u.protocol))&&(t=u.protocol));u||(u={});void 0===u.objectMode&&(u.objectMode=!(!0===u.binary||void 0===u.binary));var d=function(e,t,r){var n=new i({objectMode:e.objectMode});return n._write=t,n._flush=r,n}(u,h,function(e){l.close(),e()});u.objectMode||(d._writev=function(e,t){for(var r=new Array(e.length),n=0;n1?t-1:0),o=1;t>o;o++)r[o-1]=arguments[o];return n instanceof Error?n:e.apply(void 0,[n].concat(r))},u=r(o),c=""+n,a=function(){var t=i.apply(void 0,arguments),r={type:n};return t instanceof Error&&(r.error=!0),void 0!==t&&(r.payload=t),u&&(r.meta=o.apply(void 0,arguments)),r};return a.toString=function(){return c},a}function v(n,t,r){return t in n?Object.defineProperty(n,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[t]=r,n}function s(n){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{},e=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(e=e.concat(Object.getOwnPropertySymbols(r).filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable}))),e.forEach(function(t){v(n,t,r[t])})}return n}var y=function(n){if("object"!=typeof n||null===n)return!1;for(var t=n;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(n)===t},b=function(n){return Array.isArray(n)},g=function(n){return null==n},h=function(n){return n[n.length-1]},m=function(n){return j.test(n)?n.toLowerCase():O.test(n)?(function(n){return n.replace(x,function(n,t){return t?" "+t:""})}(n)||n).toLowerCase():w.test(n)?function(n){return n.replace(A,function(n,t,r){return t+" "+r.toLowerCase().split("").join(" ")})}(n).toLowerCase():n.toLowerCase()},j=/\s/,O=/(_|-|\.|:)/,w=/([a-z][A-Z]|[A-Z][a-z])/;var x=/[\W_]+(.|$)/g;var A=/(.)([A-Z]+)/g;var E=function(n){return m(n).replace(/[\W_]+(.|$)/g,function(n,t){return t?" "+t:""}).trim()};var P=function(n){return E(n).replace(/\s(\w)/g,function(n,t){return t.toUpperCase()})};var S=function(n){return-1===n.indexOf("/")?P(n):n.split("/").map(P).join("/")},C=function(n,t){return n.reduce(function(n,r){return t(n,r)},{})},L=function(n){return"undefined"!=typeof Map&&n instanceof Map};function R(n){if(L(n))return Array.from(n.keys());if("undefined"!=typeof Reflect&&"function"==typeof Reflect.ownKeys)return Reflect.ownKeys(n);var t=Object.getOwnPropertyNames(n);return"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(n))),t}function _(n,t){return L(t)?t.get(n):t[n]}var k=function(n){return function t(r,e,o,i){var u=void 0===e?{}:e,f=u.namespace,p=void 0===f?c:f,l=u.prefix;return void 0===o&&(o={}),void 0===i&&(i=""),R(r).forEach(function(e){var u=function(n){return i||!l||l&&RegExp("^"+l+p).test(n)?n:""+l+p+n}(function(n){var t;if(!i)return n;var r=(""+n).split(a),e=i.split(a);return(t=[]).concat.apply(t,e.map(function(n){return r.map(function(t){return""+n+p+t})})).join(a)}(e)),c=_(e,r);n(c)?t(c,{namespace:p,prefix:l},o,u):o[u]=c}),o}},M=k(y);function T(n,t){var r=void 0===t?{}:t,e=r.namespace,i=void 0===e?c:e,u=r.prefix;var a={};return Object.getOwnPropertyNames(n).forEach(function(t){var r=u?t.replace(""+u+i,""):t;return function t(r,e,i){var u=S(i.shift());o(i)?e[u]=n[r]:(e[u]||(e[u]={}),t(r,e[u],i))}(t,a,r.split(i))}),a}function Z(n,e){var o=void 0===e?{}:e,i=o.prefix,u=o.namespace,a=void 0===u?c:u;return C(Object.keys(n),function(e,o){var u,c=n[o];t(function(n){if(r(n)||g(n))return!0;if(b(n)){var t=n[0],e=n[1];return r(void 0===t?p:t)&&r(e)}return!1}(c),"Expected function, undefined, null, or array with payload and meta functions for "+o);var f=i?""+i+a+o:o,l=b(c)?d.apply(void 0,[f].concat(c)):d(f,c);return s({},e,((u={})[o]=l,u))})}function z(n,t){var r=Z(C(n,function(n,t){var r;return s({},n,((r={})[t]=p,r))}),t);return C(Object.keys(r),function(n,t){var e;return s({},n,((e={})[S(t)]=r[t],e))})}var I=function(n,t){return function r(){null==t&&(t=n.length);var e=[].slice.call(arguments);return t>e.length?function(){return r.apply(this,e.concat([].slice.call(arguments)))}:n.apply(this,e)}};var K=function(n){return void 0===n};function N(n,e,o){void 0===e&&(e=p);var u=i(n).split(a);t(!K(o),"defaultState for reducer handling "+u.join(", ")+" should be defined"),t(r(e)||y(e),"Expected reducer to be a function or object with next and throw reducers");var c=r(e)?[e,e]:[e.next,e.throw].map(function(n){return g(n)?p:n}),f=c[0],l=c[1];return function(n,t){void 0===n&&(n=o);var r=t.type;return r&&-1!==u.indexOf(i(r))?(!0===t.error?l:f)(n,t):n}}var W=function(){for(var n=arguments.length,t=Array(n),r=0;n>r;r++)t[r]=arguments[r];var e="function"!=typeof t[t.length-1]&&t.pop(),o=t;if(void 0===e)throw new TypeError("The initial state may not be undefined. If you do not want to set a value for this reducer, you can use null instead of undefined.");return function(n,t){for(var r=arguments.length,i=Array(r>2?r-2:0),u=2;r>u;u++)i[u-2]=arguments[u];var c=void 0===n,a=void 0===t;return c&&a&&e?e:o.reduce(function(n,r){return r.apply(void 0,[n,t].concat(i))},c&&!a&&e?e:n)}};var $=k(function(n){return(y(n)||L(n))&&(t=R(n),r=t.every(function(n){return"next"===n||"throw"===n}),!(t.length&&2>=t.length&&r));var t,r});n.combineActions=function(){for(var n=arguments.length,r=Array(n),e=0;n>e;e++)r[e]=arguments[e];var u;t(!o(u=r)&&u.every(f),"Expected action types to be strings, symbols, or action creators");var c=r.map(i).join(a);return{toString:function(){return c}}},n.createAction=d,n.createActions=function(n){for(var r=arguments.length,e=Array(r>1?r-1:0),o=1;r>o;o++)e[o-1]=arguments[o];var i=y(h(e))?e.pop():{};return t(e.every(u)&&(u(n)||y(n)),"Expected optional object followed by string action types"),u(n)?z([n].concat(e),i):s({},function(n,t){return T(Z(M(n,t)),t)}(n,i),z(e,i))},n.createCurriedAction=function(n,t){return I(d(n,t),t.length)},n.handleAction=N,n.handleActions=function(n,r,e){void 0===e&&(e={}),t(y(n)||L(n),"Expected handlers to be a plain object.");var o=$(n,e),i=R(o).map(function(n){return N(n,_(n,o),r)}),u=W.apply(void 0,i.concat([r]));return function(n,t){return void 0===n&&(n=r),u(n,t)}},Object.defineProperty(n,"__esModule",{value:!0})}); diff --git a/libs/redux-logger.js b/libs/redux-logger.js new file mode 100644 index 0000000..0ffa1ee --- /dev/null +++ b/libs/redux-logger.js @@ -0,0 +1 @@ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.reduxLogger=e.reduxLogger||{})}(this,function(e){"use strict";function t(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}function r(e,t){Object.defineProperty(this,"kind",{value:e,enumerable:!0}),t&&t.length&&Object.defineProperty(this,"path",{value:t,enumerable:!0})}function n(e,t,r){n.super_.call(this,"E",e),Object.defineProperty(this,"lhs",{value:t,enumerable:!0}),Object.defineProperty(this,"rhs",{value:r,enumerable:!0})}function o(e,t){o.super_.call(this,"N",e),Object.defineProperty(this,"rhs",{value:t,enumerable:!0})}function i(e,t){i.super_.call(this,"D",e),Object.defineProperty(this,"lhs",{value:t,enumerable:!0})}function a(e,t,r){a.super_.call(this,"A",e),Object.defineProperty(this,"index",{value:t,enumerable:!0}),Object.defineProperty(this,"item",{value:r,enumerable:!0})}function f(e,t,r){var n=e.slice((r||t)+1||e.length);return e.length=t<0?e.length+t:t,e.push.apply(e,n),e}function u(e){var t="undefined"==typeof e?"undefined":N(e);return"object"!==t?t:e===Math?"math":null===e?"null":Array.isArray(e)?"array":"[object Date]"===Object.prototype.toString.call(e)?"date":"function"==typeof e.toString&&/^\/.*\//.test(e.toString())?"regexp":"object"}function l(e,t,r,c,s,d,p){s=s||[],p=p||[];var g=s.slice(0);if("undefined"!=typeof d){if(c){if("function"==typeof c&&c(g,d))return;if("object"===("undefined"==typeof c?"undefined":N(c))){if(c.prefilter&&c.prefilter(g,d))return;if(c.normalize){var h=c.normalize(g,d,e,t);h&&(e=h[0],t=h[1])}}}g.push(d)}"regexp"===u(e)&&"regexp"===u(t)&&(e=e.toString(),t=t.toString());var y="undefined"==typeof e?"undefined":N(e),v="undefined"==typeof t?"undefined":N(t),b="undefined"!==y||p&&p[p.length-1].lhs&&p[p.length-1].lhs.hasOwnProperty(d),m="undefined"!==v||p&&p[p.length-1].rhs&&p[p.length-1].rhs.hasOwnProperty(d);if(!b&&m)r(new o(g,t));else if(!m&&b)r(new i(g,e));else if(u(e)!==u(t))r(new n(g,e,t));else if("date"===u(e)&&e-t!==0)r(new n(g,e,t));else if("object"===y&&null!==e&&null!==t)if(p.filter(function(t){return t.lhs===e}).length)e!==t&&r(new n(g,e,t));else{if(p.push({lhs:e,rhs:t}),Array.isArray(e)){var w;e.length;for(w=0;w=t.length?r(new a(g,w,new i(void 0,e[w]))):l(e[w],t[w],r,c,g,w,p);for(;w=0?(l(e[n],t[n],r,c,g,n,p),S=f(S,i)):l(e[n],void 0,r,c,g,n,p)}),S.forEach(function(e){l(void 0,t[e],r,c,g,e,p)})}p.length=p.length-1}else e!==t&&("number"===y&&isNaN(e)&&isNaN(t)||r(new n(g,e,t)))}function c(e,t,r,n){return n=n||[],l(e,t,function(e){e&&n.push(e)},r),n.length?n:void 0}function s(e,t,r){if(r.path&&r.path.length){var n,o=e[t],i=r.path.length-1;for(n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=Object.assign({},L,e),r=t.logger,n=t.stateTransformer,o=t.errorTransformer,i=t.predicate,a=t.logErrors,f=t.diffPredicate;if("undefined"==typeof r)return function(){return function(e){return function(t){return e(t)}}};if(e.getState&&e.dispatch)return console.error("[redux-logger] redux-logger not installed. Make sure to pass logger instance as middleware:\n// Logger with default options\nimport { logger } from 'redux-logger'\nconst store = createStore(\n reducer,\n applyMiddleware(logger)\n)\n// Or you can create your own logger with custom options http://bit.ly/redux-logger-options\nimport createLogger from 'redux-logger'\nconst logger = createLogger({\n // ...options\n});\nconst store = createStore(\n reducer,\n applyMiddleware(logger)\n)\n"),function(){return function(e){return function(t){return e(t)}}};var u=[];return function(e){var r=e.getState;return function(e){return function(l){if("function"==typeof i&&!i(r,l))return e(l);var c={};u.push(c),c.started=O.now(),c.startedTime=new Date,c.prevState=n(r()),c.action=l;var s=void 0;if(a)try{s=e(l)}catch(e){c.error=o(e)}else s=e(l);c.took=O.now()-c.started,c.nextState=n(r());var d=t.diff&&"function"==typeof f?f(r,l):t.diff;if(x(u,Object.assign({},t,{diff:d})),u.length=0,c.error)throw c.error;return s}}}}var k,j,E=function(e,t){return new Array(t+1).join(e)},A=function(e,t){return E("0",t-e.toString().length)+e},D=function(e){return A(e.getHours(),2)+":"+A(e.getMinutes(),2)+":"+A(e.getSeconds(),2)+"."+A(e.getMilliseconds(),3)},O="undefined"!=typeof performance&&null!==performance&&"function"==typeof performance.now?performance:Date,N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},P=function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t0&&void 0!==arguments[0]?arguments[0]:{},t=e.dispatch,r=e.getState;return"function"==typeof t||"function"==typeof r?S()({dispatch:t,getState:r}):void console.error("\n[redux-logger v3] BREAKING CHANGE\n[redux-logger v3] Since 3.0.0 redux-logger exports by default logger with default settings.\n[redux-logger v3] Change\n[redux-logger v3] import createLogger from 'redux-logger'\n[redux-logger v3] to\n[redux-logger v3] import { createLogger } from 'redux-logger'\n")};e.defaults=L,e.createLogger=S,e.logger=T,e.default=T,Object.defineProperty(e,"__esModule",{value:!0})}); diff --git a/libs/redux-thunk.min.js b/libs/redux-thunk.min.js new file mode 100644 index 0000000..b42c3c0 --- /dev/null +++ b/libs/redux-thunk.min.js @@ -0,0 +1 @@ +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ReduxThunk=e():t.ReduxThunk=e()}(this,function(){return function(t){function e(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return t[o].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){t.exports=n(1)},function(t,e){"use strict";function n(t){return function(e){var n=e.dispatch,o=e.getState;return function(e){return function(r){return"function"==typeof r?r(n,o,t):e(r)}}}}e.__esModule=!0;var o=n();o.withExtraArgument=n,e.default=o}])}); \ No newline at end of file diff --git a/libs/redux.js b/libs/redux.js new file mode 100644 index 0000000..699e085 --- /dev/null +++ b/libs/redux.js @@ -0,0 +1,784 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (factory((global.Redux = global.Redux || {}))); +}(this, (function (exports) { 'use strict'; + +/** Detect free variable `global` from Node.js. */ +var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; + +/** Detect free variable `self`. */ +var freeSelf = typeof self == 'object' && self && self.Object === Object && self; + +/** Used as a reference to the global object. */ +var root = freeGlobal || freeSelf || Function('return this')(); + +/** Built-in value references. */ +var Symbol = root.Symbol; + +/** Used for built-in method references. */ +var objectProto$1 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$1 = objectProto$1.hasOwnProperty; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString = objectProto$1.toString; + +/** Built-in value references. */ +var symToStringTag$1 = Symbol ? Symbol.toStringTag : undefined; + +/** + * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the raw `toStringTag`. + */ +function getRawTag(value) { + var isOwn = hasOwnProperty$1.call(value, symToStringTag$1), + tag = value[symToStringTag$1]; + + try { + value[symToStringTag$1] = undefined; + var unmasked = true; + } catch (e) {} + + var result = nativeObjectToString.call(value); + if (unmasked) { + if (isOwn) { + value[symToStringTag$1] = tag; + } else { + delete value[symToStringTag$1]; + } + } + return result; +} + +/** Used for built-in method references. */ +var objectProto$2 = Object.prototype; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString$1 = objectProto$2.toString; + +/** + * Converts `value` to a string using `Object.prototype.toString`. + * + * @private + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + */ +function objectToString(value) { + return nativeObjectToString$1.call(value); +} + +/** `Object#toString` result references. */ +var nullTag = '[object Null]'; +var undefinedTag = '[object Undefined]'; + +/** Built-in value references. */ +var symToStringTag = Symbol ? Symbol.toStringTag : undefined; + +/** + * The base implementation of `getTag` without fallbacks for buggy environments. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ +function baseGetTag(value) { + if (value == null) { + return value === undefined ? undefinedTag : nullTag; + } + return (symToStringTag && symToStringTag in Object(value)) + ? getRawTag(value) + : objectToString(value); +} + +/** + * Creates a unary function that invokes `func` with its argument transformed. + * + * @private + * @param {Function} func The function to wrap. + * @param {Function} transform The argument transform. + * @returns {Function} Returns the new function. + */ +function overArg(func, transform) { + return function(arg) { + return func(transform(arg)); + }; +} + +/** Built-in value references. */ +var getPrototype = overArg(Object.getPrototypeOf, Object); + +/** + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + * @example + * + * _.isObjectLike({}); + * // => true + * + * _.isObjectLike([1, 2, 3]); + * // => true + * + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false + */ +function isObjectLike(value) { + return value != null && typeof value == 'object'; +} + +/** `Object#toString` result references. */ +var objectTag = '[object Object]'; + +/** Used for built-in method references. */ +var funcProto = Function.prototype; +var objectProto = Object.prototype; + +/** Used to resolve the decompiled source of functions. */ +var funcToString = funcProto.toString; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** Used to infer the `Object` constructor. */ +var objectCtorString = funcToString.call(Object); + +/** + * Checks if `value` is a plain object, that is, an object created by the + * `Object` constructor or one with a `[[Prototype]]` of `null`. + * + * @static + * @memberOf _ + * @since 0.8.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. + * @example + * + * function Foo() { + * this.a = 1; + * } + * + * _.isPlainObject(new Foo); + * // => false + * + * _.isPlainObject([1, 2, 3]); + * // => false + * + * _.isPlainObject({ 'x': 0, 'y': 0 }); + * // => true + * + * _.isPlainObject(Object.create(null)); + * // => true + */ +function isPlainObject(value) { + if (!isObjectLike(value) || baseGetTag(value) != objectTag) { + return false; + } + var proto = getPrototype(value); + if (proto === null) { + return true; + } + var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; + return typeof Ctor == 'function' && Ctor instanceof Ctor && + funcToString.call(Ctor) == objectCtorString; +} + +function symbolObservablePonyfill(root) { + var result; + var Symbol = root.Symbol; + + if (typeof Symbol === 'function') { + if (Symbol.observable) { + result = Symbol.observable; + } else { + result = Symbol('observable'); + Symbol.observable = result; + } + } else { + result = '@@observable'; + } + + return result; +} + +/* global window */ +var root$2; + +if (typeof self !== 'undefined') { + root$2 = self; +} else if (typeof window !== 'undefined') { + root$2 = window; +} else if (typeof global !== 'undefined') { + root$2 = global; +} else if (typeof module !== 'undefined') { + root$2 = module; +} else { + root$2 = Function('return this')(); +} + +var result = symbolObservablePonyfill(root$2); + +/** + * These are private action types reserved by Redux. + * For any unknown actions, you must return the current state. + * If the current state is undefined, you must return the initial state. + * Do not reference these action types directly in your code. + */ +var ActionTypes = { + INIT: '@@redux/INIT' + + /** + * Creates a Redux store that holds the state tree. + * The only way to change the data in the store is to call `dispatch()` on it. + * + * There should only be a single store in your app. To specify how different + * parts of the state tree respond to actions, you may combine several reducers + * into a single reducer function by using `combineReducers`. + * + * @param {Function} reducer A function that returns the next state tree, given + * the current state tree and the action to handle. + * + * @param {any} [preloadedState] The initial state. You may optionally specify it + * to hydrate the state from the server in universal apps, or to restore a + * previously serialized user session. + * If you use `combineReducers` to produce the root reducer function, this must be + * an object with the same shape as `combineReducers` keys. + * + * @param {Function} [enhancer] The store enhancer. You may optionally specify it + * to enhance the store with third-party capabilities such as middleware, + * time travel, persistence, etc. The only store enhancer that ships with Redux + * is `applyMiddleware()`. + * + * @returns {Store} A Redux store that lets you read the state, dispatch actions + * and subscribe to changes. + */ +};function createStore(reducer, preloadedState, enhancer) { + var _ref2; + + if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') { + enhancer = preloadedState; + preloadedState = undefined; + } + + if (typeof enhancer !== 'undefined') { + if (typeof enhancer !== 'function') { + throw new Error('Expected the enhancer to be a function.'); + } + + return enhancer(createStore)(reducer, preloadedState); + } + + if (typeof reducer !== 'function') { + throw new Error('Expected the reducer to be a function.'); + } + + var currentReducer = reducer; + var currentState = preloadedState; + var currentListeners = []; + var nextListeners = currentListeners; + var isDispatching = false; + + function ensureCanMutateNextListeners() { + if (nextListeners === currentListeners) { + nextListeners = currentListeners.slice(); + } + } + + /** + * Reads the state tree managed by the store. + * + * @returns {any} The current state tree of your application. + */ + function getState() { + return currentState; + } + + /** + * Adds a change listener. It will be called any time an action is dispatched, + * and some part of the state tree may potentially have changed. You may then + * call `getState()` to read the current state tree inside the callback. + * + * You may call `dispatch()` from a change listener, with the following + * caveats: + * + * 1. The subscriptions are snapshotted just before every `dispatch()` call. + * If you subscribe or unsubscribe while the listeners are being invoked, this + * will not have any effect on the `dispatch()` that is currently in progress. + * However, the next `dispatch()` call, whether nested or not, will use a more + * recent snapshot of the subscription list. + * + * 2. The listener should not expect to see all state changes, as the state + * might have been updated multiple times during a nested `dispatch()` before + * the listener is called. It is, however, guaranteed that all subscribers + * registered before the `dispatch()` started will be called with the latest + * state by the time it exits. + * + * @param {Function} listener A callback to be invoked on every dispatch. + * @returns {Function} A function to remove this change listener. + */ + function subscribe(listener) { + if (typeof listener !== 'function') { + throw new Error('Expected listener to be a function.'); + } + + var isSubscribed = true; + + ensureCanMutateNextListeners(); + nextListeners.push(listener); + + return function unsubscribe() { + if (!isSubscribed) { + return; + } + + isSubscribed = false; + + ensureCanMutateNextListeners(); + var index = nextListeners.indexOf(listener); + nextListeners.splice(index, 1); + }; + } + + /** + * Dispatches an action. It is the only way to trigger a state change. + * + * The `reducer` function, used to create the store, will be called with the + * current state tree and the given `action`. Its return value will + * be considered the **next** state of the tree, and the change listeners + * will be notified. + * + * The base implementation only supports plain object actions. If you want to + * dispatch a Promise, an Observable, a thunk, or something else, you need to + * wrap your store creating function into the corresponding middleware. For + * example, see the documentation for the `redux-thunk` package. Even the + * middleware will eventually dispatch plain object actions using this method. + * + * @param {Object} action A plain object representing “what changed”. It is + * a good idea to keep actions serializable so you can record and replay user + * sessions, or use the time travelling `redux-devtools`. An action must have + * a `type` property which may not be `undefined`. It is a good idea to use + * string constants for action types. + * + * @returns {Object} For convenience, the same action object you dispatched. + * + * Note that, if you use a custom middleware, it may wrap `dispatch()` to + * return something else (for example, a Promise you can await). + */ + function dispatch(action) { + if (!isPlainObject(action)) { + throw new Error('Actions must be plain objects. ' + 'Use custom middleware for async actions.'); + } + + if (typeof action.type === 'undefined') { + throw new Error('Actions may not have an undefined "type" property. ' + 'Have you misspelled a constant?'); + } + + if (isDispatching) { + throw new Error('Reducers may not dispatch actions.'); + } + + try { + isDispatching = true; + currentState = currentReducer(currentState, action); + } finally { + isDispatching = false; + } + + var listeners = currentListeners = nextListeners; + for (var i = 0; i < listeners.length; i++) { + var listener = listeners[i]; + listener(); + } + + return action; + } + + /** + * Replaces the reducer currently used by the store to calculate the state. + * + * You might need this if your app implements code splitting and you want to + * load some of the reducers dynamically. You might also need this if you + * implement a hot reloading mechanism for Redux. + * + * @param {Function} nextReducer The reducer for the store to use instead. + * @returns {void} + */ + function replaceReducer(nextReducer) { + if (typeof nextReducer !== 'function') { + throw new Error('Expected the nextReducer to be a function.'); + } + + currentReducer = nextReducer; + dispatch({ type: ActionTypes.INIT }); + } + + /** + * Interoperability point for observable/reactive libraries. + * @returns {observable} A minimal observable of state changes. + * For more information, see the observable proposal: + * https://github.com/tc39/proposal-observable + */ + function observable() { + var _ref; + + var outerSubscribe = subscribe; + return _ref = { + /** + * The minimal observable subscription method. + * @param {Object} observer Any object that can be used as an observer. + * The observer object should have a `next` method. + * @returns {subscription} An object with an `unsubscribe` method that can + * be used to unsubscribe the observable from the store, and prevent further + * emission of values from the observable. + */ + subscribe: function subscribe(observer) { + if (typeof observer !== 'object') { + throw new TypeError('Expected the observer to be an object.'); + } + + function observeState() { + if (observer.next) { + observer.next(getState()); + } + } + + observeState(); + var unsubscribe = outerSubscribe(observeState); + return { unsubscribe: unsubscribe }; + } + }, _ref[result] = function () { + return this; + }, _ref; + } + + // When a store is created, an "INIT" action is dispatched so that every + // reducer returns their initial state. This effectively populates + // the initial state tree. + dispatch({ type: ActionTypes.INIT }); + + return _ref2 = { + dispatch: dispatch, + subscribe: subscribe, + getState: getState, + replaceReducer: replaceReducer + }, _ref2[result] = observable, _ref2; +} + +/** + * Prints a warning in the console if it exists. + * + * @param {String} message The warning message. + * @returns {void} + */ +function warning(message) { + /* eslint-disable no-console */ + if (typeof console !== 'undefined' && typeof console.error === 'function') { + console.error(message); + } + /* eslint-enable no-console */ + try { + // This error was thrown as a convenience so that if you enable + // "break on all exceptions" in your console, + // it would pause the execution at this line. + throw new Error(message); + /* eslint-disable no-empty */ + } catch (e) {} + /* eslint-enable no-empty */ +} + +function getUndefinedStateErrorMessage(key, action) { + var actionType = action && action.type; + var actionName = actionType && '"' + actionType.toString() + '"' || 'an action'; + + return 'Given action ' + actionName + ', reducer "' + key + '" returned undefined. ' + 'To ignore an action, you must explicitly return the previous state. ' + 'If you want this reducer to hold no value, you can return null instead of undefined.'; +} + +function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) { + var reducerKeys = Object.keys(reducers); + var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer'; + + if (reducerKeys.length === 0) { + return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.'; + } + + if (!isPlainObject(inputState)) { + return 'The ' + argumentName + ' has unexpected type of "' + {}.toString.call(inputState).match(/\s([a-z|A-Z]+)/)[1] + '". Expected argument to be an object with the following ' + ('keys: "' + reducerKeys.join('", "') + '"'); + } + + var unexpectedKeys = Object.keys(inputState).filter(function (key) { + return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]; + }); + + unexpectedKeys.forEach(function (key) { + unexpectedKeyCache[key] = true; + }); + + if (unexpectedKeys.length > 0) { + return 'Unexpected ' + (unexpectedKeys.length > 1 ? 'keys' : 'key') + ' ' + ('"' + unexpectedKeys.join('", "') + '" found in ' + argumentName + '. ') + 'Expected to find one of the known reducer keys instead: ' + ('"' + reducerKeys.join('", "') + '". Unexpected keys will be ignored.'); + } +} + +function assertReducerShape(reducers) { + Object.keys(reducers).forEach(function (key) { + var reducer = reducers[key]; + var initialState = reducer(undefined, { type: ActionTypes.INIT }); + + if (typeof initialState === 'undefined') { + throw new Error('Reducer "' + key + '" returned undefined during initialization. ' + 'If the state passed to the reducer is undefined, you must ' + 'explicitly return the initial state. The initial state may ' + 'not be undefined. If you don\'t want to set a value for this reducer, ' + 'you can use null instead of undefined.'); + } + + var type = '@@redux/PROBE_UNKNOWN_ACTION_' + Math.random().toString(36).substring(7).split('').join('.'); + if (typeof reducer(undefined, { type: type }) === 'undefined') { + throw new Error('Reducer "' + key + '" returned undefined when probed with a random type. ' + ('Don\'t try to handle ' + ActionTypes.INIT + ' or other actions in "redux/*" ') + 'namespace. They are considered private. Instead, you must return the ' + 'current state for any unknown actions, unless it is undefined, ' + 'in which case you must return the initial state, regardless of the ' + 'action type. The initial state may not be undefined, but can be null.'); + } + }); +} + +/** + * Turns an object whose values are different reducer functions, into a single + * reducer function. It will call every child reducer, and gather their results + * into a single state object, whose keys correspond to the keys of the passed + * reducer functions. + * + * @param {Object} reducers An object whose values correspond to different + * reducer functions that need to be combined into one. One handy way to obtain + * it is to use ES6 `import * as reducers` syntax. The reducers may never return + * undefined for any action. Instead, they should return their initial state + * if the state passed to them was undefined, and the current state for any + * unrecognized action. + * + * @returns {Function} A reducer function that invokes every reducer inside the + * passed object, and builds a state object with the same shape. + */ +function combineReducers(reducers) { + var reducerKeys = Object.keys(reducers); + var finalReducers = {}; + for (var i = 0; i < reducerKeys.length; i++) { + var key = reducerKeys[i]; + + { + if (typeof reducers[key] === 'undefined') { + warning('No reducer provided for key "' + key + '"'); + } + } + + if (typeof reducers[key] === 'function') { + finalReducers[key] = reducers[key]; + } + } + var finalReducerKeys = Object.keys(finalReducers); + + var unexpectedKeyCache = void 0; + { + unexpectedKeyCache = {}; + } + + var shapeAssertionError = void 0; + try { + assertReducerShape(finalReducers); + } catch (e) { + shapeAssertionError = e; + } + + return function combination() { + var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + var action = arguments[1]; + + if (shapeAssertionError) { + throw shapeAssertionError; + } + + { + var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache); + if (warningMessage) { + warning(warningMessage); + } + } + + var hasChanged = false; + var nextState = {}; + for (var _i = 0; _i < finalReducerKeys.length; _i++) { + var _key = finalReducerKeys[_i]; + var reducer = finalReducers[_key]; + var previousStateForKey = state[_key]; + var nextStateForKey = reducer(previousStateForKey, action); + if (typeof nextStateForKey === 'undefined') { + var errorMessage = getUndefinedStateErrorMessage(_key, action); + throw new Error(errorMessage); + } + nextState[_key] = nextStateForKey; + hasChanged = hasChanged || nextStateForKey !== previousStateForKey; + } + return hasChanged ? nextState : state; + }; +} + +function bindActionCreator(actionCreator, dispatch) { + return function () { + return dispatch(actionCreator.apply(undefined, arguments)); + }; +} + +/** + * Turns an object whose values are action creators, into an object with the + * same keys, but with every function wrapped into a `dispatch` call so they + * may be invoked directly. This is just a convenience method, as you can call + * `store.dispatch(MyActionCreators.doSomething())` yourself just fine. + * + * For convenience, you can also pass a single function as the first argument, + * and get a function in return. + * + * @param {Function|Object} actionCreators An object whose values are action + * creator functions. One handy way to obtain it is to use ES6 `import * as` + * syntax. You may also pass a single function. + * + * @param {Function} dispatch The `dispatch` function available on your Redux + * store. + * + * @returns {Function|Object} The object mimicking the original object, but with + * every action creator wrapped into the `dispatch` call. If you passed a + * function as `actionCreators`, the return value will also be a single + * function. + */ +function bindActionCreators(actionCreators, dispatch) { + if (typeof actionCreators === 'function') { + return bindActionCreator(actionCreators, dispatch); + } + + if (typeof actionCreators !== 'object' || actionCreators === null) { + throw new Error('bindActionCreators expected an object or a function, instead received ' + (actionCreators === null ? 'null' : typeof actionCreators) + '. ' + 'Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?'); + } + + var keys = Object.keys(actionCreators); + var boundActionCreators = {}; + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var actionCreator = actionCreators[key]; + if (typeof actionCreator === 'function') { + boundActionCreators[key] = bindActionCreator(actionCreator, dispatch); + } + } + return boundActionCreators; +} + +/** + * Composes single-argument functions from right to left. The rightmost + * function can take multiple arguments as it provides the signature for + * the resulting composite function. + * + * @param {...Function} funcs The functions to compose. + * @returns {Function} A function obtained by composing the argument functions + * from right to left. For example, compose(f, g, h) is identical to doing + * (...args) => f(g(h(...args))). + */ + +function compose() { + for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) { + funcs[_key] = arguments[_key]; + } + + if (funcs.length === 0) { + return function (arg) { + return arg; + }; + } + + if (funcs.length === 1) { + return funcs[0]; + } + + return funcs.reduce(function (a, b) { + return function () { + return a(b.apply(undefined, arguments)); + }; + }); +} + +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; }; + +/** + * Creates a store enhancer that applies middleware to the dispatch method + * of the Redux store. This is handy for a variety of tasks, such as expressing + * asynchronous actions in a concise manner, or logging every action payload. + * + * See `redux-thunk` package as an example of the Redux middleware. + * + * Because middleware is potentially asynchronous, this should be the first + * store enhancer in the composition chain. + * + * Note that each middleware will be given the `dispatch` and `getState` functions + * as named arguments. + * + * @param {...Function} middlewares The middleware chain to be applied. + * @returns {Function} A store enhancer applying the middleware. + */ +function applyMiddleware() { + for (var _len = arguments.length, middlewares = Array(_len), _key = 0; _key < _len; _key++) { + middlewares[_key] = arguments[_key]; + } + + return function (createStore) { + return function (reducer, preloadedState, enhancer) { + var store = createStore(reducer, preloadedState, enhancer); + var _dispatch = store.dispatch; + var chain = []; + + var middlewareAPI = { + getState: store.getState, + dispatch: function dispatch(action) { + return _dispatch(action); + } + }; + chain = middlewares.map(function (middleware) { + return middleware(middlewareAPI); + }); + _dispatch = compose.apply(undefined, chain)(store.dispatch); + + return _extends({}, store, { + dispatch: _dispatch + }); + }; + }; +} + +/* +* This is a dummy function to check if the function name has been altered by minification. +* If the function has been minified and NODE_ENV !== 'production', warn the user. +*/ +function isCrushed() {} + +if ("development" !== 'production' && typeof isCrushed.name === 'string' && isCrushed.name !== 'isCrushed') { + warning('You are currently using minified code outside of NODE_ENV === \'production\'. ' + 'This means that you are running a slower development build of Redux. ' + 'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + 'or DefinePlugin for webpack (http://stackoverflow.com/questions/30030031) ' + 'to ensure you have the correct code for your production build.'); +} + +exports.createStore = createStore; +exports.combineReducers = combineReducers; +exports.bindActionCreators = bindActionCreators; +exports.applyMiddleware = applyMiddleware; +exports.compose = compose; + +Object.defineProperty(exports, '__esModule', { value: true }); + +}))); diff --git a/libs/wechat-weapp-redux.min.js b/libs/wechat-weapp-redux.min.js new file mode 100644 index 0000000..16bd46e --- /dev/null +++ b/libs/wechat-weapp-redux.min.js @@ -0,0 +1 @@ +!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.WeAppRedux=n():t.WeAppRedux=n()}(this,function(){return function(t){function n(o){if(e[o])return e[o].exports;var r=e[o]={exports:{},id:o,loaded:!1};return t[o].call(r.exports,r,r.exports,n),r.loaded=!0,r.exports}var e={};return n.m=t,n.c=e,n.p="",n(0)}([function(t,n,e){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}var r=e(3),i=o(r),u=e(4),f=o(u);t.exports={Provider:i.default,connect:f.default}},function(t,n){"use strict";var e=function(t){if(void 0===t||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var n=Object(t),e=1;arguments.length>e;e++){var o=arguments[e];if(void 0!==o&&null!==o)for(var r in o)o.hasOwnProperty(r)&&(n[r]=o[r])}return n};t.exports={assign:e}},function(t,n){"use strict";function e(t){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(t);try{throw Error(t)}catch(t){}}t.exports=e},function(t,n,e){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function r(t){var n=["subscribe","dispatch","getState"].filter(function(n){return!t.hasOwnProperty(n)});n.length>0&&(0,f.default)("Store似乎不是一个合法的Redux Store对象: 缺少这些方法: "+n.join(", ")+"。")}function i(t){return r(t),function(n){return(0,s.assign)({},n,{store:t})}}var u=e(2),f=o(u),s=e(1);t.exports=i},function(t,n,e){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function r(t,n){var e=!!t,o=t||d,r=getApp(),i=void 0;return i="function"==typeof n?n:n?(0,a.default)(n):p,function(t){function n(t){if(this.unsubscribe){var n=this.store.getState(),e=o(n,t);this.data&&!(0,u.default)(this.data,e)&&this.setData(e)}}function f(t){this.store=r.store,this.store||(0,s.default)("Store对象不存在!"),e&&(this.unsubscribe=this.store.subscribe(n.bind(this,t)),n.call(this,t)),"function"==typeof a&&a.call(this,t)}function c(){"function"==typeof d&&d.call(this),"function"==typeof this.unsubscribe&&this.unsubscribe()}var a=t.onLoad,d=t.onUnload;return(0,l.assign)({},t,i(r.store.dispatch),{onLoad:f,onUnload:c})}}var i=e(5),u=o(i),f=e(2),s=o(f),c=e(6),a=o(c),l=e(1),d=function(t){return{}},p=function(t){return{dispatch:t}};t.exports=r},function(t,n){"use strict";function e(t,n){if(t===n)return!0;var e=Object.keys(t),o=Object.keys(n);if(e.length!==o.length)return!1;for(var r=Object.prototype.hasOwnProperty,i=0;e.length>i;i++)if(!r.call(n,e[i])||t[e[i]]!==n[e[i]])return!1;return!0}t.exports=e},function(t,n){"use strict";function e(t,n){return function(){return n(t.apply(void 0,arguments))}}function o(t,n){if("function"==typeof t)return e(t,n);if("object"!==(void 0===t?"undefined":i(t))||null===t)throw Error("bindActionCreators expected an object or a function, instead received "+(null===t?"null":void 0===t?"undefined":i(t))+'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');for(var o=Object.keys(t),r={},u=0;o.length>u;u++){var f=o[u],s=t[f];"function"==typeof s&&(r[f]=e(s,n))}return r}function r(t){return function(n){return o(t,n)}}var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports=r}])}); \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/button/index.js b/miniprogram_npm/@vant/weapp/button/index.js new file mode 100644 index 0000000..d38d35d --- /dev/null +++ b/miniprogram_npm/@vant/weapp/button/index.js @@ -0,0 +1,81 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +var button_1 = require('../mixins/button'); +var open_type_1 = require('../mixins/open-type'); +var version_1 = require('../common/version'); +var mixins = [button_1.button, open_type_1.openType]; +if (version_1.canIUseFormFieldButton()) { + mixins.push('wx://form-field-button'); +} +component_1.VantComponent({ + mixins: mixins, + classes: ['hover-class', 'loading-class'], + data: { + baseStyle: '', + }, + props: { + formType: String, + icon: String, + classPrefix: { + type: String, + value: 'van-icon', + }, + plain: Boolean, + block: Boolean, + round: Boolean, + square: Boolean, + loading: Boolean, + hairline: Boolean, + disabled: Boolean, + loadingText: String, + customStyle: String, + loadingType: { + type: String, + value: 'circular', + }, + type: { + type: String, + value: 'default', + }, + dataset: null, + size: { + type: String, + value: 'normal', + }, + loadingSize: { + type: String, + value: '20px', + }, + color: { + type: String, + observer: function (color) { + var style = ''; + if (color) { + style += 'color: ' + (this.data.plain ? color : 'white') + ';'; + if (!this.data.plain) { + // Use background instead of backgroundColor to make linear-gradient work + style += 'background: ' + color + ';'; + } + // hide border when color is linear-gradient + if (color.indexOf('gradient') !== -1) { + style += 'border: 0;'; + } else { + style += 'border-color: ' + color + ';'; + } + } + if (style !== this.data.baseStyle) { + this.setData({ baseStyle: style }); + } + }, + }, + }, + methods: { + onClick: function () { + if (!this.data.loading) { + this.$emit('click'); + } + }, + noop: function () {}, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/button/index.json b/miniprogram_npm/@vant/weapp/button/index.json new file mode 100644 index 0000000..e00a588 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/button/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index", + "van-loading": "../loading/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/button/index.wxml b/miniprogram_npm/@vant/weapp/button/index.wxml new file mode 100644 index 0000000..ab393e8 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/button/index.wxml @@ -0,0 +1,68 @@ + + + + + + +function get(type, color,plain) { + if(plain) { + return color ? color: '#c9c9c9'; + } + + if(type === 'default') { + return '#c9c9c9'; + } + return 'white'; +} + +module.exports = get; + diff --git a/miniprogram_npm/@vant/weapp/button/index.wxss b/miniprogram_npm/@vant/weapp/button/index.wxss new file mode 100644 index 0000000..5a591fb --- /dev/null +++ b/miniprogram_npm/@vant/weapp/button/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/card/index.js b/miniprogram_npm/@vant/weapp/card/index.js new file mode 100644 index 0000000..cb0f982 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/card/index.js @@ -0,0 +1,51 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var link_1 = require('../mixins/link'); +var component_1 = require('../common/component'); +component_1.VantComponent({ + classes: [ + 'num-class', + 'desc-class', + 'thumb-class', + 'title-class', + 'price-class', + 'origin-price-class', + ], + mixins: [link_1.link], + props: { + tag: String, + num: String, + desc: String, + thumb: String, + title: String, + price: { + type: String, + observer: 'updatePrice', + }, + centered: Boolean, + lazyLoad: Boolean, + thumbLink: String, + originPrice: String, + thumbMode: { + type: String, + value: 'aspectFit', + }, + currency: { + type: String, + value: '¥', + }, + }, + methods: { + updatePrice: function () { + var price = this.data.price; + var priceArr = price.toString().split('.'); + this.setData({ + integerStr: priceArr[0], + decimalStr: priceArr[1] ? '.' + priceArr[1] : '', + }); + }, + onClickThumb: function () { + this.jumpLink('thumbLink'); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/card/index.json b/miniprogram_npm/@vant/weapp/card/index.json new file mode 100644 index 0000000..e917407 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/card/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-tag": "../tag/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/card/index.wxml b/miniprogram_npm/@vant/weapp/card/index.wxml new file mode 100644 index 0000000..62173e4 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/card/index.wxml @@ -0,0 +1,56 @@ + + + + + + + + + {{ tag }} + + + + + + + {{ title }} + + + {{ desc }} + + + + + + + + + {{ currency }} + {{ integerStr }} + {{ decimalStr }} + + + {{ currency }} {{ originPrice }} + + x {{ num }} + + + + + + + + + + diff --git a/miniprogram_npm/@vant/weapp/card/index.wxss b/miniprogram_npm/@vant/weapp/card/index.wxss new file mode 100644 index 0000000..a21a599 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/card/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-card{position:relative;box-sizing:border-box;padding:8px 16px;padding:var(--card-padding,8px 16px);font-size:12px;font-size:var(--card-font-size,12px);color:#323233;color:var(--card-text-color,#323233);background-color:#fafafa;background-color:var(--card-background-color,#fafafa)}.van-card__header{display:-webkit-flex;display:flex}.van-card__header--center{-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.van-card__thumb{position:relative;-webkit-flex:none;flex:none;width:88px;width:var(--card-thumb-size,88px);height:88px;height:var(--card-thumb-size,88px);margin-right:8px;margin-right:var(--padding-xs,8px)}.van-card__thumb:empty{display:none}.van-card__img{width:100%;height:100%;border-radius:8px;border-radius:var(--border-radius-lg,8px)}.van-card__content{position:relative;display:-webkit-flex;display:flex;-webkit-flex:1;flex:1;-webkit-flex-direction:column;flex-direction:column;-webkit-justify-content:space-between;justify-content:space-between;min-width:0;min-height:88px;min-height:var(--card-thumb-size,88px)}.van-card__content--center{-webkit-justify-content:center;justify-content:center}.van-card__desc,.van-card__title{word-wrap:break-word}.van-card__title{font-weight:700;line-height:16px;line-height:var(--card-title-line-height,16px)}.van-card__desc{line-height:20px;line-height:var(--card-desc-line-height,20px);color:#646566;color:var(--card-desc-color,#646566)}.van-card__bottom{line-height:20px}.van-card__price{display:inline-block;font-weight:700;color:#ee0a24;color:var(--card-price-color,#ee0a24);font-size:12px;font-size:var(--card-price-font-size,12px)}.van-card__price-integer{font-size:16px;font-size:var(--card-price-integer-font-size,16px)}.van-card__price-decimal,.van-card__price-integer{font-family:Avenir-Heavy,PingFang SC,Helvetica Neue,Arial,sans-serif;font-family:var(--card-price-font-family,Avenir-Heavy,PingFang SC,Helvetica Neue,Arial,sans-serif)}.van-card__origin-price{display:inline-block;margin-left:5px;text-decoration:line-through;font-size:10px;font-size:var(--card-origin-price-font-size,10px);color:#646566;color:var(--card-origin-price-color,#646566)}.van-card__num{float:right}.van-card__tag{position:absolute!important;top:2px;left:0}.van-card__footer{-webkit-flex:none;flex:none;width:100%;text-align:right} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/cell-group/index.js b/miniprogram_npm/@vant/weapp/cell-group/index.js new file mode 100644 index 0000000..7d93487 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/cell-group/index.js @@ -0,0 +1,12 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +component_1.VantComponent({ + props: { + title: String, + border: { + type: Boolean, + value: true, + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/cell-group/index.json b/miniprogram_npm/@vant/weapp/cell-group/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/cell-group/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram_npm/@vant/weapp/cell-group/index.wxml b/miniprogram_npm/@vant/weapp/cell-group/index.wxml new file mode 100644 index 0000000..6e0b471 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/cell-group/index.wxml @@ -0,0 +1,9 @@ + + {{ title }} + + + + diff --git a/miniprogram_npm/@vant/weapp/cell-group/index.wxss b/miniprogram_npm/@vant/weapp/cell-group/index.wxss new file mode 100644 index 0000000..edbccd5 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/cell-group/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-cell-group__title{padding:16px 16px 8px;padding:var(--cell-group-title-padding,16px 16px 8px);font-size:14px;font-size:var(--cell-group-title-font-size,14px);line-height:16px;line-height:var(--cell-group-title-line-height,16px);color:#969799;color:var(--cell-group-title-color,#969799)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/cell/index.js b/miniprogram_npm/@vant/weapp/cell/index.js new file mode 100644 index 0000000..7a18c9f --- /dev/null +++ b/miniprogram_npm/@vant/weapp/cell/index.js @@ -0,0 +1,40 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var link_1 = require('../mixins/link'); +var component_1 = require('../common/component'); +component_1.VantComponent({ + classes: [ + 'title-class', + 'label-class', + 'value-class', + 'right-icon-class', + 'hover-class', + ], + mixins: [link_1.link], + props: { + title: null, + value: null, + icon: String, + size: String, + label: String, + center: Boolean, + isLink: Boolean, + required: Boolean, + clickable: Boolean, + titleWidth: String, + customStyle: String, + arrowDirection: String, + useLabelSlot: Boolean, + border: { + type: Boolean, + value: true, + }, + titleStyle: String, + }, + methods: { + onClick: function (event) { + this.$emit('click', event.detail); + this.jumpLink(); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/cell/index.json b/miniprogram_npm/@vant/weapp/cell/index.json new file mode 100644 index 0000000..0a336c0 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/cell/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/cell/index.wxml b/miniprogram_npm/@vant/weapp/cell/index.wxml new file mode 100644 index 0000000..fed768e --- /dev/null +++ b/miniprogram_npm/@vant/weapp/cell/index.wxml @@ -0,0 +1,45 @@ + + + + + + + + {{ title }} + + + + + {{ label }} + + + + + {{ value }} + + + + + + + + diff --git a/miniprogram_npm/@vant/weapp/cell/index.wxss b/miniprogram_npm/@vant/weapp/cell/index.wxss new file mode 100644 index 0000000..605570d --- /dev/null +++ b/miniprogram_npm/@vant/weapp/cell/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-cell{position:relative;display:-webkit-flex;display:flex;box-sizing:border-box;width:100%;padding:10px 16px;padding:var(--cell-vertical-padding,10px) var(--cell-horizontal-padding,16px);font-size:14px;font-size:var(--cell-font-size,14px);line-height:24px;line-height:var(--cell-line-height,24px);color:#323233;color:var(--cell-text-color,#323233);background-color:#fff;background-color:var(--cell-background-color,#fff)}.van-cell:after{position:absolute;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;content:" ";pointer-events:none;right:16px;bottom:0;left:16px;border-bottom:1px solid #ebedf0;-webkit-transform:scaleY(.5);transform:scaleY(.5)}.van-cell--borderless:after{display:none}.van-cell-group{background-color:#fff;background-color:var(--cell-background-color,#fff)}.van-cell__label{margin-top:3px;margin-top:var(--cell-label-margin-top,3px);font-size:12px;font-size:var(--cell-label-font-size,12px);line-height:18px;line-height:var(--cell-label-line-height,18px);color:#969799;color:var(--cell-label-color,#969799)}.van-cell__value{overflow:hidden;text-align:right;vertical-align:middle;color:#969799;color:var(--cell-value-color,#969799)}.van-cell__title,.van-cell__value{-webkit-flex:1;flex:1}.van-cell__title:empty,.van-cell__value:empty{display:none}.van-cell__left-icon-wrap,.van-cell__right-icon-wrap{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;height:24px;height:var(--cell-line-height,24px);font-size:16px;font-size:var(--cell-icon-size,16px)}.van-cell__left-icon-wrap{margin-right:4px;margin-right:var(--padding-base,4px)}.van-cell__right-icon-wrap{margin-left:4px;margin-left:var(--padding-base,4px);color:#969799;color:var(--cell-right-icon-color,#969799)}.van-cell__left-icon{vertical-align:middle}.van-cell__left-icon,.van-cell__right-icon{line-height:24px;line-height:var(--cell-line-height,24px)}.van-cell--clickable.van-cell--hover{background-color:#f2f3f5;background-color:var(--cell-active-color,#f2f3f5)}.van-cell--required{overflow:visible}.van-cell--required:before{position:absolute;content:"*";left:8px;left:var(--padding-xs,8px);font-size:14px;font-size:var(--cell-font-size,14px);color:#ee0a24;color:var(--cell-required-color,#ee0a24)}.van-cell--center{-webkit-align-items:center;align-items:center}.van-cell--large{padding-top:12px;padding-top:var(--cell-large-vertical-padding,12px);padding-bottom:12px;padding-bottom:var(--cell-large-vertical-padding,12px)}.van-cell--large .van-cell__title{font-size:16px;font-size:var(--cell-large-title-font-size,16px)}.van-cell--large .van-cell__value{font-size:16px;font-size:var(--cell-large-value-font-size,16px)}.van-cell--large .van-cell__label{font-size:14px;font-size:var(--cell-large-label-font-size,14px)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/circle/canvas.js b/miniprogram_npm/@vant/weapp/circle/canvas.js new file mode 100644 index 0000000..dbee1d7 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/circle/canvas.js @@ -0,0 +1,47 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +exports.adaptor = void 0; +function adaptor(ctx) { + // @ts-ignore + return Object.assign(ctx, { + setStrokeStyle: function (val) { + ctx.strokeStyle = val; + }, + setLineWidth: function (val) { + ctx.lineWidth = val; + }, + setLineCap: function (val) { + ctx.lineCap = val; + }, + setFillStyle: function (val) { + ctx.fillStyle = val; + }, + setFontSize: function (val) { + ctx.font = String(val); + }, + setGlobalAlpha: function (val) { + ctx.globalAlpha = val; + }, + setLineJoin: function (val) { + ctx.lineJoin = val; + }, + setTextAlign: function (val) { + ctx.textAlign = val; + }, + setMiterLimit: function (val) { + ctx.miterLimit = val; + }, + setShadow: function (offsetX, offsetY, blur, color) { + ctx.shadowOffsetX = offsetX; + ctx.shadowOffsetY = offsetY; + ctx.shadowBlur = blur; + ctx.shadowColor = color; + }, + setTextBaseline: function (val) { + ctx.textBaseline = val; + }, + createCircularGradient: function () {}, + draw: function () {}, + }); +} +exports.adaptor = adaptor; diff --git a/miniprogram_npm/@vant/weapp/circle/index.js b/miniprogram_npm/@vant/weapp/circle/index.js new file mode 100644 index 0000000..5c34f80 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/circle/index.js @@ -0,0 +1,209 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +var utils_1 = require('../common/utils'); +var color_1 = require('../common/color'); +var canvas_1 = require('./canvas'); +function format(rate) { + return Math.min(Math.max(rate, 0), 100); +} +var PERIMETER = 2 * Math.PI; +var BEGIN_ANGLE = -Math.PI / 2; +var STEP = 1; +component_1.VantComponent({ + props: { + text: String, + lineCap: { + type: String, + value: 'round', + }, + value: { + type: Number, + value: 0, + observer: 'reRender', + }, + speed: { + type: Number, + value: 50, + }, + size: { + type: Number, + value: 100, + observer: function () { + this.drawCircle(this.currentValue); + }, + }, + fill: String, + layerColor: { + type: String, + value: color_1.WHITE, + }, + color: { + type: [String, Object], + value: color_1.BLUE, + observer: function () { + var _this = this; + this.setHoverColor().then(function () { + _this.drawCircle(_this.currentValue); + }); + }, + }, + type: { + type: String, + value: '', + }, + strokeWidth: { + type: Number, + value: 4, + }, + clockwise: { + type: Boolean, + value: true, + }, + }, + data: { + hoverColor: color_1.BLUE, + }, + methods: { + getContext: function () { + var _this = this; + var _a = this.data, + type = _a.type, + size = _a.size; + if (type === '') { + var ctx = wx.createCanvasContext('van-circle', this); + return Promise.resolve(ctx); + } + var dpr = wx.getSystemInfoSync().pixelRatio; + return new Promise(function (resolve) { + wx.createSelectorQuery() + .in(_this) + .select('#van-circle') + .node() + .exec(function (res) { + var canvas = res[0].node; + var ctx = canvas.getContext(type); + if (!_this.inited) { + _this.inited = true; + canvas.width = size * dpr; + canvas.height = size * dpr; + ctx.scale(dpr, dpr); + } + resolve(canvas_1.adaptor(ctx)); + }); + }); + }, + setHoverColor: function () { + var _this = this; + var _a = this.data, + color = _a.color, + size = _a.size; + if (utils_1.isObj(color)) { + return this.getContext().then(function (context) { + var LinearColor = context.createLinearGradient(size, 0, 0, 0); + Object.keys(color) + .sort(function (a, b) { + return parseFloat(a) - parseFloat(b); + }) + .map(function (key) { + return LinearColor.addColorStop( + parseFloat(key) / 100, + color[key] + ); + }); + _this.hoverColor = LinearColor; + }); + } + this.hoverColor = color; + return Promise.resolve(); + }, + presetCanvas: function (context, strokeStyle, beginAngle, endAngle, fill) { + var _a = this.data, + strokeWidth = _a.strokeWidth, + lineCap = _a.lineCap, + clockwise = _a.clockwise, + size = _a.size; + var position = size / 2; + var radius = position - strokeWidth / 2; + context.setStrokeStyle(strokeStyle); + context.setLineWidth(strokeWidth); + context.setLineCap(lineCap); + context.beginPath(); + context.arc(position, position, radius, beginAngle, endAngle, !clockwise); + context.stroke(); + if (fill) { + context.setFillStyle(fill); + context.fill(); + } + }, + renderLayerCircle: function (context) { + var _a = this.data, + layerColor = _a.layerColor, + fill = _a.fill; + this.presetCanvas(context, layerColor, 0, PERIMETER, fill); + }, + renderHoverCircle: function (context, formatValue) { + var clockwise = this.data.clockwise; + // 结束角度 + var progress = PERIMETER * (formatValue / 100); + var endAngle = clockwise + ? BEGIN_ANGLE + progress + : 3 * Math.PI - (BEGIN_ANGLE + progress); + this.presetCanvas(context, this.hoverColor, BEGIN_ANGLE, endAngle); + }, + drawCircle: function (currentValue) { + var _this = this; + var size = this.data.size; + this.getContext().then(function (context) { + context.clearRect(0, 0, size, size); + _this.renderLayerCircle(context); + var formatValue = format(currentValue); + if (formatValue !== 0) { + _this.renderHoverCircle(context, formatValue); + } + context.draw(); + }); + }, + reRender: function () { + var _this = this; + // tofector 动画暂时没有想到好的解决方案 + var _a = this.data, + value = _a.value, + speed = _a.speed; + if (speed <= 0 || speed > 1000) { + this.drawCircle(value); + return; + } + this.clearInterval(); + this.currentValue = this.currentValue || 0; + this.interval = setInterval(function () { + if (_this.currentValue !== value) { + if (_this.currentValue < value) { + _this.currentValue += STEP; + } else { + _this.currentValue -= STEP; + } + _this.drawCircle(_this.currentValue); + } else { + _this.clearInterval(); + } + }, 1000 / speed); + }, + clearInterval: function () { + if (this.interval) { + clearInterval(this.interval); + this.interval = null; + } + }, + }, + mounted: function () { + var _this = this; + this.currentValue = this.data.value; + this.setHoverColor().then(function () { + _this.drawCircle(_this.currentValue); + }); + }, + destroyed: function () { + this.clearInterval(); + }, +}); diff --git a/miniprogram_npm/@vant/weapp/circle/index.json b/miniprogram_npm/@vant/weapp/circle/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/circle/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram_npm/@vant/weapp/circle/index.wxml b/miniprogram_npm/@vant/weapp/circle/index.wxml new file mode 100644 index 0000000..52bc59f --- /dev/null +++ b/miniprogram_npm/@vant/weapp/circle/index.wxml @@ -0,0 +1,9 @@ + + + + + + + + {{ text }} + diff --git a/miniprogram_npm/@vant/weapp/circle/index.wxss b/miniprogram_npm/@vant/weapp/circle/index.wxss new file mode 100644 index 0000000..b5d5486 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/circle/index.wxss @@ -0,0 +1,16 @@ +@import '../common/index.wxss'; +.van-circle { + position: relative; + display: inline-block; + text-align: center; +} +.van-circle__text { + position: absolute; + top: 50%; + left: 0; + width: 100%; + -webkit-transform: translateY(-50%); + transform: translateY(-50%); + color: #323233; + color: var(--circle-text-color, #323233); +} diff --git a/miniprogram_npm/@vant/weapp/common/color.js b/miniprogram_npm/@vant/weapp/common/color.js new file mode 100644 index 0000000..885acaa --- /dev/null +++ b/miniprogram_npm/@vant/weapp/common/color.js @@ -0,0 +1,10 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +exports.GRAY_DARK = exports.GRAY = exports.ORANGE = exports.GREEN = exports.WHITE = exports.BLUE = exports.RED = void 0; +exports.RED = '#ee0a24'; +exports.BLUE = '#1989fa'; +exports.WHITE = '#fff'; +exports.GREEN = '#07c160'; +exports.ORANGE = '#ff976a'; +exports.GRAY = '#323233'; +exports.GRAY_DARK = '#969799'; diff --git a/miniprogram_npm/@vant/weapp/common/component.js b/miniprogram_npm/@vant/weapp/common/component.js new file mode 100644 index 0000000..1f219dc --- /dev/null +++ b/miniprogram_npm/@vant/weapp/common/component.js @@ -0,0 +1,123 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +exports.VantComponent = void 0; +var basic_1 = require('../mixins/basic'); +var relationFunctions = { + ancestor: { + linked: function (parent) { + // @ts-ignore + this.parent = parent; + }, + unlinked: function () { + // @ts-ignore + this.parent = null; + }, + }, + descendant: { + linked: function (child) { + // @ts-ignore + this.children = this.children || []; + // @ts-ignore + this.children.push(child); + }, + unlinked: function (child) { + // @ts-ignore + this.children = (this.children || []).filter(function (it) { + return it !== child; + }); + }, + }, +}; +function mapKeys(source, target, map) { + Object.keys(map).forEach(function (key) { + if (source[key]) { + target[map[key]] = source[key]; + } + }); +} +function makeRelation(options, vantOptions, relation) { + var _a; + var type = relation.type, + name = relation.name, + linked = relation.linked, + unlinked = relation.unlinked, + linkChanged = relation.linkChanged; + var beforeCreate = vantOptions.beforeCreate, + destroyed = vantOptions.destroyed; + if (type === 'descendant') { + options.created = function () { + beforeCreate && beforeCreate.bind(this)(); + this.children = this.children || []; + }; + options.detached = function () { + this.children = []; + destroyed && destroyed.bind(this)(); + }; + } + options.relations = Object.assign( + options.relations || {}, + ((_a = {}), + (_a['../' + name + '/index'] = { + type: type, + linked: function (node) { + relationFunctions[type].linked.bind(this)(node); + linked && linked.bind(this)(node); + }, + linkChanged: function (node) { + linkChanged && linkChanged.bind(this)(node); + }, + unlinked: function (node) { + relationFunctions[type].unlinked.bind(this)(node); + unlinked && unlinked.bind(this)(node); + }, + }), + _a) + ); +} +function VantComponent(vantOptions) { + if (vantOptions === void 0) { + vantOptions = {}; + } + var options = {}; + mapKeys(vantOptions, options, { + data: 'data', + props: 'properties', + mixins: 'behaviors', + methods: 'methods', + beforeCreate: 'created', + created: 'attached', + mounted: 'ready', + relations: 'relations', + destroyed: 'detached', + classes: 'externalClasses', + }); + var relation = vantOptions.relation; + if (relation) { + makeRelation(options, vantOptions, relation); + } + // add default externalClasses + options.externalClasses = options.externalClasses || []; + options.externalClasses.push('custom-class'); + // add default behaviors + options.behaviors = options.behaviors || []; + options.behaviors.push(basic_1.basic); + // map field to form-field behavior + if (vantOptions.field) { + options.behaviors.push('wx://form-field'); + } + if (options.properties) { + Object.keys(options.properties).forEach(function (name) { + if (Array.isArray(options.properties[name])) { + // miniprogram do not allow multi type + options.properties[name] = null; + } + }); + } + // add default options + options.options = { + multipleSlots: true, + addGlobalClass: true, + }; + Component(options); +} +exports.VantComponent = VantComponent; diff --git a/miniprogram_npm/@vant/weapp/common/index.wxss b/miniprogram_npm/@vant/weapp/common/index.wxss new file mode 100644 index 0000000..976825d --- /dev/null +++ b/miniprogram_npm/@vant/weapp/common/index.wxss @@ -0,0 +1 @@ +.van-ellipsis{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.van-multi-ellipsis--l2{-webkit-line-clamp:2}.van-multi-ellipsis--l2,.van-multi-ellipsis--l3{display:-webkit-box;overflow:hidden;text-overflow:ellipsis;-webkit-box-orient:vertical}.van-multi-ellipsis--l3{-webkit-line-clamp:3}.van-clearfix:after{display:table;clear:both;content:""}.van-hairline,.van-hairline--bottom,.van-hairline--left,.van-hairline--right,.van-hairline--surround,.van-hairline--top,.van-hairline--top-bottom{position:relative}.van-hairline--bottom:after,.van-hairline--left:after,.van-hairline--right:after,.van-hairline--surround:after,.van-hairline--top-bottom:after,.van-hairline--top:after,.van-hairline:after{position:absolute;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;content:" ";pointer-events:none;top:-50%;right:-50%;bottom:-50%;left:-50%;border:0 solid #ebedf0;-webkit-transform:scale(.5);transform:scale(.5)}.van-hairline--top:after{border-top-width:1px}.van-hairline--left:after{border-left-width:1px}.van-hairline--right:after{border-right-width:1px}.van-hairline--bottom:after{border-bottom-width:1px}.van-hairline--top-bottom:after{border-width:1px 0}.van-hairline--surround:after{border-width:1px} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/common/style/clearfix.wxss b/miniprogram_npm/@vant/weapp/common/style/clearfix.wxss new file mode 100644 index 0000000..a0ca838 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/common/style/clearfix.wxss @@ -0,0 +1 @@ +.van-clearfix:after{display:table;clear:both;content:""} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/common/style/ellipsis.wxss b/miniprogram_npm/@vant/weapp/common/style/ellipsis.wxss new file mode 100644 index 0000000..1e9dbc9 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/common/style/ellipsis.wxss @@ -0,0 +1 @@ +.van-ellipsis{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.van-multi-ellipsis--l2{-webkit-line-clamp:2}.van-multi-ellipsis--l2,.van-multi-ellipsis--l3{display:-webkit-box;overflow:hidden;text-overflow:ellipsis;-webkit-box-orient:vertical}.van-multi-ellipsis--l3{-webkit-line-clamp:3} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/common/style/hairline.wxss b/miniprogram_npm/@vant/weapp/common/style/hairline.wxss new file mode 100644 index 0000000..49b9e65 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/common/style/hairline.wxss @@ -0,0 +1 @@ +.van-hairline,.van-hairline--bottom,.van-hairline--left,.van-hairline--right,.van-hairline--surround,.van-hairline--top,.van-hairline--top-bottom{position:relative}.van-hairline--bottom:after,.van-hairline--left:after,.van-hairline--right:after,.van-hairline--surround:after,.van-hairline--top-bottom:after,.van-hairline--top:after,.van-hairline:after{position:absolute;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;content:" ";pointer-events:none;top:-50%;right:-50%;bottom:-50%;left:-50%;border:0 solid #ebedf0;-webkit-transform:scale(.5);transform:scale(.5)}.van-hairline--top:after{border-top-width:1px}.van-hairline--left:after{border-left-width:1px}.van-hairline--right:after{border-right-width:1px}.van-hairline--bottom:after{border-bottom-width:1px}.van-hairline--top-bottom:after{border-width:1px 0}.van-hairline--surround:after{border-width:1px} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/common/style/mixins/clearfix.wxss b/miniprogram_npm/@vant/weapp/common/style/mixins/clearfix.wxss new file mode 100644 index 0000000..e69de29 diff --git a/miniprogram_npm/@vant/weapp/common/style/mixins/ellipsis.wxss b/miniprogram_npm/@vant/weapp/common/style/mixins/ellipsis.wxss new file mode 100644 index 0000000..e69de29 diff --git a/miniprogram_npm/@vant/weapp/common/style/mixins/hairline.wxss b/miniprogram_npm/@vant/weapp/common/style/mixins/hairline.wxss new file mode 100644 index 0000000..e69de29 diff --git a/miniprogram_npm/@vant/weapp/common/style/theme.wxss b/miniprogram_npm/@vant/weapp/common/style/theme.wxss new file mode 100644 index 0000000..e69de29 diff --git a/miniprogram_npm/@vant/weapp/common/style/var.wxss b/miniprogram_npm/@vant/weapp/common/style/var.wxss new file mode 100644 index 0000000..e69de29 diff --git a/miniprogram_npm/@vant/weapp/common/utils.js b/miniprogram_npm/@vant/weapp/common/utils.js new file mode 100644 index 0000000..7b3a4c7 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/common/utils.js @@ -0,0 +1,97 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +exports.getAllRect = exports.getRect = exports.pickExclude = exports.requestAnimationFrame = exports.addUnit = exports.getSystemInfoSync = exports.nextTick = exports.range = exports.isObj = exports.isDef = void 0; +var validator_1 = require('./validator'); +function isDef(value) { + return value !== undefined && value !== null; +} +exports.isDef = isDef; +function isObj(x) { + var type = typeof x; + return x !== null && (type === 'object' || type === 'function'); +} +exports.isObj = isObj; +function range(num, min, max) { + return Math.min(Math.max(num, min), max); +} +exports.range = range; +function nextTick(fn) { + setTimeout(function () { + fn(); + }, 1000 / 30); +} +exports.nextTick = nextTick; +var systemInfo; +function getSystemInfoSync() { + if (systemInfo == null) { + systemInfo = wx.getSystemInfoSync(); + } + return systemInfo; +} +exports.getSystemInfoSync = getSystemInfoSync; +function addUnit(value) { + if (!isDef(value)) { + return undefined; + } + value = String(value); + return validator_1.isNumber(value) ? value + 'px' : value; +} +exports.addUnit = addUnit; +function requestAnimationFrame(cb) { + var systemInfo = getSystemInfoSync(); + if (systemInfo.platform === 'devtools') { + return nextTick(cb); + } + return wx + .createSelectorQuery() + .selectViewport() + .boundingClientRect() + .exec(function () { + cb(); + }); +} +exports.requestAnimationFrame = requestAnimationFrame; +function pickExclude(obj, keys) { + if (!validator_1.isPlainObject(obj)) { + return {}; + } + return Object.keys(obj).reduce(function (prev, key) { + if (!keys.includes(key)) { + prev[key] = obj[key]; + } + return prev; + }, {}); +} +exports.pickExclude = pickExclude; +function getRect(selector) { + var _this = this; + return new Promise(function (resolve) { + wx.createSelectorQuery() + .in(_this) + .select(selector) + .boundingClientRect() + .exec(function (rect) { + if (rect === void 0) { + rect = []; + } + return resolve(rect[0]); + }); + }); +} +exports.getRect = getRect; +function getAllRect(selector) { + var _this = this; + return new Promise(function (resolve) { + wx.createSelectorQuery() + .in(_this) + .selectAll(selector) + .boundingClientRect() + .exec(function (rect) { + if (rect === void 0) { + rect = []; + } + return resolve(rect[0]); + }); + }); +} +exports.getAllRect = getAllRect; diff --git a/miniprogram_npm/@vant/weapp/common/validator.js b/miniprogram_npm/@vant/weapp/common/validator.js new file mode 100644 index 0000000..5c54b73 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/common/validator.js @@ -0,0 +1,42 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +exports.isVideoUrl = exports.isImageUrl = exports.isBoolean = exports.isNumber = exports.isObj = exports.isDef = exports.isPromise = exports.isPlainObject = exports.isFunction = void 0; +function isFunction(val) { + return typeof val === 'function'; +} +exports.isFunction = isFunction; +function isPlainObject(val) { + return val !== null && typeof val === 'object' && !Array.isArray(val); +} +exports.isPlainObject = isPlainObject; +function isPromise(val) { + return isPlainObject(val) && isFunction(val.then) && isFunction(val.catch); +} +exports.isPromise = isPromise; +function isDef(value) { + return value !== undefined && value !== null; +} +exports.isDef = isDef; +function isObj(x) { + var type = typeof x; + return x !== null && (type === 'object' || type === 'function'); +} +exports.isObj = isObj; +function isNumber(value) { + return /^\d+(\.\d+)?$/.test(value); +} +exports.isNumber = isNumber; +function isBoolean(value) { + return typeof value === 'boolean'; +} +exports.isBoolean = isBoolean; +var IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i; +var VIDEO_REGEXP = /\.(mp4|mpg|mpeg|dat|asf|avi|rm|rmvb|mov|wmv|flv|mkv)/i; +function isImageUrl(url) { + return IMAGE_REGEXP.test(url); +} +exports.isImageUrl = isImageUrl; +function isVideoUrl(url) { + return VIDEO_REGEXP.test(url); +} +exports.isVideoUrl = isVideoUrl; diff --git a/miniprogram_npm/@vant/weapp/common/version.js b/miniprogram_npm/@vant/weapp/common/version.js new file mode 100644 index 0000000..50b90a5 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/common/version.js @@ -0,0 +1,36 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +exports.canIUseFormFieldButton = exports.canIUseModel = void 0; +var utils_1 = require('./utils'); +function compareVersion(v1, v2) { + v1 = v1.split('.'); + v2 = v2.split('.'); + var len = Math.max(v1.length, v2.length); + while (v1.length < len) { + v1.push('0'); + } + while (v2.length < len) { + v2.push('0'); + } + for (var i = 0; i < len; i++) { + var num1 = parseInt(v1[i], 10); + var num2 = parseInt(v2[i], 10); + if (num1 > num2) { + return 1; + } + if (num1 < num2) { + return -1; + } + } + return 0; +} +function canIUseModel() { + var system = utils_1.getSystemInfoSync(); + return compareVersion(system.SDKVersion, '2.9.3') >= 0; +} +exports.canIUseModel = canIUseModel; +function canIUseFormFieldButton() { + var system = utils_1.getSystemInfoSync(); + return compareVersion(system.SDKVersion, '2.10.3') >= 0; +} +exports.canIUseFormFieldButton = canIUseFormFieldButton; diff --git a/miniprogram_npm/@vant/weapp/count-down/index.js b/miniprogram_npm/@vant/weapp/count-down/index.js new file mode 100644 index 0000000..348d489 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/count-down/index.js @@ -0,0 +1,103 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +var utils_1 = require('./utils'); +function simpleTick(fn) { + return setTimeout(fn, 30); +} +component_1.VantComponent({ + props: { + useSlot: Boolean, + millisecond: Boolean, + time: { + type: Number, + observer: 'reset', + }, + format: { + type: String, + value: 'HH:mm:ss', + }, + autoStart: { + type: Boolean, + value: true, + }, + }, + data: { + timeData: utils_1.parseTimeData(0), + formattedTime: '0', + }, + destroyed: function () { + clearTimeout(this.tid); + this.tid = null; + }, + methods: { + // 开始 + start: function () { + if (this.counting) { + return; + } + this.counting = true; + this.endTime = Date.now() + this.remain; + this.tick(); + }, + // 暂停 + pause: function () { + this.counting = false; + clearTimeout(this.tid); + }, + // 重置 + reset: function () { + this.pause(); + this.remain = this.data.time; + this.setRemain(this.remain); + if (this.data.autoStart) { + this.start(); + } + }, + tick: function () { + if (this.data.millisecond) { + this.microTick(); + } else { + this.macroTick(); + } + }, + microTick: function () { + var _this = this; + this.tid = simpleTick(function () { + _this.setRemain(_this.getRemain()); + if (_this.remain !== 0) { + _this.microTick(); + } + }); + }, + macroTick: function () { + var _this = this; + this.tid = simpleTick(function () { + var remain = _this.getRemain(); + if (!utils_1.isSameSecond(remain, _this.remain) || remain === 0) { + _this.setRemain(remain); + } + if (_this.remain !== 0) { + _this.macroTick(); + } + }); + }, + getRemain: function () { + return Math.max(this.endTime - Date.now(), 0); + }, + setRemain: function (remain) { + this.remain = remain; + var timeData = utils_1.parseTimeData(remain); + if (this.data.useSlot) { + this.$emit('change', timeData); + } + this.setData({ + formattedTime: utils_1.parseFormat(this.data.format, timeData), + }); + if (remain === 0) { + this.pause(); + this.$emit('finish'); + } + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/count-down/index.json b/miniprogram_npm/@vant/weapp/count-down/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/count-down/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram_npm/@vant/weapp/count-down/index.wxml b/miniprogram_npm/@vant/weapp/count-down/index.wxml new file mode 100644 index 0000000..e206e16 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/count-down/index.wxml @@ -0,0 +1,4 @@ + + + {{ formattedTime }} + diff --git a/miniprogram_npm/@vant/weapp/count-down/index.wxss b/miniprogram_npm/@vant/weapp/count-down/index.wxss new file mode 100644 index 0000000..bc33f5d --- /dev/null +++ b/miniprogram_npm/@vant/weapp/count-down/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-count-down{color:#323233;color:var(--count-down-text-color,#323233);font-size:14px;font-size:var(--count-down-font-size,14px);line-height:20px;line-height:var(--count-down-line-height,20px)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/count-down/utils.js b/miniprogram_npm/@vant/weapp/count-down/utils.js new file mode 100644 index 0000000..10864a2 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/count-down/utils.js @@ -0,0 +1,65 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +exports.isSameSecond = exports.parseFormat = exports.parseTimeData = void 0; +function padZero(num, targetLength) { + if (targetLength === void 0) { + targetLength = 2; + } + var str = num + ''; + while (str.length < targetLength) { + str = '0' + str; + } + return str; +} +var SECOND = 1000; +var MINUTE = 60 * SECOND; +var HOUR = 60 * MINUTE; +var DAY = 24 * HOUR; +function parseTimeData(time) { + var days = Math.floor(time / DAY); + var hours = Math.floor((time % DAY) / HOUR); + var minutes = Math.floor((time % HOUR) / MINUTE); + var seconds = Math.floor((time % MINUTE) / SECOND); + var milliseconds = Math.floor(time % SECOND); + return { + days: days, + hours: hours, + minutes: minutes, + seconds: seconds, + milliseconds: milliseconds, + }; +} +exports.parseTimeData = parseTimeData; +function parseFormat(format, timeData) { + var days = timeData.days; + var hours = timeData.hours, + minutes = timeData.minutes, + seconds = timeData.seconds, + milliseconds = timeData.milliseconds; + if (format.indexOf('DD') === -1) { + hours += days * 24; + } else { + format = format.replace('DD', padZero(days)); + } + if (format.indexOf('HH') === -1) { + minutes += hours * 60; + } else { + format = format.replace('HH', padZero(hours)); + } + if (format.indexOf('mm') === -1) { + seconds += minutes * 60; + } else { + format = format.replace('mm', padZero(minutes)); + } + if (format.indexOf('ss') === -1) { + milliseconds += seconds * 1000; + } else { + format = format.replace('ss', padZero(seconds)); + } + return format.replace('SSS', padZero(milliseconds, 3)); +} +exports.parseFormat = parseFormat; +function isSameSecond(time1, time2) { + return Math.floor(time1 / 1000) === Math.floor(time2 / 1000); +} +exports.isSameSecond = isSameSecond; diff --git a/miniprogram_npm/@vant/weapp/dialog/dialog.js b/miniprogram_npm/@vant/weapp/dialog/dialog.js new file mode 100644 index 0000000..5a09dbc --- /dev/null +++ b/miniprogram_npm/@vant/weapp/dialog/dialog.js @@ -0,0 +1,96 @@ +'use strict'; +var __assign = + (this && this.__assign) || + function () { + __assign = + Object.assign || + function (t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) + if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); + }; +Object.defineProperty(exports, '__esModule', { value: true }); +var queue = []; +var defaultOptions = { + show: false, + title: '', + width: null, + theme: 'default', + message: '', + zIndex: 100, + overlay: true, + selector: '#van-dialog', + className: '', + asyncClose: false, + transition: 'scale', + customStyle: '', + messageAlign: '', + overlayStyle: '', + confirmButtonText: '确认', + cancelButtonText: '取消', + showConfirmButton: true, + showCancelButton: false, + closeOnClickOverlay: false, + confirmButtonOpenType: '', +}; +var currentOptions = __assign({}, defaultOptions); +function getContext() { + var pages = getCurrentPages(); + return pages[pages.length - 1]; +} +var Dialog = function (options) { + options = __assign(__assign({}, currentOptions), options); + return new Promise(function (resolve, reject) { + var context = options.context || getContext(); + var dialog = context.selectComponent(options.selector); + delete options.context; + delete options.selector; + if (dialog) { + dialog.setData( + __assign({ onCancel: reject, onConfirm: resolve }, options) + ); + wx.nextTick(function () { + dialog.setData({ show: true }); + }); + queue.push(dialog); + } else { + console.warn( + '未找到 van-dialog 节点,请确认 selector 及 context 是否正确' + ); + } + }); +}; +Dialog.alert = function (options) { + return Dialog(options); +}; +Dialog.confirm = function (options) { + return Dialog(__assign({ showCancelButton: true }, options)); +}; +Dialog.close = function () { + queue.forEach(function (dialog) { + dialog.close(); + }); + queue = []; +}; +Dialog.stopLoading = function () { + queue.forEach(function (dialog) { + dialog.stopLoading(); + }); +}; +Dialog.currentOptions = currentOptions; +Dialog.defaultOptions = defaultOptions; +Dialog.setDefaultOptions = function (options) { + currentOptions = __assign(__assign({}, currentOptions), options); + Dialog.currentOptions = currentOptions; +}; +Dialog.resetDefaultOptions = function () { + currentOptions = __assign({}, defaultOptions); + Dialog.currentOptions = currentOptions; +}; +Dialog.resetDefaultOptions(); +exports.default = Dialog; diff --git a/miniprogram_npm/@vant/weapp/dialog/index.js b/miniprogram_npm/@vant/weapp/dialog/index.js new file mode 100644 index 0000000..9c672c2 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/dialog/index.js @@ -0,0 +1,115 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +var button_1 = require('../mixins/button'); +var open_type_1 = require('../mixins/open-type'); +var color_1 = require('../common/color'); +component_1.VantComponent({ + mixins: [button_1.button, open_type_1.openType], + props: { + show: { + type: Boolean, + observer: function (show) { + !show && this.stopLoading(); + }, + }, + title: String, + message: String, + theme: { + type: String, + value: 'default', + }, + useSlot: Boolean, + className: String, + customStyle: String, + asyncClose: Boolean, + messageAlign: String, + overlayStyle: String, + useTitleSlot: Boolean, + showCancelButton: Boolean, + closeOnClickOverlay: Boolean, + confirmButtonOpenType: String, + width: null, + zIndex: { + type: Number, + value: 2000, + }, + confirmButtonText: { + type: String, + value: '确认', + }, + cancelButtonText: { + type: String, + value: '取消', + }, + confirmButtonColor: { + type: String, + value: color_1.RED, + }, + cancelButtonColor: { + type: String, + value: color_1.GRAY, + }, + showConfirmButton: { + type: Boolean, + value: true, + }, + overlay: { + type: Boolean, + value: true, + }, + transition: { + type: String, + value: 'scale', + }, + }, + data: { + loading: { + confirm: false, + cancel: false, + }, + }, + methods: { + onConfirm: function () { + this.handleAction('confirm'); + }, + onCancel: function () { + this.handleAction('cancel'); + }, + onClickOverlay: function () { + this.onClose('overlay'); + }, + handleAction: function (action) { + var _a; + if (this.data.asyncClose) { + this.setData(((_a = {}), (_a['loading.' + action] = true), _a)); + } + this.onClose(action); + }, + close: function () { + this.setData({ + show: false, + }); + }, + stopLoading: function () { + this.setData({ + loading: { + confirm: false, + cancel: false, + }, + }); + }, + onClose: function (action) { + if (!this.data.asyncClose) { + this.close(); + } + this.$emit('close', action); + // 把 dialog 实例传递出去,可以通过 stopLoading() 在外部关闭按钮的 loading + this.$emit(action, { dialog: this }); + var callback = this.data[action === 'confirm' ? 'onConfirm' : 'onCancel']; + if (callback) { + callback(this); + } + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/dialog/index.json b/miniprogram_npm/@vant/weapp/dialog/index.json new file mode 100644 index 0000000..1b87cc8 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/dialog/index.json @@ -0,0 +1,9 @@ +{ + "component": true, + "usingComponents": { + "van-popup": "../popup/index", + "van-button": "../button/index", + "van-goods-action": "../goods-action//index", + "van-goods-action-button": "../goods-action-button/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/dialog/index.wxml b/miniprogram_npm/@vant/weapp/dialog/index.wxml new file mode 100644 index 0000000..fd13bc9 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/dialog/index.wxml @@ -0,0 +1,113 @@ + + + + + + {{ title }} + + + + + {{ message }} + + + + + {{ cancelButtonText }} + + + {{ confirmButtonText }} + + + + + + {{ cancelButtonText }} + + + {{ confirmButtonText }} + + + diff --git a/miniprogram_npm/@vant/weapp/dialog/index.wxss b/miniprogram_npm/@vant/weapp/dialog/index.wxss new file mode 100644 index 0000000..c6bac95 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/dialog/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-dialog{top:45%!important;overflow:hidden;width:320px;width:var(--dialog-width,320px);font-size:16px;font-size:var(--dialog-font-size,16px);border-radius:16px;border-radius:var(--dialog-border-radius,16px);background-color:#fff;background-color:var(--dialog-background-color,#fff)}@media (max-width:321px){.van-dialog{width:90%;width:var(--dialog-small-screen-width,90%)}}.van-dialog__header{text-align:center;padding-top:24px;padding-top:var(--dialog-header-padding-top,24px);font-weight:500;font-weight:var(--dialog-header-font-weight,500);line-height:24px;line-height:var(--dialog-header-line-height,24px)}.van-dialog__header--isolated{padding:24px 0;padding:var(--dialog-header-isolated-padding,24px 0)}.van-dialog__message{overflow-y:auto;text-align:center;-webkit-overflow-scrolling:touch;font-size:14px;font-size:var(--dialog-message-font-size,14px);line-height:20px;line-height:var(--dialog-message-line-height,20px);max-height:60vh;max-height:var(--dialog-message-max-height,60vh);padding:24px;padding:var(--dialog-message-padding,24px)}.van-dialog__message-text{word-wrap:break-word}.van-dialog__message--hasTitle{padding-top:8px;padding-top:var(--dialog-has-title-message-padding-top,8px);color:#646566;color:var(--dialog-has-title-message-text-color,#646566)}.van-dialog__message--round-button{padding-bottom:16px;color:#323233}.van-dialog__message--left{text-align:left}.van-dialog__message--right{text-align:right}.van-dialog__footer{display:-webkit-flex;display:flex}.van-dialog__footer--round-button{position:relative!important;padding:8px 24px 16px!important}.van-dialog__button{-webkit-flex:1;flex:1}.van-dialog__cancel,.van-dialog__confirm{border:0!important}.van-dialog-bounce-enter{-webkit-transform:translate3d(-50%,-50%,0) scale(.7);transform:translate3d(-50%,-50%,0) scale(.7);opacity:0}.van-dialog-bounce-leave-active{-webkit-transform:translate3d(-50%,-50%,0) scale(.9);transform:translate3d(-50%,-50%,0) scale(.9);opacity:0} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/divider/index.js b/miniprogram_npm/@vant/weapp/divider/index.js new file mode 100644 index 0000000..50ce01a --- /dev/null +++ b/miniprogram_npm/@vant/weapp/divider/index.js @@ -0,0 +1,35 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +component_1.VantComponent({ + props: { + dashed: { + type: Boolean, + value: false, + }, + hairline: { + type: Boolean, + value: false, + }, + contentPosition: { + type: String, + value: '', + }, + fontSize: { + type: Number, + value: '', + }, + borderColor: { + type: String, + value: '', + }, + textColor: { + type: String, + value: '', + }, + customStyle: { + type: String, + value: '', + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/divider/index.json b/miniprogram_npm/@vant/weapp/divider/index.json new file mode 100644 index 0000000..a89ef4d --- /dev/null +++ b/miniprogram_npm/@vant/weapp/divider/index.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} diff --git a/miniprogram_npm/@vant/weapp/divider/index.wxml b/miniprogram_npm/@vant/weapp/divider/index.wxml new file mode 100644 index 0000000..412e73f --- /dev/null +++ b/miniprogram_npm/@vant/weapp/divider/index.wxml @@ -0,0 +1,8 @@ + + + + + diff --git a/miniprogram_npm/@vant/weapp/divider/index.wxss b/miniprogram_npm/@vant/weapp/divider/index.wxss new file mode 100644 index 0000000..c055e3a --- /dev/null +++ b/miniprogram_npm/@vant/weapp/divider/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-divider{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;margin:16px 0;margin:var(--divider-margin,16px 0);color:#969799;color:var(--divider-text-color,#969799);font-size:14px;font-size:var(--divider-font-size,14px);line-height:24px;line-height:var(--divider-line-height,24px);border:0 solid #ebedf0;border-color:var(--divider-border-color,#ebedf0)}.van-divider:after,.van-divider:before{display:block;-webkit-flex:1;flex:1;box-sizing:border-box;height:1px;border-color:inherit;border-style:inherit;border-width:1px 0 0}.van-divider:before{content:""}.van-divider--hairline:after,.van-divider--hairline:before{-webkit-transform:scaleY(.5);transform:scaleY(.5)}.van-divider--dashed{border-style:dashed}.van-divider--center:before,.van-divider--left:before,.van-divider--right:before{margin-right:16px;margin-right:var(--divider-content-padding,16px)}.van-divider--center:after,.van-divider--left:after,.van-divider--right:after{content:"";margin-left:16px;margin-left:var(--divider-content-padding,16px)}.van-divider--left:before{max-width:10%;max-width:var(--divider-content-left-width,10%)}.van-divider--right:after{max-width:10%;max-width:var(--divider-content-right-width,10%)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/dropdown-item/index.js b/miniprogram_npm/@vant/weapp/dropdown-item/index.js new file mode 100644 index 0000000..af9bc36 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/dropdown-item/index.js @@ -0,0 +1,115 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +component_1.VantComponent({ + field: true, + relation: { + name: 'dropdown-menu', + type: 'ancestor', + current: 'dropdown-item', + linked: function () { + this.updateDataFromParent(); + }, + }, + props: { + value: { + type: null, + observer: 'rerender', + }, + title: { + type: String, + observer: 'rerender', + }, + disabled: Boolean, + titleClass: { + type: String, + observer: 'rerender', + }, + options: { + type: Array, + value: [], + observer: 'rerender', + }, + popupStyle: String, + }, + data: { + transition: true, + showPopup: false, + showWrapper: false, + displayTitle: '', + }, + methods: { + rerender: function () { + var _this = this; + wx.nextTick(function () { + _this.parent && _this.parent.updateItemListData(); + }); + }, + updateDataFromParent: function () { + if (this.parent) { + var _a = this.parent.data, + overlay = _a.overlay, + duration = _a.duration, + activeColor = _a.activeColor, + closeOnClickOverlay = _a.closeOnClickOverlay, + direction = _a.direction; + this.setData({ + overlay: overlay, + duration: duration, + activeColor: activeColor, + closeOnClickOverlay: closeOnClickOverlay, + direction: direction, + }); + } + }, + onOpen: function () { + this.$emit('open'); + }, + onOpened: function () { + this.$emit('opened'); + }, + onClose: function () { + this.$emit('close'); + }, + onClosed: function () { + this.$emit('closed'); + this.setData({ showWrapper: false }); + }, + onOptionTap: function (event) { + var option = event.currentTarget.dataset.option; + var value = option.value; + var shouldEmitChange = this.data.value !== value; + this.setData({ showPopup: false, value: value }); + this.$emit('close'); + this.rerender(); + if (shouldEmitChange) { + this.$emit('change', value); + } + }, + toggle: function (show, options) { + var _this = this; + if (options === void 0) { + options = {}; + } + var showPopup = this.data.showPopup; + if (typeof show !== 'boolean') { + show = !showPopup; + } + if (show === showPopup) { + return; + } + this.setData({ + transition: !options.immediate, + showPopup: show, + }); + if (show) { + this.parent.getChildWrapperStyle().then(function (wrapperStyle) { + _this.setData({ wrapperStyle: wrapperStyle, showWrapper: true }); + _this.rerender(); + }); + } else { + this.rerender(); + } + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/dropdown-item/index.json b/miniprogram_npm/@vant/weapp/dropdown-item/index.json new file mode 100644 index 0000000..88d5409 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/dropdown-item/index.json @@ -0,0 +1,8 @@ +{ + "component": true, + "usingComponents": { + "van-popup": "../popup/index", + "van-cell": "../cell/index", + "van-icon": "../icon/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/dropdown-item/index.wxml b/miniprogram_npm/@vant/weapp/dropdown-item/index.wxml new file mode 100644 index 0000000..dd75292 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/dropdown-item/index.wxml @@ -0,0 +1,48 @@ + + + + + + + {{ item.text }} + + + + + + + diff --git a/miniprogram_npm/@vant/weapp/dropdown-item/index.wxss b/miniprogram_npm/@vant/weapp/dropdown-item/index.wxss new file mode 100644 index 0000000..7cab3f2 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/dropdown-item/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-dropdown-item{position:fixed;right:0;left:0;overflow:hidden}.van-dropdown-item__option{text-align:left}.van-dropdown-item__option--active .van-dropdown-item__icon,.van-dropdown-item__option--active .van-dropdown-item__title{color:#ee0a24;color:var(--dropdown-menu-option-active-color,#ee0a24)}.van-dropdown-item--up{top:0}.van-dropdown-item--down{bottom:0}.van-dropdown-item__icon{display:block;line-height:inherit} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/dropdown-item/shared.js b/miniprogram_npm/@vant/weapp/dropdown-item/shared.js new file mode 100644 index 0000000..db8b17d --- /dev/null +++ b/miniprogram_npm/@vant/weapp/dropdown-item/shared.js @@ -0,0 +1,2 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); diff --git a/miniprogram_npm/@vant/weapp/dropdown-menu/index.js b/miniprogram_npm/@vant/weapp/dropdown-menu/index.js new file mode 100644 index 0000000..8f574a8 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/dropdown-menu/index.js @@ -0,0 +1,133 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +var utils_1 = require('../common/utils'); +var ARRAY = []; +component_1.VantComponent({ + field: true, + relation: { + name: 'dropdown-item', + type: 'descendant', + current: 'dropdown-menu', + linked: function () { + this.updateItemListData(); + }, + unlinked: function () { + this.updateItemListData(); + }, + }, + props: { + activeColor: { + type: String, + observer: 'updateChildrenData', + }, + overlay: { + type: Boolean, + value: true, + observer: 'updateChildrenData', + }, + zIndex: { + type: Number, + value: 10, + }, + duration: { + type: Number, + value: 200, + observer: 'updateChildrenData', + }, + direction: { + type: String, + value: 'down', + observer: 'updateChildrenData', + }, + closeOnClickOverlay: { + type: Boolean, + value: true, + observer: 'updateChildrenData', + }, + closeOnClickOutside: { + type: Boolean, + value: true, + }, + }, + data: { + itemListData: [], + }, + beforeCreate: function () { + var windowHeight = wx.getSystemInfoSync().windowHeight; + this.windowHeight = windowHeight; + ARRAY.push(this); + }, + destroyed: function () { + var _this = this; + ARRAY = ARRAY.filter(function (item) { + return item !== _this; + }); + }, + methods: { + updateItemListData: function () { + this.setData({ + itemListData: this.children.map(function (child) { + return child.data; + }), + }); + }, + updateChildrenData: function () { + this.children.forEach(function (child) { + child.updateDataFromParent(); + }); + }, + toggleItem: function (active) { + this.children.forEach(function (item, index) { + var showPopup = item.data.showPopup; + if (index === active) { + item.toggle(); + } else if (showPopup) { + item.toggle(false, { immediate: true }); + } + }); + }, + close: function () { + this.children.forEach(function (child) { + child.toggle(false, { immediate: true }); + }); + }, + getChildWrapperStyle: function () { + var _this = this; + var _a = this.data, + zIndex = _a.zIndex, + direction = _a.direction; + return this.getRect('.van-dropdown-menu').then(function (rect) { + var _a = rect.top, + top = _a === void 0 ? 0 : _a, + _b = rect.bottom, + bottom = _b === void 0 ? 0 : _b; + var offset = direction === 'down' ? bottom : _this.windowHeight - top; + var wrapperStyle = 'z-index: ' + zIndex + ';'; + if (direction === 'down') { + wrapperStyle += 'top: ' + utils_1.addUnit(offset) + ';'; + } else { + wrapperStyle += 'bottom: ' + utils_1.addUnit(offset) + ';'; + } + return wrapperStyle; + }); + }, + onTitleTap: function (event) { + var _this = this; + var index = event.currentTarget.dataset.index; + var child = this.children[index]; + if (!child.data.disabled) { + ARRAY.forEach(function (menuItem) { + if ( + menuItem && + menuItem.data.closeOnClickOutside && + menuItem !== _this + ) { + menuItem.close(); + } + }); + this.toggleItem(index); + } + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/dropdown-menu/index.json b/miniprogram_npm/@vant/weapp/dropdown-menu/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/dropdown-menu/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram_npm/@vant/weapp/dropdown-menu/index.wxml b/miniprogram_npm/@vant/weapp/dropdown-menu/index.wxml new file mode 100644 index 0000000..037ac3b --- /dev/null +++ b/miniprogram_npm/@vant/weapp/dropdown-menu/index.wxml @@ -0,0 +1,23 @@ + + + + + + + + {{ computed.displayTitle(item) }} + + + + + + diff --git a/miniprogram_npm/@vant/weapp/dropdown-menu/index.wxs b/miniprogram_npm/@vant/weapp/dropdown-menu/index.wxs new file mode 100644 index 0000000..6538854 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/dropdown-menu/index.wxs @@ -0,0 +1,16 @@ +/* eslint-disable */ +function displayTitle(item) { + if (item.title) { + return item.title; + } + + var match = item.options.filter(function(option) { + return option.value === item.value; + }); + var displayTitle = match.length ? match[0].text : ''; + return displayTitle; +} + +module.exports = { + displayTitle: displayTitle +}; diff --git a/miniprogram_npm/@vant/weapp/dropdown-menu/index.wxss b/miniprogram_npm/@vant/weapp/dropdown-menu/index.wxss new file mode 100644 index 0000000..ec6caff --- /dev/null +++ b/miniprogram_npm/@vant/weapp/dropdown-menu/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-dropdown-menu{display:-webkit-flex;display:flex;box-shadow:0 2px 12px rgba(100,101,102,.12);-webkit-user-select:none;user-select:none;height:50px;height:var(--dropdown-menu-height,50px);background-color:#fff;background-color:var(--dropdown-menu-background-color,#fff)}.van-dropdown-menu__item{display:-webkit-flex;display:flex;-webkit-flex:1;flex:1;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;min-width:0}.van-dropdown-menu__item:active{opacity:.7}.van-dropdown-menu__item--disabled:active{opacity:1}.van-dropdown-menu__item--disabled .van-dropdown-menu__title{color:#969799;color:var(--dropdown-menu-title-disabled-text-color,#969799)}.van-dropdown-menu__title{position:relative;box-sizing:border-box;max-width:100%;padding:0 8px;padding:var(--dropdown-menu-title-padding,0 8px);color:#323233;color:var(--dropdown-menu-title-text-color,#323233);font-size:15px;font-size:var(--dropdown-menu-title-font-size,15px);line-height:18px;line-height:var(--dropdown-menu-title-line-height,18px)}.van-dropdown-menu__title:after{position:absolute;top:50%;right:-4px;margin-top:-5px;border-color:transparent transparent currentcolor currentcolor;border-style:solid;border-width:3px;-webkit-transform:rotate(-45deg);transform:rotate(-45deg);opacity:.8;content:""}.van-dropdown-menu__title--active{color:#ee0a24;color:var(--dropdown-menu-title-active-text-color,#ee0a24)}.van-dropdown-menu__title--down:after{margin-top:-1px;-webkit-transform:rotate(135deg);transform:rotate(135deg)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/empty/index.js b/miniprogram_npm/@vant/weapp/empty/index.js new file mode 100644 index 0000000..caf4a5b --- /dev/null +++ b/miniprogram_npm/@vant/weapp/empty/index.js @@ -0,0 +1,23 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +var PRESETS = ['error', 'search', 'default', 'network']; +component_1.VantComponent({ + props: { + description: String, + image: { + type: String, + value: 'default', + }, + }, + created: function () { + if (PRESETS.indexOf(this.data.image) !== -1) { + this.setData({ + imageUrl: + 'https://img.yzcdn.cn/vant/empty-image-' + this.data.image + '.png', + }); + } else { + this.setData({ imageUrl: this.data.image }); + } + }, +}); diff --git a/miniprogram_npm/@vant/weapp/empty/index.json b/miniprogram_npm/@vant/weapp/empty/index.json new file mode 100644 index 0000000..e8cfaaf --- /dev/null +++ b/miniprogram_npm/@vant/weapp/empty/index.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/empty/index.wxml b/miniprogram_npm/@vant/weapp/empty/index.wxml new file mode 100644 index 0000000..b6a2cb3 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/empty/index.wxml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + {{ description }} + + + + + + diff --git a/miniprogram_npm/@vant/weapp/empty/index.wxss b/miniprogram_npm/@vant/weapp/empty/index.wxss new file mode 100644 index 0000000..aeb9d4b --- /dev/null +++ b/miniprogram_npm/@vant/weapp/empty/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-empty{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:32px 0}.van-empty__image{width:160px;height:160px}.van-empty__image:empty{display:none}.van-empty__image__img{width:100%;height:100%}.van-empty__image:not(:empty)+.van-empty__image{display:none}.van-empty__description{margin-top:16px;padding:0 60px;color:#969799;font-size:14px;line-height:20px}.van-empty__description:empty,.van-empty__description:not(:empty)+.van-empty__description{display:none}.van-empty__bottom{margin-top:24px} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/field/index.js b/miniprogram_npm/@vant/weapp/field/index.js new file mode 100644 index 0000000..b19ba63 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/field/index.js @@ -0,0 +1,147 @@ +'use strict'; +var __assign = + (this && this.__assign) || + function () { + __assign = + Object.assign || + function (t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) + if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); + }; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +var props_1 = require('./props'); +component_1.VantComponent({ + field: true, + classes: ['input-class', 'right-icon-class', 'label-class'], + props: __assign( + __assign( + __assign(__assign({}, props_1.commonProps), props_1.inputProps), + props_1.textareaProps + ), + { + size: String, + icon: String, + label: String, + error: Boolean, + center: Boolean, + isLink: Boolean, + leftIcon: String, + rightIcon: String, + autosize: [Boolean, Object], + required: Boolean, + iconClass: String, + clickable: Boolean, + inputAlign: String, + customStyle: String, + errorMessage: String, + arrowDirection: String, + showWordLimit: Boolean, + errorMessageAlign: String, + readonly: { + type: Boolean, + observer: 'setShowClear', + }, + clearable: { + type: Boolean, + observer: 'setShowClear', + }, + border: { + type: Boolean, + value: true, + }, + titleWidth: { + type: String, + value: '6.2em', + }, + } + ), + data: { + focused: false, + innerValue: '', + showClear: false, + }, + created: function () { + this.value = this.data.value; + this.setData({ innerValue: this.value }); + }, + methods: { + onInput: function (event) { + var _a = (event.detail || {}).value, + value = _a === void 0 ? '' : _a; + this.value = value; + this.setShowClear(); + this.emitChange(); + }, + onFocus: function (event) { + this.focused = true; + this.setShowClear(); + this.$emit('focus', event.detail); + }, + onBlur: function (event) { + this.focused = false; + this.setShowClear(); + this.$emit('blur', event.detail); + }, + onClickIcon: function () { + this.$emit('click-icon'); + }, + onClear: function () { + var _this = this; + this.setData({ innerValue: '' }); + this.value = ''; + this.setShowClear(); + wx.nextTick(function () { + _this.emitChange(); + _this.$emit('clear', ''); + }); + }, + onConfirm: function (event) { + var _a = (event.detail || {}).value, + value = _a === void 0 ? '' : _a; + this.value = value; + this.setShowClear(); + this.$emit('confirm', value); + }, + setValue: function (value) { + this.value = value; + this.setShowClear(); + if (value === '') { + this.setData({ innerValue: '' }); + } + this.emitChange(); + }, + onLineChange: function (event) { + this.$emit('linechange', event.detail); + }, + onKeyboardHeightChange: function (event) { + this.$emit('keyboardheightchange', event.detail); + }, + emitChange: function () { + var _this = this; + this.setData({ value: this.value }); + wx.nextTick(function () { + _this.$emit('input', _this.value); + _this.$emit('change', _this.value); + }); + }, + setShowClear: function () { + var _a = this.data, + clearable = _a.clearable, + readonly = _a.readonly; + var _b = this, + focused = _b.focused, + value = _b.value; + this.setData({ + showClear: !!clearable && !!focused && !!value && !readonly, + }); + }, + noop: function () {}, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/field/index.json b/miniprogram_npm/@vant/weapp/field/index.json new file mode 100644 index 0000000..5906c50 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/field/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "van-cell": "../cell/index", + "van-icon": "../icon/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/field/index.wxml b/miniprogram_npm/@vant/weapp/field/index.wxml new file mode 100644 index 0000000..42bd26b --- /dev/null +++ b/miniprogram_npm/@vant/weapp/field/index.wxml @@ -0,0 +1,107 @@ + + + + + + + {{ label }} + + + + + + + + + + + + + + + + + {{ value.length }}/{{ maxlength }} + + + {{ errorMessage }} + + diff --git a/miniprogram_npm/@vant/weapp/field/index.wxs b/miniprogram_npm/@vant/weapp/field/index.wxs new file mode 100644 index 0000000..639ae2f --- /dev/null +++ b/miniprogram_npm/@vant/weapp/field/index.wxs @@ -0,0 +1,21 @@ +/* eslint-disable */ +var utils = require('../wxs/utils.wxs'); + +function inputStyle(autosize) { + if (autosize && autosize.constructor === 'Object') { + var style = ''; + if (autosize.minHeight) { + style += 'min-height:' + utils.addUnit(autosize.minHeight) + ';'; + } + if (autosize.maxHeight) { + style += 'max-height:' + utils.addUnit(autosize.maxHeight) + ';'; + } + return style; + } + + return ''; +} + +module.exports = { + inputStyle: inputStyle +}; diff --git a/miniprogram_npm/@vant/weapp/field/index.wxss b/miniprogram_npm/@vant/weapp/field/index.wxss new file mode 100644 index 0000000..dbbc252 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/field/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-field{--cell-icon-size:16px;--cell-icon-size:var(--field-icon-size,16px)}.van-field__label{color:#646566;color:var(--field-label-color,#646566)}.van-field__label--disabled{color:#c8c9cc;color:var(--field-disabled-text-color,#c8c9cc)}.van-field__body{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center}.van-field__body--textarea{padding:3.6px 0;line-height:1.2em}.van-field__body--textarea,.van-field__input{box-sizing:border-box;min-height:24px;min-height:var(--cell-line-height,24px)}.van-field__input{position:relative;display:block;width:100%;margin:0;padding:0;line-height:inherit;text-align:left;background-color:initial;border:0;resize:none;color:#323233;color:var(--field-input-text-color,#323233);height:24px;height:var(--cell-line-height,24px)}.van-field__input--textarea{height:18px;height:var(--field-text-area-min-height,18px);min-height:18px;min-height:var(--field-text-area-min-height,18px)}.van-field__input--error{color:#ee0a24;color:var(--field-input-error-text-color,#ee0a24)}.van-field__input--disabled{background-color:initial;opacity:1;color:#c8c9cc;color:var(--field-input-disabled-text-color,#c8c9cc)}.van-field__input--center{text-align:center}.van-field__input--right{text-align:right}.van-field__placeholder{position:absolute;top:0;right:0;left:0;pointer-events:none;color:#c8c9cc;color:var(--field-placeholder-text-color,#c8c9cc)}.van-field__placeholder--error{color:#ee0a24;color:var(--field-error-message-color,#ee0a24)}.van-field__icon-root{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;min-height:24px;min-height:var(--cell-line-height,24px)}.van-field__clear-root,.van-field__icon-container{line-height:inherit;vertical-align:middle;padding:0 8px;padding:0 var(--padding-xs,8px);margin-right:-8px;margin-right:-var(--padding-xs,8px)}.van-field__button,.van-field__clear-root,.van-field__icon-container{-webkit-flex-shrink:0;flex-shrink:0}.van-field__clear-root{font-size:16px;font-size:var(--field-clear-icon-size,16px);color:#c8c9cc;color:var(--field-clear-icon-color,#c8c9cc)}.van-field__icon-container{font-size:16px;font-size:var(--field-icon-size,16px);color:#969799;color:var(--field-icon-container-color,#969799)}.van-field__icon-container:empty{display:none}.van-field__button{padding-left:8px;padding-left:var(--padding-xs,8px)}.van-field__button:empty{display:none}.van-field__error-message{text-align:left;font-size:12px;font-size:var(--field-error-message-text-font-size,12px);color:#ee0a24;color:var(--field-error-message-color,#ee0a24)}.van-field__error-message--center{text-align:center}.van-field__error-message--right{text-align:right}.van-field__word-limit{text-align:right;margin-top:4px;margin-top:var(--padding-base,4px);color:#646566;color:var(--field-word-limit-color,#646566);font-size:12px;font-size:var(--field-word-limit-font-size,12px);line-height:16px;line-height:var(--field-word-limit-line-height,16px)}.van-field__word-num{display:inline}.van-field__word-num--full{color:#ee0a24;color:var(--field-word-num-full-color,#ee0a24)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/field/props.js b/miniprogram_npm/@vant/weapp/field/props.js new file mode 100644 index 0000000..6ce703b --- /dev/null +++ b/miniprogram_npm/@vant/weapp/field/props.js @@ -0,0 +1,66 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +exports.textareaProps = exports.inputProps = exports.commonProps = void 0; +exports.commonProps = { + value: { + type: String, + observer: function (value) { + if (value !== this.value) { + this.setData({ innerValue: value }); + this.value = value; + } + }, + }, + placeholder: String, + placeholderStyle: String, + placeholderClass: String, + disabled: Boolean, + maxlength: { + type: Number, + value: -1, + }, + cursorSpacing: { + type: Number, + value: 50, + }, + autoFocus: Boolean, + focus: Boolean, + cursor: { + type: Number, + value: -1, + }, + selectionStart: { + type: Number, + value: -1, + }, + selectionEnd: { + type: Number, + value: -1, + }, + adjustPosition: { + type: Boolean, + value: true, + }, + holdKeyboard: Boolean, +}; +exports.inputProps = { + type: { + type: String, + value: 'text', + }, + password: Boolean, + confirmType: String, + confirmHold: Boolean, +}; +exports.textareaProps = { + autoHeight: Boolean, + fixed: Boolean, + showConfirmBar: { + type: Boolean, + value: true, + }, + disableDefaultPadding: { + type: Boolean, + value: true, + }, +}; diff --git a/miniprogram_npm/@vant/weapp/goods-action-button/index.js b/miniprogram_npm/@vant/weapp/goods-action-button/index.js new file mode 100644 index 0000000..65e9dba --- /dev/null +++ b/miniprogram_npm/@vant/weapp/goods-action-button/index.js @@ -0,0 +1,44 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +var link_1 = require('../mixins/link'); +var button_1 = require('../mixins/button'); +var open_type_1 = require('../mixins/open-type'); +component_1.VantComponent({ + mixins: [link_1.link, button_1.button, open_type_1.openType], + relation: { + type: 'ancestor', + name: 'goods-action', + current: 'goods-action-button', + }, + props: { + text: String, + color: String, + loading: Boolean, + disabled: Boolean, + plain: Boolean, + type: { + type: String, + value: 'danger', + }, + }, + methods: { + onClick: function (event) { + this.$emit('click', event.detail); + this.jumpLink(); + }, + updateStyle: function () { + if (this.parent == null) { + return; + } + var _a = this.parent.children, + children = _a === void 0 ? [] : _a; + var length = children.length; + var index = children.indexOf(this); + this.setData({ + isFirst: index === 0, + isLast: index === length - 1, + }); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/goods-action-button/index.json b/miniprogram_npm/@vant/weapp/goods-action-button/index.json new file mode 100644 index 0000000..b567686 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/goods-action-button/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-button": "../button/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/goods-action-button/index.wxml b/miniprogram_npm/@vant/weapp/goods-action-button/index.wxml new file mode 100644 index 0000000..3912ced --- /dev/null +++ b/miniprogram_npm/@vant/weapp/goods-action-button/index.wxml @@ -0,0 +1,30 @@ + + + {{ text }} + + diff --git a/miniprogram_npm/@vant/weapp/goods-action-button/index.wxss b/miniprogram_npm/@vant/weapp/goods-action-button/index.wxss new file mode 100644 index 0000000..77d16c6 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/goods-action-button/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';:host{-webkit-flex:1;flex:1}.van-goods-action-button{--button-warning-background-color:linear-gradient(90deg,#ffd01e,#ff8917);--button-warning-background-color:var(--goods-action-button-warning-color,linear-gradient(90deg,#ffd01e,#ff8917));--button-danger-background-color:linear-gradient(90deg,#ff6034,#ee0a24);--button-danger-background-color:var(--goods-action-button-danger-color,linear-gradient(90deg,#ff6034,#ee0a24));--button-default-height:40px;--button-default-height:var(--goods-action-button-height,40px);--button-line-height:20px;--button-line-height:var(--goods-action-button-line-height,20px);--button-plain-background-color:#fff;--button-plain-background-color:var(--goods-action-button-plain-color,#fff);display:block;--button-border-width:0}.van-goods-action-button--first{margin-left:5px;--button-border-radius:20px 0 0 20px;--button-border-radius:var(--goods-action-button-border-radius,20px) 0 0 var(--goods-action-button-border-radius,20px)}.van-goods-action-button--last{margin-right:5px;--button-border-radius:0 20px 20px 0;--button-border-radius:0 var(--goods-action-button-border-radius,20px) var(--goods-action-button-border-radius,20px) 0}.van-goods-action-button--first.van-goods-action-button--last{--button-border-radius:20px;--button-border-radius:var(--goods-action-button-border-radius,20px)}.van-goods-action-button--plain{--button-border-width:1px}.van-goods-action-button__inner{width:100%;font-weight:500!important;font-weight:var(--font-weight-bold,500)!important}@media (max-width:321px){.van-goods-action-button{font-size:13px}} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/goods-action-icon/index.js b/miniprogram_npm/@vant/weapp/goods-action-icon/index.js new file mode 100644 index 0000000..0631b21 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/goods-action-icon/index.js @@ -0,0 +1,24 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +var button_1 = require('../mixins/button'); +var link_1 = require('../mixins/link'); +var open_type_1 = require('../mixins/open-type'); +component_1.VantComponent({ + classes: ['icon-class', 'text-class'], + mixins: [link_1.link, button_1.button, open_type_1.openType], + props: { + text: String, + dot: Boolean, + info: String, + icon: String, + disabled: Boolean, + loading: Boolean, + }, + methods: { + onClick: function (event) { + this.$emit('click', event.detail); + this.jumpLink(); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/goods-action-icon/index.json b/miniprogram_npm/@vant/weapp/goods-action-icon/index.json new file mode 100644 index 0000000..93bfe8a --- /dev/null +++ b/miniprogram_npm/@vant/weapp/goods-action-icon/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index", + "van-button": "../button/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/goods-action-icon/index.wxml b/miniprogram_npm/@vant/weapp/goods-action-icon/index.wxml new file mode 100644 index 0000000..1983cae --- /dev/null +++ b/miniprogram_npm/@vant/weapp/goods-action-icon/index.wxml @@ -0,0 +1,35 @@ + + + + {{ text }} + diff --git a/miniprogram_npm/@vant/weapp/goods-action-icon/index.wxss b/miniprogram_npm/@vant/weapp/goods-action-icon/index.wxss new file mode 100644 index 0000000..eeef191 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/goods-action-icon/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-goods-action-icon{display:-webkit-flex!important;display:flex!important;-webkit-flex-direction:column;flex-direction:column;-webkit-justify-content:center!important;justify-content:center!important;line-height:1!important;border:none!important;font-size:10px!important;font-size:var(--goods-action-icon-font-size,10px)!important;color:#646566!important;color:var(--goods-action-icon-text-color,#646566)!important;min-width:48px;min-width:var(--goods-action-icon-width,48px);height:50px!important;height:var(--goods-action-icon-height,50px)!important}.van-goods-action-icon__icon{display:-webkit-flex;display:flex;margin:0 auto 5px;color:#323233;color:var(--goods-action-icon-color,#323233);font-size:18px;font-size:var(--goods-action-icon-size,18px)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/goods-action/index.js b/miniprogram_npm/@vant/weapp/goods-action/index.js new file mode 100644 index 0000000..4392147 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/goods-action/index.js @@ -0,0 +1,35 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +component_1.VantComponent({ + relation: { + type: 'descendant', + name: 'goods-action-button', + current: 'goods-action', + linked: function () { + this.updateStyle(); + }, + unlinked: function () { + this.updateStyle(); + }, + linkChanged: function () { + this.updateStyle(); + }, + }, + props: { + safeAreaInsetBottom: { + type: Boolean, + value: true, + }, + }, + methods: { + updateStyle: function () { + var _this = this; + wx.nextTick(function () { + _this.children.forEach(function (child) { + child.updateStyle(); + }); + }); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/goods-action/index.json b/miniprogram_npm/@vant/weapp/goods-action/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/goods-action/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram_npm/@vant/weapp/goods-action/index.wxml b/miniprogram_npm/@vant/weapp/goods-action/index.wxml new file mode 100644 index 0000000..569450c --- /dev/null +++ b/miniprogram_npm/@vant/weapp/goods-action/index.wxml @@ -0,0 +1,5 @@ + + + + + diff --git a/miniprogram_npm/@vant/weapp/goods-action/index.wxss b/miniprogram_npm/@vant/weapp/goods-action/index.wxss new file mode 100644 index 0000000..f03c6e7 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/goods-action/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-goods-action{position:fixed;right:0;bottom:0;left:0;display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;height:50px;height:var(--goods-action-height,50px);background-color:#fff;background-color:var(--goods-action-background-color,#fff)}.van-goods-action--safe{padding-bottom:env(safe-area-inset-bottom)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/grid-item/index.js b/miniprogram_npm/@vant/weapp/grid-item/index.js new file mode 100644 index 0000000..4695aa3 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/grid-item/index.js @@ -0,0 +1,86 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var link_1 = require('../mixins/link'); +var component_1 = require('../common/component'); +var utils_1 = require('../common/utils'); +component_1.VantComponent({ + relation: { + name: 'grid', + type: 'ancestor', + current: 'grid-item', + }, + classes: ['content-class', 'icon-class', 'text-class'], + mixins: [link_1.link], + props: { + icon: String, + iconColor: String, + dot: Boolean, + info: null, + badge: null, + text: String, + useSlot: Boolean, + }, + data: { + viewStyle: '', + }, + mounted: function () { + this.updateStyle(); + }, + methods: { + updateStyle: function () { + if (!this.parent) { + return; + } + var _a = this.parent, + data = _a.data, + children = _a.children; + var columnNum = data.columnNum, + border = data.border, + square = data.square, + gutter = data.gutter, + clickable = data.clickable, + center = data.center, + direction = data.direction, + iconSize = data.iconSize; + var width = 100 / columnNum + '%'; + var styleWrapper = []; + styleWrapper.push('width: ' + width); + if (square) { + styleWrapper.push('padding-top: ' + width); + } + if (gutter) { + var gutterValue = utils_1.addUnit(gutter); + styleWrapper.push('padding-right: ' + gutterValue); + var index = children.indexOf(this); + if (index >= columnNum && !square) { + styleWrapper.push('margin-top: ' + gutterValue); + } + } + var contentStyle = ''; + if (square && gutter) { + var gutterValue = utils_1.addUnit(gutter); + contentStyle = + '\n right: ' + + gutterValue + + ';\n bottom: ' + + gutterValue + + ';\n height: auto;\n '; + } + this.setData({ + viewStyle: styleWrapper.join('; '), + contentStyle: contentStyle, + center: center, + border: border, + square: square, + gutter: gutter, + clickable: clickable, + direction: direction, + iconSize: iconSize, + }); + }, + onClick: function () { + this.$emit('click'); + this.jumpLink(); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/grid-item/index.json b/miniprogram_npm/@vant/weapp/grid-item/index.json new file mode 100644 index 0000000..0a336c0 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/grid-item/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/grid-item/index.wxml b/miniprogram_npm/@vant/weapp/grid-item/index.wxml new file mode 100644 index 0000000..ede970c --- /dev/null +++ b/miniprogram_npm/@vant/weapp/grid-item/index.wxml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + {{ text }} + + + + + diff --git a/miniprogram_npm/@vant/weapp/grid-item/index.wxss b/miniprogram_npm/@vant/weapp/grid-item/index.wxss new file mode 100644 index 0000000..ed7facb --- /dev/null +++ b/miniprogram_npm/@vant/weapp/grid-item/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-grid-item{position:relative;float:left;box-sizing:border-box}.van-grid-item--square{height:0}.van-grid-item__content{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;box-sizing:border-box;height:100%;padding:16px 8px;padding:var(--grid-item-content-padding,16px 8px);background-color:#fff;background-color:var(--grid-item-content-background-color,#fff)}.van-grid-item__content:after{z-index:1;border-width:0 1px 1px 0;border-bottom-width:var(--border-width-base,1px);border-right-width:var(--border-width-base,1px);border-top-width:0}.van-grid-item__content--surround:after{border-width:1px;border-width:var(--border-width-base,1px)}.van-grid-item__content--center{-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.van-grid-item__content--square{position:absolute;top:0;right:0;left:0}.van-grid-item__content--horizontal{-webkit-flex-direction:row;flex-direction:row}.van-grid-item__content--horizontal .van-grid-item__icon+.van-grid-item__text{margin-top:0;margin-left:8px}.van-grid-item__content--clickable:active{background-color:#f2f3f5;background-color:var(--grid-item-content-active-color,#f2f3f5)}.van-grid-item__icon{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;font-size:26px;font-size:var(--grid-item-icon-size,26px);height:26px;height:var(--grid-item-icon-size,26px)}.van-grid-item__text{word-wrap:break-word;color:#646566;color:var(--grid-item-text-color,#646566);font-size:12px;font-size:var(--grid-item-text-font-size,12px)}.van-grid-item__icon+.van-grid-item__text{margin-top:8px} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/grid/index.js b/miniprogram_npm/@vant/weapp/grid/index.js new file mode 100644 index 0000000..cb5c067 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/grid/index.js @@ -0,0 +1,67 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +var utils_1 = require('../common/utils'); +component_1.VantComponent({ + relation: { + name: 'grid-item', + type: 'descendant', + current: 'grid', + }, + props: { + square: { + type: Boolean, + observer: 'updateChildren', + }, + gutter: { + type: [Number, String], + value: 0, + observer: 'updateChildren', + }, + clickable: { + type: Boolean, + observer: 'updateChildren', + }, + columnNum: { + type: Number, + value: 4, + observer: 'updateChildren', + }, + center: { + type: Boolean, + value: true, + observer: 'updateChildren', + }, + border: { + type: Boolean, + value: true, + observer: 'updateChildren', + }, + direction: { + type: String, + observer: 'updateChildren', + }, + iconSize: { + type: String, + observer: 'updateChildren', + }, + }, + data: { + viewStyle: '', + }, + created: function () { + var gutter = this.data.gutter; + if (gutter) { + this.setData({ + viewStyle: 'padding-left: ' + utils_1.addUnit(gutter), + }); + } + }, + methods: { + updateChildren: function () { + this.children.forEach(function (child) { + child.updateStyle(); + }); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/grid/index.json b/miniprogram_npm/@vant/weapp/grid/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/grid/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram_npm/@vant/weapp/grid/index.wxml b/miniprogram_npm/@vant/weapp/grid/index.wxml new file mode 100644 index 0000000..c5a545f --- /dev/null +++ b/miniprogram_npm/@vant/weapp/grid/index.wxml @@ -0,0 +1,3 @@ + + + diff --git a/miniprogram_npm/@vant/weapp/grid/index.wxss b/miniprogram_npm/@vant/weapp/grid/index.wxss new file mode 100644 index 0000000..327fc5e --- /dev/null +++ b/miniprogram_npm/@vant/weapp/grid/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-grid{position:relative;box-sizing:border-box;overflow:hidden} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/icon/computed.wxs b/miniprogram_npm/@vant/weapp/icon/computed.wxs new file mode 100644 index 0000000..4fde5f0 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/icon/computed.wxs @@ -0,0 +1,50 @@ +/* eslint-disable */ +var utils = require('../wxs/utils.wxs'); + +function isImage(name) { + return name.indexOf('/') !== -1; +} + +function rootClass(data) { + var classes = ['custom-class']; + + if (data.classPrefix != null) { + classes.push(data.classPrefix); + } + + if (isImage(data.name)) { + classes.push('van-icon--image'); + } else if (data.classPrefix != null) { + classes.push(data.classPrefix + '-' + data.name); + } + + return classes.join(' '); +} + +function rootStyle(data) { + var styles = []; + + if (data.color) { + styles.push(['color', data.color]); + } + + if (data.size) { + styles.push(['font-size', utils.addUnit(data.size)]); + } + + if (data.customStyle) { + styles.push([data.customStyle]); + } + + return styles + .map(function (pair) { + return pair.join(':'); + }) + .join(';'); +} + +module.exports = { + isImage: isImage, + rootClass: rootClass, + rootStyle: rootStyle, +}; diff --git a/miniprogram_npm/@vant/weapp/icon/index.js b/miniprogram_npm/@vant/weapp/icon/index.js new file mode 100644 index 0000000..28839c3 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/icon/index.js @@ -0,0 +1,22 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +component_1.VantComponent({ + props: { + dot: Boolean, + info: null, + size: null, + color: String, + customStyle: String, + classPrefix: { + type: String, + value: 'van-icon', + }, + name: String, + }, + methods: { + onClick: function () { + this.$emit('click'); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/icon/index.json b/miniprogram_npm/@vant/weapp/icon/index.json new file mode 100644 index 0000000..bf0ebe0 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/icon/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-info": "../info/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/icon/index.wxml b/miniprogram_npm/@vant/weapp/icon/index.wxml new file mode 100644 index 0000000..62eff36 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/icon/index.wxml @@ -0,0 +1,21 @@ + + + + + + + diff --git a/miniprogram_npm/@vant/weapp/icon/index.wxss b/miniprogram_npm/@vant/weapp/icon/index.wxss new file mode 100644 index 0000000..b3925d3 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/icon/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';@font-face{font-weight:400;font-family:vant-icon;font-style:normal;font-display:auto;src:url(https://img.yzcdn.cn/vant/vant-icon-96970a.woff2) format("woff2"),url(https://img.yzcdn.cn/vant/vant-icon-96970a.woff) format("woff"),url(https://img.yzcdn.cn/vant/vant-icon-96970a.ttf) format("truetype")}.van-icon{position:relative;font:normal normal normal 14px/1 vant-icon;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased}.van-icon,.van-icon:before{display:inline-block}.van-icon-add-o:before{content:"\F000"}.van-icon-add-square:before{content:"\F001"}.van-icon-add:before{content:"\F002"}.van-icon-after-sale:before{content:"\F003"}.van-icon-aim:before{content:"\F004"}.van-icon-alipay:before{content:"\F005"}.van-icon-apps-o:before{content:"\F006"}.van-icon-arrow-down:before{content:"\F007"}.van-icon-arrow-left:before{content:"\F008"}.van-icon-arrow-up:before{content:"\F009"}.van-icon-arrow:before{content:"\F00A"}.van-icon-ascending:before{content:"\F00B"}.van-icon-audio:before{content:"\F00C"}.van-icon-award-o:before{content:"\F00D"}.van-icon-award:before{content:"\F00E"}.van-icon-back-top:before{content:"\F0E6"}.van-icon-bag-o:before{content:"\F00F"}.van-icon-bag:before{content:"\F010"}.van-icon-balance-list-o:before{content:"\F011"}.van-icon-balance-list:before{content:"\F012"}.van-icon-balance-o:before{content:"\F013"}.van-icon-balance-pay:before{content:"\F014"}.van-icon-bar-chart-o:before{content:"\F015"}.van-icon-bars:before{content:"\F016"}.van-icon-bell:before{content:"\F017"}.van-icon-bill-o:before{content:"\F018"}.van-icon-bill:before{content:"\F019"}.van-icon-birthday-cake-o:before{content:"\F01A"}.van-icon-bookmark-o:before{content:"\F01B"}.van-icon-bookmark:before{content:"\F01C"}.van-icon-browsing-history-o:before{content:"\F01D"}.van-icon-browsing-history:before{content:"\F01E"}.van-icon-brush-o:before{content:"\F01F"}.van-icon-bulb-o:before{content:"\F020"}.van-icon-bullhorn-o:before{content:"\F021"}.van-icon-calendar-o:before{content:"\F022"}.van-icon-card:before{content:"\F023"}.van-icon-cart-circle-o:before{content:"\F024"}.van-icon-cart-circle:before{content:"\F025"}.van-icon-cart-o:before{content:"\F026"}.van-icon-cart:before{content:"\F027"}.van-icon-cash-back-record:before{content:"\F028"}.van-icon-cash-on-deliver:before{content:"\F029"}.van-icon-cashier-o:before{content:"\F02A"}.van-icon-certificate:before{content:"\F02B"}.van-icon-chart-trending-o:before{content:"\F02C"}.van-icon-chat-o:before{content:"\F02D"}.van-icon-chat:before{content:"\F02E"}.van-icon-checked:before{content:"\F02F"}.van-icon-circle:before{content:"\F030"}.van-icon-clear:before{content:"\F031"}.van-icon-clock-o:before{content:"\F032"}.van-icon-clock:before{content:"\F033"}.van-icon-close:before{content:"\F034"}.van-icon-closed-eye:before{content:"\F035"}.van-icon-cluster-o:before{content:"\F036"}.van-icon-cluster:before{content:"\F037"}.van-icon-column:before{content:"\F038"}.van-icon-comment-circle-o:before{content:"\F039"}.van-icon-comment-circle:before{content:"\F03A"}.van-icon-comment-o:before{content:"\F03B"}.van-icon-comment:before{content:"\F03C"}.van-icon-completed:before{content:"\F03D"}.van-icon-contact:before{content:"\F03E"}.van-icon-coupon-o:before{content:"\F03F"}.van-icon-coupon:before{content:"\F040"}.van-icon-credit-pay:before{content:"\F041"}.van-icon-cross:before{content:"\F042"}.van-icon-debit-pay:before{content:"\F043"}.van-icon-delete:before{content:"\F044"}.van-icon-descending:before{content:"\F045"}.van-icon-description:before{content:"\F046"}.van-icon-desktop-o:before{content:"\F047"}.van-icon-diamond-o:before{content:"\F048"}.van-icon-diamond:before{content:"\F049"}.van-icon-discount:before{content:"\F04A"}.van-icon-down:before{content:"\F04B"}.van-icon-ecard-pay:before{content:"\F04C"}.van-icon-edit:before{content:"\F04D"}.van-icon-ellipsis:before{content:"\F04E"}.van-icon-empty:before{content:"\F04F"}.van-icon-enlarge:before{content:"\F0E4"}.van-icon-envelop-o:before{content:"\F050"}.van-icon-exchange:before{content:"\F051"}.van-icon-expand-o:before{content:"\F052"}.van-icon-expand:before{content:"\F053"}.van-icon-eye-o:before{content:"\F054"}.van-icon-eye:before{content:"\F055"}.van-icon-fail:before{content:"\F056"}.van-icon-failure:before{content:"\F057"}.van-icon-filter-o:before{content:"\F058"}.van-icon-fire-o:before{content:"\F059"}.van-icon-fire:before{content:"\F05A"}.van-icon-flag-o:before{content:"\F05B"}.van-icon-flower-o:before{content:"\F05C"}.van-icon-free-postage:before{content:"\F05D"}.van-icon-friends-o:before{content:"\F05E"}.van-icon-friends:before{content:"\F05F"}.van-icon-gem-o:before{content:"\F060"}.van-icon-gem:before{content:"\F061"}.van-icon-gift-card-o:before{content:"\F062"}.van-icon-gift-card:before{content:"\F063"}.van-icon-gift-o:before{content:"\F064"}.van-icon-gift:before{content:"\F065"}.van-icon-gold-coin-o:before{content:"\F066"}.van-icon-gold-coin:before{content:"\F067"}.van-icon-good-job-o:before{content:"\F068"}.van-icon-good-job:before{content:"\F069"}.van-icon-goods-collect-o:before{content:"\F06A"}.van-icon-goods-collect:before{content:"\F06B"}.van-icon-graphic:before{content:"\F06C"}.van-icon-home-o:before{content:"\F06D"}.van-icon-hot-o:before{content:"\F06E"}.van-icon-hot-sale-o:before{content:"\F06F"}.van-icon-hot-sale:before{content:"\F070"}.van-icon-hot:before{content:"\F071"}.van-icon-hotel-o:before{content:"\F072"}.van-icon-idcard:before{content:"\F073"}.van-icon-info-o:before{content:"\F074"}.van-icon-info:before{content:"\F075"}.van-icon-invition:before{content:"\F076"}.van-icon-label-o:before{content:"\F077"}.van-icon-label:before{content:"\F078"}.van-icon-like-o:before{content:"\F079"}.van-icon-like:before{content:"\F07A"}.van-icon-live:before{content:"\F07B"}.van-icon-location-o:before{content:"\F07C"}.van-icon-location:before{content:"\F07D"}.van-icon-lock:before{content:"\F07E"}.van-icon-logistics:before{content:"\F07F"}.van-icon-manager-o:before{content:"\F080"}.van-icon-manager:before{content:"\F081"}.van-icon-map-marked:before{content:"\F082"}.van-icon-medal-o:before{content:"\F083"}.van-icon-medal:before{content:"\F084"}.van-icon-minus:before{content:"\F0E8"}.van-icon-more-o:before{content:"\F085"}.van-icon-more:before{content:"\F086"}.van-icon-music-o:before{content:"\F087"}.van-icon-music:before{content:"\F088"}.van-icon-new-arrival-o:before{content:"\F089"}.van-icon-new-arrival:before{content:"\F08A"}.van-icon-new-o:before{content:"\F08B"}.van-icon-new:before{content:"\F08C"}.van-icon-newspaper-o:before{content:"\F08D"}.van-icon-notes-o:before{content:"\F08E"}.van-icon-orders-o:before{content:"\F08F"}.van-icon-other-pay:before{content:"\F090"}.van-icon-paid:before{content:"\F091"}.van-icon-passed:before{content:"\F092"}.van-icon-pause-circle-o:before{content:"\F093"}.van-icon-pause-circle:before{content:"\F094"}.van-icon-pause:before{content:"\F095"}.van-icon-peer-pay:before{content:"\F096"}.van-icon-pending-payment:before{content:"\F097"}.van-icon-phone-circle-o:before{content:"\F098"}.van-icon-phone-circle:before{content:"\F099"}.van-icon-phone-o:before{content:"\F09A"}.van-icon-phone:before{content:"\F09B"}.van-icon-photo-fail:before{content:"\F0E5"}.van-icon-photo-o:before{content:"\F09C"}.van-icon-photo:before{content:"\F09D"}.van-icon-photograph:before{content:"\F09E"}.van-icon-play-circle-o:before{content:"\F09F"}.van-icon-play-circle:before{content:"\F0A0"}.van-icon-play:before{content:"\F0A1"}.van-icon-plus:before{content:"\F0A2"}.van-icon-point-gift-o:before{content:"\F0A3"}.van-icon-point-gift:before{content:"\F0A4"}.van-icon-points:before{content:"\F0A5"}.van-icon-printer:before{content:"\F0A6"}.van-icon-qr-invalid:before{content:"\F0A7"}.van-icon-qr:before{content:"\F0A8"}.van-icon-question-o:before{content:"\F0A9"}.van-icon-question:before{content:"\F0AA"}.van-icon-records:before{content:"\F0AB"}.van-icon-refund-o:before{content:"\F0AC"}.van-icon-replay:before{content:"\F0AD"}.van-icon-scan:before{content:"\F0AE"}.van-icon-search:before{content:"\F0AF"}.van-icon-send-gift-o:before{content:"\F0B0"}.van-icon-send-gift:before{content:"\F0B1"}.van-icon-service-o:before{content:"\F0B2"}.van-icon-service:before{content:"\F0B3"}.van-icon-setting-o:before{content:"\F0B4"}.van-icon-setting:before{content:"\F0B5"}.van-icon-share-o:before{content:"\F0E7"}.van-icon-share:before{content:"\F0B6"}.van-icon-shop-collect-o:before{content:"\F0B7"}.van-icon-shop-collect:before{content:"\F0B8"}.van-icon-shop-o:before{content:"\F0B9"}.van-icon-shop:before{content:"\F0BA"}.van-icon-shopping-cart-o:before{content:"\F0BB"}.van-icon-shopping-cart:before{content:"\F0BC"}.van-icon-shrink:before{content:"\F0BD"}.van-icon-sign:before{content:"\F0BE"}.van-icon-smile-comment-o:before{content:"\F0BF"}.van-icon-smile-comment:before{content:"\F0C0"}.van-icon-smile-o:before{content:"\F0C1"}.van-icon-smile:before{content:"\F0C2"}.van-icon-star-o:before{content:"\F0C3"}.van-icon-star:before{content:"\F0C4"}.van-icon-stop-circle-o:before{content:"\F0C5"}.van-icon-stop-circle:before{content:"\F0C6"}.van-icon-stop:before{content:"\F0C7"}.van-icon-success:before{content:"\F0C8"}.van-icon-thumb-circle-o:before{content:"\F0C9"}.van-icon-thumb-circle:before{content:"\F0CA"}.van-icon-todo-list-o:before{content:"\F0CB"}.van-icon-todo-list:before{content:"\F0CC"}.van-icon-tosend:before{content:"\F0CD"}.van-icon-tv-o:before{content:"\F0CE"}.van-icon-umbrella-circle:before{content:"\F0CF"}.van-icon-underway-o:before{content:"\F0D0"}.van-icon-underway:before{content:"\F0D1"}.van-icon-upgrade:before{content:"\F0D2"}.van-icon-user-circle-o:before{content:"\F0D3"}.van-icon-user-o:before{content:"\F0D4"}.van-icon-video-o:before{content:"\F0D5"}.van-icon-video:before{content:"\F0D6"}.van-icon-vip-card-o:before{content:"\F0D7"}.van-icon-vip-card:before{content:"\F0D8"}.van-icon-volume-o:before{content:"\F0D9"}.van-icon-volume:before{content:"\F0DA"}.van-icon-wap-home-o:before{content:"\F0DB"}.van-icon-wap-home:before{content:"\F0DC"}.van-icon-wap-nav:before{content:"\F0DD"}.van-icon-warn-o:before{content:"\F0DE"}.van-icon-warning-o:before{content:"\F0DF"}.van-icon-warning:before{content:"\F0E0"}.van-icon-weapp-nav:before{content:"\F0E1"}.van-icon-wechat:before{content:"\F0E2"}.van-icon-youzan-shield:before{content:"\F0E3"}:host{display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.van-icon--image{width:1em;height:1em}.van-icon__image{width:100%;height:100%}.van-icon__info{z-index:1} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/image/index.js b/miniprogram_npm/@vant/weapp/image/index.js new file mode 100644 index 0000000..e3348d9 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/image/index.js @@ -0,0 +1,106 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var utils_1 = require('../common/utils'); +var component_1 = require('../common/component'); +var button_1 = require('../mixins/button'); +var open_type_1 = require('../mixins/open-type'); +var FIT_MODE_MAP = { + none: 'center', + fill: 'scaleToFill', + cover: 'aspectFill', + contain: 'aspectFit', + widthFix: 'widthFix', + heightFix: 'heightFix', +}; +component_1.VantComponent({ + mixins: [button_1.button, open_type_1.openType], + classes: ['custom-class', 'loading-class', 'error-class', 'image-class'], + props: { + src: { + type: String, + observer: function () { + this.setData({ + error: false, + loading: true, + }); + }, + }, + round: Boolean, + width: { + type: null, + observer: 'setStyle', + }, + height: { + type: null, + observer: 'setStyle', + }, + radius: null, + lazyLoad: Boolean, + useErrorSlot: Boolean, + useLoadingSlot: Boolean, + showMenuByLongpress: Boolean, + fit: { + type: String, + value: 'fill', + observer: 'setMode', + }, + showError: { + type: Boolean, + value: true, + }, + showLoading: { + type: Boolean, + value: true, + }, + }, + data: { + error: false, + loading: true, + viewStyle: '', + }, + mounted: function () { + this.setMode(); + this.setStyle(); + }, + methods: { + setMode: function () { + this.setData({ + mode: FIT_MODE_MAP[this.data.fit], + }); + }, + setStyle: function () { + var _a = this.data, + width = _a.width, + height = _a.height, + radius = _a.radius; + var style = ''; + if (utils_1.isDef(width)) { + style += 'width: ' + utils_1.addUnit(width) + ';'; + } + if (utils_1.isDef(height)) { + style += 'height: ' + utils_1.addUnit(height) + ';'; + } + if (utils_1.isDef(radius)) { + style += 'overflow: hidden;'; + style += 'border-radius: ' + utils_1.addUnit(radius) + ';'; + } + this.setData({ viewStyle: style }); + }, + onLoad: function (event) { + this.setData({ + loading: false, + }); + this.$emit('load', event.detail); + }, + onError: function (event) { + this.setData({ + loading: false, + error: true, + }); + this.$emit('error', event.detail); + }, + onClick: function (event) { + this.$emit('click', event.detail); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/image/index.json b/miniprogram_npm/@vant/weapp/image/index.json new file mode 100644 index 0000000..e00a588 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/image/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index", + "van-loading": "../loading/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/image/index.wxml b/miniprogram_npm/@vant/weapp/image/index.wxml new file mode 100644 index 0000000..2cccaff --- /dev/null +++ b/miniprogram_npm/@vant/weapp/image/index.wxml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/miniprogram_npm/@vant/weapp/image/index.wxss b/miniprogram_npm/@vant/weapp/image/index.wxss new file mode 100644 index 0000000..4758910 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/image/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-image{position:relative;display:inline-block}.van-image--round{overflow:hidden;border-radius:50%}.van-image--round .van-image__img{border-radius:inherit}.van-image__error,.van-image__img,.van-image__loading{display:block;width:100%;height:100%}.van-image__error,.van-image__loading{position:absolute;top:0;left:0;display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;color:#969799;color:var(--image-placeholder-text-color,#969799);font-size:14px;font-size:var(--image-placeholder-font-size,14px);background-color:#f7f8fa;background-color:var(--image-placeholder-background-color,#f7f8fa)}.van-image__loading-icon{color:#dcdee0;color:var(--image-loading-icon-color,#dcdee0);font-size:32px!important;font-size:var(--image-loading-icon-size,32px)!important}.van-image__error-icon{color:#dcdee0;color:var(--image-error-icon-color,#dcdee0);font-size:32px!important;font-size:var(--image-error-icon-size,32px)!important} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/index-anchor/index.js b/miniprogram_npm/@vant/weapp/index-anchor/index.js new file mode 100644 index 0000000..89fcf9d --- /dev/null +++ b/miniprogram_npm/@vant/weapp/index-anchor/index.js @@ -0,0 +1,33 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +component_1.VantComponent({ + relation: { + name: 'index-bar', + type: 'ancestor', + current: 'index-anchor', + }, + props: { + useSlot: Boolean, + index: null, + }, + data: { + active: false, + wrapperStyle: '', + anchorStyle: '', + }, + methods: { + scrollIntoView: function (scrollTop) { + var _this = this; + this.getBoundingClientRect().then(function (rect) { + wx.pageScrollTo({ + duration: 0, + scrollTop: scrollTop + rect.top - _this.parent.data.stickyOffsetTop, + }); + }); + }, + getBoundingClientRect: function () { + return this.getRect('.van-index-anchor-wrapper'); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/index-anchor/index.json b/miniprogram_npm/@vant/weapp/index-anchor/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/index-anchor/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram_npm/@vant/weapp/index-anchor/index.wxml b/miniprogram_npm/@vant/weapp/index-anchor/index.wxml new file mode 100644 index 0000000..49affa7 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/index-anchor/index.wxml @@ -0,0 +1,14 @@ + + + + + {{ index }} + + + diff --git a/miniprogram_npm/@vant/weapp/index-anchor/index.wxss b/miniprogram_npm/@vant/weapp/index-anchor/index.wxss new file mode 100644 index 0000000..b8c3c0a --- /dev/null +++ b/miniprogram_npm/@vant/weapp/index-anchor/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-index-anchor{padding:0 16px;padding:var(--index-anchor-padding,0 16px);color:#323233;color:var(--index-anchor-text-color,#323233);font-weight:500;font-weight:var(--index-anchor-font-weight,500);font-size:14px;font-size:var(--index-anchor-font-size,14px);line-height:32px;line-height:var(--index-anchor-line-height,32px);background-color:initial;background-color:var(--index-anchor-background-color,transparent)}.van-index-anchor--active{right:0;left:0;color:#07c160;color:var(--index-anchor-active-text-color,#07c160);background-color:#fff;background-color:var(--index-anchor-active-background-color,#fff)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/index-bar/index.js b/miniprogram_npm/@vant/weapp/index-bar/index.js new file mode 100644 index 0000000..2dd42d0 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/index-bar/index.js @@ -0,0 +1,285 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var color_1 = require('../common/color'); +var component_1 = require('../common/component'); +var utils_1 = require('../common/utils'); +var page_scroll_1 = require('../mixins/page-scroll'); +var indexList = function () { + var indexList = []; + var charCodeOfA = 'A'.charCodeAt(0); + for (var i = 0; i < 26; i++) { + indexList.push(String.fromCharCode(charCodeOfA + i)); + } + return indexList; +}; +component_1.VantComponent({ + relation: { + name: 'index-anchor', + type: 'descendant', + current: 'index-bar', + linked: function () { + this.updateData(); + }, + unlinked: function () { + this.updateData(); + }, + }, + props: { + sticky: { + type: Boolean, + value: true, + }, + zIndex: { + type: Number, + value: 1, + }, + highlightColor: { + type: String, + value: color_1.GREEN, + }, + stickyOffsetTop: { + type: Number, + value: 0, + }, + indexList: { + type: Array, + value: indexList(), + }, + }, + mixins: [ + page_scroll_1.pageScrollMixin(function (event) { + this.scrollTop = + (event === null || event === void 0 ? void 0 : event.scrollTop) || 0; + this.onScroll(); + }), + ], + data: { + activeAnchorIndex: null, + showSidebar: false, + }, + created: function () { + this.scrollTop = 0; + }, + methods: { + updateData: function () { + var _this = this; + wx.nextTick(function () { + if (_this.timer != null) { + clearTimeout(_this.timer); + } + _this.timer = setTimeout(function () { + _this.setData({ + showSidebar: !!_this.children.length, + }); + _this.setRect().then(function () { + _this.onScroll(); + }); + }, 0); + }); + }, + setRect: function () { + return Promise.all([ + this.setAnchorsRect(), + this.setListRect(), + this.setSiderbarRect(), + ]); + }, + setAnchorsRect: function () { + var _this = this; + return Promise.all( + this.children.map(function (anchor) { + return utils_1.getRect + .call(anchor, '.van-index-anchor-wrapper') + .then(function (rect) { + Object.assign(anchor, { + height: rect.height, + top: rect.top + _this.scrollTop, + }); + }); + }) + ); + }, + setListRect: function () { + var _this = this; + return utils_1.getRect.call(this, '.van-index-bar').then(function (rect) { + Object.assign(_this, { + height: rect.height, + top: rect.top + _this.scrollTop, + }); + }); + }, + setSiderbarRect: function () { + var _this = this; + return utils_1.getRect + .call(this, '.van-index-bar__sidebar') + .then(function (res) { + _this.sidebar = { + height: res.height, + top: res.top, + }; + }); + }, + setDiffData: function (_a) { + var target = _a.target, + data = _a.data; + var diffData = {}; + Object.keys(data).forEach(function (key) { + if (target.data[key] !== data[key]) { + diffData[key] = data[key]; + } + }); + if (Object.keys(diffData).length) { + target.setData(diffData); + } + }, + getAnchorRect: function (anchor) { + return utils_1.getRect + .call(anchor, '.van-index-anchor-wrapper') + .then(function (rect) { + return { + height: rect.height, + top: rect.top, + }; + }); + }, + getActiveAnchorIndex: function () { + var _a = this, + children = _a.children, + scrollTop = _a.scrollTop; + var _b = this.data, + sticky = _b.sticky, + stickyOffsetTop = _b.stickyOffsetTop; + for (var i = this.children.length - 1; i >= 0; i--) { + var preAnchorHeight = i > 0 ? children[i - 1].height : 0; + var reachTop = sticky ? preAnchorHeight + stickyOffsetTop : 0; + if (reachTop + scrollTop >= children[i].top) { + return i; + } + } + return -1; + }, + onScroll: function () { + var _this = this; + var _a = this, + _b = _a.children, + children = _b === void 0 ? [] : _b, + scrollTop = _a.scrollTop; + if (!children.length) { + return; + } + var _c = this.data, + sticky = _c.sticky, + stickyOffsetTop = _c.stickyOffsetTop, + zIndex = _c.zIndex, + highlightColor = _c.highlightColor; + var active = this.getActiveAnchorIndex(); + this.setDiffData({ + target: this, + data: { + activeAnchorIndex: active, + }, + }); + if (sticky) { + var isActiveAnchorSticky_1 = false; + if (active !== -1) { + isActiveAnchorSticky_1 = + children[active].top <= stickyOffsetTop + scrollTop; + } + children.forEach(function (item, index) { + if (index === active) { + var wrapperStyle = ''; + var anchorStyle = + '\n color: ' + highlightColor + ';\n '; + if (isActiveAnchorSticky_1) { + wrapperStyle = + '\n height: ' + + children[index].height + + 'px;\n '; + anchorStyle = + '\n position: fixed;\n top: ' + + stickyOffsetTop + + 'px;\n z-index: ' + + zIndex + + ';\n color: ' + + highlightColor + + ';\n '; + } + _this.setDiffData({ + target: item, + data: { + active: true, + anchorStyle: anchorStyle, + wrapperStyle: wrapperStyle, + }, + }); + } else if (index === active - 1) { + var currentAnchor = children[index]; + var currentOffsetTop = currentAnchor.top; + var targetOffsetTop = + index === children.length - 1 + ? _this.top + : children[index + 1].top; + var parentOffsetHeight = targetOffsetTop - currentOffsetTop; + var translateY = parentOffsetHeight - currentAnchor.height; + var anchorStyle = + '\n position: relative;\n transform: translate3d(0, ' + + translateY + + 'px, 0);\n z-index: ' + + zIndex + + ';\n color: ' + + highlightColor + + ';\n '; + _this.setDiffData({ + target: item, + data: { + active: true, + anchorStyle: anchorStyle, + }, + }); + } else { + _this.setDiffData({ + target: item, + data: { + active: false, + anchorStyle: '', + wrapperStyle: '', + }, + }); + } + }); + } + }, + onClick: function (event) { + this.scrollToAnchor(event.target.dataset.index); + }, + onTouchMove: function (event) { + var sidebarLength = this.children.length; + var touch = event.touches[0]; + var itemHeight = this.sidebar.height / sidebarLength; + var index = Math.floor((touch.clientY - this.sidebar.top) / itemHeight); + if (index < 0) { + index = 0; + } else if (index > sidebarLength - 1) { + index = sidebarLength - 1; + } + this.scrollToAnchor(index); + }, + onTouchStop: function () { + this.scrollToAnchorIndex = null; + }, + scrollToAnchor: function (index) { + var _this = this; + if (typeof index !== 'number' || this.scrollToAnchorIndex === index) { + return; + } + this.scrollToAnchorIndex = index; + var anchor = this.children.find(function (item) { + return item.data.index === _this.data.indexList[index]; + }); + if (anchor) { + anchor.scrollIntoView(this.scrollTop); + this.$emit('select', anchor.data.index); + } + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/index-bar/index.json b/miniprogram_npm/@vant/weapp/index-bar/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/index-bar/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram_npm/@vant/weapp/index-bar/index.wxml b/miniprogram_npm/@vant/weapp/index-bar/index.wxml new file mode 100644 index 0000000..19a59cf --- /dev/null +++ b/miniprogram_npm/@vant/weapp/index-bar/index.wxml @@ -0,0 +1,22 @@ + + + + + + {{ item }} + + + diff --git a/miniprogram_npm/@vant/weapp/index-bar/index.wxss b/miniprogram_npm/@vant/weapp/index-bar/index.wxss new file mode 100644 index 0000000..dba5dc0 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/index-bar/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-index-bar{position:relative}.van-index-bar__sidebar{position:fixed;top:50%;right:0;display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;text-align:center;-webkit-transform:translateY(-50%);transform:translateY(-50%);-webkit-user-select:none;user-select:none}.van-index-bar__index{font-weight:500;padding:0 4px 0 16px;padding:0 var(--padding-base,4px) 0 var(--padding-md,16px);font-size:10px;font-size:var(--index-bar-index-font-size,10px);line-height:14px;line-height:var(--index-bar-index-line-height,14px)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/info/index.js b/miniprogram_npm/@vant/weapp/info/index.js new file mode 100644 index 0000000..a08ad2c --- /dev/null +++ b/miniprogram_npm/@vant/weapp/info/index.js @@ -0,0 +1,10 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +component_1.VantComponent({ + props: { + dot: Boolean, + info: null, + customStyle: String, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/info/index.json b/miniprogram_npm/@vant/weapp/info/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/info/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram_npm/@vant/weapp/info/index.wxml b/miniprogram_npm/@vant/weapp/info/index.wxml new file mode 100644 index 0000000..3112dfc --- /dev/null +++ b/miniprogram_npm/@vant/weapp/info/index.wxml @@ -0,0 +1,7 @@ + + +{{ dot ? '' : info }} diff --git a/miniprogram_npm/@vant/weapp/info/index.wxss b/miniprogram_npm/@vant/weapp/info/index.wxss new file mode 100644 index 0000000..2994df8 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/info/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-info{position:absolute;top:0;right:0;display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;white-space:nowrap;text-align:center;-webkit-transform:translate(50%,-50%);transform:translate(50%,-50%);-webkit-transform-origin:100%;transform-origin:100%;height:16px;height:var(--info-size,16px);min-width:16px;min-width:var(--info-size,16px);padding:0 3px;padding:var(--info-padding,0 3px);color:#fff;color:var(--info-color,#fff);font-weight:500;font-weight:var(--info-font-weight,500);font-size:12px;font-size:var(--info-font-size,12px);font-family:-apple-system-font,Helvetica Neue,Arial,sans-serif;font-family:var(--info-font-family,-apple-system-font,Helvetica Neue,Arial,sans-serif);background-color:#ee0a24;background-color:var(--info-background-color,#ee0a24);border:1px solid #fff;border:var(--info-border-width,1px) solid var(--white,#fff);border-radius:16px;border-radius:var(--info-size,16px)}.van-info--dot{min-width:0;border-radius:100%;width:8px;width:var(--info-dot-size,8px);height:8px;height:var(--info-dot-size,8px);background-color:#ee0a24;background-color:var(--info-dot-color,#ee0a24)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/loading/index.js b/miniprogram_npm/@vant/weapp/loading/index.js new file mode 100644 index 0000000..5aa2a81 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/loading/index.js @@ -0,0 +1,18 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +component_1.VantComponent({ + props: { + color: String, + vertical: Boolean, + type: { + type: String, + value: 'circular', + }, + size: String, + textSize: String, + }, + data: { + array12: Array.from({ length: 12 }), + }, +}); diff --git a/miniprogram_npm/@vant/weapp/loading/index.json b/miniprogram_npm/@vant/weapp/loading/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/loading/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram_npm/@vant/weapp/loading/index.wxml b/miniprogram_npm/@vant/weapp/loading/index.wxml new file mode 100644 index 0000000..e934288 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/loading/index.wxml @@ -0,0 +1,18 @@ + + + + + + + + + + diff --git a/miniprogram_npm/@vant/weapp/loading/index.wxss b/miniprogram_npm/@vant/weapp/loading/index.wxss new file mode 100644 index 0000000..f28a6b4 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/loading/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';:host{font-size:0;line-height:1}.van-loading{display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;color:#c8c9cc;color:var(--loading-spinner-color,#c8c9cc)}.van-loading__spinner{position:relative;box-sizing:border-box;width:30px;width:var(--loading-spinner-size,30px);max-width:100%;max-height:100%;height:30px;height:var(--loading-spinner-size,30px);-webkit-animation:van-rotate .8s linear infinite;animation:van-rotate .8s linear infinite;-webkit-animation:van-rotate var(--loading-spinner-animation-duration,.8s) linear infinite;animation:van-rotate var(--loading-spinner-animation-duration,.8s) linear infinite}.van-loading__spinner--spinner{-webkit-animation-timing-function:steps(12);animation-timing-function:steps(12)}.van-loading__spinner--circular{border:1px solid transparent;border-top-color:initial;border-radius:100%}.van-loading__text{margin-left:8px;margin-left:var(--padding-xs,8px);color:#969799;color:var(--loading-text-color,#969799);font-size:14px;font-size:var(--loading-text-font-size,14px);line-height:20px;line-height:var(--loading-text-line-height,20px)}.van-loading__text:empty{display:none}.van-loading--vertical{-webkit-flex-direction:column;flex-direction:column}.van-loading--vertical .van-loading__text{margin:8px 0 0;margin:var(--padding-xs,8px) 0 0}.van-loading__dot{position:absolute;top:0;left:0;width:100%;height:100%}.van-loading__dot:before{display:block;width:2px;height:25%;margin:0 auto;background-color:currentColor;border-radius:40%;content:" "}.van-loading__dot:first-of-type{-webkit-transform:rotate(30deg);transform:rotate(30deg);opacity:1}.van-loading__dot:nth-of-type(2){-webkit-transform:rotate(60deg);transform:rotate(60deg);opacity:.9375}.van-loading__dot:nth-of-type(3){-webkit-transform:rotate(90deg);transform:rotate(90deg);opacity:.875}.van-loading__dot:nth-of-type(4){-webkit-transform:rotate(120deg);transform:rotate(120deg);opacity:.8125}.van-loading__dot:nth-of-type(5){-webkit-transform:rotate(150deg);transform:rotate(150deg);opacity:.75}.van-loading__dot:nth-of-type(6){-webkit-transform:rotate(180deg);transform:rotate(180deg);opacity:.6875}.van-loading__dot:nth-of-type(7){-webkit-transform:rotate(210deg);transform:rotate(210deg);opacity:.625}.van-loading__dot:nth-of-type(8){-webkit-transform:rotate(240deg);transform:rotate(240deg);opacity:.5625}.van-loading__dot:nth-of-type(9){-webkit-transform:rotate(270deg);transform:rotate(270deg);opacity:.5}.van-loading__dot:nth-of-type(10){-webkit-transform:rotate(300deg);transform:rotate(300deg);opacity:.4375}.van-loading__dot:nth-of-type(11){-webkit-transform:rotate(330deg);transform:rotate(330deg);opacity:.375}.van-loading__dot:nth-of-type(12){-webkit-transform:rotate(1turn);transform:rotate(1turn);opacity:.3125}@-webkit-keyframes van-rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes van-rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/mixins/basic.js b/miniprogram_npm/@vant/weapp/mixins/basic.js new file mode 100644 index 0000000..70c2791 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/mixins/basic.js @@ -0,0 +1,33 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +exports.basic = void 0; +exports.basic = Behavior({ + methods: { + $emit: function (name, detail, options) { + this.triggerEvent(name, detail, options); + }, + set: function (data, callback) { + this.setData(data, callback); + return new Promise(function (resolve) { + return wx.nextTick(resolve); + }); + }, + getRect: function (selector, all) { + var _this = this; + return new Promise(function (resolve) { + wx.createSelectorQuery() + .in(_this) + [all ? 'selectAll' : 'select'](selector) + .boundingClientRect(function (rect) { + if (all && Array.isArray(rect) && rect.length) { + resolve(rect); + } + if (!all && rect) { + resolve(rect); + } + }) + .exec(); + }); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/mixins/button.js b/miniprogram_npm/@vant/weapp/mixins/button.js new file mode 100644 index 0000000..8de45e9 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/mixins/button.js @@ -0,0 +1,18 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +exports.button = void 0; +exports.button = Behavior({ + externalClasses: ['hover-class'], + properties: { + id: String, + lang: String, + businessId: Number, + sessionFrom: String, + sendMessageTitle: String, + sendMessagePath: String, + sendMessageImg: String, + showMessageCard: Boolean, + appParameter: String, + ariaLabel: String, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/mixins/link.js b/miniprogram_npm/@vant/weapp/mixins/link.js new file mode 100644 index 0000000..cbd2745 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/mixins/link.js @@ -0,0 +1,23 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +exports.link = void 0; +exports.link = Behavior({ + properties: { + url: String, + linkType: { + type: String, + value: 'navigateTo', + }, + }, + methods: { + jumpLink: function (urlKey) { + if (urlKey === void 0) { + urlKey = 'url'; + } + var url = this.data[urlKey]; + if (url) { + wx[this.data.linkType]({ url: url }); + } + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/mixins/open-type.js b/miniprogram_npm/@vant/weapp/mixins/open-type.js new file mode 100644 index 0000000..45e6155 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/mixins/open-type.js @@ -0,0 +1,29 @@ +'use strict'; +// @ts-nocheck +Object.defineProperty(exports, '__esModule', { value: true }); +exports.openType = void 0; +exports.openType = Behavior({ + properties: { + openType: String, + }, + methods: { + bindGetUserInfo: function (event) { + this.$emit('getuserinfo', event.detail); + }, + bindContact: function (event) { + this.$emit('contact', event.detail); + }, + bindGetPhoneNumber: function (event) { + this.$emit('getphonenumber', event.detail); + }, + bindError: function (event) { + this.$emit('error', event.detail); + }, + bindLaunchApp: function (event) { + this.$emit('launchapp', event.detail); + }, + bindOpenSetting: function (event) { + this.$emit('opensetting', event.detail); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/mixins/page-scroll.js b/miniprogram_npm/@vant/weapp/mixins/page-scroll.js new file mode 100644 index 0000000..433bfa2 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/mixins/page-scroll.js @@ -0,0 +1,41 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +exports.pageScrollMixin = void 0; +function getCurrentPage() { + var pages = getCurrentPages(); + return pages[pages.length - 1] || {}; +} +function onPageScroll(event) { + var _a = getCurrentPage().vanPageScroller, + vanPageScroller = _a === void 0 ? [] : _a; + vanPageScroller.forEach(function (scroller) { + if (typeof scroller === 'function') { + // @ts-ignore + scroller(event); + } + }); +} +exports.pageScrollMixin = function (scroller) { + return Behavior({ + attached: function () { + var page = getCurrentPage(); + if (Array.isArray(page.vanPageScroller)) { + page.vanPageScroller.push(scroller.bind(this)); + } else { + page.vanPageScroller = + typeof page.onPageScroll === 'function' + ? [page.onPageScroll.bind(page), scroller.bind(this)] + : [scroller.bind(this)]; + } + page.onPageScroll = onPageScroll; + }, + detached: function () { + var page = getCurrentPage(); + page.vanPageScroller = (page.vanPageScroller || []).filter(function ( + item + ) { + return item !== scroller; + }); + }, + }); +}; diff --git a/miniprogram_npm/@vant/weapp/mixins/touch.js b/miniprogram_npm/@vant/weapp/mixins/touch.js new file mode 100644 index 0000000..9c6da11 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/mixins/touch.js @@ -0,0 +1,40 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +exports.touch = void 0; +// @ts-nocheck +var MIN_DISTANCE = 10; +function getDirection(x, y) { + if (x > y && x > MIN_DISTANCE) { + return 'horizontal'; + } + if (y > x && y > MIN_DISTANCE) { + return 'vertical'; + } + return ''; +} +exports.touch = Behavior({ + methods: { + resetTouchStatus: function () { + this.direction = ''; + this.deltaX = 0; + this.deltaY = 0; + this.offsetX = 0; + this.offsetY = 0; + }, + touchStart: function (event) { + this.resetTouchStatus(); + var touch = event.touches[0]; + this.startX = touch.clientX; + this.startY = touch.clientY; + }, + touchMove: function (event) { + var touch = event.touches[0]; + this.deltaX = touch.clientX - this.startX; + this.deltaY = touch.clientY - this.startY; + this.offsetX = Math.abs(this.deltaX); + this.offsetY = Math.abs(this.deltaY); + this.direction = + this.direction || getDirection(this.offsetX, this.offsetY); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/mixins/transition.js b/miniprogram_npm/@vant/weapp/mixins/transition.js new file mode 100644 index 0000000..403799c --- /dev/null +++ b/miniprogram_npm/@vant/weapp/mixins/transition.js @@ -0,0 +1,146 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +exports.transition = void 0; +// @ts-nocheck +var utils_1 = require('../common/utils'); +var getClassNames = function (name) { + return { + enter: + 'van-' + + name + + '-enter van-' + + name + + '-enter-active enter-class enter-active-class', + 'enter-to': + 'van-' + + name + + '-enter-to van-' + + name + + '-enter-active enter-to-class enter-active-class', + leave: + 'van-' + + name + + '-leave van-' + + name + + '-leave-active leave-class leave-active-class', + 'leave-to': + 'van-' + + name + + '-leave-to van-' + + name + + '-leave-active leave-to-class leave-active-class', + }; +}; +function transition(showDefaultValue) { + return Behavior({ + properties: { + customStyle: String, + // @ts-ignore + show: { + type: Boolean, + value: showDefaultValue, + observer: 'observeShow', + }, + // @ts-ignore + duration: { + type: null, + value: 300, + observer: 'observeDuration', + }, + name: { + type: String, + value: 'fade', + }, + }, + data: { + type: '', + inited: false, + display: false, + }, + methods: { + observeShow: function (value, old) { + if (value === old) { + return; + } + value ? this.enter() : this.leave(); + }, + enter: function () { + var _this = this; + var _a = this.data, + duration = _a.duration, + name = _a.name; + var classNames = getClassNames(name); + var currentDuration = utils_1.isObj(duration) + ? duration.enter + : duration; + this.status = 'enter'; + this.$emit('before-enter'); + utils_1.requestAnimationFrame(function () { + _this.checkStatus('enter'); + _this.$emit('enter'); + _this.setData({ + inited: true, + display: true, + classes: classNames.enter, + currentDuration: currentDuration, + }); + utils_1.requestAnimationFrame(function () { + _this.checkStatus('enter'); + _this.transitionEnded = false; + _this.setData({ classes: classNames['enter-to'] }); + }); + }); + }, + leave: function () { + var _this = this; + if (!this.data.display) { + return; + } + var _a = this.data, + duration = _a.duration, + name = _a.name; + var classNames = getClassNames(name); + var currentDuration = utils_1.isObj(duration) + ? duration.leave + : duration; + this.status = 'leave'; + this.$emit('before-leave'); + utils_1.requestAnimationFrame(function () { + _this.checkStatus('leave'); + _this.$emit('leave'); + _this.setData({ + classes: classNames.leave, + currentDuration: currentDuration, + }); + utils_1.requestAnimationFrame(function () { + _this.checkStatus('leave'); + _this.transitionEnded = false; + setTimeout(function () { + return _this.onTransitionEnd(); + }, currentDuration); + _this.setData({ classes: classNames['leave-to'] }); + }); + }); + }, + checkStatus: function (status) { + if (status !== this.status) { + throw new Error('incongruent status: ' + status); + } + }, + onTransitionEnd: function () { + if (this.transitionEnded) { + return; + } + this.transitionEnded = true; + this.$emit('after-' + this.status); + var _a = this.data, + show = _a.show, + display = _a.display; + if (!show && display) { + this.setData({ display: false }); + } + }, + }, + }); +} +exports.transition = transition; diff --git a/miniprogram_npm/@vant/weapp/nav-bar/index.js b/miniprogram_npm/@vant/weapp/nav-bar/index.js new file mode 100644 index 0000000..2627de4 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/nav-bar/index.js @@ -0,0 +1,66 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +var utils_1 = require('../common/utils'); +component_1.VantComponent({ + classes: ['title-class'], + props: { + title: String, + fixed: { + type: Boolean, + observer: 'setHeight', + }, + placeholder: { + type: Boolean, + observer: 'setHeight', + }, + leftText: String, + rightText: String, + customStyle: String, + leftArrow: Boolean, + border: { + type: Boolean, + value: true, + }, + zIndex: { + type: Number, + value: 1, + }, + safeAreaInsetTop: { + type: Boolean, + value: true, + }, + }, + data: { + height: 46, + }, + created: function () { + var statusBarHeight = utils_1.getSystemInfoSync().statusBarHeight; + this.setData({ + statusBarHeight: statusBarHeight, + height: 46 + statusBarHeight, + }); + }, + mounted: function () { + this.setHeight(); + }, + methods: { + onClickLeft: function () { + this.$emit('click-left'); + }, + onClickRight: function () { + this.$emit('click-right'); + }, + setHeight: function () { + var _this = this; + if (!this.data.fixed || !this.data.placeholder) { + return; + } + wx.nextTick(function () { + utils_1.getRect.call(_this, '.van-nav-bar').then(function (res) { + _this.setData({ height: res.height }); + }); + }); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/nav-bar/index.json b/miniprogram_npm/@vant/weapp/nav-bar/index.json new file mode 100644 index 0000000..0a336c0 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/nav-bar/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/nav-bar/index.wxml b/miniprogram_npm/@vant/weapp/nav-bar/index.wxml new file mode 100644 index 0000000..b6405fd --- /dev/null +++ b/miniprogram_npm/@vant/weapp/nav-bar/index.wxml @@ -0,0 +1,42 @@ + + + + + + + + + + + {{ leftText }} + + + + + {{ title }} + + + + {{ rightText }} + + + + diff --git a/miniprogram_npm/@vant/weapp/nav-bar/index.wxs b/miniprogram_npm/@vant/weapp/nav-bar/index.wxs new file mode 100644 index 0000000..6482832 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/nav-bar/index.wxs @@ -0,0 +1,17 @@ +/* eslint-disable */ +function barStyle(data) { + var styles = [ + ['z-index', data.zIndex], + ['padding-top', data.safeAreaInsetTop ? data.statusBarHeight + 'px' : 0], + ]; + + return styles + .map(function (item) { + return item.join(':'); + }) + .join(';'); +} + +module.exports = { + barStyle: barStyle, +}; diff --git a/miniprogram_npm/@vant/weapp/nav-bar/index.wxss b/miniprogram_npm/@vant/weapp/nav-bar/index.wxss new file mode 100644 index 0000000..48e9e3f --- /dev/null +++ b/miniprogram_npm/@vant/weapp/nav-bar/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-nav-bar{position:relative;text-align:center;-webkit-user-select:none;user-select:none;height:46px;height:var(--nav-bar-height,46px);line-height:46px;line-height:var(--nav-bar-height,46px);background-color:#fff;background-color:var(--nav-bar-background-color,#fff)}.van-nav-bar__content{position:relative;height:100%}.van-nav-bar__text{display:inline-block;vertical-align:middle;margin:0 -16px;margin:0 -var(--padding-md,16px);padding:0 16px;padding:0 var(--padding-md,16px);color:#1989fa;color:var(--nav-bar-text-color,#1989fa)}.van-nav-bar__text--hover{background-color:#f2f3f5;background-color:var(--active-color,#f2f3f5)}.van-nav-bar__arrow{vertical-align:middle;font-size:16px!important;font-size:var(--nav-bar-arrow-size,16px)!important;color:#1989fa!important;color:var(--nav-bar-icon-color,#1989fa)!important}.van-nav-bar__arrow+.van-nav-bar__text{margin-left:-20px;padding-left:25px}.van-nav-bar--fixed{position:fixed;top:0;left:0;width:100%}.van-nav-bar__title{max-width:60%;margin:0 auto;color:#323233;color:var(--nav-bar-title-text-color,#323233);font-weight:500;font-weight:var(--font-weight-bold,500);font-size:16px;font-size:var(--nav-bar-title-font-size,16px)}.van-nav-bar__left,.van-nav-bar__right{position:absolute;top:0;bottom:0;display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;font-size:14px;font-size:var(--font-size-md,14px)}.van-nav-bar__left{left:16px;left:var(--padding-md,16px)}.van-nav-bar__right{right:16px;right:var(--padding-md,16px)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/notice-bar/index.js b/miniprogram_npm/@vant/weapp/notice-bar/index.js new file mode 100644 index 0000000..3766245 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/notice-bar/index.js @@ -0,0 +1,137 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +var utils_1 = require('../common/utils'); +component_1.VantComponent({ + props: { + text: { + type: String, + value: '', + observer: function () { + var _this = this; + wx.nextTick(function () { + _this.init(); + }); + }, + }, + mode: { + type: String, + value: '', + }, + url: { + type: String, + value: '', + }, + openType: { + type: String, + value: 'navigate', + }, + delay: { + type: Number, + value: 1, + }, + speed: { + type: Number, + value: 50, + observer: function () { + var _this = this; + wx.nextTick(function () { + _this.init(); + }); + }, + }, + scrollable: { + type: Boolean, + value: true, + }, + leftIcon: { + type: String, + value: '', + }, + color: String, + backgroundColor: String, + background: String, + wrapable: Boolean, + }, + data: { + show: true, + }, + created: function () { + this.resetAnimation = wx.createAnimation({ + duration: 0, + timingFunction: 'linear', + }); + }, + destroyed: function () { + this.timer && clearTimeout(this.timer); + }, + methods: { + init: function () { + var _this = this; + Promise.all([ + utils_1.getRect.call(this, '.van-notice-bar__content'), + utils_1.getRect.call(this, '.van-notice-bar__wrap'), + ]).then(function (rects) { + var contentRect = rects[0], + wrapRect = rects[1]; + if ( + contentRect == null || + wrapRect == null || + !contentRect.width || + !wrapRect.width + ) { + return; + } + var _a = _this.data, + speed = _a.speed, + scrollable = _a.scrollable, + delay = _a.delay; + if (scrollable || wrapRect.width < contentRect.width) { + var duration = (contentRect.width / speed) * 1000; + _this.wrapWidth = wrapRect.width; + _this.contentWidth = contentRect.width; + _this.duration = duration; + _this.animation = wx.createAnimation({ + duration: duration, + timingFunction: 'linear', + delay: delay, + }); + _this.scroll(); + } + }); + }, + scroll: function () { + var _this = this; + this.timer && clearTimeout(this.timer); + this.timer = null; + this.setData({ + animationData: this.resetAnimation + .translateX(this.wrapWidth) + .step() + .export(), + }); + utils_1.requestAnimationFrame(function () { + _this.setData({ + animationData: _this.animation + .translateX(-_this.contentWidth) + .step() + .export(), + }); + }); + this.timer = setTimeout(function () { + _this.scroll(); + }, this.duration); + }, + onClickIcon: function (event) { + if (this.data.mode === 'closeable') { + this.timer && clearTimeout(this.timer); + this.timer = null; + this.setData({ show: false }); + this.$emit('close', event.detail); + } + }, + onClick: function (event) { + this.$emit('click', event); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/notice-bar/index.json b/miniprogram_npm/@vant/weapp/notice-bar/index.json new file mode 100644 index 0000000..0a336c0 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/notice-bar/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/notice-bar/index.wxml b/miniprogram_npm/@vant/weapp/notice-bar/index.wxml new file mode 100644 index 0000000..9228c6b --- /dev/null +++ b/miniprogram_npm/@vant/weapp/notice-bar/index.wxml @@ -0,0 +1,37 @@ + + + + + + + + + {{ text }} + + + + + + + + + diff --git a/miniprogram_npm/@vant/weapp/notice-bar/index.wxss b/miniprogram_npm/@vant/weapp/notice-bar/index.wxss new file mode 100644 index 0000000..6a49858 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/notice-bar/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-notice-bar{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;height:40px;height:var(--notice-bar-height,40px);padding:0 16px;padding:var(--notice-bar-padding,0 16px);font-size:14px;font-size:var(--notice-bar-font-size,14px);color:#ed6a0c;color:var(--notice-bar-text-color,#ed6a0c);line-height:24px;line-height:var(--notice-bar-line-height,24px);background-color:#fffbe8;background-color:var(--notice-bar-background-color,#fffbe8)}.van-notice-bar--withicon{position:relative;padding-right:40px}.van-notice-bar--wrapable{height:auto;padding:8px 16px;padding:var(--notice-bar-wrapable-padding,8px 16px)}.van-notice-bar--wrapable .van-notice-bar__wrap{height:auto}.van-notice-bar--wrapable .van-notice-bar__content{position:relative;white-space:normal}.van-notice-bar__left-icon{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;margin-right:4px;vertical-align:middle}.van-notice-bar__left-icon,.van-notice-bar__right-icon{font-size:16px;font-size:var(--notice-bar-icon-size,16px);min-width:22px;min-width:var(--notice-bar-icon-min-width,22px)}.van-notice-bar__right-icon{position:absolute;top:10px;right:15px}.van-notice-bar__wrap{position:relative;-webkit-flex:1;flex:1;overflow:hidden;height:24px;height:var(--notice-bar-line-height,24px)}.van-notice-bar__content{position:absolute;white-space:nowrap}.van-notice-bar__content.van-ellipsis{max-width:100%} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/notify/index.js b/miniprogram_npm/@vant/weapp/notify/index.js new file mode 100644 index 0000000..69f9d2c --- /dev/null +++ b/miniprogram_npm/@vant/weapp/notify/index.js @@ -0,0 +1,66 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +var color_1 = require('../common/color'); +component_1.VantComponent({ + props: { + message: String, + background: String, + type: { + type: String, + value: 'danger', + }, + color: { + type: String, + value: color_1.WHITE, + }, + duration: { + type: Number, + value: 3000, + }, + zIndex: { + type: Number, + value: 110, + }, + safeAreaInsetTop: { + type: Boolean, + value: false, + }, + top: null, + }, + data: { + show: false, + }, + created: function () { + var statusBarHeight = wx.getSystemInfoSync().statusBarHeight; + this.setData({ statusBarHeight: statusBarHeight }); + }, + methods: { + show: function () { + var _this = this; + var _a = this.data, + duration = _a.duration, + onOpened = _a.onOpened; + clearTimeout(this.timer); + this.setData({ show: true }); + wx.nextTick(onOpened); + if (duration > 0 && duration !== Infinity) { + this.timer = setTimeout(function () { + _this.hide(); + }, duration); + } + }, + hide: function () { + var onClose = this.data.onClose; + clearTimeout(this.timer); + this.setData({ show: false }); + wx.nextTick(onClose); + }, + onTap: function (event) { + var onClick = this.data.onClick; + if (onClick) { + onClick(event.detail); + } + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/notify/index.json b/miniprogram_npm/@vant/weapp/notify/index.json new file mode 100644 index 0000000..c14a65f --- /dev/null +++ b/miniprogram_npm/@vant/weapp/notify/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-transition": "../transition/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/notify/index.wxml b/miniprogram_npm/@vant/weapp/notify/index.wxml new file mode 100644 index 0000000..060d1ba --- /dev/null +++ b/miniprogram_npm/@vant/weapp/notify/index.wxml @@ -0,0 +1,20 @@ + + + + + + {{ message }} + + diff --git a/miniprogram_npm/@vant/weapp/notify/index.wxss b/miniprogram_npm/@vant/weapp/notify/index.wxss new file mode 100644 index 0000000..8a7688b --- /dev/null +++ b/miniprogram_npm/@vant/weapp/notify/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-notify{text-align:center;word-wrap:break-word;padding:6px 15px;padding:var(--notify-padding,6px 15px);font-size:14px;font-size:var(--notify-font-size,14px);line-height:20px;line-height:var(--notify-line-height,20px)}.van-notify__container{position:fixed;top:0;left:0;box-sizing:border-box;width:100%}.van-notify--primary{background-color:#1989fa;background-color:var(--notify-primary-background-color,#1989fa)}.van-notify--success{background-color:#07c160;background-color:var(--notify-success-background-color,#07c160)}.van-notify--danger{background-color:#ee0a24;background-color:var(--notify-danger-background-color,#ee0a24)}.van-notify--warning{background-color:#ff976a;background-color:var(--notify-warning-background-color,#ff976a)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/notify/notify.js b/miniprogram_npm/@vant/weapp/notify/notify.js new file mode 100644 index 0000000..a789af1 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/notify/notify.js @@ -0,0 +1,64 @@ +'use strict'; +var __assign = + (this && this.__assign) || + function () { + __assign = + Object.assign || + function (t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) + if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); + }; +Object.defineProperty(exports, '__esModule', { value: true }); +var color_1 = require('../common/color'); +var defaultOptions = { + selector: '#van-notify', + type: 'danger', + message: '', + background: '', + duration: 3000, + zIndex: 110, + top: 0, + color: color_1.WHITE, + safeAreaInsetTop: false, + onClick: function () {}, + onOpened: function () {}, + onClose: function () {}, +}; +function parseOptions(message) { + if (message == null) { + return {}; + } + return typeof message === 'string' ? { message: message } : message; +} +function getContext() { + var pages = getCurrentPages(); + return pages[pages.length - 1]; +} +function Notify(options) { + options = __assign(__assign({}, defaultOptions), parseOptions(options)); + var context = options.context || getContext(); + var notify = context.selectComponent(options.selector); + delete options.context; + delete options.selector; + if (notify) { + notify.setData(options); + notify.show(); + return notify; + } + console.warn('未找到 van-notify 节点,请确认 selector 及 context 是否正确'); +} +exports.default = Notify; +Notify.clear = function (options) { + options = __assign(__assign({}, defaultOptions), parseOptions(options)); + var context = options.context || getContext(); + var notify = context.selectComponent(options.selector); + if (notify) { + notify.hide(); + } +}; diff --git a/miniprogram_npm/@vant/weapp/overlay/index.js b/miniprogram_npm/@vant/weapp/overlay/index.js new file mode 100644 index 0000000..a0e55eb --- /dev/null +++ b/miniprogram_npm/@vant/weapp/overlay/index.js @@ -0,0 +1,24 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +component_1.VantComponent({ + props: { + show: Boolean, + customStyle: String, + duration: { + type: null, + value: 300, + }, + zIndex: { + type: Number, + value: 1, + }, + }, + methods: { + onClick: function () { + this.$emit('click'); + }, + // for prevent touchmove + noop: function () {}, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/overlay/index.json b/miniprogram_npm/@vant/weapp/overlay/index.json new file mode 100644 index 0000000..c14a65f --- /dev/null +++ b/miniprogram_npm/@vant/weapp/overlay/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-transition": "../transition/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/overlay/index.wxml b/miniprogram_npm/@vant/weapp/overlay/index.wxml new file mode 100644 index 0000000..9212348 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/overlay/index.wxml @@ -0,0 +1,10 @@ + + + diff --git a/miniprogram_npm/@vant/weapp/overlay/index.wxss b/miniprogram_npm/@vant/weapp/overlay/index.wxss new file mode 100644 index 0000000..0f9df0e --- /dev/null +++ b/miniprogram_npm/@vant/weapp/overlay/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-overlay{position:fixed;top:0;left:0;width:100%;height:100%;background-color:rgba(0,0,0,.7);background-color:var(--overlay-background-color,rgba(0,0,0,.7))} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/panel/index.js b/miniprogram_npm/@vant/weapp/panel/index.js new file mode 100644 index 0000000..64f3be5 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/panel/index.js @@ -0,0 +1,12 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +component_1.VantComponent({ + classes: ['header-class', 'footer-class'], + props: { + desc: String, + title: String, + status: String, + useFooterSlot: Boolean, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/panel/index.json b/miniprogram_npm/@vant/weapp/panel/index.json new file mode 100644 index 0000000..0e5425c --- /dev/null +++ b/miniprogram_npm/@vant/weapp/panel/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-cell": "../cell/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/panel/index.wxml b/miniprogram_npm/@vant/weapp/panel/index.wxml new file mode 100644 index 0000000..3f135d2 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/panel/index.wxml @@ -0,0 +1,19 @@ + + + + + + + + + + + + diff --git a/miniprogram_npm/@vant/weapp/panel/index.wxss b/miniprogram_npm/@vant/weapp/panel/index.wxss new file mode 100644 index 0000000..ffd9df9 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/panel/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-panel{background:#fff;background:var(--panel-background-color,#fff)}.van-panel__header-value{color:#ee0a24;color:var(--panel-header-value-color,#ee0a24)}.van-panel__footer{padding:8px 16px;padding:var(--panel-footer-padding,8px 16px)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/picker-column/index.js b/miniprogram_npm/@vant/weapp/picker-column/index.js new file mode 100644 index 0000000..f7f5b93 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/picker-column/index.js @@ -0,0 +1,131 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +var utils_1 = require('../common/utils'); +var DEFAULT_DURATION = 200; +component_1.VantComponent({ + classes: ['active-class'], + props: { + valueKey: String, + className: String, + itemHeight: Number, + visibleItemCount: Number, + initialOptions: { + type: Array, + value: [], + }, + defaultIndex: { + type: Number, + value: 0, + observer: function (value) { + this.setIndex(value); + }, + }, + }, + data: { + startY: 0, + offset: 0, + duration: 0, + startOffset: 0, + options: [], + currentIndex: 0, + }, + created: function () { + var _this = this; + var _a = this.data, + defaultIndex = _a.defaultIndex, + initialOptions = _a.initialOptions; + this.set({ + currentIndex: defaultIndex, + options: initialOptions, + }).then(function () { + _this.setIndex(defaultIndex); + }); + }, + methods: { + getCount: function () { + return this.data.options.length; + }, + onTouchStart: function (event) { + this.setData({ + startY: event.touches[0].clientY, + startOffset: this.data.offset, + duration: 0, + }); + }, + onTouchMove: function (event) { + var data = this.data; + var deltaY = event.touches[0].clientY - data.startY; + this.setData({ + offset: utils_1.range( + data.startOffset + deltaY, + -(this.getCount() * data.itemHeight), + data.itemHeight + ), + }); + }, + onTouchEnd: function () { + var data = this.data; + if (data.offset !== data.startOffset) { + this.setData({ duration: DEFAULT_DURATION }); + var index = utils_1.range( + Math.round(-data.offset / data.itemHeight), + 0, + this.getCount() - 1 + ); + this.setIndex(index, true); + } + }, + onClickItem: function (event) { + var index = event.currentTarget.dataset.index; + this.setIndex(index, true); + }, + adjustIndex: function (index) { + var data = this.data; + var count = this.getCount(); + index = utils_1.range(index, 0, count); + for (var i = index; i < count; i++) { + if (!this.isDisabled(data.options[i])) return i; + } + for (var i = index - 1; i >= 0; i--) { + if (!this.isDisabled(data.options[i])) return i; + } + }, + isDisabled: function (option) { + return utils_1.isObj(option) && option.disabled; + }, + getOptionText: function (option) { + var data = this.data; + return utils_1.isObj(option) && data.valueKey in option + ? option[data.valueKey] + : option; + }, + setIndex: function (index, userAction) { + var _this = this; + var data = this.data; + index = this.adjustIndex(index) || 0; + var offset = -index * data.itemHeight; + if (index !== data.currentIndex) { + return this.set({ offset: offset, currentIndex: index }).then( + function () { + userAction && _this.$emit('change', index); + } + ); + } + return this.set({ offset: offset }); + }, + setValue: function (value) { + var options = this.data.options; + for (var i = 0; i < options.length; i++) { + if (this.getOptionText(options[i]) === value) { + return this.setIndex(i); + } + } + return Promise.resolve(); + }, + getValue: function () { + var data = this.data; + return data.options[data.currentIndex]; + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/picker-column/index.json b/miniprogram_npm/@vant/weapp/picker-column/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/picker-column/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram_npm/@vant/weapp/picker-column/index.wxml b/miniprogram_npm/@vant/weapp/picker-column/index.wxml new file mode 100644 index 0000000..f052ed9 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/picker-column/index.wxml @@ -0,0 +1,22 @@ + + + + + {{ getOptionText(option, valueKey) }} + + diff --git a/miniprogram_npm/@vant/weapp/picker-column/index.wxs b/miniprogram_npm/@vant/weapp/picker-column/index.wxs new file mode 100644 index 0000000..3c8fc68 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/picker-column/index.wxs @@ -0,0 +1,8 @@ +function isObj(x) { + var type = typeof x; + return x !== null && (type === 'object' || type === 'function'); +} + +module.exports = function (option, valueKey) { + return isObj(option) && option[valueKey] != null ? option[valueKey] : option; +} diff --git a/miniprogram_npm/@vant/weapp/picker-column/index.wxss b/miniprogram_npm/@vant/weapp/picker-column/index.wxss new file mode 100644 index 0000000..c5c6910 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/picker-column/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-picker-column{overflow:hidden;text-align:center;color:#000;color:var(--picker-option-text-color,#000);font-size:16px;font-size:var(--picker-option-font-size,16px)}.van-picker-column__item{padding:0 5px}.van-picker-column__item--selected{font-weight:500;font-weight:var(--font-weight-bold,500);color:#323233;color:var(--picker-option-selected-text-color,#323233)}.van-picker-column__item--disabled{opacity:.3;opacity:var(--picker-option-disabled-opacity,.3)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/picker/index.js b/miniprogram_npm/@vant/weapp/picker/index.js new file mode 100644 index 0000000..87b10ed --- /dev/null +++ b/miniprogram_npm/@vant/weapp/picker/index.js @@ -0,0 +1,175 @@ +'use strict'; +var __assign = + (this && this.__assign) || + function () { + __assign = + Object.assign || + function (t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) + if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); + }; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +var shared_1 = require('./shared'); +component_1.VantComponent({ + classes: ['active-class', 'toolbar-class', 'column-class'], + props: __assign(__assign({}, shared_1.pickerProps), { + valueKey: { + type: String, + value: 'text', + }, + toolbarPosition: { + type: String, + value: 'top', + }, + defaultIndex: { + type: Number, + value: 0, + }, + columns: { + type: Array, + value: [], + observer: function (columns) { + if (columns === void 0) { + columns = []; + } + this.simple = columns.length && !columns[0].values; + this.children = this.selectAllComponents('.van-picker__column'); + if (Array.isArray(this.children) && this.children.length) { + this.setColumns().catch(function () {}); + } + }, + }, + }), + beforeCreate: function () { + this.children = []; + }, + methods: { + noop: function () {}, + setColumns: function () { + var _this = this; + var data = this.data; + var columns = this.simple ? [{ values: data.columns }] : data.columns; + var stack = columns.map(function (column, index) { + return _this.setColumnValues(index, column.values); + }); + return Promise.all(stack); + }, + emit: function (event) { + var type = event.currentTarget.dataset.type; + if (this.simple) { + this.$emit(type, { + value: this.getColumnValue(0), + index: this.getColumnIndex(0), + }); + } else { + this.$emit(type, { + value: this.getValues(), + index: this.getIndexes(), + }); + } + }, + onChange: function (event) { + if (this.simple) { + this.$emit('change', { + picker: this, + value: this.getColumnValue(0), + index: this.getColumnIndex(0), + }); + } else { + this.$emit('change', { + picker: this, + value: this.getValues(), + index: event.currentTarget.dataset.index, + }); + } + }, + // get column instance by index + getColumn: function (index) { + return this.children[index]; + }, + // get column value by index + getColumnValue: function (index) { + var column = this.getColumn(index); + return column && column.getValue(); + }, + // set column value by index + setColumnValue: function (index, value) { + var column = this.getColumn(index); + if (column == null) { + return Promise.reject(new Error('setColumnValue: 对应列不存在')); + } + return column.setValue(value); + }, + // get column option index by column index + getColumnIndex: function (columnIndex) { + return (this.getColumn(columnIndex) || {}).data.currentIndex; + }, + // set column option index by column index + setColumnIndex: function (columnIndex, optionIndex) { + var column = this.getColumn(columnIndex); + if (column == null) { + return Promise.reject(new Error('setColumnIndex: 对应列不存在')); + } + return column.setIndex(optionIndex); + }, + // get options of column by index + getColumnValues: function (index) { + return (this.children[index] || {}).data.options; + }, + // set options of column by index + setColumnValues: function (index, options, needReset) { + if (needReset === void 0) { + needReset = true; + } + var column = this.children[index]; + if (column == null) { + return Promise.reject(new Error('setColumnValues: 对应列不存在')); + } + var isSame = + JSON.stringify(column.data.options) === JSON.stringify(options); + if (isSame) { + return Promise.resolve(); + } + return column.set({ options: options }).then(function () { + if (needReset) { + column.setIndex(0); + } + }); + }, + // get values of all columns + getValues: function () { + return this.children.map(function (child) { + return child.getValue(); + }); + }, + // set values of all columns + setValues: function (values) { + var _this = this; + var stack = values.map(function (value, index) { + return _this.setColumnValue(index, value); + }); + return Promise.all(stack); + }, + // get indexes of all columns + getIndexes: function () { + return this.children.map(function (child) { + return child.data.currentIndex; + }); + }, + // set indexes of all columns + setIndexes: function (indexes) { + var _this = this; + var stack = indexes.map(function (optionIndex, columnIndex) { + return _this.setColumnIndex(columnIndex, optionIndex); + }); + return Promise.all(stack); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/picker/index.json b/miniprogram_npm/@vant/weapp/picker/index.json new file mode 100644 index 0000000..2fcec89 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/picker/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "picker-column": "../picker-column/index", + "loading": "../loading/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/picker/index.wxml b/miniprogram_npm/@vant/weapp/picker/index.wxml new file mode 100644 index 0000000..519adb5 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/picker/index.wxml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + function isSimple(columns) { + return columns.length && !columns[0].values; + } + module.exports = isSimple; + diff --git a/miniprogram_npm/@vant/weapp/picker/index.wxss b/miniprogram_npm/@vant/weapp/picker/index.wxss new file mode 100644 index 0000000..f74b164 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/picker/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-picker{position:relative;overflow:hidden;-webkit-text-size-adjust:100%;-webkit-user-select:none;user-select:none;background-color:#fff;background-color:var(--picker-background-color,#fff)}.van-picker__toolbar{display:-webkit-flex;display:flex;-webkit-justify-content:space-between;justify-content:space-between;height:44px;height:var(--picker-toolbar-height,44px);line-height:44px;line-height:var(--picker-toolbar-height,44px)}.van-picker__cancel,.van-picker__confirm{padding:0 16px;padding:var(--picker-action-padding,0 16px);font-size:14px;font-size:var(--picker-action-font-size,14px)}.van-picker__cancel--hover,.van-picker__confirm--hover{opacity:.7}.van-picker__confirm{color:#576b95;color:var(--picker-confirm-action-color,#576b95)}.van-picker__cancel{color:#969799;color:var(--picker-cancel-action-color,#969799)}.van-picker__title{max-width:50%;text-align:center;font-weight:500;font-weight:var(--font-weight-bold,500);font-size:16px;font-size:var(--picker-option-font-size,16px)}.van-picker__columns{position:relative;display:-webkit-flex;display:flex}.van-picker__column{-webkit-flex:1 1;flex:1 1;width:0}.van-picker__loading{position:absolute;top:0;right:0;bottom:0;left:0;z-index:4;display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;background-color:hsla(0,0%,100%,.9);background-color:var(--picker-loading-mask-color,hsla(0,0%,100%,.9))}.van-picker__mask{top:0;left:0;z-index:2;width:100%;height:100%;background-image:linear-gradient(180deg,hsla(0,0%,100%,.9),hsla(0,0%,100%,.4)),linear-gradient(0deg,hsla(0,0%,100%,.9),hsla(0,0%,100%,.4));background-repeat:no-repeat;background-position:top,bottom;-webkit-backface-visibility:hidden;backface-visibility:hidden}.van-picker__frame,.van-picker__mask{position:absolute;pointer-events:none}.van-picker__frame{top:50%;right:16px;left:16px;z-index:1;-webkit-transform:translateY(-50%);transform:translateY(-50%)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/picker/shared.js b/miniprogram_npm/@vant/weapp/picker/shared.js new file mode 100644 index 0000000..9b2ca48 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/picker/shared.js @@ -0,0 +1,24 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +exports.pickerProps = void 0; +exports.pickerProps = { + title: String, + loading: Boolean, + showToolbar: Boolean, + cancelButtonText: { + type: String, + value: '取消', + }, + confirmButtonText: { + type: String, + value: '确认', + }, + visibleItemCount: { + type: Number, + value: 6, + }, + itemHeight: { + type: Number, + value: 44, + }, +}; diff --git a/miniprogram_npm/@vant/weapp/picker/toolbar.wxml b/miniprogram_npm/@vant/weapp/picker/toolbar.wxml new file mode 100644 index 0000000..e41a730 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/picker/toolbar.wxml @@ -0,0 +1,28 @@ + diff --git a/miniprogram_npm/@vant/weapp/popup/index.js b/miniprogram_npm/@vant/weapp/popup/index.js new file mode 100644 index 0000000..fbe673c --- /dev/null +++ b/miniprogram_npm/@vant/weapp/popup/index.js @@ -0,0 +1,89 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +var transition_1 = require('../mixins/transition'); +component_1.VantComponent({ + classes: [ + 'enter-class', + 'enter-active-class', + 'enter-to-class', + 'leave-class', + 'leave-active-class', + 'leave-to-class', + 'close-icon-class', + ], + mixins: [transition_1.transition(false)], + props: { + round: Boolean, + closeable: Boolean, + customStyle: String, + overlayStyle: String, + transition: { + type: String, + observer: 'observeClass', + }, + zIndex: { + type: Number, + value: 100, + }, + overlay: { + type: Boolean, + value: true, + }, + closeIcon: { + type: String, + value: 'cross', + }, + closeIconPosition: { + type: String, + value: 'top-right', + }, + closeOnClickOverlay: { + type: Boolean, + value: true, + }, + position: { + type: String, + value: 'center', + observer: 'observeClass', + }, + safeAreaInsetBottom: { + type: Boolean, + value: true, + }, + safeAreaInsetTop: { + type: Boolean, + value: false, + }, + }, + created: function () { + this.observeClass(); + }, + methods: { + onClickCloseIcon: function () { + this.$emit('close'); + }, + onClickOverlay: function () { + this.$emit('click-overlay'); + if (this.data.closeOnClickOverlay) { + this.$emit('close'); + } + }, + observeClass: function () { + var _a = this.data, + transition = _a.transition, + position = _a.position, + duration = _a.duration; + var updateData = { + name: transition || position, + }; + if (transition === 'none') { + updateData.duration = 0; + this.originDuration = duration; + } else if (this.originDuration != null) { + updateData.duration = this.originDuration; + } + this.setData(updateData); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/popup/index.json b/miniprogram_npm/@vant/weapp/popup/index.json new file mode 100644 index 0000000..88a6eab --- /dev/null +++ b/miniprogram_npm/@vant/weapp/popup/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index", + "van-overlay": "../overlay/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/popup/index.wxml b/miniprogram_npm/@vant/weapp/popup/index.wxml new file mode 100644 index 0000000..9b41e5c --- /dev/null +++ b/miniprogram_npm/@vant/weapp/popup/index.wxml @@ -0,0 +1,24 @@ + + + + + + + diff --git a/miniprogram_npm/@vant/weapp/popup/index.wxss b/miniprogram_npm/@vant/weapp/popup/index.wxss new file mode 100644 index 0000000..a3d6e6f --- /dev/null +++ b/miniprogram_npm/@vant/weapp/popup/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-popup{position:fixed;box-sizing:border-box;max-height:100%;overflow-y:auto;transition-timing-function:ease;-webkit-animation:ease both;animation:ease both;-webkit-overflow-scrolling:touch;background-color:#fff;background-color:var(--popup-background-color,#fff)}.van-popup--center{top:50%;left:50%;-webkit-transform:translate3d(-50%,-50%,0);transform:translate3d(-50%,-50%,0)}.van-popup--center.van-popup--round{border-radius:16px;border-radius:var(--popup-round-border-radius,16px)}.van-popup--top{top:0;left:0;width:100%}.van-popup--top.van-popup--round{border-radius:0 0 16px 16px;border-radius:0 0 var(--popup-round-border-radius,16px) var(--popup-round-border-radius,16px)}.van-popup--right{top:50%;right:0;-webkit-transform:translate3d(0,-50%,0);transform:translate3d(0,-50%,0)}.van-popup--right.van-popup--round{border-radius:16px 0 0 16px;border-radius:var(--popup-round-border-radius,16px) 0 0 var(--popup-round-border-radius,16px)}.van-popup--bottom{bottom:0;left:0;width:100%}.van-popup--bottom.van-popup--round{border-radius:16px 16px 0 0;border-radius:var(--popup-round-border-radius,16px) var(--popup-round-border-radius,16px) 0 0}.van-popup--left{top:50%;left:0;-webkit-transform:translate3d(0,-50%,0);transform:translate3d(0,-50%,0)}.van-popup--left.van-popup--round{border-radius:0 16px 16px 0;border-radius:0 var(--popup-round-border-radius,16px) var(--popup-round-border-radius,16px) 0}.van-popup--bottom.van-popup--safe{padding-bottom:env(safe-area-inset-bottom)}.van-popup--safeTop{padding-top:env(safe-area-inset-top)}.van-popup__close-icon{position:absolute;z-index:1;z-index:var(--popup-close-icon-z-index,1);color:#969799;color:var(--popup-close-icon-color,#969799);font-size:18px;font-size:var(--popup-close-icon-size,18px)}.van-popup__close-icon--top-left{top:16px;top:var(--popup-close-icon-margin,16px);left:16px;left:var(--popup-close-icon-margin,16px)}.van-popup__close-icon--top-right{top:16px;top:var(--popup-close-icon-margin,16px);right:16px;right:var(--popup-close-icon-margin,16px)}.van-popup__close-icon--bottom-left{bottom:16px;bottom:var(--popup-close-icon-margin,16px);left:16px;left:var(--popup-close-icon-margin,16px)}.van-popup__close-icon--bottom-right{right:16px;right:var(--popup-close-icon-margin,16px);bottom:16px;bottom:var(--popup-close-icon-margin,16px)}.van-popup__close-icon:active{opacity:.6}.van-scale-enter-active,.van-scale-leave-active{transition-property:opacity,-webkit-transform;transition-property:opacity,transform;transition-property:opacity,transform,-webkit-transform}.van-scale-enter,.van-scale-leave-to{-webkit-transform:translate3d(-50%,-50%,0) scale(.7);transform:translate3d(-50%,-50%,0) scale(.7);opacity:0}.van-fade-enter-active,.van-fade-leave-active{transition-property:opacity}.van-fade-enter,.van-fade-leave-to{opacity:0}.van-center-enter-active,.van-center-leave-active{transition-property:opacity}.van-center-enter,.van-center-leave-to{opacity:0}.van-bottom-enter-active,.van-bottom-leave-active,.van-left-enter-active,.van-left-leave-active,.van-right-enter-active,.van-right-leave-active,.van-top-enter-active,.van-top-leave-active{transition-property:-webkit-transform;transition-property:transform;transition-property:transform,-webkit-transform}.van-bottom-enter,.van-bottom-leave-to{-webkit-transform:translate3d(0,100%,0);transform:translate3d(0,100%,0)}.van-top-enter,.van-top-leave-to{-webkit-transform:translate3d(0,-100%,0);transform:translate3d(0,-100%,0)}.van-left-enter,.van-left-leave-to{-webkit-transform:translate3d(-100%,-50%,0);transform:translate3d(-100%,-50%,0)}.van-right-enter,.van-right-leave-to{-webkit-transform:translate3d(100%,-50%,0);transform:translate3d(100%,-50%,0)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/progress/index.js b/miniprogram_npm/@vant/weapp/progress/index.js new file mode 100644 index 0000000..c56efb7 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/progress/index.js @@ -0,0 +1,29 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +var color_1 = require('../common/color'); +component_1.VantComponent({ + props: { + inactive: Boolean, + percentage: Number, + pivotText: String, + pivotColor: String, + trackColor: String, + showPivot: { + type: Boolean, + value: true, + }, + color: { + type: String, + value: color_1.BLUE, + }, + textColor: { + type: String, + value: '#fff', + }, + strokeWidth: { + type: null, + value: 4, + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/progress/index.json b/miniprogram_npm/@vant/weapp/progress/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/progress/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram_npm/@vant/weapp/progress/index.wxml b/miniprogram_npm/@vant/weapp/progress/index.wxml new file mode 100644 index 0000000..e5981f0 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/progress/index.wxml @@ -0,0 +1,20 @@ + + + + + + + {{ getters.text(pivotText, percentage) }} + + + diff --git a/miniprogram_npm/@vant/weapp/progress/index.wxs b/miniprogram_npm/@vant/weapp/progress/index.wxs new file mode 100644 index 0000000..d685345 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/progress/index.wxs @@ -0,0 +1,5 @@ +module.exports = { + text: function(pivotText, percentage) { + return pivotText || percentage + '%'; + } +}; diff --git a/miniprogram_npm/@vant/weapp/progress/index.wxss b/miniprogram_npm/@vant/weapp/progress/index.wxss new file mode 100644 index 0000000..33c62c7 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/progress/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-progress{position:relative;height:4px;height:var(--progress-height,4px);border-radius:4px;border-radius:var(--progress-height,4px);background:#ebedf0;background:var(--progress-background-color,#ebedf0)}.van-progress__portion{position:absolute;left:0;height:100%;border-radius:inherit;background:#1989fa;background:var(--progress-color,#1989fa)}.van-progress__pivot{position:absolute;top:50%;right:0;box-sizing:border-box;min-width:2em;text-align:center;word-break:keep-all;border-radius:1em;-webkit-transform:translateY(-50%);transform:translateY(-50%);color:#fff;color:var(--progress-pivot-text-color,#fff);padding:0 5px;padding:var(--progress-pivot-padding,0 5px);font-size:10px;font-size:var(--progress-pivot-font-size,10px);line-height:1.6;line-height:var(--progress-pivot-line-height,1.6);background-color:#1989fa;background-color:var(--progress-pivot-background-color,#1989fa)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/radio-group/index.js b/miniprogram_npm/@vant/weapp/radio-group/index.js new file mode 100644 index 0000000..78629da --- /dev/null +++ b/miniprogram_npm/@vant/weapp/radio-group/index.js @@ -0,0 +1,41 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +component_1.VantComponent({ + field: true, + relation: { + name: 'radio', + type: 'descendant', + current: 'radio-group', + linked: function (target) { + this.updateChild(target); + }, + }, + props: { + value: { + type: null, + observer: 'updateChildren', + }, + disabled: { + type: Boolean, + observer: 'updateChildren', + }, + }, + methods: { + updateChildren: function () { + var _this = this; + (this.children || []).forEach(function (child) { + return _this.updateChild(child); + }); + }, + updateChild: function (child) { + var _a = this.data, + value = _a.value, + disabled = _a.disabled; + child.setData({ + value: value, + disabled: disabled || child.data.disabled, + }); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/radio-group/index.json b/miniprogram_npm/@vant/weapp/radio-group/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/radio-group/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram_npm/@vant/weapp/radio-group/index.wxml b/miniprogram_npm/@vant/weapp/radio-group/index.wxml new file mode 100644 index 0000000..4fa864c --- /dev/null +++ b/miniprogram_npm/@vant/weapp/radio-group/index.wxml @@ -0,0 +1 @@ + diff --git a/miniprogram_npm/@vant/weapp/radio-group/index.wxss b/miniprogram_npm/@vant/weapp/radio-group/index.wxss new file mode 100644 index 0000000..99694d6 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/radio-group/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss'; \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/radio/index.js b/miniprogram_npm/@vant/weapp/radio/index.js new file mode 100644 index 0000000..4133c8d --- /dev/null +++ b/miniprogram_npm/@vant/weapp/radio/index.js @@ -0,0 +1,53 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +component_1.VantComponent({ + field: true, + relation: { + name: 'radio-group', + type: 'ancestor', + current: 'radio', + }, + classes: ['icon-class', 'label-class'], + props: { + name: null, + value: null, + disabled: Boolean, + useIconSlot: Boolean, + checkedColor: String, + labelPosition: { + type: String, + value: 'right', + }, + labelDisabled: Boolean, + shape: { + type: String, + value: 'round', + }, + iconSize: { + type: null, + value: 20, + }, + }, + methods: { + emitChange: function (value) { + var instance = this.parent || this; + instance.$emit('input', value); + instance.$emit('change', value); + }, + onChange: function () { + if (!this.data.disabled) { + this.emitChange(this.data.name); + } + }, + onClickLabel: function () { + var _a = this.data, + disabled = _a.disabled, + labelDisabled = _a.labelDisabled, + name = _a.name; + if (!disabled && !labelDisabled) { + this.emitChange(name); + } + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/radio/index.json b/miniprogram_npm/@vant/weapp/radio/index.json new file mode 100644 index 0000000..0a336c0 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/radio/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/radio/index.wxml b/miniprogram_npm/@vant/weapp/radio/index.wxml new file mode 100644 index 0000000..0b748ef --- /dev/null +++ b/miniprogram_npm/@vant/weapp/radio/index.wxml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + diff --git a/miniprogram_npm/@vant/weapp/radio/index.wxss b/miniprogram_npm/@vant/weapp/radio/index.wxss new file mode 100644 index 0000000..96c81f0 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/radio/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-radio{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;overflow:hidden;-webkit-user-select:none;user-select:none}.van-radio__icon-wrap{-webkit-flex:none;flex:none}.van-radio__icon{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;width:1em;height:1em;color:transparent;text-align:center;transition-property:color,border-color,background-color;border:1px solid #c8c9cc;border:1px solid var(--radio-border-color,#c8c9cc);font-size:20px;font-size:var(--radio-size,20px);transition-duration:.2s;transition-duration:var(--radio-transition-duration,.2s)}.van-radio__icon--round{border-radius:100%}.van-radio__icon--checked{color:#fff;color:var(--white,#fff);background-color:#1989fa;background-color:var(--radio-checked-icon-color,#1989fa);border-color:#1989fa;border-color:var(--radio-checked-icon-color,#1989fa)}.van-radio__icon--disabled{background-color:#ebedf0;background-color:var(--radio-disabled-background-color,#ebedf0);border-color:#c8c9cc;border-color:var(--radio-disabled-icon-color,#c8c9cc)}.van-radio__icon--disabled.van-radio__icon--checked{color:#c8c9cc;color:var(--radio-disabled-icon-color,#c8c9cc)}.van-radio__label{word-wrap:break-word;margin-left:10px;margin-left:var(--radio-label-margin,10px);color:#323233;color:var(--radio-label-color,#323233);line-height:20px;line-height:var(--radio-size,20px)}.van-radio__label--left{float:left;margin:0 10px 0 0;margin:0 var(--radio-label-margin,10px) 0 0}.van-radio__label--disabled{color:#c8c9cc;color:var(--radio-disabled-label-color,#c8c9cc)}.van-radio__label:empty{margin:0} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/rate/index.js b/miniprogram_npm/@vant/weapp/rate/index.js new file mode 100644 index 0000000..39f06ff --- /dev/null +++ b/miniprogram_npm/@vant/weapp/rate/index.js @@ -0,0 +1,110 @@ +'use strict'; +var __assign = + (this && this.__assign) || + function () { + __assign = + Object.assign || + function (t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) + if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); + }; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +var version_1 = require('../common/version'); +component_1.VantComponent({ + field: true, + classes: ['icon-class'], + props: { + value: { + type: Number, + observer: function (value) { + if (value !== this.data.innerValue) { + this.setData({ innerValue: value }); + } + }, + }, + readonly: Boolean, + disabled: Boolean, + allowHalf: Boolean, + size: null, + icon: { + type: String, + value: 'star', + }, + voidIcon: { + type: String, + value: 'star-o', + }, + color: { + type: String, + value: '#ffd21e', + }, + voidColor: { + type: String, + value: '#c7c7c7', + }, + disabledColor: { + type: String, + value: '#bdbdbd', + }, + count: { + type: Number, + value: 5, + observer: function (value) { + this.setData({ innerCountArray: Array.from({ length: value }) }); + }, + }, + gutter: null, + touchable: { + type: Boolean, + value: true, + }, + }, + data: { + innerValue: 0, + innerCountArray: Array.from({ length: 5 }), + }, + methods: { + onSelect: function (event) { + var _this = this; + var data = this.data; + var score = event.currentTarget.dataset.score; + if (!data.disabled && !data.readonly) { + this.setData({ innerValue: score + 1 }); + if (version_1.canIUseModel()) { + this.setData({ value: score + 1 }); + } + wx.nextTick(function () { + _this.$emit('input', score + 1); + _this.$emit('change', score + 1); + }); + } + }, + onTouchMove: function (event) { + var _this = this; + var touchable = this.data.touchable; + if (!touchable) return; + var clientX = event.touches[0].clientX; + this.getRect('.van-rate__icon', true).then(function (list) { + var target = list + .sort(function (item) { + return item.right - item.left; + }) + .find(function (item) { + return clientX >= item.left && clientX <= item.right; + }); + if (target != null) { + _this.onSelect( + __assign(__assign({}, event), { currentTarget: target }) + ); + } + }); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/rate/index.json b/miniprogram_npm/@vant/weapp/rate/index.json new file mode 100644 index 0000000..0a336c0 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/rate/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/rate/index.wxml b/miniprogram_npm/@vant/weapp/rate/index.wxml new file mode 100644 index 0000000..58eee5c --- /dev/null +++ b/miniprogram_npm/@vant/weapp/rate/index.wxml @@ -0,0 +1,34 @@ + + + + + + + + + diff --git a/miniprogram_npm/@vant/weapp/rate/index.wxss b/miniprogram_npm/@vant/weapp/rate/index.wxss new file mode 100644 index 0000000..6fd3435 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/rate/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-rate{display:-webkit-inline-flex;display:inline-flex;-webkit-user-select:none;user-select:none}.van-rate__item{position:relative;padding:0 2px;padding:0 var(--rate-horizontal-padding,2px)}.van-rate__icon{display:block;height:1em;font-size:20px;font-size:var(--rate-icon-size,20px)}.van-rate__icon--half{position:absolute;top:0;width:.5em;overflow:hidden;left:2px;left:var(--rate-horizontal-padding,2px)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/row/index.js b/miniprogram_npm/@vant/weapp/row/index.js new file mode 100644 index 0000000..613462a --- /dev/null +++ b/miniprogram_npm/@vant/weapp/row/index.js @@ -0,0 +1,43 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +component_1.VantComponent({ + relation: { + name: 'col', + type: 'descendant', + current: 'row', + linked: function (target) { + if (this.data.gutter) { + target.setGutter(this.data.gutter); + } + }, + }, + props: { + gutter: { + type: Number, + observer: 'setGutter', + }, + }, + data: { + viewStyle: '', + }, + mounted: function () { + if (this.data.gutter) { + this.setGutter(); + } + }, + methods: { + setGutter: function () { + var _this = this; + var gutter = this.data.gutter; + var margin = '-' + Number(gutter) / 2 + 'px'; + var viewStyle = gutter + ? 'margin-right: ' + margin + '; margin-left: ' + margin + ';' + : ''; + this.setData({ viewStyle: viewStyle }); + this.getRelationNodes('../col/index').forEach(function (col) { + col.setGutter(_this.data.gutter); + }); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/row/index.json b/miniprogram_npm/@vant/weapp/row/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/row/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram_npm/@vant/weapp/row/index.wxml b/miniprogram_npm/@vant/weapp/row/index.wxml new file mode 100644 index 0000000..ab8fcf5 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/row/index.wxml @@ -0,0 +1,3 @@ + + + diff --git a/miniprogram_npm/@vant/weapp/row/index.wxss b/miniprogram_npm/@vant/weapp/row/index.wxss new file mode 100644 index 0000000..32a098b --- /dev/null +++ b/miniprogram_npm/@vant/weapp/row/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-row:after{display:table;clear:both;content:""} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/search/index.js b/miniprogram_npm/@vant/weapp/search/index.js new file mode 100644 index 0000000..2e61ab9 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/search/index.js @@ -0,0 +1,81 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +var version_1 = require('../common/version'); +component_1.VantComponent({ + field: true, + classes: ['field-class', 'input-class', 'cancel-class'], + props: { + label: String, + focus: Boolean, + error: Boolean, + disabled: Boolean, + readonly: Boolean, + inputAlign: String, + showAction: Boolean, + useActionSlot: Boolean, + useLeftIconSlot: Boolean, + useRightIconSlot: Boolean, + leftIcon: { + type: String, + value: 'search', + }, + rightIcon: String, + placeholder: String, + placeholderStyle: String, + actionText: { + type: String, + value: '取消', + }, + background: { + type: String, + value: '#ffffff', + }, + maxlength: { + type: Number, + value: -1, + }, + shape: { + type: String, + value: 'square', + }, + clearable: { + type: Boolean, + value: true, + }, + }, + methods: { + onChange: function (event) { + if (version_1.canIUseModel()) { + this.setData({ value: event.detail }); + } + this.$emit('change', event.detail); + }, + onCancel: function () { + var _this = this; + /** + * 修复修改输入框值时,输入框失焦和赋值同时触发,赋值失效 + * https://github.com/youzan/@vant/weapp/issues/1768 + */ + setTimeout(function () { + if (version_1.canIUseModel()) { + _this.setData({ value: '' }); + } + _this.$emit('cancel'); + _this.$emit('change', ''); + }, 200); + }, + onSearch: function (event) { + this.$emit('search', event.detail); + }, + onFocus: function (event) { + this.$emit('focus', event.detail); + }, + onBlur: function (event) { + this.$emit('blur', event.detail); + }, + onClear: function (event) { + this.$emit('clear', event.detail); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/search/index.json b/miniprogram_npm/@vant/weapp/search/index.json new file mode 100644 index 0000000..b4cfe91 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/search/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-field": "../field/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/search/index.wxml b/miniprogram_npm/@vant/weapp/search/index.wxml new file mode 100644 index 0000000..1d0e6f1 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/search/index.wxml @@ -0,0 +1,50 @@ + + + + + {{ label }} + + + + + + + + + + + {{ actionText }} + + diff --git a/miniprogram_npm/@vant/weapp/search/index.wxss b/miniprogram_npm/@vant/weapp/search/index.wxss new file mode 100644 index 0000000..c918deb --- /dev/null +++ b/miniprogram_npm/@vant/weapp/search/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-search{-webkit-align-items:center;align-items:center;box-sizing:border-box;padding:10px 12px;padding:var(--search-padding,10px 12px)}.van-search,.van-search__content{display:-webkit-flex;display:flex}.van-search__content{-webkit-flex:1;flex:1;padding-left:12px;padding-left:var(--padding-sm,12px);border-radius:2px;border-radius:var(--border-radius-sm,2px);background-color:#f7f8fa;background-color:var(--search-background-color,#f7f8fa)}.van-search__content--round{border-radius:17px;border-radius:calc(var(--search-input-height, 34px)/2)}.van-search__label{padding:0 5px;padding:var(--search-label-padding,0 5px);font-size:14px;font-size:var(--search-label-font-size,14px);line-height:34px;line-height:var(--search-input-height,34px);color:#323233;color:var(--search-label-color,#323233)}.van-search__field{-webkit-flex:1;flex:1}.van-search__field__left-icon{color:#969799;color:var(--search-left-icon-color,#969799)}.van-search--withaction{padding-right:0}.van-search__action{padding:0 8px;padding:var(--search-action-padding,0 8px);font-size:14px;font-size:var(--search-action-font-size,14px);line-height:34px;line-height:var(--search-input-height,34px);color:#323233;color:var(--search-action-text-color,#323233)}.van-search__action--hover{background-color:#f2f3f5;background-color:var(--active-color,#f2f3f5)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/share-sheet/index.js b/miniprogram_npm/@vant/weapp/share-sheet/index.js new file mode 100644 index 0000000..440caf8 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/share-sheet/index.js @@ -0,0 +1,57 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +component_1.VantComponent({ + props: { + // whether to show popup + show: Boolean, + // overlay custom style + overlayStyle: Object, + // z-index + zIndex: { + type: Number, + value: 100, + }, + title: String, + cancelText: { + type: String, + value: '取消', + }, + description: String, + options: { + type: Array, + value: [], + }, + overlay: { + type: Boolean, + value: true, + }, + safeAreaInsetBottom: { + type: Boolean, + value: true, + }, + closeOnClickOverlay: { + type: Boolean, + value: true, + }, + duration: { + type: null, + value: 300, + }, + }, + methods: { + onClickOverlay: function () { + this.$emit('click-overlay'); + }, + onCancel: function () { + this.onClose(); + this.$emit('cancel'); + }, + onSelect: function (event) { + this.$emit('select', event.detail); + }, + onClose: function () { + this.$emit('close'); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/share-sheet/index.json b/miniprogram_npm/@vant/weapp/share-sheet/index.json new file mode 100644 index 0000000..15a7c22 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/share-sheet/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "van-popup": "../popup/index", + "options": "./options" + } +} diff --git a/miniprogram_npm/@vant/weapp/share-sheet/index.wxml b/miniprogram_npm/@vant/weapp/share-sheet/index.wxml new file mode 100644 index 0000000..cefc3af --- /dev/null +++ b/miniprogram_npm/@vant/weapp/share-sheet/index.wxml @@ -0,0 +1,46 @@ + + + + + + + + {{ title }} + + + + + + {{ description }} + + + + + + + + + + + diff --git a/miniprogram_npm/@vant/weapp/share-sheet/index.wxs b/miniprogram_npm/@vant/weapp/share-sheet/index.wxs new file mode 100644 index 0000000..2149ee9 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/share-sheet/index.wxs @@ -0,0 +1,12 @@ +/* eslint-disable */ +function isMulti(options) { + if (options == null || options[0] == null) { + return false; + } + + return "Array" === options.constructor && "Array" === options[0].constructor; +} + +module.exports = { + isMulti: isMulti +}; diff --git a/miniprogram_npm/@vant/weapp/share-sheet/index.wxss b/miniprogram_npm/@vant/weapp/share-sheet/index.wxss new file mode 100644 index 0000000..8d42eb2 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/share-sheet/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-share-sheet__header{padding:12px 16px 4px;text-align:center}.van-share-sheet__title{margin-top:8px;color:#323233;font-weight:400;font-size:14px;line-height:20px}.van-share-sheet__title:empty,.van-share-sheet__title:not(:empty)+.van-share-sheet__title{display:none}.van-share-sheet__description{display:block;margin-top:8px;color:#969799;font-size:12px;line-height:16px}.van-share-sheet__description:empty,.van-share-sheet__description:not(:empty)+.van-share-sheet__description{display:none}.van-share-sheet__cancel{display:block;box-sizing:initial;width:100%;height:auto;padding:0;font-size:16px;line-height:48px;text-align:center;background:#fff;border:none}.van-share-sheet__cancel:before{display:block;height:8px;background-color:#f7f8fa;content:" "}.van-share-sheet__cancel:after{display:none}.van-share-sheet__cancel:active{background-color:#f2f3f5} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/share-sheet/options.js b/miniprogram_npm/@vant/weapp/share-sheet/options.js new file mode 100644 index 0000000..f503f4c --- /dev/null +++ b/miniprogram_npm/@vant/weapp/share-sheet/options.js @@ -0,0 +1,31 @@ +'use strict'; +var __assign = + (this && this.__assign) || + function () { + __assign = + Object.assign || + function (t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) + if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); + }; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +component_1.VantComponent({ + props: { + options: Array, + showBorder: Boolean, + }, + methods: { + onSelect: function (event) { + var index = event.currentTarget.dataset.index; + var option = this.data.options[index]; + this.$emit('select', __assign(__assign({}, option), { index: index })); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/share-sheet/options.json b/miniprogram_npm/@vant/weapp/share-sheet/options.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/share-sheet/options.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram_npm/@vant/weapp/share-sheet/options.wxml b/miniprogram_npm/@vant/weapp/share-sheet/options.wxml new file mode 100644 index 0000000..cad6837 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/share-sheet/options.wxml @@ -0,0 +1,20 @@ + + + + + + + {{ item.name }} + + {{ item.description }} + + + diff --git a/miniprogram_npm/@vant/weapp/share-sheet/options.wxs b/miniprogram_npm/@vant/weapp/share-sheet/options.wxs new file mode 100644 index 0000000..ab6033b --- /dev/null +++ b/miniprogram_npm/@vant/weapp/share-sheet/options.wxs @@ -0,0 +1,14 @@ +/* eslint-disable */ +var PRESET_ICONS = ['qq', 'weibo', 'wechat', 'link', 'qrcode', 'poster']; + +function getIconURL(icon) { + if (PRESET_ICONS.indexOf(icon) !== -1) { + return 'https://img.yzcdn.cn/vant/share-icon-' + icon + '.png'; + } + + return icon; +} + +module.exports = { + getIconURL: getIconURL, +}; diff --git a/miniprogram_npm/@vant/weapp/share-sheet/options.wxss b/miniprogram_npm/@vant/weapp/share-sheet/options.wxss new file mode 100644 index 0000000..ca7b02f --- /dev/null +++ b/miniprogram_npm/@vant/weapp/share-sheet/options.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-share-sheet__options{position:relative;display:-webkit-flex;display:flex;padding:16px 0 16px 8px;overflow-x:auto;overflow-y:visible;-webkit-overflow-scrolling:touch}.van-share-sheet__options--border:before{position:absolute;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;content:" ";pointer-events:none;top:0;right:0;left:16px;border-top:1px solid #ebedf0;-webkit-transform:scaleY(.5);transform:scaleY(.5)}.van-share-sheet__options::-webkit-scrollbar{height:0}.van-share-sheet__option{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-user-select:none;user-select:none}.van-share-sheet__option:active{opacity:.7}.van-share-sheet__button{height:auto;padding:0;line-height:inherit;background-color:initial;border:0}.van-share-sheet__button:after{border:0}.van-share-sheet__icon{width:48px;height:48px;margin:0 16px}.van-share-sheet__name{margin-top:8px;padding:0 4px;color:#646566;font-size:12px}.van-share-sheet__option-description{padding:0 4px;color:#c8c9cc;font-size:12px} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/sidebar-item/index.js b/miniprogram_npm/@vant/weapp/sidebar-item/index.js new file mode 100644 index 0000000..a7f0d5e --- /dev/null +++ b/miniprogram_npm/@vant/weapp/sidebar-item/index.js @@ -0,0 +1,35 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +component_1.VantComponent({ + classes: ['active-class', 'disabled-class'], + relation: { + type: 'ancestor', + name: 'sidebar', + current: 'sidebar-item', + }, + props: { + dot: Boolean, + badge: null, + info: null, + title: String, + disabled: Boolean, + }, + methods: { + onClick: function () { + var _this = this; + var parent = this.parent; + if (!parent || this.data.disabled) { + return; + } + var index = parent.children.indexOf(this); + parent.setActive(index).then(function () { + _this.$emit('click', index); + parent.$emit('change', index); + }); + }, + setActive: function (selected) { + return this.setData({ selected: selected }); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/sidebar-item/index.json b/miniprogram_npm/@vant/weapp/sidebar-item/index.json new file mode 100644 index 0000000..bf0ebe0 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/sidebar-item/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-info": "../info/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/sidebar-item/index.wxml b/miniprogram_npm/@vant/weapp/sidebar-item/index.wxml new file mode 100644 index 0000000..c5c08a6 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/sidebar-item/index.wxml @@ -0,0 +1,18 @@ + + + + + + {{ title }} + + + diff --git a/miniprogram_npm/@vant/weapp/sidebar-item/index.wxss b/miniprogram_npm/@vant/weapp/sidebar-item/index.wxss new file mode 100644 index 0000000..f134528 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/sidebar-item/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-sidebar-item{display:block;box-sizing:border-box;overflow:hidden;border-left:3px solid transparent;-webkit-user-select:none;user-select:none;padding:20px 12px 20px 8px;padding:var(--sidebar-padding,20px 12px 20px 8px);font-size:14px;font-size:var(--sidebar-font-size,14px);line-height:20px;line-height:var(--sidebar-line-height,20px);color:#323233;color:var(--sidebar-text-color,#323233);background-color:#f7f8fa;background-color:var(--sidebar-background-color,#f7f8fa)}.van-sidebar-item__text{position:relative;display:inline-block;word-break:break-all}.van-sidebar-item--hover:not(.van-sidebar-item--disabled){background-color:#f2f3f5;background-color:var(--sidebar-active-color,#f2f3f5)}.van-sidebar-item:after{border-bottom-width:1px}.van-sidebar-item--selected{color:#323233;color:var(--sidebar-selected-text-color,#323233);font-weight:500;font-weight:var(--sidebar-selected-font-weight,500);border-color:#ee0a24;border-color:var(--sidebar-selected-border-color,#ee0a24)}.van-sidebar-item--selected:after{border-right-width:1px}.van-sidebar-item--selected,.van-sidebar-item--selected.van-sidebar-item--hover{background-color:#fff;background-color:var(--sidebar-selected-background-color,#fff)}.van-sidebar-item--disabled{color:#c8c9cc;color:var(--sidebar-disabled-text-color,#c8c9cc)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/sidebar/index.js b/miniprogram_npm/@vant/weapp/sidebar/index.js new file mode 100644 index 0000000..97a3080 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/sidebar/index.js @@ -0,0 +1,45 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +component_1.VantComponent({ + relation: { + name: 'sidebar-item', + type: 'descendant', + current: 'sidebar', + linked: function () { + this.setActive(this.data.activeKey); + }, + unlinked: function () { + this.setActive(this.data.activeKey); + }, + }, + props: { + activeKey: { + type: Number, + value: 0, + observer: 'setActive', + }, + }, + beforeCreate: function () { + this.currentActive = -1; + }, + methods: { + setActive: function (activeKey) { + var _a = this, + children = _a.children, + currentActive = _a.currentActive; + if (!children.length) { + return Promise.resolve(); + } + this.currentActive = activeKey; + var stack = []; + if (currentActive !== activeKey && children[currentActive]) { + stack.push(children[currentActive].setActive(false)); + } + if (children[activeKey]) { + stack.push(children[activeKey].setActive(true)); + } + return Promise.all(stack); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/sidebar/index.json b/miniprogram_npm/@vant/weapp/sidebar/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/sidebar/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram_npm/@vant/weapp/sidebar/index.wxml b/miniprogram_npm/@vant/weapp/sidebar/index.wxml new file mode 100644 index 0000000..96b11c7 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/sidebar/index.wxml @@ -0,0 +1,3 @@ + + + diff --git a/miniprogram_npm/@vant/weapp/sidebar/index.wxss b/miniprogram_npm/@vant/weapp/sidebar/index.wxss new file mode 100644 index 0000000..8ad1884 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/sidebar/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-sidebar{width:80px;width:var(--sidebar-width,80px)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/skeleton/index.js b/miniprogram_npm/@vant/weapp/skeleton/index.js new file mode 100644 index 0000000..52137fa --- /dev/null +++ b/miniprogram_npm/@vant/weapp/skeleton/index.js @@ -0,0 +1,48 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +component_1.VantComponent({ + classes: ['avatar-class', 'title-class', 'row-class'], + props: { + row: { + type: Number, + value: 0, + observer: function (value) { + this.setData({ rowArray: Array.from({ length: value }) }); + }, + }, + title: Boolean, + avatar: Boolean, + loading: { + type: Boolean, + value: true, + }, + animate: { + type: Boolean, + value: true, + }, + avatarSize: { + type: String, + value: '32px', + }, + avatarShape: { + type: String, + value: 'round', + }, + titleWidth: { + type: String, + value: '40%', + }, + rowWidth: { + type: null, + value: '100%', + observer: function (val) { + this.setData({ isArray: val instanceof Array }); + }, + }, + }, + data: { + isArray: false, + rowArray: [], + }, +}); diff --git a/miniprogram_npm/@vant/weapp/skeleton/index.json b/miniprogram_npm/@vant/weapp/skeleton/index.json new file mode 100644 index 0000000..a89ef4d --- /dev/null +++ b/miniprogram_npm/@vant/weapp/skeleton/index.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} diff --git a/miniprogram_npm/@vant/weapp/skeleton/index.wxml b/miniprogram_npm/@vant/weapp/skeleton/index.wxml new file mode 100644 index 0000000..058e2ef --- /dev/null +++ b/miniprogram_npm/@vant/weapp/skeleton/index.wxml @@ -0,0 +1,29 @@ + + + + + + + + + + + + diff --git a/miniprogram_npm/@vant/weapp/skeleton/index.wxss b/miniprogram_npm/@vant/weapp/skeleton/index.wxss new file mode 100644 index 0000000..565b26e --- /dev/null +++ b/miniprogram_npm/@vant/weapp/skeleton/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-skeleton{display:-webkit-flex;display:flex;box-sizing:border-box;width:100%;padding:0 16px;padding:var(--skeleton-padding,0 16px)}.van-skeleton__avatar{-webkit-flex-shrink:0;flex-shrink:0;margin-right:16px;margin-right:var(--padding-md,16px);background-color:#f2f3f5;background-color:var(--skeleton-avatar-background-color,#f2f3f5)}.van-skeleton__avatar--round{border-radius:100%}.van-skeleton__content{-webkit-flex:1;flex:1}.van-skeleton__avatar+.van-skeleton__content{padding-top:8px;padding-top:var(--padding-xs,8px)}.van-skeleton__row,.van-skeleton__title{height:16px;height:var(--skeleton-row-height,16px);background-color:#f2f3f5;background-color:var(--skeleton-row-background-color,#f2f3f5)}.van-skeleton__title{margin:0}.van-skeleton__row:not(:first-child){margin-top:12px;margin-top:var(--skeleton-row-margin-top,12px)}.van-skeleton__title+.van-skeleton__row{margin-top:20px}.van-skeleton--animate{-webkit-animation:van-skeleton-blink 1.2s ease-in-out infinite;animation:van-skeleton-blink 1.2s ease-in-out infinite}@-webkit-keyframes van-skeleton-blink{50%{opacity:.6}}@keyframes van-skeleton-blink{50%{opacity:.6}} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/slider/index.js b/miniprogram_npm/@vant/weapp/slider/index.js new file mode 100644 index 0000000..1001a4d --- /dev/null +++ b/miniprogram_npm/@vant/weapp/slider/index.js @@ -0,0 +1,117 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +var touch_1 = require('../mixins/touch'); +var version_1 = require('../common/version'); +component_1.VantComponent({ + mixins: [touch_1.touch], + props: { + disabled: Boolean, + useButtonSlot: Boolean, + activeColor: String, + inactiveColor: String, + max: { + type: Number, + value: 100, + }, + min: { + type: Number, + value: 0, + }, + step: { + type: Number, + value: 1, + }, + value: { + type: Number, + value: 0, + observer: function (val) { + if (val !== this.value) { + this.updateValue(val); + } + }, + }, + barHeight: { + type: null, + value: 2, + }, + }, + created: function () { + this.updateValue(this.data.value); + }, + methods: { + onTouchStart: function (event) { + if (this.data.disabled) return; + this.touchStart(event); + this.startValue = this.format(this.value); + this.dragStatus = 'start'; + }, + onTouchMove: function (event) { + var _this = this; + if (this.data.disabled) return; + if (this.dragStatus === 'start') { + this.$emit('drag-start'); + } + this.touchMove(event); + this.dragStatus = 'draging'; + this.getRect('.van-slider').then(function (rect) { + var diff = (_this.deltaX / rect.width) * 100; + _this.newValue = _this.startValue + diff; + _this.updateValue(_this.newValue, false, true); + }); + }, + onTouchEnd: function () { + if (this.data.disabled) return; + if (this.dragStatus === 'draging') { + this.updateValue(this.newValue, true); + this.$emit('drag-end'); + } + }, + onClick: function (event) { + var _this = this; + if (this.data.disabled) return; + var min = this.data.min; + this.getRect('.van-slider').then(function (rect) { + var value = + ((event.detail.x - rect.left) / rect.width) * _this.getRange() + min; + _this.updateValue(value, true); + }); + }, + updateValue: function (value, end, drag) { + value = this.format(value); + var min = this.data.min; + var width = ((value - min) * 100) / this.getRange() + '%'; + this.value = value; + this.setData({ + barStyle: + '\n width: ' + + width + + ';\n ' + + (drag ? 'transition: none;' : '') + + '\n ', + }); + if (drag) { + this.$emit('drag', { value: value }); + } + if (end) { + this.$emit('change', value); + } + if ((drag || end) && version_1.canIUseModel()) { + this.setData({ value: value }); + } + }, + getRange: function () { + var _a = this.data, + max = _a.max, + min = _a.min; + return max - min; + }, + format: function (value) { + var _a = this.data, + max = _a.max, + min = _a.min, + step = _a.step; + return Math.round(Math.max(min, Math.min(value, max)) / step) * step; + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/slider/index.json b/miniprogram_npm/@vant/weapp/slider/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/slider/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram_npm/@vant/weapp/slider/index.wxml b/miniprogram_npm/@vant/weapp/slider/index.wxml new file mode 100644 index 0000000..6a430f3 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/slider/index.wxml @@ -0,0 +1,30 @@ + + + + + + + + + + + diff --git a/miniprogram_npm/@vant/weapp/slider/index.wxs b/miniprogram_npm/@vant/weapp/slider/index.wxs new file mode 100644 index 0000000..d6404d6 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/slider/index.wxs @@ -0,0 +1,20 @@ +/* eslint-disable */ +var utils = require('../wxs/utils.wxs'); + +function barStyle(barHeight, activeColor) { + var styles = [['height', utils.addUnit(barHeight)]]; + + if (activeColor) { + styles.push(['background', activeColor]); + } + + return styles + .map(function (item) { + return item.join(':'); + }) + .join(';'); +} + +module.exports = { + barStyle: barStyle, +}; diff --git a/miniprogram_npm/@vant/weapp/slider/index.wxss b/miniprogram_npm/@vant/weapp/slider/index.wxss new file mode 100644 index 0000000..7886b60 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/slider/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-slider{position:relative;border-radius:999px;border-radius:var(--border-radius-max,999px);background-color:#ebedf0;background-color:var(--slider-inactive-background-color,#ebedf0)}.van-slider:before{position:absolute;right:0;left:0;content:"";top:-8px;top:-var(--padding-xs,8px);bottom:-8px;bottom:-var(--padding-xs,8px)}.van-slider__bar{position:relative;border-radius:inherit;transition:width .2s;transition:width var(--animation-duration-fast,.2s);background-color:#1989fa;background-color:var(--slider-active-background-color,#1989fa)}.van-slider__button{width:24px;height:24px;border-radius:50%;box-shadow:0 1px 2px rgba(0,0,0,.5);background-color:#fff;background-color:var(--slider-button-background-color,#fff)}.van-slider__button-wrapper{position:absolute;top:50%;right:0;-webkit-transform:translate3d(50%,-50%,0);transform:translate3d(50%,-50%,0)}.van-slider--disabled{opacity:.5} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/steps/index.js b/miniprogram_npm/@vant/weapp/steps/index.js new file mode 100644 index 0000000..c41e5ad --- /dev/null +++ b/miniprogram_npm/@vant/weapp/steps/index.js @@ -0,0 +1,35 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +var color_1 = require('../common/color'); +component_1.VantComponent({ + classes: ['desc-class'], + props: { + icon: String, + steps: Array, + active: Number, + direction: { + type: String, + value: 'horizontal', + }, + activeColor: { + type: String, + value: color_1.GREEN, + }, + inactiveColor: { + type: String, + value: color_1.GRAY_DARK, + }, + activeIcon: { + type: String, + value: 'checked', + }, + inactiveIcon: String, + }, + methods: { + onClick: function (event) { + var index = event.currentTarget.dataset.index; + this.$emit('click-step', index); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/steps/index.json b/miniprogram_npm/@vant/weapp/steps/index.json new file mode 100644 index 0000000..0a336c0 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/steps/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/steps/index.wxml b/miniprogram_npm/@vant/weapp/steps/index.wxml new file mode 100644 index 0000000..6180b41 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/steps/index.wxml @@ -0,0 +1,54 @@ + + + + + + + {{ item.text }} + {{ item.desc }} + + + + + + + + + + + + + + + +function get(index, active) { + if (index < active) { + return 'finish'; + } else if (index === active) { + return 'process'; + } + + return 'inactive'; +} + +module.exports = get; + diff --git a/miniprogram_npm/@vant/weapp/steps/index.wxss b/miniprogram_npm/@vant/weapp/steps/index.wxss new file mode 100644 index 0000000..2c50b1a --- /dev/null +++ b/miniprogram_npm/@vant/weapp/steps/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-steps{overflow:hidden;background-color:#fff;background-color:var(--steps-background-color,#fff)}.van-steps--horizontal{padding:10px}.van-steps--horizontal .van-step__wrapper{position:relative;display:-webkit-flex;display:flex;overflow:hidden}.van-steps--vertical{padding-left:10px}.van-steps--vertical .van-step__wrapper{padding:0 0 0 20px}.van-step{position:relative;-webkit-flex:1;flex:1;font-size:14px;font-size:var(--step-font-size,14px);color:#969799;color:var(--step-text-color,#969799)}.van-step--finish{color:#323233;color:var(--step-finish-text-color,#323233)}.van-step__circle{border-radius:50%;width:5px;width:var(--step-circle-size,5px);height:5px;height:var(--step-circle-size,5px);background-color:#969799;background-color:var(--step-circle-color,#969799)}.van-step--horizontal{padding-bottom:14px}.van-step--horizontal:first-child .van-step__title{-webkit-transform:none;transform:none}.van-step--horizontal:first-child .van-step__circle-container{padding:0 8px 0 0;-webkit-transform:translate3d(0,50%,0);transform:translate3d(0,50%,0)}.van-step--horizontal:last-child{position:absolute;right:0;width:auto}.van-step--horizontal:last-child .van-step__title{text-align:right;-webkit-transform:none;transform:none}.van-step--horizontal:last-child .van-step__circle-container{right:0;padding:0 0 0 8px;-webkit-transform:translate3d(0,50%,0);transform:translate3d(0,50%,0)}.van-step--horizontal .van-step__circle-container{position:absolute;bottom:6px;z-index:1;-webkit-transform:translate3d(-50%,50%,0);transform:translate3d(-50%,50%,0);background-color:#fff;background-color:var(--white,#fff);padding:0 8px;padding:0 var(--padding-xs,8px)}.van-step--horizontal .van-step__title{display:inline-block;-webkit-transform:translate3d(-50%,0,0);transform:translate3d(-50%,0,0);font-size:12px;font-size:var(--step-horizontal-title-font-size,12px)}.van-step--horizontal .van-step__line{position:absolute;right:0;bottom:6px;left:0;height:1px;-webkit-transform:translate3d(0,50%,0);transform:translate3d(0,50%,0);background-color:#ebedf0;background-color:var(--step-line-color,#ebedf0)}.van-step--horizontal.van-step--process{color:#323233;color:var(--step-process-text-color,#323233)}.van-step--horizontal.van-step--process .van-step__icon{display:block;line-height:1;font-size:12px;font-size:var(--step-icon-size,12px)}.van-step--vertical{padding:10px 10px 10px 0;line-height:18px}.van-step--vertical:after{border-bottom-width:1px}.van-step--vertical:last-child:after{border-bottom-width:none}.van-step--vertical:first-child:before{position:absolute;top:0;left:-15px;z-index:1;width:1px;height:20px;content:"";background-color:#fff;background-color:var(--white,#fff)}.van-step--vertical .van-step__circle,.van-step--vertical .van-step__icon,.van-step--vertical .van-step__line{position:absolute;top:19px;left:-14px;z-index:2;-webkit-transform:translate3d(-50%,-50%,0);transform:translate3d(-50%,-50%,0)}.van-step--vertical .van-step__icon{line-height:1;font-size:12px;font-size:var(--step-icon-size,12px)}.van-step--vertical .van-step__line{z-index:1;width:1px;height:100%;-webkit-transform:translate3d(-50%,0,0);transform:translate3d(-50%,0,0);background-color:#ebedf0;background-color:var(--step-line-color,#ebedf0)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/sticky/index.js b/miniprogram_npm/@vant/weapp/sticky/index.js new file mode 100644 index 0000000..11d0c07 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/sticky/index.js @@ -0,0 +1,119 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +var page_scroll_1 = require('../mixins/page-scroll'); +var ROOT_ELEMENT = '.van-sticky'; +component_1.VantComponent({ + props: { + zIndex: { + type: Number, + value: 99, + }, + offsetTop: { + type: Number, + value: 0, + observer: 'onScroll', + }, + disabled: { + type: Boolean, + observer: 'onScroll', + }, + container: { + type: null, + observer: 'onScroll', + }, + scrollTop: { + type: null, + observer: function (val) { + this.onScroll({ scrollTop: val }); + }, + }, + }, + mixins: [ + page_scroll_1.pageScrollMixin(function (event) { + if (this.data.scrollTop != null) { + return; + } + this.onScroll(event); + }), + ], + data: { + height: 0, + fixed: false, + transform: 0, + }, + mounted: function () { + this.onScroll(); + }, + methods: { + onScroll: function (_a) { + var _this = this; + var scrollTop = (_a === void 0 ? {} : _a).scrollTop; + var _b = this.data, + container = _b.container, + offsetTop = _b.offsetTop, + disabled = _b.disabled; + if (disabled) { + this.setDataAfterDiff({ + fixed: false, + transform: 0, + }); + return; + } + this.scrollTop = scrollTop || this.scrollTop; + if (typeof container === 'function') { + Promise.all([this.getRect(ROOT_ELEMENT), this.getContainerRect()]).then( + function (_a) { + var root = _a[0], + container = _a[1]; + if (offsetTop + root.height > container.height + container.top) { + _this.setDataAfterDiff({ + fixed: false, + transform: container.height - root.height, + }); + } else if (offsetTop >= root.top) { + _this.setDataAfterDiff({ + fixed: true, + height: root.height, + transform: 0, + }); + } else { + _this.setDataAfterDiff({ fixed: false, transform: 0 }); + } + } + ); + return; + } + this.getRect(ROOT_ELEMENT).then(function (root) { + if (offsetTop >= root.top) { + _this.setDataAfterDiff({ fixed: true, height: root.height }); + _this.transform = 0; + } else { + _this.setDataAfterDiff({ fixed: false }); + } + }); + }, + setDataAfterDiff: function (data) { + var _this = this; + wx.nextTick(function () { + var diff = Object.keys(data).reduce(function (prev, key) { + if (data[key] !== _this.data[key]) { + prev[key] = data[key]; + } + return prev; + }, {}); + _this.setData(diff); + _this.$emit('scroll', { + scrollTop: _this.scrollTop, + isFixed: data.fixed || _this.data.fixed, + }); + }); + }, + getContainerRect: function () { + var nodesRef = this.data.container(); + return new Promise(function (resolve) { + return nodesRef.boundingClientRect(resolve).exec(); + }); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/sticky/index.json b/miniprogram_npm/@vant/weapp/sticky/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/sticky/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram_npm/@vant/weapp/sticky/index.wxml b/miniprogram_npm/@vant/weapp/sticky/index.wxml new file mode 100644 index 0000000..15e9f4a --- /dev/null +++ b/miniprogram_npm/@vant/weapp/sticky/index.wxml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/miniprogram_npm/@vant/weapp/sticky/index.wxs b/miniprogram_npm/@vant/weapp/sticky/index.wxs new file mode 100644 index 0000000..18efe14 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/sticky/index.wxs @@ -0,0 +1,37 @@ +/* eslint-disable */ +function wrapStyle(data) { + var style = ''; + + if (data.transform) { + style += 'transform: translate3d(0, ' + data.transform + 'px, 0);'; + } + + if (data.fixed) { + style += 'top: ' + data.offsetTop + 'px;'; + } + + if (data.zIndex) { + style += 'z-index: ' + data.zIndex + ';'; + } + + return style; +} + +function containerStyle(data) { + var style = ''; + + if (data.fixed) { + style += 'height: ' + data.height + 'px;'; + } + + if (data.zIndex) { + style += 'z-index: ' + data.zIndex + ';'; + } + + return style; +} + +module.exports = { + wrapStyle: wrapStyle, + containerStyle: containerStyle +}; diff --git a/miniprogram_npm/@vant/weapp/sticky/index.wxss b/miniprogram_npm/@vant/weapp/sticky/index.wxss new file mode 100644 index 0000000..5269387 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/sticky/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-sticky{position:relative}.van-sticky-wrap--fixed{position:fixed;right:0;left:0} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/submit-bar/index.js b/miniprogram_npm/@vant/weapp/submit-bar/index.js new file mode 100644 index 0000000..2b06332 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/submit-bar/index.js @@ -0,0 +1,61 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +component_1.VantComponent({ + classes: ['bar-class', 'price-class', 'button-class'], + props: { + tip: { + type: null, + observer: 'updateTip', + }, + tipIcon: String, + type: Number, + price: { + type: null, + observer: 'updatePrice', + }, + label: String, + loading: Boolean, + disabled: Boolean, + buttonText: String, + currency: { + type: String, + value: '¥', + }, + buttonType: { + type: String, + value: 'danger', + }, + decimalLength: { + type: Number, + value: 2, + observer: 'updatePrice', + }, + suffixLabel: String, + safeAreaInsetBottom: { + type: Boolean, + value: true, + }, + }, + methods: { + updatePrice: function () { + var _a = this.data, + price = _a.price, + decimalLength = _a.decimalLength; + var priceStrArr = + typeof price === 'number' && + (price / 100).toFixed(decimalLength).split('.'); + this.setData({ + hasPrice: typeof price === 'number', + integerStr: priceStrArr && priceStrArr[0], + decimalStr: decimalLength && priceStrArr ? '.' + priceStrArr[1] : '', + }); + }, + updateTip: function () { + this.setData({ hasTip: typeof this.data.tip === 'string' }); + }, + onSubmit: function (event) { + this.$emit('submit', event.detail); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/submit-bar/index.json b/miniprogram_npm/@vant/weapp/submit-bar/index.json new file mode 100644 index 0000000..bda9b8d --- /dev/null +++ b/miniprogram_npm/@vant/weapp/submit-bar/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "van-button": "../button/index", + "van-icon": "../icon/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/submit-bar/index.wxml b/miniprogram_npm/@vant/weapp/submit-bar/index.wxml new file mode 100644 index 0000000..a56dd46 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/submit-bar/index.wxml @@ -0,0 +1,44 @@ + + + + + + + + + {{ tip }} + + + + + + + + {{ label || '合计:' }} + + {{ currency }} + {{ integerStr }}{{decimalStr}} + + {{ suffixLabel }} + + + {{ loading ? '' : buttonText }} + + + + + diff --git a/miniprogram_npm/@vant/weapp/submit-bar/index.wxss b/miniprogram_npm/@vant/weapp/submit-bar/index.wxss new file mode 100644 index 0000000..3126e91 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/submit-bar/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-submit-bar{position:fixed;bottom:0;left:0;width:100%;-webkit-user-select:none;user-select:none;z-index:100;z-index:var(--submit-bar-z-index,100);background-color:#fff;background-color:var(--submit-bar-background-color,#fff)}.van-submit-bar__tip{padding:10px;padding:var(--submit-bar-tip-padding,10px);color:#f56723;color:var(--submit-bar-tip-color,#f56723);font-size:12px;font-size:var(--submit-bar-tip-font-size,12px);line-height:1.5;line-height:var(--submit-bar-tip-line-height,1.5);background-color:#fff7cc;background-color:var(--submit-bar-tip-background-color,#fff7cc)}.van-submit-bar__tip:empty{display:none}.van-submit-bar__tip-icon{width:12px;height:12px;margin-right:4px;vertical-align:middle;font-size:12px;font-size:var(--submit-bar-tip-icon-size,12px);min-width:18px;min-width:calc(var(--submit-bar-tip-icon-size, 12px)*1.5)}.van-submit-bar__tip-text{display:inline;vertical-align:middle}.van-submit-bar__bar{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:flex-end;justify-content:flex-end;padding:0 16px;padding:var(--submit-bar-padding,0 16px);height:50px;height:var(--submit-bar-height,50px);font-size:14px;font-size:var(--submit-bar-text-font-size,14px);background-color:#fff;background-color:var(--submit-bar-background-color,#fff)}.van-submit-bar__safe{height:constant(safe-area-inset-bottom);height:env(safe-area-inset-bottom)}.van-submit-bar__text{-webkit-flex:1;flex:1;text-align:right;color:#323233;color:var(--submit-bar-text-color,#323233);padding-right:12px;padding-right:var(--padding-sm,12px)}.van-submit-bar__price,.van-submit-bar__text{font-weight:500;font-weight:var(--font-weight-bold,500)}.van-submit-bar__price{color:#ee0a24;color:var(--submit-bar-price-color,#ee0a24);font-size:12px;font-size:var(--submit-bar-price-font-size,12px)}.van-submit-bar__price-integer{font-size:20px;font-family:Avenir-Heavy,PingFang SC,Helvetica Neue,Arial,sans-serif}.van-submit-bar__currency{font-size:12px;font-size:var(--submit-bar-currency-font-size,12px)}.van-submit-bar__suffix-label{margin-left:5px}.van-submit-bar__button{width:110px;width:var(--submit-bar-button-width,110px);font-weight:500;font-weight:var(--font-weight-bold,500);--button-default-height:40px!important;--button-default-height:var(--submit-bar-button-height,40px)!important;--button-line-height:40px!important;--button-line-height:var(--submit-bar-button-height,40px)!important} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/swipe-cell/index.js b/miniprogram_npm/@vant/weapp/swipe-cell/index.js new file mode 100644 index 0000000..78280a6 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/swipe-cell/index.js @@ -0,0 +1,162 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +var touch_1 = require('../mixins/touch'); +var utils_1 = require('../common/utils'); +var THRESHOLD = 0.3; +var ARRAY = []; +component_1.VantComponent({ + props: { + disabled: Boolean, + leftWidth: { + type: Number, + value: 0, + observer: function (leftWidth) { + if (leftWidth === void 0) { + leftWidth = 0; + } + if (this.offset > 0) { + this.swipeMove(leftWidth); + } + }, + }, + rightWidth: { + type: Number, + value: 0, + observer: function (rightWidth) { + if (rightWidth === void 0) { + rightWidth = 0; + } + if (this.offset < 0) { + this.swipeMove(-rightWidth); + } + }, + }, + asyncClose: Boolean, + name: { + type: [Number, String], + value: '', + }, + }, + mixins: [touch_1.touch], + data: { + catchMove: false, + wrapperStyle: '', + }, + created: function () { + this.offset = 0; + ARRAY.push(this); + }, + destroyed: function () { + var _this = this; + ARRAY = ARRAY.filter(function (item) { + return item !== _this; + }); + }, + methods: { + open: function (position) { + var _a = this.data, + leftWidth = _a.leftWidth, + rightWidth = _a.rightWidth; + var offset = position === 'left' ? leftWidth : -rightWidth; + this.swipeMove(offset); + this.$emit('open', { + position: position, + name: this.data.name, + }); + }, + close: function () { + this.swipeMove(0); + }, + swipeMove: function (offset) { + if (offset === void 0) { + offset = 0; + } + this.offset = utils_1.range( + offset, + -this.data.rightWidth, + this.data.leftWidth + ); + var transform = 'translate3d(' + this.offset + 'px, 0, 0)'; + var transition = this.dragging + ? 'none' + : 'transform .6s cubic-bezier(0.18, 0.89, 0.32, 1)'; + this.setData({ + wrapperStyle: + '\n -webkit-transform: ' + + transform + + ';\n -webkit-transition: ' + + transition + + ';\n transform: ' + + transform + + ';\n transition: ' + + transition + + ';\n ', + }); + }, + swipeLeaveTransition: function () { + var _a = this.data, + leftWidth = _a.leftWidth, + rightWidth = _a.rightWidth; + var offset = this.offset; + if (rightWidth > 0 && -offset > rightWidth * THRESHOLD) { + this.open('right'); + } else if (leftWidth > 0 && offset > leftWidth * THRESHOLD) { + this.open('left'); + } else { + this.swipeMove(0); + } + this.setData({ catchMove: false }); + }, + startDrag: function (event) { + if (this.data.disabled) { + return; + } + this.startOffset = this.offset; + this.touchStart(event); + }, + noop: function () {}, + onDrag: function (event) { + var _this = this; + if (this.data.disabled) { + return; + } + this.touchMove(event); + if (this.direction !== 'horizontal') { + return; + } + this.dragging = true; + ARRAY.filter(function (item) { + return item !== _this; + }).forEach(function (item) { + return item.close(); + }); + this.setData({ catchMove: true }); + this.swipeMove(this.startOffset + this.deltaX); + }, + endDrag: function () { + if (this.data.disabled) { + return; + } + this.dragging = false; + this.swipeLeaveTransition(); + }, + onClick: function (event) { + var _a = event.currentTarget.dataset.key, + position = _a === void 0 ? 'outside' : _a; + this.$emit('click', position); + if (!this.offset) { + return; + } + if (this.data.asyncClose) { + this.$emit('close', { + position: position, + instance: this, + name: this.data.name, + }); + } else { + this.swipeMove(0); + } + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/swipe-cell/index.json b/miniprogram_npm/@vant/weapp/swipe-cell/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/swipe-cell/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram_npm/@vant/weapp/swipe-cell/index.wxml b/miniprogram_npm/@vant/weapp/swipe-cell/index.wxml new file mode 100644 index 0000000..3f7f726 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/swipe-cell/index.wxml @@ -0,0 +1,20 @@ + + + + + + + + + + + diff --git a/miniprogram_npm/@vant/weapp/swipe-cell/index.wxss b/miniprogram_npm/@vant/weapp/swipe-cell/index.wxss new file mode 100644 index 0000000..d615270 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/swipe-cell/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-swipe-cell{position:relative;overflow:hidden}.van-swipe-cell__left,.van-swipe-cell__right{position:absolute;top:0;height:100%}.van-swipe-cell__left{left:0;-webkit-transform:translate3d(-100%,0,0);transform:translate3d(-100%,0,0)}.van-swipe-cell__right{right:0;-webkit-transform:translate3d(100%,0,0);transform:translate3d(100%,0,0)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/switch/index.js b/miniprogram_npm/@vant/weapp/switch/index.js new file mode 100644 index 0000000..a5b64ad --- /dev/null +++ b/miniprogram_npm/@vant/weapp/switch/index.js @@ -0,0 +1,59 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +var color_1 = require('../common/color'); +component_1.VantComponent({ + field: true, + classes: ['node-class'], + props: { + checked: { + type: null, + observer: function (value) { + var loadingColor = this.getLoadingColor(value); + this.setData({ value: value, loadingColor: loadingColor }); + }, + }, + loading: Boolean, + disabled: Boolean, + activeColor: String, + inactiveColor: String, + size: { + type: String, + value: '30px', + }, + activeValue: { + type: null, + value: true, + }, + inactiveValue: { + type: null, + value: false, + }, + }, + created: function () { + var value = this.data.checked; + var loadingColor = this.getLoadingColor(value); + this.setData({ value: value, loadingColor: loadingColor }); + }, + methods: { + getLoadingColor: function (checked) { + var _a = this.data, + activeColor = _a.activeColor, + inactiveColor = _a.inactiveColor; + return checked + ? activeColor || color_1.BLUE + : inactiveColor || color_1.GRAY_DARK; + }, + onClick: function () { + var _a = this.data, + activeValue = _a.activeValue, + inactiveValue = _a.inactiveValue; + if (!this.data.disabled && !this.data.loading) { + var checked = this.data.checked === activeValue; + var value = checked ? inactiveValue : activeValue; + this.$emit('input', value); + this.$emit('change', value); + } + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/switch/index.json b/miniprogram_npm/@vant/weapp/switch/index.json new file mode 100644 index 0000000..01077f5 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/switch/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-loading": "../loading/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/switch/index.wxml b/miniprogram_npm/@vant/weapp/switch/index.wxml new file mode 100644 index 0000000..31a104d --- /dev/null +++ b/miniprogram_npm/@vant/weapp/switch/index.wxml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/miniprogram_npm/@vant/weapp/switch/index.wxss b/miniprogram_npm/@vant/weapp/switch/index.wxss new file mode 100644 index 0000000..e32a72a --- /dev/null +++ b/miniprogram_npm/@vant/weapp/switch/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-switch{position:relative;display:inline-block;box-sizing:initial;width:2em;width:var(--switch-width,2em);height:1em;height:var(--switch-height,1em);background-color:#fff;background-color:var(--switch-background-color,#fff);border:1px solid rgba(0,0,0,.1);border:var(--switch-border,1px solid rgba(0,0,0,.1));border-radius:1em;border-radius:var(--switch-node-size,1em);transition:background-color .3s;transition:background-color var(--switch-transition-duration,.3s)}.van-switch__node{position:absolute;top:0;left:0;border-radius:100%;z-index:1;z-index:var(--switch-node-z-index,1);width:1em;width:var(--switch-node-size,1em);height:1em;height:var(--switch-node-size,1em);background-color:#fff;background-color:var(--switch-node-background-color,#fff);box-shadow:0 3px 1px 0 rgba(0,0,0,.05),0 2px 2px 0 rgba(0,0,0,.1),0 3px 3px 0 rgba(0,0,0,.05);box-shadow:var(--switch-node-box-shadow,0 3px 1px 0 rgba(0,0,0,.05),0 2px 2px 0 rgba(0,0,0,.1),0 3px 3px 0 rgba(0,0,0,.05));transition:-webkit-transform .3s cubic-bezier(.3,1.05,.4,1.05);transition:transform .3s cubic-bezier(.3,1.05,.4,1.05);transition:transform .3s cubic-bezier(.3,1.05,.4,1.05),-webkit-transform .3s cubic-bezier(.3,1.05,.4,1.05);transition:-webkit-transform var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05);transition:transform var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05);transition:transform var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05),-webkit-transform var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05)}.van-switch__loading{position:absolute!important;top:25%;left:25%;width:50%;height:50%}.van-switch--on{background-color:#1989fa;background-color:var(--switch-on-background-color,#1989fa)}.van-switch--on .van-switch__node{-webkit-transform:translateX(1em);transform:translateX(1em);-webkit-transform:translateX(calc(var(--switch-width, 2em) - var(--switch-node-size, 1em)));transform:translateX(calc(var(--switch-width, 2em) - var(--switch-node-size, 1em)))}.van-switch--disabled{opacity:.4;opacity:var(--switch-disabled-opacity,.4)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/tab/index.js b/miniprogram_npm/@vant/weapp/tab/index.js new file mode 100644 index 0000000..554d9d5 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/tab/index.js @@ -0,0 +1,61 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +component_1.VantComponent({ + relation: { + name: 'tabs', + type: 'ancestor', + current: 'tab', + }, + props: { + dot: { + type: Boolean, + observer: 'update', + }, + info: { + type: null, + observer: 'update', + }, + title: { + type: String, + observer: 'update', + }, + disabled: { + type: Boolean, + observer: 'update', + }, + titleStyle: { + type: String, + observer: 'update', + }, + name: { + type: [Number, String], + value: '', + }, + }, + data: { + active: false, + }, + methods: { + getComputedName: function () { + if (this.data.name !== '') { + return this.data.name; + } + return this.index; + }, + updateRender: function (active, parent) { + var parentData = parent.data; + this.inited = this.inited || active; + this.setData({ + active: active, + shouldRender: this.inited || !parentData.lazyRender, + shouldShow: active || parentData.animated, + }); + }, + update: function () { + if (this.parent) { + this.parent.updateTabs(); + } + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/tab/index.json b/miniprogram_npm/@vant/weapp/tab/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/tab/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram_npm/@vant/weapp/tab/index.wxml b/miniprogram_npm/@vant/weapp/tab/index.wxml new file mode 100644 index 0000000..f5e99f2 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/tab/index.wxml @@ -0,0 +1,8 @@ + + + + + diff --git a/miniprogram_npm/@vant/weapp/tab/index.wxss b/miniprogram_npm/@vant/weapp/tab/index.wxss new file mode 100644 index 0000000..76ddf06 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/tab/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';:host{-webkit-flex-shrink:0;flex-shrink:0;width:100%}.van-tab__pane,:host{box-sizing:border-box}.van-tab__pane{overflow-y:auto;-webkit-overflow-scrolling:touch}.van-tab__pane--active{height:auto}.van-tab__pane--inactive{height:0;overflow:visible} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/tabbar-item/index.js b/miniprogram_npm/@vant/weapp/tabbar-item/index.js new file mode 100644 index 0000000..a83fa39 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/tabbar-item/index.js @@ -0,0 +1,59 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +component_1.VantComponent({ + props: { + info: null, + name: null, + icon: String, + dot: Boolean, + iconPrefix: { + type: String, + value: 'van-icon', + }, + }, + relation: { + name: 'tabbar', + type: 'ancestor', + current: 'tabbar-item', + }, + data: { + active: false, + }, + methods: { + onClick: function () { + var parent = this.parent; + if (parent) { + var index = parent.children.indexOf(this); + var active = this.data.name || index; + if (active !== this.data.active) { + parent.$emit('change', active); + } + } + this.$emit('click'); + }, + updateFromParent: function () { + var parent = this.parent; + if (!parent) { + return; + } + var index = parent.children.indexOf(this); + var parentData = parent.data; + var data = this.data; + var active = (data.name || index) === parentData.active; + var patch = {}; + if (active !== data.active) { + patch.active = active; + } + if (parentData.activeColor !== data.activeColor) { + patch.activeColor = parentData.activeColor; + } + if (parentData.inactiveColor !== data.inactiveColor) { + patch.inactiveColor = parentData.inactiveColor; + } + if (Object.keys(patch).length > 0) { + this.setData(patch); + } + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/tabbar-item/index.json b/miniprogram_npm/@vant/weapp/tabbar-item/index.json new file mode 100644 index 0000000..16f174c --- /dev/null +++ b/miniprogram_npm/@vant/weapp/tabbar-item/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index", + "van-info": "../info/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/tabbar-item/index.wxml b/miniprogram_npm/@vant/weapp/tabbar-item/index.wxml new file mode 100644 index 0000000..524728f --- /dev/null +++ b/miniprogram_npm/@vant/weapp/tabbar-item/index.wxml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + diff --git a/miniprogram_npm/@vant/weapp/tabbar-item/index.wxss b/miniprogram_npm/@vant/weapp/tabbar-item/index.wxss new file mode 100644 index 0000000..ff33bd2 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/tabbar-item/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';:host{-webkit-flex:1;flex:1}.van-tabbar-item{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;height:100%;color:#646566;color:var(--tabbar-item-text-color,#646566);font-size:12px;font-size:var(--tabbar-item-font-size,12px);line-height:1;line-height:var(--tabbar-item-line-height,1)}.van-tabbar-item__icon{position:relative;margin-bottom:4px;margin-bottom:var(--tabbar-item-margin-bottom,4px);font-size:22px;font-size:var(--tabbar-item-icon-size,22px)}.van-tabbar-item__icon__inner{display:block;min-width:1em}.van-tabbar-item--active{color:#1989fa;color:var(--tabbar-item-active-color,#1989fa)}.van-tabbar-item__info{margin-top:2px} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/tabbar/index.js b/miniprogram_npm/@vant/weapp/tabbar/index.js new file mode 100644 index 0000000..c2cfed6 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/tabbar/index.js @@ -0,0 +1,78 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var utils_1 = require('../common/utils'); +var component_1 = require('../common/component'); +component_1.VantComponent({ + relation: { + name: 'tabbar-item', + type: 'descendant', + current: 'tabbar', + linked: function (target) { + target.parent = this; + target.updateFromParent(); + }, + unlinked: function () { + this.updateChildren(); + }, + }, + props: { + active: { + type: null, + observer: 'updateChildren', + }, + activeColor: { + type: String, + observer: 'updateChildren', + }, + inactiveColor: { + type: String, + observer: 'updateChildren', + }, + fixed: { + type: Boolean, + value: true, + observer: 'setHeight', + }, + placeholder: { + type: Boolean, + observer: 'setHeight', + }, + border: { + type: Boolean, + value: true, + }, + zIndex: { + type: Number, + value: 1, + }, + safeAreaInsetBottom: { + type: Boolean, + value: true, + }, + }, + data: { + height: 50, + }, + methods: { + updateChildren: function () { + var children = this.children; + if (!Array.isArray(children) || !children.length) { + return; + } + children.forEach(function (child) { + return child.updateFromParent(); + }); + }, + setHeight: function () { + var _this = this; + if (!this.data.fixed || !this.data.placeholder) { + return; + } + wx.nextTick(function () { + utils_1.getRect.call(_this, '.van-tabbar').then(function (res) { + _this.setData({ height: res.height }); + }); + }); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/tabbar/index.json b/miniprogram_npm/@vant/weapp/tabbar/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/tabbar/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram_npm/@vant/weapp/tabbar/index.wxml b/miniprogram_npm/@vant/weapp/tabbar/index.wxml new file mode 100644 index 0000000..43bb111 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/tabbar/index.wxml @@ -0,0 +1,10 @@ + + + + + + + diff --git a/miniprogram_npm/@vant/weapp/tabbar/index.wxss b/miniprogram_npm/@vant/weapp/tabbar/index.wxss new file mode 100644 index 0000000..6819569 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/tabbar/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-tabbar{display:-webkit-flex;display:flex;box-sizing:initial;width:100%;height:50px;height:var(--tabbar-height,50px);background-color:#fff;background-color:var(--tabbar-background-color,#fff)}.van-tabbar--fixed{position:fixed;bottom:0;left:0}.van-tabbar--safe{padding-bottom:env(safe-area-inset-bottom)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/tabs/index.js b/miniprogram_npm/@vant/weapp/tabs/index.js new file mode 100644 index 0000000..1ed7f12 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/tabs/index.js @@ -0,0 +1,320 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +var touch_1 = require('../mixins/touch'); +var utils_1 = require('../common/utils'); +component_1.VantComponent({ + mixins: [touch_1.touch], + classes: ['nav-class', 'tab-class', 'tab-active-class', 'line-class'], + relation: { + name: 'tab', + type: 'descendant', + current: 'tabs', + linked: function (target) { + target.index = this.children.length - 1; + this.updateTabs(); + }, + unlinked: function () { + this.children = this.children.map(function (child, index) { + child.index = index; + return child; + }); + this.updateTabs(); + }, + }, + props: { + sticky: Boolean, + border: Boolean, + swipeable: Boolean, + titleActiveColor: String, + titleInactiveColor: String, + color: String, + animated: { + type: Boolean, + observer: function () { + var _this = this; + this.children.forEach(function (child, index) { + return child.updateRender(index === _this.data.currentIndex, _this); + }); + }, + }, + lineWidth: { + type: [String, Number], + value: 10, + observer: 'setLine', + }, + lineHeight: { + type: [String, Number], + value: -1, + }, + active: { + type: [String, Number], + value: 0, + observer: function (name) { + if (name !== this.getCurrentName()) { + this.setCurrentIndexByName(name); + } + }, + }, + type: { + type: String, + value: 'line', + }, + ellipsis: { + type: Boolean, + value: true, + }, + duration: { + type: Number, + value: 0.3, + }, + zIndex: { + type: Number, + value: 1, + }, + swipeThreshold: { + type: Number, + value: 5, + observer: function (value) { + this.setData({ + scrollable: this.children.length > value || !this.data.ellipsis, + }); + }, + }, + offsetTop: { + type: Number, + value: 0, + }, + lazyRender: { + type: Boolean, + value: true, + }, + }, + data: { + tabs: [], + lineStyle: '', + scrollLeft: 0, + scrollable: false, + trackStyle: '', + currentIndex: 0, + container: null, + skipTransition: true, + lineOffsetLeft: 0, + }, + mounted: function () { + var _this = this; + wx.nextTick(function () { + _this.setLine(true); + _this.scrollIntoView(); + }); + }, + methods: { + updateContainer: function () { + var _this = this; + this.setData({ + container: function () { + return _this.createSelectorQuery().select('.van-tabs'); + }, + }); + }, + updateTabs: function () { + var _a = this, + _b = _a.children, + children = _b === void 0 ? [] : _b, + data = _a.data; + this.setData({ + tabs: children.map(function (child) { + return child.data; + }), + scrollable: + this.children.length > data.swipeThreshold || !data.ellipsis, + }); + this.setCurrentIndexByName(this.getCurrentName() || data.active); + }, + trigger: function (eventName, child) { + var currentIndex = this.data.currentIndex; + var currentChild = child || this.children[currentIndex]; + if (!utils_1.isDef(currentChild)) { + return; + } + this.$emit(eventName, { + index: currentChild.index, + name: currentChild.getComputedName(), + title: currentChild.data.title, + }); + }, + onTap: function (event) { + var _this = this; + var index = event.currentTarget.dataset.index; + var child = this.children[index]; + if (child.data.disabled) { + this.trigger('disabled', child); + } else { + this.setCurrentIndex(index); + wx.nextTick(function () { + _this.trigger('click'); + }); + } + }, + // correct the index of active tab + setCurrentIndexByName: function (name) { + var _a = this.children, + children = _a === void 0 ? [] : _a; + var matched = children.filter(function (child) { + return child.getComputedName() === name; + }); + if (matched.length) { + this.setCurrentIndex(matched[0].index); + } + }, + setCurrentIndex: function (currentIndex) { + var _this = this; + var _a = this, + data = _a.data, + _b = _a.children, + children = _b === void 0 ? [] : _b; + if ( + !utils_1.isDef(currentIndex) || + currentIndex >= children.length || + currentIndex < 0 + ) { + return; + } + children.forEach(function (item, index) { + var active = index === currentIndex; + if (active !== item.data.active || !item.inited) { + item.updateRender(active, _this); + } + }); + if (currentIndex === data.currentIndex) { + return; + } + var shouldEmitChange = data.currentIndex !== null; + this.setData({ currentIndex: currentIndex }); + wx.nextTick(function () { + _this.setLine(); + _this.scrollIntoView(); + _this.updateContainer(); + _this.trigger('input'); + if (shouldEmitChange) { + _this.trigger('change'); + } + }); + }, + getCurrentName: function () { + var activeTab = this.children[this.data.currentIndex]; + if (activeTab) { + return activeTab.getComputedName(); + } + }, + setLine: function (skipTransition) { + var _this = this; + if (skipTransition === void 0) { + skipTransition = false; + } + if (this.data.type !== 'line') { + return; + } + var _a = this.data, + currentIndex = _a.currentIndex, + ellipsis = _a.ellipsis; + Promise.all([ + utils_1.getAllRect.call(this, '.van-tab'), + utils_1.getRect.call(this, '.van-tabs__line'), + ]).then(function (_a) { + var _b = _a[0], + rects = _b === void 0 ? [] : _b, + lineRect = _a[1]; + var rect = rects[currentIndex]; + if (rect == null) { + return; + } + var lineOffsetLeft = rects + .slice(0, currentIndex) + .reduce(function (prev, curr) { + return prev + curr.width; + }, 0); + lineOffsetLeft += + (rect.width - lineRect.width) / 2 + (ellipsis ? 0 : 8); + _this.setData({ + lineOffsetLeft: lineOffsetLeft, + skipTransition: skipTransition, + }); + }); + }, + // scroll active tab into view + scrollIntoView: function () { + var _this = this; + var _a = this.data, + currentIndex = _a.currentIndex, + scrollable = _a.scrollable; + if (!scrollable) { + return; + } + Promise.all([ + utils_1.getAllRect.call(this, '.van-tab'), + utils_1.getRect.call(this, '.van-tabs__nav'), + ]).then(function (_a) { + var tabRects = _a[0], + navRect = _a[1]; + var tabRect = tabRects[currentIndex]; + var offsetLeft = tabRects + .slice(0, currentIndex) + .reduce(function (prev, curr) { + return prev + curr.width; + }, 0); + _this.setData({ + scrollLeft: offsetLeft - (navRect.width - tabRect.width) / 2, + }); + }); + }, + onTouchScroll: function (event) { + this.$emit('scroll', event.detail); + }, + onTouchStart: function (event) { + if (!this.data.swipeable) return; + this.touchStart(event); + }, + onTouchMove: function (event) { + if (!this.data.swipeable) return; + this.touchMove(event); + }, + // watch swipe touch end + onTouchEnd: function () { + if (!this.data.swipeable) return; + var _a = this, + direction = _a.direction, + deltaX = _a.deltaX, + offsetX = _a.offsetX; + var minSwipeDistance = 50; + if (direction === 'horizontal' && offsetX >= minSwipeDistance) { + var index = this.getAvaiableTab(deltaX); + if (index !== -1) { + this.setCurrentIndex(index); + } + } + }, + getAvaiableTab: function (direction) { + var _a = this.data, + tabs = _a.tabs, + currentIndex = _a.currentIndex; + var step = direction > 0 ? -1 : 1; + for ( + var i = step; + currentIndex + i < tabs.length && currentIndex + i >= 0; + i += step + ) { + var index = currentIndex + i; + if ( + index >= 0 && + index < tabs.length && + tabs[index] && + !tabs[index].disabled + ) { + return index; + } + } + return -1; + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/tabs/index.json b/miniprogram_npm/@vant/weapp/tabs/index.json new file mode 100644 index 0000000..19c0bc3 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/tabs/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "van-info": "../info/index", + "van-sticky": "../sticky/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/tabs/index.wxml b/miniprogram_npm/@vant/weapp/tabs/index.wxml new file mode 100644 index 0000000..dd92ac4 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/tabs/index.wxml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + {{ item.title }} + + + + + + + + + + + + + + + + diff --git a/miniprogram_npm/@vant/weapp/tabs/index.wxs b/miniprogram_npm/@vant/weapp/tabs/index.wxs new file mode 100644 index 0000000..60c48fd --- /dev/null +++ b/miniprogram_npm/@vant/weapp/tabs/index.wxs @@ -0,0 +1,115 @@ +/* eslint-disable */ +var utils = require('../wxs/utils.wxs'); + +function tabClass(active, ellipsis) { + var classes = ['tab-class']; + + if (active) { + classes.push('tab-active-class'); + } + + if (ellipsis) { + classes.push('van-ellipsis'); + } + + return classes.join(' '); +} + +function tabStyle( + active, + ellipsis, + color, + type, + disabled, + activeColor, + inactiveColor, + swipeThreshold, + scrollable +) { + var styles = []; + var isCard = type === 'card'; + // card theme color + if (color && isCard) { + styles.push('border-color:' + color); + + if (!disabled) { + if (active) { + styles.push('background-color:' + color); + } else { + styles.push('color:' + color); + } + } + } + + var titleColor = active ? activeColor : inactiveColor; + if (titleColor) { + styles.push('color:' + titleColor); + } + + if (scrollable && ellipsis) { + styles.push('flex-basis:' + 88 / swipeThreshold + '%'); + } + + return styles.join(';'); +} + +function tabCardTypeBorderStyle(color, type) { + var isCard = type === 'card'; + var styles = []; + if (isCard && color) { + styles.push('border-color:' + color); + } + return styles.join(';'); +} + +function trackStyle(data) { + if (!data.animated) { + return ''; + } + + return [ + ['left', -100 * data.currentIndex + '%'], + ['-webkit-transition-duration', data.duration + 's'], + ['transition-duration: ', data.duration + 's'], + ] + .map(function (item) { + return item.join(':'); + }) + .join(';'); +} + +function lineStyle(data) { + var styles = [ + ['width', utils.addUnit(data.lineWidth)], + ['transform', 'translateX(' + data.lineOffsetLeft + 'px)'], + ['-webkit-transform', 'translateX(' + data.lineOffsetLeft + 'px)'], + ]; + + if (data.color) { + styles.push(['background-color', data.color]); + } + + if (data.lineHeight !== -1) { + styles.push(['height', utils.addUnit(data.lineHeight)]); + styles.push(['border-radius', utils.addUnit(data.lineHeight)]); + } + + if (!data.skipTransition) { + styles.push(['transition-duration', data.duration + 's']); + styles.push(['-webkit-transition-duration', data.duration + 's']); + } + + return styles + .map(function (item) { + return item.join(':'); + }) + .join(';'); +} + +module.exports = { + tabClass: tabClass, + tabStyle: tabStyle, + trackStyle: trackStyle, + lineStyle: lineStyle, + tabCardTypeBorderStyle: tabCardTypeBorderStyle, +}; diff --git a/miniprogram_npm/@vant/weapp/tabs/index.wxss b/miniprogram_npm/@vant/weapp/tabs/index.wxss new file mode 100644 index 0000000..3b469f8 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/tabs/index.wxss @@ -0,0 +1,166 @@ +@import '../common/index.wxss'; + +.van-tabs { + position: relative; + -webkit-tap-highlight-color: transparent +} + +.van-tabs__wrap { + display: -webkit-flex; + display: flex; + overflow: hidden +} + +.van-tabs__wrap--scrollable .van-tab { + -webkit-flex: 0 0 22%; + flex: 0 0 22% +} + +.van-tabs__wrap--scrollable .van-tab--complete { + -webkit-flex: 1 0 auto !important; + flex: 1 0 auto !important; + padding: 0 12px +} + +.van-tabs__wrap--scrollable .van-tabs__nav--complete { + padding-right: 8px; + padding-left: 8px +} + +.van-tabs__scroll { + background-color: #fff; + background-color: var(--tabs-nav-background-color, #fff) +} + +.van-tabs__scroll--line { + box-sizing: initial; + height: calc(100% + 15px) +} + +.van-tabs__scroll--card { + margin: 0 16px; + margin: 0 var(--padding-md, 16px) +} + +.van-tabs__scroll::-webkit-scrollbar { + display: none +} + +.van-tabs__nav { + position: relative; + display: -webkit-flex; + display: flex; + -webkit-user-select: none; + user-select: none +} + +.van-tabs__nav--card { + box-sizing: border-box; + height: 30px; + height: var(--tabs-card-height, 30px); + border: 1px solid #ee0a24; + border: var(--border-width-base, 1px) solid var(--tabs-default-color, #ee0a24); + border-radius: 2px; + border-radius: var(--border-radius-sm, 2px) +} + +.van-tabs__nav--card .van-tab { + color: #ee0a24; + color: var(--tabs-default-color, #ee0a24); + line-height: 28px; + line-height: calc(var(--tabs-card-height, 30px) - var(--border-width-base, 1px)*2); + border-right: 1px solid #ee0a24; + border-right: var(--border-width-base, 1px) solid var(--tabs-default-color, #ee0a24) +} + +.van-tabs__nav--card .van-tab:last-child { + border-right: none +} + +.van-tabs__nav--card .van-tab.van-tab--active { + color: #fff; + color: var(--white, #fff); + background-color: #ee0a24; + background-color: var(--tabs-default-color, #ee0a24) +} + +.van-tabs__nav--card .van-tab--disabled { + color: #c8c9cc; + color: var(--tab-disabled-text-color, #c8c9cc) +} + +.van-tabs__line { + position: absolute; + bottom: 0; + left: 0; + z-index: 1; + height: 3px; + height: var(--tabs-bottom-bar-height, 3px); + border-radius: 3px; + border-radius: var(--tabs-bottom-bar-height, 3px); + background-color: #ee0a24; + background-color: var(--tabs-bottom-bar-color, #ee0a24) +} + +.van-tabs__track { + position: relative; + width: 100%; + height: 100% +} + +.van-tabs__track--animated { + display: -webkit-flex; + display: flex; + transition-property: left +} + +.van-tabs__content { + overflow: hidden +} + +.van-tabs--line .van-tabs__wrap { + height: 44px; + height: var(--tabs-line-height, 44px) +} + +.van-tabs--card .van-tabs__wrap { + height: 30px; + height: var(--tabs-card-height, 30px) +} + +.van-tab { + position: relative; + -webkit-flex: 1; + flex: 1; + box-sizing: border-box; + min-width: 0; + padding: 0 5px; + text-align: center; + cursor: pointer; + color: #646566; + color: var(--tab-text-color, #646566); + font-size: 14px; + font-size: var(--tab-font-size, 14px); + line-height: 44px; + line-height: var(--tabs-line-height, 44px) +} + +.van-tab--active { + font-weight: 500; + font-weight: var(--font-weight-bold, 500); + color: #323233; + color: var(--tab-active-text-color, #323233) +} + +.van-tab--disabled { + color: #c8c9cc; + color: var(--tab-disabled-text-color, #c8c9cc) +} + +.van-tab__title__info { + position: relative !important; + top: -1px !important; + display: inline-block; + -webkit-transform: translateX(0) !important; + transform: translateX(0) !important +} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/tag/index.js b/miniprogram_npm/@vant/weapp/tag/index.js new file mode 100644 index 0000000..b51d3fb --- /dev/null +++ b/miniprogram_npm/@vant/weapp/tag/index.js @@ -0,0 +1,23 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +component_1.VantComponent({ + props: { + size: String, + mark: Boolean, + color: String, + plain: Boolean, + round: Boolean, + textColor: String, + type: { + type: String, + value: 'default', + }, + closeable: Boolean, + }, + methods: { + onClose: function () { + this.$emit('close'); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/tag/index.json b/miniprogram_npm/@vant/weapp/tag/index.json new file mode 100644 index 0000000..0a336c0 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/tag/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/tag/index.wxml b/miniprogram_npm/@vant/weapp/tag/index.wxml new file mode 100644 index 0000000..16ab750 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/tag/index.wxml @@ -0,0 +1,14 @@ + + + + + + diff --git a/miniprogram_npm/@vant/weapp/tag/index.wxss b/miniprogram_npm/@vant/weapp/tag/index.wxss new file mode 100644 index 0000000..46df0da --- /dev/null +++ b/miniprogram_npm/@vant/weapp/tag/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-tag{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;padding:0 4px;padding:var(--tag-padding,0 4px);color:#fff;color:var(--tag-text-color,#fff);font-size:12px;font-size:var(--tag-font-size,12px);line-height:16px;line-height:var(--tag-line-height,16px);border-radius:2px;border-radius:var(--tag-border-radius,2px)}.van-tag--default{background-color:#969799;background-color:var(--tag-default-color,#969799)}.van-tag--default.van-tag--plain{color:#969799;color:var(--tag-default-color,#969799)}.van-tag--danger{background-color:#ee0a24;background-color:var(--tag-danger-color,#ee0a24)}.van-tag--danger.van-tag--plain{color:#ee0a24;color:var(--tag-danger-color,#ee0a24)}.van-tag--primary{background-color:#1989fa;background-color:var(--tag-primary-color,#1989fa)}.van-tag--primary.van-tag--plain{color:#1989fa;color:var(--tag-primary-color,#1989fa)}.van-tag--success{background-color:#07c160;background-color:var(--tag-success-color,#07c160)}.van-tag--success.van-tag--plain{color:#07c160;color:var(--tag-success-color,#07c160)}.van-tag--warning{background-color:#ff976a;background-color:var(--tag-warning-color,#ff976a)}.van-tag--warning.van-tag--plain{color:#ff976a;color:var(--tag-warning-color,#ff976a)}.van-tag--plain{background-color:#fff;background-color:var(--tag-plain-background-color,#fff)}.van-tag--plain:before{position:absolute;top:0;right:0;bottom:0;left:0;border:1px solid;border-radius:inherit;content:"";pointer-events:none}.van-tag--medium{padding:2px 6px;padding:var(--tag-medium-padding,2px 6px)}.van-tag--large{padding:4px 8px;padding:var(--tag-large-padding,4px 8px);font-size:14px;font-size:var(--tag-large-font-size,14px);border-radius:4px;border-radius:var(--tag-large-border-radius,4px)}.van-tag--mark{border-radius:0 999px 999px 0;border-radius:0 var(--tag-round-border-radius,999px) var(--tag-round-border-radius,999px) 0}.van-tag--mark:after{display:block;width:2px;content:""}.van-tag--round{border-radius:999px;border-radius:var(--tag-round-border-radius,999px)}.van-tag__close{min-width:1em;margin-left:2px} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/toast/index.js b/miniprogram_npm/@vant/weapp/toast/index.js new file mode 100644 index 0000000..da703bb --- /dev/null +++ b/miniprogram_npm/@vant/weapp/toast/index.js @@ -0,0 +1,31 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +component_1.VantComponent({ + props: { + show: Boolean, + mask: Boolean, + message: String, + forbidClick: Boolean, + zIndex: { + type: Number, + value: 1000, + }, + type: { + type: String, + value: 'text', + }, + loadingType: { + type: String, + value: 'circular', + }, + position: { + type: String, + value: 'middle', + }, + }, + methods: { + // for prevent touchmove + noop: function () {}, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/toast/index.json b/miniprogram_npm/@vant/weapp/toast/index.json new file mode 100644 index 0000000..9b1b78c --- /dev/null +++ b/miniprogram_npm/@vant/weapp/toast/index.json @@ -0,0 +1,9 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index", + "van-loading": "../loading/index", + "van-overlay": "../overlay/index", + "van-transition": "../transition/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/toast/index.wxml b/miniprogram_npm/@vant/weapp/toast/index.wxml new file mode 100644 index 0000000..635e7d6 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/toast/index.wxml @@ -0,0 +1,33 @@ + + + + + {{ message }} + + + + + + {{ message }} + + + + + diff --git a/miniprogram_npm/@vant/weapp/toast/index.wxss b/miniprogram_npm/@vant/weapp/toast/index.wxss new file mode 100644 index 0000000..85dc7a8 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/toast/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-toast{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:initial;color:#fff;color:var(--toast-text-color,#fff);font-size:14px;font-size:var(--toast-font-size,14px);line-height:20px;line-height:var(--toast-line-height,20px);white-space:pre-wrap;word-wrap:break-word;background-color:rgba(0,0,0,.7);background-color:var(--toast-background-color,rgba(0,0,0,.7));border-radius:8px;border-radius:var(--toast-border-radius,8px)}.van-toast__container{position:fixed;top:50%;left:50%;width:-webkit-fit-content;width:fit-content;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);max-width:70%;max-width:var(--toast-max-width,70%)}.van-toast--text{min-width:96px;min-width:var(--toast-text-min-width,96px);padding:8px 12px;padding:var(--toast-text-padding,8px 12px)}.van-toast--icon{width:88px;width:var(--toast-default-width,88px);min-height:88px;min-height:var(--toast-default-min-height,88px);padding:16px;padding:var(--toast-default-padding,16px)}.van-toast--icon .van-toast__icon{font-size:36px;font-size:var(--toast-icon-size,36px)}.van-toast--icon .van-toast__text{padding-top:8px}.van-toast__loading{margin:10px 0}.van-toast--top{-webkit-transform:translateY(-30vh);transform:translateY(-30vh)}.van-toast--bottom{-webkit-transform:translateY(30vh);transform:translateY(30vh)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/toast/toast.js b/miniprogram_npm/@vant/weapp/toast/toast.js new file mode 100644 index 0000000..302059b --- /dev/null +++ b/miniprogram_npm/@vant/weapp/toast/toast.js @@ -0,0 +1,92 @@ +'use strict'; +var __assign = + (this && this.__assign) || + function () { + __assign = + Object.assign || + function (t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) + if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); + }; +Object.defineProperty(exports, '__esModule', { value: true }); +var utils_1 = require('../common/utils'); +var defaultOptions = { + type: 'text', + mask: false, + message: '', + show: true, + zIndex: 1000, + duration: 2000, + position: 'middle', + forbidClick: false, + loadingType: 'circular', + selector: '#van-toast', +}; +var queue = []; +var currentOptions = __assign({}, defaultOptions); +function parseOptions(message) { + return utils_1.isObj(message) ? message : { message: message }; +} +function getContext() { + var pages = getCurrentPages(); + return pages[pages.length - 1]; +} +function Toast(toastOptions) { + var options = __assign( + __assign({}, currentOptions), + parseOptions(toastOptions) + ); + var context = options.context || getContext(); + var toast = context.selectComponent(options.selector); + if (!toast) { + console.warn('未找到 van-toast 节点,请确认 selector 及 context 是否正确'); + return; + } + delete options.context; + delete options.selector; + toast.clear = function () { + toast.setData({ show: false }); + if (options.onClose) { + options.onClose(); + } + }; + queue.push(toast); + toast.setData(options); + clearTimeout(toast.timer); + if (options.duration != null && options.duration > 0) { + toast.timer = setTimeout(function () { + toast.clear(); + queue = queue.filter(function (item) { + return item !== toast; + }); + }, options.duration); + } + return toast; +} +var createMethod = function (type) { + return function (options) { + return Toast(__assign({ type: type }, parseOptions(options))); + }; +}; +Toast.loading = createMethod('loading'); +Toast.success = createMethod('success'); +Toast.fail = createMethod('fail'); +Toast.clear = function () { + queue.forEach(function (toast) { + toast.clear(); + }); + queue = []; +}; +Toast.setDefaultOptions = function (options) { + Object.assign(currentOptions, options); +}; +Toast.resetDefaultOptions = function () { + currentOptions = __assign({}, defaultOptions); +}; +exports.default = Toast; diff --git a/miniprogram_npm/@vant/weapp/transition/index.js b/miniprogram_npm/@vant/weapp/transition/index.js new file mode 100644 index 0000000..f3c96e4 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/transition/index.js @@ -0,0 +1,15 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +var transition_1 = require('../mixins/transition'); +component_1.VantComponent({ + classes: [ + 'enter-class', + 'enter-active-class', + 'enter-to-class', + 'leave-class', + 'leave-active-class', + 'leave-to-class', + ], + mixins: [transition_1.transition(true)], +}); diff --git a/miniprogram_npm/@vant/weapp/transition/index.json b/miniprogram_npm/@vant/weapp/transition/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/transition/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/miniprogram_npm/@vant/weapp/transition/index.wxml b/miniprogram_npm/@vant/weapp/transition/index.wxml new file mode 100644 index 0000000..412e8af --- /dev/null +++ b/miniprogram_npm/@vant/weapp/transition/index.wxml @@ -0,0 +1,8 @@ + + + diff --git a/miniprogram_npm/@vant/weapp/transition/index.wxss b/miniprogram_npm/@vant/weapp/transition/index.wxss new file mode 100644 index 0000000..d459f5c --- /dev/null +++ b/miniprogram_npm/@vant/weapp/transition/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-transition{transition-timing-function:ease}.van-fade-enter-active,.van-fade-leave-active{transition-property:opacity}.van-fade-enter,.van-fade-leave-to{opacity:0}.van-fade-down-enter-active,.van-fade-down-leave-active,.van-fade-left-enter-active,.van-fade-left-leave-active,.van-fade-right-enter-active,.van-fade-right-leave-active,.van-fade-up-enter-active,.van-fade-up-leave-active{transition-property:opacity,-webkit-transform;transition-property:opacity,transform;transition-property:opacity,transform,-webkit-transform}.van-fade-up-enter,.van-fade-up-leave-to{-webkit-transform:translate3d(0,100%,0);transform:translate3d(0,100%,0);opacity:0}.van-fade-down-enter,.van-fade-down-leave-to{-webkit-transform:translate3d(0,-100%,0);transform:translate3d(0,-100%,0);opacity:0}.van-fade-left-enter,.van-fade-left-leave-to{-webkit-transform:translate3d(-100%,0,0);transform:translate3d(-100%,0,0);opacity:0}.van-fade-right-enter,.van-fade-right-leave-to{-webkit-transform:translate3d(100%,0,0);transform:translate3d(100%,0,0);opacity:0}.van-slide-down-enter-active,.van-slide-down-leave-active,.van-slide-left-enter-active,.van-slide-left-leave-active,.van-slide-right-enter-active,.van-slide-right-leave-active,.van-slide-up-enter-active,.van-slide-up-leave-active{transition-property:-webkit-transform;transition-property:transform;transition-property:transform,-webkit-transform}.van-slide-up-enter,.van-slide-up-leave-to{-webkit-transform:translate3d(0,100%,0);transform:translate3d(0,100%,0)}.van-slide-down-enter,.van-slide-down-leave-to{-webkit-transform:translate3d(0,-100%,0);transform:translate3d(0,-100%,0)}.van-slide-left-enter,.van-slide-left-leave-to{-webkit-transform:translate3d(-100%,0,0);transform:translate3d(-100%,0,0)}.van-slide-right-enter,.van-slide-right-leave-to{-webkit-transform:translate3d(100%,0,0);transform:translate3d(100%,0,0)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/tree-select/index.js b/miniprogram_npm/@vant/weapp/tree-select/index.js new file mode 100644 index 0000000..e43744b --- /dev/null +++ b/miniprogram_npm/@vant/weapp/tree-select/index.js @@ -0,0 +1,73 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +component_1.VantComponent({ + classes: [ + 'main-item-class', + 'content-item-class', + 'main-active-class', + 'content-active-class', + 'main-disabled-class', + 'content-disabled-class', + ], + props: { + items: { + type: Array, + observer: 'updateSubItems', + }, + activeId: null, + mainActiveIndex: { + type: Number, + value: 0, + observer: 'updateSubItems', + }, + height: { + type: [Number, String], + value: 300, + }, + max: { + type: Number, + value: Infinity, + }, + selectedIcon: { + type: String, + value: 'success', + }, + }, + data: { + subItems: [], + }, + methods: { + // 当一个子项被选择时 + onSelectItem: function (event) { + var item = event.currentTarget.dataset.item; + var isArray = Array.isArray(this.data.activeId); + // 判断有没有超出右侧选择的最大数 + var isOverMax = isArray && this.data.activeId.length >= this.data.max; + // 判断该项有没有被选中, 如果有被选中,则忽视是否超出的条件 + var isSelected = isArray + ? this.data.activeId.indexOf(item.id) > -1 + : this.data.activeId === item.id; + if (!item.disabled && (!isOverMax || isSelected)) { + this.$emit('click-item', item); + } + }, + // 当一个导航被点击时 + onClickNav: function (event) { + var index = event.detail; + var item = this.data.items[index]; + if (!item.disabled) { + this.$emit('click-nav', { index: index }); + } + }, + // 更新子项列表 + updateSubItems: function () { + var _a = this.data, + items = _a.items, + mainActiveIndex = _a.mainActiveIndex; + var _b = (items[mainActiveIndex] || {}).children, + children = _b === void 0 ? [] : _b; + return this.set({ subItems: children }); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/tree-select/index.json b/miniprogram_npm/@vant/weapp/tree-select/index.json new file mode 100644 index 0000000..42991a2 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/tree-select/index.json @@ -0,0 +1,8 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index", + "van-sidebar": "../sidebar/index", + "van-sidebar-item": "../sidebar-item/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/tree-select/index.wxml b/miniprogram_npm/@vant/weapp/tree-select/index.wxml new file mode 100644 index 0000000..2663e52 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/tree-select/index.wxml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + {{ item.text }} + + + + diff --git a/miniprogram_npm/@vant/weapp/tree-select/index.wxs b/miniprogram_npm/@vant/weapp/tree-select/index.wxs new file mode 100644 index 0000000..b1cbb39 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/tree-select/index.wxs @@ -0,0 +1,12 @@ +/* eslint-disable */ +var array = require('../wxs/array.wxs'); + +function isActive (activeList, itemId) { + if (array.isArray(activeList)) { + return activeList.indexOf(itemId) > -1; + } + + return activeList === itemId; +} + +module.exports.isActive = isActive; diff --git a/miniprogram_npm/@vant/weapp/tree-select/index.wxss b/miniprogram_npm/@vant/weapp/tree-select/index.wxss new file mode 100644 index 0000000..3f7cca6 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/tree-select/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-tree-select{position:relative;display:-webkit-flex;display:flex;-webkit-user-select:none;user-select:none;font-size:14px;font-size:var(--tree-select-font-size,14px)}.van-tree-select__nav{-webkit-flex:1;flex:1;background-color:#f7f8fa;background-color:var(--tree-select-nav-background-color,#f7f8fa);--sidebar-padding:12px 8px 12px 12px}.van-tree-select__nav__inner{width:100%!important;height:100%}.van-tree-select__content{-webkit-flex:2;flex:2;background-color:#fff;background-color:var(--tree-select-content-background-color,#fff)}.van-tree-select__item{position:relative;font-weight:700;padding:0 32px 0 16px;padding:0 32px 0 var(--padding-md,16px);line-height:44px;line-height:var(--tree-select-item-height,44px)}.van-tree-select__item--active{color:#ee0a24;color:var(--tree-select-item-active-color,#ee0a24)}.van-tree-select__item--disabled{color:#c8c9cc;color:var(--tree-select-item-disabled-color,#c8c9cc)}.van-tree-select__selected{position:absolute;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%);right:16px;right:var(--padding-md,16px)} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/uploader/index.js b/miniprogram_npm/@vant/weapp/uploader/index.js new file mode 100644 index 0000000..64cccd8 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/uploader/index.js @@ -0,0 +1,239 @@ +'use strict'; +var __assign = + (this && this.__assign) || + function () { + __assign = + Object.assign || + function (t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) + if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); + }; +Object.defineProperty(exports, '__esModule', { value: true }); +var component_1 = require('../common/component'); +var utils_1 = require('./utils'); +var shared_1 = require('./shared'); +var validator_1 = require('../common/validator'); +component_1.VantComponent({ + props: __assign( + __assign( + { + disabled: Boolean, + multiple: Boolean, + uploadText: String, + useBeforeRead: Boolean, + afterRead: null, + beforeRead: null, + previewSize: { + type: null, + value: 80, + }, + name: { + type: [Number, String], + value: '', + }, + accept: { + type: String, + value: 'image', + }, + fileList: { + type: Array, + value: [], + observer: 'formatFileList', + }, + maxSize: { + type: Number, + value: Number.MAX_VALUE, + }, + maxCount: { + type: Number, + value: 100, + }, + deletable: { + type: Boolean, + value: true, + }, + showUpload: { + type: Boolean, + value: true, + }, + previewImage: { + type: Boolean, + value: true, + }, + previewFullImage: { + type: Boolean, + value: true, + }, + imageFit: { + type: String, + value: 'scaleToFill', + }, + uploadIcon: { + type: String, + value: 'photograph', + }, + }, + shared_1.chooseImageProps + ), + shared_1.chooseVideoProps + ), + data: { + lists: [], + isInCount: true, + }, + methods: { + formatFileList: function () { + var _a = this.data, + _b = _a.fileList, + fileList = _b === void 0 ? [] : _b, + maxCount = _a.maxCount; + var lists = fileList.map(function (item) { + return __assign(__assign({}, item), { + isImage: utils_1.isImageFile(item), + isVideo: utils_1.isVideoFile(item), + deletable: validator_1.isBoolean(item.deletable) + ? item.deletable + : true, + }); + }); + this.setData({ lists: lists, isInCount: lists.length < maxCount }); + }, + getDetail: function (index) { + return { + name: this.data.name, + index: index == null ? this.data.fileList.length : index, + }; + }, + startUpload: function () { + var _this = this; + var _a = this.data, + maxCount = _a.maxCount, + multiple = _a.multiple, + lists = _a.lists, + disabled = _a.disabled; + if (disabled) return; + utils_1 + .chooseFile( + __assign(__assign({}, this.data), { + maxCount: maxCount - lists.length, + }) + ) + .then(function (res) { + _this.onBeforeRead(multiple ? res : res[0]); + }) + .catch(function (error) { + _this.$emit('error', error); + }); + }, + onBeforeRead: function (file) { + var _this = this; + var _a = this.data, + beforeRead = _a.beforeRead, + useBeforeRead = _a.useBeforeRead; + var res = true; + if (typeof beforeRead === 'function') { + res = beforeRead(file, this.getDetail()); + } + if (useBeforeRead) { + res = new Promise(function (resolve, reject) { + _this.$emit( + 'before-read', + __assign(__assign({ file: file }, _this.getDetail()), { + callback: function (ok) { + ok ? resolve() : reject(); + }, + }) + ); + }); + } + if (!res) { + return; + } + if (validator_1.isPromise(res)) { + res.then(function (data) { + return _this.onAfterRead(data || file); + }); + } else { + this.onAfterRead(file); + } + }, + onAfterRead: function (file) { + var _a = this.data, + maxSize = _a.maxSize, + afterRead = _a.afterRead; + var oversize = Array.isArray(file) + ? file.some(function (item) { + return item.size > maxSize; + }) + : file.size > maxSize; + if (oversize) { + this.$emit('oversize', __assign({ file: file }, this.getDetail())); + return; + } + if (typeof afterRead === 'function') { + afterRead(file, this.getDetail()); + } + this.$emit('after-read', __assign({ file: file }, this.getDetail())); + }, + deleteItem: function (event) { + var index = event.currentTarget.dataset.index; + this.$emit( + 'delete', + __assign(__assign({}, this.getDetail(index)), { + file: this.data.fileList[index], + }) + ); + }, + onPreviewImage: function (event) { + if (!this.data.previewFullImage) return; + var index = event.currentTarget.dataset.index; + var lists = this.data.lists; + var item = lists[index]; + wx.previewImage({ + urls: lists + .filter(function (item) { + return utils_1.isImageFile(item); + }) + .map(function (item) { + return item.url; + }), + current: item.url, + fail: function () { + wx.showToast({ title: '预览图片失败', icon: 'none' }); + }, + }); + }, + onPreviewVideo: function (event) { + if (!this.data.previewFullImage) return; + var index = event.currentTarget.dataset.index; + var lists = this.data.lists; + wx.previewMedia({ + sources: lists + .filter(function (item) { + return utils_1.isVideoFile(item); + }) + .map(function (item) { + return __assign(__assign({}, item), { type: 'video' }); + }), + current: index, + fail: function () { + wx.showToast({ title: '预览视频失败', icon: 'none' }); + }, + }); + }, + onClickPreview: function (event) { + var index = event.currentTarget.dataset.index; + var item = this.data.lists[index]; + this.$emit( + 'click-preview', + __assign(__assign({}, item), this.getDetail(index)) + ); + }, + }, +}); diff --git a/miniprogram_npm/@vant/weapp/uploader/index.json b/miniprogram_npm/@vant/weapp/uploader/index.json new file mode 100644 index 0000000..e00a588 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/uploader/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "van-icon": "../icon/index", + "van-loading": "../loading/index" + } +} diff --git a/miniprogram_npm/@vant/weapp/uploader/index.wxml b/miniprogram_npm/@vant/weapp/uploader/index.wxml new file mode 100644 index 0000000..111e64c --- /dev/null +++ b/miniprogram_npm/@vant/weapp/uploader/index.wxml @@ -0,0 +1,80 @@ + + + + + + + {{ item.name || ('图片' + index) }} + + + + {{ item.name || item.url }} + + + + + {{ item.message }} + + + + + + + + + + + + + + + + {{ uploadText }} + + + + diff --git a/miniprogram_npm/@vant/weapp/uploader/index.wxss b/miniprogram_npm/@vant/weapp/uploader/index.wxss new file mode 100644 index 0000000..61ef7a5 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/uploader/index.wxss @@ -0,0 +1 @@ +@import '../common/index.wxss';.van-uploader{position:relative;display:inline-block}.van-uploader__wrapper{display:-webkit-flex;display:flex;-webkit-flex-wrap:wrap;flex-wrap:wrap}.van-uploader__slot:empty{display:none}.van-uploader__slot:not(:empty)+.van-uploader__upload{display:none!important}.van-uploader__upload{position:relative;display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;width:80px;height:80px;margin:0 8px 8px 0;background-color:#f7f8fa}.van-uploader__upload:active{background-color:#f2f3f5}.van-uploader__upload-icon{color:#dcdee0;font-size:24px}.van-uploader__upload-text{margin-top:8px;color:#969799;font-size:12px}.van-uploader__upload--disabled{opacity:.5;opacity:var(--uploader-disabled-opacity,.5)}.van-uploader__preview{position:relative;margin:0 8px 8px 0;cursor:pointer}.van-uploader__preview-image{display:block;width:80px;height:80px;overflow:hidden}.van-uploader__preview-delete{position:absolute;top:0;right:0;width:14px;height:14px;padding:0 0 8px 8px}.van-uploader__preview-delete:after{position:absolute;top:0;right:0;width:14px;height:14px;background-color:rgba(0,0,0,.7);border-radius:0 0 0 12px;content:""}.van-uploader__preview-delete-icon{position:absolute;top:-2px;right:-2px;z-index:1;color:#fff;font-size:16px;-webkit-transform:scale(.5);transform:scale(.5)}.van-uploader__file{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;width:80px;height:80px;background-color:#f7f8fa}.van-uploader__file-icon{color:#646566;font-size:20px}.van-uploader__file-name{box-sizing:border-box;width:100%;margin-top:8px;padding:0 4px;color:#646566;font-size:12px;text-align:center}.van-uploader__mask{position:absolute;top:0;right:0;bottom:0;left:0;display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;color:#fff;background-color:rgba(50,50,51,.88)}.van-uploader__mask-icon{font-size:22px}.van-uploader__mask-message{margin-top:6px;padding:0 4px;font-size:12px;line-height:14px}.van-uploader__loading{width:22px;height:22px;color:#fff!important} \ No newline at end of file diff --git a/miniprogram_npm/@vant/weapp/uploader/shared.js b/miniprogram_npm/@vant/weapp/uploader/shared.js new file mode 100644 index 0000000..9418618 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/uploader/shared.js @@ -0,0 +1,33 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +exports.chooseVideoProps = exports.chooseImageProps = void 0; +// props for choose image +exports.chooseImageProps = { + sizeType: { + type: Array, + value: ['original', 'compressed'], + }, + capture: { + type: Array, + value: ['album', 'camera'], + }, +}; +// props for choose video +exports.chooseVideoProps = { + capture: { + type: Array, + value: ['album', 'camera'], + }, + compressed: { + type: Boolean, + value: true, + }, + maxDuration: { + type: Number, + value: 60, + }, + camera: { + type: String, + value: 'back', + }, +}; diff --git a/miniprogram_npm/@vant/weapp/uploader/utils.js b/miniprogram_npm/@vant/weapp/uploader/utils.js new file mode 100644 index 0000000..d8eb852 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/uploader/utils.js @@ -0,0 +1,158 @@ +'use strict'; +var __assign = + (this && this.__assign) || + function () { + __assign = + Object.assign || + function (t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) + if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); + }; +Object.defineProperty(exports, '__esModule', { value: true }); +exports.chooseFile = exports.isVideoFile = exports.isImageFile = void 0; +var utils_1 = require('../common/utils'); +var validator_1 = require('../common/validator'); +function isImageFile(item) { + if (item.isImage != null) { + return item.isImage; + } + if (item.type) { + return item.type === 'image'; + } + if (item.url) { + return validator_1.isImageUrl(item.url); + } + return false; +} +exports.isImageFile = isImageFile; +function isVideoFile(item) { + if (item.isVideo != null) { + return item.isVideo; + } + if (item.type) { + return item.type === 'video'; + } + if (item.url) { + return validator_1.isVideoUrl(item.url); + } + return false; +} +exports.isVideoFile = isVideoFile; +function formatImage(res) { + return res.tempFiles.map(function (item) { + return __assign(__assign({}, utils_1.pickExclude(item, ['path'])), { + type: 'image', + url: item.path, + thumb: item.path, + }); + }); +} +function formatVideo(res) { + return [ + __assign( + __assign( + {}, + utils_1.pickExclude(res, [ + 'tempFilePath', + 'thumbTempFilePath', + 'errMsg', + ]) + ), + { type: 'video', url: res.tempFilePath, thumb: res.thumbTempFilePath } + ), + ]; +} +function formatMedia(res) { + return res.tempFiles.map(function (item) { + return __assign( + __assign( + {}, + utils_1.pickExclude(item, [ + 'fileType', + 'thumbTempFilePath', + 'tempFilePath', + ]) + ), + { + type: res.type, + url: item.tempFilePath, + thumb: + res.type === 'video' ? item.thumbTempFilePath : item.tempFilePath, + } + ); + }); +} +function formatFile(res) { + return res.tempFiles.map(function (item) { + return __assign(__assign({}, utils_1.pickExclude(item, ['path'])), { + url: item.path, + }); + }); +} +function chooseFile(_a) { + var accept = _a.accept, + multiple = _a.multiple, + capture = _a.capture, + compressed = _a.compressed, + maxDuration = _a.maxDuration, + sizeType = _a.sizeType, + camera = _a.camera, + maxCount = _a.maxCount; + return new Promise(function (resolve, reject) { + switch (accept) { + case 'image': + wx.chooseImage({ + count: multiple ? Math.min(maxCount, 9) : 1, + sourceType: capture, + sizeType: sizeType, + success: function (res) { + return resolve(formatImage(res)); + }, + fail: reject, + }); + break; + case 'media': + wx.chooseMedia({ + count: multiple ? Math.min(maxCount, 9) : 1, + sourceType: capture, + maxDuration: maxDuration, + sizeType: sizeType, + camera: camera, + success: function (res) { + return resolve(formatMedia(res)); + }, + fail: reject, + }); + break; + case 'video': + wx.chooseVideo({ + sourceType: capture, + compressed: compressed, + maxDuration: maxDuration, + camera: camera, + success: function (res) { + return resolve(formatVideo(res)); + }, + fail: reject, + }); + break; + default: + wx.chooseMessageFile({ + count: multiple ? maxCount : 1, + type: accept, + success: function (res) { + return resolve(formatFile(res)); + }, + fail: reject, + }); + break; + } + }); +} +exports.chooseFile = chooseFile; diff --git a/miniprogram_npm/@vant/weapp/wxs/add-unit.wxs b/miniprogram_npm/@vant/weapp/wxs/add-unit.wxs new file mode 100644 index 0000000..27a22d8 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/wxs/add-unit.wxs @@ -0,0 +1,14 @@ +/* eslint-disable */ +var REGEXP = getRegExp('^\d+(\.\d+)?$'); + +function addUnit(value) { + if (value == null) { + return undefined; + } + + return REGEXP.test('' + value) ? value + 'px' : value; +} + +module.exports = { + addUnit: addUnit +}; diff --git a/miniprogram_npm/@vant/weapp/wxs/array.wxs b/miniprogram_npm/@vant/weapp/wxs/array.wxs new file mode 100644 index 0000000..610089c --- /dev/null +++ b/miniprogram_npm/@vant/weapp/wxs/array.wxs @@ -0,0 +1,5 @@ +function isArray(array) { + return array && array.constructor === 'Array'; +} + +module.exports.isArray = isArray; diff --git a/miniprogram_npm/@vant/weapp/wxs/bem.wxs b/miniprogram_npm/@vant/weapp/wxs/bem.wxs new file mode 100644 index 0000000..93b2777 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/wxs/bem.wxs @@ -0,0 +1,38 @@ +var array = require('./array.wxs'); +var object = require('./object.wxs'); +var PREFIX = 'van-'; + +function join(name, mods) { + name = PREFIX + name; + mods = mods.map(function(mod) { + return name + '--' + mod; + }); + mods.unshift(name); + return mods.join(' '); +} + +function traversing(mods, conf) { + if (!conf) { + return; + } + + if (typeof conf === 'string' || typeof conf === 'number') { + mods.push(conf); + } else if (array.isArray(conf)) { + conf.forEach(function(item) { + traversing(mods, item); + }); + } else if (typeof conf === 'object') { + object.keys(conf).forEach(function(key) { + conf[key] && mods.push(key); + }); + } +} + +function bem(name, conf) { + var mods = []; + traversing(mods, conf); + return join(name, mods); +} + +module.exports.bem = bem; diff --git a/miniprogram_npm/@vant/weapp/wxs/memoize.wxs b/miniprogram_npm/@vant/weapp/wxs/memoize.wxs new file mode 100644 index 0000000..261ae67 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/wxs/memoize.wxs @@ -0,0 +1,54 @@ +/** + * Simple memoize + * wxs doesn't support fn.apply, so this memoize only support up to 2 args + */ + +function isPrimitive(value) { + var type = typeof value; + return ( + type === 'boolean' || + type === 'number' || + type === 'string' || + type === 'undefined' || + value === null + ); +} + +// mock simple fn.call in wxs +function call(fn, args) { + if (args.length === 2) { + return fn(args[0], args[1]); + } + + if (args.length === 1) { + return fn(args[0]); + } + + return fn(); +} + +function serializer(args) { + if (args.length === 1 && isPrimitive(args[0])) { + return args[0]; + } + var obj = {}; + for (var i = 0; i < args.length; i++) { + obj['key' + i] = args[i]; + } + return JSON.stringify(obj); +} + +function memoize(fn) { + var cache = {}; + + return function() { + var key = serializer(arguments); + if (cache[key] === undefined) { + cache[key] = call(fn, arguments); + } + + return cache[key]; + }; +} + +module.exports.memoize = memoize; diff --git a/miniprogram_npm/@vant/weapp/wxs/object.wxs b/miniprogram_npm/@vant/weapp/wxs/object.wxs new file mode 100644 index 0000000..e077107 --- /dev/null +++ b/miniprogram_npm/@vant/weapp/wxs/object.wxs @@ -0,0 +1,13 @@ +/* eslint-disable */ +var REGEXP = getRegExp('{|}|"', 'g'); + +function keys(obj) { + return JSON.stringify(obj) + .replace(REGEXP, '') + .split(',') + .map(function(item) { + return item.split(':')[0]; + }); +} + +module.exports.keys = keys; diff --git a/miniprogram_npm/@vant/weapp/wxs/utils.wxs b/miniprogram_npm/@vant/weapp/wxs/utils.wxs new file mode 100644 index 0000000..d5c9d8c --- /dev/null +++ b/miniprogram_npm/@vant/weapp/wxs/utils.wxs @@ -0,0 +1,10 @@ +/* eslint-disable */ +var bem = require('./bem.wxs').bem; +var memoize = require('./memoize.wxs').memoize; +var addUnit = require('./add-unit.wxs').addUnit; + +module.exports = { + bem: memoize(bem), + memoize: memoize, + addUnit: addUnit +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..9dbeca9 --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "@vant/weapp": "^1.6.2" + } +} diff --git a/pages/base_function/index.js b/pages/base_function/index.js new file mode 100644 index 0000000..16b30b7 --- /dev/null +++ b/pages/base_function/index.js @@ -0,0 +1,60 @@ +// miniprogram/pages/base_function/index.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + list: [ + { + name: '设备配网', + text: '体验设备配网操作与查看示例代码文档', + url: '/pages/function_center/device_connect/index' + }, + { + name: '设备功能点', + text: '查看设备的功能点介绍与使用', + url: '/pages/web_view/index' + }, + { + name: '体验 Demo 面板', + text: '体验产品虚拟面板,0距离感受交互效果', + url: '/pages/home_center/device_list/index' + }, + ] + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + gotoOtherage: function (event) { + const { dataset: { url } } = event.currentTarget + const { list } = this.data + let Url = url + if(url == list[1].url) { + Url = `${url}?urlType=dpUrl` + } + + wx.navigateTo({ + url: Url, + }) + }, +}) \ No newline at end of file diff --git a/pages/base_function/index.json b/pages/base_function/index.json new file mode 100644 index 0000000..8e654c0 --- /dev/null +++ b/pages/base_function/index.json @@ -0,0 +1,7 @@ +{ + "usingComponents": { + "van-icon": "@vant/weapp/icon/index" + }, + "navigationBarTitleText": "基础业务功能", + "navigationBarBackgroundColor": "#f8f8f8" +} \ No newline at end of file diff --git a/pages/base_function/index.wxml b/pages/base_function/index.wxml new file mode 100644 index 0000000..0cdf015 --- /dev/null +++ b/pages/base_function/index.wxml @@ -0,0 +1,12 @@ + + + + + + {{item.name}} + {{item.text}} + + + + + \ No newline at end of file diff --git a/pages/base_function/index.wxss b/pages/base_function/index.wxss new file mode 100644 index 0000000..8363c2a --- /dev/null +++ b/pages/base_function/index.wxss @@ -0,0 +1,32 @@ +/* miniprogram/pages/base_function/index.wxss */ +page { + background-color: #f6f6f6; +} +.root { + padding: 27px 16px; +} + +.list-item { + display: flex; + background-color: #fff; + padding: 18px 16px 19px 20px; + border-radius: 16px; + margin-bottom: 12px; +} + +.list-item-header { + flex: 1; +} + +.list-item-header-name { + font-family: PingFangSC-Regular; + font-size: 16px; + line-height: 24px; + color: #22242c; +} + +.list-item-header-text { + font-family: PingFangSC-Regular; + font-size: 12px; + color: rgba(0, 0, 0, 0.5); +} \ No newline at end of file diff --git a/pages/cloud_check/index.js b/pages/cloud_check/index.js new file mode 100644 index 0000000..44ea34e --- /dev/null +++ b/pages/cloud_check/index.js @@ -0,0 +1,93 @@ +// pages/cloud_check/index.js +import { login } from '../../utils/request' + +Page({ + + /** + * 页面的初始数据 + */ + data: { + percentage: 100, + errorText: '' + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: async function () { + this.checkCloud() + }, + + checkCloud: async function () { + try { + const { miniProgram } = wx.getAccountInfoSync() + wx.cloud.init({ env: `ty-${miniProgram.appId}` }) + this.setData({ percentage: 25 }) + } catch (error) { + console.log(error) + this.setData({ errorText: '开通云开发失败' }) + } + + try { + const res = await wx.cloud.callFunction({ + name: 'ty-service', + data: { + action: 'hello', + params: {} + } + }) + + if (!res) { + throw ('部署SDK') + } else { + this.setData({ percentage: 50 }) + } + } catch (error) { + console.log(typeof error) + this.setData({ errorText: '部署SDK失败' }) + } + + try { + const clientd + = await wx.cloud.callFunction({ + name: 'ty-service', + data: { + action: 'getClientId', + params: {} + } + }) + + if (!clientd) { + throw ('部署授权文件') + } else { + this.setData({ percentage: 75 }) + } + } catch (error) { + this.setData({ errorText: '部署授权文件失败' }) + } + + try { + const uid = await login() + if (!uid) { + throw ('调用云函数失败') + } else { + this.setData({ percentage: 100 }) + } + } catch (error) { + this.setData({ errorText: '调用云函数失败' }) + } + }, + + backPage: function() { + wx.navigateBack({ + delta: 1, + }) + } +}) \ No newline at end of file diff --git a/pages/cloud_check/index.json b/pages/cloud_check/index.json new file mode 100644 index 0000000..02f81de --- /dev/null +++ b/pages/cloud_check/index.json @@ -0,0 +1,9 @@ +{ + "usingComponents": { + "van-progress": "@vant/weapp/progress/index", + "van-loading": "@vant/weapp/loading/index", + "van-icon": "@vant/weapp/icon/index" + }, + "navigationBarTitleText": "小程序demo", + "navigationBarBackgroundColor": "#f8f8f8" +} \ No newline at end of file diff --git a/pages/cloud_check/index.wxml b/pages/cloud_check/index.wxml new file mode 100644 index 0000000..f742a45 --- /dev/null +++ b/pages/cloud_check/index.wxml @@ -0,0 +1,38 @@ + + + + + 小程序环境检测中... + + + + + 检测是否开通云开发 + 检测是否部署SDK + 检测是否上传授权文件 + 检测调用云函数是否成功 + + + + + + 环境部署失败 + 检测到{{errorText}}, 请去涂鸦开发平台程序部署,如果依然失败,请通过工单联系我们 + + + 重新检测 + + + + + + + 您的环境检测成功 + + + 返回首页 + + + + \ No newline at end of file diff --git a/pages/cloud_check/index.wxss b/pages/cloud_check/index.wxss new file mode 100644 index 0000000..e0feba7 --- /dev/null +++ b/pages/cloud_check/index.wxss @@ -0,0 +1,93 @@ +/* pages/cloud_check/index.wxss */ +.van-loading { + margin-bottom: 16px; +} + +.cloud-container { + padding: 76px 52px; +} + +.cloud-check-title { + margin-bottom: 20px; + height: 28px; + font-family: PingFangSC-Semibold; + font-size: 20px; + text-align: center; + color: rgba(0, 0, 0, 0.9); +} + +.cloud-checking { + padding-left: 48px; +} + +.cloud-fail { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + padding: 76px 52px; +} + +.cloud-fail-img { + border-radius: 50%; + width: 72px; + height: 72px; +} + +.cloud-fail-title { + margin-top: 18px; + text-align: center; + height: 28px; + font-family: PingFangSC-Medium; + font-size: 20px; + color: rgba(0, 0, 0, 0.9); +} + +.cloud-fail-label { + margin-top: 7px; + text-align: center; + height: 40px; + font-family: PingFangSC-Regular; + font-size: 14px; + color: rgba(0, 0, 0, 0.7); +} + +.cloud-fail-btn { + margin-top: 48px; + text-align: center; + width: 244px; + height: 48px; + background-color: #ff5a28; + border-radius: 24px; + font-size: 16px; + line-height: 48px; + color: #fff; +} + +.cloud-success { + padding: 112px 66px; +} + +.cloud-success-label { + margin-left: 5px; + font-family: PingFangSC-Medium; + font-size: 20px; + color: rgba(0, 0, 0, 0.9); +} + +.cloud-success-container { + display: flex; + justify-content: center; +} + +.cloud-success-btn { + margin-top: 96px; + text-align: center; + width: 244px; + height: 48px; + background-color: #ff5a28; + border-radius: 24px; + font-size: 16px; + line-height: 48px; + color: #fff; +} \ No newline at end of file diff --git a/pages/function_center/device_connect/index.js b/pages/function_center/device_connect/index.js new file mode 100644 index 0000000..104f353 --- /dev/null +++ b/pages/function_center/device_connect/index.js @@ -0,0 +1,57 @@ +// miniprogram/pages/function_center/device_connet/index.js +import { reqTicket, getClientId } from '../../../utils/api/common-api' + +Page({ + + /** + * 页面的初始数据 + */ + data: { + apUrl: '/pages/web_view/index?urlType=apUrl', + list: [ + { + name: 'Wi-Fi AP 配网', + baseUrl: 'plugin://tuya-ap-plugin/step1' + }, + { + name: '蓝牙配网', + baseUrl: 'plugin://tuya-ap-plugin/ble' + }, + { + name: '扫码配网', + baseUrl: 'plugin://tuya-ap-plugin/virtual' + } + ] + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + gotoPluginpage: async function ({ currentTarget }) { + const { dataset: { baseurl } } = currentTarget + const [{ ticket }, clientId] = await Promise.all([reqTicket(), getClientId()]) + + wx.navigateTo({ + url: `${baseurl}?ticket=${ticket}&clientId=${clientId}`, + }) + }, + + gotoWebview: function({currentTarget}) { + const { dataset: { baseurl } } = currentTarget + wx.navigateTo({ + url: baseurl, + }) + } + +}) \ No newline at end of file diff --git a/pages/function_center/device_connect/index.json b/pages/function_center/device_connect/index.json new file mode 100644 index 0000000..84badee --- /dev/null +++ b/pages/function_center/device_connect/index.json @@ -0,0 +1,7 @@ +{ + "usingComponents": { + "van-icon": "@vant/weapp/icon/index" + }, + "navigationBarTitleText": "设备配网", + "navigationBarBackgroundColor": "#f8f8f8" +} \ No newline at end of file diff --git a/pages/function_center/device_connect/index.wxml b/pages/function_center/device_connect/index.wxml new file mode 100644 index 0000000..9e91926 --- /dev/null +++ b/pages/function_center/device_connect/index.wxml @@ -0,0 +1,14 @@ + + + 体验配网 + + + {{item.name}} + + + + + 查看示例代码与文档说明 + + + \ No newline at end of file diff --git a/pages/function_center/device_connect/index.wxss b/pages/function_center/device_connect/index.wxss new file mode 100644 index 0000000..cc7eaee --- /dev/null +++ b/pages/function_center/device_connect/index.wxss @@ -0,0 +1,40 @@ +/* miniprogram/pages/function_center/device_connet/index.wxss */ +.root { + padding: 16px 16px; +} + +.device-connect-title { + margin-top: 8px; + font-family: PingFangSC-Medium; + font-size: 18px; + letter-spacing: 0px; + color: rgba(0, 0, 0, 0.9); +} + +.device-connect-text { + font-family: PingFangSC-Regular; + font-size: 14px; + color: rgba(0, 0, 0, 0.5); +} + +.device-connect-item { + padding: 28px 16px 28px 20px; + display: flex; + margin-top: 8px; + background-color: #fff; + border-radius: 16px; +} + +.device-connect-item-name { + flex: 1; + font-family: PingFangSC-Regular; + font-size: 16px; + color: #22242c; +} + +.device-connect-copy-title { + font-family: PingFangSC-Regular; + font-size: 16px; + line-height: 24px; + color: #22242c; +} \ No newline at end of file diff --git a/pages/guide/index.js b/pages/guide/index.js new file mode 100644 index 0000000..68d9a77 --- /dev/null +++ b/pages/guide/index.js @@ -0,0 +1,94 @@ +// pages/guide/index.js +import wxMqtt from '../../utils/mqtt/wxMqtt'; +import { getMqttconfig } from '../../utils/api/device-api'; +import request from '../../utils/request'; + +Page({ + /** + * 页面的初始数据 + */ + data: { + cloudInner: { + isDroped: false, + url: '/pages/cloud_check/index' + }, + list: [ + { + name: '基础业务功能', + url: '/pages/base_function/index' + }, + { + name: '体验 Demo 面板', + url: '/pages/home_center/device_list/index' + }, + { + name: '体验涂鸦小程序', + url: 'navigateToMiniProgram' + } + ] + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: async function (options) { + const { cloudInner } = this.data; + const { miniProgram } = wx.getAccountInfoSync(); + wx.cloud.init({ env: `ty-${miniProgram.appId}` }); + + try { + const { device_id } = await request({ + name: 'ty-service', + data: { + action: 'device.virtualAdd', + params: { + product_id: 'qkxb0pmel0q1g9yf', + token: 'release_common_component' + } + } + }); + + if (!device_id) { + throw '检测到未部署SDK'; + } + + cloudInner.isDroped = true; + this.setData({ cloudInner: { ...cloudInner } }); + + wx.setStorageSync('vir_device', device_id); + let { + client_id, + password, + source_topic: { device: topic }, + url, + username + } = await getMqttconfig(); + + wxMqtt.connectMqtt(url, { clientId: client_id, username, password, subscribeTopics: topic }); + } catch (error) { + // wx.showModal({ + // title: '检测到未部署SDK', + // content: '后续功能操作都需要SDK能力, 请去涂鸦开发平台程序一键部署SDK' + // }) + cloudInner.isDroped = false; + this.setData({ cloudInner: { ...cloudInner } }); + } + }, + + onClickHide: function () { + this.setData({ show: false }); + }, + + gotoOtherage: function (event) { + const { + dataset: { url } + } = event.currentTarget; + if (url == 'navigateToMiniProgram') { + this.setData({ show: true }); + } else { + wx.navigateTo({ + url + }); + } + } +}); diff --git a/pages/guide/index.json b/pages/guide/index.json new file mode 100644 index 0000000..31613b1 --- /dev/null +++ b/pages/guide/index.json @@ -0,0 +1,9 @@ +{ + "usingComponents": { + "van-icon": "@vant/weapp/icon/index", + "van-circle": "@vant/weapp/circle/index", + "van-overlay": "@vant/weapp/overlay/index" + }, + "navigationBarTitleText": "小程序demo", + "navigationBarBackgroundColor": "#f8f8f8" +} \ No newline at end of file diff --git a/pages/guide/index.wxml b/pages/guide/index.wxml new file mode 100644 index 0000000..88008ab --- /dev/null +++ b/pages/guide/index.wxml @@ -0,0 +1,31 @@ + + + + + + {{cloudInner.isDroped ? "云函数部署":"体验Demo前请先检测云函数部署"}} + + + + + + + + + + + + {{item.name}} + {{item.text}} + + + + + + + + 请扫码体验涂鸦智能小程序 + + + + \ No newline at end of file diff --git a/pages/guide/index.wxss b/pages/guide/index.wxss new file mode 100644 index 0000000..07dad33 --- /dev/null +++ b/pages/guide/index.wxss @@ -0,0 +1,49 @@ +/* pages/guide/index.wxss */ +page { + background-color: #f6f6f6; +} +.root { + padding: 27px 16px; +} + +.list-item{ + display: flex; + background-color: #fff; + padding: 28px 16px 28px 20px; + border-radius: 16px; + margin-bottom: 12px; +} + +.list-item-header { + display: flex; + flex: 1; +} + +.list-item-header-name { + font-family: PingFangSC-Regular; + font-size: 16px; + line-height: 24px; + color: #22242c; +} + +.over-container { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + height: 100%; +} + +.over-label { + margin-bottom: 32px; + font-family: PingFangSC-Regular; + font-size: 16px; + line-height: 24px; + color: #fff; +} + +.over-image { + width: 260px; + height: 260px; + border-radius: 50%; +} \ No newline at end of file diff --git a/pages/home_center/common_panel/components/Boolean/index.js b/pages/home_center/common_panel/components/Boolean/index.js new file mode 100644 index 0000000..4e092cc --- /dev/null +++ b/pages/home_center/common_panel/components/Boolean/index.js @@ -0,0 +1,28 @@ +// pages/home_center/common_panel/components/Boolean/index.js +Component({ + /** + * 组件的属性列表 + */ + properties: { + isChecked:Boolean, + dpCode: String, + dpName: String, + }, + + /** + * 组件的初始数据 + */ + data: { + + }, + + /** + * 组件的方法列表 + */ + methods: { + onChange: async function() { + const { isChecked, dpCode } = this.properties + this.triggerEvent('sendDp', { dpCode, value: !isChecked }) + } + } +}) diff --git a/pages/home_center/common_panel/components/Boolean/index.json b/pages/home_center/common_panel/components/Boolean/index.json new file mode 100644 index 0000000..c702766 --- /dev/null +++ b/pages/home_center/common_panel/components/Boolean/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-switch": "@vant/weapp/switch/index" + } +} \ No newline at end of file diff --git a/pages/home_center/common_panel/components/Boolean/index.wxml b/pages/home_center/common_panel/components/Boolean/index.wxml new file mode 100644 index 0000000..49e5524 --- /dev/null +++ b/pages/home_center/common_panel/components/Boolean/index.wxml @@ -0,0 +1,5 @@ + + + {{dpName}} + + \ No newline at end of file diff --git a/pages/home_center/common_panel/components/Boolean/index.wxss b/pages/home_center/common_panel/components/Boolean/index.wxss new file mode 100644 index 0000000..966a40a --- /dev/null +++ b/pages/home_center/common_panel/components/Boolean/index.wxss @@ -0,0 +1,30 @@ +/* pages/home_center/common_panel/components/Boolean/index.wxss */ +.boolean-container { + margin-top: 16px; + display: flex; + justify-content: space-between; + align-items: center; + height: 32px; + padding: 20px 24px; + background-color: #fff; + border-radius: 14px; +} + +.boolean-name { + flex: 1; + font-family: PingFangSC-Medium; + font-size: 16px; + line-height: 25px; + color: #505050; +} + +.van-switch__node { + background-color: #fff; + box-shadow: 0px 3px 3px 0px + rgba(0, 0, 0, 0.05), + 0px 2px 2px 0px + rgba(0, 0, 0, 0.1), + 0px 2px 2px 0px + rgba(0, 0, 0, 0.05); + border: solid 1px rgba(0, 0, 0, 0.1); +} \ No newline at end of file diff --git a/pages/home_center/common_panel/components/Enum/index.js b/pages/home_center/common_panel/components/Enum/index.js new file mode 100644 index 0000000..d25aa14 --- /dev/null +++ b/pages/home_center/common_panel/components/Enum/index.js @@ -0,0 +1,39 @@ +// pages/home_center/common_panel/components/Enum/index.js +Component({ + /** + * 组件的属性列表 + */ + properties: { + value: String, + dpCode: String, + dpName: String, + values: String, + }, + + /** + * 组件的初始数据 + */ + data: { + range: [] + }, + + lifetimes: { + attached: function () { + const { values } = this.properties + console.log(values) + const { range } = values ? JSON.parse(values) : { range: [] }; + this.setData({ range }) + } + }, + + /** + * 组件的方法列表 + */ + methods: { + onChange: function (event) { + const { dpCode } = this.properties + const { dataset: { value } } = event.currentTarget + this.triggerEvent('sendDp', { dpCode, value }) + } + } +}) diff --git a/pages/home_center/common_panel/components/Enum/index.json b/pages/home_center/common_panel/components/Enum/index.json new file mode 100644 index 0000000..e8cfaaf --- /dev/null +++ b/pages/home_center/common_panel/components/Enum/index.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/home_center/common_panel/components/Enum/index.wxml b/pages/home_center/common_panel/components/Enum/index.wxml new file mode 100644 index 0000000..5829d2a --- /dev/null +++ b/pages/home_center/common_panel/components/Enum/index.wxml @@ -0,0 +1,14 @@ + + + {{dpName}} + + + + + {{item}} + + + + + \ No newline at end of file diff --git a/pages/home_center/common_panel/components/Enum/index.wxss b/pages/home_center/common_panel/components/Enum/index.wxss new file mode 100644 index 0000000..5c21e8f --- /dev/null +++ b/pages/home_center/common_panel/components/Enum/index.wxss @@ -0,0 +1,44 @@ +/* pages/home_center/common_panel/components/Enum/index.wxss */ +.enum-container { + margin-top: 16px; + display: flex; + flex-direction: column; + justify-content: space-between; + padding: 20px 15px; + background-color: #fff; + border-radius: 14px; +} + +.enum-name { + margin-bottom: 24px; + text-align: left; + font-family: PingFangSC-Medium; + font-size: 16px; + line-height: 25px; + color: #505050; +} + +.enum-scrollView { + width: 100%; + height: 33px; + white-space: nowrap; +} + +.enum-item { + display: inline-block; + margin-right: 11px; + width: 102px; + height: 33px; + text-align: center; + font-family: PingFangSC-Regular; + font-size: 12px; + line-height: 33px; + color: #fff; + border-radius: 25px; +} + +.unselect{ + font-family: PingFangSC-Regular; + font-size: 12px; + color: #349fff; +} \ No newline at end of file diff --git a/pages/home_center/common_panel/components/Integer/index.js b/pages/home_center/common_panel/components/Integer/index.js new file mode 100644 index 0000000..e86f6a6 --- /dev/null +++ b/pages/home_center/common_panel/components/Integer/index.js @@ -0,0 +1,47 @@ +// pages/home_center/common_panel/components/Integer/index.js +Component({ + options: { + styleIsolation: 'shared' + }, + /** + * 组件的属性列表 + */ + properties: { + values: String, + value: Number, + dpName: String, + dpCode: String + }, + + /** + * 组件的初始数据 + */ + data: { + min: 1, + step: 1, + max: 1, + unit: '%' + }, + + lifetimes: { + attached: function() { + const { values } = this.properties + const { step, min, max, unit } = values + ? JSON.parse(values) + : { step: 1, min: 1, max: 1, unit: '%' }; + + this.setData({ step, min, max, unit }) + } + }, + + /** + * 组件的方法列表 + */ + methods: { + onChange: function(event) { + const { dpCode } = this.properties + const value = event.detail + this.triggerEvent('sendDp', { dpCode, value }) + } + } +}) diff --git a/pages/home_center/common_panel/components/Integer/index.json b/pages/home_center/common_panel/components/Integer/index.json new file mode 100644 index 0000000..f33b858 --- /dev/null +++ b/pages/home_center/common_panel/components/Integer/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "van-slider": "@vant/weapp/slider/index" + } +} \ No newline at end of file diff --git a/pages/home_center/common_panel/components/Integer/index.wxml b/pages/home_center/common_panel/components/Integer/index.wxml new file mode 100644 index 0000000..91221c2 --- /dev/null +++ b/pages/home_center/common_panel/components/Integer/index.wxml @@ -0,0 +1,5 @@ + + + {{dpName}}:{{value}}{{unit}} + + diff --git a/pages/home_center/common_panel/components/Integer/index.wxss b/pages/home_center/common_panel/components/Integer/index.wxss new file mode 100644 index 0000000..8fca1fb --- /dev/null +++ b/pages/home_center/common_panel/components/Integer/index.wxss @@ -0,0 +1,19 @@ +/* pages/home_center/common_panel/components/Integer/index.wxss */ + +.integer-container { + margin-top: 16px; + display: flex; + flex-direction: column; + padding: 20px 24px; + background-color: #fff; + border-radius: 14px; +} + +.integer-name{ + margin-bottom: 30px; + text-align: left; + font-family: PingFangSC-Medium; + font-size: 16px; + line-height: 25px; + color: #505050; +} \ No newline at end of file diff --git a/pages/home_center/common_panel/index.js b/pages/home_center/common_panel/index.js new file mode 100644 index 0000000..c75e60a --- /dev/null +++ b/pages/home_center/common_panel/index.js @@ -0,0 +1,149 @@ +// miniprogram/pages/home_center/common_panel/index.js.js +import { getDevFunctions, getDeviceDetails, deviceControl } from '../../../utils/api/device-api' +import wxMqtt from '../../../utils/mqtt/wxMqtt' + + +Page({ + + /** + * 页面的初始数据 + */ + data: { + device_name: '', + titleItem: { + name: '', + value: '', + }, + roDpList: {}, //只上报功能点 + rwDpList: {}, //可上报可下发功能点 + isRoDpListShow: false, + isRwDpListShow: false, + forest: '../../../image/forest@2x.png', + checked: true + }, + onChange({ detail }) { + // 需要手动对 checked 状态进行更新 + this.setData({ checked: detail }); + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + const { device_id } = options + this.setData({ device_id }) + + // mqtt消息监听 + wxMqtt.on('message', (topic, newVal) => { + const { status } = newVal + console.log(newVal) + this.updateStatus(status) + }) + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: async function () { + const { device_id } = this.data + const [{ name, status, icon }, { functions = [] }] = await Promise.all([ + getDeviceDetails(device_id), + getDevFunctions(device_id), + ]); + + const { roDpList, rwDpList } = this.reducerDpList(status, functions) + + // 获取头部展示功能点信息 + let titleItem = { + name: '', + value: '', + }; + if (Object.keys(roDpList).length > 0) { + let keys = Object.keys(roDpList)[0]; + titleItem = roDpList[keys]; + } else { + let keys = Object.keys(rwDpList)[0]; + titleItem = rwDpList[keys]; + } + + const roDpListLength = Object.keys(roDpList).length + const isRoDpListShow = Object.keys(roDpList).length > 0 + const isRwDpListShow = Object.keys(rwDpList).length > 0 + + this.setData({ titleItem, roDpList, rwDpList, device_name: name, isRoDpListShow, isRwDpListShow, roDpListLength, icon }) + }, + + // 分离只上报功能点,可上报可下发功能点 + reducerDpList: function (status, functions) { + // 处理功能点和状态的数据 + let roDpList = {}; + let rwDpList = {}; + if (status && status.length) { + status.map((item) => { + const { code, value } = item; + let isExit = functions.find(element => element.code == code); + if (isExit) { + let rightvalue = value + // 兼容初始拿到的布尔类型的值为字符串类型 + if (isExit.type === 'Boolean') { + rightvalue = value == 'true' + } + + rwDpList[code] = { + code, + value: rightvalue, + type: isExit.type, + values: isExit.values, + name: isExit.name, + }; + } else { + roDpList[code] = { + code, + value, + name: code, + }; + } + }); + } + return { roDpList, rwDpList } + }, + + sendDp: async function (e) { + const { dpCode, value } = e.detail + const { device_id } = this.data + + const { success } = await deviceControl(device_id, dpCode, value) + }, + + updateStatus: function (newStatus) { + let { roDpList, rwDpList, titleItem } = this.data + + newStatus.forEach(item => { + const { code, value } = item + + if (typeof roDpList[code] !== 'undefined') { + roDpList[code]['value'] = value; + } else if (rwDpList[code]) { + rwDpList[code]['value'] = value; + } + }) + + // 更新titleItem + if (Object.keys(roDpList).length > 0) { + let keys = Object.keys(roDpList)[0]; + titleItem = roDpList[keys]; + } else { + let keys = Object.keys(rwDpList)[0]; + titleItem = rwDpList[keys]; + } + + this.setData({ titleItem, roDpList: { ...roDpList }, rwDpList: { ...rwDpList } }) + }, + + jumpTodeviceEditPage: function(){ + console.log('jumpTodeviceEditPage') + const { icon, device_id, device_name } = this.data + wx.navigateTo({ + url: `/pages/home_center/device_manage/index?device_id=${device_id}&device_name=${device_name}&device_icon=${icon}`, + }) + } +}) \ No newline at end of file diff --git a/pages/home_center/common_panel/index.json b/pages/home_center/common_panel/index.json new file mode 100644 index 0000000..6fa93e6 --- /dev/null +++ b/pages/home_center/common_panel/index.json @@ -0,0 +1,10 @@ +{ + "usingComponents": { + "navbar": "../../../components/t_navbar/index", + "Boolean": "./components/Boolean/index", + "Enum": "./components/Enum/index", + "Integer": "./components/Integer/index", + "van-switch": "@vant/weapp/switch/index" + }, + "navigationStyle": "custom" +} \ No newline at end of file diff --git a/pages/home_center/common_panel/index.wxml b/pages/home_center/common_panel/index.wxml new file mode 100644 index 0000000..b4c7d67 --- /dev/null +++ b/pages/home_center/common_panel/index.wxml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + {{checked? '开': '关'}} + + + + + + + + + + + + 开关 + + + + 倒计时 + + + + 电量 + + + + 定时 + + + \ No newline at end of file diff --git a/pages/home_center/common_panel/index.wxs b/pages/home_center/common_panel/index.wxs new file mode 100644 index 0000000..902e660 --- /dev/null +++ b/pages/home_center/common_panel/index.wxs @@ -0,0 +1,22 @@ +function countDpItem(dpRate, idx) { + var roDpItemStyle = 'normal' + switch (dpRate % 3) { + case 1: + roDpItemStyle = dpRate - idx == 0 ? 'one' : 'normal'; + case 2: + roDpItemStyle = dpRate - idx <= 1 ? 'two' : 'normal'; + + } + + if (dpRate == 1) { + roDpItemStyle = 'one' + } else if (dpRate == 2) { + roDpItemStyle = 'two' + } + + return 'roDpItem-'+roDpItemStyle +} + +module.exports = { + countDpItem: countDpItem +} \ No newline at end of file diff --git a/pages/home_center/common_panel/index.wxss b/pages/home_center/common_panel/index.wxss new file mode 100644 index 0000000..339280a --- /dev/null +++ b/pages/home_center/common_panel/index.wxss @@ -0,0 +1,223 @@ +/* miniprogram/pages/home_center/common_panel/index.js.wxss */ +/* +.common-panel-backgroud { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 320px; + background-color: #27c3d9; +} + +.common-panel-header { + z-index: 1; + width: 100%; + height: 256px; + display: flex; + justify-content: center; + align-items: center; +} + +.common-panel-header-block { + display: flex; + flex-direction: column; + align-items: center; +} + +.common-panel-header-dpName { + width: 160px; + height: 25px; + text-align: center; + font-family: HelveticaNeue; + font-size: 12px; + line-height: 24px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + color: #fff; +} + +.common-panel-header-dpValue { + width: 114px; + height: 75px; + font-family: DINCondensed-Bold; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + text-align: center; + font-size: 74px; + color: #fff; +} + +.roDpItem-normal { + display: flex; + flex-direction: column; + align-items: center; + height: 54px; + padding: 16px 2px; +} + +.roDpItem-normal:not(:last-child) { + border-right: solid 1px #d6d6d6; +} + +.roDpItem-two { + display: flex; + flex-direction: column; + align-items: center; + height: 54px; + padding: 16px 33px; +} + +.roDpItem-two:not(:last-child) { + border-right: solid 1px #d6d6d6; +} + +.roDpItem-one { + display: flex; + align-items: center; + flex: 1; + height: 64px; + padding: 20px 24px; + background-color: #fff; + border-radius: 14px; +} + +.roDpItem-dpName { + flex: 1; + width: 115px; + text-align: center; + font-family: PingFangSC-Regular; + font-size: 12px; + line-height: 24px; + color: rgba(80, 80, 80, 0.5); + overflow: hidden; + text-overflow:ellipsis; + white-space: nowrap; +} + +.roDpItem-status { + width: 115px; + text-align: center; + font-family: PingFangSC-Semibold; + font-size: 18px; + line-height: 24px; + color: #505050; + overflow: hidden; + text-overflow:ellipsis; + white-space: nowrap; +} + +.statuslist { + padding-top: 16px; + display: flex; + justify-content: center; + line-height: 12px; + flex-wrap: wrap; +} + +.scroll-view { + padding: 16px 8px; + width: auto; + height: 100%; +} +*/ + +/* HYM */ + +.common-panel-backgroud { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: rgb(100, 50, 197); +} + +/*顶部 大图标*/ +.top_col { + overflow: hidden; + margin-bottom: 0; + width: 100%; + position: fixed; + top: 250px; + display: flex; + justify-content: center; +} +.top_block{ + display: flex; + justify-content: center; + flex-direction: column; + align-items:center; + color:white; +} +.status { + font-size: 80rpx; +} +.top_image { + display: flex; + width: 300px; + height: 300px; +} +.top_content{ + display: flex; + color: rgb(255,255,255); + font-size:25px; + justify-content: center; +} + +/*中间 电压 功率 电流*/ +.center_col { + overflow: hidden; + margin-bottom: 0; + width: 100%; + position: fixed; + bottom: 100px; + display: flex; + justify-content: center; +} + +.center_block { + display: flex; + flex-direction: column; + width: 130rpx; + align-items: center; + margin-left: 45rpx; + margin-right: 45rpx; + margin-bottom: 10rpx; + color: rgb(255,255,255); + font-size:20px; +} + +/* 底部 按钮 */ +.bottom_col { + overflow: hidden; + margin-bottom: 0; + width: 100%; + position: fixed; + bottom: 20px; + display: flex; + justify-content: space-around; +} + +.bottom_block { + display: flex; + flex-direction: column; + width: 130rpx; + align-items: center; + margin-left: 25rpx; + margin-right: 25rpx; + color: rgb(255,255,255); + font-size:20px; +} + +.bottom_image { + display: flex; + width: 45rpx; + height: 45rpx; +} +.name { + font-size: 28rpx; + margin-top: 15rpx; + color: #f0f0f0; +} \ No newline at end of file diff --git a/pages/home_center/device_list/index.js b/pages/home_center/device_list/index.js new file mode 100644 index 0000000..3e60baa --- /dev/null +++ b/pages/home_center/device_list/index.js @@ -0,0 +1,58 @@ +// miniprogram/pages/home_center/device_list/index.js.js +import { getDeviceList } from '../../../utils/api/device-api' + +Page({ + + /** + * 页面的初始数据 + */ + data: { + active: 0, + deviceList: [] + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: async function () { + const deviceList = await getDeviceList() + deviceList.forEach(item => { + item.icon = `https://images.tuyacn.com/${item.icon}` + }) + this.setData({ deviceList }) + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + jumpToPanel({currentTarget}) { + const { dataset: { device } } = currentTarget + const { id, category, name } = device + switch (category) { + case 'kg': break; + default: { + wx.navigateTo({ + url: `/pages/home_center/common_panel/index?device_id=${id}&device_name=${name}`, + }) + } + } + } +}) \ No newline at end of file diff --git a/pages/home_center/device_list/index.json b/pages/home_center/device_list/index.json new file mode 100644 index 0000000..9c5d616 --- /dev/null +++ b/pages/home_center/device_list/index.json @@ -0,0 +1,8 @@ +{ + "usingComponents": { + "van-tab": "@vant/weapp/tab/index", + "van-tabs": "@vant/weapp/tabs/index" + }, + "navigationBarTitleText": "面板列表", + "disableScroll": true +} \ No newline at end of file diff --git a/pages/home_center/device_list/index.wxml b/pages/home_center/device_list/index.wxml new file mode 100644 index 0000000..08957e6 --- /dev/null +++ b/pages/home_center/device_list/index.wxml @@ -0,0 +1,19 @@ + + + + + + + + + + + + {{device.name}} + + + + + + + \ No newline at end of file diff --git a/pages/home_center/device_list/index.wxss b/pages/home_center/device_list/index.wxss new file mode 100644 index 0000000..d2dd090 --- /dev/null +++ b/pages/home_center/device_list/index.wxss @@ -0,0 +1,62 @@ +/* miniprogram/pages/home_center/device_list/index.js.wxss */ +/* pages/home_center/device_list/components/base_icon/index.js.wxss */ +.van-tab { + flex: none !important; + padding: 0 16px !important; +} + +.van-ellipsis { + font-size: 17px; + color: #1d1e1f; +} + +.scroll-list{ + padding: 16px 16px; + width: auto; + height: 100%; +} + +.base-list{ + display: flex; + flex-wrap: wrap; +} + +.base-item { + margin-bottom: 12px; + width: 166px; + height: 164px; + background-color: #fff; + border-radius: 16px; + display: flex; + flex-direction: column; + align-items: center; +} + +.base-item-left { + margin-right: 11px; +} + +.base-icon { + margin-top: 34px; + width: 48px; + height: 50px; +} + +.base-icon-images { + width: 100%; + height: 100%; +} + +.base-name { + margin-top: 14px; + width: 126px; + height: 22px; + font-family: PingFangSC-Regular; + font-size: 16px; + line-height: 22px; + text-align: center; + color: rgba(34, 36, 44, 0.9); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} \ No newline at end of file diff --git a/pages/home_center/device_manage/index.js b/pages/home_center/device_manage/index.js new file mode 100644 index 0000000..7de0cc7 --- /dev/null +++ b/pages/home_center/device_manage/index.js @@ -0,0 +1,31 @@ +// miniprogram/pages/home_center/device_manage/index.js.js + + +Page({ + + /** + * 页面的初始数据 + */ + data: { + dialogShow: false + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + const { device_icon, device_name, device_id } = options + this.setData({ device_icon: `https://images.tuyacn.com/${device_icon}`, device_name, device_id }) + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + showDeviceInfo: function() { + this.setData({ dialogShow: true }) + } +}) \ No newline at end of file diff --git a/pages/home_center/device_manage/index.json b/pages/home_center/device_manage/index.json new file mode 100644 index 0000000..02d195e --- /dev/null +++ b/pages/home_center/device_manage/index.json @@ -0,0 +1,6 @@ +{ + "usingComponents": { + "van-icon": "@vant/weapp/icon/index", + "van-dialog": "@vant/weapp/dialog/index" + } +} \ No newline at end of file diff --git a/pages/home_center/device_manage/index.wxml b/pages/home_center/device_manage/index.wxml new file mode 100644 index 0000000..10df771 --- /dev/null +++ b/pages/home_center/device_manage/index.wxml @@ -0,0 +1,24 @@ + + + + + + + {{device_name}} + + + + 设备信息 + + + + + 移除设备 + + + + + + 设备id: {{device_id}} + + diff --git a/pages/home_center/device_manage/index.wxss b/pages/home_center/device_manage/index.wxss new file mode 100644 index 0000000..732f164 --- /dev/null +++ b/pages/home_center/device_manage/index.wxss @@ -0,0 +1,66 @@ +/* miniprogram/pages/home_center/device_manage/index.js.wxss */ +.root { + display: flex; + flex-direction: column; + padding: 16px 16px; +} + +.device-header { + display: flex; + align-items: center; + padding: 20px 20px; + background-color: #fff; + border-radius: 16px; + margin-bottom: 16px; +} + +.device-icon { + width: 48px; + height: 48px; +} + +.device-images { + width: 100%; + height: 100%; +} + +.device-name { + flex: 1; + height: 28px; + font-family: PingFangSC-Semibold; + font-size: 20px; + color: rgba(0, 0, 0, 0.9); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.device-block { + display: flex; + padding: 24px 16px; + background-color: #fff; + border-radius: 16px; + margin-bottom: 16px; +} + +.device-block-title { + flex: 1; + height: 24px; + font-family: PingFangSC-Regular; + font-size: 16px; + line-height: 24px; + color: #22242c; +} + +.device-remove { + height: 22px; + font-family: PingFangSC-Regular; + font-size: 16px; + color: #ff4444; +} + +.dalog-info { + padding: 16px 16px; + display: flex; + justify-content: center; +} \ No newline at end of file diff --git a/pages/web_view/index.js b/pages/web_view/index.js new file mode 100644 index 0000000..4625459 --- /dev/null +++ b/pages/web_view/index.js @@ -0,0 +1,47 @@ +// miniprogram/pages/web_view/index.js +const urlList = { + apUrl: 'https://developer.tuya.com/cn/docs/iot/app-development/mini-programs/plugin/distribution-network-plugin?id=K9lq218xn0wn8', + dpUrl: 'https://developer.tuya.com/cn/docs/iot/app-development/mini-programs/quick-start/device-function-point?id=Ka6y8bi672n1s' +} +Page({ + + /** + * 页面的初始数据 + */ + data: { + url: '' + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + const { urlType } = options + if (urlList[urlType]) { + this.setData({ url: urlList[urlType] }) + } + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + bindload: function (res) { + console.log(res) + }, + + binderror: function (res) { + console.log(res) + } + +}) \ No newline at end of file diff --git a/pages/web_view/index.json b/pages/web_view/index.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/pages/web_view/index.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/web_view/index.wxml b/pages/web_view/index.wxml new file mode 100644 index 0000000..1d34cec --- /dev/null +++ b/pages/web_view/index.wxml @@ -0,0 +1,3 @@ + +个人小程序不支持web-view: 请自主访问该连接: {{url}} + \ No newline at end of file diff --git a/pages/web_view/index.wxss b/pages/web_view/index.wxss new file mode 100644 index 0000000..29ed8fc --- /dev/null +++ b/pages/web_view/index.wxss @@ -0,0 +1 @@ +/* miniprogram/pages/web_view/index.wxss */ \ No newline at end of file diff --git a/project.config.json b/project.config.json new file mode 100644 index 0000000..104d32a --- /dev/null +++ b/project.config.json @@ -0,0 +1,73 @@ +{ + "description": "项目配置文件", + "packOptions": { + "ignore": [] + }, + "setting": { + "urlCheck": false, + "es6": true, + "enhance": false, + "postcss": true, + "preloadBackgroundData": false, + "minified": true, + "newFeature": true, + "coverView": true, + "nodeModules": true, + "autoAudits": false, + "showShadowRootInWxmlPanel": true, + "scopeDataCheck": false, + "uglifyFileName": false, + "checkInvalidKey": true, + "checkSiteMap": true, + "uploadWithSourceMap": true, + "compileHotReLoad": false, + "useMultiFrameRuntime": true, + "useApiHook": true, + "useApiHostProcess": false, + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + }, + "enableEngineNative": false, + "bundle": false, + "useIsolateContext": true, + "useCompilerModule": false, + "userConfirmedUseCompilerModuleSwitch": false, + "userConfirmedBundleSwitch": false, + "packNpmManually": true, + "packNpmRelationList": [ + { + "packageJsonPath": "./package.json", + "miniprogramNpmDistDir": "./miniprogram/" + } + ], + "minifyWXSS": true + }, + "compileType": "miniprogram", + "libVersion": "2.12.0", + "appid": "wx0a3a3dc8953ae613", + "projectname": "Tuya_chazuo", + "debugOptions": { + "hidedInDevtools": [] + }, + "isGameTourist": false, + "simulatorType": "wechat", + "simulatorPluginLibVersion": {}, + "cloudfunctionTemplateRoot": "cloudfunctionTemplate", + "condition": { + "search": { + "list": [] + }, + "conversation": { + "list": [] + }, + "game": { + "currentL": -1, + "list": [] + }, + "miniprogram": { + "list": [] + } + } +} \ No newline at end of file diff --git a/project.private.config.json b/project.private.config.json new file mode 100644 index 0000000..598f417 --- /dev/null +++ b/project.private.config.json @@ -0,0 +1,22 @@ +{ + "condition": { + "plugin": { + "list": [] + }, + "game": { + "list": [] + }, + "gamePlugin": { + "list": [] + }, + "miniprogram": { + "list": [ + { + "name": "pages/home_center/common_panel/index", + "pathName": "pages/home_center/common_panel/index", + "scene": null + } + ] + } + } +} \ No newline at end of file diff --git a/sitemap.json b/sitemap.json new file mode 100644 index 0000000..ca02add --- /dev/null +++ b/sitemap.json @@ -0,0 +1,7 @@ +{ + "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", + "rules": [{ + "action": "allow", + "page": "*" + }] +} \ No newline at end of file diff --git a/utils/api/common-api.js b/utils/api/common-api.js new file mode 100644 index 0000000..ad179d3 --- /dev/null +++ b/utils/api/common-api.js @@ -0,0 +1,53 @@ +import request from '../request' + +// 用户临时票据获取 +export const reqTicket = () => { + return request({ + name: 'ty-service', + data: { + action: 'system.userTicket', + params: {} + } + }) +} + +export const getClientId = () => { + return request({ + name: 'ty-service', + data: { + action: 'getClientId', + params: {} + } + }) +} + +// 根据uid获取用户信息 +export const getUserInfo = (uid) => { + return request({ + name: 'ty-service', + data: { + action: 'user.infos', + params: { + uid + } + } + }) +} + +export const gotoApNetwork = async () => { + const { data: { clientId } } = (await getClientId()).result + const { ticket } = await reqTicket() + console.log(getClientId()); + wx.navigateTo({ + url: `plugin://tuya-ap-plugin/step1?clientId=${clientId}&ticket=${ticket}`, + }) +} + +export const gotoVirtualNetwork = async () => { + const { data: { clientId } } = (await getClientId()).result + const { ticket } = await reqTicket() + wx.navigateTo({ + url: `plugin://tuya-ap-plugin/virtual?clientId=${clientId}&ticket=${ticket}`, + }) +} + diff --git a/utils/api/device-api.js b/utils/api/device-api.js new file mode 100644 index 0000000..eafaeec --- /dev/null +++ b/utils/api/device-api.js @@ -0,0 +1,111 @@ +import request from '../request' +// request 做了自动向params中添加uid的操作,因此可以不带入uid + +// 获取mqtt配置 +export const getMqttconfig = () => { + return request({ + name: 'ty-service', + data: { + action: 'device.openHubConfig', + params: { + link_id: Math.random() + .toString(10) + .substring(2, 11), + link_type: 'websocket' + } + } + }) +} + +// 获取设备列表 +export const getDeviceList = () => { + return request({ + name: 'ty-service', + data: { + action: 'device.getDeviceList', + params: {} + } + }) +} + +// 获取设备最新状态 +export const getDeviceStatus = (device_id) => { + return request({ + name: 'ty-service', + data: { + action: 'device.status', + params: { + device_id + } + } + }) +} + +// 获取设备指令集 +export const getDeviceSpecifications = (device_id) => { + return request({ + name: 'ty-service', + data: { + action: 'device.specifications', + params: { + device_id + } + } + }) +} + +// 获取设备指令集(带中文dp名称) +export const getDevFunctions = (device_id) => { + return request({ + name: 'ty-service', + data: { + action: 'device.functions', + params: { + device_id + } + } + }) +} + +// 获取设备指令集(带中文dp名称) +export const getDeviceDetails = (device_id) => { + return request({ + name: 'ty-service', + data: { + action: 'device.details', + params: { + device_id + } + } + }) +} + + +// 指令下发 +export const deviceControl = (device_id, code, value) => { + return request({ + name: 'ty-service', + data: { + action: 'device.control', + params: { + device_id, + commands: [ + { + code, + value + } + ] + } + } + }) +} + +// 获取 ticket +export const reqTicket = () => + request({ + name: 'ty-service', + data: { + action: 'system.userTicket', + params: {} + } + }); \ No newline at end of file diff --git a/utils/api/family-api.js b/utils/api/family-api.js new file mode 100644 index 0000000..cf3c841 --- /dev/null +++ b/utils/api/family-api.js @@ -0,0 +1,140 @@ +import request from '../request' + +// 获取用户所有家庭信息 +export const getFamilyList = () => { + return request({ + name: 'ty-service', + data: { + action: 'home.memberHomeList', + params: {} + } + }) +} + +// 获取当前家庭下的设备情况 +export const getHomeDeviceList = (home_id) => { + return request({ + name: 'ty-service', + data: { + action: 'home.devices', + params: { + home_id + } + } + }); +} + +// 修改家庭信息 +export const changFamily = (home_id, homeName) => { + return Taro.cloud.callFunction({ + name: 'ty-service', + data: { + action: 'home.edit', + params: { + home_id, + name: homeName + } + } + }); +} + +// 添加家庭 +export const addFamily = (homeName, uid) => { + return wx.cloud.callFunction({ + name: 'ty-service', + data: { + action: 'home.add', + params: { + uid, + home: { + name: homeName + } + } + } + }) +} + +// 删除家庭 +export const deleteFamily = (home_id) => { + return wx.cloud.callFunction({ + name: 'ty-service', + data: { + action: 'home.delete', + params: { + home_id + } + } + }) +} + +// 查询家庭成员 +export const getMemberList = (home_id) => { + return request({ + name: 'ty-service', + data: { + action: 'home.memberList', + params: { + home_id + } + } + }) +} + +// 删除家庭成员 +export const deleteMember = (home_id, uid) => { + return request({ + name: 'ty-service', + data: { + action: 'home.deleteMember', + params: { + home_id, + uid + } + } + }) +} + +// 生成分享票据 +export const getHomeTicket = (home_id, sharer) => { + return wx.cloud.callFunction({ + name: 'ty-service', + data: { + action: "sharing.homeTicket", + params: { + app_schema: 'cloud', + home_id, + sharer + } + } + }) +} + +// 确认加入分享 +export const homeConfirm = (sharing_id, sharing_ticket, receiver) => { + return request({ + name: 'ty-service', + data: { + action: 'sharing.homeConfirm', + params: { + sharing_id, + sharing_ticket, + receiver, + app_schema: 'cloud' + } + } + }) +} + +// 分享票据校验 +export const checkHomeTicket = (sharing_ticket) => { + return request({ + name: 'ty-service', + data: { + action: 'sharing.homeTicketVerification', + params: { + sharing_ticket + } + } + }) +} + diff --git a/utils/mqtt/mqttLib.js b/utils/mqtt/mqttLib.js new file mode 100644 index 0000000..ce7436b --- /dev/null +++ b/utils/mqtt/mqttLib.js @@ -0,0 +1,203 @@ +import { EventEmitter } from '../../libs/events'; +import { isWx } from './util'; +import Mqtt from '../../libs/mqtt.min.js'; +import CryptoJS from '../../libs/ctypto-js' + +const CONNECT = 'connect'; +const MESSAGE = 'message'; +const PACKETSEND = 'packetsend'; +const PACKETRECEIVE = 'packetreceive'; +const ERROR = 'error'; +const CLOSE = 'close'; +const OFFLINE = 'offline'; +const DISCONNECT = 'disconnect'; +const END = 'end'; + +const mqttEvents = [ + CONNECT, + MESSAGE, + PACKETSEND, + PACKETRECEIVE, + ERROR, + CLOSE, + OFFLINE, + DISCONNECT, + END +]; + +// 校验password有效期 +function checkSign(data, accessKey) { + const { sign, ...rest } = data; + const sortedArray = Object.keys(rest) + .sort((a, b) => (a < b ? -1 : 1)) + .reduce((previousValue, currentValue) => { + if (!rest[currentValue] && rest[currentValue] !== 0) return previousValue; + return previousValue.concat(`${currentValue}=${rest[currentValue]}`); + }, []); + sortedArray.push(accessKey); + const derivedStr = sortedArray.join('||'); + const calculatedSign = CryptoJS.MD5(derivedStr).toString(); + return calculatedSign === sign; +} + +// 解密消息 +function aesDecrypt(encryptedMessage, secretPassphrase, option) { + secretPassphrase = CryptoJS.enc.Utf8.parse(secretPassphrase); + return CryptoJS.AES.decrypt(encryptedMessage, secretPassphrase, option).toString( + CryptoJS.enc.Utf8 + ); +} + +// 校验是否为mqtt的连接 +function isMqttConnection(config) { + if (!config) return false; + let protocols = config.protocols; + if (!Array.isArray(protocols)) protocols = [protocols]; + return !!~protocols.indexOf('mqtt'); +} + +class MqttLib { + // socketTask; // wx的socketTask对象 + // password; // 用于解密后的密码 + // emitter; // 事件对象类 + // originConnectSocket; // 保存改写前的wx的socketTask对象 + + constructor() { + this.emitter = new EventEmitter() + this.init(); + } + + // 获取wx的socketTask对象,并且监听其close,error事件 + init() { + if (isWx()) { + const connectSocket = wx.connectSocket; + this.originConnectSocket = connectSocket; + let that = this; + function modifiedConnectSocket(config) { + const isMqtt = isMqttConnection(config); + const maybeSocketTask = connectSocket.call(wx, config); + if (isMqtt) { + that.socketTask = maybeSocketTask; + + // 单独监听mqtt的socketTask的 onClose, onError 事件,无需再去监听网络变化 + that.socketTask.onError(({ errMsg }) => { + // if (!that.isWorking) return; + that.emitter.emit(ERROR, { + type: 'error', + reason: errMsg + }); + }); + that.socketTask.onClose(({ code, reason }) => { + // if (!that.isWorking) return; + that.emitter.emit(CLOSE, { + type: 'close', + code, + reason + }); + }); + } + return maybeSocketTask; + } + + Object.defineProperty(wx, 'connectSocket', { + value: modifiedConnectSocket + }); + + } else { + console.log('do nothing'); + } + } + + // mqtt连接 + connect(mqttUrl, mqttConnectOptions) { + let { subscribeTopics, password } = mqttConnectOptions; + + // 去除多余的前缀的wxs/wss。这个由环境自动加上 + const prefix = isWx() ? 'wxs://' : 'wss://'; + let url = prefix + mqttUrl.split('//')[1]; + + const mqttClient = Mqtt.connect(url, mqttConnectOptions); + + this.mqttClient = mqttClient; + + mqttClient.on('connect', () => { + // 保存password,供解密 + this.password = password; + // 订阅消息 + mqttClient.subscribe(subscribeTopics,(err)=> { + console.log('err', err) + }); + + // 监听所有mqtt事件,并且用eventEmitter派发出去 + // 无需自己保存回调函数,eventEmitter来完成这个事情 + mqttEvents.forEach((mqttEvent) => { + mqttClient.on(mqttEvent, (...args) => { + if (mqttEvent === MESSAGE) { + // message事件,解密后再emit + let message = this.onMessage(args[1]); + if (message) this.emitter.emit(mqttEvent, args[0], message); + } else if (mqttEvent === ( CLOSE || ERROR )) { + if(!isWx()) this.emitter.emit(mqttEvent, args); + } else { + this.emitter.emit(mqttEvent, args); + } + }); + }); + }); + + return mqttClient; + } + + // 消息解密 + onMessage(payload) { + const receivedObject = JSON.parse(payload.toString()); + const isSignValid = checkSign(receivedObject, this.password); + if (isSignValid) { + let msg = receivedObject.data; + const decryptData = aesDecrypt(msg, this.password.substring(8, 24), { + mode: CryptoJS.mode.ECB, + padding: CryptoJS.pad.Pkcs7 + }); + + return JSON.parse(decryptData); + } else { + console.warn('check sign invalid', receivedObject); + } + }; + + // 添加封装后的监听事件 + addMqttEventListener(event, cb) { + this.emitter.on(event, cb); + + // return () => { + // this.removeMqttEventListener(event, cb); + // }; + } + + // 移除封装后的监听事件 + removeMqttEventListener(event, cb) { + this.emitter.off(event, cb); + } + + /** + * destory销毁mqtt实例,解绑全部的listener + */ + destroy() { + this.mqttClient && this.mqttClient.end(true); + this.mqttClient = undefined; + mqttEvents.forEach((mqttEvent) => { + this.removeMqttEventListener(mqttEvent); + }); + + // destroy 在小程序,解除network的监听, 解除defineProperty,解除全部事件监听 + if (isWx()) { + Object.defineProperty(wx, 'connectSocket', { + value: this.originConnectSocket + }); + wx.offNetworkStatusChange(this.networkChangeHandler); + } + this.emitter.off(EVENT); + } +} + +export default new MqttLib(); diff --git a/utils/mqtt/util.js b/utils/mqtt/util.js new file mode 100644 index 0000000..7da522f --- /dev/null +++ b/utils/mqtt/util.js @@ -0,0 +1,6 @@ +export function isWx () { + return typeof wx !== 'undefined' +} + +export function noop() { +} diff --git a/utils/mqtt/wxMqtt.js b/utils/mqtt/wxMqtt.js new file mode 100644 index 0000000..f1f4992 --- /dev/null +++ b/utils/mqtt/wxMqtt.js @@ -0,0 +1,50 @@ +import MqttLibs from './mqttLib'; +import { getMqttconfig } from '../api/device-api' + +let count = 0 + +class wxMqtt { + constructor() {} + + async connectMqtt() { + + let { + client_id, + password, + source_topic: { device: topic }, + url, + username + } = await getMqttconfig() + + if (url) { + const mqttClient = MqttLibs.connect(url, { + clientId: client_id, + username, + password, + subscribeTopics: topic, + reconnectPeriod: 0, + keepalive: 60 + }); + + this._mqttClient = mqttClient; + + return mqttClient + } + + } + + // 添加封装后的监听事件 + on(event, cb) { + MqttLibs.addMqttEventListener(event, cb); + } + + off(event, cb) { + MqttLibs.removeMqttEventListener(event, cb) + } + + reconnectMqtt() { + this.connectMqtt() + } +} + +export default new wxMqtt(); diff --git a/utils/request.js b/utils/request.js new file mode 100644 index 0000000..baa2a56 --- /dev/null +++ b/utils/request.js @@ -0,0 +1,68 @@ +// 重新请求限制 +let count = 5; + +export const login = async () => { + const params = { + name: 'ty-service', + data: { + action: 'user.wx-applet.synchronization', + params: { + open_id: 'cloud', + app_schema: 'cloud' + } + } + }; + + const { uid } = await request(params); + wx.setStorageSync('uid', uid); + return uid +}; + +const setUid = async (params) => { + const { + data: { action } + } = params; + let uid = wx.getStorageSync('uid'); + const isNoLogin = action !== 'user.wx-applet.synchronization'; + if (!uid && isNoLogin && count) { + await login(); + count--; + return setUid(params); + } + if (uid && isNoLogin) { + params.data.params || (params.data.params = {}); + params.data.params['uid'] = uid; + } +}; + +const request = async (params) => { + await setUid(params); + + try { + const { success, data, errorCode, errorMsg, t } = ( + await wx.cloud.callFunction(params) + ).result; + if (success && data === true) { + return { success, t } + }else if(success) { + return data + } + + wx.showToast({ + title: `code:${errorCode}, message:${errorMsg}`, + icon: 'none', + duration: 3000, + mask: true + }); + } catch (error) { + wx.showToast({ + title: '网络错误!', + icon: 'none', + duration: 3000, + mask: true + }); + } + return []; +}; + +export default request; diff --git a/utils/store/reducer/index.js b/utils/store/reducer/index.js new file mode 100644 index 0000000..529aca9 --- /dev/null +++ b/utils/store/reducer/index.js @@ -0,0 +1,4 @@ +import { combineReducers } from "../../../libs/redux"; + +export default combineReducers({ +}); \ No newline at end of file diff --git a/utils/store/store.js b/utils/store/store.js new file mode 100644 index 0000000..f88ad64 --- /dev/null +++ b/utils/store/store.js @@ -0,0 +1,25 @@ +import { createStore, applyMiddleware } from '../../libs/redux'; +import thunkMiddlewares from '../../libs/redux-thunk.min'; +import { createLogger } from '../../libs/redux-logger'; +import rootReducer from './reducer/index'; + +const middlewares = [thunkMiddlewares, createLogger()]; + +let dispatch; + +export function configStore() { + const store = createStore(rootReducer, applyMiddleware(...middlewares)); + dispatch = store.dispatch; + return store; +} + +export function getDispatch() { + return dispatch; +} + +export default { + configStore, + getDispatch() { + return dispatch; + } +}; \ No newline at end of file