@cfcs/core
Advanced tools
Comparing version 0.0.25 to 0.0.26
@@ -16,6 +16,6 @@ /** | ||
class TestComputed { | ||
@Computed | ||
get ob3() { | ||
return ob1.current + ob2.current; | ||
} | ||
@Computed | ||
get ob3() { | ||
return ob1.current + ob2.current; | ||
} | ||
} | ||
@@ -22,0 +22,0 @@ const inst = new TestComputed(); |
@@ -7,3 +7,3 @@ /* | ||
repository: https://github.com/naver/cfcs | ||
version: 0.0.25 | ||
version: 0.0.26 | ||
*/ | ||
@@ -915,6 +915,6 @@ 'use strict'; | ||
class TestComputed { | ||
@Computed | ||
get ob3() { | ||
return ob1.current + ob2.current; | ||
} | ||
@Computed | ||
get ob3() { | ||
return ob1.current + ob2.current; | ||
} | ||
} | ||
@@ -948,10 +948,7 @@ const inst = new TestComputed(); | ||
}; | ||
prototype[COMPUTED_PATH] || (prototype[COMPUTED_PATH] = []); | ||
var computedList = prototype[COMPUTED_PATH]; | ||
if (COMPUTED_PATH in prototype) { | ||
prototype[COMPUTED_PATH] || (prototype[COMPUTED_PATH] = []); | ||
var computedList = prototype[COMPUTED_PATH]; | ||
if (computedList.indexOf(memberName) === -1) { | ||
computedList.push(memberName); | ||
} | ||
if (computedList.indexOf(memberName) === -1) { | ||
computedList.push(memberName); | ||
} | ||
@@ -958,0 +955,0 @@ |
@@ -7,3 +7,3 @@ /* | ||
repository: https://github.com/naver/cfcs | ||
version: 0.0.25 | ||
version: 0.0.26 | ||
*/ | ||
@@ -913,6 +913,6 @@ import Component from '@egjs/component'; | ||
class TestComputed { | ||
@Computed | ||
get ob3() { | ||
return ob1.current + ob2.current; | ||
} | ||
@Computed | ||
get ob3() { | ||
return ob1.current + ob2.current; | ||
} | ||
} | ||
@@ -946,10 +946,7 @@ const inst = new TestComputed(); | ||
}; | ||
prototype[COMPUTED_PATH] || (prototype[COMPUTED_PATH] = []); | ||
var computedList = prototype[COMPUTED_PATH]; | ||
if (COMPUTED_PATH in prototype) { | ||
prototype[COMPUTED_PATH] || (prototype[COMPUTED_PATH] = []); | ||
var computedList = prototype[COMPUTED_PATH]; | ||
if (computedList.indexOf(memberName) === -1) { | ||
computedList.push(memberName); | ||
} | ||
if (computedList.indexOf(memberName) === -1) { | ||
computedList.push(memberName); | ||
} | ||
@@ -956,0 +953,0 @@ |
@@ -7,3 +7,3 @@ /* | ||
repository: https://github.com/naver/cfcs | ||
version: 0.0.25 | ||
version: 0.0.26 | ||
*/ | ||
@@ -1317,6 +1317,6 @@ (function (global, factory) { | ||
class TestComputed { | ||
@Computed | ||
get ob3() { | ||
return ob1.current + ob2.current; | ||
} | ||
@Computed | ||
get ob3() { | ||
return ob1.current + ob2.current; | ||
} | ||
} | ||
@@ -1350,10 +1350,7 @@ const inst = new TestComputed(); | ||
}; | ||
prototype[COMPUTED_PATH] || (prototype[COMPUTED_PATH] = []); | ||
var computedList = prototype[COMPUTED_PATH]; | ||
if (COMPUTED_PATH in prototype) { | ||
prototype[COMPUTED_PATH] || (prototype[COMPUTED_PATH] = []); | ||
var computedList = prototype[COMPUTED_PATH]; | ||
if (computedList.indexOf(memberName) === -1) { | ||
computedList.push(memberName); | ||
} | ||
if (computedList.indexOf(memberName) === -1) { | ||
computedList.push(memberName); | ||
} | ||
@@ -1360,0 +1357,0 @@ |
@@ -7,5 +7,5 @@ /* | ||
repository: https://github.com/naver/cfcs | ||
version: 0.0.25 | ||
version: 0.0.26 | ||
*/ | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t="undefined"!=typeof globalThis?globalThis:t||self).cfcs=n()}(this,function(){"use strict";function _(t){return Object.keys(t)}function e(t){return"string"==typeof t}function n(t){return"object"==typeof t}function g(t){return"function"==typeof t}var r="__observers__",o="__computed__",i=1,u="__CFCS_DETECTED_DEPENDENCIES__",c=function(t,n){return(c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])})(t,n)};function m(t,n,e){if(e||2===arguments.length)for(var r,i=0,o=n.length;i<o;i++)!r&&i in n||((r=r||Array.prototype.slice.call(n,0,i))[i]=n[i]);return t.concat(r||Array.prototype.slice.call(n))}function f(){Object[u]=Object[u]||{};var t=Object[u];return t[i]=t[i]||[],t[i]}function a(t){var n="function"==typeof Symbol&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&r>=t.length?void 0:t)&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(){for(var t=[],n=0;n<arguments.length;n++)t=t.concat(function(t,n){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,i,o=e.call(t),u=[];try{for(;(void 0===n||0<n--)&&!(r=o.next()).done;)u.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(e=o.return)&&e.call(o)}finally{if(i)throw i.error}}return u}(arguments[n]));return t}function l(t){return void 0===t}var h=function(){function t(t,n){var e,r;if(this._canceled=!1,n)try{for(var i=a(Object.keys(n)),o=i.next();!o.done;o=i.next()){var u=o.value;this[u]=n[u]}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}this.eventType=t}var n=t.prototype;return n.stop=function(){this._canceled=!0},n.isCanceled=function(){return this._canceled},t}(),O=function(){function t(){this._eventHandler={}}var n=t.prototype;return n.trigger=function(n){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];var r=n instanceof h?n.eventType:n,r=s(this._eventHandler[r]||[]);return r.length<=0||(n instanceof h?(n.currentTarget=this,r.forEach(function(t){t(n)})):r.forEach(function(t){t.apply(void 0,s(e))})),this},n.once=function(e,r){var i,o=this;if("object"==typeof e&&l(r)){var t,n=e;for(t in n)this.once(t,n[t])}else"string"==typeof e&&"function"==typeof r&&(i=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];r.apply(void 0,s(t)),o.off(e,i)},this.on(e,i));return this},n.hasOn=function(t){return!!this._eventHandler[t]},n.on=function(t,n){if("object"==typeof t&&l(n)){var e,r=t;for(e in r)this.on(e,r[e])}else{var i;"string"==typeof t&&"function"==typeof n&&(i=this._eventHandler[t],l(i)&&(this._eventHandler[t]=[],i=this._eventHandler[t]),i.push(n))}return this},n.off=function(t,n){var e,r;if(l(t))return this._eventHandler={},this;if(l(n)){if("string"==typeof t)return delete this._eventHandler[t],this;var i,o=t;for(i in o)this.off(i,o[i])}else{var u=this._eventHandler[t];if(u){var c=0;try{for(var f=a(u),s=f.next();!s.done;s=f.next()){if(s.value===n){u.splice(c,1),u.length<=0&&delete this._eventHandler[t];break}c++}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=f.return)&&r.call(f)}finally{if(e)throw e.error}}}}return this},t.VERSION="3.0.4",t}(),v=function(){function t(t){this._emitter=new O,this._current=t}var n=t.prototype;return Object.defineProperty(n,"current",{get:function(){var t=(t=f())[t.length-1];return null!=t&&t.push(this),this._current},set:function(t){this._setCurrent(t)},enumerable:!1,configurable:!0}),n.subscribe=function(t){return this.current,this._emitter.on("update",t),this},n.unsubscribe=function(t){return this._emitter.off("update",t),this},n._setCurrent=function(t){var n=this._current,e=t!==n;this._current=t,e&&this._emitter.trigger("update",t,n)},n.toString=function(){return"".concat(this.current)},n.valueOf=function(){return this.current},t}(),p=function(e){var t=i,n=e;if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}function i(t){var n=e.call(this)||this;return n._computedCallback=t,n._registered=[],n._onCheckUpdate=function(){n._setCurrent(n.current)},n._current=n.current,n}return c(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r),Object.defineProperty(i.prototype,"current",{get:function(){var n,e,r=this,t=(n=this,t=f(),i={host:n,observers:e=[],push:function(t){n!==t&&-1===e.indexOf(t)&&e.push(t)}},t.push(i),this._computedCallback()),i=f().pop();return this._registered.forEach(function(t){t.unsubscribe(r._onCheckUpdate)}),i.observers.forEach(function(t){t.subscribe(r._onCheckUpdate)}),this._registered=i.observers,t},enumerable:!1,configurable:!0}),i}(v);function d(t,n,e){void 0===e&&(e=n),Object.defineProperty(t,n,{configurable:!0,get:function(){return x(this,e).current},set:function(t){x(this,e,t).current=t}}),e!==n&&Object.defineProperty(t,e,{configurable:!0,get:function(){return x(this,e).current}})}function b(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 1<e.length?d(e[0],e[1]):function(t,n){return d(t,n,e[0])}}function y(t){t.subscribe=function(t,n){this[t],x(this,t).subscribe(n)},t.unsubscribe=function(t,n){var e=this;t?t in this&&x(this,t).unsubscribe(n):_(S(this)).forEach(function(t){e.unsubscribe(t)})}}function t(t){var e=g(t)?t():t,r={};return w(r),_(e).forEach(function(t){var n=e[t];P(n)?H(r,t,n):H(r,t,E(n)),b(t)(r,t)}),y(r),r}function E(t){return new v(t)}function j(t){return new p(t)}function C(i,t){var n={};return t&&t.forEach(function(r){n[r]=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=i.current||i.value;return e[r].apply(e,t)}}),n}function w(t){var n={};return Object.defineProperty(t,r,{get:function(){return n}}),n}function S(n,t){n[r]||w(n);var e=n[r];return t||(t=null==(t=null==(t=null==n?void 0:n.constructor)?void 0:t.prototype)?void 0:t[o])&&t.forEach(function(t){!(t in e)&&t in n&&n[t]}),e}function x(t,n,e){t=S(t);return t[n]||(t[n]=E(e)),t[n]}function H(t,n,e){S(t)[n]=e}function P(t){return t&&n(t)&&"current"in t&&"subscribe"in t&&"unsubscribe"in t}return{__proto__:null,keys:_,camelize:function(t){return t.replace(/[\s-_]([a-z])/g,function(t,n){return n.toUpperCase()})},isString:e,isObject:n,isFunction:g,findTarget:function(t){var n;return t?(e(t)?n=document.querySelector(t):t instanceof Element?n=t:("value"in t||"current"in t)&&(n=t.value||t.current),n):null},withClassMethods:function(n){return function(t,i){n.forEach(function(r){r in t||(t[r]=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=(e=this[i])[r].apply(e,t);return e===this[i]?this:e})})}},withReactiveMethods:C,defineObservers:w,getObservers:S,getObserver:x,setObserver:H,isObserver:P,isReactive:function(t){return t&&!P(t)&&"subscribe"in t&&"unsubscribe"in t},Observer:v,ComputedObserver:p,reactive:t,partialReactive:t,observe:E,computed:j,adaptReactive:function(t,n){var o=g(t)?{setup:t}:t;function r(){var t;return null!=(t=null!=(t=null!=(t=null==n?void 0:n())?t:null==(t=o.props)?void 0:t.call(o))?t:null==(t=o.data)?void 0:t.call(o))?t:{}}function e(t){s.push(t)}function i(t){d=t}function u(t){b=t}function c(t){y=t}var f=new O,s=[],a=[],l=[],h=[],v={current:null},p=[],d=null,b=[],y=[];return o.setup&&(v.current=o.setup({getProps:r,setInitialState:i,setEvents:u,setMethods:c,onMounted:e,onDestroy:function(t){l.push(t)},onInit:function(t){a.push(t)},emit:function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];f.trigger.apply(f,m([t],n,!1))},on:function(t){h.push(t)}})||null),o.created&&(v.current=o.created(r())||null),o.events&&u(o.events),o.state&&i(o.state),o.methods&&c(o.methods),o.mounted&&e(o.mounted),o.destroy&&l.push(o.destroy),o.init&&a.push(o.init),o.on&&h.push(function(n,e,r){var i=o.on(n,e,r);return function(){var t;i&&i(),null!=(t=o.off)&&t.call(o,n,e,r)}}),{events:function(){return b},state:function(){var e,t=v.current;return d||(t&&(e=S(t),i(_(e).reduce(function(t,n){return t[n]=e[n].current,t},{}))),d||{})},instance:function(){return v.current},mounted:function(){var n=r();s.forEach(function(t){v.current=t(n,v.current)||v.current})},init:function(){var n=v.current,e=r();p=b.map(function(e){function n(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];f.trigger.apply(f,m([e],t,!1))}var r=v.current;return h.map(function(t){return t(r,e,n)}).filter(Boolean)}),a.forEach(function(t){t(n,e)})},destroy:function(){p.forEach(function(t){t.forEach(function(t){t()})}),f.off();var n=v.current,e=r();l.forEach(function(t){t(n,e)})},methods:function(){return C(v,y)},on:function(t,n){f.on(t,n)},off:function(t,n){f.off(t,n)}}},Observe:b,Reactive:function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return b.apply(void 0,t)},Computed:function(t,n,e){var r,i=e.get,e={configurable:!0,get:function(){var t=S(this,!0);return n in t||(t[n]=j(i.bind(this))),x(this,n).current}};return o in t&&(t[o]||(t[o]=[]),-1===(r=t[o]).indexOf(n)&&r.push(n)),Object.defineProperty(t,n,e),e},injectReactiveSubscribe:y,ReactiveSubscribe:function(t){y(t.prototype)}}}); | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t="undefined"!=typeof globalThis?globalThis:t||self).cfcs=n()}(this,function(){"use strict";function _(t){return Object.keys(t)}function e(t){return"string"==typeof t}function n(t){return"object"==typeof t}function g(t){return"function"==typeof t}var r="__observers__",i="__computed__",o=1,u="__CFCS_DETECTED_DEPENDENCIES__",c=function(t,n){return(c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])})(t,n)};function m(t,n,e){if(e||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||((r=r||Array.prototype.slice.call(n,0,o))[o]=n[o]);return t.concat(r||Array.prototype.slice.call(n))}function f(){Object[u]=Object[u]||{};var t=Object[u];return t[o]=t[o]||[],t[o]}function a(t){var n="function"==typeof Symbol&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&r>=t.length?void 0:t)&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(){for(var t=[],n=0;n<arguments.length;n++)t=t.concat(function(t,n){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),u=[];try{for(;(void 0===n||0<n--)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return u}(arguments[n]));return t}function l(t){return void 0===t}var h=function(){function t(t,n){var e,r;if(this._canceled=!1,n)try{for(var o=a(Object.keys(n)),i=o.next();!i.done;i=o.next()){var u=i.value;this[u]=n[u]}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}this.eventType=t}var n=t.prototype;return n.stop=function(){this._canceled=!0},n.isCanceled=function(){return this._canceled},t}(),O=function(){function t(){this._eventHandler={}}var n=t.prototype;return n.trigger=function(n){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];var r=n instanceof h?n.eventType:n,r=s(this._eventHandler[r]||[]);return r.length<=0||(n instanceof h?(n.currentTarget=this,r.forEach(function(t){t(n)})):r.forEach(function(t){t.apply(void 0,s(e))})),this},n.once=function(e,r){var o,i=this;if("object"==typeof e&&l(r)){var t,n=e;for(t in n)this.once(t,n[t])}else"string"==typeof e&&"function"==typeof r&&(o=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];r.apply(void 0,s(t)),i.off(e,o)},this.on(e,o));return this},n.hasOn=function(t){return!!this._eventHandler[t]},n.on=function(t,n){if("object"==typeof t&&l(n)){var e,r=t;for(e in r)this.on(e,r[e])}else{var o;"string"==typeof t&&"function"==typeof n&&(o=this._eventHandler[t],l(o)&&(this._eventHandler[t]=[],o=this._eventHandler[t]),o.push(n))}return this},n.off=function(t,n){var e,r;if(l(t))return this._eventHandler={},this;if(l(n)){if("string"==typeof t)return delete this._eventHandler[t],this;var o,i=t;for(o in i)this.off(o,i[o])}else{var u=this._eventHandler[t];if(u){var c=0;try{for(var f=a(u),s=f.next();!s.done;s=f.next()){if(s.value===n){u.splice(c,1),u.length<=0&&delete this._eventHandler[t];break}c++}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=f.return)&&r.call(f)}finally{if(e)throw e.error}}}}return this},t.VERSION="3.0.4",t}(),v=function(){function t(t){this._emitter=new O,this._current=t}var n=t.prototype;return Object.defineProperty(n,"current",{get:function(){var t=(t=f())[t.length-1];return null!=t&&t.push(this),this._current},set:function(t){this._setCurrent(t)},enumerable:!1,configurable:!0}),n.subscribe=function(t){return this.current,this._emitter.on("update",t),this},n.unsubscribe=function(t){return this._emitter.off("update",t),this},n._setCurrent=function(t){var n=this._current,e=t!==n;this._current=t,e&&this._emitter.trigger("update",t,n)},n.toString=function(){return"".concat(this.current)},n.valueOf=function(){return this.current},t}(),p=function(e){var t=o,n=e;if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}function o(t){var n=e.call(this)||this;return n._computedCallback=t,n._registered=[],n._onCheckUpdate=function(){n._setCurrent(n.current)},n._current=n.current,n}return c(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r),Object.defineProperty(o.prototype,"current",{get:function(){var n,e,r=this,t=(n=this,t=f(),o={host:n,observers:e=[],push:function(t){n!==t&&-1===e.indexOf(t)&&e.push(t)}},t.push(o),this._computedCallback()),o=f().pop();return this._registered.forEach(function(t){t.unsubscribe(r._onCheckUpdate)}),o.observers.forEach(function(t){t.subscribe(r._onCheckUpdate)}),this._registered=o.observers,t},enumerable:!1,configurable:!0}),o}(v);function d(t,n,e){void 0===e&&(e=n),Object.defineProperty(t,n,{configurable:!0,get:function(){return x(this,e).current},set:function(t){x(this,e,t).current=t}}),e!==n&&Object.defineProperty(t,e,{configurable:!0,get:function(){return x(this,e).current}})}function b(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 1<e.length?d(e[0],e[1]):function(t,n){return d(t,n,e[0])}}function y(t){t.subscribe=function(t,n){this[t],x(this,t).subscribe(n)},t.unsubscribe=function(t,n){var e=this;t?t in this&&x(this,t).unsubscribe(n):_(S(this)).forEach(function(t){e.unsubscribe(t)})}}function t(t){var e=g(t)?t():t,r={};return w(r),_(e).forEach(function(t){var n=e[t];P(n)?H(r,t,n):H(r,t,E(n)),b(t)(r,t)}),y(r),r}function E(t){return new v(t)}function j(t){return new p(t)}function C(o,t){var n={};return t&&t.forEach(function(r){n[r]=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=o.current||o.value;return e[r].apply(e,t)}}),n}function w(t){var n={};return Object.defineProperty(t,r,{get:function(){return n}}),n}function S(n,t){n[r]||w(n);var e=n[r];return t||(t=null==(t=null==(t=null==n?void 0:n.constructor)?void 0:t.prototype)?void 0:t[i])&&t.forEach(function(t){!(t in e)&&t in n&&n[t]}),e}function x(t,n,e){t=S(t);return t[n]||(t[n]=E(e)),t[n]}function H(t,n,e){S(t)[n]=e}function P(t){return t&&n(t)&&"current"in t&&"subscribe"in t&&"unsubscribe"in t}return{__proto__:null,keys:_,camelize:function(t){return t.replace(/[\s-_]([a-z])/g,function(t,n){return n.toUpperCase()})},isString:e,isObject:n,isFunction:g,findTarget:function(t){var n;return t?(e(t)?n=document.querySelector(t):t instanceof Element?n=t:("value"in t||"current"in t)&&(n=t.value||t.current),n):null},withClassMethods:function(n){return function(t,o){n.forEach(function(r){r in t||(t[r]=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=(e=this[o])[r].apply(e,t);return e===this[o]?this:e})})}},withReactiveMethods:C,defineObservers:w,getObservers:S,getObserver:x,setObserver:H,isObserver:P,isReactive:function(t){return t&&!P(t)&&"subscribe"in t&&"unsubscribe"in t},Observer:v,ComputedObserver:p,reactive:t,partialReactive:t,observe:E,computed:j,adaptReactive:function(t,n){var i=g(t)?{setup:t}:t;function r(){var t;return null!=(t=null!=(t=null!=(t=null==n?void 0:n())?t:null==(t=i.props)?void 0:t.call(i))?t:null==(t=i.data)?void 0:t.call(i))?t:{}}function e(t){s.push(t)}function o(t){d=t}function u(t){b=t}function c(t){y=t}var f=new O,s=[],a=[],l=[],h=[],v={current:null},p=[],d=null,b=[],y=[];return i.setup&&(v.current=i.setup({getProps:r,setInitialState:o,setEvents:u,setMethods:c,onMounted:e,onDestroy:function(t){l.push(t)},onInit:function(t){a.push(t)},emit:function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];f.trigger.apply(f,m([t],n,!1))},on:function(t){h.push(t)}})||null),i.created&&(v.current=i.created(r())||null),i.events&&u(i.events),i.state&&o(i.state),i.methods&&c(i.methods),i.mounted&&e(i.mounted),i.destroy&&l.push(i.destroy),i.init&&a.push(i.init),i.on&&h.push(function(n,e,r){var o=i.on(n,e,r);return function(){var t;o&&o(),null!=(t=i.off)&&t.call(i,n,e,r)}}),{events:function(){return b},state:function(){var e,t=v.current;return d||(t&&(e=S(t),o(_(e).reduce(function(t,n){return t[n]=e[n].current,t},{}))),d||{})},instance:function(){return v.current},mounted:function(){var n=r();s.forEach(function(t){v.current=t(n,v.current)||v.current})},init:function(){var n=v.current,e=r();p=b.map(function(e){function n(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];f.trigger.apply(f,m([e],t,!1))}var r=v.current;return h.map(function(t){return t(r,e,n)}).filter(Boolean)}),a.forEach(function(t){t(n,e)})},destroy:function(){p.forEach(function(t){t.forEach(function(t){t()})}),f.off();var n=v.current,e=r();l.forEach(function(t){t(n,e)})},methods:function(){return C(v,y)},on:function(t,n){f.on(t,n)},off:function(t,n){f.off(t,n)}}},Observe:b,Reactive:function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return b.apply(void 0,t)},Computed:function(t,n,e){var r=e.get,e={configurable:!0,get:function(){var t=S(this,!0);return n in t||(t[n]=j(r.bind(this))),x(this,n).current}},o=(t[i]||(t[i]=[]),t[i]);return-1===o.indexOf(n)&&o.push(n),Object.defineProperty(t,n,e),e},injectReactiveSubscribe:y,ReactiveSubscribe:function(t){y(t.prototype)}}}); | ||
//# sourceMappingURL=cfcs.min.js.map |
{ | ||
"name": "@cfcs/core", | ||
"version": "0.0.25", | ||
"version": "0.0.26", | ||
"description": "CFCs(Cross Framework Components) are modules that convert components into framework usage", | ||
@@ -5,0 +5,0 @@ "main": "dist/cfcs.cjs.js", |
@@ -51,9 +51,7 @@ import { COMPUTED_PATH } from "../const"; | ||
if (COMPUTED_PATH in prototype) { | ||
prototype[COMPUTED_PATH] ||= []; | ||
const computedList = prototype[COMPUTED_PATH]; | ||
prototype[COMPUTED_PATH] ||= []; | ||
const computedList = prototype[COMPUTED_PATH]; | ||
if (computedList.indexOf(memberName) === -1) { | ||
computedList.push(memberName); | ||
} | ||
if (computedList.indexOf(memberName) === -1) { | ||
computedList.push(memberName); | ||
} | ||
@@ -60,0 +58,0 @@ Object.defineProperty(prototype, memberName, nextAttributes); |
@@ -5,172 +5,159 @@ import * as Sinon from "sinon"; | ||
describe("computed", () => { | ||
describe("computed instance", () => { | ||
it("should check the calculated value", () => { | ||
// Given | ||
const ob1 = observe(0); | ||
const ob2 = observe(1); | ||
describe("computed instance", () => { | ||
it("should check the calculated value", () => { | ||
// Given | ||
const ob1 = observe(0); | ||
const ob2 = observe(1); | ||
// When | ||
const ob3 = computed(() => ob1.current + ob2.current); | ||
// When | ||
const ob3 = computed(() => ob1.current + ob2.current); | ||
// Then | ||
expect(ob3.current).toBe(1); | ||
}); | ||
it("should check if the value is calculated when the value changes", () => { | ||
// Given | ||
const ob1 = observe(0); | ||
const ob2 = observe(1); | ||
const ob3 = computed(() => ob1.current + ob2.current); | ||
// Then | ||
expect(ob3.current).toBe(1); | ||
}); | ||
it("should check if the value is calculated when the value changes", () => { | ||
// Given | ||
const ob1 = observe(0); | ||
const ob2 = observe(1); | ||
const ob3 = computed(() => ob1.current + ob2.current); | ||
// Whensp | ||
ob2.current = 2; | ||
// Whensp | ||
ob2.current = 2; | ||
// Then | ||
expect(ob3.current).toBe(2); | ||
}); | ||
it("should check if an event fires when the value changes", () => { | ||
// Given | ||
const ob1 = observe(0); | ||
const ob2 = observe(1); | ||
const ob3 = computed(() => ob1.current + ob2.current); | ||
const subscribeSpy = Sinon.spy(); | ||
// Then | ||
expect(ob3.current).toBe(2); | ||
}); | ||
it("should check if an event fires when the value changes", () => { | ||
// Given | ||
const ob1 = observe(0); | ||
const ob2 = observe(1); | ||
const ob3 = computed(() => ob1.current + ob2.current); | ||
const subscribeSpy = Sinon.spy(); | ||
ob3.subscribe(subscribeSpy); | ||
ob3.subscribe(subscribeSpy); | ||
// When | ||
ob2.current = 2; | ||
// When | ||
ob2.current = 2; | ||
// Then | ||
expect(subscribeSpy.calledOnce).toBe(true); | ||
// Then | ||
expect(subscribeSpy.calledOnce).toBe(true); | ||
}); | ||
}); | ||
}); | ||
describe("Computed decorator", () => { | ||
it("should check Computed decorator", () => { | ||
// Given | ||
const ob1 = observe(0); | ||
const ob2 = observe(1); | ||
describe("Computed decorator", () => { | ||
it("should check Computed decorator", () => { | ||
// Given | ||
const ob1 = observe(0); | ||
const ob2 = observe(1); | ||
// When | ||
@ReactiveSubscribe | ||
class TestComputed { | ||
@Computed | ||
get ob3() { | ||
return ob1.current + ob2.current; | ||
} | ||
} | ||
const inst = new TestComputed(); | ||
// When | ||
@ReactiveSubscribe | ||
class TestComputed { | ||
@Computed | ||
get ob3() { | ||
return ob1.current + ob2.current; | ||
} | ||
} | ||
const inst = new TestComputed(); | ||
// Then | ||
expect(inst.ob3).toBe(1); | ||
}); | ||
it("Check if the value is calculated even if the value changes", () => { | ||
// Given | ||
const ob1 = observe(0); | ||
const ob2 = observe(1); | ||
// Then | ||
expect(inst.ob3).toBe(1); | ||
}); | ||
it("Check if the value is calculated even if the value changes", () => { | ||
// Given | ||
const ob1 = observe(0); | ||
const ob2 = observe(1); | ||
// When | ||
@ReactiveSubscribe | ||
class TestComputed { | ||
@Computed | ||
get ob3() { | ||
return ob1.current + ob2.current; | ||
} | ||
} | ||
const inst = new TestComputed(); | ||
ob2.current = 2; | ||
// When | ||
@ReactiveSubscribe | ||
class TestComputed { | ||
@Computed | ||
get ob3() { | ||
return ob1.current + ob2.current; | ||
} | ||
} | ||
const inst = new TestComputed(); | ||
ob2.current = 2; | ||
// Then | ||
expect(inst.ob3).toBe(2); | ||
}); | ||
it("should check if an event fires when the value changes", () => { | ||
// Given | ||
const ob1 = observe(0); | ||
const ob2 = observe(1); | ||
// Then | ||
expect(inst.ob3).toBe(2); | ||
}); | ||
it("should check if an event fires when the value changes", () => { | ||
// Given | ||
const ob1 = observe(0); | ||
const ob2 = observe(1); | ||
@ReactiveSubscribe | ||
class TestComputed { | ||
@Computed | ||
get ob3() { | ||
console.log("GET"); | ||
return ob1.current + ob2.current; | ||
} | ||
} | ||
interface TestComputed extends ReactiveSubscribe<{ ob3: number }> { } | ||
const inst = new TestComputed(); | ||
const subscribeSpy = Sinon.spy(); | ||
@ReactiveSubscribe | ||
class TestComputed { | ||
@Computed | ||
get ob3() { | ||
console.log("GET"); | ||
return ob1.current + ob2.current; | ||
} | ||
} | ||
interface TestComputed extends ReactiveSubscribe<{ ob3: number }> {} | ||
const inst = new TestComputed(); | ||
const subscribeSpy = Sinon.spy(); | ||
inst.subscribe("ob3", subscribeSpy); | ||
inst.subscribe("ob3", subscribeSpy); | ||
// When | ||
ob2.current = 2; | ||
// When | ||
ob2.current = 2; | ||
// Then | ||
expect(subscribeSpy.calledOnce).toBe(true); | ||
expect(subscribeSpy.args[0][0]).toBe(2); | ||
}); | ||
it("should check if an event fires even if the values of both instances change", () => { | ||
// Given | ||
@ReactiveSubscribe | ||
class TestComputed { | ||
@Observe ob1 = 0; | ||
@Observe ob2 = 1; | ||
@Computed | ||
get ob3() { | ||
return this.ob1 + this.ob2; | ||
} | ||
} | ||
interface TestComputed extends ReactiveSubscribe<{ ob3: number }> { } | ||
const inst1 = new TestComputed(); | ||
const inst2 = new TestComputed(); | ||
const subscribeSpy = Sinon.spy(); | ||
// Then | ||
expect(subscribeSpy.calledOnce).toBe(true); | ||
expect(subscribeSpy.args[0][0]).toBe(2); | ||
}); | ||
it("should check if an event fires even if the values of both instances change", () => { | ||
// Given | ||
@ReactiveSubscribe | ||
class TestComputed { | ||
@Observe ob1 = 0; | ||
@Observe ob2 = 1; | ||
@Computed | ||
get ob3() { | ||
return this.ob1 + this.ob2; | ||
} | ||
} | ||
interface TestComputed extends ReactiveSubscribe<{ ob3: number }> {} | ||
const inst1 = new TestComputed(); | ||
const inst2 = new TestComputed(); | ||
const subscribeSpy = Sinon.spy(); | ||
// When | ||
const ob4 = computed(() => inst1.ob3 + inst2.ob3); | ||
ob4.subscribe(subscribeSpy); | ||
inst1.ob1 = 1; | ||
// When | ||
const ob4 = computed(() => inst1.ob3 + inst2.ob3); | ||
ob4.subscribe(subscribeSpy); | ||
inst1.ob1 = 1; | ||
// Then | ||
expect(subscribeSpy.calledOnce).toBe(true); | ||
expect(subscribeSpy.args[0][0]).toBe(3); | ||
expect(ob4.current).toBe(3); | ||
}); | ||
it("should check if an event fires even if the values of both instances change", () => { | ||
// Given | ||
@ReactiveSubscribe | ||
class TestComputed { | ||
@Observe ob1 = 0; | ||
@Observe ob2 = 1; | ||
@Computed | ||
get ob3() { | ||
return this.ob1 + this.ob2; | ||
} | ||
} | ||
interface TestComputed extends ReactiveSubscribe<{ ob3: number }> { } | ||
const inst1 = new TestComputed(); | ||
const inst2 = new TestComputed(); | ||
const subscribeSpy = Sinon.spy(); | ||
// Then | ||
expect(subscribeSpy.calledOnce).toBe(true); | ||
expect(subscribeSpy.args[0][0]).toBe(3); | ||
expect(ob4.current).toBe(3); | ||
}); | ||
it("should check if an event fires even if the values of both instances change", () => { | ||
// Given | ||
@ReactiveSubscribe | ||
class TestComputed { | ||
@Observe ob1 = 0; | ||
@Observe ob2 = 1; | ||
@Computed | ||
get ob3() { | ||
return this.ob1 + this.ob2; | ||
} | ||
} | ||
interface TestComputed extends ReactiveSubscribe<{ ob3: number }> {} | ||
const inst1 = new TestComputed(); | ||
const inst2 = new TestComputed(); | ||
const subscribeSpy = Sinon.spy(); | ||
// When | ||
const ob4 = computed(() => inst1.ob3 + inst2.ob3); | ||
ob4.subscribe(subscribeSpy); | ||
inst1.ob1 = 1; | ||
// When | ||
const ob4 = computed(() => inst1.ob3 + inst2.ob3); | ||
ob4.subscribe(subscribeSpy); | ||
inst1.ob1 = 1; | ||
// Then | ||
expect(subscribeSpy.calledOnce).toBe(true); | ||
expect(subscribeSpy.args[0][0]).toBe(3); | ||
expect(ob4.current).toBe(3); | ||
// Then | ||
expect(subscribeSpy.calledOnce).toBe(true); | ||
expect(subscribeSpy.args[0][0]).toBe(3); | ||
expect(ob4.current).toBe(3); | ||
}); | ||
}); | ||
it("should check if an event fires even if the values of both instances change", () => { | ||
// Given | ||
@ReactiveSubscribe | ||
class TestComputed { | ||
@Observe ob1 = 0; | ||
@Observe ob2 = 1; | ||
@Computed | ||
get ob3() { | ||
console.log(this.ob3); | ||
return this.ob1 + this.ob2; | ||
} | ||
} | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
350124
4799