Socket
Socket
Sign inDemoInstall

weex-vue-framework

Package Overview
Dependencies
0
Maintainers
4
Versions
60
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.4.2-weex.8 to 2.4.2-weex.9

355

index.js

@@ -5,12 +5,2 @@ 'use strict';

var latestNodeId = 1;
function TextNode (text) {
this.instanceId = '';
this.nodeId = latestNodeId++;
this.parentNode = null;
this.nodeType = 3;
this.text = text;
}
// this will be preserved during build

@@ -20,22 +10,8 @@ var VueFactory = require('./factory');

var instances = {};
var modules = {};
var components = {};
var renderer = {
TextNode: TextNode,
instances: instances,
modules: modules,
components: components
};
/**
* Prepare framework config, basically about the virtual-DOM and JS bridge.
* @param {object} cfg
* Prepare framework config.
* Nothing need to do actually, just an interface provided to weex runtime.
*/
function init (cfg) {
renderer.Document = cfg.Document;
renderer.Element = cfg.Element;
renderer.Comment = cfg.Comment;
renderer.compileBundle = cfg.compileBundle;
}
function init () {}

@@ -47,8 +23,2 @@ /**

clear(instances);
clear(modules);
clear(components);
delete renderer.Document;
delete renderer.Element;
delete renderer.Comment;
delete renderer.compileBundle;
}

@@ -85,5 +55,4 @@

// Virtual-DOM object.
var document = new renderer.Document(instanceId, config.bundleUrl);
var weex = env.weex;
var document = weex.document;
var instance = instances[instanceId] = {

@@ -94,17 +63,6 @@ instanceId: instanceId, config: config, data: data,

// Prepare native module getter and HTML5 Timer APIs.
var moduleGetter = genModuleGetter(instanceId);
var timerAPIs = getInstanceTimer(instanceId, moduleGetter);
var timerAPIs = getInstanceTimer(instanceId, weex.requireModule);
// Prepare `weex` instance variable.
var weexInstanceVar = {
config: config,
document: document,
supports: supports,
requireModule: moduleGetter
};
Object.freeze(weexInstanceVar);
// Each instance has a independent `Vue` module instance
var Vue = instance.Vue = createVueModuleInstance(instanceId, moduleGetter);
var Vue = instance.Vue = createVueModuleInstance(instanceId, weex);

@@ -115,3 +73,3 @@ // The function which create a closure the JS Bundle will run in.

Vue: Vue,
weex: weexInstanceVar
weex: weex
}, timerAPIs, env.services);

@@ -121,10 +79,6 @@

if (!callFunctionNative(instanceVars, appCode)) {
// If failed to compile functionBody on native side,
// fallback to 'callFunction()'.
callFunction(instanceVars, appCode);
}
callFunction(instanceVars, appCode);
// Send `createFinish` signal to native.
instance.document.taskCenter.send('dom', { action: 'createFinish' }, []);
document.taskCenter.send('dom', { action: 'createFinish' }, []);

@@ -142,8 +96,6 @@ return instance

if (instance && instance.app instanceof instance.Vue) {
try {
instance.app.$destroy();
} catch (e) {
} finally {
instance.document.destroy();
}
instance.document.destroy();
instance.app.$destroy();
delete instance.document;
delete instance.app;
}

@@ -184,148 +136,8 @@ delete instances[instanceId];

var jsHandlers = {
fireEvent: function (id) {
var args = [], len = arguments.length - 1;
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
return fireEvent.apply(void 0, [ instances[id] ].concat( args ))
},
callback: function (id) {
var args = [], len = arguments.length - 1;
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
return callback.apply(void 0, [ instances[id] ].concat( args ))
}
};
function fireEvent (instance, nodeId, type, e, domChanges, params) {
var el = instance.document.getRef(nodeId);
if (el) {
var result = null;
try {
result = instance.document.fireEvent(el, type, e, domChanges, params);
} catch (e) {}
return result
}
return new Error(("invalid element reference \"" + nodeId + "\""))
}
function callback (instance, callbackId, data, ifKeepAlive) {
var result = null;
try {
result = instance.document.taskCenter.callback(callbackId, data, ifKeepAlive);
} catch (e) {}
return result
}
/**
* Accept calls from native (event or callback).
*
* @param {string} id
* @param {array} tasks list with `method` and `args`
*/
function receiveTasks (id, tasks) {
var instance = instances[id];
if (instance && Array.isArray(tasks)) {
var results = [];
tasks.forEach(function (task) {
var handler = jsHandlers[task.method];
var args = [].concat( task.args );
/* istanbul ignore else */
if (typeof handler === 'function') {
args.unshift(id);
results.push(handler.apply(void 0, args));
}
});
return results
}
return new Error(("invalid instance id \"" + id + "\" or tasks"))
}
/**
* Register native modules information.
* @param {object} newModules
*/
function registerModules (newModules) {
var loop = function ( name ) {
if (!modules[name]) {
modules[name] = {};
}
newModules[name].forEach(function (method) {
if (typeof method === 'string') {
modules[name][method] = true;
} else {
modules[name][method.name] = method.args;
}
});
};
for (var name in newModules) loop( name );
}
/**
* Check whether the module or the method has been registered.
* @param {String} module name
* @param {String} method name (optional)
*/
function isRegisteredModule (name, method) {
if (typeof method === 'string') {
return !!(modules[name] && modules[name][method])
}
return !!modules[name]
}
/**
* Register native components information.
* @param {array} newComponents
*/
function registerComponents (newComponents) {
if (Array.isArray(newComponents)) {
newComponents.forEach(function (component) {
if (!component) {
return
}
if (typeof component === 'string') {
components[component] = true;
} else if (typeof component === 'object' && typeof component.type === 'string') {
components[component.type] = component;
}
});
}
}
/**
* Check whether the component has been registered.
* @param {String} component name
*/
function isRegisteredComponent (name) {
return !!components[name]
}
/**
* Detects whether Weex supports specific features.
* @param {String} condition
*/
function supports (condition) {
if (typeof condition !== 'string') { return null }
var res = condition.match(/^@(\w+)\/(\w+)(\.(\w+))?$/i);
if (res) {
var type = res[1];
var name = res[2];
var method = res[4];
switch (type) {
case 'module': return isRegisteredModule(name, method)
case 'component': return isRegisteredComponent(name)
}
}
return null
}
/**
* Create a fresh instance of Vue for each Weex instance.
*/
function createVueModuleInstance (instanceId, moduleGetter) {
function createVueModuleInstance (instanceId, weex) {
var exports = {};
VueFactory(exports, renderer);
VueFactory(exports, weex.document);
var Vue = exports.Vue;

@@ -341,3 +153,3 @@

Vue.config.isReservedTag = function (name) {
return (!isRuntimeComponent(name) && components[name]) ||
return (!isRuntimeComponent(name) && weex.supports(("@component/" + name))) ||
isReservedTag(name) ||

@@ -354,3 +166,3 @@ weexRegex.test(name)

// vdom runtime modules can access native modules via vnode.context
Vue.prototype.$requireWeexModule = moduleGetter;
Vue.prototype.$requireWeexModule = weex.requireModule;

@@ -389,40 +201,2 @@ // Hack `Vue` behavior to handle instance information and data

/**
* Generate native module getter. Each native module has several
* methods to call. And all the behaviors is instance-related. So
* this getter will return a set of methods which additionally
* send current instance id to native when called.
* @param {string} instanceId
* @return {function}
*/
function genModuleGetter (instanceId) {
var instance = instances[instanceId];
return function (name) {
var nativeModule = modules[name] || [];
var output = {};
var loop = function ( methodName ) {
Object.defineProperty(output, methodName, {
enumerable: true,
configurable: true,
get: function proxyGetter () {
return function () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];
return instance.document.taskCenter.send('module', { module: name, method: methodName }, args)
}
},
set: function proxySetter (val) {
if (typeof val === 'function') {
return instance.document.taskCenter.send('module', { module: name, method: methodName }, [val])
}
}
});
};
for (var methodName in nativeModule) loop( methodName );
return output
}
}
/**
* Generate HTML5 Timer APIs. An important point is that the callback

@@ -467,37 +241,2 @@ * will be converted into callback id when sent to native. So the

timer.clearInterval(n);
},
// TODO: deprecated
deprecated_setTimeout: function deprecated_setTimeout (handler, delay) {
if (typeof global.setIntervalWeex === 'function') {
var timerId = global.setIntervalWeex(instanceId, function () {
handler.apply(null);
if (typeof global.clearIntervalWeex === 'function') {
global.clearIntervalWeex(instanceId, timerId);
}
}, delay);
}
},
// TODO: deprecated
deprecated_clearTimeout: function deprecated_clearTimeout (timerId) {
if (typeof global.clearIntervalWeex === 'function') {
return global.clearIntervalWeex(instanceId, timerId)
}
},
// TODO: deprecated
deprecated_setInterval: function deprecated_setInterval (handler, delay) {
if (typeof global.setIntervalWeex === 'function') {
return global.setIntervalWeex(instanceId, handler, delay)
}
console.warn("[JS Framework] can't find \"global.setIntervalWeex\"," +
" please use \"setInerval\" instead!!");
},
// TODO: deprecated
deprecated_clearInterval: function deprecated_clearInterval (timerId) {
if (typeof global.clearIntervalWeex === 'function') {
return global.clearIntervalWeex(instanceId, timerId)
}
}

@@ -527,54 +266,2 @@ };

/**
* Call a new function generated on the V8 native side.
*
* This function helps speed up bundle compiling. Normally, the V8
* engine needs to download, parse, and compile a bundle on every
* visit. If 'compileBundle()' is available on native side,
* the downloding, parsing, and compiling steps would be skipped.
* @param {object} globalObjects
* @param {string} body
* @return {boolean}
*/
function callFunctionNative (globalObjects, body) {
if (typeof renderer.compileBundle !== 'function') {
return false
}
var fn = void 0;
var isNativeCompileOk = false;
var script = '(function (';
var globalKeys = [];
var globalValues = [];
for (var key in globalObjects) {
globalKeys.push(key);
globalValues.push(globalObjects[key]);
}
for (var i = 0; i < globalKeys.length - 1; ++i) {
script += globalKeys[i];
script += ',';
}
script += globalKeys[globalKeys.length - 1];
script += ') {';
script += body;
script += '} )';
try {
var weex = globalObjects.weex || {};
var config = weex.config || {};
fn = renderer.compileBundle(script,
config.bundleUrl,
config.bundleDigest,
config.codeCachePath);
if (fn && typeof fn === 'function') {
fn.apply(void 0, globalValues);
isNativeCompileOk = true;
}
} catch (e) {
console.error(e);
}
return isNativeCompileOk
}
exports.init = init;

@@ -586,7 +273,1 @@ exports.reset = reset;

exports.getRoot = getRoot;
exports.receiveTasks = receiveTasks;
exports.registerModules = registerModules;
exports.isRegisteredModule = isRegisteredModule;
exports.registerComponents = registerComponents;
exports.isRegisteredComponent = isRegisteredComponent;
exports.supports = supports;

2

package.json
{
"name": "weex-vue-framework",
"version": "2.4.2-weex.8",
"version": "2.4.2-weex.9",
"description": "Vue 2.0 Framework for Weex",

@@ -5,0 +5,0 @@ "main": "index.js",

# weex-vue-framework
> This package is auto-generated. For pull requests please see [src/entries/weex-framework.js](https://github.com/vuejs/vue/blob/dev/src/platforms/weex/framework.js).
> This package is auto-generated. For pull requests please see [src/platforms/weex/entry-framework.js](https://github.com/vuejs/vue/blob/dev/src/platforms/weex/entry-framework.js).

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc