Socket
Socket
Sign inDemoInstall

driver-weex

Package Overview
Dependencies
Maintainers
6
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

driver-weex - npm Package Compare versions

Comparing version 2.0.2 to 2.1.0

4

CHANGELOG.md
## Changelog
### v2.1.0
- Support weex v2
### v2.0.2

@@ -4,0 +8,0 @@

648

dist/driver-weex.js
var DriverWeex = (function (exports) {
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
function getDefaultExportFromCjs (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}

@@ -15,2 +17,17 @@ function createCommonjsModule(fn, basedir, module) {

function getAugmentedNamespace(n) {
if (n.__esModule) return n;
var a = Object.defineProperty({}, '__esModule', {value: true});
Object.keys(n).forEach(function (k) {
var d = Object.getOwnPropertyDescriptor(n, k);
Object.defineProperty(a, k, d.get ? d : {
enumerable: true,
get: function () {
return n[k];
}
});
});
return a;
}
function commonjsRequire () {

@@ -20,187 +37,449 @@ throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');

var lib$1 = createCommonjsModule(function (module, exports) {
var defineProperty = createCommonjsModule(function (module) {
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;
}
exports.__esModule = true;
exports.isQuickApp = exports.isWeChatMiniProgram = exports.isByteDanceMicroApp = exports.isMiniApp = exports.isKraken = exports.isWeex = exports.isNode = exports.isWeb = void 0;
function isUndef(type) {
return type === 'undefined';
return obj;
}
var isWeb = !isUndef(typeof window) && 'onload' in window;
exports.isWeb = isWeb;
var isNode = !isUndef(typeof process) && !!(process.versions && process.versions.node);
exports.isNode = isNode;
var isWeex = !isUndef(typeof WXEnvironment) && WXEnvironment.platform !== 'Web';
exports.isWeex = isWeex;
var isKraken = !isUndef(typeof __kraken__);
exports.isKraken = isKraken;
var isMiniApp = !isUndef(typeof my) && my !== null && !isUndef(typeof my.alert);
exports.isMiniApp = isMiniApp;
var isByteDanceMicroApp = !isUndef(typeof tt) && tt !== null && !isUndef(typeof tt) && !isUndef(tt.showToast); // In wechat mini program, wx.login is a function
// In wechat mini propgram webview, there is no wx.login, but exist wx.miniProgram
// In bytedance maicro app, there is wx variable.
exports.isByteDanceMicroApp = isByteDanceMicroApp;
var isWeChatMiniProgram = !isByteDanceMicroApp && !isUndef(typeof wx) && wx !== null && (!isUndef(typeof wx.login) || !isUndef(typeof wx.miniProgram));
exports.isWeChatMiniProgram = isWeChatMiniProgram;
var isQuickApp = !isUndef(typeof commonjsGlobal) && commonjsGlobal !== null && !isUndef(typeof commonjsGlobal.callNative) && !isWeex;
exports.isQuickApp = isQuickApp;
module.exports = _defineProperty;
module.exports["default"] = module.exports, module.exports.__esModule = true;
});
var _defineProperty = /*@__PURE__*/getDefaultExportFromCjs(defineProperty);
var isWeb = typeof window !== 'undefined' && 'onload' in window;
var isNode = typeof process !== 'undefined' && !!(process.versions && process.versions.node);
var isWeex = typeof WXEnvironment !== 'undefined' && WXEnvironment.platform !== 'Web';
var isKraken = typeof __kraken__ !== 'undefined';
var isMiniApp = typeof my !== 'undefined' && my !== null && typeof my.alert !== 'undefined';
var isByteDanceMicroApp = typeof tt !== 'undefined' && tt !== null && typeof tt.showToast !== 'undefined';
var isBaiduSmartProgram = typeof swan !== 'undefined' && swan !== null && typeof swan.showToast !== 'undefined';
var isKuaiShouMiniProgram = typeof ks !== 'undefined' && ks !== null && typeof ks.showToast !== 'undefined'; // In wechat mini program, wx.login is a function
// In wechat mini propgram webview, there is no wx.login, but exist wx.miniProgram
// In bytedance maicro app, there is wx variable.
var isWeChatMiniProgram = !isByteDanceMicroApp && typeof wx !== 'undefined' && wx !== null && (typeof wx.request !== 'undefined' || typeof wx.miniProgram !== 'undefined');
var isQuickApp = typeof global !== 'undefined' && global !== null && typeof global.callNative !== 'undefined' && !isWeex;
var index = {
isWeb: isWeb,
isNode: isNode,
isWeex: isWeex,
isKraken: isKraken,
isMiniApp: isMiniApp,
isByteDanceMicroApp: isByteDanceMicroApp,
isBaiduSmartProgram: isBaiduSmartProgram,
isKuaiShouMiniProgram: isKuaiShouMiniProgram,
isWeChatMiniProgram: isWeChatMiniProgram,
isQuickApp: isQuickApp
};
var es = {
__proto__: null,
isWeb: isWeb,
isNode: isNode,
isWeex: isWeex,
isKraken: isKraken,
isMiniApp: isMiniApp,
isByteDanceMicroApp: isByteDanceMicroApp,
isBaiduSmartProgram: isBaiduSmartProgram,
isKuaiShouMiniProgram: isKuaiShouMiniProgram,
isWeChatMiniProgram: isWeChatMiniProgram,
isQuickApp: isQuickApp,
'default': index
};
var _env = /*@__PURE__*/getAugmentedNamespace(es);
var lib = createCommonjsModule(function (module, exports) {
exports.__esModule = true;
exports.isRpx = isRpx;
exports.calcRpx = calcRpx;
exports.getRpx = getRpx;
exports.setRpx = setRpx;
exports.getViewportWidth = getViewportWidth;
exports.setViewportWidth = setViewportWidth;
exports.setDecimalPixelTransformer = setDecimalPixelTransformer;
exports.setUnitPrecision = setUnitPrecision;
exports.cached = cached;
exports.setTargetPlatform = setTargetPlatform;
exports.convertUnit = void 0;
var RPX_REG = /"[^"]+"|'[^']+'|url\([^\)]+\)|(\d*\.?\d+)rpx/g;
Object.keys(_env).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _env[key]) return;
exports[key] = _env[key];
});
});
var __rpx_coefficient__;
var RPX_REG = /"[^"]+"|'[^']+'|url\([^\)]+\)|(\d*\.?\d+)rpx/g;
var __viewport_width__; // convertUnit method targetPlatform
var __rpx_coefficient__;
var __viewport_width__; // convertUnit method targetPlatform
var targetPlatform = lib$1.isWeb ? 'web' : lib$1.isWeex ? 'weex' : ''; // Init toFixed method
var unitPrecision = 4;
var targetPlatform = lib.isWeb ? 'web' : lib.isWeex ? 'weex' : ''; // Init toFixed method
var toFixed = function toFixed(number, precision) {
var multiplier = Math.pow(10, precision + 1);
var wholeNumber = Math.floor(number * multiplier);
return Math.round(wholeNumber / 10) * 10 / multiplier;
}; // Dedault decimal px transformer.
var unitPrecision = 4;
var toFixed = function toFixed(number, precision) {
var multiplier = Math.pow(10, precision + 1);
var wholeNumber = Math.floor(number * multiplier);
return Math.round(wholeNumber / 10) * 10 / multiplier;
}; // Dedault decimal px transformer.
var decimalPixelTransformer = function decimalPixelTransformer(rpx, $1) {
return $1 ? parseFloat(rpx) * getRpx() + 'px' : rpx;
}; // Default decimal vw transformer.
var decimalPixelTransformer = function decimalPixelTransformer(rpx, $1) {
return $1 ? parseFloat(rpx) * getRpx() + 'px' : rpx;
}; // Default decimal vw transformer.
var decimalVWTransformer = function decimalVWTransformer(rpx, $1) {
return $1 ? toFixed(parseFloat(rpx) / (getViewportWidth() / 100), unitPrecision) + 'vw' : rpx;
}; // Default 1 rpx to 1 px
var decimalVWTransformer = function decimalVWTransformer(rpx, $1) {
return $1 ? toFixed(parseFloat(rpx) / (getViewportWidth() / 100), unitPrecision) + 'vw' : rpx;
}; // Default 1 rpx to 1 px
if (getRpx() === undefined) {
setRpx(1);
} // Viewport width, default to 750.
if (getRpx() === undefined) {
setRpx(1);
} // Viewport width, default to 750.
if (getViewportWidth() === undefined) {
setViewportWidth(750);
if (getViewportWidth() === undefined) {
setViewportWidth(750);
}
var CustomMap = /*#__PURE__*/function () {
function CustomMap() {
_defineProperty(this, "__store", {});
}
/**
* Is string contains rpx
* note: rpx is an alias to rpx
* @param {String} str
* @returns {Boolean}
*/
var _proto = CustomMap.prototype;
function isRpx(str) {
return typeof str === 'string' && RPX_REG.test(str);
_proto.set = function set(key, value) {
this.__store[key + "_" + typeof key] = value;
};
_proto.get = function get(key) {
return this.__store[key + "_" + typeof key];
};
_proto.has = function has(key) {
return Object.prototype.hasOwnProperty.call(this.__store, key + "_" + typeof key);
};
return CustomMap;
}();
/**
* Is string contains rpx
* note: rpx is an alias to rpx
* @param {String} str
* @returns {Boolean}
*/
function isRpx(str) {
return typeof str === 'string' && RPX_REG.test(str);
}
/**
* Calculate rpx
* @param {String} str
* @returns {String}
*/
function calcRpx(str) {
if (targetPlatform === 'web') {
// In Web convert rpx to 'vw', same as driver-dom and driver-universal
// '375rpx' => '50vw'
return str.replace(RPX_REG, decimalVWTransformer);
} else if (targetPlatform === 'weex') {
// In Weex convert rpx to 'px'
// '375rpx' => 375 * px
return str.replace(RPX_REG, decimalPixelTransformer);
} else {
// Other platform return original value, like Mini-App and WX Mini-Program ...
// '375rpx' => '375rpx'
return str;
}
/**
* Calculate rpx
* @param {String} str
* @returns {String}
*/
}
function getRpx() {
return __rpx_coefficient__;
}
function setRpx(rpx) {
__rpx_coefficient__ = rpx;
}
function getViewportWidth() {
return __viewport_width__;
}
function setViewportWidth(viewport) {
__viewport_width__ = viewport;
}
/**
* Create a cached version of a pure function.
* Use the first params as cache key.
*/
function cached(fn) {
var cache = new CustomMap();
return function cachedFn() {
var key = arguments.length <= 0 ? undefined : arguments[0];
if (!cache.has(key)) cache.set(key, fn.apply(void 0, arguments));
return cache.get(key);
};
}
function setTargetPlatform(platform) {
targetPlatform = platform;
}
/**
* Convert rpx.
* @param value
* @param prop
* @param platform
* @return {String} Transformed value.
*/
function calcRpx(str) {
if (targetPlatform === 'web') {
// In Web convert rpx to 'vw', same as driver-dom and driver-universal
// '375rpx' => '50vw'
return str.replace(RPX_REG, decimalVWTransformer);
} else if (targetPlatform === 'weex') {
// In Weex convert rpx to 'px'
// '375rpx' => 375 * px
return str.replace(RPX_REG, decimalPixelTransformer);
var convertUnit = cached(function (value, prop, platform) {
if (platform) {
setTargetPlatform(platform);
}
return isRpx(value) ? calcRpx(value) : value;
});
/**
* Driver for Web DOM
**/
// fontWeight -> ntw
// lineHeight|lineClamp -> ne[ch]
// flex|flexGrow|flexPositive|flexShrink|flexNegative|boxFlex|boxFlexGroup|zIndex -> ex(?:s|g|n|p|$)
// order -> ^ord
// zoom -> zoo
// gridArea|gridRow|gridRowEnd|gridRowSpan|gridRowStart|gridColumn|gridColumnEnd|gridColumnSpan|gridColumnStart -> grid
// columnCount -> mnc
// tabSize -> bs
// orphans -> orp
// windows -> ows
// animationIterationCount -> onit
// borderImageOutset|borderImageSlice|borderImageWidth -> erim
var NON_DIMENSIONAL_REG = /opa|ntw|ne[ch]|ex(?:s|g|n|p|$)|^ord|zoo|grid|orp|ows|mnc|^columns$|bs|erim|onit/i;
var EVENT_PREFIX_REG = /^on[A-Z]/;
var DANGEROUSLY_SET_INNER_HTML = 'dangerouslySetInnerHTML';
var HTML = '__html';
var INNER_HTML = 'innerHTML';
var CLASS_NAME = 'className';
var CLASS = 'class';
var STYLE$1 = 'style';
var CHILDREN$1 = 'children';
var TEXT_CONTENT_ATTR = 'textContent';
var CREATE_ELEMENT = 'createElement';
var CREATE_COMMENT = 'createComment';
var CREATE_TEXT_NODE = 'createTextNode';
var SET_ATTRIBUTE = 'setAttribute';
var REMOVE_ATTRIBUTE = 'removeAttribute';
var SVG_NS = 'http://www.w3.org/2000/svg';
var EMPTY$1 = '';
var WITH_INNERHTML = '__h';
var isSVGMode = false;
/**
* Camelize CSS property.
* Vendor prefixes should begin with a capital letter.
* For example:
* background-color -> backgroundColor
* -webkit-transition -> webkitTransition
*/
cached(function (name) {
return name.replace(/-([a-z])/gi, function (s, g) {
return g.toUpperCase();
});
});
var isDimensionalProp = cached(function (prop) {
return !NON_DIMENSIONAL_REG.test(prop);
});
var isEventProp = cached(function (prop) {
return EVENT_PREFIX_REG.test(prop);
});
function createBody$1() {
return document.body;
}
function createEmpty$1(component) {
component._parent;
var node;
{
node = document[CREATE_COMMENT](EMPTY$1);
}
return node;
}
function createText$1(text, component) {
component._parent;
var node;
{
node = document[CREATE_TEXT_NODE](text);
}
return node;
}
function updateText$1(node, text) {
node[TEXT_CONTENT_ATTR] = text;
}
/**
* @param {string} type node type
* @param {object} props elemement properties
* @param {object} component component instance
* @param {boolean} __shouldConvertUnitlessToRpx should add unit when missing
*/
function createElement$1(type, props, component, __shouldConvertUnitlessToRpx) {
var parent = component._parent;
isSVGMode = type === 'svg' || parent && parent.namespaceURI === SVG_NS;
var node;
function createNode() {
if (isSVGMode) {
node = document.createElementNS(SVG_NS, type);
} else {
// Other platform return original value, like Mini-App and WX Mini-Program ...
// '375rpx' => '375rpx'
return str;
node = document[CREATE_ELEMENT](type);
}
}
function getRpx() {
return __rpx_coefficient__;
{
createNode();
}
function setRpx(rpx) {
__rpx_coefficient__ = rpx;
for (var prop in props) {
var value = props[prop];
if (prop === CHILDREN$1) continue;
if (value != null) {
if (prop === STYLE$1) {
setStyle$1(node, value, __shouldConvertUnitlessToRpx);
} else if (isEventProp(prop)) {
addEventListener$1(node, prop.slice(2).toLowerCase(), value);
} else {
setAttribute$1(node, prop, value, isSVGMode);
}
}
}
function getViewportWidth() {
return __viewport_width__;
return node;
}
function appendChild$1(node, parent) {
{
return parent.appendChild(node);
}
}
function removeChild$1(node, parent) {
parent = parent || node.parentNode; // Maybe has been removed when remove child
function setViewportWidth(viewport) {
__viewport_width__ = viewport;
if (parent) {
parent.removeChild(node);
}
/**
* Set a function to transform unit of pixel,
* default to passthrough.
* @param {Function} transformer function
*/
}
function replaceChild$1(newChild, oldChild, parent) {
parent = parent || oldChild.parentNode;
parent.replaceChild(newChild, oldChild);
}
function insertAfter$1(node, after, parent) {
parent = parent || after.parentNode;
var nextSibling = after.nextSibling;
function setDecimalPixelTransformer(transformer) {
decimalPixelTransformer = transformer;
if (nextSibling) {
// Performance improve when node has been existed before nextSibling
if (nextSibling !== node) {
insertBefore$1(node, nextSibling, parent);
}
} else {
appendChild$1(node, parent);
}
/**
* Set unit precision.
* @param n {Number} Unit precision, default to 4.
*/
}
function insertBefore$1(node, before, parent) {
parent = parent || before.parentNode;
parent.insertBefore(node, before);
}
function addEventListener$1(node, eventName, eventHandler) {
return node.addEventListener(eventName, eventHandler);
}
function removeEventListener$1(node, eventName, eventHandler) {
return node.removeEventListener(eventName, eventHandler);
}
function removeAttribute$1(node, propKey) {
if (propKey === DANGEROUSLY_SET_INNER_HTML) {
return node[INNER_HTML] = null;
}
if (propKey === CLASS_NAME) propKey = CLASS;
function setUnitPrecision(n) {
unitPrecision = n;
if (propKey in node) {
try {
// Some node property is readonly when in strict mode
node[propKey] = null;
} catch (e) {}
}
/**
* Create a cached version of a pure function.
* Use the first params as cache key.
*/
node[REMOVE_ATTRIBUTE](propKey);
}
function setAttribute$1(node, propKey, propValue, isSvg) {
if (propKey === DANGEROUSLY_SET_INNER_HTML) {
// For reduce innerHTML operation to improve performance.
if (node[INNER_HTML] !== propValue[HTML]) {
node[INNER_HTML] = propValue[HTML];
}
function cached(fn) {
var cache = new Map();
return function cachedFn() {
var key = arguments.length <= 0 ? undefined : arguments[0];
if (!cache.has(key)) cache.set(key, fn.apply(void 0, arguments));
return cache.get(key);
};
node[WITH_INNERHTML] = true;
return;
}
function setTargetPlatform(platform) {
targetPlatform = platform;
if (propKey === CLASS_NAME) propKey = CLASS; // Prop for svg can only be set by attribute
if (!isSvg && propKey in node) {
try {
// Some node property is readonly when in strict mode
node[propKey] = propValue;
} catch (e) {
node[SET_ATTRIBUTE](propKey, propValue);
}
} else {
node[SET_ATTRIBUTE](propKey, propValue);
}
/**
* Convert rpx.
* @param value
* @param prop
* @param platform
* @return {String} Transformed value.
*/
}
/**
* @param {object} node target node
* @param {object} style target node style value
* @param {boolean} __shouldConvertUnitlessToRpx
*/
function setStyle$1(node, style, __shouldConvertUnitlessToRpx) {
for (var prop in style) {
var value = style[prop];
var convertedValue = void 0;
var convertUnit = cached(function (value, prop, platform) {
if (platform) {
setTargetPlatform(platform);
if (typeof value === 'number' && isDimensionalProp(prop)) {
if (__shouldConvertUnitlessToRpx) {
convertedValue = value + 'rpx'; // Transfrom rpx to vw
convertedValue = convertUnit(convertedValue);
} else {
convertedValue = value + 'px';
}
} else {
convertedValue = convertUnit(value);
} // Support CSS custom properties (variables) like { --main-color: "black" }
if (prop[0] === '-' && prop[1] === '-') {
// reference: https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration/setProperty.
// style.setProperty do not support Camel-Case style properties.
node.style.setProperty(prop, convertedValue);
} else {
node.style[prop] = convertedValue;
}
}
}
return isRpx(value) ? calcRpx(value) : value;
});
exports.convertUnit = convertUnit;
});
/* global __weex_v2__ */
var isWeexV2 = typeof __weex_v2__ === 'object';
var STYLE = 'style';

@@ -226,13 +505,21 @@ var ID = 'id';

var document = typeof __weex_document__ === 'object' ? __weex_document__ : typeof document === 'object' ? document : null;
var weexDocument = typeof __weex_document__ === 'object' ? __weex_document__ : typeof document === 'object' ? document : null;
function getElementById(id) {
if (isWeexV2) {
return document.getElementById(id);
}
return nodeMaps[id];
}
function createBody(type, props) {
if (document.body) {
return document.body;
if (isWeexV2) {
return createBody$1();
}
var documentElement = document.documentElement;
var body = document.createBody(type, props);
if (weexDocument.body) {
return weexDocument.body;
}
var documentElement = weexDocument.documentElement;
var body = weexDocument.createBody(type, props);
documentElement.appendChild(body);

@@ -242,21 +529,34 @@ return body;

function createComment(content) {
return document.createComment(content);
return weexDocument.createComment(content);
}
function createEmpty() {
function createEmpty(component) {
if (isWeexV2) {
return createEmpty$1(component);
}
return createComment(EMPTY);
}
function createText(text) {
// Use comment node type mock text node
function createText(text, component) {
if (isWeexV2) {
return createText$1(text, component);
} // Use comment node type mock text node
return createComment(text);
}
function updateText(node, text) {
if (isWeexV2) {
return updateText$1(node, text);
}
node.value = text;
updateWeexTextValue(node.parentNode);
}
function createElement(type, props) {
if (props === void 0) {
props = {};
function createElement(type, props, component) {
if (isWeexV2) {
return createElement$1(type, props, component, true);
}
var style = {};
props = props || {};
var originStyle = props.style;

@@ -266,7 +566,7 @@

for (var prop in originStyle) {
style[prop] = lib.convertUnit(originStyle[prop], prop);
style[prop] = convertUnit(originStyle[prop], prop);
}
}
var node = document.createElement(type, {
var node = weexDocument.createElement(type, {
style: style

@@ -298,2 +598,6 @@ });

function appendChild(node, parent) {
if (isWeexV2) {
return appendChild$1(node, parent);
}
parent.appendChild(node);

@@ -306,2 +610,6 @@

function removeChild(node, parent) {
if (isWeexV2) {
return removeChild$1(node, parent);
}
parent = parent || node.parentNode;

@@ -321,2 +629,6 @@ var id = node.attr && node.attr[ID];

function replaceChild(newChild, oldChild, parent) {
if (isWeexV2) {
return replaceChild$1(newChild, oldChild, parent);
}
parent = parent || oldChild.parentNode;

@@ -336,2 +648,6 @@ var previousSibling = oldChild.previousSibling;

function insertAfter(node, after, parent) {
if (isWeexV2) {
return insertAfter$1(node, after, parent);
}
parent = parent || after.parentNode;

@@ -345,2 +661,6 @@ parent.insertAfter(node, after);

function insertBefore(node, before, parent) {
if (isWeexV2) {
return insertBefore$1(node, before, parent);
}
parent = parent || before.parentNode;

@@ -354,3 +674,7 @@ parent.insertBefore(node, before);

function addEventListener(node, eventName, eventHandler, props) {
// https://github.com/apache/incubator-weex/blob/master/runtime/vdom/Element.js#L421
if (isWeexV2) {
return addEventListener$1(node, eventName, eventHandler);
} // https://github.com/apache/incubator-weex/blob/master/runtime/vdom/Element.js#L421
var params = props[eventName + 'EventParams'];

@@ -360,5 +684,13 @@ return node.addEvent(eventName, eventHandler, params);

function removeEventListener(node, eventName, eventHandler) {
if (isWeexV2) {
return removeEventListener$1(node, eventName, eventHandler);
}
return node.removeEvent(eventName, eventHandler);
}
function removeAttribute(node, propKey, propValue) {
if (isWeexV2) {
return removeAttribute$1(node, propKey);
}
if (propKey == ID) {

@@ -371,3 +703,7 @@ nodeMaps[propValue] = null;

}
function setAttribute(node, propKey, propValue) {
function setAttribute(node, propKey, propValue, isSvg) {
if (isWeexV2) {
return setAttribute$1(node, propKey, propValue, isSvg);
}
if (propKey == ID) {

@@ -387,5 +723,9 @@ nodeMaps[propValue] = node;

function setStyle(node, style) {
if (isWeexV2) {
return setStyle$1(node, style, true);
}
for (var prop in style) {
// Translate `rpx` to weex `px`
style[prop] = lib.convertUnit(style[prop], prop);
style[prop] = convertUnit(style[prop], prop);
}

@@ -397,13 +737,13 @@

// Turn off batched updates
document.open(); // Set `rpx` unit converter
weexDocument.open(); // Set `rpx` unit converter
lib.setRpx(1);
setRpx(1);
}
function afterRender() {
if (document.listener && document.listener.createFinish) {
document.listener.createFinish();
if (weexDocument.listener && weexDocument.listener.createFinish) {
weexDocument.listener.createFinish();
} // Turn on batched updates
document.close();
weexDocument.close();
}

@@ -410,0 +750,0 @@

@@ -1,2 +0,2 @@

var DriverWeex=function(n){var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function r(n,t,r){return n(r={path:t,exports:{},require:function(){return function(){throw Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}()}},r.exports),r.exports}var o=r((function(n,r){function o(n){return"undefined"===n}r.t=!0,r.isQuickApp=r.isWeChatMiniProgram=r.isByteDanceMicroApp=r.isMiniApp=r.isKraken=r.isWeex=r.isNode=r.isWeb=void 0;var e=!o(typeof window)&&"onload"in window;r.isWeb=e;var u=!o(typeof process)&&!(!process.versions||!process.versions.node);r.isNode=u;var i=!o(typeof WXEnvironment)&&"Web"!==WXEnvironment.platform;r.isWeex=i;var f=!o(typeof __kraken__);r.isKraken=f;var c=!o(typeof my)&&null!==my&&!o(typeof my.alert);r.isMiniApp=c;var a=!o(typeof tt)&&null!==tt&&!o(typeof tt)&&!o(tt.showToast);r.isByteDanceMicroApp=a;var l=!(a||o(typeof wx)||null===wx||o(typeof wx.login)&&o(typeof wx.miniProgram));r.isWeChatMiniProgram=l;var v=!o(typeof t)&&null!==t&&!o(typeof t.callNative)&&!i;r.isQuickApp=v})),e=r((function(n,t){t.t=!0,t.isRpx=l,t.calcRpx=v,t.getRpx=p,t.setRpx=d,t.getViewportWidth=y,t.setViewportWidth=w,t.setDecimalPixelTransformer=function(n){c=n},t.setUnitPrecision=function(n){f=n},t.cached=s,t.setTargetPlatform=_,t.convertUnit=void 0;var r,e,u=/"[^"]+"|'[^']+'|url\([^\)]+\)|(\d*\.?\d+)rpx/g,i=o.isWeb?"web":o.isWeex?"weex":"",f=4,c=function(n,t){return t?parseFloat(n)*p()+"px":n},a=function(n,t){return t?(r=parseFloat(n)/(y()/100),10*Math.round(Math.floor(r*(o=Math.pow(10,f+1)))/10)/o+"vw"):n;var r,o};function l(n){return"string"==typeof n&&u.test(n)}function v(n){return"web"===i?n.replace(u,a):"weex"===i?n.replace(u,c):n}function p(){return r}function d(n){r=n}function y(){return e}function w(n){e=n}function s(n){var t=new Map;return function(){var r=arguments.length<=0?void 0:arguments[0];return t.has(r)||t.set(r,n.apply(void 0,arguments)),t.get(r)}}function _(n){i=n}void 0===p()&&d(1),void 0===y()&&w(750);var x=s((function(n,t,r){return r&&_(r),l(n)?v(n):n}));t.convertUnit=x})),u="id",i="text",f=/^on[A-Z]/,c=/^aria-/,a=/\-(\w)/;function l(n){var t=n.children.map((function(n){return 8===n.nodeType?n.value:""})).join("");n.setAttr("value",t)}var v={},p="object"==typeof __weex_document__?__weex_document__:"object"==typeof p?p:null;function d(n){return p.createComment(n)}function y(n,t){t.appendChild(n),t.type===i&&l(t)}function w(n,t){t=t||n.parentNode;var r=n.attr&&n.attr.id;null!=r&&(v[r]=null),t.removeChild(n),t.type===i&&l(t)}function s(n,t,r){(r=r||t.parentNode).insertAfter(n,t),r.type===i&&l(r)}function _(n,t,r){(r=r||t.parentNode).insertBefore(n,t),r.type===i&&l(r)}function x(n,t,r,o){return n.addEvent(t,r,o[t+"EventParams"])}function b(n,t,r){return t==u&&(v[r]=n),c.test(t)&&(t=t.replace(a,(function(n,t){return t.toUpperCase()}))),n.setAttr(t,r,!1)}return n.addEventListener=x,n.afterRender=function(){p.listener&&p.listener.createFinish&&p.listener.createFinish(),p.close()},n.appendChild=y,n.beforeRender=function(){p.open(),e.setRpx(1)},n.createBody=function(n,t){if(p.body)return p.body;var r=p.documentElement,o=p.createBody(n,t);return r.appendChild(o),o},n.createComment=d,n.createElement=function(n,t){void 0===t&&(t={});var r={},o=t.style;if(o)for(var u in o)r[u]=e.convertUnit(o[u],u);var i=p.createElement(n,{style:r});for(var c in t){var a=t[c];if("children"!==c&&null!=a){if("style"===c)continue;f.test(c)?x(i,c.slice(2).toLowerCase(),a,t):b(i,c,a)}}return i},n.createEmpty=function(){return d("")},n.createText=function(n){return d(n)},n.getElementById=function(n){return v[n]},n.insertAfter=s,n.insertBefore=_,n.removeAttribute=function(n,t,r){return t==u&&(v[r]=null),n.setAttr(t,void 0,!1)},n.removeChild=w,n.removeEventListener=function(n,t,r){return n.removeEvent(t,r)},n.replaceChild=function(n,t,r){var o=t.previousSibling,e=t.nextSibling;w(t,r=r||t.parentNode),o?s(n,o,r):e?_(n,e,r):y(n,r)},n.setAttribute=b,n.setStyle=function(n,t){for(var r in t)t[r]=e.convertUnit(t[r],r);n.setStyles(t)},n.updateText=function(n,t){n.value=t,l(n.parentNode)},Object.defineProperty(n,"t",{value:!0}),n}({});
var DriverWeex=function(n){function t(n){return n&&n.t&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function r(n,t,r){return n(r={path:t,exports:{},require:function(){return function(){throw Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}()}},r.exports),r.exports}function e(n){if(n.t)return n;var t=Object.defineProperty({},"t",{value:!0});return Object.keys(n).forEach((function(r){var e=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,e.get?e:{enumerable:!0,get:function(){return n[r]}})})),t}var u,i,o=t(r((function(n){n.exports=function(n,t,r){return t in n?Object.defineProperty(n,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[t]=r,n},n.exports.default=n.exports,n.exports.t=!0}))),f="undefined"!=typeof window&&"onload"in window,c="undefined"!=typeof process&&!(!process.versions||!process.versions.node),a="undefined"!=typeof WXEnvironment&&"Web"!==WXEnvironment.platform,l="undefined"!=typeof __kraken__,d="undefined"!=typeof my&&null!==my&&void 0!==my.alert,s="undefined"!=typeof tt&&null!==tt&&void 0!==tt.showToast,v="undefined"!=typeof swan&&null!==swan&&void 0!==swan.showToast,p="undefined"!=typeof ks&&null!==ks&&void 0!==ks.showToast,_=!s&&"undefined"!=typeof wx&&null!==wx&&(void 0!==wx.request||void 0!==wx.miniProgram),m="undefined"!=typeof global&&null!==global&&void 0!==global.callNative&&!a,y=e({__proto__:null,isWeb:f,isNode:c,isWeex:a,isKraken:l,isMiniApp:d,isByteDanceMicroApp:s,isBaiduSmartProgram:v,isKuaiShouMiniProgram:p,isWeChatMiniProgram:_,isQuickApp:m,default:{isWeb:f,isNode:c,isWeex:a,isKraken:l,isMiniApp:d,isByteDanceMicroApp:s,isBaiduSmartProgram:v,isKuaiShouMiniProgram:p,isWeChatMiniProgram:_,isQuickApp:m}}),w=r((function(n,t){t.t=!0,Object.keys(y).forEach((function(n){"default"!==n&&"__esModule"!==n&&(n in t&&t[n]===y[n]||(t[n]=y[n]))}))})),b=/"[^"]+"|'[^']+'|url\([^\)]+\)|(\d*\.?\d+)rpx/g,g=w.isWeb?"web":w.isWeex?"weex":"",h=function(n,t){return t?parseFloat(n)*j()+"px":n},x=function(n,t){return t?(r=parseFloat(n)/(k()/100),10*Math.round(Math.floor(r*(e=Math.pow(10,4+1)))/10)/e+"vw"):n;var r,e};void 0===j()&&W(1),void 0===k()&&(i=750);var M=function(){function n(){o(this,"__store",{})}var t=n.prototype;return t.set=function(n,t){this.u[n+"_"+typeof n]=t},t.get=function(n){return this.u[n+"_"+typeof n]},t.has=function(n){return Object.prototype.hasOwnProperty.call(this.u,n+"_"+typeof n)},n}();function j(){return u}function W(n){u=n}function k(){return i}function O(n){var t=new M;return function(){var r=arguments.length<=0?void 0:arguments[0];return t.has(r)||t.set(r,n.apply(void 0,arguments)),t.get(r)}}var A=O((function(n,t,r){return r&&function(n){g=n}(r),"string"==typeof(e=n)&&b.test(e)?function(n){return"web"===g?n.replace(b,x):"weex"===g?n.replace(b,h):n}(n):n;var e})),P=/opa|ntw|ne[ch]|ex(?:s|g|n|p|$)|^ord|zoo|grid|orp|ows|mnc|^columns$|bs|erim|onit/i,S=/^on[A-Z]/,B="dangerouslySetInnerHTML",D="__html",E="className",K="class",N="http://www.w3.org/2000/svg",q=!1;O((function(n){return n.replace(/-([a-z])/gi,(function(n,t){return t.toUpperCase()}))}));var z=O((function(n){return!P.test(n)})),C=O((function(n){return S.test(n)}));function F(n,t){return t.appendChild(n)}function Q(n,t,r){(r=r||t.parentNode).insertBefore(n,t)}function X(n,t,r){return n.addEventListener(t,r)}function Z(n,t,r,e){if(t===B)return n.innerHTML!==r[D]&&(n.innerHTML=r[D]),void(n.i=!0);if(t===E&&(t=K),!e&&t in n)try{n[t]=r}catch(e){n.setAttribute(t,r)}else n.setAttribute(t,r)}function $(n,t,r){for(var e in t){var u=t[e],i=void 0;i="number"==typeof u&&z(e)?r?A(i=u+"rpx"):u+"px":A(u),"-"===e[0]&&"-"===e[1]?n.style.setProperty(e,i):n.style[e]=i}}var H="object"==typeof __weex_v2__,I="id",L="text",T=/^on[A-Z]/,G=/^aria-/,J=/\-(\w)/;function R(n){var t=n.children.map((function(n){return 8===n.nodeType?n.value:""})).join("");n.setAttr("value",t)}var U={},V="object"==typeof __weex_document__?__weex_document__:"object"==typeof document?document:null;function Y(n){return V.createComment(n)}function nn(n,t){if(H)return F(n,t);t.appendChild(n),t.type===L&&R(t)}function tn(n,t){if(H)return function(n,t){(t=t||n.parentNode)&&t.removeChild(n)}(n,t);t=t||n.parentNode;var r=n.attr&&n.attr.id;null!=r&&(U[r]=null),t.removeChild(n),t.type===L&&R(t)}function rn(n,t,r){if(H)return function(n,t,r){r=r||t.parentNode;var e=t.nextSibling;e?e!==n&&Q(n,e,r):F(n,r)}(n,t,r);(r=r||t.parentNode).insertAfter(n,t),r.type===L&&R(r)}function en(n,t,r){if(H)return Q(n,t,r);(r=r||t.parentNode).insertBefore(n,t),r.type===L&&R(r)}function un(n,t,r,e){return H?X(n,t,r):n.addEvent(t,r,e[t+"EventParams"])}function on(n,t,r,e){return H?Z(n,t,r,e):(t==I&&(U[r]=n),G.test(t)&&(t=t.replace(J,(function(n,t){return t.toUpperCase()}))),n.setAttr(t,r,!1))}return n.addEventListener=un,n.afterRender=function(){V.listener&&V.listener.createFinish&&V.listener.createFinish(),V.close()},n.appendChild=nn,n.beforeRender=function(){V.open(),W(1)},n.createBody=function(n,t){if(H)return document.body;if(V.body)return V.body;var r=V.documentElement,e=V.createBody(n,t);return r.appendChild(e),e},n.createComment=Y,n.createElement=function(n,t,r){if(H)return function(n,t,r,e){var u,i=r._parent;for(var o in u=(q="svg"===n||i&&i.namespaceURI===N)?document.createElementNS(N,n):document.createElement(n),t){var f=t[o];"children"!==o&&null!=f&&("style"===o?$(u,f,e):C(o)?X(u,o.slice(2).toLowerCase(),f):Z(u,o,f,q))}return u}(n,t,r,!0);var e={},u=(t=t||{}).style;if(u)for(var i in u)e[i]=A(u[i],i);var o=V.createElement(n,{style:e});for(var f in t){var c=t[f];if("children"!==f&&null!=c){if("style"===f)continue;T.test(f)?un(o,f.slice(2).toLowerCase(),c,t):on(o,f,c)}}return o},n.createEmpty=function(){return H?document.createComment(""):Y("")},n.createText=function(n){return H?function(n){return document.createTextNode(n)}(n):Y(n)},n.getElementById=function(n){return H?document.getElementById(n):U[n]},n.insertAfter=rn,n.insertBefore=en,n.removeAttribute=function(n,t,r){return H?function(n,t){if(t===B)return n.innerHTML=null;if(t===E&&(t=K),t in n)try{n[t]=null}catch(n){}n.removeAttribute(t)}(n,t):(t==I&&(U[r]=null),n.setAttr(t,void 0,!1))},n.removeChild=tn,n.removeEventListener=function(n,t,r){return H?function(n,t,r){return n.removeEventListener(t,r)}(n,t,r):n.removeEvent(t,r)},n.replaceChild=function(n,t,r){if(H)return function(n,t,r){(r=r||t.parentNode).replaceChild(n,t)}(n,t,r);var e=t.previousSibling,u=t.nextSibling;tn(t,r=r||t.parentNode),e?rn(n,e,r):u?en(n,u,r):nn(n,r)},n.setAttribute=on,n.setStyle=function(n,t){if(H)return $(n,t,!0);for(var r in t)t[r]=A(t[r],r);n.setStyles(t)},n.updateText=function(n,t){if(H)return function(n,t){n.textContent=t}(n,t);n.value=t,R(n.parentNode)},Object.defineProperty(n,"t",{value:!0}),n}({});
//# sourceMappingURL=driver-weex.min.js.map

@@ -6,3 +6,5 @@ (function (global, factory) {

}(this, (function (exports) {
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
function getDefaultExportFromCjs (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}

@@ -19,2 +21,17 @@ function createCommonjsModule(fn, basedir, module) {

function getAugmentedNamespace(n) {
if (n.__esModule) return n;
var a = Object.defineProperty({}, '__esModule', {value: true});
Object.keys(n).forEach(function (k) {
var d = Object.getOwnPropertyDescriptor(n, k);
Object.defineProperty(a, k, d.get ? d : {
enumerable: true,
get: function () {
return n[k];
}
});
});
return a;
}
function commonjsRequire () {

@@ -24,187 +41,449 @@ throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');

var lib$1 = createCommonjsModule(function (module, exports) {
var defineProperty = createCommonjsModule(function (module) {
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;
}
exports.__esModule = true;
exports.isQuickApp = exports.isWeChatMiniProgram = exports.isByteDanceMicroApp = exports.isMiniApp = exports.isKraken = exports.isWeex = exports.isNode = exports.isWeb = void 0;
function isUndef(type) {
return type === 'undefined';
return obj;
}
var isWeb = !isUndef(typeof window) && 'onload' in window;
exports.isWeb = isWeb;
var isNode = !isUndef(typeof process) && !!(process.versions && process.versions.node);
exports.isNode = isNode;
var isWeex = !isUndef(typeof WXEnvironment) && WXEnvironment.platform !== 'Web';
exports.isWeex = isWeex;
var isKraken = !isUndef(typeof __kraken__);
exports.isKraken = isKraken;
var isMiniApp = !isUndef(typeof my) && my !== null && !isUndef(typeof my.alert);
exports.isMiniApp = isMiniApp;
var isByteDanceMicroApp = !isUndef(typeof tt) && tt !== null && !isUndef(typeof tt) && !isUndef(tt.showToast); // In wechat mini program, wx.login is a function
// In wechat mini propgram webview, there is no wx.login, but exist wx.miniProgram
// In bytedance maicro app, there is wx variable.
exports.isByteDanceMicroApp = isByteDanceMicroApp;
var isWeChatMiniProgram = !isByteDanceMicroApp && !isUndef(typeof wx) && wx !== null && (!isUndef(typeof wx.login) || !isUndef(typeof wx.miniProgram));
exports.isWeChatMiniProgram = isWeChatMiniProgram;
var isQuickApp = !isUndef(typeof commonjsGlobal) && commonjsGlobal !== null && !isUndef(typeof commonjsGlobal.callNative) && !isWeex;
exports.isQuickApp = isQuickApp;
module.exports = _defineProperty;
module.exports["default"] = module.exports, module.exports.__esModule = true;
});
var _defineProperty = /*@__PURE__*/getDefaultExportFromCjs(defineProperty);
var isWeb = typeof window !== 'undefined' && 'onload' in window;
var isNode = typeof process !== 'undefined' && !!(process.versions && process.versions.node);
var isWeex = typeof WXEnvironment !== 'undefined' && WXEnvironment.platform !== 'Web';
var isKraken = typeof __kraken__ !== 'undefined';
var isMiniApp = typeof my !== 'undefined' && my !== null && typeof my.alert !== 'undefined';
var isByteDanceMicroApp = typeof tt !== 'undefined' && tt !== null && typeof tt.showToast !== 'undefined';
var isBaiduSmartProgram = typeof swan !== 'undefined' && swan !== null && typeof swan.showToast !== 'undefined';
var isKuaiShouMiniProgram = typeof ks !== 'undefined' && ks !== null && typeof ks.showToast !== 'undefined'; // In wechat mini program, wx.login is a function
// In wechat mini propgram webview, there is no wx.login, but exist wx.miniProgram
// In bytedance maicro app, there is wx variable.
var isWeChatMiniProgram = !isByteDanceMicroApp && typeof wx !== 'undefined' && wx !== null && (typeof wx.request !== 'undefined' || typeof wx.miniProgram !== 'undefined');
var isQuickApp = typeof global !== 'undefined' && global !== null && typeof global.callNative !== 'undefined' && !isWeex;
var index = {
isWeb: isWeb,
isNode: isNode,
isWeex: isWeex,
isKraken: isKraken,
isMiniApp: isMiniApp,
isByteDanceMicroApp: isByteDanceMicroApp,
isBaiduSmartProgram: isBaiduSmartProgram,
isKuaiShouMiniProgram: isKuaiShouMiniProgram,
isWeChatMiniProgram: isWeChatMiniProgram,
isQuickApp: isQuickApp
};
var es = {
__proto__: null,
isWeb: isWeb,
isNode: isNode,
isWeex: isWeex,
isKraken: isKraken,
isMiniApp: isMiniApp,
isByteDanceMicroApp: isByteDanceMicroApp,
isBaiduSmartProgram: isBaiduSmartProgram,
isKuaiShouMiniProgram: isKuaiShouMiniProgram,
isWeChatMiniProgram: isWeChatMiniProgram,
isQuickApp: isQuickApp,
'default': index
};
var _env = /*@__PURE__*/getAugmentedNamespace(es);
var lib = createCommonjsModule(function (module, exports) {
exports.__esModule = true;
exports.isRpx = isRpx;
exports.calcRpx = calcRpx;
exports.getRpx = getRpx;
exports.setRpx = setRpx;
exports.getViewportWidth = getViewportWidth;
exports.setViewportWidth = setViewportWidth;
exports.setDecimalPixelTransformer = setDecimalPixelTransformer;
exports.setUnitPrecision = setUnitPrecision;
exports.cached = cached;
exports.setTargetPlatform = setTargetPlatform;
exports.convertUnit = void 0;
var RPX_REG = /"[^"]+"|'[^']+'|url\([^\)]+\)|(\d*\.?\d+)rpx/g;
Object.keys(_env).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _env[key]) return;
exports[key] = _env[key];
});
});
var __rpx_coefficient__;
var RPX_REG = /"[^"]+"|'[^']+'|url\([^\)]+\)|(\d*\.?\d+)rpx/g;
var __viewport_width__; // convertUnit method targetPlatform
var __rpx_coefficient__;
var __viewport_width__; // convertUnit method targetPlatform
var targetPlatform = lib$1.isWeb ? 'web' : lib$1.isWeex ? 'weex' : ''; // Init toFixed method
var unitPrecision = 4;
var targetPlatform = lib.isWeb ? 'web' : lib.isWeex ? 'weex' : ''; // Init toFixed method
var toFixed = function toFixed(number, precision) {
var multiplier = Math.pow(10, precision + 1);
var wholeNumber = Math.floor(number * multiplier);
return Math.round(wholeNumber / 10) * 10 / multiplier;
}; // Dedault decimal px transformer.
var unitPrecision = 4;
var toFixed = function toFixed(number, precision) {
var multiplier = Math.pow(10, precision + 1);
var wholeNumber = Math.floor(number * multiplier);
return Math.round(wholeNumber / 10) * 10 / multiplier;
}; // Dedault decimal px transformer.
var decimalPixelTransformer = function decimalPixelTransformer(rpx, $1) {
return $1 ? parseFloat(rpx) * getRpx() + 'px' : rpx;
}; // Default decimal vw transformer.
var decimalPixelTransformer = function decimalPixelTransformer(rpx, $1) {
return $1 ? parseFloat(rpx) * getRpx() + 'px' : rpx;
}; // Default decimal vw transformer.
var decimalVWTransformer = function decimalVWTransformer(rpx, $1) {
return $1 ? toFixed(parseFloat(rpx) / (getViewportWidth() / 100), unitPrecision) + 'vw' : rpx;
}; // Default 1 rpx to 1 px
var decimalVWTransformer = function decimalVWTransformer(rpx, $1) {
return $1 ? toFixed(parseFloat(rpx) / (getViewportWidth() / 100), unitPrecision) + 'vw' : rpx;
}; // Default 1 rpx to 1 px
if (getRpx() === undefined) {
setRpx(1);
} // Viewport width, default to 750.
if (getRpx() === undefined) {
setRpx(1);
} // Viewport width, default to 750.
if (getViewportWidth() === undefined) {
setViewportWidth(750);
if (getViewportWidth() === undefined) {
setViewportWidth(750);
}
var CustomMap = /*#__PURE__*/function () {
function CustomMap() {
_defineProperty(this, "__store", {});
}
/**
* Is string contains rpx
* note: rpx is an alias to rpx
* @param {String} str
* @returns {Boolean}
*/
var _proto = CustomMap.prototype;
function isRpx(str) {
return typeof str === 'string' && RPX_REG.test(str);
_proto.set = function set(key, value) {
this.__store[key + "_" + typeof key] = value;
};
_proto.get = function get(key) {
return this.__store[key + "_" + typeof key];
};
_proto.has = function has(key) {
return Object.prototype.hasOwnProperty.call(this.__store, key + "_" + typeof key);
};
return CustomMap;
}();
/**
* Is string contains rpx
* note: rpx is an alias to rpx
* @param {String} str
* @returns {Boolean}
*/
function isRpx(str) {
return typeof str === 'string' && RPX_REG.test(str);
}
/**
* Calculate rpx
* @param {String} str
* @returns {String}
*/
function calcRpx(str) {
if (targetPlatform === 'web') {
// In Web convert rpx to 'vw', same as driver-dom and driver-universal
// '375rpx' => '50vw'
return str.replace(RPX_REG, decimalVWTransformer);
} else if (targetPlatform === 'weex') {
// In Weex convert rpx to 'px'
// '375rpx' => 375 * px
return str.replace(RPX_REG, decimalPixelTransformer);
} else {
// Other platform return original value, like Mini-App and WX Mini-Program ...
// '375rpx' => '375rpx'
return str;
}
/**
* Calculate rpx
* @param {String} str
* @returns {String}
*/
}
function getRpx() {
return __rpx_coefficient__;
}
function setRpx(rpx) {
__rpx_coefficient__ = rpx;
}
function getViewportWidth() {
return __viewport_width__;
}
function setViewportWidth(viewport) {
__viewport_width__ = viewport;
}
/**
* Create a cached version of a pure function.
* Use the first params as cache key.
*/
function cached(fn) {
var cache = new CustomMap();
return function cachedFn() {
var key = arguments.length <= 0 ? undefined : arguments[0];
if (!cache.has(key)) cache.set(key, fn.apply(void 0, arguments));
return cache.get(key);
};
}
function setTargetPlatform(platform) {
targetPlatform = platform;
}
/**
* Convert rpx.
* @param value
* @param prop
* @param platform
* @return {String} Transformed value.
*/
function calcRpx(str) {
if (targetPlatform === 'web') {
// In Web convert rpx to 'vw', same as driver-dom and driver-universal
// '375rpx' => '50vw'
return str.replace(RPX_REG, decimalVWTransformer);
} else if (targetPlatform === 'weex') {
// In Weex convert rpx to 'px'
// '375rpx' => 375 * px
return str.replace(RPX_REG, decimalPixelTransformer);
var convertUnit = cached(function (value, prop, platform) {
if (platform) {
setTargetPlatform(platform);
}
return isRpx(value) ? calcRpx(value) : value;
});
/**
* Driver for Web DOM
**/
// fontWeight -> ntw
// lineHeight|lineClamp -> ne[ch]
// flex|flexGrow|flexPositive|flexShrink|flexNegative|boxFlex|boxFlexGroup|zIndex -> ex(?:s|g|n|p|$)
// order -> ^ord
// zoom -> zoo
// gridArea|gridRow|gridRowEnd|gridRowSpan|gridRowStart|gridColumn|gridColumnEnd|gridColumnSpan|gridColumnStart -> grid
// columnCount -> mnc
// tabSize -> bs
// orphans -> orp
// windows -> ows
// animationIterationCount -> onit
// borderImageOutset|borderImageSlice|borderImageWidth -> erim
var NON_DIMENSIONAL_REG = /opa|ntw|ne[ch]|ex(?:s|g|n|p|$)|^ord|zoo|grid|orp|ows|mnc|^columns$|bs|erim|onit/i;
var EVENT_PREFIX_REG = /^on[A-Z]/;
var DANGEROUSLY_SET_INNER_HTML = 'dangerouslySetInnerHTML';
var HTML = '__html';
var INNER_HTML = 'innerHTML';
var CLASS_NAME = 'className';
var CLASS = 'class';
var STYLE$1 = 'style';
var CHILDREN$1 = 'children';
var TEXT_CONTENT_ATTR = 'textContent';
var CREATE_ELEMENT = 'createElement';
var CREATE_COMMENT = 'createComment';
var CREATE_TEXT_NODE = 'createTextNode';
var SET_ATTRIBUTE = 'setAttribute';
var REMOVE_ATTRIBUTE = 'removeAttribute';
var SVG_NS = 'http://www.w3.org/2000/svg';
var EMPTY$1 = '';
var WITH_INNERHTML = '__h';
var isSVGMode = false;
/**
* Camelize CSS property.
* Vendor prefixes should begin with a capital letter.
* For example:
* background-color -> backgroundColor
* -webkit-transition -> webkitTransition
*/
cached(function (name) {
return name.replace(/-([a-z])/gi, function (s, g) {
return g.toUpperCase();
});
});
var isDimensionalProp = cached(function (prop) {
return !NON_DIMENSIONAL_REG.test(prop);
});
var isEventProp = cached(function (prop) {
return EVENT_PREFIX_REG.test(prop);
});
function createBody$1() {
return document.body;
}
function createEmpty$1(component) {
component._parent;
var node;
{
node = document[CREATE_COMMENT](EMPTY$1);
}
return node;
}
function createText$1(text, component) {
component._parent;
var node;
{
node = document[CREATE_TEXT_NODE](text);
}
return node;
}
function updateText$1(node, text) {
node[TEXT_CONTENT_ATTR] = text;
}
/**
* @param {string} type node type
* @param {object} props elemement properties
* @param {object} component component instance
* @param {boolean} __shouldConvertUnitlessToRpx should add unit when missing
*/
function createElement$1(type, props, component, __shouldConvertUnitlessToRpx) {
var parent = component._parent;
isSVGMode = type === 'svg' || parent && parent.namespaceURI === SVG_NS;
var node;
function createNode() {
if (isSVGMode) {
node = document.createElementNS(SVG_NS, type);
} else {
// Other platform return original value, like Mini-App and WX Mini-Program ...
// '375rpx' => '375rpx'
return str;
node = document[CREATE_ELEMENT](type);
}
}
function getRpx() {
return __rpx_coefficient__;
{
createNode();
}
function setRpx(rpx) {
__rpx_coefficient__ = rpx;
for (var prop in props) {
var value = props[prop];
if (prop === CHILDREN$1) continue;
if (value != null) {
if (prop === STYLE$1) {
setStyle$1(node, value, __shouldConvertUnitlessToRpx);
} else if (isEventProp(prop)) {
addEventListener$1(node, prop.slice(2).toLowerCase(), value);
} else {
setAttribute$1(node, prop, value, isSVGMode);
}
}
}
function getViewportWidth() {
return __viewport_width__;
return node;
}
function appendChild$1(node, parent) {
{
return parent.appendChild(node);
}
}
function removeChild$1(node, parent) {
parent = parent || node.parentNode; // Maybe has been removed when remove child
function setViewportWidth(viewport) {
__viewport_width__ = viewport;
if (parent) {
parent.removeChild(node);
}
/**
* Set a function to transform unit of pixel,
* default to passthrough.
* @param {Function} transformer function
*/
}
function replaceChild$1(newChild, oldChild, parent) {
parent = parent || oldChild.parentNode;
parent.replaceChild(newChild, oldChild);
}
function insertAfter$1(node, after, parent) {
parent = parent || after.parentNode;
var nextSibling = after.nextSibling;
function setDecimalPixelTransformer(transformer) {
decimalPixelTransformer = transformer;
if (nextSibling) {
// Performance improve when node has been existed before nextSibling
if (nextSibling !== node) {
insertBefore$1(node, nextSibling, parent);
}
} else {
appendChild$1(node, parent);
}
/**
* Set unit precision.
* @param n {Number} Unit precision, default to 4.
*/
}
function insertBefore$1(node, before, parent) {
parent = parent || before.parentNode;
parent.insertBefore(node, before);
}
function addEventListener$1(node, eventName, eventHandler) {
return node.addEventListener(eventName, eventHandler);
}
function removeEventListener$1(node, eventName, eventHandler) {
return node.removeEventListener(eventName, eventHandler);
}
function removeAttribute$1(node, propKey) {
if (propKey === DANGEROUSLY_SET_INNER_HTML) {
return node[INNER_HTML] = null;
}
if (propKey === CLASS_NAME) propKey = CLASS;
function setUnitPrecision(n) {
unitPrecision = n;
if (propKey in node) {
try {
// Some node property is readonly when in strict mode
node[propKey] = null;
} catch (e) {}
}
/**
* Create a cached version of a pure function.
* Use the first params as cache key.
*/
node[REMOVE_ATTRIBUTE](propKey);
}
function setAttribute$1(node, propKey, propValue, isSvg) {
if (propKey === DANGEROUSLY_SET_INNER_HTML) {
// For reduce innerHTML operation to improve performance.
if (node[INNER_HTML] !== propValue[HTML]) {
node[INNER_HTML] = propValue[HTML];
}
function cached(fn) {
var cache = new Map();
return function cachedFn() {
var key = arguments.length <= 0 ? undefined : arguments[0];
if (!cache.has(key)) cache.set(key, fn.apply(void 0, arguments));
return cache.get(key);
};
node[WITH_INNERHTML] = true;
return;
}
function setTargetPlatform(platform) {
targetPlatform = platform;
if (propKey === CLASS_NAME) propKey = CLASS; // Prop for svg can only be set by attribute
if (!isSvg && propKey in node) {
try {
// Some node property is readonly when in strict mode
node[propKey] = propValue;
} catch (e) {
node[SET_ATTRIBUTE](propKey, propValue);
}
} else {
node[SET_ATTRIBUTE](propKey, propValue);
}
/**
* Convert rpx.
* @param value
* @param prop
* @param platform
* @return {String} Transformed value.
*/
}
/**
* @param {object} node target node
* @param {object} style target node style value
* @param {boolean} __shouldConvertUnitlessToRpx
*/
function setStyle$1(node, style, __shouldConvertUnitlessToRpx) {
for (var prop in style) {
var value = style[prop];
var convertedValue = void 0;
var convertUnit = cached(function (value, prop, platform) {
if (platform) {
setTargetPlatform(platform);
if (typeof value === 'number' && isDimensionalProp(prop)) {
if (__shouldConvertUnitlessToRpx) {
convertedValue = value + 'rpx'; // Transfrom rpx to vw
convertedValue = convertUnit(convertedValue);
} else {
convertedValue = value + 'px';
}
} else {
convertedValue = convertUnit(value);
} // Support CSS custom properties (variables) like { --main-color: "black" }
if (prop[0] === '-' && prop[1] === '-') {
// reference: https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration/setProperty.
// style.setProperty do not support Camel-Case style properties.
node.style.setProperty(prop, convertedValue);
} else {
node.style[prop] = convertedValue;
}
}
}
return isRpx(value) ? calcRpx(value) : value;
});
exports.convertUnit = convertUnit;
});
/* global __weex_v2__ */
var isWeexV2 = typeof __weex_v2__ === 'object';
var STYLE = 'style';

@@ -230,13 +509,21 @@ var ID = 'id';

var document = typeof __weex_document__ === 'object' ? __weex_document__ : typeof document === 'object' ? document : null;
var weexDocument = typeof __weex_document__ === 'object' ? __weex_document__ : typeof document === 'object' ? document : null;
function getElementById(id) {
if (isWeexV2) {
return document.getElementById(id);
}
return nodeMaps[id];
}
function createBody(type, props) {
if (document.body) {
return document.body;
if (isWeexV2) {
return createBody$1();
}
var documentElement = document.documentElement;
var body = document.createBody(type, props);
if (weexDocument.body) {
return weexDocument.body;
}
var documentElement = weexDocument.documentElement;
var body = weexDocument.createBody(type, props);
documentElement.appendChild(body);

@@ -246,21 +533,34 @@ return body;

function createComment(content) {
return document.createComment(content);
return weexDocument.createComment(content);
}
function createEmpty() {
function createEmpty(component) {
if (isWeexV2) {
return createEmpty$1(component);
}
return createComment(EMPTY);
}
function createText(text) {
// Use comment node type mock text node
function createText(text, component) {
if (isWeexV2) {
return createText$1(text, component);
} // Use comment node type mock text node
return createComment(text);
}
function updateText(node, text) {
if (isWeexV2) {
return updateText$1(node, text);
}
node.value = text;
updateWeexTextValue(node.parentNode);
}
function createElement(type, props) {
if (props === void 0) {
props = {};
function createElement(type, props, component) {
if (isWeexV2) {
return createElement$1(type, props, component, true);
}
var style = {};
props = props || {};
var originStyle = props.style;

@@ -270,7 +570,7 @@

for (var prop in originStyle) {
style[prop] = lib.convertUnit(originStyle[prop], prop);
style[prop] = convertUnit(originStyle[prop], prop);
}
}
var node = document.createElement(type, {
var node = weexDocument.createElement(type, {
style: style

@@ -302,2 +602,6 @@ });

function appendChild(node, parent) {
if (isWeexV2) {
return appendChild$1(node, parent);
}
parent.appendChild(node);

@@ -310,2 +614,6 @@

function removeChild(node, parent) {
if (isWeexV2) {
return removeChild$1(node, parent);
}
parent = parent || node.parentNode;

@@ -325,2 +633,6 @@ var id = node.attr && node.attr[ID];

function replaceChild(newChild, oldChild, parent) {
if (isWeexV2) {
return replaceChild$1(newChild, oldChild, parent);
}
parent = parent || oldChild.parentNode;

@@ -340,2 +652,6 @@ var previousSibling = oldChild.previousSibling;

function insertAfter(node, after, parent) {
if (isWeexV2) {
return insertAfter$1(node, after, parent);
}
parent = parent || after.parentNode;

@@ -349,2 +665,6 @@ parent.insertAfter(node, after);

function insertBefore(node, before, parent) {
if (isWeexV2) {
return insertBefore$1(node, before, parent);
}
parent = parent || before.parentNode;

@@ -358,3 +678,7 @@ parent.insertBefore(node, before);

function addEventListener(node, eventName, eventHandler, props) {
// https://github.com/apache/incubator-weex/blob/master/runtime/vdom/Element.js#L421
if (isWeexV2) {
return addEventListener$1(node, eventName, eventHandler);
} // https://github.com/apache/incubator-weex/blob/master/runtime/vdom/Element.js#L421
var params = props[eventName + 'EventParams'];

@@ -364,5 +688,13 @@ return node.addEvent(eventName, eventHandler, params);

function removeEventListener(node, eventName, eventHandler) {
if (isWeexV2) {
return removeEventListener$1(node, eventName, eventHandler);
}
return node.removeEvent(eventName, eventHandler);
}
function removeAttribute(node, propKey, propValue) {
if (isWeexV2) {
return removeAttribute$1(node, propKey);
}
if (propKey == ID) {

@@ -375,3 +707,7 @@ nodeMaps[propValue] = null;

}
function setAttribute(node, propKey, propValue) {
function setAttribute(node, propKey, propValue, isSvg) {
if (isWeexV2) {
return setAttribute$1(node, propKey, propValue, isSvg);
}
if (propKey == ID) {

@@ -391,5 +727,9 @@ nodeMaps[propValue] = node;

function setStyle(node, style) {
if (isWeexV2) {
return setStyle$1(node, style, true);
}
for (var prop in style) {
// Translate `rpx` to weex `px`
style[prop] = lib.convertUnit(style[prop], prop);
style[prop] = convertUnit(style[prop], prop);
}

@@ -401,13 +741,13 @@

// Turn off batched updates
document.open(); // Set `rpx` unit converter
weexDocument.open(); // Set `rpx` unit converter
lib.setRpx(1);
setRpx(1);
}
function afterRender() {
if (document.listener && document.listener.createFinish) {
document.listener.createFinish();
if (weexDocument.listener && weexDocument.listener.createFinish) {
weexDocument.listener.createFinish();
} // Turn on batched updates
document.close();
weexDocument.close();
}

@@ -414,0 +754,0 @@

import { setRpx, convertUnit } from 'style-unit';
import * as DriverDOM from 'driver-dom'; // Use driver-dom in Weex V2
/* global __weex_v2__ */
var isWeexV2 = typeof __weex_v2__ === 'object';
var STYLE = 'style';

@@ -22,13 +27,21 @@ var ID = 'id';

var document = typeof __weex_document__ === 'object' ? __weex_document__ : typeof document === 'object' ? document : null;
var weexDocument = typeof __weex_document__ === 'object' ? __weex_document__ : typeof document === 'object' ? document : null;
export function getElementById(id) {
if (isWeexV2) {
return document.getElementById(id);
}
return nodeMaps[id];
}
export function createBody(type, props) {
if (document.body) {
return document.body;
if (isWeexV2) {
return DriverDOM.createBody();
}
var documentElement = document.documentElement;
var body = document.createBody(type, props);
if (weexDocument.body) {
return weexDocument.body;
}
var documentElement = weexDocument.documentElement;
var body = weexDocument.createBody(type, props);
documentElement.appendChild(body);

@@ -38,21 +51,34 @@ return body;

export function createComment(content) {
return document.createComment(content);
return weexDocument.createComment(content);
}
export function createEmpty() {
export function createEmpty(component) {
if (isWeexV2) {
return DriverDOM.createEmpty(component);
}
return createComment(EMPTY);
}
export function createText(text) {
// Use comment node type mock text node
export function createText(text, component) {
if (isWeexV2) {
return DriverDOM.createText(text, component);
} // Use comment node type mock text node
return createComment(text);
}
export function updateText(node, text) {
if (isWeexV2) {
return DriverDOM.updateText(node, text);
}
node.value = text;
updateWeexTextValue(node.parentNode);
}
export function createElement(type, props) {
if (props === void 0) {
props = {};
export function createElement(type, props, component) {
if (isWeexV2) {
return DriverDOM.createElement(type, props, component, true);
}
var style = {};
props = props || {};
var originStyle = props.style;

@@ -66,3 +92,3 @@

var node = document.createElement(type, {
var node = weexDocument.createElement(type, {
style: style

@@ -94,2 +120,6 @@ });

export function appendChild(node, parent) {
if (isWeexV2) {
return DriverDOM.appendChild(node, parent);
}
parent.appendChild(node);

@@ -102,2 +132,6 @@

export function removeChild(node, parent) {
if (isWeexV2) {
return DriverDOM.removeChild(node, parent);
}
parent = parent || node.parentNode;

@@ -117,2 +151,6 @@ var id = node.attr && node.attr[ID];

export function replaceChild(newChild, oldChild, parent) {
if (isWeexV2) {
return DriverDOM.replaceChild(newChild, oldChild, parent);
}
parent = parent || oldChild.parentNode;

@@ -132,2 +170,6 @@ var previousSibling = oldChild.previousSibling;

export function insertAfter(node, after, parent) {
if (isWeexV2) {
return DriverDOM.insertAfter(node, after, parent);
}
parent = parent || after.parentNode;

@@ -141,2 +183,6 @@ parent.insertAfter(node, after);

export function insertBefore(node, before, parent) {
if (isWeexV2) {
return DriverDOM.insertBefore(node, before, parent);
}
parent = parent || before.parentNode;

@@ -150,3 +196,7 @@ parent.insertBefore(node, before);

export function addEventListener(node, eventName, eventHandler, props) {
// https://github.com/apache/incubator-weex/blob/master/runtime/vdom/Element.js#L421
if (isWeexV2) {
return DriverDOM.addEventListener(node, eventName, eventHandler);
} // https://github.com/apache/incubator-weex/blob/master/runtime/vdom/Element.js#L421
var params = props[eventName + 'EventParams'];

@@ -156,5 +206,13 @@ return node.addEvent(eventName, eventHandler, params);

export function removeEventListener(node, eventName, eventHandler) {
if (isWeexV2) {
return DriverDOM.removeEventListener(node, eventName, eventHandler);
}
return node.removeEvent(eventName, eventHandler);
}
export function removeAttribute(node, propKey, propValue) {
if (isWeexV2) {
return DriverDOM.removeAttribute(node, propKey);
}
if (propKey == ID) {

@@ -167,3 +225,7 @@ nodeMaps[propValue] = null;

}
export function setAttribute(node, propKey, propValue) {
export function setAttribute(node, propKey, propValue, isSvg) {
if (isWeexV2) {
return DriverDOM.setAttribute(node, propKey, propValue, isSvg);
}
if (propKey == ID) {

@@ -183,2 +245,6 @@ nodeMaps[propValue] = node;

export function setStyle(node, style) {
if (isWeexV2) {
return DriverDOM.setStyle(node, style, true);
}
for (var prop in style) {

@@ -193,3 +259,3 @@ // Translate `rpx` to weex `px`

// Turn off batched updates
document.open(); // Set `rpx` unit converter
weexDocument.open(); // Set `rpx` unit converter

@@ -199,8 +265,8 @@ setRpx(1);

export function afterRender() {
if (document.listener && document.listener.createFinish) {
document.listener.createFinish();
if (weexDocument.listener && weexDocument.listener.createFinish) {
weexDocument.listener.createFinish();
} // Turn on batched updates
document.close();
weexDocument.close();
}

@@ -26,2 +26,12 @@ "use strict";

var DriverDOM = _interopRequireWildcard(require("driver-dom"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
// Use driver-dom in Weex V2
/* global __weex_v2__ */
var isWeexV2 = typeof __weex_v2__ === 'object';
var STYLE = 'style';

@@ -47,5 +57,9 @@ var ID = 'id';

var document = typeof __weex_document__ === 'object' ? __weex_document__ : typeof document === 'object' ? document : null;
var weexDocument = typeof __weex_document__ === 'object' ? __weex_document__ : typeof document === 'object' ? document : null;
function getElementById(id) {
if (isWeexV2) {
return document.getElementById(id);
}
return nodeMaps[id];

@@ -55,8 +69,12 @@ }

function createBody(type, props) {
if (document.body) {
return document.body;
if (isWeexV2) {
return DriverDOM.createBody();
}
var documentElement = document.documentElement;
var body = document.createBody(type, props);
if (weexDocument.body) {
return weexDocument.body;
}
var documentElement = weexDocument.documentElement;
var body = weexDocument.createBody(type, props);
documentElement.appendChild(body);

@@ -67,11 +85,19 @@ return body;

function createComment(content) {
return document.createComment(content);
return weexDocument.createComment(content);
}
function createEmpty() {
function createEmpty(component) {
if (isWeexV2) {
return DriverDOM.createEmpty(component);
}
return createComment(EMPTY);
}
function createText(text) {
// Use comment node type mock text node
function createText(text, component) {
if (isWeexV2) {
return DriverDOM.createText(text, component);
} // Use comment node type mock text node
return createComment(text);

@@ -81,2 +107,6 @@ }

function updateText(node, text) {
if (isWeexV2) {
return DriverDOM.updateText(node, text);
}
node.value = text;

@@ -86,8 +116,9 @@ updateWeexTextValue(node.parentNode);

function createElement(type, props) {
if (props === void 0) {
props = {};
function createElement(type, props, component) {
if (isWeexV2) {
return DriverDOM.createElement(type, props, component, true);
}
var style = {};
props = props || {};
var originStyle = props.style;

@@ -101,3 +132,3 @@

var node = document.createElement(type, {
var node = weexDocument.createElement(type, {
style: style

@@ -130,2 +161,6 @@ });

function appendChild(node, parent) {
if (isWeexV2) {
return DriverDOM.appendChild(node, parent);
}
parent.appendChild(node);

@@ -139,2 +174,6 @@

function removeChild(node, parent) {
if (isWeexV2) {
return DriverDOM.removeChild(node, parent);
}
parent = parent || node.parentNode;

@@ -155,2 +194,6 @@ var id = node.attr && node.attr[ID];

function replaceChild(newChild, oldChild, parent) {
if (isWeexV2) {
return DriverDOM.replaceChild(newChild, oldChild, parent);
}
parent = parent || oldChild.parentNode;

@@ -171,2 +214,6 @@ var previousSibling = oldChild.previousSibling;

function insertAfter(node, after, parent) {
if (isWeexV2) {
return DriverDOM.insertAfter(node, after, parent);
}
parent = parent || after.parentNode;

@@ -181,2 +228,6 @@ parent.insertAfter(node, after);

function insertBefore(node, before, parent) {
if (isWeexV2) {
return DriverDOM.insertBefore(node, before, parent);
}
parent = parent || before.parentNode;

@@ -191,3 +242,7 @@ parent.insertBefore(node, before);

function addEventListener(node, eventName, eventHandler, props) {
// https://github.com/apache/incubator-weex/blob/master/runtime/vdom/Element.js#L421
if (isWeexV2) {
return DriverDOM.addEventListener(node, eventName, eventHandler);
} // https://github.com/apache/incubator-weex/blob/master/runtime/vdom/Element.js#L421
var params = props[eventName + 'EventParams'];

@@ -198,2 +253,6 @@ return node.addEvent(eventName, eventHandler, params);

function removeEventListener(node, eventName, eventHandler) {
if (isWeexV2) {
return DriverDOM.removeEventListener(node, eventName, eventHandler);
}
return node.removeEvent(eventName, eventHandler);

@@ -203,2 +262,6 @@ }

function removeAttribute(node, propKey, propValue) {
if (isWeexV2) {
return DriverDOM.removeAttribute(node, propKey);
}
if (propKey == ID) {

@@ -212,3 +275,7 @@ nodeMaps[propValue] = null;

function setAttribute(node, propKey, propValue) {
function setAttribute(node, propKey, propValue, isSvg) {
if (isWeexV2) {
return DriverDOM.setAttribute(node, propKey, propValue, isSvg);
}
if (propKey == ID) {

@@ -229,2 +296,6 @@ nodeMaps[propValue] = node;

function setStyle(node, style) {
if (isWeexV2) {
return DriverDOM.setStyle(node, style, true);
}
for (var prop in style) {

@@ -240,3 +311,3 @@ // Translate `rpx` to weex `px`

// Turn off batched updates
document.open(); // Set `rpx` unit converter
weexDocument.open(); // Set `rpx` unit converter

@@ -247,8 +318,8 @@ (0, _styleUnit.setRpx)(1);

function afterRender() {
if (document.listener && document.listener.createFinish) {
document.listener.createFinish();
if (weexDocument.listener && weexDocument.listener.createFinish) {
weexDocument.listener.createFinish();
} // Turn on batched updates
document.close();
weexDocument.close();
}
{
"name": "driver-weex",
"version": "2.0.2",
"version": "2.1.0",
"description": "Weex driver for Rax",

@@ -17,4 +17,5 @@ "license": "BSD-3-Clause",

"dependencies": {
"driver-dom": "^2.0.5",
"style-unit": "^3.0.0"
}
}
import { setRpx, convertUnit } from 'style-unit';
import * as DriverDOM from 'driver-dom';
// Use driver-dom in Weex V2
/* global __weex_v2__ */
const isWeexV2 = typeof __weex_v2__ === 'object';
const STYLE = 'style';

@@ -23,3 +28,3 @@ const ID = 'id';

/* global __weex_document__ */
const document = typeof __weex_document__ === 'object' ?
const weexDocument = typeof __weex_document__ === 'object' ?
__weex_document__ : typeof document === 'object' ?

@@ -29,2 +34,5 @@ document : null;

export function getElementById(id) {
if (isWeexV2) {
return document.getElementById(id);
}
return nodeMaps[id];

@@ -34,8 +42,11 @@ }

export function createBody(type, props) {
if (document.body) {
return document.body;
if (isWeexV2) {
return DriverDOM.createBody();
}
if (weexDocument.body) {
return weexDocument.body;
}
const documentElement = document.documentElement;
const body = document.createBody(type, props);
const documentElement = weexDocument.documentElement;
const body = weexDocument.createBody(type, props);
documentElement.appendChild(body);

@@ -47,10 +58,16 @@

export function createComment(content) {
return document.createComment(content);
return weexDocument.createComment(content);
}
export function createEmpty() {
export function createEmpty(component) {
if (isWeexV2) {
return DriverDOM.createEmpty(component);
}
return createComment(EMPTY);
}
export function createText(text) {
export function createText(text, component) {
if (isWeexV2) {
return DriverDOM.createText(text, component);
}
// Use comment node type mock text node

@@ -61,2 +78,5 @@ return createComment(text);

export function updateText(node, text) {
if (isWeexV2) {
return DriverDOM.updateText(node, text);
}
node.value = text;

@@ -66,4 +86,8 @@ updateWeexTextValue(node.parentNode);

export function createElement(type, props = {}) {
export function createElement(type, props, component) {
if (isWeexV2) {
return DriverDOM.createElement(type, props, component, true);
}
const style = {};
props = props || {};
const originStyle = props.style;

@@ -76,3 +100,3 @@ if (originStyle) {

const node = document.createElement(type, {
const node = weexDocument.createElement(type, {
style

@@ -102,2 +126,5 @@ });

export function appendChild(node, parent) {
if (isWeexV2) {
return DriverDOM.appendChild(node, parent);
}
parent.appendChild(node);

@@ -111,2 +138,5 @@

export function removeChild(node, parent) {
if (isWeexV2) {
return DriverDOM.removeChild(node, parent);
}
parent = parent || node.parentNode;

@@ -126,2 +156,5 @@ let id = node.attr && node.attr[ID];

export function replaceChild(newChild, oldChild, parent) {
if (isWeexV2) {
return DriverDOM.replaceChild(newChild, oldChild, parent);
}
parent = parent || oldChild.parentNode;

@@ -142,2 +175,5 @@ let previousSibling = oldChild.previousSibling;

export function insertAfter(node, after, parent) {
if (isWeexV2) {
return DriverDOM.insertAfter(node, after, parent);
}
parent = parent || after.parentNode;

@@ -152,2 +188,5 @@ parent.insertAfter(node, after);

export function insertBefore(node, before, parent) {
if (isWeexV2) {
return DriverDOM.insertBefore(node, before, parent);
}
parent = parent || before.parentNode;

@@ -162,2 +201,5 @@ parent.insertBefore(node, before);

export function addEventListener(node, eventName, eventHandler, props) {
if (isWeexV2) {
return DriverDOM.addEventListener(node, eventName, eventHandler);
}
// https://github.com/apache/incubator-weex/blob/master/runtime/vdom/Element.js#L421

@@ -169,2 +211,5 @@ let params = props[eventName + 'EventParams'];

export function removeEventListener(node, eventName, eventHandler) {
if (isWeexV2) {
return DriverDOM.removeEventListener(node, eventName, eventHandler);
}
return node.removeEvent(eventName, eventHandler);

@@ -174,2 +219,5 @@ }

export function removeAttribute(node, propKey, propValue) {
if (isWeexV2) {
return DriverDOM.removeAttribute(node, propKey);
}
if (propKey == ID) {

@@ -182,3 +230,6 @@ nodeMaps[propValue] = null;

export function setAttribute(node, propKey, propValue) {
export function setAttribute(node, propKey, propValue, isSvg) {
if (isWeexV2) {
return DriverDOM.setAttribute(node, propKey, propValue, isSvg);
}
if (propKey == ID) {

@@ -199,2 +250,5 @@ nodeMaps[propValue] = node;

export function setStyle(node, style) {
if (isWeexV2) {
return DriverDOM.setStyle(node, style, true);
}
for (let prop in style) {

@@ -209,3 +263,3 @@ // Translate `rpx` to weex `px`

// Turn off batched updates
document.open();
weexDocument.open();

@@ -217,8 +271,8 @@ // Set `rpx` unit converter

export function afterRender() {
if (document.listener && document.listener.createFinish) {
document.listener.createFinish();
if (weexDocument.listener && weexDocument.listener.createFinish) {
weexDocument.listener.createFinish();
}
// Turn on batched updates
document.close();
weexDocument.close();
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc