ag-reactive
Advanced tools
Comparing version 1.0.25 to 1.0.26
243
Builder.js
"use strict"; | ||
var __values = (this && this.__values) || function(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
}; | ||
var __read = (this && this.__read) || function (o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -31,40 +58,79 @@ exports.Builder = void 0; | ||
Builder.prototype.update = function (delta) { | ||
for (var _i = 0, _a = Object.entries(delta); _i < _a.length; _i++) { | ||
var _b = _a[_i], id = _b[0], t = _b[1].t; | ||
if (t === 'a') { | ||
this.objs.set(id, this.wrapper ? this.wrapper({}) : {}); | ||
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e; | ||
try { | ||
for (var _f = __values(Object.entries(delta)), _g = _f.next(); !_g.done; _g = _f.next()) { | ||
var _h = __read(_g.value, 2), id = _h[0], t = _h[1].t; | ||
if (t === 'a') { | ||
this.objs.set(id, this.wrapper ? this.wrapper({}) : {}); | ||
} | ||
if (t === 'aa') { | ||
this.objs.set(id, this.wrapper ? this.wrapper([]) : []); | ||
} | ||
} | ||
if (t === 'aa') { | ||
this.objs.set(id, this.wrapper ? this.wrapper([]) : []); | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (_g && !_g.done && (_a = _f.return)) _a.call(_f); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
for (var _c = 0, _d = Object.entries(delta); _c < _d.length; _c++) { | ||
var _e = _d[_c], id = _e[0], _f = _e[1], t = _f.t, v = _f.v; | ||
if (t == 'a') { | ||
var obj = this.objs.get(id); | ||
if (obj) { | ||
for (var _g = 0, _h = Object.entries(v); _g < _h.length; _g++) { | ||
var _j = _h[_g], key = _j[0], value = _j[1]; | ||
this.setKeyValue(obj, key, value); | ||
try { | ||
for (var _j = __values(Object.entries(delta)), _k = _j.next(); !_k.done; _k = _j.next()) { | ||
var _l = __read(_k.value, 2), id = _l[0], _m = _l[1], t = _m.t, v = _m.v; | ||
if (t == 'a') { | ||
var obj = this.objs.get(id); | ||
if (obj) { | ||
try { | ||
for (var _o = (e_3 = void 0, __values(Object.entries(v))), _p = _o.next(); !_p.done; _p = _o.next()) { | ||
var _q = __read(_p.value, 2), key = _q[0], value = _q[1]; | ||
this.setKeyValue(obj, key, value); | ||
} | ||
} | ||
catch (e_3_1) { e_3 = { error: e_3_1 }; } | ||
finally { | ||
try { | ||
if (_p && !_p.done && (_c = _o.return)) _c.call(_o); | ||
} | ||
finally { if (e_3) throw e_3.error; } | ||
} | ||
} | ||
} | ||
} | ||
else if (t == 'aa') { | ||
var obj = this.objs.get(id); | ||
if (obj) { | ||
for (var _k = 0, _l = Object.entries(v); _k < _l.length; _k++) { | ||
var _m = _l[_k], key = _m[0], value = _m[1]; | ||
this.setKeyValue(obj, key, value); | ||
else if (t == 'aa') { | ||
var obj = this.objs.get(id); | ||
if (obj) { | ||
try { | ||
for (var _r = (e_4 = void 0, __values(Object.entries(v))), _s = _r.next(); !_s.done; _s = _r.next()) { | ||
var _t = __read(_s.value, 2), key = _t[0], value = _t[1]; | ||
this.setKeyValue(obj, key, value); | ||
} | ||
} | ||
catch (e_4_1) { e_4 = { error: e_4_1 }; } | ||
finally { | ||
try { | ||
if (_s && !_s.done && (_d = _r.return)) _d.call(_r); | ||
} | ||
finally { if (e_4) throw e_4.error; } | ||
} | ||
} | ||
} | ||
} | ||
else if (t === 'd' || t === 'da') { | ||
this.objs.delete(id); | ||
} | ||
else if (t === 'u') { | ||
var obj = this.objs.get(id); | ||
if (obj) { | ||
for (var _o = 0, _p = Object.entries(v); _o < _p.length; _o++) { | ||
var _q = _p[_o], key = _q[0], nv = _q[1].nv; | ||
this.setKeyValue(obj, key, nv); | ||
else if (t === 'd' || t === 'da') { | ||
this.objs.delete(id); | ||
} | ||
else if (t === 'u') { | ||
var obj = this.objs.get(id); | ||
if (obj) { | ||
try { | ||
for (var _u = (e_5 = void 0, __values(Object.entries(v))), _v = _u.next(); !_v.done; _v = _u.next()) { | ||
var _w = __read(_v.value, 2), key = _w[0], nv = _w[1].nv; | ||
this.setKeyValue(obj, key, nv); | ||
} | ||
} | ||
catch (e_5_1) { e_5 = { error: e_5_1 }; } | ||
finally { | ||
try { | ||
if (_v && !_v.done && (_e = _u.return)) _e.call(_u); | ||
} | ||
finally { if (e_5) throw e_5.error; } | ||
} | ||
} | ||
@@ -74,42 +140,88 @@ } | ||
} | ||
catch (e_2_1) { e_2 = { error: e_2_1 }; } | ||
finally { | ||
try { | ||
if (_k && !_k.done && (_b = _j.return)) _b.call(_j); | ||
} | ||
finally { if (e_2) throw e_2.error; } | ||
} | ||
}; | ||
Builder.prototype.reverse = function (delta) { | ||
for (var _i = 0, _a = Object.entries(delta); _i < _a.length; _i++) { | ||
var _b = _a[_i], id = _b[0], t = _b[1].t; | ||
if (t === 'd') { | ||
this.objs.set(id, this.wrapper ? this.wrapper({}) : {}); | ||
var e_6, _a, e_7, _b, e_8, _c, e_9, _d, e_10, _e; | ||
try { | ||
for (var _f = __values(Object.entries(delta)), _g = _f.next(); !_g.done; _g = _f.next()) { | ||
var _h = __read(_g.value, 2), id = _h[0], t = _h[1].t; | ||
if (t === 'd') { | ||
this.objs.set(id, this.wrapper ? this.wrapper({}) : {}); | ||
} | ||
if (t === 'da') { | ||
this.objs.set(id, this.wrapper ? this.wrapper([]) : []); | ||
} | ||
} | ||
if (t === 'da') { | ||
this.objs.set(id, this.wrapper ? this.wrapper([]) : []); | ||
} | ||
catch (e_6_1) { e_6 = { error: e_6_1 }; } | ||
finally { | ||
try { | ||
if (_g && !_g.done && (_a = _f.return)) _a.call(_f); | ||
} | ||
finally { if (e_6) throw e_6.error; } | ||
} | ||
for (var _c = 0, _d = Object.entries(delta); _c < _d.length; _c++) { | ||
var _e = _d[_c], id = _e[0], _f = _e[1], t = _f.t, v = _f.v; | ||
if (t == 'd') { | ||
var obj = this.objs.get(id); | ||
if (obj) { | ||
for (var _g = 0, _h = Object.entries(v); _g < _h.length; _g++) { | ||
var _j = _h[_g], key = _j[0], value = _j[1]; | ||
this.setKeyValue(obj, key, value); | ||
try { | ||
for (var _j = __values(Object.entries(delta)), _k = _j.next(); !_k.done; _k = _j.next()) { | ||
var _l = __read(_k.value, 2), id = _l[0], _m = _l[1], t = _m.t, v = _m.v; | ||
if (t == 'd') { | ||
var obj = this.objs.get(id); | ||
if (obj) { | ||
try { | ||
for (var _o = (e_8 = void 0, __values(Object.entries(v))), _p = _o.next(); !_p.done; _p = _o.next()) { | ||
var _q = __read(_p.value, 2), key = _q[0], value = _q[1]; | ||
this.setKeyValue(obj, key, value); | ||
} | ||
} | ||
catch (e_8_1) { e_8 = { error: e_8_1 }; } | ||
finally { | ||
try { | ||
if (_p && !_p.done && (_c = _o.return)) _c.call(_o); | ||
} | ||
finally { if (e_8) throw e_8.error; } | ||
} | ||
} | ||
} | ||
} | ||
else if (t == 'da') { | ||
var obj = this.objs.get(id); | ||
if (obj) { | ||
for (var _k = 0, _l = Object.entries(v); _k < _l.length; _k++) { | ||
var _m = _l[_k], key = _m[0], value = _m[1]; | ||
this.setKeyValue(obj, key, value); | ||
else if (t == 'da') { | ||
var obj = this.objs.get(id); | ||
if (obj) { | ||
try { | ||
for (var _r = (e_9 = void 0, __values(Object.entries(v))), _s = _r.next(); !_s.done; _s = _r.next()) { | ||
var _t = __read(_s.value, 2), key = _t[0], value = _t[1]; | ||
this.setKeyValue(obj, key, value); | ||
} | ||
} | ||
catch (e_9_1) { e_9 = { error: e_9_1 }; } | ||
finally { | ||
try { | ||
if (_s && !_s.done && (_d = _r.return)) _d.call(_r); | ||
} | ||
finally { if (e_9) throw e_9.error; } | ||
} | ||
} | ||
} | ||
} | ||
else if (t === 'a' || t === 'aa') { | ||
this.objs.delete(id); | ||
} | ||
else if (t === 'u') { | ||
var obj = this.objs.get(id); | ||
if (obj) { | ||
for (var _o = 0, _p = Object.entries(v); _o < _p.length; _o++) { | ||
var _q = _p[_o], key = _q[0], ov = _q[1].ov; | ||
this.setKeyValue(obj, key, ov); | ||
else if (t === 'a' || t === 'aa') { | ||
this.objs.delete(id); | ||
} | ||
else if (t === 'u') { | ||
var obj = this.objs.get(id); | ||
if (obj) { | ||
try { | ||
for (var _u = (e_10 = void 0, __values(Object.entries(v))), _v = _u.next(); !_v.done; _v = _u.next()) { | ||
var _w = __read(_v.value, 2), key = _w[0], ov = _w[1].ov; | ||
this.setKeyValue(obj, key, ov); | ||
} | ||
} | ||
catch (e_10_1) { e_10 = { error: e_10_1 }; } | ||
finally { | ||
try { | ||
if (_v && !_v.done && (_e = _u.return)) _e.call(_u); | ||
} | ||
finally { if (e_10) throw e_10.error; } | ||
} | ||
} | ||
@@ -119,2 +231,9 @@ } | ||
} | ||
catch (e_7_1) { e_7 = { error: e_7_1 }; } | ||
finally { | ||
try { | ||
if (_k && !_k.done && (_b = _j.return)) _b.call(_j); | ||
} | ||
finally { if (e_7) throw e_7.error; } | ||
} | ||
}; | ||
@@ -121,0 +240,0 @@ return Builder; |
@@ -17,2 +17,29 @@ "use strict"; | ||
})(); | ||
var __values = (this && this.__values) || function(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
}; | ||
var __read = (this && this.__read) || function (o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -55,10 +82,20 @@ exports.Computed = exports.dependon = void 0; | ||
Computed.prototype.confirmDirty = function () { | ||
var e_1, _a; | ||
computeStack.push(this); | ||
try { | ||
for (var _i = 0, _a = this.dirties; _i < _a.length; _i++) { | ||
var node = _a[_i]; | ||
if (node.terminated || this.dependencies.get(node) !== node.get()) { | ||
return; | ||
try { | ||
for (var _b = __values(this.dirties), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var node = _c.value; | ||
if (node.terminated || this.dependencies.get(node) !== node.get()) { | ||
return; | ||
} | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
Observer_1.dirtyNodes.delete(this); | ||
@@ -73,8 +110,18 @@ this.dirty = false; | ||
Computed.prototype.compute = function () { | ||
var e_2, _a; | ||
computeStack.push(this); | ||
this.dirties.clear(); | ||
for (var _i = 0, _a = this.dependencies; _i < _a.length; _i++) { | ||
var node = _a[_i][0]; | ||
node.unbind(this); | ||
try { | ||
for (var _b = __values(this.dependencies), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var _d = __read(_c.value, 1), node = _d[0]; | ||
node.unbind(this); | ||
} | ||
} | ||
catch (e_2_1) { e_2 = { error: e_2_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
} | ||
finally { if (e_2) throw e_2.error; } | ||
} | ||
this.dependencies.clear(); | ||
@@ -81,0 +128,0 @@ _super.prototype.set.call(this, this.fn()); |
27
index.js
"use strict"; | ||
var __read = (this && this.__read) || function (o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -77,3 +102,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
} | ||
consoleLog.apply(void 0, d.map(function (v) { return (0, pretty_format_1.default)(v); })); | ||
consoleLog.apply(void 0, __spreadArray([], __read(d.map(function (v) { return (0, pretty_format_1.default)(v); })), false)); | ||
}; |
103
Obj.js
"use strict"; | ||
var __values = (this && this.__values) || function(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
}; | ||
var __read = (this && this.__read) || function (o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -23,2 +50,3 @@ exports.Obj = void 0; | ||
Obj.prototype.backTraceDirty = function (key) { | ||
var e_1, _a; | ||
if (!Observer_1.dirtyProps.has(this)) { | ||
@@ -30,8 +58,17 @@ Observer_1.dirtyProps.set(this, new Set()); | ||
keys.add(key); | ||
for (var _i = 0, _a = this.observers; _i < _a.length; _i++) { | ||
var _b = _a[_i], _ = _b[0], status_1 = _b[1]; | ||
if (status_1.active) { | ||
status_1.active.backTraceDirtyPath(); | ||
try { | ||
for (var _b = __values(this.observers), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var _d = __read(_c.value, 2), _ = _d[0], status_1 = _d[1]; | ||
if (status_1.active) { | ||
status_1.active.backTraceDirtyPath(); | ||
} | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
} | ||
@@ -43,12 +80,22 @@ else { | ||
Obj.prototype.forwardClearDirty = function () { | ||
var e_2, _a; | ||
var dirties = Observer_1.dirtyProps.get(this); | ||
if (dirties) { | ||
for (var _i = 0, dirties_1 = dirties; _i < dirties_1.length; _i++) { | ||
var key = dirties_1[_i]; | ||
var node = this.props[key]; | ||
var value = node.get(); | ||
if (value instanceof Obj) { | ||
value.forwardClearDirty(); | ||
try { | ||
for (var dirties_1 = __values(dirties), dirties_1_1 = dirties_1.next(); !dirties_1_1.done; dirties_1_1 = dirties_1.next()) { | ||
var key = dirties_1_1.value; | ||
var node = this.props[key]; | ||
var value = node.get(); | ||
if (value instanceof Obj) { | ||
value.forwardClearDirty(); | ||
} | ||
} | ||
} | ||
catch (e_2_1) { e_2 = { error: e_2_1 }; } | ||
finally { | ||
try { | ||
if (dirties_1_1 && !dirties_1_1.done && (_a = dirties_1.return)) _a.call(dirties_1); | ||
} | ||
finally { if (e_2) throw e_2.error; } | ||
} | ||
Observer_1.dirtyProps.delete(this); | ||
@@ -58,2 +105,3 @@ } | ||
Obj.prototype.wilter = function (observer, from, pendings) { | ||
var e_3, _a; | ||
var status = this.observers.get(observer); | ||
@@ -64,8 +112,17 @@ if (status) { | ||
observer.updateObjState(this, false); | ||
for (var _i = 0, _a = Object.values(this.props); _i < _a.length; _i++) { | ||
var prop = _a[_i]; | ||
if (prop.cache instanceof Obj) { | ||
prop.cache.wilter(observer, prop, pendings); | ||
try { | ||
for (var _b = __values(Object.values(this.props)), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var prop = _c.value; | ||
if (prop.cache instanceof Obj) { | ||
prop.cache.wilter(observer, prop, pendings); | ||
} | ||
} | ||
} | ||
catch (e_3_1) { e_3 = { error: e_3_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
} | ||
finally { if (e_3) throw e_3.error; } | ||
} | ||
if (status.pending.length > 0) { | ||
@@ -84,2 +141,3 @@ pendings.push(this); | ||
Obj.prototype.grow = function (observer, from) { | ||
var e_4, _a; | ||
if (!this.observers.has(observer)) { | ||
@@ -92,8 +150,17 @@ this.observers.set(observer, { pending: [] }); | ||
observer.updateObjState(this, true); | ||
for (var _i = 0, _a = Object.values(this.props); _i < _a.length; _i++) { | ||
var prop = _a[_i]; | ||
if (prop.cache instanceof Obj) { | ||
prop.cache.grow(observer, prop); | ||
try { | ||
for (var _b = __values(Object.values(this.props)), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var prop = _c.value; | ||
if (prop.cache instanceof Obj) { | ||
prop.cache.grow(observer, prop); | ||
} | ||
} | ||
} | ||
catch (e_4_1) { e_4 = { error: e_4_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
} | ||
finally { if (e_4) throw e_4.error; } | ||
} | ||
} | ||
@@ -100,0 +167,0 @@ else { |
@@ -17,2 +17,29 @@ "use strict"; | ||
})(); | ||
var __values = (this && this.__values) || function(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
}; | ||
var __read = (this && this.__read) || function (o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -60,2 +87,3 @@ exports.Observable = void 0; | ||
Observable.prototype.set = function (value) { | ||
var e_1, _a; | ||
if (!this.inited || value !== this.cache) { | ||
@@ -67,6 +95,15 @@ this.cutoff(); | ||
delta.nv = this.getFormatedValue(); | ||
for (var _i = 0, _a = this.owner.observers.keys(); _i < _a.length; _i++) { | ||
var observer = _a[_i]; | ||
observer.markUpdate(this.owner); | ||
try { | ||
for (var _b = __values(this.owner.observers.keys()), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var observer = _c.value; | ||
observer.markUpdate(this.owner); | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
this.grow(); | ||
@@ -76,20 +113,49 @@ } | ||
Observable.prototype.cutoff = function () { | ||
var e_2, _a, e_3, _b; | ||
if (this.cache instanceof Obj_1.Obj) { | ||
for (var _i = 0, _a = this.owner.observers; _i < _a.length; _i++) { | ||
var observer = _a[_i][0]; | ||
var pending = []; | ||
this.cache.wilter(observer, this, pending); | ||
for (var _b = 0, pending_1 = pending; _b < pending_1.length; _b++) { | ||
var obj = pending_1[_b]; | ||
obj.wakeup(observer); | ||
try { | ||
for (var _c = __values(this.owner.observers), _d = _c.next(); !_d.done; _d = _c.next()) { | ||
var _e = __read(_d.value, 1), observer = _e[0]; | ||
var pending = []; | ||
this.cache.wilter(observer, this, pending); | ||
try { | ||
for (var pending_1 = (e_3 = void 0, __values(pending)), pending_1_1 = pending_1.next(); !pending_1_1.done; pending_1_1 = pending_1.next()) { | ||
var obj = pending_1_1.value; | ||
obj.wakeup(observer); | ||
} | ||
} | ||
catch (e_3_1) { e_3 = { error: e_3_1 }; } | ||
finally { | ||
try { | ||
if (pending_1_1 && !pending_1_1.done && (_b = pending_1.return)) _b.call(pending_1); | ||
} | ||
finally { if (e_3) throw e_3.error; } | ||
} | ||
} | ||
} | ||
catch (e_2_1) { e_2 = { error: e_2_1 }; } | ||
finally { | ||
try { | ||
if (_d && !_d.done && (_a = _c.return)) _a.call(_c); | ||
} | ||
finally { if (e_2) throw e_2.error; } | ||
} | ||
} | ||
}; | ||
Observable.prototype.grow = function () { | ||
var e_4, _a; | ||
if (this.cache instanceof Obj_1.Obj) { | ||
for (var _i = 0, _a = this.owner.observers; _i < _a.length; _i++) { | ||
var observer = _a[_i][0]; | ||
this.cache.grow(observer, this); | ||
try { | ||
for (var _b = __values(this.owner.observers), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var _d = __read(_c.value, 1), observer = _d[0]; | ||
this.cache.grow(observer, this); | ||
} | ||
} | ||
catch (e_4_1) { e_4 = { error: e_4_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
} | ||
finally { if (e_4) throw e_4.error; } | ||
} | ||
} | ||
@@ -96,0 +162,0 @@ }; |
159
Observer.js
"use strict"; | ||
var __values = (this && this.__values) || function(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
}; | ||
var __read = (this && this.__read) || function (o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -10,26 +37,63 @@ exports.Observer = exports.observe = exports.dirtyNodes = exports.dirtyProps = exports.globalDeltas = void 0; | ||
function sweep() { | ||
var e_1, _a, e_2, _b, e_3, _c, e_4, _d; | ||
var ret = []; | ||
for (var _i = 0, dirtyNodes_1 = exports.dirtyNodes; _i < dirtyNodes_1.length; _i++) { | ||
var node = dirtyNodes_1[_i]; | ||
node.backTraceDirtyPath(); | ||
try { | ||
for (var dirtyNodes_1 = __values(exports.dirtyNodes), dirtyNodes_1_1 = dirtyNodes_1.next(); !dirtyNodes_1_1.done; dirtyNodes_1_1 = dirtyNodes_1.next()) { | ||
var node = dirtyNodes_1_1.value; | ||
node.backTraceDirtyPath(); | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (dirtyNodes_1_1 && !dirtyNodes_1_1.done && (_a = dirtyNodes_1.return)) _a.call(dirtyNodes_1); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
exports.dirtyNodes.clear(); | ||
for (var _a = 0, tobeCleaned_1 = tobeCleaned; _a < tobeCleaned_1.length; _a++) { | ||
var obj = tobeCleaned_1[_a]; | ||
obj.forwardClearDirty(); | ||
try { | ||
for (var tobeCleaned_1 = __values(tobeCleaned), tobeCleaned_1_1 = tobeCleaned_1.next(); !tobeCleaned_1_1.done; tobeCleaned_1_1 = tobeCleaned_1.next()) { | ||
var obj = tobeCleaned_1_1.value; | ||
obj.forwardClearDirty(); | ||
} | ||
} | ||
for (var _b = 0, updatedObservers_1 = updatedObservers; _b < updatedObservers_1.length; _b++) { | ||
var observer = updatedObservers_1[_b]; | ||
var delta = observer.getDeltas(); | ||
if (Object.keys(delta).length > 0) { | ||
ret.push([observer, delta]); | ||
catch (e_2_1) { e_2 = { error: e_2_1 }; } | ||
finally { | ||
try { | ||
if (tobeCleaned_1_1 && !tobeCleaned_1_1.done && (_b = tobeCleaned_1.return)) _b.call(tobeCleaned_1); | ||
} | ||
finally { if (e_2) throw e_2.error; } | ||
} | ||
try { | ||
for (var updatedObservers_1 = __values(updatedObservers), updatedObservers_1_1 = updatedObservers_1.next(); !updatedObservers_1_1.done; updatedObservers_1_1 = updatedObservers_1.next()) { | ||
var observer = updatedObservers_1_1.value; | ||
var delta = observer.getDeltas(); | ||
if (Object.keys(delta).length > 0) { | ||
ret.push([observer, delta]); | ||
} | ||
} | ||
} | ||
catch (e_3_1) { e_3 = { error: e_3_1 }; } | ||
finally { | ||
try { | ||
if (updatedObservers_1_1 && !updatedObservers_1_1.done && (_c = updatedObservers_1.return)) _c.call(updatedObservers_1); | ||
} | ||
finally { if (e_3) throw e_3.error; } | ||
} | ||
updatedObservers.clear(); | ||
exports.globalDeltas.clear(); | ||
for (var _c = 0, ret_1 = ret; _c < ret_1.length; _c++) { | ||
var _d = ret_1[_c], observer = _d[0], delta = _d[1]; | ||
var cb = callbacks.get(observer); | ||
cb(delta); | ||
try { | ||
for (var ret_1 = __values(ret), ret_1_1 = ret_1.next(); !ret_1_1.done; ret_1_1 = ret_1.next()) { | ||
var _e = __read(ret_1_1.value, 2), observer = _e[0], delta = _e[1]; | ||
var cb = callbacks.get(observer); | ||
cb(delta); | ||
} | ||
} | ||
catch (e_4_1) { e_4 = { error: e_4_1 }; } | ||
finally { | ||
try { | ||
if (ret_1_1 && !ret_1_1.done && (_d = ret_1.return)) _d.call(ret_1); | ||
} | ||
finally { if (e_4) throw e_4.error; } | ||
} | ||
} | ||
@@ -79,31 +143,50 @@ setInterval(sweep, 0); | ||
Observer.prototype.getDeltas = function () { | ||
var e_5, _a, e_6, _b; | ||
var ret = {}; | ||
for (var _i = 0, _a = this.addRemove.entries(); _i < _a.length; _i++) { | ||
var _b = _a[_i], observable = _b[0], _c = _b[1], ov = _c[0], nv = _c[1]; | ||
if (ov === nv) | ||
continue; | ||
this.update.delete(observable); | ||
if (nv) { | ||
ret[observable.id] = { | ||
t: observable.isAry ? 'aa' : 'a', | ||
v: observable.snapshot() | ||
}; | ||
try { | ||
for (var _c = __values(this.addRemove.entries()), _d = _c.next(); !_d.done; _d = _c.next()) { | ||
var _e = __read(_d.value, 2), observable = _e[0], _f = __read(_e[1], 2), ov = _f[0], nv = _f[1]; | ||
if (ov === nv) | ||
continue; | ||
this.update.delete(observable); | ||
if (nv) { | ||
ret[observable.id] = { | ||
t: observable.isAry ? 'aa' : 'a', | ||
v: observable.snapshot() | ||
}; | ||
} | ||
else { | ||
ret[observable.id] = { | ||
t: observable.isAry ? 'da' : 'd', | ||
v: observable.lastSnapshot() | ||
}; | ||
} | ||
} | ||
else { | ||
ret[observable.id] = { | ||
t: observable.isAry ? 'da' : 'd', | ||
v: observable.lastSnapshot() | ||
}; | ||
} | ||
catch (e_5_1) { e_5 = { error: e_5_1 }; } | ||
finally { | ||
try { | ||
if (_d && !_d.done && (_a = _c.return)) _a.call(_c); | ||
} | ||
finally { if (e_5) throw e_5.error; } | ||
} | ||
for (var _d = 0, _e = this.update.keys(); _d < _e.length; _d++) { | ||
var observable = _e[_d]; | ||
var delta = exports.globalDeltas.get(observable); | ||
if (delta && Object.keys(delta).length > 0) { | ||
ret[observable.id] = { | ||
t: 'u', | ||
v: delta | ||
}; | ||
try { | ||
for (var _g = __values(this.update.keys()), _h = _g.next(); !_h.done; _h = _g.next()) { | ||
var observable = _h.value; | ||
var delta = exports.globalDeltas.get(observable); | ||
if (delta && Object.keys(delta).length > 0) { | ||
ret[observable.id] = { | ||
t: 'u', | ||
v: delta | ||
}; | ||
} | ||
} | ||
} | ||
catch (e_6_1) { e_6 = { error: e_6_1 }; } | ||
finally { | ||
try { | ||
if (_h && !_h.done && (_b = _g.return)) _b.call(_g); | ||
} | ||
finally { if (e_6) throw e_6.error; } | ||
} | ||
this.addRemove.clear(); | ||
@@ -110,0 +193,0 @@ this.update.clear(); |
{ | ||
"name": "ag-reactive", | ||
"version": "1.0.25", | ||
"version": "1.0.26", | ||
"description": "", | ||
@@ -8,3 +8,3 @@ "author": "", | ||
"devDependencies": { | ||
"ag-bundle": "^2.0.179" | ||
"ag-bundle": "^2.0.182" | ||
}, | ||
@@ -11,0 +11,0 @@ "dependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56685
1553