weex-vue-framework
Advanced tools
Comparing version 2.5.4-weex.0 to 2.5.4-weex.1
83
index.js
@@ -5,24 +5,31 @@ 'use strict'; | ||
/* */ | ||
// TODO: these declarations should be moved to a separate file. | ||
// this will be preserved during build | ||
// $flow-disable-line | ||
var VueFactory = require('./factory'); | ||
var instances = {}; | ||
var instanceOptions = {}; | ||
/** | ||
* Reset framework config and clear all registrations. | ||
* Create instance context. | ||
*/ | ||
function reset () { | ||
for (var key in instances) { | ||
delete instances[key]; | ||
} | ||
} | ||
function createInstanceContext ( | ||
instanceId, | ||
runtimeContext, | ||
data | ||
) { | ||
if ( data === void 0 ) data = {}; | ||
function createInstanceContext (instanceId, runtimeContext, data) { | ||
if ( runtimeContext === void 0 ) runtimeContext = {}; | ||
var weex = runtimeContext.weex; | ||
var instance = instances[instanceId] = { | ||
var instance = instanceOptions[instanceId] = { | ||
instanceId: instanceId, | ||
data: data, | ||
document: weex.document | ||
document: weex.document, | ||
data: data | ||
}; | ||
@@ -33,6 +40,7 @@ | ||
// DEPRECATED | ||
var timerAPIs = getInstanceTimer(instanceId, weex.requireModule); | ||
var instanceContext = Object.assign({ Vue: Vue }, timerAPIs); | ||
Object.freeze(instanceContext); | ||
return instanceContext | ||
@@ -44,13 +52,14 @@ } | ||
* this instance released and no more leaks. | ||
* @param {string} instanceId | ||
*/ | ||
function destroyInstance (instanceId) { | ||
var instance = instances[instanceId]; | ||
var instance = instanceOptions[instanceId]; | ||
if (instance && instance.app instanceof instance.Vue) { | ||
instance.document.destroy(); | ||
instance.app.$destroy(); | ||
try { | ||
instance.app.$destroy(); | ||
instance.document.destroy(); | ||
} catch (e) {} | ||
delete instance.document; | ||
delete instance.app; | ||
} | ||
delete instances[instanceId]; | ||
delete instanceOptions[instanceId]; | ||
} | ||
@@ -62,12 +71,15 @@ | ||
* define all possible meaningful keys when instance created. | ||
* @param {string} instanceId | ||
* @param {object} data | ||
*/ | ||
function refreshInstance (instanceId, data) { | ||
var instance = instances[instanceId]; | ||
function refreshInstance ( | ||
instanceId, | ||
data | ||
) { | ||
var instance = instanceOptions[instanceId]; | ||
if (!instance || !(instance.app instanceof instance.Vue)) { | ||
return new Error(("refreshInstance: instance " + instanceId + " not found!")) | ||
} | ||
for (var key in data) { | ||
instance.Vue.set(instance.app, key, data[key]); | ||
if (instance.Vue && instance.Vue.set) { | ||
for (var key in data) { | ||
instance.Vue.set(instance.app, key, data[key]); | ||
} | ||
} | ||
@@ -81,3 +93,6 @@ // Finally `refreshFinish` signal needed. | ||
*/ | ||
function createVueModuleInstance (instanceId, weex) { | ||
function createVueModuleInstance ( | ||
instanceId, | ||
weex | ||
) { | ||
var exports = {}; | ||
@@ -87,3 +102,3 @@ VueFactory(exports, weex.document); | ||
var instance = instances[instanceId]; | ||
var instance = instanceOptions[instanceId]; | ||
@@ -129,3 +144,3 @@ // patch reserved tag detection to account for dynamically registered | ||
try { | ||
// Send `createFinish` signal to native. | ||
// Send "createFinish" signal to native. | ||
weex.document.taskCenter.send('dom', { action: 'createFinish' }, []); | ||
@@ -141,2 +156,3 @@ } catch (e) {} | ||
/** | ||
* DEPRECATED | ||
* Generate HTML5 Timer APIs. An important point is that the callback | ||
@@ -146,8 +162,8 @@ * will be converted into callback id when sent to native. So the | ||
* an instance destroyed. | ||
* @param {[type]} instanceId [description] | ||
* @param {[type]} moduleGetter [description] | ||
* @return {[type]} [description] | ||
*/ | ||
function getInstanceTimer (instanceId, moduleGetter) { | ||
var instance = instances[instanceId]; | ||
function getInstanceTimer ( | ||
instanceId, | ||
moduleGetter | ||
) { | ||
var instance = instanceOptions[instanceId]; | ||
var timer = moduleGetter('timer'); | ||
@@ -187,5 +203,4 @@ var timerAPIs = { | ||
exports.reset = reset; | ||
exports.createInstanceContext = createInstanceContext; | ||
exports.destroyInstance = destroyInstance; | ||
exports.refreshInstance = refreshInstance; |
{ | ||
"name": "weex-vue-framework", | ||
"version": "2.5.4-weex.0", | ||
"version": "2.5.4-weex.1", | ||
"description": "Vue 2.0 Framework for Weex", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6555
192949