weex-ui
Version:
A rich interaction, lightweight, high performance UI library based on Weex
1,404 lines (1,262 loc) • 862 kB
JavaScript
// { "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/weex-ui/index"] = factory();
else
root["npm/weex-ui/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 = 17);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports) {
/* globals __VUE_SSR_CONTEXT__ */
// this module is a runtime utility for cleaner component module output and will
// be included in the final webpack user bundle
module.exports = function normalizeComponent (
rawScriptExports,
compiledTemplate,
injectStyles,
scopeId,
moduleIdentifier /* server only */
) {
var esModule
var scriptExports = rawScriptExports = rawScriptExports || {}
// ES6 modules interop
var type = typeof rawScriptExports.default
if (type === 'object' || type === 'function') {
esModule = rawScriptExports
scriptExports = rawScriptExports.default
}
// Vue.extend constructor export interop
var options = typeof scriptExports === 'function'
? scriptExports.options
: scriptExports
// render functions
if (compiledTemplate) {
options.render = compiledTemplate.render
options.staticRenderFns = compiledTemplate.staticRenderFns
}
// scopedId
if (scopeId) {
options._scopeId = scopeId
}
var hook
if (moduleIdentifier) { // server build
hook = function (context) {
// 2.3 injection
context =
context || // cached call
(this.$vnode && this.$vnode.ssrContext) || // stateful
(this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
// 2.2 with runInNewContext: true
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
context = __VUE_SSR_CONTEXT__
}
// inject component styles
if (injectStyles) {
injectStyles.call(this, context)
}
// register component module identifier for async chunk inferrence
if (context && context._registeredComponents) {
context._registeredComponents.add(moduleIdentifier)
}
}
// used by ssr in case component is cached and beforeCreate
// never gets called
options._ssrRegister = hook
} else if (injectStyles) {
hook = injectStyles
}
if (hook) {
var functional = options.functional
var existing = functional
? options.render
: options.beforeCreate
if (!functional) {
// inject component registration as beforeCreate hook
options.beforeCreate = existing
? [].concat(existing, hook)
: [hook]
} else {
// register for functioal component in vue file
options.render = function renderWithStyleInjection (h, context) {
hook.call(context)
return existing(h, context)
}
}
}
return {
esModule: esModule,
exports: scriptExports,
options: options
}
}
/***/ }),
/* 1 */
/***/ (function(module, exports) {
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
// css base code, injected by the css-loader
module.exports = function(useSourceMap) {
var list = [];
// return the list of modules as css string
list.toString = function toString() {
return this.map(function (item) {
var content = cssWithMappingToString(item, useSourceMap);
if(item[2]) {
return "@media " + item[2] + "{" + content + "}";
} else {
return content;
}
}).join("");
};
// import a list of modules into the list
list.i = function(modules, mediaQuery) {
if(typeof modules === "string")
modules = [[null, modules, ""]];
var alreadyImportedModules = {};
for(var i = 0; i < this.length; i++) {
var id = this[i][0];
if(typeof id === "number")
alreadyImportedModules[id] = true;
}
for(i = 0; i < modules.length; i++) {
var item = modules[i];
// skip already imported module
// this implementation is not 100% perfect for weird media query combinations
// when a module is imported multiple times with different media queries.
// I hope this will never occur (Hey this way we have smaller bundles)
if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) {
if(mediaQuery && !item[2]) {
item[2] = mediaQuery;
} else if(mediaQuery) {
item[2] = "(" + item[2] + ") and (" + mediaQuery + ")";
}
list.push(item);
}
}
};
return list;
};
function cssWithMappingToString(item, useSourceMap) {
var content = item[1] || '';
var cssMapping = item[3];
if (!cssMapping) {
return content;
}
if (useSourceMap && typeof btoa === 'function') {
var sourceMapping = toComment(cssMapping);
var sourceURLs = cssMapping.sources.map(function (source) {
return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'
});
return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
}
return [content].join('\n');
}
// Adapted from convert-source-map (MIT)
function toComment(sourceMap) {
// eslint-disable-next-line no-undef
var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;
return '/*# ' + data + ' */';
}
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
Modified by Evan You @yyx990803
*/
var hasDocument = typeof document !== 'undefined'
if (typeof DEBUG !== 'undefined' && DEBUG) {
if (!hasDocument) {
throw new Error(
'vue-style-loader cannot be used in a non-browser environment. ' +
"Use { target: 'node' } in your Webpack config to indicate a server-rendering environment."
) }
}
var listToStyles = __webpack_require__(293)
/*
type StyleObject = {
id: number;
parts: Array<StyleObjectPart>
}
type StyleObjectPart = {
css: string;
media: string;
sourceMap: ?string
}
*/
var stylesInDom = {/*
[id: number]: {
id: number,
refs: number,
parts: Array<(obj?: StyleObjectPart) => void>
}
*/}
var head = hasDocument && (document.head || document.getElementsByTagName('head')[0])
var singletonElement = null
var singletonCounter = 0
var isProduction = false
var noop = function () {}
var options = null
var ssrIdKey = 'data-vue-ssr-id'
// Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
// tags it will allow on a page
var isOldIE = typeof navigator !== 'undefined' && /msie [6-9]\b/.test(navigator.userAgent.toLowerCase())
module.exports = function (parentId, list, _isProduction, _options) {
isProduction = _isProduction
options = _options || {}
var styles = listToStyles(parentId, list)
addStylesToDom(styles)
return function update (newList) {
var mayRemove = []
for (var i = 0; i < styles.length; i++) {
var item = styles[i]
var domStyle = stylesInDom[item.id]
domStyle.refs--
mayRemove.push(domStyle)
}
if (newList) {
styles = listToStyles(parentId, newList)
addStylesToDom(styles)
} else {
styles = []
}
for (var i = 0; i < mayRemove.length; i++) {
var domStyle = mayRemove[i]
if (domStyle.refs === 0) {
for (var j = 0; j < domStyle.parts.length; j++) {
domStyle.parts[j]()
}
delete stylesInDom[domStyle.id]
}
}
}
}
function addStylesToDom (styles /* Array<StyleObject> */) {
for (var i = 0; i < styles.length; i++) {
var item = styles[i]
var domStyle = stylesInDom[item.id]
if (domStyle) {
domStyle.refs++
for (var j = 0; j < domStyle.parts.length; j++) {
domStyle.parts[j](item.parts[j])
}
for (; j < item.parts.length; j++) {
domStyle.parts.push(addStyle(item.parts[j]))
}
if (domStyle.parts.length > item.parts.length) {
domStyle.parts.length = item.parts.length
}
} else {
var parts = []
for (var j = 0; j < item.parts.length; j++) {
parts.push(addStyle(item.parts[j]))
}
stylesInDom[item.id] = { id: item.id, refs: 1, parts: parts }
}
}
}
function createStyleElement () {
var styleElement = document.createElement('style')
styleElement.type = 'text/css'
head.appendChild(styleElement)
return styleElement
}
function addStyle (obj /* StyleObjectPart */) {
var update, remove
var styleElement = document.querySelector('style[' + ssrIdKey + '~="' + obj.id + '"]')
if (styleElement) {
if (isProduction) {
// has SSR styles and in production mode.
// simply do nothing.
return noop
} else {
// has SSR styles but in dev mode.
// for some reason Chrome can't handle source map in server-rendered
// style tags - source maps in <style> only works if the style tag is
// created and inserted dynamically. So we remove the server rendered
// styles and inject new ones.
styleElement.parentNode.removeChild(styleElement)
}
}
if (isOldIE) {
// use singleton mode for IE9.
var styleIndex = singletonCounter++
styleElement = singletonElement || (singletonElement = createStyleElement())
update = applyToSingletonTag.bind(null, styleElement, styleIndex, false)
remove = applyToSingletonTag.bind(null, styleElement, styleIndex, true)
} else {
// use multi-style-tag mode in all other cases
styleElement = createStyleElement()
update = applyToTag.bind(null, styleElement)
remove = function () {
styleElement.parentNode.removeChild(styleElement)
}
}
update(obj)
return function updateStyle (newObj /* StyleObjectPart */) {
if (newObj) {
if (newObj.css === obj.css &&
newObj.media === obj.media &&
newObj.sourceMap === obj.sourceMap) {
return
}
update(obj = newObj)
} else {
remove()
}
}
}
var replaceText = (function () {
var textStore = []
return function (index, replacement) {
textStore[index] = replacement
return textStore.filter(Boolean).join('\n')
}
})()
function applyToSingletonTag (styleElement, index, remove, obj) {
var css = remove ? '' : obj.css
if (styleElement.styleSheet) {
styleElement.styleSheet.cssText = replaceText(index, css)
} else {
var cssNode = document.createTextNode(css)
var childNodes = styleElement.childNodes
if (childNodes[index]) styleElement.removeChild(childNodes[index])
if (childNodes.length) {
styleElement.insertBefore(cssNode, childNodes[index])
} else {
styleElement.appendChild(cssNode)
}
}
}
function applyToTag (styleElement, obj) {
var css = obj.css
var media = obj.media
var sourceMap = obj.sourceMap
if (media) {
styleElement.setAttribute('media', media)
}
if (options.ssrId) {
styleElement.setAttribute(ssrIdKey, obj.id)
}
if (sourceMap) {
// https://developer.chrome.com/devtools/docs/javascript-debugging
// this makes source maps inside style tags work properly in Chrome
css += '\n/*# sourceURL=' + sourceMap.sources[0] + ' */'
// http://stackoverflow.com/a/26603875
css += '\n/*# sourceMappingURL=data:application/json;base64,' + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + ' */'
}
if (styleElement.styleSheet) {
styleElement.styleSheet.cssText = css
} else {
while (styleElement.firstChild) {
styleElement.removeChild(styleElement.firstChild)
}
styleElement.appendChild(document.createTextNode(css))
}
}
/***/ }),
/* 3 */
/***/ (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__(158);
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: 我去上学校,天天不迟到
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;
/***/ }),
/* 4 */
/***/ (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',
{
'get': function () {
return regexp.lastIndex;
},
'set': function (v) {
regexp.lastIndex = v;
}
});
}
function LexicalParser() {
var inputElementDiv = new XRegExp(lex, 'InputElementDiv', 'g');
var inputElementRegExp = new XRegExp(lex, 'InputElementRegExp', 'g');
var source;
Object.defineProperty(this, 'source', {
'get': function () {
return source;
},
'set': function (v) {
source = v;
inputElementDiv.lastIndex = 0;
inputElementRegExp.lastIndex = 0;
}
});
this.reset = function () {
inputElementDiv.lastIndex = 0;
inputElementRegExp.lastIndex = 0;
};
this.getNextToken = function (useDiv) {
var lastIndex = inputElementDiv.lastIndex;
var inputElement;
if (useDiv)
inputElement = inputElementDiv;
else
inputElement = inputElementRegExp;
var token = inputElement.exec(source);
if (token && inputElement.lastIndex - lastIndex > token.length) {
throw new SyntaxError('Unexpected token ILLEGAL');
}
inputElementDiv.lastIndex = inputElement.lastIndex;
inputElementRegExp.lastIndex = inputElement.lastIndex;
return token;
};
}
var rules = {
'IdentifierName': [['Identifier']],
'Literal': [['NullLiteral'], ['BooleanLiteral'], ['NumericLiteral'], ['StringLiteral'], ['RegularExpressionLiteral']],
'PrimaryExpression': [['Identifier'], ['Literal'], ['(', 'Expression', ')']],
'CallExpression': [['PrimaryExpression', 'Arguments'], ['CallExpression', 'Arguments']],
'Arguments': [['(', ')'], ['(', 'ArgumentList', ')']],
'ArgumentList': [['ConditionalExpression'], ['ArgumentList', ',', 'ConditionalExpression']],
'LeftHandSideExpression': [['PrimaryExpression'], ['CallExpression']],
'UnaryExpression': [['LeftHandSideExpression'], ['void', 'UnaryExpression'], ['+', 'UnaryExpression'], ['-', 'UnaryExpression'], ['~', 'UnaryExpression'], ['!', 'UnaryExpression']],
'ExponentiationExpression': [['UnaryExpression'], ['ExponentiationExpression', '**', 'UnaryExpression']],
'MultiplicativeExpression': [['MultiplicativeExpression', '/', 'ExponentiationExpression'], ['ExponentiationExpression'], ['MultiplicativeExpression', '*', 'ExponentiationExpression'], ['MultiplicativeExpression', '%', 'ExponentiationExpression']],
'AdditiveExpression': [['MultiplicativeExpression'], ['AdditiveExpression', '+', 'MultiplicativeExpression'], ['AdditiveExpression', '-', 'MultiplicativeExpression']],
'ShiftExpression': [['AdditiveExpression'], ['ShiftExpression', '<<', 'AdditiveExpression'], ['ShiftExpression', '>>', 'AdditiveExpression'], ['ShiftExpression', '>>>', 'AdditiveExpression']],
'RelationalExpression': [['ShiftExpression'], ['RelationalExpression', '<', 'ShiftExpression'], ['RelationalExpression', '>', 'ShiftExpression'], ['RelationalExpression', '<=', 'ShiftExpression'], ['RelationalExpression', '>=', 'ShiftExpression'], ['RelationalExpression', 'instanceof', 'ShiftExpression'], ['RelationalExpression', 'in', 'ShiftExpression']],
'EqualityExpression': [['RelationalExpression'], ['EqualityExpression', '==', 'RelationalExpression'], ['EqualityExpression', '!=', 'RelationalExpression'], ['EqualityExpression', '===', 'RelationalExpression'], ['EqualityExpression', '!==', 'RelationalExpression']],
'BitwiseANDExpression': [['EqualityExpression'], ['BitwiseANDExpression', '&', 'EqualityExpression']],
'BitwiseXORExpression': [['BitwiseANDExpression'], ['BitwiseXORExpression', '^', 'BitwiseANDExpression']],
'BitwiseORExpression': [['BitwiseXORExpression'], ['BitwiseORExpression', '|', 'BitwiseXORExpression']],
'LogicalANDExpression': [['BitwiseORExpression'], ['LogicalANDExpression', '&&', 'BitwiseORExpression']],
'LogicalORExpression': [['LogicalANDExpression'], ['LogicalORExpression', '||', 'LogicalANDExpression']],
'ConditionalExpression': [['LogicalORExpression'], ['LogicalORExpression', '?', 'LogicalORExpression', ':', 'LogicalORExpression']],
'Expression': [['ConditionalExpression'], ['Expression', ',', 'ConditionalExpression']],
'Program': [['Expression']]
};
function Symbol(symbolName, token) {
this.name = symbolName;
this.token = token;
this.childNodes = [];
this.toString = function (indent) {
if (!indent)
indent = '';
if (this.childNodes.length == 1)
return this.childNodes[0].toString(indent);
var str = indent + this.name + (this.token != undefined && this.name != this.token ? ':' + this.token : '') + '\n';
for (var i = 0; i < this.childNodes.length; i++)
str += this.childNodes[i].toString(indent + ' ');
return str;
};
}
function SyntacticalParser() {
var currentRule;
var root = {
Program: '$'
};
var hash = {};
function closureNode(node) {
hash[JSON.stringify(node)] = node;
var queue = Object.getOwnPropertyNames(node);
while (queue.length) {
var symbolName = queue.shift();
if (!rules[symbolName])
continue;
rules[symbolName].forEach(function (rule) {
if (!node[rule[0]])
queue.push(rule[0]);
var rulenode = node;
var lastnode = null;
rule.forEach(function (symbol) {
if (!rulenode[symbol])
rulenode[symbol] = {};
lastnode = rulenode;
rulenode = rulenode[symbol];
});
if (node[symbolName].$div)
rulenode.$div = true;
rulenode.$reduce = symbolName;
rulenode.$count = rule.length;
});
}
for (var p in node) {
if (typeof node[p] != 'object' || p.charAt(0) == '$' || node[p].$closure)
continue;
if (hash[JSON.stringify(node[p])])
node[p] = hash[JSON.stringify(node[p])];
else {
closureNode(node[p]);
}
}
node.$closure = true;
}
closureNode(root);
var symbolStack = [];
var statusStack = [root];
var current = root;
this.insertSymbol = function insertSymbol(symbol, haveLineTerminator) {
while (!current[symbol.name] && current.$reduce) {
var count = current.$count;
var newsymbol = new Symbol(current.$reduce);
while (count--)
newsymbol.childNodes.push(symbolStack.pop()), statusStack.pop();
current = statusStack[statusStack.length - 1];
this.insertSymbol(newsymbol);
}
current = current[symbol.name];
symbolStack.push(symbol), statusStack.push(current);
if (!current)
throw new Error();
return current.$div;
};
this.reset = function () {
current = root;
symbolStack = [];
statusStack = [root];
};
Object.defineProperty(this, 'grammarTree', {
'get': function () {
try {
while (current.$reduce) {
var count = current.$count;
var newsymbol = new Symbol(current.$reduce);
while (count--)
newsymbol.childNodes.push(symbolStack.pop()), statusStack.pop();
current = statusStack[statusStack.length - 1];
this.insertSymbol(newsymbol);
}
if (symbolStack.length > 0 && current[';']) {
this.insertSymbol(new Symbol(';', ';'));
return this.grammarTree;
}
if (symbolStack.length != 1 || symbolStack[0].name != 'Program')
throw new Error();
} catch (e) {
throw new SyntaxError('Unexpected end of input');
}
return symbolStack[0];
}
});
}
function Parser() {
this.lexicalParser = new LexicalParser();
this.syntacticalParser = new SyntacticalParser();
var terminalSymbols = ['NullLiteral', 'BooleanLiteral', 'NumericLiteral', 'StringLiteral', 'RegularExpressionLiteral', 'Identifier', '**', '=>', '{', '}', '(', ')', '[', ']', '.', ';', ',', '<', '>', '<=', '>=', '==', '!=', '===', '!==', '+', '-', '*', '%', '++', '--', '<<', '>>', '>>>', '&', '|', '^', '!', '~', '&&', '||', '?', ':', '=', '+=', '-=', '*=', '%=', '<<=', '>>=', '>>>=', '&=', '|=', '^=', '/', '/=', 'instanceof', 'typeof', 'new', 'void', 'debugger', 'this', 'delete', 'in'];
var terminalSymbolIndex = {};
terminalSymbols.forEach(function (e) {