UNPKG

weex-js-runtime

Version:
3 lines (2 loc) 25 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.WeexJSRuntime=t()}(this,function(){"use strict";function e(e,t,n){return t+"@"+n+"#"+e}var t=function(e){this.instanceId=String(e),this.lastCallbackId=0,this.callbacks={},this.hooks={}};t.prototype.add=function(e){return this.lastCallbackId++,this.callbacks[this.lastCallbackId]=e,this.lastCallbackId},t.prototype.remove=function(e){var t=this.callbacks[e];return delete this.callbacks[e],t},t.prototype.registerHook=function(t,n,r,o){var i=e(t,n,r);this.hooks[i]&&console.warn('[JS Framework] Override an existing component hook "'+i+'".'),this.hooks[i]=o},t.prototype.triggerHook=function(t,n,r,o){var i=e(t,n,r),a=this.hooks[i];if("function"!=typeof a)return console.error("[JS Framework] Invalid hook function type ("+typeof a+') on "'+i+'".'),null;var s=null;try{s=a.apply(null,o||[])}catch(e){console.error('[JS Framework] Failed to execute the hook function on "'+i+'".')}return s},t.prototype.consume=function(e,t,n){var r=this.callbacks[e];return void 0!==n&&!1!==n||delete this.callbacks[e],"function"==typeof r?r(t):new Error('invalid callback id "'+e+'"')},t.prototype.close=function(){this.callbacks={},this.hooks={}};var n=1;function r(){return(n++).toString()}function o(e){var t=Object.prototype.toString.call(e);return t.substring(8,t.length-1)}function i(e){if("function"!=typeof btoa)return"";var t=Array.prototype.map.call(new Uint8Array(e),function(e){return String.fromCharCode(e)}).join("");return btoa(t)}function a(e){if(!e||"object"!=typeof e)return!0;for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}var s={};function c(e){return s[e]}function l(e){var t=s[e];return t&&t.taskCenter?t.taskCenter:null}function d(e,t,n){var r=e.documentElement;if(!(r.pureChildren.length>0||t.parentNode)){var o,i,a=r.children,s=a.indexOf(n);s<0?a.push(t):a.splice(s,0,t),1===t.nodeType?("body"===t.role?(t.docId=e.id,t.ownerDocument=e,t.parentNode=r,f(t,r)):(t.children.forEach(function(e){e.parentNode=t}),u(e,t),t.docId=e.id,t.ownerDocument=e,f(t,r),delete e.nodeMap[t.nodeId]),r.pureChildren.push(t),o=e,i=t.toJSON(),o&&o.taskCenter&&"function"==typeof o.taskCenter.send&&o.taskCenter.send("dom",{action:"createBody"},[i])):(t.parentNode=r,e.nodeMap[t.ref]=t)}}function u(e,t){t.role="body",t.depth=1,delete e.nodeMap[t.nodeId],t.ref="_root",e.nodeMap._root=t,e.body=t}function f(e,t){e.parentNode=t,t.docId&&(e.docId=t.docId,e.ownerDocument=t.ownerDocument,e.ownerDocument.nodeMap[e.nodeId]=e,e.depth=t.depth+1),e.children.forEach(function(t){f(t,e)})}function h(e){for(;e;){if(1===e.nodeType)return e;e=e.nextSibling}}function p(e){for(;e;){if(1===e.nodeType)return e;e=e.previousSibling}}function v(e,t,n,r){n<0&&(n=0);var o=t[n-1],i=t[n];return t.splice(n,0,e),r&&(o&&(o.nextSibling=e),e.previousSibling=o,e.nextSibling=i,i&&(i.previousSibling=e)),n}function y(e,t,n,r){var o=t.indexOf(e);if(o<0)return-1;if(r){var i=t[o-1],a=t[o+1];i&&(i.nextSibling=a),a&&(a.previousSibling=i)}t.splice(o,1);var s=n;o<=n&&(s=n-1);var c=t[s-1],l=t[s];return t.splice(s,0,e),r&&(c&&(c.nextSibling=e),e.previousSibling=c,e.nextSibling=l,l&&(l.previousSibling=e)),o===s?-1:n}function m(e,t,n){var r=t.indexOf(e);if(!(r<0)){if(n){var o=t[r-1],i=t[r+1];o&&(o.nextSibling=i),i&&(i.previousSibling=o)}t.splice(r,1)}}var g,b=function(){this.nodeId=r(),this.ref=this.nodeId,this.children=[],this.pureChildren=[],this.parentNode=null,this.nextSibling=null,this.previousSibling=null};b.prototype.destroy=function(){var e=c(this.docId);e&&(delete this.docId,delete e.nodeMap[this.nodeId]),this.children.forEach(function(e){e.destroy()})};var S={};var k="div",E=["click","longpress","touchstart","touchmove","touchend","panstart","panmove","panend","horizontalpan","verticalpan","swipe"];function I(e,t){c(e).nodeMap[t.nodeId]=t}var w=function(e){function t(t,n,o){void 0===t&&(t=k),e.call(this);var i=S[t];if(i&&!o)return new i(t,n,!0);n=n||{},this.nodeType=1,this.nodeId=r(),this.ref=this.nodeId,this.type=t,this.attr=n.attr||{},this.style=n.style||{},this.classStyle=n.classStyle||{},this.classList=n.classList||[],this.event={},this.children=[],this.pureChildren=[]}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.appendChild=function(e){if(!e.parentNode||e.parentNode===this)if(e.parentNode){if(y(e,this.children,this.children.length,!0),1===e.nodeType){var t=y(e,this.pureChildren,this.pureChildren.length),n=l(this.docId);if(n&&t>=0)return n.send("dom",{action:"moveElement"},[e.ref,this.ref,t])}}else if(f(e,this),v(e,this.children,this.children.length,!0),this.docId&&I(this.docId,e),1===e.nodeType){v(e,this.pureChildren,this.pureChildren.length);var r=l(this.docId);if(r)return r.send("dom",{action:"addElement"},[this.ref,e.toJSON(),-1])}},t.prototype.insertBefore=function(e,t){if(!(e.parentNode&&e.parentNode!==this||e===t||e.nextSibling&&e.nextSibling===t))if(e.parentNode){if(y(e,this.children,this.children.indexOf(t),!0),1===e.nodeType){var n=h(t),r=y(e,this.pureChildren,n?this.pureChildren.indexOf(n):this.pureChildren.length),o=l(this.docId);if(o&&r>=0)return o.send("dom",{action:"moveElement"},[e.ref,this.ref,r])}}else if(f(e,this),v(e,this.children,this.children.indexOf(t),!0),this.docId&&I(this.docId,e),1===e.nodeType){var i=h(t),a=v(e,this.pureChildren,i?this.pureChildren.indexOf(i):this.pureChildren.length),s=l(this.docId);if(s)return s.send("dom",{action:"addElement"},[this.ref,e.toJSON(),a])}},t.prototype.insertAfter=function(e,t){if(!(e.parentNode&&e.parentNode!==this||e===t||e.previousSibling&&e.previousSibling===t))if(e.parentNode){if(y(e,this.children,this.children.indexOf(t)+1,!0),1===e.nodeType){var n=y(e,this.pureChildren,this.pureChildren.indexOf(p(t))+1),r=l(this.docId);if(r&&n>=0)return r.send("dom",{action:"moveElement"},[e.ref,this.ref,n])}}else if(f(e,this),v(e,this.children,this.children.indexOf(t)+1,!0),this.docId&&I(this.docId,e),1===e.nodeType){var o=v(e,this.pureChildren,this.pureChildren.indexOf(p(t))+1),i=l(this.docId);if(i)return i.send("dom",{action:"addElement"},[this.ref,e.toJSON(),o])}},t.prototype.removeChild=function(e,t){if(e.parentNode&&(m(e,this.children,!0),1===e.nodeType)){m(e,this.pureChildren);var n=l(this.docId);n&&n.send("dom",{action:"removeElement"},[e.ref])}t||e.destroy()},t.prototype.clear=function(){var e=l(this.docId);e&&this.pureChildren.forEach(function(t){e.send("dom",{action:"removeElement"},[t.ref])}),this.children.forEach(function(e){e.destroy()}),this.children.length=0,this.pureChildren.length=0},t.prototype.setAttr=function(e,t,n){if(this.attr[e]!==t||!1===n){this.attr[e]=t;var r=l(this.docId);if(!n&&r){var o={};o[e]=t,r.send("dom",{action:"updateAttrs"},[this.ref,o])}}},t.prototype.setAttrs=function(e,t){if(!a(e)){var n={};for(var r in e)this.attr[r]!==e[r]&&(this.attr[r]=e[r],n[r]=e[r]);if(!a(n)){var o=l(this.docId);!t&&o&&o.send("dom",{action:"updateAttrs"},[this.ref,n])}}},t.prototype.setStyle=function(e,t,n){if(this.style[e]!==t||!1===n){this.style[e]=t;var r=l(this.docId);if(!n&&r){var o={};o[e]=t,r.send("dom",{action:"updateStyle"},[this.ref,o])}}},t.prototype.setStyles=function(e,t){if(!a(e)){var n={};for(var r in e)this.style[r]!==e[r]&&(this.style[r]=e[r],n[r]=e[r]);if(!a(n)){var o=l(this.docId);!t&&o&&o.send("dom",{action:"updateStyle"},[this.ref,n])}}},t.prototype.setClassStyle=function(e){for(var t in this.classStyle)this.classStyle[t]="";Object.assign(this.classStyle,e);var n=l(this.docId);n&&n.send("dom",{action:"updateStyle"},[this.ref,this.toStyle()])},t.prototype.setClassList=function(e){var t="string"==typeof e?e.split(/\s+/):Array.from(e);if(Array.isArray(t)&&t.length>0){this.classList=t;var n=l(this.docId);n&&n.send("dom",{action:"updateClassList"},[this.ref,this.classList.slice()])}},t.prototype.addEvent=function(e,t,n){if(this.event||(this.event={}),!this.event[e]){this.event[e]={handler:t,params:n};var r=l(this.docId);r&&r.send("dom",{action:"addEvent"},[this.ref,e])}},t.prototype.removeEvent=function(e){if(this.event&&this.event[e]){delete this.event[e];var t=l(this.docId);t&&t.send("dom",{action:"removeEvent"},[this.ref,e])}},t.prototype.fireEvent=function(e,t,n,r){var o=null,i=!1,a=this.event[e];if(a&&t){var s=a.handler;t.stopPropagation=function(){i=!0},o=r&&r.params?s.call.apply(s,[this].concat(r.params,[t])):s.call(this,t)}return!i&&n&&-1!==E.indexOf(e)&&this.parentNode&&this.parentNode.fireEvent&&(t.currentTarget=this.parentNode,this.parentNode.fireEvent(e,t,n)),o},t.prototype.toStyle=function(){return Object.assign({},this.classStyle,this.style)},t.prototype.toJSON=function(){var e={ref:this.ref.toString(),type:this.type};a(this.attr)||(e.attr=this.attr),this.classList.length>0&&(e.classList=this.classList.slice());var t=this.toStyle();a(t)||(e.style=t);var n=[];for(var r in this.event){var o=this.event[r].params;o?n.push({type:r,params:o}):n.push(r)}return n.length&&(e.event=n),this.pureChildren.length&&(e.children=this.pureChildren.map(function(e){return e.toJSON()})),e},t.prototype.toString=function(){return"<"+this.type+" attr="+JSON.stringify(this.attr)+" style="+JSON.stringify(this.toStyle())+">"+this.pureChildren.map(function(e){return e.toString()}).join("")+"</"+this.type+">"},t}(b);g=w;var C=function(){},O=function(e,n){Object.defineProperty(this,"instanceId",{enumerable:!0,value:String(e)}),Object.defineProperty(this,"callbackManager",{enumerable:!0,value:new t(e)}),C=n||function(){}};function A(e,t){var n=c(e);return n?Array.isArray(t)?t.map(function(e){switch(e.method){case"callback":return function(e,t,n,r){return e.taskCenter.callback(t,n,r)}.apply(void 0,[n].concat(e.args));case"fireEventSync":case"fireEvent":return function(e,t,n,r,o,i){var a=e.getRef(t);return a?e.fireEvent(a,n,r,o,i):new Error('invalid element reference "'+t+'"')}.apply(void 0,[n].concat(e.args));case"componentHook":return function(e,t,n,r,o){if(!e||!e.taskCenter)return console.error('[JS Framework] Can\'t find "document" or "taskCenter".'),null;var i=null;try{i=e.taskCenter.triggerHook(t,n,r,o)}catch(e){console.error('[JS Framework] Failed to trigger the "'+n+"@"+r+'" hook on '+t+".")}return i}.apply(void 0,[n].concat(e.args))}}):void 0:new Error("[JS Framework] Failed to receiveTasks, instance ("+e+") is not available.")}O.prototype.callback=function(e,t,n){return this.callbackManager.consume(e,t,n)},O.prototype.registerHook=function(){for(var e,t=[],n=arguments.length;n--;)t[n]=arguments[n];return(e=this.callbackManager).registerHook.apply(e,t)},O.prototype.triggerHook=function(){for(var e,t=[],n=arguments.length;n--;)t[n]=arguments[n];return(e=this.callbackManager).triggerHook.apply(e,t)},O.prototype.updateData=function(e,t,n){this.send("module",{module:"dom",method:"updateComponentData"},[e,t,n])},O.prototype.destroyCallback=function(){return this.callbackManager.close()},O.prototype.normalize=function(e){var t=o(e);return e&&e instanceof w?e.ref:e&&e._isVue&&e.$el instanceof w?e.$el.ref:"Function"===t?this.callbackManager.add(e).toString():function(e){var t=o(e);switch(t){case"Undefined":case"Null":return"";case"RegExp":return e.toString();case"Date":return e.toISOString();case"Number":case"String":case"Boolean":case"Array":case"Object":return e;case"ArrayBuffer":return{"@type":"binary",dataType:t,base64:i(e)};case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":return{"@type":"binary",dataType:t,base64:i(e.buffer)};default:return JSON.stringify(e)}}(e)},O.prototype.send=function(e,t,n,r){var o=this,i=t.action,a=t.component,s=t.ref,c=t.module,l=t.method;switch(n=n.map(function(e){return o.normalize(e)}),e){case"dom":return this[i](this.instanceId,n);case"component":return this.componentHandler(this.instanceId,s,l,n,Object.assign({component:a},r));default:return this.moduleHandler(this.instanceId,c,l,n,r)}},O.prototype.callDOM=function(e,t){return this[e](this.instanceId,t)},O.prototype.callComponent=function(e,t,n,r){return this.componentHandler(this.instanceId,e,t,n,r)},O.prototype.callModule=function(e,t,n,r){return this.moduleHandler(this.instanceId,e,t,n,r)};var F={};function x(e){var t=function(t){F[t]||(F[t]={}),e[t].forEach(function(e){"string"==typeof e?F[t][e]=!0:F[t][e.name]=e.args})};for(var n in e)t(n)}function N(e,t){return"string"==typeof t?!(!F[e]||!F[e][t]):!!F[e]}var j={};function J(e){Array.isArray(e)&&e.forEach(function(e){e&&("string"==typeof e?j[e]=!0:"object"==typeof e&&"string"==typeof e.type&&(j[e.type]=e,function(e,t){if(t&&t.length){var n=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t}(g);t.forEach(function(t){n.prototype[t]=function(){for(var n=[],r=arguments.length;r--;)n[r]=arguments[r];var o=l(this.docId);if(o)return o.send("component",{ref:this.ref,component:e,method:t},n)}}),S[e]=n}}(e.type,e.methods)))})}function M(e){return!!j[e]}var T=[];function _(e,t){D(e)?console.warn('Service "'+e+'" has been registered already!'):(t=Object.assign({},t),T.push({name:e,options:t}))}function R(e){T.some(function(t,n){if(t.name===e)return T.splice(n,1),!0})}function D(e){return t=e,T.map(function(e){return e.name}).indexOf(t)>=0;var t}var L=function(e){function t(t){e.call(this),this.nodeType=8,this.nodeId=r(),this.ref=this.nodeId,this.type="comment",this.value=t,this.children=[],this.pureChildren=[]}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return"\x3c!-- "+this.value+" --\x3e"},t}(b);function P(e,t){return void 0===t&&(t=[]),{module:"dom",method:e,args:t}}var U=function(e,t){this.id=e,this.batched=!1,this.updates=[],"function"==typeof t?Object.defineProperty(this,"handler",{configurable:!0,enumerable:!0,writable:!0,value:t}):console.error("[JS Runtime] invalid parameter, handler must be a function")};U.prototype.createFinish=function(e){return(0,this.handler)([P("createFinish")],e)},U.prototype.updateFinish=function(e){return(0,this.handler)([P("updateFinish")],e)},U.prototype.refreshFinish=function(e){return(0,this.handler)([P("refreshFinish")],e)},U.prototype.createBody=function(e){var t=e.toJSON(),n=t.children;delete t.children;var r=[P("createBody",[t])];return n&&r.push.apply(r,n.map(function(e){return P("addElement",[t.ref,e,-1])})),this.addActions(r)},U.prototype.addElement=function(e,t,n){return n>=0||(n=-1),this.addActions(P("addElement",[t,e.toJSON(),n]))},U.prototype.removeElement=function(e){if(Array.isArray(e)){var t=e.map(function(e){return P("removeElement",[e])});return this.addActions(t)}return this.addActions(P("removeElement",[e]))},U.prototype.moveElement=function(e,t,n){return this.addActions(P("moveElement",[e,t,n]))},U.prototype.setAttr=function(e,t,n){var r={};return r[t]=n,this.addActions(P("updateAttrs",[e,r]))},U.prototype.setStyle=function(e,t,n){var r={};return r[t]=n,this.addActions(P("updateStyle",[e,r]))},U.prototype.setStyles=function(e,t){return this.addActions(P("updateStyle",[e,t]))},U.prototype.addEvent=function(e,t){return this.addActions(P("addEvent",[e,t]))},U.prototype.removeEvent=function(e,t){return this.addActions(P("removeEvent",[e,t]))},U.prototype.handler=function(e,t){return t&&t()},U.prototype.addActions=function(e){var t=this.updates,n=this.handler;if(Array.isArray(e)||(e=[e]),!this.batched)return n(e);t.push.apply(t,e)};var z={createBody:"callCreateBody",addElement:"callAddElement",removeElement:"callRemoveElement",moveElement:"callMoveElement",updateAttrs:"callUpdateAttrs",updateStyle:"callUpdateStyle",addEvent:"callAddEvent",removeEvent:"callRemoveEvent"};function H(e,t,n){var r,o=t.module,i=t.method,a=t.args;return r=i,"dom"===o&&z[r]&&"function"==typeof global[z[r]]?global[z[i]].apply(global,[e].concat(a,["-1"])):n(e,[t],"-1")}var B=function e(t,n,r){var o,i;t=t?t.toString():"",this.id=t,this.URL=n,i=this,(o=t)&&(s[o]=i),this.nodeMap={};var a,c,l=e.Listener||U;this.listener=new l(t,r||(a=t,"function"!=typeof(c=e.handler||global.callNative)&&console.error("[JS Runtime] no default handler"),function(e){Array.isArray(e)||(e=[e]);for(var t=0;t<e.length;t++){var n=H(a,e[t],c);if(-1===n)return n}})),this.taskCenter=new O(t,r?function(e){for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];return r.apply(void 0,t)}:e.handler),this.createDocumentElement()};B.prototype.getRef=function(e){return this.nodeMap[e]},B.prototype.open=function(){this.listener.batched=!1},B.prototype.close=function(){this.listener.batched=!0},B.prototype.createDocumentElement=function(){var e=this;if(!this.documentElement){var t=new w("document");t.docId=this.id,t.ownerDocument=this,t.role="documentElement",t.depth=0,t.ref="_documentElement",this.nodeMap._documentElement=t,this.documentElement=t,Object.defineProperty(t,"appendChild",{configurable:!0,enumerable:!0,writable:!0,value:function(t){d(e,t)}}),Object.defineProperty(t,"insertBefore",{configurable:!0,enumerable:!0,writable:!0,value:function(t,n){d(e,t,n)}})}return this.documentElement},B.prototype.createBody=function(e,t){this.body||u(this,new w(e,t));return this.body},B.prototype.createElement=function(e,t){return new w(e,t)},B.prototype.createComment=function(e){return new L(e)},B.prototype.registerStyleSheets=function(e,t){var n=Array.isArray(t)?t:[t];if(this.taskCenter&&n.length)return this.taskCenter.send("dom",{action:"registerStyleSheets"},[e,n])},B.prototype.fireEvent=function(e,t,n,r,o){if(e){(n=n||{}).type=n.type||t,n.target=e,n.currentTarget=e,n.timestamp=Date.now(),r&&function(e,t){var n=t.attrs||{};for(var r in n)e.setAttr(r,n[r],!0);var o=t.style||{};for(var i in o)e.setStyle(i,o[i],!0)}(e,r);var i="true"===this.getRef("_root").attr.bubble;return e.fireEvent(t,n,i,o)}},B.prototype.destroy=function(){var e;this.taskCenter.destroyCallback(),delete this.listener,delete this.nodeMap,delete this.taskCenter,e=this.id,delete s[e]},B.handler=null;var W={};var V,q,$=function(e,t){var n,r;n=this,r=String(e),Object.defineProperty(n,"[[CurrentInstanceId]]",{value:r}),this.config=t||{},this.document=new B(e,this.config.bundleUrl),this.requireModule=this.requireModule.bind(this),this.isRegisteredModule=N,this.isRegisteredComponent=M};$.prototype.requireModule=function(e){var t=this["[[CurrentInstanceId]]"];if(t&&this.document&&this.document.taskCenter){if(N(e)){var n=e+"#"+t;if(!W[n]){var r=F[e],o={},i=function(n){Object.defineProperty(o,n,{enumerable:!0,configurable:!0,get:function(){return o=e,i=n,(a=l(r=t))&&"function"==typeof a.send?function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return a.send("module",{module:o,method:i},e)}:(console.error("[JS Framework] Failed to find taskCenter ("+r+")."),null);var r,o,i,a},set:function(r){return i=e,a=n,s=r,(c=l(o=t))&&"function"==typeof c.send?"function"!=typeof s?(console.error("[JS Framework] "+i+"."+a+" must be assigned as a function."),null):function(e){return c.send("module",{module:i,method:a},[e])}:(console.error("[JS Framework] Failed to find taskCenter ("+o+")."),null);var o,i,a,s,c}})};for(var a in r)i(a);W[n]=o}return W[n]}console.warn('[JS Framework] using unregistered weex module "'+e+'"')}else console.error('[JS Framework] Failed to requireModule("'+e+'"), instance ('+t+") doesn't exist anymore.")},$.prototype.supports=function(e){if("string"!=typeof e)return null;var t=e.match(/^@(\w+)\/(\w+)(\.(\w+))?$/i);if(t){var n=t[1],r=t[2],o=t[4];switch(n){case"module":return N(r,o);case"component":return M(r)}}return null};var X=/^\s*\/\/ *(\{[^}]*\}) *\r?\n/;function G(){return"0.23.7"}var K={};function Y(e){return K[e]}function Q(e,t,n){void 0===t&&(t={});var r=new $(e,t);Object.freeze(r);var o=t.bundleType||"Vue";K[e]=o;var i=q.frameworks[o];if(!i)return new Error('[JS Framework] Invalid bundle type "'+o+'".');!function(e,t,n){var r=l(e);if(r&&"function"==typeof r.send)if(t&&n){var o="jsfm."+t+"."+n;try{if(N("userTrack","addPerfPoint")){var i=Object.create(null);i[o]="4",r.send("module",{module:"userTrack",method:"addPerfPoint"},[i])}}catch(e){console.error('[JS Framework] Failed to trace "'+o+'"!')}}else console.warn("[JS Framework] Invalid track type ("+t+") or value ("+n+")");else console.error("[JS Framework] Failed to create tracker!")}(e,"bundleType",o);var a,s,c,d,u=(a=e,s={weex:r,config:t,created:Date.now(),framework:o,bundleType:o},c=q,(d=Object.create(null)).service=Object.create(null),T.forEach(function(e){var t=e.name,n=e.options.create;if(n)try{var r=n(a,s,c);Object.assign(d.service,r),Object.assign(d,r.instance)}catch(e){console.error("[JS Runtime] Failed to create service "+t+".")}}),delete d.service.instance,Object.freeze(d.service),d);Object.freeze(u);var f=Object.create(null);Object.assign(f,u,{weex:r,getJSFMVersion:G,__WEEX_CALL_JAVASCRIPT__:A,services:u}),Object.freeze(f);var h=Object.assign({},f);return"function"==typeof i.createInstanceContext&&Object.assign(h,i.createInstanceContext(e,f,n)),Object.freeze(h),h}var Z={createInstance:function(e,t,n,r){if(K[e])return new Error('The instance id "'+e+'" has already been used!');var o=function(e){var t=X.exec(e);if(t)try{return JSON.parse(t[1]).framework}catch(e){}return"Weex"}(t);K[e]=o,(n=JSON.parse(JSON.stringify(n||{}))).env=JSON.parse(JSON.stringify(global.WXEnvironment||{})),n.bundleType=o;var i=q.frameworks[o];if(!i)return new Error('[JS Framework] Invalid bundle type "'+o+'".');"Weex"===o&&console.error('[JS Framework] COMPATIBILITY WARNING: Weex DSL 1.0 (.we) framework is no longer supported! It will be removed in the next version of WeexSDK, your page would be crash if you still using the ".we" framework. Please upgrade it to Vue.js or Rax.');var a=Q(e,n,r);if("function"==typeof i.createInstance){if("Rax"===o||"Weex"===o){var s=Object.assign({config:n,created:Date.now(),framework:o},a);return i.createInstance(e,t,n,r,s)}return i.createInstance(e,t,n,r,a)}!function(e,t){var n=[],r=[];for(var o in t)n.push(o),r.push(t[o]);var i="\n (function (global) {\n "+e+"\n })(Object.create(this))\n ";(new(Function.prototype.bind.apply(Function,[null].concat(n,[i])))).apply(void 0,r)}(t,a)},createInstanceContext:Q,getRoot:function(e){var t=c(e);try{if(t&&t.body)return t.body.toJSON()}catch(e){return void console.error("[JS Framework] Failed to get the virtual dom tree.")}},getJSFMVersion:G,getDocument:c,registerService:_,unregisterService:R,callJS:function(e,t){var n=V[Y(e)];return n&&"function"==typeof n.receiveTasks?n.receiveTasks(e,t):A(e,t)}};function ee(e){Z[e]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var r,o=t[0],i=Y(o);if(i&&V[i]){var a=(r=V[i])[e].apply(r,t),s={framework:i};return"refreshInstance"===e?T.forEach(function(e){var t=e.options.refresh;t&&t(o,{info:s,runtime:q})}):"destroyInstance"===e&&(T.forEach(function(e){var t=e.options.destroy;t&&t(o,{info:s,runtime:q})}),delete K[o]),a}return new Error('[JS Framework] Using invalid instance id "'+o+'" when calling '+e+".")}}function te(e,t){Z[e]=function(){for(var n=[],r=arguments.length;r--;)n[r]=arguments[r];for(var o in"function"==typeof t&&t.apply(void 0,n),q.frameworks){var i=q.frameworks[o];i&&i[e]&&i[e].apply(i,n)}}}var ne={Document:B,Element:w,Comment:L,Listener:U,TaskCenter:O,sendTasks:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return"function"==typeof callNative?callNative.apply(void 0,e):(global.callNative||function(){}).apply(void 0,e)}};return B.handler=ne.sendTasks,{service:{register:_,unregister:R,has:D},freezePrototype:function(){Object.freeze(ne.Comment),Object.freeze(ne.Listener),Object.freeze(ne.Document.prototype),Object.freeze(ne.Comment.prototype),Object.freeze(ne.Listener.prototype)},init:function(e){for(var t in V=(q=e||{}).frameworks||{},function(){var e={createFinish:global.callCreateFinish,updateFinish:global.callUpdateFinish,refreshFinish:global.callRefreshFinish,createBody:global.callCreateBody,registerStyleSheets:global.callRegisterStyleSheets,addElement:global.callAddElement,removeElement:global.callRemoveElement,moveElement:global.callMoveElement,updateAttrs:global.callUpdateAttrs,updateStyle:global.callUpdateStyle,updateClassList:global.callUpdateClassList,addEvent:global.callAddEvent,removeEvent:global.callRemoveEvent},t=O.prototype,n=function(n){var r=e[n];t[n]=r?function(e,t){return r.apply(void 0,[e].concat(t))}:function(e,t){return C(e,[{module:"dom",method:n,args:t}],"-1")}};for(var r in e)n(r);t.componentHandler=global.callNativeComponent||function(e,t,n,r,o){return C(e,[{component:o.component,ref:t,method:n,args:r}])},t.moduleHandler=global.callNativeModule||function(e,t,n,r){return C(e,[{module:t,method:n,args:r}])}}(),V){var n=V[t];if("function"==typeof n.init)try{n.init(e)}catch(e){}}return te("registerComponents",J),te("registerModules",x),te("registerMethods"),["destroyInstance","refreshInstance"].forEach(ee),Z},config:ne}}); //# sourceMappingURL=index.min.js.map