Skip to content
Browse files

browser build

  • Loading branch information...
1 parent b6b2c47 commit f04a7792b8af1ac0ec0a9d44afaab69168084b4c @Benvie committed May 23, 2012
Showing with 164 additions and 173 deletions.
  1. +3 −2 browser/build.js
  2. +159 −169 meta-objects.browser.js
  3. +1 −1 meta-objects.browser.min.js
  4. +1 −1 package.json
View
5 browser/build.js
@@ -13,6 +13,7 @@ var names = [
'callable',
'interceptor',
'doppelganger',
+ 'namespace',
];
var ret = names.map(function(name){
return name+': '+name;
@@ -26,9 +27,9 @@ var libs = names.map(function(name){
var output = [
'var meta = function(global){',
- libs.join('\n\n'),
+ libs.join('\n\n'),
'return { ' + ret.join(', ') + ' }',
- '}(Function("return this")());'
+ '}(this);'
].join('\n');
fs.writeFileSync('../meta-objects.browser.js', output);
View
328 meta-objects.browser.js
@@ -90,18 +90,20 @@ function merge(to, from){
var desc = value();
keys(from).forEach(function(key){
- desc.value = from[key];
- define(to, key, desc);
+ if (!hasOwn(to, key)) {
+ desc.value = from[key];
+ define(to, key, desc);
+ }
});
return to;
}
function isObject(o){
- return Object(o) === o;
+ return o !== null && typeof o === 'object' || typeof o === 'function';
}
function isPrimitive(o){
- return Object(o) !== o;
+ return o == null || !(typeof o === 'object' || typeof o === 'function');
}
function getPropertyDescriptor(o,n){
@@ -396,8 +398,10 @@ var Emitter = function(O){
function _(o){
if (!emitters.has(o)) {
+ var ret = {};
receivers.set(o, o);
- return emitters.set(o, {});
+ emitters.set(o, ret);
+ return ret;
} else {
return emitters.get(o);
}
@@ -464,9 +468,9 @@ var Emitter = function(O){
},
emit: function emit(type){
var event, events = _(this);
- if (typeof type !== 'string') {
+ if (typeof type !== 'string' && type.type) {
event = type;
- type = event.type;
+ type = type.type;
}
if (events['*']) {
var listeners = events[type] ? events['*'].concat(events[type]) : events['*'];
@@ -508,7 +512,7 @@ var proxy = function(O){
wmset = Function.callbind(WeakMap.prototype.set),
wmdelete = Function.callbind(WeakMap.prototype.delete),
wmhasget = function hasget(wm, obj){
- return (Object.isObject(obj) && wmhas(wm, obj)) ? wmget(wm, obj) : obj;
+ return Object.isObject(obj) && (wm = wmget(wm, obj)) === undefined ? obj : wm;
};
var checkArray = function(){
@@ -531,45 +535,23 @@ var proxy = function(O){
var checkToString = function(){
var wrapped = new WeakMap;
- var FtoString = function toString(){
- return Function.stringify(wmhasget(wrapped, this));
- }
-
- var OtoString = function toString(){
- return Object.stringify(wmhasget(wrapped, this));
- }
-
- var DtoString = function toString(){
- return Date.stringify(wmhasget(wrapped, this));
- }
-
-
- wmset(wrapped, FtoString, Function.prototype.toString);
- wmset(wrapped, OtoString, Object.prototype.toString);
- wmset(wrapped, DtoString, Date.prototype.toString);
-
- Function.prototype.toString = FtoString;
- Object.prototype.toString = OtoString;
- Date.prototype.toString = DtoString;
+ [Function, RegExp, Object, Date].forEach(function(Ctor){
+ function toString(){
+ return Ctor.stringify(wmhasget(wrapped, this));
+ }
+ wmset(wrapped, toString, Ctor.prototype.toString);
+ Ctor.prototype.toString = toString;
+ });
return function(o,p){
wmset(wrapped, p, o);
}
}();
-
- var definer = function(valueOnly, normal){
- return function definer(o, n, v, newDesc){
- if (newDesc && !Object.isExtensible(o))
- return false;
-
- var desc = newDesc ? normal : valueOnly;
- desc.value = v;
- O.define(o, n, desc);
- desc.value = null;
- return true;
- }
- }({}, Descriptor.value());
+ function definer(o, n, v, newDesc){
+ o[n] = v;
+ return true;
+ }
function setter(desc, rcvr, val){
var exists = desc.set != null;
@@ -621,7 +603,13 @@ var proxy = function(O){
if (N === '__proto__')
return O.getProto(T);
- var desc = O.describe(T,N);
+ try {
+ // Firefox fails here due to XPConnectWrapper interacting poorly with WeakMap/Proxy
+ var desc = O.describe(T,N);
+ } catch (e) {
+ return R[N];
+ }
+
if (desc == null) {
var proto = O.getProto(T);
if (proto != null)
@@ -643,7 +631,13 @@ var proxy = function(O){
if (N === '__proto__')
return Object.isObject(V) ? (T.__proto__ = V) && true : false;
- var oDesc = O.describe(T,N);
+ try {
+ // Firefox fails here due to XPConnectWrapper interacting poorly with WeakMap/Proxy
+ var oDesc = O.describe(T,N)
+ } catch (e) {
+ R[N] = V;
+ return true;
+ }
if (oDesc) {
// existing own desc
if (Descriptor.isAccessor(oDesc))
@@ -711,21 +705,19 @@ var proxy = function(O){
trap = trapMap[trap];
var trapHandler = handler[trap];
- return function(){
+ return function finalize(){
var args = Array.slice(arguments);
if (trap === 'get' || trap === 'set') {
args = Array.concat(args.slice(1), args[0]);
- if (args[0] === 'splice')
- return Function.applying(forwarder[trap], handler, [target].concat(args));
if (args[0] === '__proto__')
trapHandler = handler.proto;
}
if (typeof trapHandler !== 'function')
return Function.applying(forwarder[trap], handler, [target].concat(args));
else
- return Function.applying(trapHandler, handler, [makeFwd(args, trap), target].concat(args));
+ return trapHandler.apply(handler, [makeFwd(args, trap), target].concat(args));
}
}
});
@@ -764,21 +756,25 @@ var membrane = function(O, proxy, WrapMap){
if (WrapMap === null)
WrapMap = require('./WrapMap');
+ var fakehandler = {};
function membrane(handlers){
- if (Object.isPrimitive(handlers)) throw new Error('Handlers must be provided');
+ if (Object.isPrimitive(handlers))
+ throw new Error('Handlers must be provided');
var wrapper = new WrapMap(function(target){
//var protoCeptor = typeof target === 'function' ? function(){} : Object.create(wrapper.wrap(Object.getPrototypeOf(target)));
- return proxy(target, proxy({}, {
- get: function(f, t, trap){
- return function(fwd, faketarget){
+ return proxy(target, proxy(fakehandler, {
+ get: function membraneHandlerGet(f, t, trap){
+ return function membraneMetaHandler(fwd, faketarget){
var handler = handlers[trap];
var args = Array.slice(arguments);
- args[1] = fwd.target = wrapper.unwrap(target);
+ args[1] = fwd.target = wrapper.unwrap(faketarget);
if (handler) {
var origfwd = fwd;
- fwd = function fwd(){ return Function.applying(handler, handlers, args); }
+ fwd = function fwd(){
+ return Function.applying(handler, handlers, args);
+ };
fwd.args = origfwd.args;
}
return Function.applying(wrapHandler[trap], null, Array.concat([fwd], Array.slice(args, 1)));
@@ -788,49 +784,56 @@ var membrane = function(O, proxy, WrapMap){
});
- function forward(fwd){ return fwd() }
+
+ function forward(fwd){
+ return fwd();
+ }
var wrapHandler = {
names: forward,
enumerate: forward,
keys: forward,
delete: forward,
- has: forward,
owns: forward,
- proto: function(fwd, target){
+ has: function has(){
+ // spidermonkey fails on get/set for proxies as prototypes without this
+ return true;
+ },
+ proto: function proto(fwd, target){
return wrapper.wrap(fwd());
},
- fix: function(fwd, target){
+ fix: function fix(fwd, target){
throw target;
},
- define: function(fwd, target, name, desc){
+ define: function define(fwd, target, name, desc){
wrapper.unwrap(desc, true);
return fwd();
},
- describe: function(fwd, target, name){
+ describe: function describe(fwd, target, name){
return wrapper.wrap(fwd(), true);
},
- get: function(fwd, target, name, rcvr){
+ get: function get(fwd, target, name, rcvr){
+ fwd.args[1] = wrapper.unwrap(rcvr);
return wrapper.wrap(fwd());
},
- set: function(fwd, target, name, val, rcvr){
+ set: function set(fwd, target, name, val, rcvr){
fwd.args[1] = wrapper.unwrap(val);
fwd.args[2] = wrapper.unwrap(rcvr);
return fwd();
},
- apply: function(fwd, target, args, rcvr){
+ apply: function apply(fwd, target, args, rcvr){
fwd.args[0] = Array.map(args, wrapper.unwrap);
fwd.args[1] = wrapper.unwrap(rcvr);
return wrapper.wrap(fwd());
},
- construct: function(fwd, target, args){
+ construct: function construct(fwd, target, args){
fwd.args[0] = Array.map(args, wrapper.unwrap);
return wrapper.wrap(fwd());
}
};
return wrapper;
- }
+ };
return membrane;
}(typeof O === 'undefined' ? require('./utility') : O, typeof proxy === 'undefined' ? null : proxy, typeof WrapMap === 'undefined' ? null : WrapMap);
@@ -1008,97 +1011,16 @@ var tracer = function(O, proxy, membrane, Emitter){
if (Emitter === null)
Emitter = require('./Emitter');
-
-
- var builtins = new WeakMap;
- var ids = new WeakMap;
- ids.id = 0;
- function tag(obj){
- return ids.has(obj) ? ids.get(obj) : ids.set(obj, ids.id++);
- }
-
- // function initBuiltins(){
-
- // function addAll(obj, path){
- // tag(obj);
- // Object.getOwnPropertyNames(obj).forEach(function(name){
- // if (name === 'arguments' || name === 'caller' || name ==='callee')
- // return;
- // var val = obj[name];
- // if (Object.isObject(val) && !builtins.has(val))
- // addAll(val, builtins.set(val, (path || []).concat(name)));
- // });
- // }
-
- // [Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError,
- // Array, Boolean, Date, Function, Map, Number, Object, Proxy, Set, String, WeakMap, Math, JSON,
- // decodeURI, decodeURIComponent, encodeURI, encodeURIComponent, escape, eval,
- // isFinite, isNaN, parseFloat, parseInt, unescape
- // ].forEach(function(builtin){
- // tag(builtin);
- // var path = ['@'+(builtin.name || (builtin+'').slice(8, -1))];
- // builtins.set(builtin, path);
- // addAll(builtin, path);
- // });
-
- // ['document', 'navigator', 'location'].forEach(function(name){
- // if (Object.isObject(global[name])) {
- // tag(global[name]);
- // builtins.set(global[name], ['@'+name]);
- // }
- // });
- // }
-
- //initBuiltins();
-
function TraceEmitter(object, name){
- if (!(this instanceof TraceEmitter))
- return new TraceEmitter(object, name);
-
- var self = this;
+ var self = this instanceof TraceEmitter ? this : Object.create(TraceEmitter.prototype);
- var names = new WeakMap;
- var instances = new WeakMap;
name = name || 'root';
- names.set(object, [name]);
-
Emitter.call(this);
-
- var managers = {
- get: function(target, prop, path, ret){
- if (Object.isObject(ret) && !names.has(ret))
- names.set(ret, path.concat(prop));
- },
- apply: function(target, args, path, ret){
- if (Object.isObject(ret) && !names.has(ret))
- names.set(ret, [path[path.length-1], '%']);
- },
- describe: function(target, prop, path, ret){
- if (Object.isObject(ret.value))
- names.set(ret.value, path.concat(prop));
- if (Object.isObject(ret.get))
- names.set(ret.get, path.concat(prop+'[getter]'));
- if (Object.isObject(ret.set))
- names.set(ret.set, path.concat(prop+'[setter]'));
- },
- construct: function(target, prop, path, ret){
- var num = instances.has(target) ? instances.get(target) + 1 : 0;
- instances.set(target, num);
- names.set(ret, (path || []).concat('^'+num));
- }
- };
-
var wrapper = membrane(proxy({}, {
get: function get(f,t,trap){
return function(fwd, target, prop){
var ret = fwd();
- var path = builtins.has(target) ? builtins.get(target) : names.get(target);
- var args = fwd.args;
-
- if (managers[trap])
- managers[trap](target, prop, path, ret);
-
- self.emit(new TraceEvent(trap, target, args, ret, path));
+ self.emit(new TraceEvent(trap, target, fwd.args, ret));
return ret;
}
}
@@ -1111,23 +1033,32 @@ var tracer = function(O, proxy, membrane, Emitter){
TraceEmitter.prototype = Object.create(Emitter.prototype);
TraceEmitter.prototype.constructor = TraceEmitter;
- function TraceEvent(type, target, args, result, path){
- Emitter.Event.apply(this, arguments);
- this.id = tag(target);
+ function TraceEvent(type, target, args, result){
+ this.type = type;
+ this.target = target;
this.result = result;
- this.path = path;
- if (type === 'construct' || type === 'apply') {
- this.args = args[0];
- } else if (type !== 'keys' && type !== 'names' && type !== 'enumerate' && type !== 'fix') {
- this.property = args[0];
- }
- if (type === 'define' || type === 'set') {
- this.value = args[1];
- }
- if (type === 'get' || type === 'apply') {
- this.receiver = args[1];
- } else if (type === 'set') {
- this.receiver = args[2];
+
+ var i = 0;
+ switch (type) {
+ case 'keys':
+ case 'names':
+ case 'enumerate':
+ case 'fix':
+ break;
+ case 'set':
+ case 'define':
+ if (this.result === true)
+ delete this.result;
+ this.value = args[1];
+ case 'get':
+ case 'describe':
+ this.property = args[0];
+ break;
+ case 'apply':
+ this.context = args[1];
+ case 'construct':
+ this.name = target.name;
+ this.args = args[0];
}
}
@@ -1166,17 +1097,15 @@ var callable = function(O, proxy){
names: list,
apply: function(fwd, target, args, rcvr){
var call = target.$$call;
- if (call) {
- return apply(call, target, args);
- }
+ return call ? apply(call, target, args) : undefined;
},
construct: function(fwd, target, args){
var construct = target.$$construct;
var instance = proxy(create(target), handler, true);
if (construct) {
var result = apply(construct, instance, args);
return isObject(result) ? result : instance;
- } else{
+ } else {
return instance;
}
}
@@ -1615,5 +1544,66 @@ var doppelganger = function(O, proxy){
if (typeof module !== 'undefined')
module.exports = doppelganger;
-return { WrapMap: WrapMap, Emitter: Emitter, proxy: proxy, membrane: membrane, multiherit: multiherit, tracer: tracer, callable: callable, interceptor: interceptor, doppelganger: doppelganger }
-}(Function("return this")());
+
+var namespace = function(O){
+
+ function frozen(o){
+ return Object.preventExtensions(O.names(o).reduce(function(r,s){
+ var desc = O.describe(o, s);
+ desc.enumerable = desc.configurable = false;
+ if ('value' in desc)
+ desc.writeable = false;
+ return O.define(r, s, desc);
+ }, O()));
+ }
+
+ function Store(values){
+ if (Object.isObject(values))
+ this.set(values);
+ }
+
+ Store.prototype = frozen({
+ set: function set(key, value){
+ if (Object.isObject(key))
+ Object.keys(key).forEach(function(k){
+ this[k] = key[k];
+ }, this);
+ else
+ this[key] = value;
+ },
+ get: function get(key){
+ if (Array.isArray(key))
+ return key.reduce(function(r,k){
+ r[k] = this[k];
+ return r;
+ }.bind(this), {});
+ else
+ return this[key];
+ },
+ toString: function toString(){
+ return '[object Store]';
+ },
+ valueOf: Object.prototype.valueOf
+ });
+
+
+ return function namespace(){
+ var storage = new WeakMap;
+ return function unwrap(obj, values){
+ var ret = storage.get(obj);
+ if (!ret) {
+ ret = new Store(values);
+ storage.set(obj, ret);
+ }
+ return ret;
+ };
+ };
+
+}(typeof O === 'undefined' ? require('./utility') : O);
+
+
+if (typeof module !== 'undefined')
+ module.exports = namespace;
+
+return { WrapMap: WrapMap, Emitter: Emitter, proxy: proxy, membrane: membrane, multiherit: multiherit, tracer: tracer, callable: callable, interceptor: interceptor, doppelganger: doppelganger, namespace: namespace }
+}(this);
View
2 meta-objects.browser.min.js
@@ -1 +1 @@
-var meta=function(global){if(typeof module!="undefined"&&module.O)return module.exports=module.O;var FP=Function.prototype,OP=Object.prototype,AP=Array.prototype,bindbind=FP.bind.bind(FP.bind),callbind=bindbind(FP.call),applybind=bindbind(FP.apply),calling=callbind(FP.call),binding=callbind(FP.bind),applying=callbind(FP.apply),hasOwn=callbind(OP.hasOwnProperty),flatten=applybind(AP.concat,[]),concat=callbind(AP.concat),map=callbind(AP.map),define=Object.defineProperty,defines=Object.defineProperties,describe=Object.getOwnPropertyDescriptor,describeAny=getPropertyDescriptor,names=Object.getOwnPropertyNames,namesAny=getPropertyNames,keys=Object.keys,getProto=Object.getPrototypeOf,create=Object.create,types=[Array,Boolean,Date,Function,Map,Number,Object,RegExp,Set,String,WeakMap];function Descriptor(type,valueOrGet,readonlyOrSet,hidden,frozen){this[type?"setAccessors":"setValue"](valueOrGet,readonlyOrSet),hidden&&(this.enumerable=!1),frozen&&(this.configurable=!1)}Descriptor.VALUE=0,Descriptor.ACCESSOR=1,Descriptor.prototype={constructor:Descriptor,configurable:!0,enumerable:!0,setValue:function setValue(value,readonly){this.value=value,this.writable=!readonly},setAccessors:function setAccessors(get,set){this.get=get,this.set=set}};function value(v,h,r,f){return new Descriptor(0,v,r,h,f)}function hiddenValue(v,r,f){return new Descriptor(0,v,r,!0,f)}function accessor(g,s,h,f){return new Descriptor(1,g,s,h,f)}function hiddenAccessor(g,s,f){return new Descriptor(1,g,s,!0,f)}function isAccessor(desc){return isObject(desc)&&("get"in desc||"set"in desc)&&!("value"in desc)}function isValue(desc){return isObject(desc)&&!("get"in desc||"set"in desc)&&"value"in desc}function merge(to,from){if(~types.indexOf(to)||keys(to).length===0&&names(to)>0)var desc=hiddenValue();else var desc=value();return keys(from).forEach(function(key){desc.value=from[key],define(to,key,desc)}),to}function isObject(o){return Object(o)===o}function isPrimitive(o){return Object(o)!==o}function getPropertyDescriptor(o,n){while(isObject(o)){var desc=describe(o,n);if(desc)return desc;o=getProto(o)}return undefined}function getPropertyNames(o){var out=[];while(isObject(o))out.push(names(o)),o=getProto(o);return unique(flatten(out))}function parameters(fn){return(fn+="").slice(fn.indexOf("(")+1,fn.indexOf(")")).split(/\s*,\s*/)}function unique(a){return keys(a.reduce(function(r,s){return r[s]=1,r},{}))}var slice=function(){var _slice=[].slice;return function slice(a,o,p){switch(a.length){case 0:return[];case 1:return o?[]:[a[0]];default:return _slice.call(a,o,p);case 2:a=[a[0],a[1]];break;case 3:a=[a[0],a[1],a[2]];break;case 4:a=[a[0],a[1],a[2],a[3]];break;case 5:a=[a[0],a[1],a[2],a[3],a[4]];break;case 6:a=[a[0],a[1],a[2],a[3],a[4],a[5]];break;case 7:a=[a[0],a[1],a[2],a[3],a[4],a[5],a[6]];break;case 8:a=[a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7]];break;case 9:a=[a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8]];break;case 10:a=[a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9]];break;case 11:a=[a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10]];break;case 12:a=[a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11]];break;case 13:a=[a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12]];break;case 14:a=[a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13]]}return o||p?a.slice(o,p):a}}(),brandname=function(){var brands={};return types.forEach(function(Ctor){hasOwn(Ctor.prototype,"toString")&&define(Ctor,"stringify",hiddenValue(callbind(Ctor.prototype.toString))),brands["[object "+Ctor.name+"]"]=Ctor.prototype}),function brandname(o){var brand=Object.stringify(o);return brand in brands?brands[brand]:brand}}();define(global,"Descriptor",hiddenValue(Descriptor)),merge(Descriptor,{value:value,hiddenValue:hiddenValue,accessor:accessor,hiddenAccessor:hiddenAccessor,isValue:isValue,isAccessor:isAccessor}),merge(Object,{isObject:isObject,isPrimitive:isPrimitive,getPropertyDescriptor:getPropertyDescriptor,getPropertyNames:getPropertyNames,hasOwn:hasOwn,merge:merge,brandname:brandname}),merge(Function,{parameters:parameters,bindbind:bindbind,callbind:callbind,applybind:applybind,calling:calling,binding:binding,applying:applying}),merge(Array,{unique:unique,slice:slice,flatten:flatten,concat:concat,map:map});function O(v){var out=Object.create(null);return isObject(v)&&merge(out,v),out}Object.merge(O,{isobj:Object.isObject,notobj:Object.isPrimitive,create:Object.create,define:Object.defineProperty,defines:Object.defineProperties,getProto:Object.getPrototypeOf,describeAny:Object.getPropertyDescriptor,describe:Object.getOwnPropertyDescriptor,namesAny:Object.getPropertyNames,names:Object.getOwnPropertyNames,keys:Object.keys,has:Object.hasOwn}),typeof module!="undefined"&&(module.O=module.exports=O);if(typeof WeakMap=="undefined")throw Error("WeakMaps unsupported");var WrapMap=function(O){"use strict";function lookup(o){if(!wrapmaps.has(o))throw new TypeError("WrapMaps are not generic");return wrapmaps.get(o)}var wrapmaps=new WeakMap;function WrapMap(wrapper){var wrapped=new WeakMap,unwrapped=new WeakMap;if(typeof wrapper=="function")var wrap=function wrap(o,isDescriptor){if(isDescriptor===!0)return wrapDescriptor(o);if(Object.isPrimitive(o)||wrapped.has(o))return o;if(unwrapped.has(o))return unwrapped.get(o);var p=wrapper(o);return Object.isObject(p)&&(wrapped.set(p,o),unwrapped.set(o,p)),p};else var wrap=function wrap(o,p){return Object.isPrimitive(o)||wrapped.has(o)?o:unwrapped.has(o)?unwrapped.get(o):(Object.isObject(p)&&(wrapped.set(p,o),unwrapped.set(o,p)),p)};function unwrap(o,isDescriptor){return isDescriptor===!0?unwrapDescriptor(o):Object.isPrimitive(o)||!wrapped.has(o)?o:wrapped.get(o)}function has(o){return Object.isObject(o)&&wrapped.has(o)}function remove(o){var p=unwrap(o);return o!==p&&wrapped.delete(o),p}function wrapDescriptor(o){return Object.isObject(o)&&!wrapped.has(o)&&(o.value&&(o.value=wrap(o.value)),o.set&&(o.set=wrap(o.set)),o.get&&(o.get=wrap(o.get))),o}function unwrapDescriptor(o){return Object.isObject(o)&&wrapped.has(o)&&(o.value&&(o.value=unwrap(o.value)),o.set&&(o.set=unwrap(o.set)),o.get&&(o.get=unwrap(o.get))),o}var self=this===global?Object.create(WrapMap.prototype):this;return self.wrap=wrap,self.unwrap=unwrap,self.remove=remove,self.has=has,wrapmaps.set(self,{wrap:wrap,unwrap:unwrap,remove:remove,has:has}),self}return WrapMap.prototype={constructor:WrapMap,wrap:function wrap(o,p){return lookup(this).wrap(o,p)},unwrap:function unwrap(o){return lookup(this).unwrap(o)},remove:function remove(o){return lookup(this).remove(o)},has:function has(o){return lookup(this).has(o)}},WrapMap}(typeof O=="undefined"?require("./utility"):O);typeof module!="undefined"&&(module.exports=WrapMap);var Emitter=function(O){"use strict";function Event(type,target){this.type=type,this.target=target}function ErrorEvent(error,event,target){Event.call(this,"error",target),this.error=error,this.event=event}var emitters=new WeakMap,receivers=new WeakMap;function _(o){return emitters.has(o)?emitters.get(o):(receivers.set(o,o),emitters.set(o,{}))}function Emitter(){emitters.set(this,{}),receivers.set(this,this)}return Emitter.Event=Event,Emitter.forward=function forward(from,to){emitters.has(to)||(emitters.set(to,{}),receivers.set(to,to)),emitters.set(from,emitters.get(to)),from.on=Emitter.prototype.on.bind(to),from.off=Emitter.prototype.off.bind(to)},Emitter.prototype={constructor:Emitter,on:function on(events,listener){var listeners=_(this);events.split(" ").forEach(function(event){event in listeners?listeners[event].push(listener):listeners[event]=[listener]})},off:function off(events,listener){var listeners=_(this);events.split(" ").forEach(function(event){listeners[event]&&listeners[event].splice(listeners[event].indexOf(listener),1)})},offAll:function offAll(event){delete _(this)[event]},once:function once(event,listener){var self=this;this.on(event,function(){return self.off(event,listener),listener.apply(receivers.get(self),arguments)})},isListened:function isListened(type){var events=_(this),listeners=events[type]||events["*"];return Boolean(listeners&&listeners.length)},emit:function emit(type){var event,events=_(this);typeof type!="string"&&(event=type,type=event.type);if(events["*"])var listeners=events[type]?events["*"].concat(events[type]):events["*"];else var listeners=events[type];if(listeners&&listeners.length){event=event||new Event(type,receivers.get(this));var args=[event].concat(Array.slice(arguments,1));for(var i=0;i<listeners.length;i++)try{listeners[i].apply(this,args)}catch(e){this.emit(new ErrorEvent(e,event,listeners[i]))}}}},Emitter}(typeof O=="undefined"?require("./utility"):O);typeof module!="undefined"&&(module.exports=Emitter);if(typeof Proxy!="object")throw Error("Proxies unsupported");var proxy=function(O){"use strict";var createProxyObject=Proxy.create,createProxyFunction=Proxy.createFunction,wmhas=Function.callbind(WeakMap.prototype.has),wmget=Function.callbind(WeakMap.prototype.get),wmset=Function.callbind(WeakMap.prototype.set),wmdelete=Function.callbind(WeakMap.prototype.delete),wmhasget=function hasget(wm,obj){return Object.isObject(obj)&&wmhas(wm,obj)?wmget(wm,obj):obj},checkArray=function(){var wrapped=new WeakMap,isArr=Array.isArray;return Array.isArray=function isArray(){var a=arguments[0];return isArr(a)?!0:Object.isPrimitive(a)?!1:wmhas(wrapped,a)},function(o,p){isArr(o)&&wmset(wrapped,o,!0)}}(),checkToString=function(){var wrapped=new WeakMap,FtoString=function toString(){return Function.stringify(wmhasget(wrapped,this))},OtoString=function toString(){return Object.stringify(wmhasget(wrapped,this))},DtoString=function toString(){return Date.stringify(wmhasget(wrapped,this))};return wmset(wrapped,FtoString,Function.prototype.toString),wmset(wrapped,OtoString,Object.prototype.toString),wmset(wrapped,DtoString,Date.prototype.toString),Function.prototype.toString=FtoString,Object.prototype.toString=OtoString,Date.prototype.toString=DtoString,function(o,p){wmset(wrapped,p,o)}}(),definer=function(valueOnly,normal){return function definer(o,n,v,newDesc){if(newDesc&&!Object.isExtensible(o))return!1;var desc=newDesc?normal:valueOnly;return desc.value=v,O.define(o,n,desc),desc.value=null,!0}}({},Descriptor.value());function setter(desc,rcvr,val){var exists=desc.set!=null;return exists&&Function.calling(desc.set,rcvr,val),exists}function configurable(desc){return desc&&(desc.configurable=!0),desc}var trapMap={getOwnPropertyDescriptor:"describe",getOwnPropertyNames:"names",getPropertyNames:"names",defineProperty:"define","delete":"delete",fix:"fix",keys:"keys",enumerate:"enumerate",hasOwn:"owns",has:"has",get:"get",set:"set",apply:"apply",construct:"construct"},forwarder={proto:function(T){return O.getProto(T)},describe:function(T,N){return configurable(O.describe(T,N))},define:function(T,N,D){return O.define(T,N,D),!0},"delete":function(T,N){return delete T[N]},fix:function(T){return Object.freeze(T)},keys:function(T){return O.keys(T)},names:function(T){return O.names(T)},enumerate:function(T){var i=0,a=[];for(a[i++]in T);return a},owns:function(T,N){return O.has(T,N)},has:function(T,N){return N in T},get:function(T,N,R){var handler=wmget(proxies,T);if(handler!=null)return wmget(handler,R,N);if(N==="__proto__")return O.getProto(T);var desc=O.describe(T,N);if(desc==null){var proto=O.getProto(T);if(proto!=null)return forwarder.get(proto,N,R)}else{if(Descriptor.isValue(desc))return desc.value;if(Descriptor.isAccessor(desc)&&typeof desc.get=="function")return Function.calling(desc.get,R)}return undefined},set:function(T,N,V,R){var handler=wmget(proxies,T);if(handler!=null)return handler.set(R,N,V);if(N==="__proto__")return Object.isObject(V)?(T.__proto__=V)&&!0:!1;var oDesc=O.describe(T,N);if(oDesc)return Descriptor.isAccessor(oDesc)?setter(oDesc,R,V):oDesc.writable?definer(R,N,V,R!==T):!1;var proto=O.getProto(T);return proto===null?definer(R,N,V,!0):forwarder.set(proto,N,V,R)},apply:function(T,A,R){return Function.applying(T,R,A)},construct:function(T,A){var handler=wmget(proxies,T);if(handler!=null)return handler.construct(T,A);var result=new(Function.applying(Function.bind,T,[null].concat(A)));return Object.isObject(result)?result:O.create(T.prototype)}},proxies=new WeakMap,targets=new WeakMap;function proxy(target,handler,callable){if(!Object.isObject(target))throw new TypeError("Target must be an object");if(!Object.isObject(handler))throw new TypeError("Handler must be an object");function makeFwd(args,trap){var fwd=function(){return Function.applying(forwarder[fwd.trap],handler,[fwd.target].concat(fwd.args))};return fwd.target=target,fwd.args=args,fwd.trap=trap,fwd}var metaHandler=createProxyObject({get:function get(R,trap){if(trap==="getPropertyDescriptor")return function(n){return configurable(get(null,"getOwnPropertyDescriptor")(n)||O.describeAny(O.getProto(target)))};if(trap==="getPropertyNames")return function(){return Array.unique(get(null,"getOwnPropertyNames")().concat(O.namesAny(O.getProto(target))))};trap=trapMap[trap];var trapHandler=handler[trap];return function(){var args=Array.slice(arguments);if(trap==="get"||trap==="set"){args=Array.concat(args.slice(1),args[0]);if(args[0]==="splice")return Function.applying(forwarder[trap],handler,[target].concat(args));args[0]==="__proto__"&&(trapHandler=handler.proto)}return typeof trapHandler!="function"?Function.applying(forwarder[trap],handler,[target].concat(args)):Function.applying(trapHandler,handler,[makeFwd(args,trap),target].concat(args))}}});if(callable===!0||callable==null&&typeof target=="function")var reflectProxy=createProxyFunction(metaHandler,function(){return metaHandler.apply(Array.slice(arguments),this)},function(){return metaHandler.construct(Array.slice(arguments))});else var reflectProxy=createProxyObject(metaHandler,O.getProto(target));return wmset(proxies,reflectProxy,metaHandler),wmset(targets,reflectProxy,target),checkArray(target,reflectProxy),checkToString(target,reflectProxy),reflectProxy}return proxy}(typeof O=="undefined"?require("./utility"):O);typeof module!="undefined"&&(module.exports=proxy);var membrane=function(O,proxy,WrapMap){"use strict",proxy===null&&(proxy=require("./proxy")),WrapMap===null&&(WrapMap=require("./WrapMap"));function membrane(handlers){if(Object.isPrimitive(handlers))throw Error("Handlers must be provided");var wrapper=new WrapMap(function(target){return proxy(target,proxy({},{get:function(f,t,trap){return function(fwd,faketarget){var handler=handlers[trap],args=Array.slice(arguments);args[1]=fwd.target=wrapper.unwrap(target);if(handler){var origfwd=fwd;fwd=function fwd(){return Function.applying(handler,handlers,args)},fwd.args=origfwd.args}return Function.applying(wrapHandler[trap],null,Array.concat([fwd],Array.slice(args,1)))}}}))});function forward(fwd){return fwd()}var wrapHandler={names:forward,enumerate:forward,keys:forward,"delete":forward,has:forward,owns:forward,proto:function(fwd,target){return wrapper.wrap(fwd())},fix:function(fwd,target){throw target},define:function(fwd,target,name,desc){return wrapper.unwrap(desc,!0),fwd()},describe:function(fwd,target,name){return wrapper.wrap(fwd(),!0)},get:function(fwd,target,name,rcvr){return wrapper.wrap(fwd())},set:function(fwd,target,name,val,rcvr){return fwd.args[1]=wrapper.unwrap(val),fwd.args[2]=wrapper.unwrap(rcvr),fwd()},apply:function(fwd,target,args,rcvr){return fwd.args[0]=Array.map(args,wrapper.unwrap),fwd.args[1]=wrapper.unwrap(rcvr),wrapper.wrap(fwd())},construct:function(fwd,target,args){return fwd.args[0]=Array.map(args,wrapper.unwrap),wrapper.wrap(fwd())}};return wrapper}return membrane}(typeof O=="undefined"?require("./utility"):O,typeof proxy=="undefined"?null:proxy,typeof WrapMap=="undefined"?null:WrapMap);typeof module!="undefined"&&(module.exports=membrane);var multiherit=function(O,proxy){"use strict",proxy===null&&(proxy=require("./proxy"));function multiherit(o){o.params=o.params||[];var arglist=o.ctors.map(function(ctor,i){return Array.isArray(o.params[i])?o.params[i]:parameters(ctor).map(function(param){return o.params.indexOf(param)})}),protos=o.ctors.map(function(ctor){return ctor.prototype});return new MultiCtor(new Multiproto(protos),arglist,o)}function MultiCtor(proto,params,o){var ctors=o.ctors;function Ctor(){var args=arguments;for(var i=0;i<ctors.length;i++)apply(ctors[i],this,params[i].map(function(i){return args[i]}));return this}return Ctor.prototype=proto,proto.constructor=Ctor,this.name=o.name||ctors.map(function(ctor){return ctor.name}).join(""),this.createInstance=instanceCreator(proto,o.onCall,o.onConstruct),proxy(Ctor,this)}function toString(){return"function "+this.name+"() { [native code] }"}MultiCtor.prototype={get:function(fwd,target,name,rcvr){return name==="name"?this.name:name==="toString"?toString:fwd()},describe:function(fwd,target,name){if(name==="name"){var desc=fwd();return desc.value=this.name,desc}return fwd()},call:function(fwd,target,args,rcvr){return this.construct(fwd,target,args)},construct:function(fwd,target,args){return apply(target,this.createInstance(),args)}};function instanceCreator(proto,call,construct){if(call||construct){var handler={apply:function(fwd,target,args,rcvr){return apply(call,rcvr,args)},construct:function(fwd,target,args){return construct?apply(construct,Object.create(target.prototype),args):apply(call,global,args)}};return function(){var fake=function(){};return fake.__proto__=proto,proxy(fake,handler)}}return function(){return Object.create(proto)}}function Multiproto(protos){this.protos=protos=Object.freeze(protos.slice());var proto=Object.create(null,{inherits:{configurable:!0,value:protos}});return proxy(proto,this)}return Multiproto.prototype=function(){function list(fwd,target){return unique(this.protos.reduce(function(ret,proto){return fwd.target=proto,ret.concat(fwd())},fwd())).filter(function(s){return!(s in Object.prototype)})}function has(fwd,target,name){if(fwd())return!0;for(var i=0;i<this.protos.length;i++){fwd.target=this.protos[i];if(fwd())return!0}return!1}return{names:list,keys:list,enumerate:list,hasOwn:has,has:has,describe:function(fwd,target,name){var desc=fwd();if(desc)return desc;for(var i=0;i<this.protos.length;i++){fwd.target=this.protos[i],desc=fwd();if(desc)return desc}return undefined},get:function(fwd,target,name,rcvr){var ret,i=0;while(typeof ret=="undefined"&&fwd.target)ret=fwd(),fwd.target=this.protos[i++];return ret}}}(),multiherit}(typeof O=="undefined"?require("./utility"):O,typeof proxy=="undefined"?null:proxy);typeof module!="undefined"&&(module.exports=multiherit);var tracer=function(O,proxy,membrane,Emitter){"use strict",proxy===null&&(proxy=require("./proxy")),membrane===null&&(membrane=require("./membrane")),Emitter===null&&(Emitter=require("./Emitter"));var builtins=new WeakMap,ids=new WeakMap;ids.id=0;function tag(obj){return ids.has(obj)?ids.get(obj):ids.set(obj,ids.id++)}function TraceEmitter(object,name){if(!(this instanceof TraceEmitter))return new TraceEmitter(object,name);var self=this,names=new WeakMap,instances=new WeakMap;name=name||"root",names.set(object,[name]),Emitter.call(this);var managers={get:function(target,prop,path,ret){Object.isObject(ret)&&!names.has(ret)&&names.set(ret,path.concat(prop))},apply:function(target,args,path,ret){Object.isObject(ret)&&!names.has(ret)&&names.set(ret,[path[path.length-1],"%"])},describe:function(target,prop,path,ret){Object.isObject(ret.value)&&names.set(ret.value,path.concat(prop)),Object.isObject(ret.get)&&names.set(ret.get,path.concat(prop+"[getter]")),Object.isObject(ret.set)&&names.set(ret.set,path.concat(prop+"[setter]"))},construct:function(target,prop,path,ret){var num=instances.has(target)?instances.get(target)+1:0;instances.set(target,num),names.set(ret,(path||[]).concat("^"+num))}},wrapper=membrane(proxy({},{get:function get(f,t,trap){return function(fwd,target,prop){var ret=fwd(),path=builtins.has(target)?builtins.get(target):names.get(target),args=fwd.args;return managers[trap]&&managers[trap](target,prop,path,ret),self.emit(new TraceEvent(trap,target,args,ret,path)),ret}}}));this.unwrap=wrapper.unwrap,this[name]=wrapper.wrap(object)}TraceEmitter.prototype=Object.create(Emitter.prototype),TraceEmitter.prototype.constructor=TraceEmitter;function TraceEvent(type,target,args,result,path){Emitter.Event.apply(this,arguments),this.id=tag(target),this.result=result,this.path=path,type==="construct"||type==="apply"?this.args=args[0]:type!=="keys"&&type!=="names"&&type!=="enumerate"&&type!=="fix"&&(this.property=args[0]);if(type==="define"||type==="set")this.value=args[1];type==="get"||type==="apply"?this.receiver=args[1]:type==="set"&&(this.receiver=args[2])}TraceEvent.prototype=Object.create(Emitter.Event.prototype),TraceEvent.prototype.constructor=TraceEvent;function tracer(object,name){return new TraceEmitter(object,name)}return tracer}(typeof O=="undefined"?require("./utility"):O,typeof proxy=="undefined"?null:proxy,typeof membrane=="undefined"?null:membrane,typeof Emitter=="undefined"?null:Emitter);typeof module!="undefined"&&(module.exports=tracer);var callable=function(O,proxy){"use strict",proxy===null&&(proxy=require("./proxy"));function callable(obj){return proxy(obj,handler,!0)}function list(fwd){return fwd().filter(function(s){return s!=="$$call"&&s!=="$$construct"&&!hasOwn(s)})}var handler={enumerate:list,keys:list,names:list,apply:function(fwd,target,args,rcvr){var call=target.$$call;if(call)return apply(call,target,args)},construct:function(fwd,target,args){var construct=target.$$construct,instance=proxy(create(target),handler,!0);if(construct){var result=apply(construct,instance,args);return isObject(result)?result:instance}return instance}};return callable}(typeof O=="undefined"?require("./utility"):O,typeof proxy=="undefined"?null:proxy);typeof module!="undefined"&&(module.exports=callable);var interceptor=function(O,proxy,WrapMap){"use strict",proxy===null&&(proxy=require("./proxy")),WrapMap===null&&(WrapMap=require("./WrapMap"));var store=new WrapMap,wrap=store.wrap,unwrap=store.unwrap;function listAccessors(o,p){var out=p||O.create(null);do O.names(o).forEach(function(prop){var desc=O.describe(o,prop);if(desc.get||desc.set)out[prop]=desc}),o=O.getProto(o);while(o);return out}var Interceptor=function(){function list(fwd,target){return fwd().concat(this.properties)}function owns(fwd,target,prop){return fwd()||prop in this.accessors}function Interceptor(name,accessors,proto){var brand="[object "+name+"]";this.accessors=accessors,this.prototype=proto,this.stringifier=Descriptor.hiddenValue(Object.hasOwn(proto,"toString")?proto.toString:function toString(){return brand}),this.properties=O.keys(accessors)}return Interceptor.keys=Object.freeze(Object.create(null)),Interceptor.prototype={getter:function(target,prop){return this.accessors[prop].get.call(unwrap(target))},setter:function(target,prop,value){return this.accessors[prop].set.call(unwrap(target),value)},names:list,keys:list,enumerate:list,has:owns,owns:owns,proto:function(fwd,target){return this.fakeproto},describe:function(fwd,target,prop){if(prop==="toString"&&!Object.hasOwn(target,"toString"))return this.stringifier;if(prop in this.accessors){var desc=O.describe(this.prototype,prop);return{enumerable:desc.enumerable,configurable:!0,writable:Boolean(desc.set),value:desc.get.call(unwrap(target))}}return fwd()},define:function(fwd,target,prop,desc){return prop in this.accessors?this.setter(target,prop,desc.value):fwd()},get:function(fwd,target,prop,rcvr){return prop==="toString"&&!Object.hasOwn(target,"toString")?this.stringifier.value:prop in this.accessors?this.getter(target,prop):fwd()},set:function(fwd,target,prop,value,rcvr){return prop in this.accessors?this.setter(target,prop,value):fwd()}},Interceptor}(),IndexedInterceptor=function(){var Ceptor=Interceptor.prototype;function numbers(start,end){isFinite(end)||(end=start,start=0);var length=end-start;if(end>numbers.cache.length)while(length--)numbers.cache[length+start]=length+start+"";return numbers.cache.slice(start,end)}numbers.cache=[];function list(fwd,target){return numbers(this.prototype.length.call(unwrap(target))).concat(this.properties,fwd())}function has(fwd,target,prop){return isFinite(prop)?prop<this.prototype.length.call(unwrap(target)):prop in this.accessors||fwd()}function IndexedInterceptor(name,accessors,proto){Interceptor.apply(this,arguments),this.properties.push("length")}var indexed=IndexedInterceptor.keys=Object.create(null);return indexed.get=!0,indexed.set=!0,indexed.length=!0,Object.freeze(indexed),IndexedInterceptor.prototype={__proto__:Ceptor,names:list,keys:list,enumerate:list,has:has,owns:has,describe:function(fwd,target,prop){return isFinite(prop)&&this.prototype.get?Descriptor.value(this.prototype.get.call(unwrap(target),prop)):prop==="length"?Descriptor.hiddenValue(this.prototype.length.call(unwrap(target)),!0):Ceptor.describe.apply(this,arguments)},define:function(fwd,target,prop,desc){return isFinite(prop)&&this.prototype.set?this.prototype.set.call(unwrap(target),prop,value):Ceptor.define.apply(this,arguments)},get:function(fwd,target,prop,rcvr){return isFinite(prop)&&this.prototype.get?this.prototype.get.call(unwrap(target),prop):prop==="length"?this.prototype.length.call(unwrap(target)):Ceptor.get.apply(this,arguments)},set:function(fwd,target,prop,value,rcvr){return isFinite(prop)&&this.prototype.set?this.prototype.set.call(unwrap(target),prop,value):Ceptor.set.apply(this,arguments)}},IndexedInterceptor}(),NamedInterceptor=function(){var Ceptor=Interceptor.prototype;function list(fwd,target){return this.prototype.list.call(unwrap(target)).concat(this.properties,fwd())}function has(fwd,target,prop){return fwd()||this.prototype.has.call(unwrap(target),prop)}function NamedInterceptor(name,accessors,proto){Interceptor.apply(this,arguments)}var named=NamedInterceptor.keys=Object.create(null);return named.get=!0,named.set=!0,named.has=!0,named.list=!0,Object.freeze(named),NamedInterceptor.prototype={__proto__:Ceptor,names:list,keys:list,enumerate:list,has:has,owns:has,describe:function(fwd,target,prop){var inst=unwrap(target);return this.prototype.has.call(inst,prop)?Descriptor.value(this.prototype.get.call(inst,prop)):prop in this.accessors?Ceptor.describe.apply(this,arguments):prop in this.fakeproto?fwd():Descriptor.value(this.prototype.get.call(unwrap(target),prop))},define:function(fwd,target,prop,desc){var inst=unwrap(target);return this.prototype.has.call(inst,prop)?this.prototype.set.call(inst,prop,desc.value):prop in this.accessors?this.setter(target,prop,desc.value):this.prototype.set.call(unwrap(target),prop,value)},get:function(fwd,target,prop,rcvr){var inst=unwrap(target);return this.prototype.has.call(inst,prop)?this.prototype.get.call(inst,prop):prop in this.accessors?this.getter(target,prop):fwd()},set:function(fwd,target,prop,value,rcvr){var inst=unwrap(target);return this.prototype.has.call(inst,prop)?this.prototype.set.call(inst,prop,value):prop in this.accessors?this.setter(target,prop,value):this.prototype.set.call(unwrap(target),prop,value)}},NamedInterceptor}(),Constructor=function(){var stringifier=Descriptor.hiddenValue(function toString(){return"function "+this.name+"() { [native code] }"});function Constructor(name,ctor,template){return this.template=template,this.ctor=ctor,proxy(Function("return function "+name+"(){}")(),this)}return Constructor.prototype={describe:function(fwd,target,prop){return prop==="prototype"?Descriptor.hiddenValue(this.template.fakeproto):prop==="toString"?stringifier:fwd()},get:function(fwd,target,prop,rcvr){return prop==="prototype"?this.template.fakeproto:prop==="toString"?stringifier.value:fwd()},apply:function(fwd,target,args,rcvr){var inst=Object.create(this.template.fakeproto),out=proxy(inst,this.template);return wrap(out,inst),this.ctor.apply(out,args),out},construct:function(fwd,target,args){var inst=Object.create(this.template.fakeproto),out=proxy(inst,this.template);return wrap(out,inst),this.ctor.apply(out,args),out}},Constructor}(),protos=new WeakMap;function interceptor(name,Ctor,inherits){typeof name=="function"&&(inherits=Ctor,Ctor=name,name=Ctor.name);var proto=Ctor.prototype,accessors=listAccessors(proto);inherits&&listAccessors(protos.get(inherits),accessors);var Template="length"in proto?IndexedInterceptor:"list"in proto?NamedInterceptor:Interceptor,template=new Template(name,accessors,proto),ctor=new Constructor(name,Ctor,template);return template.fakeproto=O.keys(proto).reduce(function(ret,key){if(!(key in accessors||key in Template.keys)){var desc=O.describe(proto,key);key==="constructor"&&(desc.value=ctor),desc.enumerable=!1,O.define(ret,key,desc)}return ret},O.create(O.getProto(proto))),protos.set(template.fakeproto,proto),ctor}return interceptor}(typeof O=="undefined"?require("./utility"):O,typeof proxy=="undefined"?null:proxy,typeof WrapMap=="undefined"?null:WrapMap);typeof module!="undefined"&&(module.exports=interceptor);var doppelganger=function(O,proxy){"use strict",proxy===null&&(proxy=require("./proxy"));function doppelganger(callable){var handler=new Doppelganger,doppel=proxy(handler.target,handler,callable);return function changeInfo(into){handler.target=Object(into);if(doppel)return[doppel,doppel=null][0]}}function Doppelganger(){this.target={}}function targeter(fwd){return fwd.target=this.target,fwd()}return Doppelganger.prototype={proto:targeter,names:targeter,describe:targeter,define:targeter,"delete":targeter,fix:targeter,keys:targeter,enumerate:targeter,owns:targeter,has:targeter,get:targeter,set:targeter,apply:targeter,construct:targeter},doppelganger}(typeof O=="undefined"?require("./utility"):O,typeof proxy=="undefined"?null:proxy);return typeof module!="undefined"&&(module.exports=doppelganger),{WrapMap:WrapMap,Emitter:Emitter,proxy:proxy,membrane:membrane,multiherit:multiherit,tracer:tracer,callable:callable,interceptor:interceptor,doppelganger:doppelganger}}(Function("return this")())
+var meta=function(global){if(typeof module!="undefined"&&module.O)return module.exports=module.O;var FP=Function.prototype,OP=Object.prototype,AP=Array.prototype,bindbind=FP.bind.bind(FP.bind),callbind=bindbind(FP.call),applybind=bindbind(FP.apply),calling=callbind(FP.call),binding=callbind(FP.bind),applying=callbind(FP.apply),hasOwn=callbind(OP.hasOwnProperty),flatten=applybind(AP.concat,[]),concat=callbind(AP.concat),map=callbind(AP.map),define=Object.defineProperty,defines=Object.defineProperties,describe=Object.getOwnPropertyDescriptor,describeAny=getPropertyDescriptor,names=Object.getOwnPropertyNames,namesAny=getPropertyNames,keys=Object.keys,getProto=Object.getPrototypeOf,create=Object.create,types=[Array,Boolean,Date,Function,Map,Number,Object,RegExp,Set,String,WeakMap];function Descriptor(type,valueOrGet,readonlyOrSet,hidden,frozen){this[type?"setAccessors":"setValue"](valueOrGet,readonlyOrSet),hidden&&(this.enumerable=!1),frozen&&(this.configurable=!1)}Descriptor.VALUE=0,Descriptor.ACCESSOR=1,Descriptor.prototype={constructor:Descriptor,configurable:!0,enumerable:!0,setValue:function setValue(value,readonly){this.value=value,this.writable=!readonly},setAccessors:function setAccessors(get,set){this.get=get,this.set=set}};function value(v,h,r,f){return new Descriptor(0,v,r,h,f)}function hiddenValue(v,r,f){return new Descriptor(0,v,r,!0,f)}function accessor(g,s,h,f){return new Descriptor(1,g,s,h,f)}function hiddenAccessor(g,s,f){return new Descriptor(1,g,s,!0,f)}function isAccessor(desc){return isObject(desc)&&("get"in desc||"set"in desc)&&!("value"in desc)}function isValue(desc){return isObject(desc)&&!("get"in desc||"set"in desc)&&"value"in desc}function merge(to,from){if(~types.indexOf(to)||keys(to).length===0&&names(to)>0)var desc=hiddenValue();else var desc=value();return keys(from).forEach(function(key){hasOwn(to,key)||(desc.value=from[key],define(to,key,desc))}),to}function isObject(o){return o!==null&&typeof o=="object"||typeof o=="function"}function isPrimitive(o){return o==null||typeof o!="object"&&typeof o!="function"}function getPropertyDescriptor(o,n){while(isObject(o)){var desc=describe(o,n);if(desc)return desc;o=getProto(o)}return undefined}function getPropertyNames(o){var out=[];while(isObject(o))out.push(names(o)),o=getProto(o);return unique(flatten(out))}function parameters(fn){return(fn+="").slice(fn.indexOf("(")+1,fn.indexOf(")")).split(/\s*,\s*/)}function unique(a){return keys(a.reduce(function(r,s){return r[s]=1,r},{}))}var slice=function(){var _slice=[].slice;return function slice(a,o,p){switch(a.length){case 0:return[];case 1:return o?[]:[a[0]];default:return _slice.call(a,o,p);case 2:a=[a[0],a[1]];break;case 3:a=[a[0],a[1],a[2]];break;case 4:a=[a[0],a[1],a[2],a[3]];break;case 5:a=[a[0],a[1],a[2],a[3],a[4]];break;case 6:a=[a[0],a[1],a[2],a[3],a[4],a[5]];break;case 7:a=[a[0],a[1],a[2],a[3],a[4],a[5],a[6]];break;case 8:a=[a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7]];break;case 9:a=[a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8]];break;case 10:a=[a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9]];break;case 11:a=[a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10]];break;case 12:a=[a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11]];break;case 13:a=[a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12]];break;case 14:a=[a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13]]}return o||p?a.slice(o,p):a}}(),brandname=function(){var brands={};return types.forEach(function(Ctor){hasOwn(Ctor.prototype,"toString")&&define(Ctor,"stringify",hiddenValue(callbind(Ctor.prototype.toString))),brands["[object "+Ctor.name+"]"]=Ctor.prototype}),function brandname(o){var brand=Object.stringify(o);return brand in brands?brands[brand]:brand}}();define(global,"Descriptor",hiddenValue(Descriptor)),merge(Descriptor,{value:value,hiddenValue:hiddenValue,accessor:accessor,hiddenAccessor:hiddenAccessor,isValue:isValue,isAccessor:isAccessor}),merge(Object,{isObject:isObject,isPrimitive:isPrimitive,getPropertyDescriptor:getPropertyDescriptor,getPropertyNames:getPropertyNames,hasOwn:hasOwn,merge:merge,brandname:brandname}),merge(Function,{parameters:parameters,bindbind:bindbind,callbind:callbind,applybind:applybind,calling:calling,binding:binding,applying:applying}),merge(Array,{unique:unique,slice:slice,flatten:flatten,concat:concat,map:map});function O(v){var out=Object.create(null);return isObject(v)&&merge(out,v),out}Object.merge(O,{isobj:Object.isObject,notobj:Object.isPrimitive,create:Object.create,define:Object.defineProperty,defines:Object.defineProperties,getProto:Object.getPrototypeOf,describeAny:Object.getPropertyDescriptor,describe:Object.getOwnPropertyDescriptor,namesAny:Object.getPropertyNames,names:Object.getOwnPropertyNames,keys:Object.keys,has:Object.hasOwn}),typeof module!="undefined"&&(module.O=module.exports=O);if(typeof WeakMap=="undefined")throw Error("WeakMaps unsupported");var WrapMap=function(O){"use strict";function lookup(o){if(!wrapmaps.has(o))throw new TypeError("WrapMaps are not generic");return wrapmaps.get(o)}var wrapmaps=new WeakMap;function WrapMap(wrapper){var wrapped=new WeakMap,unwrapped=new WeakMap;if(typeof wrapper=="function")var wrap=function wrap(o,isDescriptor){if(isDescriptor===!0)return wrapDescriptor(o);if(Object.isPrimitive(o)||wrapped.has(o))return o;if(unwrapped.has(o))return unwrapped.get(o);var p=wrapper(o);return Object.isObject(p)&&(wrapped.set(p,o),unwrapped.set(o,p)),p};else var wrap=function wrap(o,p){return Object.isPrimitive(o)||wrapped.has(o)?o:unwrapped.has(o)?unwrapped.get(o):(Object.isObject(p)&&(wrapped.set(p,o),unwrapped.set(o,p)),p)};function unwrap(o,isDescriptor){return isDescriptor===!0?unwrapDescriptor(o):Object.isPrimitive(o)||!wrapped.has(o)?o:wrapped.get(o)}function has(o){return Object.isObject(o)&&wrapped.has(o)}function remove(o){var p=unwrap(o);return o!==p&&wrapped.delete(o),p}function wrapDescriptor(o){return Object.isObject(o)&&!wrapped.has(o)&&(o.value&&(o.value=wrap(o.value)),o.set&&(o.set=wrap(o.set)),o.get&&(o.get=wrap(o.get))),o}function unwrapDescriptor(o){return Object.isObject(o)&&wrapped.has(o)&&(o.value&&(o.value=unwrap(o.value)),o.set&&(o.set=unwrap(o.set)),o.get&&(o.get=unwrap(o.get))),o}var self=this===global?Object.create(WrapMap.prototype):this;return self.wrap=wrap,self.unwrap=unwrap,self.remove=remove,self.has=has,wrapmaps.set(self,{wrap:wrap,unwrap:unwrap,remove:remove,has:has}),self}return WrapMap.prototype={constructor:WrapMap,wrap:function wrap(o,p){return lookup(this).wrap(o,p)},unwrap:function unwrap(o){return lookup(this).unwrap(o)},remove:function remove(o){return lookup(this).remove(o)},has:function has(o){return lookup(this).has(o)}},WrapMap}(typeof O=="undefined"?require("./utility"):O);typeof module!="undefined"&&(module.exports=WrapMap);var Emitter=function(O){"use strict";function Event(type,target){this.type=type,this.target=target}function ErrorEvent(error,event,target){Event.call(this,"error",target),this.error=error,this.event=event}var emitters=new WeakMap,receivers=new WeakMap;function _(o){if(!emitters.has(o)){var ret={};return receivers.set(o,o),emitters.set(o,ret),ret}return emitters.get(o)}function Emitter(){emitters.set(this,{}),receivers.set(this,this)}return Emitter.Event=Event,Emitter.forward=function forward(from,to){emitters.has(to)||(emitters.set(to,{}),receivers.set(to,to)),emitters.set(from,emitters.get(to)),from.on=Emitter.prototype.on.bind(to),from.off=Emitter.prototype.off.bind(to)},Emitter.prototype={constructor:Emitter,on:function on(events,listener){var listeners=_(this);events.split(" ").forEach(function(event){event in listeners?listeners[event].push(listener):listeners[event]=[listener]})},off:function off(events,listener){var listeners=_(this);events.split(" ").forEach(function(event){listeners[event]&&listeners[event].splice(listeners[event].indexOf(listener),1)})},offAll:function offAll(event){delete _(this)[event]},once:function once(event,listener){var self=this;this.on(event,function(){return self.off(event,listener),listener.apply(receivers.get(self),arguments)})},isListened:function isListened(type){var events=_(this),listeners=events[type]||events["*"];return Boolean(listeners&&listeners.length)},emit:function emit(type){var event,events=_(this);typeof type!="string"&&type.type&&(event=type,type=type.type);if(events["*"])var listeners=events[type]?events["*"].concat(events[type]):events["*"];else var listeners=events[type];if(listeners&&listeners.length){event=event||new Event(type,receivers.get(this));var args=[event].concat(Array.slice(arguments,1));for(var i=0;i<listeners.length;i++)try{listeners[i].apply(this,args)}catch(e){this.emit(new ErrorEvent(e,event,listeners[i]))}}}},Emitter}(typeof O=="undefined"?require("./utility"):O);typeof module!="undefined"&&(module.exports=Emitter);if(typeof Proxy!="object")throw Error("Proxies unsupported");var proxy=function(O){"use strict";var createProxyObject=Proxy.create,createProxyFunction=Proxy.createFunction,wmhas=Function.callbind(WeakMap.prototype.has),wmget=Function.callbind(WeakMap.prototype.get),wmset=Function.callbind(WeakMap.prototype.set),wmdelete=Function.callbind(WeakMap.prototype.delete),wmhasget=function hasget(wm,obj){return Object.isObject(obj)&&(wm=wmget(wm,obj))===undefined?obj:wm},checkArray=function(){var wrapped=new WeakMap,isArr=Array.isArray;return Array.isArray=function isArray(){var a=arguments[0];return isArr(a)?!0:Object.isPrimitive(a)?!1:wmhas(wrapped,a)},function(o,p){isArr(o)&&wmset(wrapped,o,!0)}}(),checkToString=function(){var wrapped=new WeakMap;return[Function,RegExp,Object,Date].forEach(function(Ctor){function toString(){return Ctor.stringify(wmhasget(wrapped,this))}wmset(wrapped,toString,Ctor.prototype.toString),Ctor.prototype.toString=toString}),function(o,p){wmset(wrapped,p,o)}}();function definer(o,n,v,newDesc){return o[n]=v,!0}function setter(desc,rcvr,val){var exists=desc.set!=null;return exists&&Function.calling(desc.set,rcvr,val),exists}function configurable(desc){return desc&&(desc.configurable=!0),desc}var trapMap={getOwnPropertyDescriptor:"describe",getOwnPropertyNames:"names",getPropertyNames:"names",defineProperty:"define","delete":"delete",fix:"fix",keys:"keys",enumerate:"enumerate",hasOwn:"owns",has:"has",get:"get",set:"set",apply:"apply",construct:"construct"},forwarder={proto:function(T){return O.getProto(T)},describe:function(T,N){return configurable(O.describe(T,N))},define:function(T,N,D){return O.define(T,N,D),!0},"delete":function(T,N){return delete T[N]},fix:function(T){return Object.freeze(T)},keys:function(T){return O.keys(T)},names:function(T){return O.names(T)},enumerate:function(T){var i=0,a=[];for(a[i++]in T);return a},owns:function(T,N){return O.has(T,N)},has:function(T,N){return N in T},get:function(T,N,R){var handler=wmget(proxies,T);if(handler!=null)return wmget(handler,R,N);if(N==="__proto__")return O.getProto(T);try{var desc=O.describe(T,N)}catch(e){return R[N]}if(desc==null){var proto=O.getProto(T);if(proto!=null)return forwarder.get(proto,N,R)}else{if(Descriptor.isValue(desc))return desc.value;if(Descriptor.isAccessor(desc)&&typeof desc.get=="function")return Function.calling(desc.get,R)}return undefined},set:function(T,N,V,R){var handler=wmget(proxies,T);if(handler!=null)return handler.set(R,N,V);if(N==="__proto__")return Object.isObject(V)?(T.__proto__=V)&&!0:!1;try{var oDesc=O.describe(T,N)}catch(e){return R[N]=V,!0}if(oDesc)return Descriptor.isAccessor(oDesc)?setter(oDesc,R,V):oDesc.writable?definer(R,N,V,R!==T):!1;var proto=O.getProto(T);return proto===null?definer(R,N,V,!0):forwarder.set(proto,N,V,R)},apply:function(T,A,R){return Function.applying(T,R,A)},construct:function(T,A){var handler=wmget(proxies,T);if(handler!=null)return handler.construct(T,A);var result=new(Function.applying(Function.bind,T,[null].concat(A)));return Object.isObject(result)?result:O.create(T.prototype)}},proxies=new WeakMap,targets=new WeakMap;function proxy(target,handler,callable){if(!Object.isObject(target))throw new TypeError("Target must be an object");if(!Object.isObject(handler))throw new TypeError("Handler must be an object");function makeFwd(args,trap){var fwd=function(){return Function.applying(forwarder[fwd.trap],handler,[fwd.target].concat(fwd.args))};return fwd.target=target,fwd.args=args,fwd.trap=trap,fwd}var metaHandler=createProxyObject({get:function get(R,trap){if(trap==="getPropertyDescriptor")return function(n){return configurable(get(null,"getOwnPropertyDescriptor")(n)||O.describeAny(O.getProto(target)))};if(trap==="getPropertyNames")return function(){return Array.unique(get(null,"getOwnPropertyNames")().concat(O.namesAny(O.getProto(target))))};trap=trapMap[trap];var trapHandler=handler[trap];return function finalize(){var args=Array.slice(arguments);if(trap==="get"||trap==="set")args=Array.concat(args.slice(1),args[0]),args[0]==="__proto__"&&(trapHandler=handler.proto);return typeof trapHandler!="function"?Function.applying(forwarder[trap],handler,[target].concat(args)):trapHandler.apply(handler,[makeFwd(args,trap),target].concat(args))}}});if(callable===!0||callable==null&&typeof target=="function")var reflectProxy=createProxyFunction(metaHandler,function(){return metaHandler.apply(Array.slice(arguments),this)},function(){return metaHandler.construct(Array.slice(arguments))});else var reflectProxy=createProxyObject(metaHandler,O.getProto(target));return wmset(proxies,reflectProxy,metaHandler),wmset(targets,reflectProxy,target),checkArray(target,reflectProxy),checkToString(target,reflectProxy),reflectProxy}return proxy}(typeof O=="undefined"?require("./utility"):O);typeof module!="undefined"&&(module.exports=proxy);var membrane=function(O,proxy,WrapMap){"use strict",proxy===null&&(proxy=require("./proxy")),WrapMap===null&&(WrapMap=require("./WrapMap"));var fakehandler={};function membrane(handlers){if(Object.isPrimitive(handlers))throw Error("Handlers must be provided");var wrapper=new WrapMap(function(target){return proxy(target,proxy(fakehandler,{get:function membraneHandlerGet(f,t,trap){return function membraneMetaHandler(fwd,faketarget){var handler=handlers[trap],args=Array.slice(arguments);args[1]=fwd.target=wrapper.unwrap(faketarget);if(handler){var origfwd=fwd;fwd=function fwd(){return Function.applying(handler,handlers,args)},fwd.args=origfwd.args}return Function.applying(wrapHandler[trap],null,Array.concat([fwd],Array.slice(args,1)))}}}))});function forward(fwd){return fwd()}var wrapHandler={names:forward,enumerate:forward,keys:forward,"delete":forward,owns:forward,has:function has(){return!0},proto:function proto(fwd,target){return wrapper.wrap(fwd())},fix:function fix(fwd,target){throw target},define:function define(fwd,target,name,desc){return wrapper.unwrap(desc,!0),fwd()},describe:function describe(fwd,target,name){return wrapper.wrap(fwd(),!0)},get:function get(fwd,target,name,rcvr){return fwd.args[1]=wrapper.unwrap(rcvr),wrapper.wrap(fwd())},set:function set(fwd,target,name,val,rcvr){return fwd.args[1]=wrapper.unwrap(val),fwd.args[2]=wrapper.unwrap(rcvr),fwd()},apply:function apply(fwd,target,args,rcvr){return fwd.args[0]=Array.map(args,wrapper.unwrap),fwd.args[1]=wrapper.unwrap(rcvr),wrapper.wrap(fwd())},construct:function construct(fwd,target,args){return fwd.args[0]=Array.map(args,wrapper.unwrap),wrapper.wrap(fwd())}};return wrapper}return membrane}(typeof O=="undefined"?require("./utility"):O,typeof proxy=="undefined"?null:proxy,typeof WrapMap=="undefined"?null:WrapMap);typeof module!="undefined"&&(module.exports=membrane);var multiherit=function(O,proxy){"use strict",proxy===null&&(proxy=require("./proxy"));function multiherit(o){o.params=o.params||[];var arglist=o.ctors.map(function(ctor,i){return Array.isArray(o.params[i])?o.params[i]:parameters(ctor).map(function(param){return o.params.indexOf(param)})}),protos=o.ctors.map(function(ctor){return ctor.prototype});return new MultiCtor(new Multiproto(protos),arglist,o)}function MultiCtor(proto,params,o){var ctors=o.ctors;function Ctor(){var args=arguments;for(var i=0;i<ctors.length;i++)apply(ctors[i],this,params[i].map(function(i){return args[i]}));return this}return Ctor.prototype=proto,proto.constructor=Ctor,this.name=o.name||ctors.map(function(ctor){return ctor.name}).join(""),this.createInstance=instanceCreator(proto,o.onCall,o.onConstruct),proxy(Ctor,this)}function toString(){return"function "+this.name+"() { [native code] }"}MultiCtor.prototype={get:function(fwd,target,name,rcvr){return name==="name"?this.name:name==="toString"?toString:fwd()},describe:function(fwd,target,name){if(name==="name"){var desc=fwd();return desc.value=this.name,desc}return fwd()},call:function(fwd,target,args,rcvr){return this.construct(fwd,target,args)},construct:function(fwd,target,args){return apply(target,this.createInstance(),args)}};function instanceCreator(proto,call,construct){if(call||construct){var handler={apply:function(fwd,target,args,rcvr){return apply(call,rcvr,args)},construct:function(fwd,target,args){return construct?apply(construct,Object.create(target.prototype),args):apply(call,global,args)}};return function(){var fake=function(){};return fake.__proto__=proto,proxy(fake,handler)}}return function(){return Object.create(proto)}}function Multiproto(protos){this.protos=protos=Object.freeze(protos.slice());var proto=Object.create(null,{inherits:{configurable:!0,value:protos}});return proxy(proto,this)}return Multiproto.prototype=function(){function list(fwd,target){return unique(this.protos.reduce(function(ret,proto){return fwd.target=proto,ret.concat(fwd())},fwd())).filter(function(s){return!(s in Object.prototype)})}function has(fwd,target,name){if(fwd())return!0;for(var i=0;i<this.protos.length;i++){fwd.target=this.protos[i];if(fwd())return!0}return!1}return{names:list,keys:list,enumerate:list,hasOwn:has,has:has,describe:function(fwd,target,name){var desc=fwd();if(desc)return desc;for(var i=0;i<this.protos.length;i++){fwd.target=this.protos[i],desc=fwd();if(desc)return desc}return undefined},get:function(fwd,target,name,rcvr){var ret,i=0;while(typeof ret=="undefined"&&fwd.target)ret=fwd(),fwd.target=this.protos[i++];return ret}}}(),multiherit}(typeof O=="undefined"?require("./utility"):O,typeof proxy=="undefined"?null:proxy);typeof module!="undefined"&&(module.exports=multiherit);var tracer=function(O,proxy,membrane,Emitter){"use strict",proxy===null&&(proxy=require("./proxy")),membrane===null&&(membrane=require("./membrane")),Emitter===null&&(Emitter=require("./Emitter"));function TraceEmitter(object,name){var self=this instanceof TraceEmitter?this:Object.create(TraceEmitter.prototype);name=name||"root",Emitter.call(this);var wrapper=membrane(proxy({},{get:function get(f,t,trap){return function(fwd,target,prop){var ret=fwd();return self.emit(new TraceEvent(trap,target,fwd.args,ret)),ret}}}));this.unwrap=wrapper.unwrap,this[name]=wrapper.wrap(object)}TraceEmitter.prototype=Object.create(Emitter.prototype),TraceEmitter.prototype.constructor=TraceEmitter;function TraceEvent(type,target,args,result){this.type=type,this.target=target,this.result=result;var i=0;switch(type){case"keys":case"names":case"enumerate":case"fix":break;case"set":case"define":this.result===!0&&delete this.result,this.value=args[1];case"get":case"describe":this.property=args[0];break;case"apply":this.context=args[1];case"construct":this.name=target.name,this.args=args[0]}}TraceEvent.prototype=Object.create(Emitter.Event.prototype),TraceEvent.prototype.constructor=TraceEvent;function tracer(object,name){return new TraceEmitter(object,name)}return tracer}(typeof O=="undefined"?require("./utility"):O,typeof proxy=="undefined"?null:proxy,typeof membrane=="undefined"?null:membrane,typeof Emitter=="undefined"?null:Emitter);typeof module!="undefined"&&(module.exports=tracer);var callable=function(O,proxy){"use strict",proxy===null&&(proxy=require("./proxy"));function callable(obj){return proxy(obj,handler,!0)}function list(fwd){return fwd().filter(function(s){return s!=="$$call"&&s!=="$$construct"&&!hasOwn(s)})}var handler={enumerate:list,keys:list,names:list,apply:function(fwd,target,args,rcvr){var call=target.$$call;return call?apply(call,target,args):undefined},construct:function(fwd,target,args){var construct=target.$$construct,instance=proxy(create(target),handler,!0);if(construct){var result=apply(construct,instance,args);return isObject(result)?result:instance}return instance}};return callable}(typeof O=="undefined"?require("./utility"):O,typeof proxy=="undefined"?null:proxy);typeof module!="undefined"&&(module.exports=callable);var interceptor=function(O,proxy,WrapMap){"use strict",proxy===null&&(proxy=require("./proxy")),WrapMap===null&&(WrapMap=require("./WrapMap"));var store=new WrapMap,wrap=store.wrap,unwrap=store.unwrap;function listAccessors(o,p){var out=p||O.create(null);do O.names(o).forEach(function(prop){var desc=O.describe(o,prop);if(desc.get||desc.set)out[prop]=desc}),o=O.getProto(o);while(o);return out}var Interceptor=function(){function list(fwd,target){return fwd().concat(this.properties)}function owns(fwd,target,prop){return fwd()||prop in this.accessors}function Interceptor(name,accessors,proto){var brand="[object "+name+"]";this.accessors=accessors,this.prototype=proto,this.stringifier=Descriptor.hiddenValue(Object.hasOwn(proto,"toString")?proto.toString:function toString(){return brand}),this.properties=O.keys(accessors)}return Interceptor.keys=Object.freeze(Object.create(null)),Interceptor.prototype={getter:function(target,prop){return this.accessors[prop].get.call(unwrap(target))},setter:function(target,prop,value){return this.accessors[prop].set.call(unwrap(target),value)},names:list,keys:list,enumerate:list,has:owns,owns:owns,proto:function(fwd,target){return this.fakeproto},describe:function(fwd,target,prop){if(prop==="toString"&&!Object.hasOwn(target,"toString"))return this.stringifier;if(prop in this.accessors){var desc=O.describe(this.prototype,prop);return{enumerable:desc.enumerable,configurable:!0,writable:Boolean(desc.set),value:desc.get.call(unwrap(target))}}return fwd()},define:function(fwd,target,prop,desc){return prop in this.accessors?this.setter(target,prop,desc.value):fwd()},get:function(fwd,target,prop,rcvr){return prop==="toString"&&!Object.hasOwn(target,"toString")?this.stringifier.value:prop in this.accessors?this.getter(target,prop):fwd()},set:function(fwd,target,prop,value,rcvr){return prop in this.accessors?this.setter(target,prop,value):fwd()}},Interceptor}(),IndexedInterceptor=function(){var Ceptor=Interceptor.prototype;function numbers(start,end){isFinite(end)||(end=start,start=0);var length=end-start;if(end>numbers.cache.length)while(length--)numbers.cache[length+start]=length+start+"";return numbers.cache.slice(start,end)}numbers.cache=[];function list(fwd,target){return numbers(this.prototype.length.call(unwrap(target))).concat(this.properties,fwd())}function has(fwd,target,prop){return isFinite(prop)?prop<this.prototype.length.call(unwrap(target)):prop in this.accessors||fwd()}function IndexedInterceptor(name,accessors,proto){Interceptor.apply(this,arguments),this.properties.push("length")}var indexed=IndexedInterceptor.keys=Object.create(null);return indexed.get=!0,indexed.set=!0,indexed.length=!0,Object.freeze(indexed),IndexedInterceptor.prototype={__proto__:Ceptor,names:list,keys:list,enumerate:list,has:has,owns:has,describe:function(fwd,target,prop){return isFinite(prop)&&this.prototype.get?Descriptor.value(this.prototype.get.call(unwrap(target),prop)):prop==="length"?Descriptor.hiddenValue(this.prototype.length.call(unwrap(target)),!0):Ceptor.describe.apply(this,arguments)},define:function(fwd,target,prop,desc){return isFinite(prop)&&this.prototype.set?this.prototype.set.call(unwrap(target),prop,value):Ceptor.define.apply(this,arguments)},get:function(fwd,target,prop,rcvr){return isFinite(prop)&&this.prototype.get?this.prototype.get.call(unwrap(target),prop):prop==="length"?this.prototype.length.call(unwrap(target)):Ceptor.get.apply(this,arguments)},set:function(fwd,target,prop,value,rcvr){return isFinite(prop)&&this.prototype.set?this.prototype.set.call(unwrap(target),prop,value):Ceptor.set.apply(this,arguments)}},IndexedInterceptor}(),NamedInterceptor=function(){var Ceptor=Interceptor.prototype;function list(fwd,target){return this.prototype.list.call(unwrap(target)).concat(this.properties,fwd())}function has(fwd,target,prop){return fwd()||this.prototype.has.call(unwrap(target),prop)}function NamedInterceptor(name,accessors,proto){Interceptor.apply(this,arguments)}var named=NamedInterceptor.keys=Object.create(null);return named.get=!0,named.set=!0,named.has=!0,named.list=!0,Object.freeze(named),NamedInterceptor.prototype={__proto__:Ceptor,names:list,keys:list,enumerate:list,has:has,owns:has,describe:function(fwd,target,prop){var inst=unwrap(target);return this.prototype.has.call(inst,prop)?Descriptor.value(this.prototype.get.call(inst,prop)):prop in this.accessors?Ceptor.describe.apply(this,arguments):prop in this.fakeproto?fwd():Descriptor.value(this.prototype.get.call(unwrap(target),prop))},define:function(fwd,target,prop,desc){var inst=unwrap(target);return this.prototype.has.call(inst,prop)?this.prototype.set.call(inst,prop,desc.value):prop in this.accessors?this.setter(target,prop,desc.value):this.prototype.set.call(unwrap(target),prop,value)},get:function(fwd,target,prop,rcvr){var inst=unwrap(target);return this.prototype.has.call(inst,prop)?this.prototype.get.call(inst,prop):prop in this.accessors?this.getter(target,prop):fwd()},set:function(fwd,target,prop,value,rcvr){var inst=unwrap(target);return this.prototype.has.call(inst,prop)?this.prototype.set.call(inst,prop,value):prop in this.accessors?this.setter(target,prop,value):this.prototype.set.call(unwrap(target),prop,value)}},NamedInterceptor}(),Constructor=function(){var stringifier=Descriptor.hiddenValue(function toString(){return"function "+this.name+"() { [native code] }"});function Constructor(name,ctor,template){return this.template=template,this.ctor=ctor,proxy(Function("return function "+name+"(){}")(),this)}return Constructor.prototype={describe:function(fwd,target,prop){return prop==="prototype"?Descriptor.hiddenValue(this.template.fakeproto):prop==="toString"?stringifier:fwd()},get:function(fwd,target,prop,rcvr){return prop==="prototype"?this.template.fakeproto:prop==="toString"?stringifier.value:fwd()},apply:function(fwd,target,args,rcvr){var inst=Object.create(this.template.fakeproto),out=proxy(inst,this.template);return wrap(out,inst),this.ctor.apply(out,args),out},construct:function(fwd,target,args){var inst=Object.create(this.template.fakeproto),out=proxy(inst,this.template);return wrap(out,inst),this.ctor.apply(out,args),out}},Constructor}(),protos=new WeakMap;function interceptor(name,Ctor,inherits){typeof name=="function"&&(inherits=Ctor,Ctor=name,name=Ctor.name);var proto=Ctor.prototype,accessors=listAccessors(proto);inherits&&listAccessors(protos.get(inherits),accessors);var Template="length"in proto?IndexedInterceptor:"list"in proto?NamedInterceptor:Interceptor,template=new Template(name,accessors,proto),ctor=new Constructor(name,Ctor,template);return template.fakeproto=O.keys(proto).reduce(function(ret,key){if(!(key in accessors||key in Template.keys)){var desc=O.describe(proto,key);key==="constructor"&&(desc.value=ctor),desc.enumerable=!1,O.define(ret,key,desc)}return ret},O.create(O.getProto(proto))),protos.set(template.fakeproto,proto),ctor}return interceptor}(typeof O=="undefined"?require("./utility"):O,typeof proxy=="undefined"?null:proxy,typeof WrapMap=="undefined"?null:WrapMap);typeof module!="undefined"&&(module.exports=interceptor);var doppelganger=function(O,proxy){"use strict",proxy===null&&(proxy=require("./proxy"));function doppelganger(callable){var handler=new Doppelganger,doppel=proxy(handler.target,handler,callable);return function changeInfo(into){handler.target=Object(into);if(doppel)return[doppel,doppel=null][0]}}function Doppelganger(){this.target={}}function targeter(fwd){return fwd.target=this.target,fwd()}return Doppelganger.prototype={proto:targeter,names:targeter,describe:targeter,define:targeter,"delete":targeter,fix:targeter,keys:targeter,enumerate:targeter,owns:targeter,has:targeter,get:targeter,set:targeter,apply:targeter,construct:targeter},doppelganger}(typeof O=="undefined"?require("./utility"):O,typeof proxy=="undefined"?null:proxy);typeof module!="undefined"&&(module.exports=doppelganger);var namespace=function(O){function frozen(o){return Object.preventExtensions(O.names(o).reduce(function(r,s){var desc=O.describe(o,s);return desc.enumerable=desc.configurable=!1,"value"in desc&&(desc.writeable=!1),O.define(r,s,desc)},O()))}function Store(values){Object.isObject(values)&&this.set(values)}return Store.prototype=frozen({set:function set(key,value){Object.isObject(key)?Object.keys(key).forEach(function(k){this[k]=key[k]},this):this[key]=value},get:function get(key){return Array.isArray(key)?key.reduce(function(r,k){return r[k]=this[k],r}.bind(this),{}):this[key]},toString:function toString(){return"[object Store]"},valueOf:Object.prototype.valueOf}),function namespace(){var storage=new WeakMap;return function unwrap(obj,values){var ret=storage.get(obj);return ret||(ret=new Store(values),storage.set(obj,ret)),ret}}}(typeof O=="undefined"?require("./utility"):O);return typeof module!="undefined"&&(module.exports=namespace),{WrapMap:WrapMap,Emitter:Emitter,proxy:proxy,membrane:membrane,multiherit:multiherit,tracer:tracer,callable:callable,interceptor:interceptor,doppelganger:doppelganger,namespace:namespace}}(this)
View
2 package.json
@@ -4,7 +4,7 @@
"description": "Utilities and patterns for using Harmony Proxies to meta-program. Proxies as Proxy handlers, catch all forwarders for catch all forwarders, intercession introspection. Now you're thinking with portals.",
"keywords": [ "harmony", "proxy", "meta", "objects", "membrane",
"ecmascript", "functional", "partial", "weakmap", "trace" ],
- "version": "0.2.6",
+ "version": "0.2.8",
"repository": {
"url": "https://github.com/Benvie/meta-objects"
},

0 comments on commit f04a779

Please sign in to comment.
Something went wrong with that request. Please try again.