@cfcs/core
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -7,3 +7,3 @@ /* | ||
repository: https://github.com/naver/cfcs | ||
version: 0.0.7 | ||
version: 0.0.8 | ||
*/ | ||
@@ -365,6 +365,7 @@ 'use strict'; | ||
setObserver(reactiveObject, name, value); | ||
Reactive(name)(reactiveObject, name); | ||
} else { | ||
reactiveObject[name] = value; | ||
setObserver(reactiveObject, name, observe(value)); | ||
} | ||
Observe(name)(reactiveObject, name); | ||
}); | ||
@@ -371,0 +372,0 @@ injectReactiveSubscribe(reactiveObject); |
@@ -7,3 +7,3 @@ /* | ||
repository: https://github.com/naver/cfcs | ||
version: 0.0.7 | ||
version: 0.0.8 | ||
*/ | ||
@@ -363,6 +363,7 @@ import Component from '@egjs/component'; | ||
setObserver(reactiveObject, name, value); | ||
Reactive(name)(reactiveObject, name); | ||
} else { | ||
reactiveObject[name] = value; | ||
setObserver(reactiveObject, name, observe(value)); | ||
} | ||
Observe(name)(reactiveObject, name); | ||
}); | ||
@@ -369,0 +370,0 @@ injectReactiveSubscribe(reactiveObject); |
@@ -7,3 +7,3 @@ /* | ||
repository: https://github.com/naver/cfcs | ||
version: 0.0.7 | ||
version: 0.0.8 | ||
*/ | ||
@@ -767,6 +767,7 @@ (function (global, factory) { | ||
setObserver(reactiveObject, name, value); | ||
Reactive(name)(reactiveObject, name); | ||
} else { | ||
reactiveObject[name] = value; | ||
setObserver(reactiveObject, name, observe(value)); | ||
} | ||
Observe(name)(reactiveObject, name); | ||
}); | ||
@@ -773,0 +774,0 @@ injectReactiveSubscribe(reactiveObject); |
@@ -7,5 +7,5 @@ /* | ||
repository: https://github.com/naver/cfcs | ||
version: 0.0.7 | ||
version: 0.0.8 | ||
*/ | ||
!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 S(this,e).current},set:function(t){S(this,e,t).current=t}}),e!==n&&Object.defineProperty(t,e,{configurable:!0,get:function(){return S(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(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return _.apply(void 0,t)}function O(t){t.subscribe=function(t,n){this[t],S(this,t).subscribe(n)},t.unsubscribe=function(t,n){var e=this;t?t in this&&S(this,t).unsubscribe(n):u(w(this)).forEach(function(t){e.unsubscribe(t)})}}function m(t){return new b(t)}function j(t){return new d(t)}function E(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 C(t){var n={};return Object.defineProperty(t,r,{get:function(){return n}}),n}function w(t){return t[r]||C(t),t[r]}function S(t,n,e){t=w(t);return t[n]||(t[n]=j(e)),t[n]}function x(t,n,e){w(t)[n]=e}function H(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:E,defineObservers:C,getObservers:w,getObserver:S,setObserver:x,isObserver:H,Observer:d,ComputedObserver:b,reactive:function(t){var e=i(t)?t():t,r={};return C(r),u(e).forEach(function(t){var n=e[t];H(n)?(x(r,t,n),g(t)(r,t)):r[t]=n}),O(r),r},computed:m,observe:j,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=w(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 E(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:g,Computed:function(t,n,e){var r=e.get;return e={configurable:!0,get:function(){var t=w(this);return n in t||(t[n]=m(r.bind(this))),S(this,n).current}},Object.defineProperty(t,n,e),e},injectReactiveSubscribe:O,ReactiveSubscribe:function(t){O(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=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)}}}); | ||
//# sourceMappingURL=cfcs.min.js.map |
{ | ||
"name": "@cfcs/core", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/cfcs.cjs.js", |
import { ComputedObserver } from "./ComputedObserver"; | ||
import { Observer } from "./Observer"; | ||
import { ExtractNever, isFunction, keys } from "../core"; | ||
import { Reactive } from "./decorators/Observe"; | ||
import { Observe } from "./decorators/Observe"; | ||
import { injectReactiveSubscribe, ReactiveSubscribe } from "./decorators/ReactiveSubscribe"; | ||
@@ -32,6 +32,6 @@ import { defineObservers, isObserver, setObserver } from "./utils"; | ||
setObserver(reactiveObject, name, value); | ||
Reactive(name)(reactiveObject, name); | ||
} else { | ||
reactiveObject[name] = value; | ||
setObserver(reactiveObject, name, observe(value)); | ||
} | ||
Observe(name)(reactiveObject, name); | ||
}); | ||
@@ -38,0 +38,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
230827