@cfcs/core
Advanced tools
Comparing version 0.0.8 to 0.0.9
import Component from "@egjs/component"; | ||
interface EmitterEvents<Value> { | ||
update: (value: Value) => void; | ||
update: (value: Value, prevValue: Value) => void; | ||
} | ||
@@ -17,4 +17,4 @@ /** | ||
set current(value: Value); | ||
subscribe(callback: (value: Value) => void): this; | ||
unsubscribe(callback?: (value: Value) => void): this; | ||
subscribe(callback: (value: Value, prevValue: Value) => void): this; | ||
unsubscribe(callback?: (value: Value, prevValue: Value) => void): this; | ||
protected _setCurrent(value: Value): void; | ||
@@ -21,0 +21,0 @@ toString(): string; |
@@ -7,3 +7,3 @@ /* | ||
repository: https://github.com/naver/cfcs | ||
version: 0.0.8 | ||
version: 0.0.9 | ||
*/ | ||
@@ -201,7 +201,8 @@ 'use strict'; | ||
__proto._setCurrent = function (value) { | ||
var isUpdate = value !== this._current; | ||
var prevValue = this._current; | ||
var isUpdate = value !== prevValue; | ||
this._current = value; | ||
if (isUpdate) { | ||
this._emitter.trigger("update", value); | ||
this._emitter.trigger("update", value, prevValue); | ||
} | ||
@@ -208,0 +209,0 @@ }; |
@@ -7,3 +7,3 @@ /* | ||
repository: https://github.com/naver/cfcs | ||
version: 0.0.8 | ||
version: 0.0.9 | ||
*/ | ||
@@ -199,7 +199,8 @@ import Component from '@egjs/component'; | ||
__proto._setCurrent = function (value) { | ||
var isUpdate = value !== this._current; | ||
var prevValue = this._current; | ||
var isUpdate = value !== prevValue; | ||
this._current = value; | ||
if (isUpdate) { | ||
this._emitter.trigger("update", value); | ||
this._emitter.trigger("update", value, prevValue); | ||
} | ||
@@ -206,0 +207,0 @@ }; |
@@ -7,3 +7,3 @@ /* | ||
repository: https://github.com/naver/cfcs | ||
version: 0.0.8 | ||
version: 0.0.9 | ||
*/ | ||
@@ -603,7 +603,8 @@ (function (global, factory) { | ||
__proto._setCurrent = function (value) { | ||
var isUpdate = value !== this._current; | ||
var prevValue = this._current; | ||
var isUpdate = value !== prevValue; | ||
this._current = value; | ||
if (isUpdate) { | ||
this._emitter.trigger("update", value); | ||
this._emitter.trigger("update", value, prevValue); | ||
} | ||
@@ -610,0 +611,0 @@ }; |
@@ -7,5 +7,5 @@ /* | ||
repository: https://github.com/naver/cfcs | ||
version: 0.0.8 | ||
version: 0.0.9 | ||
*/ | ||
!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 u(t){return Object.keys(t)}function e(t){return"string"==typeof t}function n(t){return"object"==typeof t}function i(t){return"function"==typeof t}var r="__observers__",o=1,c="__CFCS_DETECTED_DEPENDENCIES__",f=function(t,n){return(f=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 s(){Object[c]=Object[c]||{};var t=Object[c];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 l(){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 h(t){return void 0===t}var v=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}(),p=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 v?n.eventType:n,r=l(this._eventHandler[r]||[]);return r.length<=0||(n instanceof v?(n.currentTarget=this,r.forEach(function(t){t(n)})):r.forEach(function(t){t.apply(void 0,l(e))})),this},n.once=function(e,r){var i,o=this;if("object"==typeof e&&h(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,l(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&&h(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],h(i)&&(this._eventHandler[t]=[],i=this._eventHandler[t]),i.push(n))}return this},n.off=function(t,n){var e,r;if(h(t))return this._eventHandler={},this;if(h(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.3",t}(),d=function(){function t(t){this._emitter=new p,this._current=t}var n=t.prototype;return Object.defineProperty(n,"current",{get:function(){var t=(t=s())[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=t!==this._current;this._current=t,n&&this._emitter.trigger("update",t)},n.toString=function(){return"".concat(this.current)},n.valueOf=function(){return this.current},t}(),b=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 f(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=s(),i={host:n,observers:e=[],push:function(t){n!==t&&-1===e.indexOf(t)&&e.push(t)}},t.push(i),this._computedCallback()),i=s().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}(d);function y(t,n,e){void 0===e&&(e=n),Object.defineProperty(t,n,{configurable:!0,get:function(){return w(this,e).current},set:function(t){w(this,e,t).current=t}}),e!==n&&Object.defineProperty(t,e,{configurable:!0,get:function(){return w(this,e).current}})}function _(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 1<e.length?y(e[0],e[1]):function(t,n){return y(t,n,e[0])}}function g(t){t.subscribe=function(t,n){this[t],w(this,t).subscribe(n)},t.unsubscribe=function(t,n){var e=this;t?t in this&&w(this,t).unsubscribe(n):u(C(this)).forEach(function(t){e.unsubscribe(t)})}}function O(t){return new b(t)}function m(t){return new d(t)}function j(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 E(t){var n={};return Object.defineProperty(t,r,{get:function(){return n}}),n}function C(t){return t[r]||E(t),t[r]}function w(t,n,e){t=C(t);return t[n]||(t[n]=m(e)),t[n]}function S(t,n,e){C(t)[n]=e}function x(t){return t&&n(t)&&"current"in t&&"subscribe"in t&&"unsubscribe"in t}return{__proto__:null,keys:u,camelize:function(t){return t.replace(/[\s-_]([a-z])/g,function(t,n){return n.toUpperCase()})},isString:e,isObject:n,isFunction:i,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:j,defineObservers:E,getObservers:C,getObserver:w,setObserver:S,isObserver:x,Observer:d,ComputedObserver:b,reactive:function(t){var e=i(t)?t():t,r={};return E(r),u(e).forEach(function(t){var n=e[t];x(n)?S(r,t,n):S(r,t,m(n)),_(t)(r,t)}),g(r),r},computed:O,observe:m,adaptReactive:function(r){var t;function n(){var t;return null!=(t=null==(t=r.data)?void 0:t.call(r))?t:{}}var i={current:(null==(t=r.created)?void 0:t.call(r,n()))||null},o=null;return{state:function(){var e,t=i.current;return o||(r.state?o=r.state:t&&(e=C(t),o=u(e).reduce(function(t,n){return t[n]=e[n].current,t},{})),o||{})},instance:function(){return i.current},mounted:function(){var t;i.current=(null==(t=r.mounted)?void 0:t.call(r,n()))||i.current},init:function(){var t;null!=(t=r.init)&&t.call(r,i.current,n())},destroy:function(){var t;null!=(t=r.destroy)&&t.call(r,i.current,n())},methods:function(){return j(i,r.methods)},on:function(t,n){var e;null!=(e=r.on)&&e.call(r,i.current,t,n)},off:function(t,n){var e;null!=(e=r.off)&&e.call(r,i.current,t,n)}}},Observe:_,Reactive:function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return _.apply(void 0,t)},Computed:function(t,n,e){var r=e.get;return e={configurable:!0,get:function(){var t=C(this);return n in t||(t[n]=O(r.bind(this))),w(this,n).current}},Object.defineProperty(t,n,e),e},injectReactiveSubscribe:g,ReactiveSubscribe:function(t){g(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 u(t){return Object.keys(t)}function e(t){return"string"==typeof t}function n(t){return"object"==typeof t}function i(t){return"function"==typeof t}var r="__observers__",o=1,c="__CFCS_DETECTED_DEPENDENCIES__",f=function(t,n){return(f=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 s(){Object[c]=Object[c]||{};var t=Object[c];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 l(){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 h(t){return void 0===t}var v=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}(),p=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 v?n.eventType:n,r=l(this._eventHandler[r]||[]);return r.length<=0||(n instanceof v?(n.currentTarget=this,r.forEach(function(t){t(n)})):r.forEach(function(t){t.apply(void 0,l(e))})),this},n.once=function(e,r){var i,o=this;if("object"==typeof e&&h(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,l(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&&h(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],h(i)&&(this._eventHandler[t]=[],i=this._eventHandler[t]),i.push(n))}return this},n.off=function(t,n){var e,r;if(h(t))return this._eventHandler={},this;if(h(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.3",t}(),d=function(){function t(t){this._emitter=new p,this._current=t}var n=t.prototype;return Object.defineProperty(n,"current",{get:function(){var t=(t=s())[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}(),b=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 f(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=s(),i={host:n,observers:e=[],push:function(t){n!==t&&-1===e.indexOf(t)&&e.push(t)}},t.push(i),this._computedCallback()),i=s().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}(d);function y(t,n,e){void 0===e&&(e=n),Object.defineProperty(t,n,{configurable:!0,get:function(){return w(this,e).current},set:function(t){w(this,e,t).current=t}}),e!==n&&Object.defineProperty(t,e,{configurable:!0,get:function(){return w(this,e).current}})}function _(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 1<e.length?y(e[0],e[1]):function(t,n){return y(t,n,e[0])}}function g(t){t.subscribe=function(t,n){this[t],w(this,t).subscribe(n)},t.unsubscribe=function(t,n){var e=this;t?t in this&&w(this,t).unsubscribe(n):u(C(this)).forEach(function(t){e.unsubscribe(t)})}}function O(t){return new b(t)}function m(t){return new d(t)}function j(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 E(t){var n={};return Object.defineProperty(t,r,{get:function(){return n}}),n}function C(t){return t[r]||E(t),t[r]}function w(t,n,e){t=C(t);return t[n]||(t[n]=m(e)),t[n]}function S(t,n,e){C(t)[n]=e}function x(t){return t&&n(t)&&"current"in t&&"subscribe"in t&&"unsubscribe"in t}return{__proto__:null,keys:u,camelize:function(t){return t.replace(/[\s-_]([a-z])/g,function(t,n){return n.toUpperCase()})},isString:e,isObject:n,isFunction:i,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:j,defineObservers:E,getObservers:C,getObserver:w,setObserver:S,isObserver:x,Observer:d,ComputedObserver:b,reactive:function(t){var e=i(t)?t():t,r={};return E(r),u(e).forEach(function(t){var n=e[t];x(n)?S(r,t,n):S(r,t,m(n)),_(t)(r,t)}),g(r),r},computed:O,observe:m,adaptReactive:function(r){var t;function n(){var t;return null!=(t=null==(t=r.data)?void 0:t.call(r))?t:{}}var i={current:(null==(t=r.created)?void 0:t.call(r,n()))||null},o=null;return{state:function(){var e,t=i.current;return o||(r.state?o=r.state:t&&(e=C(t),o=u(e).reduce(function(t,n){return t[n]=e[n].current,t},{})),o||{})},instance:function(){return i.current},mounted:function(){var t;i.current=(null==(t=r.mounted)?void 0:t.call(r,n()))||i.current},init:function(){var t;null!=(t=r.init)&&t.call(r,i.current,n())},destroy:function(){var t;null!=(t=r.destroy)&&t.call(r,i.current,n())},methods:function(){return j(i,r.methods)},on:function(t,n){var e;null!=(e=r.on)&&e.call(r,i.current,t,n)},off:function(t,n){var e;null!=(e=r.off)&&e.call(r,i.current,t,n)}}},Observe:_,Reactive:function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return _.apply(void 0,t)},Computed:function(t,n,e){var r=e.get;return e={configurable:!0,get:function(){var t=C(this);return n in t||(t[n]=O(r.bind(this))),w(this,n).current}},Object.defineProperty(t,n,e),e},injectReactiveSubscribe:g,ReactiveSubscribe:function(t){g(t.prototype)}}}); | ||
//# sourceMappingURL=cfcs.min.js.map |
{ | ||
"name": "@cfcs/core", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/cfcs.cjs.js", |
@@ -5,3 +5,3 @@ import Component from "@egjs/component"; | ||
interface EmitterEvents<Value> { | ||
update: (value: Value) => void; | ||
update: (value: Value, prevValue: Value) => void; | ||
} | ||
@@ -31,3 +31,3 @@ | ||
} | ||
public subscribe(callback: (value: Value) => void) { | ||
public subscribe(callback: (value: Value, prevValue: Value) => void) { | ||
this.current; | ||
@@ -37,3 +37,3 @@ this._emitter.on("update", callback); | ||
} | ||
public unsubscribe(callback?: (value: Value) => void) { | ||
public unsubscribe(callback?: (value: Value, prevValue: Value) => void) { | ||
this._emitter.off("update", callback); | ||
@@ -43,3 +43,4 @@ return this; | ||
protected _setCurrent(value: Value) { | ||
const isUpdate = value !== this._current; | ||
const prevValue = this._current; | ||
const isUpdate = value !== prevValue; | ||
@@ -49,3 +50,3 @@ this._current = value; | ||
if (isUpdate) { | ||
this._emitter.trigger("update", value); | ||
this._emitter.trigger("update", value, prevValue); | ||
} | ||
@@ -52,0 +53,0 @@ } |
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
231730
2828