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.1 to 2.0.2-0

217

dist/driver-weex.js

@@ -1,38 +0,23 @@

(function () {
function unwrapExports (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
var DriverWeex = (function (exports) {
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
function createCommonjsModule(fn, basedir, module) {
return module = {
path: basedir,
exports: {},
require: function (path, base) {
return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
}
}, fn(module, module.exports), module.exports;
}
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
function commonjsRequire () {
throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
}
var index_min = createCommonjsModule(function (module, exports) {
function isUndef(e) {
return "undefined" === e;
}
Object.defineProperty(exports, "__esModule", {
value: !0
});
var isWeb = !isUndef(typeof window) && "onload" in window,
isNode = !isUndef(typeof process) && !(!process.versions || !process.versions.node),
isWeex = !isUndef(typeof callNative) || !isUndef(typeof WXEnvironment) && "Web" !== WXEnvironment.platform,
isMiniApp = !isUndef(typeof my) && !isUndef(my.navigateTo),
isWeChatMiniprogram = !isUndef(typeof wx) && !isUndef(wx.navigateTo);
exports.isMiniApp = isMiniApp, exports.isNode = isNode, exports.isWeChatMiniprogram = isWeChatMiniprogram, exports.isWeb = isWeb, exports.isWeex = isWeex;
});
unwrapExports(index_min);
var index_min_1 = index_min.isMiniApp;
var index_min_2 = index_min.isNode;
var index_min_3 = index_min.isWeChatMiniprogram;
var index_min_4 = index_min.isWeb;
var index_min_5 = index_min.isWeex;
var lib = createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.__esModule = true;
exports.isQuickApp = exports.isWeChatMiniProgram = exports.isByteDanceMicroApp = exports.isMiniApp = exports.isKraken = exports.isWeex = exports.isNode = exports.isWeb = void 0;

@@ -44,23 +29,20 @@ function isUndef(type) {

var isWeb = !isUndef(typeof window) && 'onload' in window;
exports.isWeb = isWeb;
var isNode = !isUndef(typeof process) && !!(process.versions && process.versions.node);
var isWeex = !isUndef(typeof callNative) || !isUndef(typeof WXEnvironment) && WXEnvironment.platform !== 'Web';
var isMiniApp = !isUndef(typeof my) && !isUndef(my.navigateTo);
var isWeChatMiniprogram = !isUndef(typeof wx) && !isUndef(wx.navigateTo);
exports.isMiniApp = isMiniApp;
exports.isNode = isNode;
exports.isWeChatMiniprogram = isWeChatMiniprogram;
exports.isWeb = isWeb;
var isWeex = !isUndef(typeof WXEnvironment) && WXEnvironment.platform !== 'Web';
exports.isWeex = isWeex;
});
unwrapExports(lib);
var lib_1 = lib.isMiniApp;
var lib_2 = lib.isNode;
var lib_3 = lib.isWeChatMiniprogram;
var lib_4 = lib.isWeb;
var lib_5 = lib.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.
var universalEnv = createCommonjsModule(function (module) {
{
module.exports = lib;
}
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;
});

@@ -78,10 +60,15 @@

exports.setDecimalPixelTransformer = setDecimalPixelTransformer;
exports.convertUnit = convertUnit;
var RPX_REG = /[-+]?\d*\.?\d+rpx/g;
var GLOBAL_RPX_COEFFICIENT = '__rpx_coefficient__';
var GLOBAL_VIEWPORT_WIDTH = '__viewport_width__';
var global = typeof window === 'object' ? window : typeof global === 'object' ? global : {}; // convertUnit method targetPlatform
exports.setUnitPrecision = setUnitPrecision;
exports.cached = cached;
exports.setTargetPlatform = setTargetPlatform;
exports.convertUnit = void 0;
var RPX_REG = /"[^"]+"|'[^']+'|url\([^\)]+\)|(\d*\.?\d+)rpx/g;
var targetPlatform = universalEnv.isWeb ? 'web' : universalEnv.isWeex ? 'weex' : ''; // Init toFixed method
var __rpx_coefficient__;
var __viewport_width__; // convertUnit method targetPlatform
var targetPlatform = lib.isWeb ? 'web' : lib.isWeex ? 'weex' : ''; // Init toFixed method
var unitPrecision = 4;

@@ -96,9 +83,9 @@

var decimalPixelTransformer = function decimalPixelTransformer(rpx) {
return parseFloat(rpx) * getRpx() + 'px';
var decimalPixelTransformer = function decimalPixelTransformer(rpx, $1) {
return $1 ? parseFloat(rpx) * getRpx() + 'px' : rpx;
}; // Default decimal vw transformer.
var decimalVWTransformer = function decimalVWTransformer(rpx) {
return toFixed(parseFloat(rpx) / (getViewportWidth() / 100), unitPrecision) + 'vw';
var decimalVWTransformer = function decimalVWTransformer(rpx, $1) {
return $1 ? toFixed(parseFloat(rpx) / (getViewportWidth() / 100), unitPrecision) + 'vw' : rpx;
}; // Default 1 rpx to 1 px

@@ -150,15 +137,15 @@

function getRpx() {
return global[GLOBAL_RPX_COEFFICIENT];
return __rpx_coefficient__;
}
function setRpx(rpx) {
global[GLOBAL_RPX_COEFFICIENT] = rpx;
__rpx_coefficient__ = rpx;
}
function getViewportWidth() {
return global[GLOBAL_VIEWPORT_WIDTH];
return __viewport_width__;
}
function setViewportWidth(viewport) {
global[GLOBAL_VIEWPORT_WIDTH] = viewport;
__viewport_width__ = viewport;
}

@@ -175,5 +162,30 @@ /**

}
/**
* Set unit precision.
* @param n {Number} Unit precision, default to 4.
*/
var cache = Object.create(null);
function setUnitPrecision(n) {
unitPrecision = n;
}
/**
* Create a cached version of a pure function.
* Use the first params as cache key.
*/
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);
};
}
function setTargetPlatform(platform) {
targetPlatform = platform;
}
/**
* Convert rpx.

@@ -186,28 +198,12 @@ * @param value

function convertUnit(value, prop, platform) {
var cacheKey = prop + "-" + value;
var hit = cache[cacheKey];
var convertUnit = cached(function (value, prop, platform) {
if (platform) {
cacheKey += "-" + platform;
targetPlatform = platform;
setTargetPlatform(platform);
}
if (hit) {
return hit;
} else {
value = value + '';
return cache[cacheKey] = isRpx(value) ? calcRpx(value) : value;
}
}
return isRpx(value) ? calcRpx(value) : value;
});
exports.convertUnit = convertUnit;
});
unwrapExports(lib$1);
var lib_1$1 = lib$1.isRpx;
var lib_2$1 = lib$1.calcRpx;
var lib_3$1 = lib$1.getRpx;
var lib_4$1 = lib$1.setRpx;
var lib_5$1 = lib$1.getViewportWidth;
var lib_6 = lib$1.setViewportWidth;
var lib_7 = lib$1.setDecimalPixelTransformer;
var lib_8 = lib$1.convertUnit;

@@ -272,3 +268,3 @@ var STYLE = 'style';

for (var prop in originStyle) {
style[prop] = lib_8(originStyle[prop], prop);
style[prop] = lib$1.convertUnit(originStyle[prop], prop);
}

@@ -387,3 +383,3 @@ }

// Translate `rpx` to weex `px`
style[prop] = lib_8(style[prop], prop);
style[prop] = lib$1.convertUnit(style[prop], prop);
}

@@ -397,3 +393,3 @@

lib_4$1(1);
lib$1.setRpx(1);
}

@@ -409,28 +405,27 @@ function afterRender() {

var DriverWeex = {
__proto__: null,
getElementById: getElementById,
createBody: createBody,
createComment: createComment,
createEmpty: createEmpty,
createText: createText,
updateText: updateText,
createElement: createElement,
appendChild: appendChild,
removeChild: removeChild,
replaceChild: replaceChild,
insertAfter: insertAfter,
insertBefore: insertBefore,
addEventListener: addEventListener,
removeEventListener: removeEventListener,
removeAttribute: removeAttribute,
setAttribute: setAttribute,
setStyle: setStyle,
beforeRender: beforeRender,
afterRender: afterRender
};
exports.addEventListener = addEventListener;
exports.afterRender = afterRender;
exports.appendChild = appendChild;
exports.beforeRender = beforeRender;
exports.createBody = createBody;
exports.createComment = createComment;
exports.createElement = createElement;
exports.createEmpty = createEmpty;
exports.createText = createText;
exports.getElementById = getElementById;
exports.insertAfter = insertAfter;
exports.insertBefore = insertBefore;
exports.removeAttribute = removeAttribute;
exports.removeChild = removeChild;
exports.removeEventListener = removeEventListener;
exports.replaceChild = replaceChild;
exports.setAttribute = setAttribute;
exports.setStyle = setStyle;
exports.updateText = updateText;
if (typeof module !== 'undefined') module.exports = DriverWeex;else self.DriverWeex = DriverWeex;
Object.defineProperty(exports, '__esModule', { value: true });
}());
return exports;
}({}));
//# sourceMappingURL=driver-weex.js.map

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

!function(){function n(n){return n&&n.n&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function e(n,e){return n(e={exports:{}},e.exports),e.exports}var t=e(function(n,e){function t(n){return"undefined"===n}Object.defineProperty(e,"n",{value:!0});var r=!t(typeof window)&&"onload"in window,o=!t(typeof process)&&!(!process.versions||!process.versions.node),u=!t(typeof callNative)||!t(typeof WXEnvironment)&&"Web"!==WXEnvironment.platform,i=!t(typeof my)&&!t(my.navigateTo),f=!t(typeof wx)&&!t(wx.navigateTo);e.isMiniApp=i,e.isNode=o,e.isWeChatMiniprogram=f,e.isWeb=r,e.isWeex=u});n(t);var r=e(function(n,e){function t(n){return"undefined"===n}Object.defineProperty(e,"n",{value:!0});var r=!t(typeof window)&&"onload"in window,o=!t(typeof process)&&!(!process.versions||!process.versions.node),u=!t(typeof callNative)||!t(typeof WXEnvironment)&&"Web"!==WXEnvironment.platform,i=!t(typeof my)&&!t(my.navigateTo),f=!t(typeof wx)&&!t(wx.navigateTo);e.isMiniApp=i,e.isNode=o,e.isWeChatMiniprogram=f,e.isWeb=r,e.isWeex=u});n(r);var _=e(function(n){n.exports=t}),r=e(function(n,e){e.n=!0,e.isRpx=a,e.calcRpx=d,e.getRpx=l,e.setRpx=v,e.getViewportWidth=p,e.setViewportWidth=s,e.setDecimalPixelTransformer=function(n){f=n},e.convertUnit=function(n,e,t){var r=e+"-"+n,e=y[r];t&&(r+="-"+t,i=t);return e||(y[r]=a(n+="")?d(n):n)};var t=/[-+]?\d*\.?\d+rpx/g,r="__rpx_coefficient__",o="__viewport_width__",u="object"==typeof window?window:"object"==typeof u?u:{},i=_.isWeb?"web":_.isWeex?"weex":"",f=function(n){return parseFloat(n)*l()+"px"},c=function(n){return function(n,e){e=Math.pow(10,e+1);return 10*Math.round(Math.floor(n*e)/10)/e}(parseFloat(n)/(p()/100),4)+"vw"};function a(n){return"string"==typeof n&&t.test(n)}function d(n){return"web"===i?n.replace(t,c):"weex"===i?n.replace(t,f):n}function l(){return u[r]}function v(n){u[r]=n}function p(){return u[o]}function s(n){u[o]=n}void 0===l()&&v(1),void 0===p()&&s(750);var y=Object.create(null)});n(r);var o=r.setRpx,c=r.convertUnit,u="id",i="text",a=/^on[A-Z]/,f=/^aria-/,d=/\-(\w)/,l="";function v(n){var e=n.children.map(function(n){return 8===n.nodeType?n.value:l}).join(l);n.setAttr("value",e)}var p={},s="object"==typeof __weex_document__?__weex_document__:"object"==typeof s?s:null;function y(n){return s.createComment(n)}function w(n,e){e.appendChild(n),e.type===i&&v(e)}function m(n,e){e=e||n.parentNode;var t=n.attr&&n.attr[u];null!=t&&(p[t]=null),e.removeChild(n),e.type===i&&v(e)}function b(n,e,t){(t=t||e.parentNode).insertAfter(n,e),t.type===i&&v(t)}function x(n,e,t){(t=t||e.parentNode).insertBefore(n,e),t.type===i&&v(t)}function E(n,e,t,r){return n.addEvent(e,t,r[e+"EventParams"])}function h(n,e,t){return e==u&&(p[t]=n),f.test(e)&&(e=e.replace(d,function(n,e){return e.toUpperCase()})),n.setAttr(e,t,!1)}r={__proto__:null,getElementById:function(n){return p[n]},createBody:function(n,e){if(s.body)return s.body;var t=s.documentElement,e=s.createBody(n,e);return t.appendChild(e),e},createComment:y,createEmpty:function(){return y(l)},createText:y,updateText:function(n,e){n.value=e,v(n.parentNode)},createElement:function(n,e){void 0===e&&(e={});var t={},r=e.style;if(r)for(var o in r)t[o]=c(r[o],o);var u,i=s.createElement(n,{style:t});for(u in e){var f=e[u];"children"!==u&&null!=f&&"style"!==u&&(a.test(u)?E(i,u.slice(2).toLowerCase(),f,e):h(i,u,f))}return i},appendChild:w,removeChild:m,replaceChild:function(n,e,t){var r=e.previousSibling,o=e.nextSibling;m(e,t=t||e.parentNode),r?b(n,r,t):o?x(n,o,t):w(n,t)},insertAfter:b,insertBefore:x,addEventListener:E,removeEventListener:function(n,e,t){return n.removeEvent(e,t)},removeAttribute:function(n,e,t){return e==u&&(p[t]=null),n.setAttr(e,void 0,!1)},setAttribute:h,setStyle:function(n,e){for(var t in e)e[t]=c(e[t],t);n.setStyles(e)},beforeRender:function(){s.open(),o(1)},afterRender:function(){s.listener&&s.listener.createFinish&&s.listener.createFinish(),s.close()}};"undefined"!=typeof module?module.exports=r:self.DriverWeex=r}();
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}({});
//# sourceMappingURL=driver-weex.min.js.map
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global.DriverWeex = {}));
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.DriverWeex = {}));
}(this, (function (exports) {
function unwrapExports (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
function createCommonjsModule(fn, basedir, module) {
return module = {
path: basedir,
exports: {},
require: function (path, base) {
return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
}
}, fn(module, module.exports), module.exports;
}
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
function commonjsRequire () {
throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
}
var index_min = createCommonjsModule(function (module, exports) {
function isUndef(e) {
return "undefined" === e;
}
Object.defineProperty(exports, "__esModule", {
value: !0
});
var isWeb = !isUndef(typeof window) && "onload" in window,
isNode = !isUndef(typeof process) && !(!process.versions || !process.versions.node),
isWeex = !isUndef(typeof callNative) || !isUndef(typeof WXEnvironment) && "Web" !== WXEnvironment.platform,
isMiniApp = !isUndef(typeof my) && !isUndef(my.navigateTo),
isWeChatMiniprogram = !isUndef(typeof wx) && !isUndef(wx.navigateTo);
exports.isMiniApp = isMiniApp, exports.isNode = isNode, exports.isWeChatMiniprogram = isWeChatMiniprogram, exports.isWeb = isWeb, exports.isWeex = isWeex;
});
unwrapExports(index_min);
var index_min_1 = index_min.isMiniApp;
var index_min_2 = index_min.isNode;
var index_min_3 = index_min.isWeChatMiniprogram;
var index_min_4 = index_min.isWeb;
var index_min_5 = index_min.isWeex;
var lib = createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.__esModule = true;
exports.isQuickApp = exports.isWeChatMiniProgram = exports.isByteDanceMicroApp = exports.isMiniApp = exports.isKraken = exports.isWeex = exports.isNode = exports.isWeb = void 0;

@@ -48,23 +32,20 @@ function isUndef(type) {

var isWeb = !isUndef(typeof window) && 'onload' in window;
exports.isWeb = isWeb;
var isNode = !isUndef(typeof process) && !!(process.versions && process.versions.node);
var isWeex = !isUndef(typeof callNative) || !isUndef(typeof WXEnvironment) && WXEnvironment.platform !== 'Web';
var isMiniApp = !isUndef(typeof my) && !isUndef(my.navigateTo);
var isWeChatMiniprogram = !isUndef(typeof wx) && !isUndef(wx.navigateTo);
exports.isMiniApp = isMiniApp;
exports.isNode = isNode;
exports.isWeChatMiniprogram = isWeChatMiniprogram;
exports.isWeb = isWeb;
var isWeex = !isUndef(typeof WXEnvironment) && WXEnvironment.platform !== 'Web';
exports.isWeex = isWeex;
});
unwrapExports(lib);
var lib_1 = lib.isMiniApp;
var lib_2 = lib.isNode;
var lib_3 = lib.isWeChatMiniprogram;
var lib_4 = lib.isWeb;
var lib_5 = lib.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.
var universalEnv = createCommonjsModule(function (module) {
{
module.exports = lib;
}
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;
});

@@ -82,10 +63,15 @@

exports.setDecimalPixelTransformer = setDecimalPixelTransformer;
exports.convertUnit = convertUnit;
var RPX_REG = /[-+]?\d*\.?\d+rpx/g;
var GLOBAL_RPX_COEFFICIENT = '__rpx_coefficient__';
var GLOBAL_VIEWPORT_WIDTH = '__viewport_width__';
var global = typeof window === 'object' ? window : typeof global === 'object' ? global : {}; // convertUnit method targetPlatform
exports.setUnitPrecision = setUnitPrecision;
exports.cached = cached;
exports.setTargetPlatform = setTargetPlatform;
exports.convertUnit = void 0;
var RPX_REG = /"[^"]+"|'[^']+'|url\([^\)]+\)|(\d*\.?\d+)rpx/g;
var targetPlatform = universalEnv.isWeb ? 'web' : universalEnv.isWeex ? 'weex' : ''; // Init toFixed method
var __rpx_coefficient__;
var __viewport_width__; // convertUnit method targetPlatform
var targetPlatform = lib.isWeb ? 'web' : lib.isWeex ? 'weex' : ''; // Init toFixed method
var unitPrecision = 4;

@@ -100,9 +86,9 @@

var decimalPixelTransformer = function decimalPixelTransformer(rpx) {
return parseFloat(rpx) * getRpx() + 'px';
var decimalPixelTransformer = function decimalPixelTransformer(rpx, $1) {
return $1 ? parseFloat(rpx) * getRpx() + 'px' : rpx;
}; // Default decimal vw transformer.
var decimalVWTransformer = function decimalVWTransformer(rpx) {
return toFixed(parseFloat(rpx) / (getViewportWidth() / 100), unitPrecision) + 'vw';
var decimalVWTransformer = function decimalVWTransformer(rpx, $1) {
return $1 ? toFixed(parseFloat(rpx) / (getViewportWidth() / 100), unitPrecision) + 'vw' : rpx;
}; // Default 1 rpx to 1 px

@@ -154,15 +140,15 @@

function getRpx() {
return global[GLOBAL_RPX_COEFFICIENT];
return __rpx_coefficient__;
}
function setRpx(rpx) {
global[GLOBAL_RPX_COEFFICIENT] = rpx;
__rpx_coefficient__ = rpx;
}
function getViewportWidth() {
return global[GLOBAL_VIEWPORT_WIDTH];
return __viewport_width__;
}
function setViewportWidth(viewport) {
global[GLOBAL_VIEWPORT_WIDTH] = viewport;
__viewport_width__ = viewport;
}

@@ -179,5 +165,30 @@ /**

}
/**
* Set unit precision.
* @param n {Number} Unit precision, default to 4.
*/
var cache = Object.create(null);
function setUnitPrecision(n) {
unitPrecision = n;
}
/**
* Create a cached version of a pure function.
* Use the first params as cache key.
*/
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);
};
}
function setTargetPlatform(platform) {
targetPlatform = platform;
}
/**
* Convert rpx.

@@ -190,28 +201,12 @@ * @param value

function convertUnit(value, prop, platform) {
var cacheKey = prop + "-" + value;
var hit = cache[cacheKey];
var convertUnit = cached(function (value, prop, platform) {
if (platform) {
cacheKey += "-" + platform;
targetPlatform = platform;
setTargetPlatform(platform);
}
if (hit) {
return hit;
} else {
value = value + '';
return cache[cacheKey] = isRpx(value) ? calcRpx(value) : value;
}
}
return isRpx(value) ? calcRpx(value) : value;
});
exports.convertUnit = convertUnit;
});
unwrapExports(lib$1);
var lib_1$1 = lib$1.isRpx;
var lib_2$1 = lib$1.calcRpx;
var lib_3$1 = lib$1.getRpx;
var lib_4$1 = lib$1.setRpx;
var lib_5$1 = lib$1.getViewportWidth;
var lib_6 = lib$1.setViewportWidth;
var lib_7 = lib$1.setDecimalPixelTransformer;
var lib_8 = lib$1.convertUnit;

@@ -276,3 +271,3 @@ var STYLE = 'style';

for (var prop in originStyle) {
style[prop] = lib_8(originStyle[prop], prop);
style[prop] = lib$1.convertUnit(originStyle[prop], prop);
}

@@ -391,3 +386,3 @@ }

// Translate `rpx` to weex `px`
style[prop] = lib_8(style[prop], prop);
style[prop] = lib$1.convertUnit(style[prop], prop);
}

@@ -401,3 +396,3 @@

lib_4$1(1);
lib$1.setRpx(1);
}

@@ -404,0 +399,0 @@ function afterRender() {

{
"name": "driver-weex",
"version": "2.0.1",
"version": "2.0.2-0",
"description": "Weex driver for Rax",

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

"dependencies": {
"style-unit": "^3.0.0"
"style-unit": "3.0.1-0"
}
}

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

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc