/*
MagJS v0.24.6
http://github.com/magnumjs/mag.js
(c) Michael Glazer
License: MIT
*/
(function(mag, global) {

  function proxyAssign(obj, cb) {
    var last = [];

    return new Proxy(obj, {
      get: function(proxy, name) {
        var retval = proxy[name],
          val = cb({
            type: 'get',
            object: mag.utils.copy(typeof proxy[name] == 'object' ? proxy[name]: proxy),
            name: name,
            oldValue: last[name]
          })
        if (typeof val != 'undefined') retval =proxy[name]=val;
        return retval;
      },
      deleteProperty: function(proxy, name) {
        cb({
          type: 'delete',
          name: name,
          object: proxy,
          oldValue: last[name]
        })
        return delete proxy[name]
      },
      set: function(proxy, name, value) {
        //prevent recursion
        if(last[name] === value && name !== 'length') return true;
        if (name !== 'length' && JSON.stringify(value) !== JSON.stringify(proxy[name])) {
          last[name] = mag.utils.copy(proxy[name]);
        }

        cb({
          type: 'set',
          name: name,
          object: proxy,
          oldValue: last[name]
        });
        proxy[name] = value;
        return true;
      }
    });

  }

  function observer(obj, cb) {
    //TODO: too expensive maybe on small objects?

    for (var k in obj) {
      if (Array.isArray(obj[k]) && obj[k].length < 101) {
        // assign
        obj[k] = proxyAssign(obj[k], cb)
      }
    }

    return proxyAssign(obj, cb)
  }

  mag.proxy = function(obj, callback) {
    if (obj && global.Proxy) {

      var handler = function(change) {

        if (typeof change.object[change.name] == 'object') {
          change.object[change.name] = mag.proxy(change.object[change.name], callback);
        }

        return callback(change);
      };

      return observer(obj, handler);
    }
  }

}(mag, window || global || this));

@@ -12,9 +12,9 @@
 .24.
-6
+7
 %0Ahtt
@@ -158,16 +158,114 @@
 t = %5B%5D;%0A
+    var proxies = new WeakSet();%0A%0A    function isProxy(obj) %7B%0A      return proxies.has(obj);%0A    %7D
 %0A    ret
@@ -352,17 +352,18 @@
 xy%5Bname%5D
-,
+;%0A
 %0A       
@@ -367,137 +367,581 @@
     
-  val = cb(%7B%0A            type: 'get',%0A            object: mag.utils.copy(typeof proxy%5Bname%5D
+if (typeof name == 'symbol') return retval;%0A%0A%0A        //check for sub objects%0A        if (typeof retval === 'object' && typeof retval !== 'symbol' && retval !== null && typeof retval !== 'function' && !Array.isArray(retval) && retval.toString()
  == '
+%5B
 object
-' ? proxy%5Bname%5D: proxy),%0A  
+ Object%5D' && !retval.then && !retval.draw) %7B%0A%0A          if (!isProxy(retval)) %7B%0A            // console.info('INNER', name, retval);%0A            proxies.add(retval);%0A            return mag.proxy(retval, cb);%0A          %7D%0A        %7D%0A%0A        var val = cb(%7B%0A          type: 'get',%0A          object: mag.utils.copy(proxy),%0A
     
@@ -950,34 +950,32 @@
     name: name,%0A
-  
           oldVal
@@ -985,26 +985,24 @@
  last%5Bname%5D%0A
-  
         %7D)%0A 
@@ -1051,20 +1051,9 @@
 al =
-proxy%5Bname%5D=
+ 
 val;
@@ -1340,24 +1340,25 @@
 e, value) %7B%0A
+%0A
         //pr
@@ -1383,16 +1383,17 @@
       if
+ 
 (last%5Bna
@@ -1895,24 +1895,57 @@
 k in obj) %7B%0A
+      var stype = typeof obj%5Bk%5D;%0A
       if (Ar
@@ -2049,16 +2049,247 @@
 k%5D, cb)%0A
+      %7D else if (stype == 'object' && obj%5Bk%5D !== null && typeof k != 'symbol' && stype != 'symbol' && typeof k != 'symbol' && stype != 'function' && obj%5Bk%5D.toString() == '%5Bobject Object%5D') %7B%0A        obj%5Bk%5D = mag.proxy(obj%5Bk%5D, cb);%0A
       %7D%0A
@@ -2443,32 +2443,35 @@
 ange) %7B%0A%0A       
+ //
  if (typeof chan
@@ -2511,24 +2511,27 @@
 ') %7B%0A       
+ //
    change.ob
@@ -2598,32 +2598,35 @@
 llback);%0A       
+ //
  %7D%0A%0A        retu

Update mag-proxy.js