blob: 199508fa728fc71ce55f6bc0176311877b6c7cf1 [file] [log] [blame]
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.WeexVanillaFramework=e.WeexVanillaFramework||{})}(this,function(e){"use strict";var n={},t={};e.init=function(e){n.Document=e.Document,n.Element=e.Element,n.Comment=e.Comment,n.sendTasks=e.sendTasks},e.createInstance=function(e,o,a,r,c){void 0===a&&(a={}),void 0===r&&(r={}),void 0===c&&(c={});var u=new n.Document(e,a.bundleUrl),i={},d={id:e,data:r,document:u,callbacks:i},s=0;u.addCallback=function(e){return s++,i[s]=e,s},u.handleCallback=function(e,n,t){var o=i[e];return t&&delete i[e],o(n)},t[e]=d;var l=Object.assign({Document:n.Document,Element:n.Element,Comment:n.Comment,sendTasks:function(t){return n.sendTasks(e,t,-1)},options:a,document:u},c),f=[],m=[];for(var p in l)f.push(p),m.push(l[p]);return f.push(o),(new(Function.prototype.bind.apply(Function,[null].concat(f)))).apply(void 0,m),n.sendTasks(e,[{module:"dom",method:"createFinish",args:[]}],-1),d},e.destroyInstance=function(e){delete t[e]},e.getRoot=function(e){return t[e].document.body.toJSON()},e.receiveTasks=function(e,n){var o={fireEvent:function(e,n,o,a,r){var c=t[e].document,u=c.getRef(n);return c.fireEvent(u,o,a,r)},callback:function(e,n,o,a){return t[e].document.handleCallback(n,o,a)}};if((t[e]||{}).document&&Array.isArray(n)){var a=[];return n.forEach(function(n){var t=o[n.method],r=[].concat(n.args);"function"==typeof t&&(r.unshift(e),a.push(t.apply(void 0,r)))}),a}},Object.defineProperty(e,"__esModule",{value:!0})});