@cfcs/core
Advanced tools
Comparing version 0.0.23 to 0.0.24
/** | ||
* @description `Computed` is a property decorator. | ||
* Changes in computed state values are also recognized according to changes in observers used within the getter function. | ||
* You can detect its status through `.subscribe`. | ||
* @hidden | ||
* @category Reactive-Decorator | ||
* @see ReactiveSubscribe | ||
* @example | ||
* ```ts | ||
const ob1 = observe(0); | ||
const ob2 = observe(1); | ||
// When | ||
@ReactiveSubscribe | ||
class TestComputed { | ||
@Computed | ||
get ob3() { | ||
return ob1.current + ob2.current; | ||
} | ||
} | ||
const inst = new TestComputed(); | ||
inst.subscribe("ob3", ob3 => { | ||
console.log(ob3); | ||
}); | ||
ob1.current = 1; | ||
``` | ||
*/ | ||
export declare function Computed(prototype: any, memberName: string, attributes: PropertyDescriptor): PropertyDescriptor; |
@@ -7,3 +7,3 @@ /* | ||
repository: https://github.com/naver/cfcs | ||
version: 0.0.23 | ||
version: 0.0.24 | ||
*/ | ||
@@ -719,2 +719,3 @@ 'use strict'; | ||
var eventNames = []; | ||
var methodNames = []; | ||
@@ -756,2 +757,3 @@ var onMounted = function (callback) { | ||
var setMethods = function (methods) { | ||
methodNames = methods; | ||
}; | ||
@@ -886,3 +888,3 @@ | ||
methods: function () { | ||
return withReactiveMethods(instanceRef, objectAdapter.methods); | ||
return withReactiveMethods(instanceRef, methodNames); | ||
}, | ||
@@ -899,3 +901,29 @@ on: function (eventName, listener) { | ||
/** | ||
* @description `Computed` is a property decorator. | ||
* Changes in computed state values are also recognized according to changes in observers used within the getter function. | ||
* You can detect its status through `.subscribe`. | ||
* @hidden | ||
* @category Reactive-Decorator | ||
* @see ReactiveSubscribe | ||
* @example | ||
* ```ts | ||
const ob1 = observe(0); | ||
const ob2 = observe(1); | ||
// When | ||
@ReactiveSubscribe | ||
class TestComputed { | ||
@Computed | ||
get ob3() { | ||
return ob1.current + ob2.current; | ||
} | ||
} | ||
const inst = new TestComputed(); | ||
inst.subscribe("ob3", ob3 => { | ||
console.log(ob3); | ||
}); | ||
ob1.current = 1; | ||
``` | ||
*/ | ||
@@ -902,0 +930,0 @@ |
@@ -7,3 +7,3 @@ /* | ||
repository: https://github.com/naver/cfcs | ||
version: 0.0.23 | ||
version: 0.0.24 | ||
*/ | ||
@@ -717,2 +717,3 @@ import Component from '@egjs/component'; | ||
var eventNames = []; | ||
var methodNames = []; | ||
@@ -754,2 +755,3 @@ var onMounted = function (callback) { | ||
var setMethods = function (methods) { | ||
methodNames = methods; | ||
}; | ||
@@ -884,3 +886,3 @@ | ||
methods: function () { | ||
return withReactiveMethods(instanceRef, objectAdapter.methods); | ||
return withReactiveMethods(instanceRef, methodNames); | ||
}, | ||
@@ -897,3 +899,29 @@ on: function (eventName, listener) { | ||
/** | ||
* @description `Computed` is a property decorator. | ||
* Changes in computed state values are also recognized according to changes in observers used within the getter function. | ||
* You can detect its status through `.subscribe`. | ||
* @hidden | ||
* @category Reactive-Decorator | ||
* @see ReactiveSubscribe | ||
* @example | ||
* ```ts | ||
const ob1 = observe(0); | ||
const ob2 = observe(1); | ||
// When | ||
@ReactiveSubscribe | ||
class TestComputed { | ||
@Computed | ||
get ob3() { | ||
return ob1.current + ob2.current; | ||
} | ||
} | ||
const inst = new TestComputed(); | ||
inst.subscribe("ob3", ob3 => { | ||
console.log(ob3); | ||
}); | ||
ob1.current = 1; | ||
``` | ||
*/ | ||
@@ -900,0 +928,0 @@ |
@@ -7,3 +7,3 @@ /* | ||
repository: https://github.com/naver/cfcs | ||
version: 0.0.23 | ||
version: 0.0.24 | ||
*/ | ||
@@ -1121,2 +1121,3 @@ (function (global, factory) { | ||
var eventNames = []; | ||
var methodNames = []; | ||
@@ -1158,2 +1159,3 @@ var onMounted = function (callback) { | ||
var setMethods = function (methods) { | ||
methodNames = methods; | ||
}; | ||
@@ -1288,3 +1290,3 @@ | ||
methods: function () { | ||
return withReactiveMethods(instanceRef, objectAdapter.methods); | ||
return withReactiveMethods(instanceRef, methodNames); | ||
}, | ||
@@ -1301,3 +1303,29 @@ on: function (eventName, listener) { | ||
/** | ||
* @description `Computed` is a property decorator. | ||
* Changes in computed state values are also recognized according to changes in observers used within the getter function. | ||
* You can detect its status through `.subscribe`. | ||
* @hidden | ||
* @category Reactive-Decorator | ||
* @see ReactiveSubscribe | ||
* @example | ||
* ```ts | ||
const ob1 = observe(0); | ||
const ob2 = observe(1); | ||
// When | ||
@ReactiveSubscribe | ||
class TestComputed { | ||
@Computed | ||
get ob3() { | ||
return ob1.current + ob2.current; | ||
} | ||
} | ||
const inst = new TestComputed(); | ||
inst.subscribe("ob3", ob3 => { | ||
console.log(ob3); | ||
}); | ||
ob1.current = 1; | ||
``` | ||
*/ | ||
@@ -1304,0 +1332,0 @@ |
@@ -7,5 +7,5 @@ /* | ||
repository: https://github.com/naver/cfcs | ||
version: 0.0.23 | ||
version: 0.0.24 | ||
*/ | ||
!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 y(t){return Object.keys(t)}function e(t){return"string"==typeof t}function n(t){return"object"==typeof t}function _(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 g(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}(),m=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 m,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 O(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):y(S(this)).forEach(function(t){e.unsubscribe(t)})}}function t(t){var e=_(t)?t():t,r={};return w(r),y(e).forEach(function(t){var n=e[t];P(n)?H(r,t,n):H(r,t,E(n)),b(t)(r,t)}),O(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){n[r]||w(n);var e=n[r],t=null==(t=null==(t=null==n?void 0:n.constructor)?void 0:t.prototype)?void 0:t[i];return t&&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:y,camelize:function(t){return t.replace(/[\s-_]([a-z])/g,function(t,n){return n.toUpperCase()})},isString:e,isObject:n,isFunction:_,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=_(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){}var f=new m,s=[],a=[],l=[],h=[],v={current:null},p=[],d=null,b=[];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,g([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&&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(y(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,g([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,i.methods)},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,o=e.get,e={configurable:!0,get:function(){var t=S(this);return n in t||(t[n]=j(o.bind(this))),x(this,n).current}};return i in t&&(t[i]||(t[i]=[]),-1===(r=t[i]).indexOf(n)&&r.push(n)),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 _(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){n[r]||w(n);var e=n[r],t=null==(t=null==(t=null==n?void 0:n.constructor)?void 0:t.prototype)?void 0:t[o];return t&&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);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)}}}); | ||
//# sourceMappingURL=cfcs.min.js.map |
{ | ||
"name": "@cfcs/core", | ||
"version": "0.0.23", | ||
"version": "0.0.24", | ||
"description": "CFCs(Cross Framework Components) are modules that convert components into framework usage", | ||
@@ -5,0 +5,0 @@ "main": "dist/cfcs.cjs.js", |
@@ -181,3 +181,3 @@ import { isFunction, keys } from "../core"; | ||
methods() { | ||
return withReactiveMethods<any, any, any>(instanceRef, objectAdapter.methods); | ||
return withReactiveMethods<any, any, any>(instanceRef, methodNames); | ||
}, | ||
@@ -184,0 +184,0 @@ on(eventName: string, listener: ReactiveEventCallback<any, any>) { |
@@ -7,3 +7,29 @@ import { COMPUTED_PATH } from "../const"; | ||
/** | ||
* @description `Computed` is a property decorator. | ||
* Changes in computed state values are also recognized according to changes in observers used within the getter function. | ||
* You can detect its status through `.subscribe`. | ||
* @hidden | ||
* @category Reactive-Decorator | ||
* @see ReactiveSubscribe | ||
* @example | ||
* ```ts | ||
const ob1 = observe(0); | ||
const ob2 = observe(1); | ||
// When | ||
@ReactiveSubscribe | ||
class TestComputed { | ||
@Computed | ||
get ob3() { | ||
return ob1.current + ob2.current; | ||
} | ||
} | ||
const inst = new TestComputed(); | ||
inst.subscribe("ob3", ob3 => { | ||
console.log(ob3); | ||
}); | ||
ob1.current = 1; | ||
``` | ||
*/ | ||
@@ -10,0 +36,0 @@ export function Computed(prototype: any, memberName: string, attributes: PropertyDescriptor): PropertyDescriptor { |
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
349968
4799