|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
-
- var proxiedDescriptor = (()=> {
- var __values = [];
-
- class proxiedDescriptorClass {
- get [Symbol.toStringTag]() { return 'proxiedDescriptor';}
- valueOf(){return 'pdc'}
- }
- var __composite = { a : '__composite'};
- console.dir(__composite)
- function composite(){
- var o = js.isUndefined(__values[0]) ? __values[0] : js.assign(js.getTypeInfo(__values[0]).create(), ...__values)
- return o;
- }
-
-
- let mutableTarget;
- let mutableHandler;
-
- function setHandler(handler) {
- Object.keys(handler).forEach(key => {
- const value = handler[key];
-
- if (typeof value !== 'function') {
-
- throw new Error(`Trap "${key}: ${value}" is not a function`);
- }
-
- if (!Reflect[key]) {
- throw new Error(`Trap "${key}: ${value}" is not a valid trap`);
- }
- });
-
- mutableHandler = js.assign(mutableHandler || {}, handler);
-
- }
- function setTarget(target) {
-
-
-
- mutableTarget = target;
- }
- setTarget(() => {});
-
- console.log('-----MT---------')
- console.dir(mutableTarget)
- console.log('-----MT---------')
-
-
- const handler = new Proxy({}, {
- get(target, property) {
- console.log('-----marker---------')
- setTarget(composite())
-
-
- console.log(property)
- if(mutableHandler[property]) return (...args) => mutableHandler[property].apply(null, [mutableTarget, ...args.slice(1)]);
-
- }
- });
-
- var mutableProxyInstance = {
- setHandler,
- getTarget() {
- return mutableTarget;
- },
- getHandler() {
- return mutableHandler;
- },
- proxy: new Proxy(mutableTarget, handler)
- };
- setHandler({
-
- getOwnPropertyDescriptor: function(target, prop) {
- console.log('accessing prop : ')
- console.dir(prop)
-
- o = composite()
- console.dir(target)
- var a = {value : undefined, configurable : true};
- if(!js.isUndefined(o)) a= Object.getOwnPropertyDescriptor(o, prop);
-
-
- return a;
-
-
-
-
-
-
- }
- ,
-
-
-
-
- get: function(target, name) {
- console.log('accessing name : ')
- console.dir(name)
- console.log('target is now')
- console.dir(target)
-
-
-
-
- if(js.isUndefined(target)) return Reflect[name];
- if(
- name == util.inspect.custom
-
-
-
-
-
-
-
-
- ) {
-
-
- return function(){
- console.log('in toString ....')
- var o = composite();
- console.dir(o)
- return o
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- return (name == 'composite' ? composite()
-
-
-
-
-
-
- : name == 'current' ? Ref.isRef(__values[0]) ? __values[0].getValue() : __values[0]
- : name == 'previous' ? Ref.isRef(__values[1]) ? __values[1].getValue() : __values[1]
- : composite()[name]
- )
- }
- , set: function(target, name, value) {
- mutabletarget = __composite = composite();
- name == 'revise' ? (__values.splice(0, 0, value), value)
- : name == 'precede' ? (__values.push(value), value)
- : name == 'current' ? __values[0] = value
- : __values[name] = value;
- return __composite;
- }
- })
-
- var p = new Proxy(__composite, handler);
- p.toString = function() { return 'ps tostring' }
- return {
- get : function(){ return p}
- , set : function(value) { p.revise = value}
- }
- })()
|