UNPKG

ys-ui-test3

Version:

A rich interaction, lightweight, high performance UI library based on Weex

1,560 lines (1,337 loc) 69.9 kB
// { "framework": "Vue" } (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else if(typeof exports === 'object') exports["npm/ys-ui-test3/index"] = factory(); else root["npm/ys-ui-test3/index"] = factory(); })(this, function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // identity function for calling harmony imports with the correct context /******/ __webpack_require__.i = function(value) { return value; }; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { /******/ configurable: false, /******/ enumerable: true, /******/ get: getter /******/ }); /******/ } /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = "/"; /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 3); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _typeof2 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ var _urlParse = __webpack_require__(7); var _urlParse2 = _interopRequireDefault(_urlParse); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var Utils = { UrlParser: _urlParse2.default, _typeof: function _typeof(obj) { return Object.prototype.toString.call(obj).slice(8, -1).toLowerCase(); }, isPlainObject: function isPlainObject(obj) { return Utils._typeof(obj) === 'object'; }, isString: function isString(obj) { return typeof obj === 'string'; }, isNonEmptyArray: function isNonEmptyArray() { var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; return obj && obj.length > 0 && Array.isArray(obj) && typeof obj !== 'undefined'; }, isObject: function isObject(item) { return item && (typeof item === 'undefined' ? 'undefined' : _typeof2(item)) === 'object' && !Array.isArray(item); }, isEmptyObject: function isEmptyObject(obj) { return Object.keys(obj).length === 0 && obj.constructor === Object; }, decodeIconFont: function decodeIconFont(text) { // 正则匹配 图标和文字混排 eg: 我去上学校&#xe600;,天天不&#xe600;迟到 var regExp = /&#x[a-z|0-9]{4,5};?/g; if (regExp.test(text)) { return text.replace(new RegExp(regExp, 'g'), function (iconText) { var replace = iconText.replace(/&#x/, '0x').replace(/;$/, ''); return String.fromCharCode(replace); }); } else { return text; } }, mergeDeep: function mergeDeep(target) { for (var _len = arguments.length, sources = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { sources[_key - 1] = arguments[_key]; } if (!sources.length) return target; var source = sources.shift(); if (Utils.isObject(target) && Utils.isObject(source)) { for (var key in source) { if (Utils.isObject(source[key])) { if (!target[key]) { Object.assign(target, _defineProperty({}, key, {})); } Utils.mergeDeep(target[key], source[key]); } else { Object.assign(target, _defineProperty({}, key, source[key])); } } } return Utils.mergeDeep.apply(Utils, [target].concat(sources)); }, appendProtocol: function appendProtocol(url) { if (/^\/\//.test(url)) { var bundleUrl = weex.config.bundleUrl; return 'http' + (/^https:/.test(bundleUrl) ? 's' : '') + ':' + url; } return url; }, encodeURLParams: function encodeURLParams(url) { var parsedUrl = new _urlParse2.default(url, true); return parsedUrl.toString(); }, goToH5Page: function goToH5Page(jumpUrl) { var animated = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; var callback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; var Navigator = weex.requireModule('navigator'); var jumpUrlObj = new Utils.UrlParser(jumpUrl, true); var url = Utils.appendProtocol(jumpUrlObj.toString()); Navigator.push({ url: Utils.encodeURLParams(url), animated: animated.toString() }, callback); }, env: { isTaobao: function isTaobao() { var appName = weex.config.env.appName; return (/(tb|taobao|淘宝)/i.test(appName) ); }, isTrip: function isTrip() { var appName = weex.config.env.appName; return appName === 'LX'; }, isBoat: function isBoat() { var appName = weex.config.env.appName; return appName === 'Boat' || appName === 'BoatPlayground'; }, isWeb: function isWeb() { var platform = weex.config.env.platform; return (typeof window === 'undefined' ? 'undefined' : _typeof2(window)) === 'object' && platform.toLowerCase() === 'web'; }, isIOS: function isIOS() { var platform = weex.config.env.platform; return platform.toLowerCase() === 'ios'; }, /** * 是否为 iPhone X or iPhoneXS or iPhoneXR or iPhoneXS Max * @returns {boolean} */ isIPhoneX: function isIPhoneX() { var deviceHeight = weex.config.env.deviceHeight; if (Utils.env.isWeb()) { return (typeof window === 'undefined' ? 'undefined' : _typeof2(window)) !== undefined && window.screen && window.screen.width && window.screen.height && (parseInt(window.screen.width, 10) === 375 && parseInt(window.screen.height, 10) === 812 || parseInt(window.screen.width, 10) === 414 && parseInt(window.screen.height, 10) === 896); } return Utils.env.isIOS() && (deviceHeight === 2436 || deviceHeight === 2688 || deviceHeight === 1792 || deviceHeight === 1624); }, isAndroid: function isAndroid() { var platform = weex.config.env.platform; return platform.toLowerCase() === 'android'; }, isTmall: function isTmall() { var appName = weex.config.env.appName; return (/(tm|tmall|天猫)/i.test(appName) ); }, isAliWeex: function isAliWeex() { return Utils.env.isTmall() || Utils.env.isTrip() || Utils.env.isTaobao(); }, /** * 获取weex屏幕真实的设置高度,需要减去导航栏高度 * @returns {Number} */ getPageHeight: function getPageHeight() { var env = weex.config.env; var navHeight = Utils.env.isWeb() ? 0 : Utils.env.isIPhoneX() ? 176 : 132; return env.deviceHeight / env.deviceWidth * 750 - navHeight; }, /** * 获取weex屏幕真实的设置高度 * @returns {Number} */ getScreenHeight: function getScreenHeight() { var env = weex.config.env; return env.deviceHeight / env.deviceWidth * 750; } }, /** * 版本号比较 * @memberOf Utils * @param currVer {string} * @param promoteVer {string} * @returns {boolean} * @example * * const { Utils } = require('@ali/wx-bridge'); * const { compareVersion } = Utils; * console.log(compareVersion('0.1.100', '0.1.11')); // 'true' */ compareVersion: function compareVersion() { var currVer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '0.0.0'; var promoteVer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '0.0.0'; if (currVer === promoteVer) return true; var currVerArr = currVer.split('.'); var promoteVerArr = promoteVer.split('.'); var len = Math.max(currVerArr.length, promoteVerArr.length); for (var i = 0; i < len; i++) { var proVal = ~~promoteVerArr[i]; var curVal = ~~currVerArr[i]; if (proVal < curVal) { return true; } else if (proVal > curVal) { return false; } } return false; }, /** * 分割数组 * @param arr 被分割数组 * @param size 分割数组的长度 * @returns {Array} */ arrayChunk: function arrayChunk() { var arr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 4; var groups = []; if (arr && arr.length > 0) { groups = arr.map(function (e, i) { return i % size === 0 ? arr.slice(i, i + size) : null; }).filter(function (e) { return e; }); } return groups; }, /* * 截断字符串 * @param str 传入字符串 * @param len 截断长度 * @param hasDot 末尾是否... * @returns {String} */ truncateString: function truncateString(str, len) { var hasDot = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; var newLength = 0; var newStr = ''; var singleChar = ''; var chineseRegex = /[^\x00-\xff]/g; var strLength = str.replace(chineseRegex, '**').length; for (var i = 0; i < strLength; i++) { singleChar = str.charAt(i).toString(); if (singleChar.match(chineseRegex) !== null) { newLength += 2; } else { newLength++; } if (newLength > len) { break; } newStr += singleChar; } if (hasDot && strLength > len) { newStr += '...'; } return newStr; }, /* * 转换 obj 为 url params参数 * @param obj 传入字符串 * @returns {String} */ objToParams: function objToParams(obj) { var str = ''; for (var key in obj) { if (str !== '') { str += '&'; } str += key + '=' + encodeURIComponent(obj[key]); } return str; }, /* * 转换 url params参数为obj * @param str 传入url参数字符串 * @returns {Object} */ paramsToObj: function paramsToObj(str) { var obj = {}; try { obj = JSON.parse('{"' + decodeURI(str).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') + '"}'); } catch (e) { console.log(e); } return obj; }, animation: { /** * 返回定义页面转场动画起初的位置 * @param ref * @param transform 运动类型 * @param status * @param callback 回调函数 */ pageTransitionAnimation: function pageTransitionAnimation(ref, transform, status, callback) { var animation = weex.requireModule('animation'); animation.transition(ref, { styles: { transform: transform }, duration: status ? 250 : 300, // ms timingFunction: status ? 'ease-in' : 'ease-out', delay: 0 // ms }, function () { callback && callback(); }); } }, uiStyle: { /** * 返回定义页面转场动画起初的位置 * @param animationType 页面转场动画的类型 push,model * @param size 分割数组的长度 * @returns {} */ pageTransitionAnimationStyle: function pageTransitionAnimationStyle(animationType) { if (animationType === 'push') { return { left: '750px', top: '0px', height: weex.config.env.deviceHeight / weex.config.env.deviceWidth * 750 + 'px' }; } else if (animationType === 'model') { return { top: weex.config.env.deviceHeight / weex.config.env.deviceWidth * 750 + 'px', left: '0px', height: weex.config.env.deviceHeight / weex.config.env.deviceWidth * 750 + 'px' }; } return {}; } } }; exports.default = Utils; /***/ }), /* 1 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _bindEnv = __webpack_require__(4); Object.defineProperty(exports, 'default', { enumerable: true, get: function get() { return _interopRequireDefault(_bindEnv).default; } }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /***/ }), /* 2 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _index = __webpack_require__(9); Object.defineProperty(exports, 'default', { enumerable: true, get: function get() { return _interopRequireDefault(_index).default; } }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /***/ }), /* 3 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.YsMask = exports.Utils = exports.BindEnv = undefined; var _bindEnv = __webpack_require__(1); var _bindEnv2 = _interopRequireDefault(_bindEnv); var _utils = __webpack_require__(0); var _utils2 = _interopRequireDefault(_utils); var _ysMask = __webpack_require__(2); var _ysMask2 = _interopRequireDefault(_ysMask); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.BindEnv = _bindEnv2.default; exports.Utils = _utils2.default; exports.YsMask = _ysMask2.default; /** * Created by Tw93 on 17/09/25 */ /***/ }), /* 4 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _indexWeex = __webpack_require__(8); var _indexWeex2 = _interopRequireDefault(_indexWeex); var _index = __webpack_require__(0); var _index2 = _interopRequireDefault(_index); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ var BindEnv = { supportsEB: function supportsEB() { return _indexWeex2.default.isSupportBinding && !_index2.default.env.isWeb(); }, /** * 判断Android容器是否支持是否支持expressionBinding(处理方式很不一致) * @returns {boolean} */ supportsEBForAndroid: function supportsEBForAndroid() { return _index2.default.env.isAndroid() && BindEnv.supportsEB(); }, /** * 判断IOS容器是否支持是否支持expressionBinding * @returns {boolean} */ supportsEBForIos: function supportsEBForIos() { return _index2.default.env.isIOS() && BindEnv.supportsEB(); } }; exports.default = BindEnv; /***/ }), /* 5 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var has = Object.prototype.hasOwnProperty , undef; /** * Decode a URI encoded string. * * @param {String} input The URI encoded string. * @returns {String|Null} The decoded string. * @api private */ function decode(input) { try { return decodeURIComponent(input.replace(/\+/g, ' ')); } catch (e) { return null; } } /** * Attempts to encode a given input. * * @param {String} input The string that needs to be encoded. * @returns {String|Null} The encoded string. * @api private */ function encode(input) { try { return encodeURIComponent(input); } catch (e) { return null; } } /** * Simple query string parser. * * @param {String} query The query string that needs to be parsed. * @returns {Object} * @api public */ function querystring(query) { var parser = /([^=?&]+)=?([^&]*)/g , result = {} , part; while (part = parser.exec(query)) { var key = decode(part[1]) , value = decode(part[2]); // // Prevent overriding of existing properties. This ensures that build-in // methods like `toString` or __proto__ are not overriden by malicious // querystrings. // // In the case if failed decoding, we want to omit the key/value pairs // from the result. // if (key === null || value === null || key in result) continue; result[key] = value; } return result; } /** * Transform a query string to an object. * * @param {Object} obj Object that should be transformed. * @param {String} prefix Optional prefix. * @returns {String} * @api public */ function querystringify(obj, prefix) { prefix = prefix || ''; var pairs = [] , value , key; // // Optionally prefix with a '?' if needed // if ('string' !== typeof prefix) prefix = '?'; for (key in obj) { if (has.call(obj, key)) { value = obj[key]; // // Edge cases where we actually want to encode the value to an empty // string instead of the stringified value. // if (!value && (value === null || value === undef || isNaN(value))) { value = ''; } key = encodeURIComponent(key); value = encodeURIComponent(value); // // If we failed to encode the strings, we should bail out as we don't // want to add invalid strings to the query. // if (key === null || value === null) continue; pairs.push(key +'='+ value); } } return pairs.length ? prefix + pairs.join('&') : ''; } // // Expose the module. // exports.stringify = querystringify; exports.parse = querystring; /***/ }), /* 6 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /** * Check if we're required to add a port number. * * @see https://url.spec.whatwg.org/#default-port * @param {Number|String} port Port number we need to check * @param {String} protocol Protocol we need to check against. * @returns {Boolean} Is it a default port for the given protocol * @api private */ module.exports = function required(port, protocol) { protocol = protocol.split(':')[0]; port = +port; if (!port) return false; switch (protocol) { case 'http': case 'ws': return port !== 80; case 'https': case 'wss': return port !== 443; case 'ftp': return port !== 21; case 'gopher': return port !== 70; case 'file': return false; } return port !== 0; }; /***/ }), /* 7 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var required = __webpack_require__(6) , qs = __webpack_require__(5) , protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i , slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//; /** * These are the parse rules for the URL parser, it informs the parser * about: * * 0. The char it Needs to parse, if it's a string it should be done using * indexOf, RegExp using exec and NaN means set as current value. * 1. The property we should set when parsing this value. * 2. Indication if it's backwards or forward parsing, when set as number it's * the value of extra chars that should be split off. * 3. Inherit from location if non existing in the parser. * 4. `toLowerCase` the resulting value. */ var rules = [ ['#', 'hash'], // Extract from the back. ['?', 'query'], // Extract from the back. function sanitize(address) { // Sanitize what is left of the address return address.replace('\\', '/'); }, ['/', 'pathname'], // Extract from the back. ['@', 'auth', 1], // Extract from the front. [NaN, 'host', undefined, 1, 1], // Set left over value. [/:(\d+)$/, 'port', undefined, 1], // RegExp the back. [NaN, 'hostname', undefined, 1, 1] // Set left over. ]; /** * These properties should not be copied or inherited from. This is only needed * for all non blob URL's as a blob URL does not include a hash, only the * origin. * * @type {Object} * @private */ var ignore = { hash: 1, query: 1 }; /** * The location object differs when your code is loaded through a normal page, * Worker or through a worker using a blob. And with the blobble begins the * trouble as the location object will contain the URL of the blob, not the * location of the page where our code is loaded in. The actual origin is * encoded in the `pathname` so we can thankfully generate a good "default" * location from it so we can generate proper relative URL's again. * * @param {Object|String} loc Optional default location object. * @returns {Object} lolcation object. * @public */ function lolcation(loc) { var globalVar; if (typeof window !== 'undefined') globalVar = window; else if (typeof {} !== 'undefined') globalVar = {}; else if (typeof self !== 'undefined') globalVar = self; else globalVar = {}; var location = globalVar.location || {}; loc = loc || location; var finaldestination = {} , type = typeof loc , key; if ('blob:' === loc.protocol) { finaldestination = new Url(unescape(loc.pathname), {}); } else if ('string' === type) { finaldestination = new Url(loc, {}); for (key in ignore) delete finaldestination[key]; } else if ('object' === type) { for (key in loc) { if (key in ignore) continue; finaldestination[key] = loc[key]; } if (finaldestination.slashes === undefined) { finaldestination.slashes = slashes.test(loc.href); } } return finaldestination; } /** * @typedef ProtocolExtract * @type Object * @property {String} protocol Protocol matched in the URL, in lowercase. * @property {Boolean} slashes `true` if protocol is followed by "//", else `false`. * @property {String} rest Rest of the URL that is not part of the protocol. */ /** * Extract protocol information from a URL with/without double slash ("//"). * * @param {String} address URL we want to extract from. * @return {ProtocolExtract} Extracted information. * @private */ function extractProtocol(address) { var match = protocolre.exec(address); return { protocol: match[1] ? match[1].toLowerCase() : '', slashes: !!match[2], rest: match[3] }; } /** * Resolve a relative URL pathname against a base URL pathname. * * @param {String} relative Pathname of the relative URL. * @param {String} base Pathname of the base URL. * @return {String} Resolved pathname. * @private */ function resolve(relative, base) { var path = (base || '/').split('/').slice(0, -1).concat(relative.split('/')) , i = path.length , last = path[i - 1] , unshift = false , up = 0; while (i--) { if (path[i] === '.') { path.splice(i, 1); } else if (path[i] === '..') { path.splice(i, 1); up++; } else if (up) { if (i === 0) unshift = true; path.splice(i, 1); up--; } } if (unshift) path.unshift(''); if (last === '.' || last === '..') path.push(''); return path.join('/'); } /** * The actual URL instance. Instead of returning an object we've opted-in to * create an actual constructor as it's much more memory efficient and * faster and it pleases my OCD. * * It is worth noting that we should not use `URL` as class name to prevent * clashes with the global URL instance that got introduced in browsers. * * @constructor * @param {String} address URL we want to parse. * @param {Object|String} [location] Location defaults for relative paths. * @param {Boolean|Function} [parser] Parser for the query string. * @private */ function Url(address, location, parser) { if (!(this instanceof Url)) { return new Url(address, location, parser); } var relative, extracted, parse, instruction, index, key , instructions = rules.slice() , type = typeof location , url = this , i = 0; // // The following if statements allows this module two have compatibility with // 2 different API: // // 1. Node.js's `url.parse` api which accepts a URL, boolean as arguments // where the boolean indicates that the query string should also be parsed. // // 2. The `URL` interface of the browser which accepts a URL, object as // arguments. The supplied object will be used as default values / fall-back // for relative paths. // if ('object' !== type && 'string' !== type) { parser = location; location = null; } if (parser && 'function' !== typeof parser) parser = qs.parse; location = lolcation(location); // // Extract protocol information before running the instructions. // extracted = extractProtocol(address || ''); relative = !extracted.protocol && !extracted.slashes; url.slashes = extracted.slashes || relative && location.slashes; url.protocol = extracted.protocol || location.protocol || ''; address = extracted.rest; // // When the authority component is absent the URL starts with a path // component. // if (!extracted.slashes) instructions[3] = [/(.*)/, 'pathname']; for (; i < instructions.length; i++) { instruction = instructions[i]; if (typeof instruction === 'function') { address = instruction(address); continue; } parse = instruction[0]; key = instruction[1]; if (parse !== parse) { url[key] = address; } else if ('string' === typeof parse) { if (~(index = address.indexOf(parse))) { if ('number' === typeof instruction[2]) { url[key] = address.slice(0, index); address = address.slice(index + instruction[2]); } else { url[key] = address.slice(index); address = address.slice(0, index); } } } else if ((index = parse.exec(address))) { url[key] = index[1]; address = address.slice(0, index.index); } url[key] = url[key] || ( relative && instruction[3] ? location[key] || '' : '' ); // // Hostname, host and protocol should be lowercased so they can be used to // create a proper `origin`. // if (instruction[4]) url[key] = url[key].toLowerCase(); } // // Also parse the supplied query string in to an object. If we're supplied // with a custom parser as function use that instead of the default build-in // parser. // if (parser) url.query = parser(url.query); // // If the URL is relative, resolve the pathname against the base URL. // if ( relative && location.slashes && url.pathname.charAt(0) !== '/' && (url.pathname !== '' || location.pathname !== '') ) { url.pathname = resolve(url.pathname, location.pathname); } // // We should not add port numbers if they are already the default port number // for a given protocol. As the host also contains the port number we're going // override it with the hostname which contains no port number. // if (!required(url.port, url.protocol)) { url.host = url.hostname; url.port = ''; } // // Parse down the `auth` for the username and password. // url.username = url.password = ''; if (url.auth) { instruction = url.auth.split(':'); url.username = instruction[0] || ''; url.password = instruction[1] || ''; } url.origin = url.protocol && url.host && url.protocol !== 'file:' ? url.protocol +'//'+ url.host : 'null'; // // The href is just the compiled result. // url.href = url.toString(); } /** * This is convenience method for changing properties in the URL instance to * insure that they all propagate correctly. * * @param {String} part Property we need to adjust. * @param {Mixed} value The newly assigned value. * @param {Boolean|Function} fn When setting the query, it will be the function * used to parse the query. * When setting the protocol, double slash will be * removed from the final url if it is true. * @returns {URL} URL instance for chaining. * @public */ function set(part, value, fn) { var url = this; switch (part) { case 'query': if ('string' === typeof value && value.length) { value = (fn || qs.parse)(value); } url[part] = value; break; case 'port': url[part] = value; if (!required(value, url.protocol)) { url.host = url.hostname; url[part] = ''; } else if (value) { url.host = url.hostname +':'+ value; } break; case 'hostname': url[part] = value; if (url.port) value += ':'+ url.port; url.host = value; break; case 'host': url[part] = value; if (/:\d+$/.test(value)) { value = value.split(':'); url.port = value.pop(); url.hostname = value.join(':'); } else { url.hostname = value; url.port = ''; } break; case 'protocol': url.protocol = value.toLowerCase(); url.slashes = !fn; break; case 'pathname': case 'hash': if (value) { var char = part === 'pathname' ? '/' : '#'; url[part] = value.charAt(0) !== char ? char + value : value; } else { url[part] = value; } break; default: url[part] = value; } for (var i = 0; i < rules.length; i++) { var ins = rules[i]; if (ins[4]) url[ins[1]] = url[ins[1]].toLowerCase(); } url.origin = url.protocol && url.host && url.protocol !== 'file:' ? url.protocol +'//'+ url.host : 'null'; url.href = url.toString(); return url; } /** * Transform the properties back in to a valid and full URL string. * * @param {Function} stringify Optional query stringify function. * @returns {String} Compiled version of the URL. * @public */ function toString(stringify) { if (!stringify || 'function' !== typeof stringify) stringify = qs.stringify; var query , url = this , protocol = url.protocol; if (protocol && protocol.charAt(protocol.length - 1) !== ':') protocol += ':'; var result = protocol + (url.slashes ? '//' : ''); if (url.username) { result += url.username; if (url.password) result += ':'+ url.password; result += '@'; } result += url.host + url.pathname; query = 'object' === typeof url.query ? stringify(url.query) : url.query; if (query) result += '?' !== query.charAt(0) ? '?'+ query : query; if (url.hash) result += url.hash; return result; } Url.prototype = { set: set, toString: toString }; // // Expose the URL parser and some additional properties that might be useful for // others or testing. // Url.extractProtocol = extractProtocol; Url.location = lolcation; Url.qs = qs; module.exports = Url; /***/ }), /* 8 */ /***/ (function(module, exports, __webpack_require__) { ;(function(fn) { if (true) { module.exports = fn(); } else if (typeof define === "function") { define("index", function(require, exports, module){ module.exports = fn(); }); } else { var root; if (typeof window !== "undefined") { root = window; } else if (typeof self !== "undefined") { root = self; } else if (typeof global !== "undefined") { root = global; } else { // NOTICE: In JavaScript strict mode, this is null root = this; } root["index"] = fn(); } })(function(){ return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { /******/ configurable: false, /******/ enumerable: true, /******/ get: getter /******/ }); /******/ } /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 0); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /** Copyright 2018 Alibaba Group Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var _bindingxParser = __webpack_require__(1); var isWeb = false; var isWeex = true; function requireModule(moduleName) { try { if ((typeof weex === 'undefined' ? 'undefined' : _typeof(weex)) !== undefined && weex.requireModule) { // eslint-disable-line return weex.requireModule(moduleName); // eslint-disable-line } } catch (err) {} return window.require('@weex-module/' + moduleName); } var isSupportNewBinding = true; var isSupportBinding = true; var WeexBinding = void 0; var WebBinding = {}; try { WeexBinding = requireModule('bindingx'); isSupportNewBinding = true; } catch (e) { isSupportNewBinding = false; } if (!WeexBinding || !WeexBinding.bind) { try { WeexBinding = requireModule('binding'); isSupportNewBinding = true; } catch (e) { isSupportNewBinding = false; } } isSupportNewBinding = !!(WeexBinding && WeexBinding.bind && WeexBinding.unbind); if (!isSupportNewBinding) { try { WeexBinding = requireModule('expressionBinding'); isSupportBinding = true; } catch (err) { isSupportBinding = false; } } isSupportBinding = !!(WeexBinding && (WeexBinding.bind || WeexBinding.createBinding)); function formatExpression(expression) { if (expression === undefined) return; try { expression = JSON.parse(expression); } catch (err) {} var resultExpression = {}; if (typeof expression === 'string') { resultExpression.origin = expression; } else if (expression) { resultExpression.origin = expression.origin; resultExpression.transformed = expression.transformed; } if (!resultExpression.transformed && !resultExpression.origin) return; resultExpression.transformed = resultExpression.transformed || (0, _bindingxParser.parse)(resultExpression.origin); return resultExpression; } // 统一回调参数 function fixCallback(callback) { return function () { var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; if (typeof callback === 'function') { return callback({ state: params.state === 'end' ? 'exit' : params.state, t: params.t !== undefined ? params.t : params.deltaT }); } }; } exports.default = { // 是否支持新版本的binding isSupportNewBinding: isSupportNewBinding, // 是否支持binding isSupportBinding: isSupportBinding, _bindingInstances: [], /** * 绑定 * @param options 参数 * @example { anchor:blockRef, eventType:'pan', props: [ { element:blockRef, property:'transform.translateX', expression:{ origin:"x+1", transformed:"{\"type\":\"+\",\"children\":[{\"type\":\"Identifier\",\"value\":\"x\"},{\"type\":\"NumericLiteral\",\"value\":1}]}" } } ] } */ bind: function bind(options) { var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {}; if (!options) { throw new Error('should pass options for binding'); } options.exitExpression = formatExpression(options.exitExpression); if (options.props) { options.props.forEach(function (prop) { prop.expression = formatExpression(prop.expression); }); } if (WeexBinding && isSupportBinding) { if (isSupportNewBinding) { return WeexBinding.bind(options, options && options.eventType === 'timing' ? fixCallback(callback) : callback); } else { WeexBinding.enableBinding(options.anchor, options.eventType); // 处理expression的参数格式 var expressionArgs = options.props.map(function (prop) { return { element: prop.element, property: prop.property, expression: prop.expression.transformed }; }); WeexBinding.createBinding(options.anchor, options.eventType, '', expressionArgs, callback); } } }, /** * @param {object} options * @example * {eventType:'pan', * token:self.gesToken} */ unbind: function unbind(options) { if (!options) { throw new Error('should pass options for binding'); } if (WeexBinding && isSupportBinding) { if (isSupportNewBinding) { return WeexBinding.unbind(options); } else { return WeexBinding.disableBinding(options.anchor, options.eventType); } } }, unbindAll: function unbindAll() { if (WeexBinding && isSupportBinding) { if (isSupportNewBinding) { return WeexBinding.unbindAll(); } else { return WeexBinding.disableAll(); } } }, prepare: function prepare(options) { if (WeexBinding && isSupportBinding) { if (isSupportNewBinding) { return WeexBinding.prepare(options); } else { return WeexBinding.enableBinding(options.anchor, options.eventType); } } }, getComputedStyle: function getComputedStyle(el) { if (isSupportNewBinding) { return WeexBinding.getComputedStyle(el); } else { return {}; } } }; module.exports = exports['default']; /***/ }), /* 1 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; module.exports = __webpack_require__(2); /***/ }), /* 2 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var lex = { InputElementDiv: '<WhiteSpace>|<LineTerminator>|<ReservedWord>|<Identifier>|<NumericLiteral>|<Punctuator>|<StringLiteral>', InputElementRegExp: '<WhiteSpace>|<LineTerminator>|<ReservedWord>|<Identifier>|<NumericLiteral>|<Punctuator>|<StringLiteral>', ReservedWord: '<Keyword>|<NullLiteral>|<BooleanLiteral>', WhiteSpace: /[\t\v\f\u0020\u00A0\u1680\u180E\u2000-\u200A\u202F\u205f\u3000\uFEFF]/, LineTerminator: /[\n\r\u2028\u2029]/, Keyword: /new(?![_$a-zA-Z0-9])|void(?![_$a-zA-Z0-9])|delete(?![_$a-zA-Z0-9])|in(?![_$a-zA-Z0-9])|instanceof(?![_$a-zA-Z0-9])|typeof(?![_$a-zA-Z0-9])/, NullLiteral: /null(?![_$a-zA-Z0-9])/, BooleanLiteral: /(?:true|false)(?![_$a-zA-Z0-9])/, Identifier: /[_$a-zA-Z][_$a-zA-Z0-9]*/, Punctuator: /\/|=>|\*\*|>>>=|>>=|<<=|===|!==|>>>|<<|%=|\*=|-=|\+=|<=|>=|==|!=|\^=|\|=|\|\||&&|&=|>>|\+\+|--|\:|}|\*|&|\||\^|!|~|-|\+|\?|%|=|>|<|,|;|\.(?![0-9])|\]|\[|\)|\(|{/, DivPunctuator: /\/=|\//, NumericLiteral: /(?:0[xX][0-9a-fA-F]*|\.[0-9]+|(?:[1-9]+[0-9]*|0)(?:\.[0-9]*|\.)?)(?:[eE][+-]{0,1}[0-9]+)?(?![_$a-zA-Z0-9])/, StringLiteral: /"(?:[^"\n\\\r\u2028\u2029]|\\(?:['"\\bfnrtv\n\r\u2028\u2029]|\r\n)|\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}|\\[^0-9ux'"\\bfnrtv\n\\\r\u2028\u2029])*"|'(?:[^'\n\\\r\u2028\u2029]|\\(?:['"\\bfnrtv\n\r\u2028\u2029]|\r\n)|\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}|\\[^0-9ux'"\\bfnrtv\n\\\r\u2028\u2029])*'/, RegularExpressionLiteral: /\/(?:\[(?:\\[\s\S]|[^\]])*\]|[^*\/\\\n\r\u2028\u2029]|\\[^\n\r\u2028\u2029])(?:\[(?:\\[\s\S]|[^\]])*\]|[^\/\\\n\r\u2028\u2029]|\\[^\n\r\u2028\u2029])*\/[0-9a-zA-Z]*/ }; function XRegExp(xregexps, rootname, flag) { var expnames = [rootname]; function buildRegExp(source) { var regexp = new RegExp; regexp.compile(source.replace(/<([^>]+)>/g, function (all, expname) { if (!xregexps[expname]) return ''; expnames.push(expname); if (xregexps[expname] instanceof RegExp) return '(' + xregexps[expname].source + ')'; return '(' + buildRegExp(xregexps[expname]).source + ')'; }), flag); return regexp; } var regexp = buildRegExp(xregexps[rootname]); this.exec = function (string) { var matches = regexp.exec(string); if (matches == null) return null; var result = new String(matches[0]); for (var i = 0; i < expnames.length; i++) if (matches[i]) result[expnames[i]] = matches[i]; return result; }; Object.defineProperty(this, 'lastIndex',