@pravosleva/reactive-engine 0.4.1-beta → 1.0.1-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -2
- package/dist/AbstractService.cjs +2 -0
- package/dist/AbstractService.cjs.map +1 -0
- package/dist/AbstractService.mjs +24 -0
- package/dist/AbstractService.mjs.map +1 -0
- package/dist/BaseREServiceEnhanced.cjs +2 -0
- package/dist/BaseREServiceEnhanced.cjs.map +1 -0
- package/dist/BaseREServiceEnhanced.mjs +12 -0
- package/dist/BaseREServiceEnhanced.mjs.map +1 -0
- package/dist/_react-bindings.d.ts +17 -0
- package/dist/_react-bindings.d.ts.map +1 -0
- package/dist/_virtual/_rolldown/runtime.cjs +1 -0
- package/dist/core/AbstractService.d.ts +11 -0
- package/dist/core/AbstractService.d.ts.map +1 -0
- package/dist/core/BaseREServiceEnhanced.d.ts +7 -0
- package/dist/core/BaseREServiceEnhanced.d.ts.map +1 -0
- package/dist/core/core.d.ts +282 -0
- package/dist/core/core.d.ts.map +1 -0
- package/dist/core/core.test.d.ts +2 -0
- package/dist/core/core.test.d.ts.map +1 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/types.d.ts +92 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core.cjs +2 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.mjs +286 -0
- package/dist/core.mjs.map +1 -0
- package/dist/decorators/index.d.ts +6 -0
- package/dist/decorators/index.d.ts.map +1 -0
- package/dist/decorators/withCache/index.d.ts +2 -0
- package/dist/decorators/withCache/index.d.ts.map +1 -0
- package/dist/decorators/withCache/withCache.d.ts +13 -0
- package/dist/decorators/withCache/withCache.d.ts.map +1 -0
- package/dist/decorators/withCache/withCache.test.d.ts +2 -0
- package/dist/decorators/withCache/withCache.test.d.ts.map +1 -0
- package/dist/decorators/withDebounce/index.d.ts +2 -0
- package/dist/decorators/withDebounce/index.d.ts.map +1 -0
- package/dist/decorators/withDebounce/withDebounce.d.ts +12 -0
- package/dist/decorators/withDebounce/withDebounce.d.ts.map +1 -0
- package/dist/decorators/withDebounce/withDebounce.test.d.ts +2 -0
- package/dist/decorators/withDebounce/withDebounce.test.d.ts.map +1 -0
- package/dist/decorators/withLongPolling/index.d.ts +2 -0
- package/dist/decorators/withLongPolling/index.d.ts.map +1 -0
- package/dist/decorators/withLongPolling/withLongPolling.d.ts +28 -0
- package/dist/decorators/withLongPolling/withLongPolling.d.ts.map +1 -0
- package/dist/decorators/withLongPolling/withLongPolling.test.d.ts +2 -0
- package/dist/decorators/withLongPolling/withLongPolling.test.d.ts.map +1 -0
- package/dist/decorators/withThrottle/index.d.ts +2 -0
- package/dist/decorators/withThrottle/index.d.ts.map +1 -0
- package/dist/decorators/withThrottle/withThrottle.d.ts +12 -0
- package/dist/decorators/withThrottle/withThrottle.d.ts.map +1 -0
- package/dist/decorators/withThrottle/withThrottle.test.d.ts +2 -0
- package/dist/decorators/withThrottle/withThrottle.test.d.ts.map +1 -0
- package/dist/decorators/withThrottleAndCache/index.d.ts +2 -0
- package/dist/decorators/withThrottleAndCache/index.d.ts.map +1 -0
- package/dist/decorators/withThrottleAndCache/withThrottleAndCache.d.ts +13 -0
- package/dist/decorators/withThrottleAndCache/withThrottleAndCache.d.ts.map +1 -0
- package/dist/decorators/withThrottleAndCache/withThrottleAndCache.test.d.ts +2 -0
- package/dist/decorators/withThrottleAndCache/withThrottleAndCache.test.d.ts.map +1 -0
- package/dist/index.cjs +1 -6
- package/dist/index.d.ts +2 -605
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +4 -541
- package/dist/react/ReactiveEngine4React.cjs +6 -0
- package/dist/react/ReactiveEngine4React.cjs.map +1 -0
- package/dist/react/ReactiveEngine4React.d.ts +27 -0
- package/dist/react/ReactiveEngine4React.d.ts.map +1 -0
- package/dist/react/ReactiveEngine4React.mjs +28 -0
- package/dist/react/ReactiveEngine4React.mjs.map +1 -0
- package/dist/react/core.react.test.d.ts +2 -0
- package/dist/react/core.react.test.d.ts.map +1 -0
- package/dist/react/createObserver.cjs +2 -0
- package/dist/react/createObserver.cjs.map +1 -0
- package/dist/react/createObserver.d.ts +70 -0
- package/dist/react/createObserver.d.ts.map +1 -0
- package/dist/react/createObserver.mjs +62 -0
- package/dist/react/createObserver.mjs.map +1 -0
- package/dist/react/createObserver.test.d.ts +2 -0
- package/dist/react/createObserver.test.d.ts.map +1 -0
- package/dist/react/hooks/FilteredCatalog.test.d.ts +2 -0
- package/dist/react/hooks/FilteredCatalog.test.d.ts.map +1 -0
- package/dist/react/hooks/index.cjs +1 -0
- package/dist/react/hooks/index.d.ts +4 -0
- package/dist/react/hooks/index.d.ts.map +1 -0
- package/dist/react/hooks/index.mjs +7 -0
- package/dist/react/hooks/types.d.ts +16 -0
- package/dist/react/hooks/types.d.ts.map +1 -0
- package/dist/react/hooks/useReactiveSubscription/index.cjs +1 -0
- package/dist/react/hooks/useReactiveSubscription/index.d.ts +2 -0
- package/dist/react/hooks/useReactiveSubscription/index.d.ts.map +1 -0
- package/dist/react/hooks/useReactiveSubscription/index.mjs +2 -0
- package/dist/react/hooks/useReactiveSubscription/useReactiveSubscription.cjs +2 -0
- package/dist/react/hooks/useReactiveSubscription/useReactiveSubscription.cjs.map +1 -0
- package/dist/react/hooks/useReactiveSubscription/useReactiveSubscription.d.ts +10 -0
- package/dist/react/hooks/useReactiveSubscription/useReactiveSubscription.d.ts.map +1 -0
- package/dist/react/hooks/useReactiveSubscription/useReactiveSubscription.mjs +14 -0
- package/dist/react/hooks/useReactiveSubscription/useReactiveSubscription.mjs.map +1 -0
- package/dist/react/hooks/useReactiveSubscription/useReactiveSubscription.test.d.ts +2 -0
- package/dist/react/hooks/useReactiveSubscription/useReactiveSubscription.test.d.ts.map +1 -0
- package/dist/react/hooks/useReactiveValue/index.cjs +1 -0
- package/dist/react/hooks/useReactiveValue/index.d.ts +2 -0
- package/dist/react/hooks/useReactiveValue/index.d.ts.map +1 -0
- package/dist/react/hooks/useReactiveValue/index.mjs +2 -0
- package/dist/react/hooks/useReactiveValue/useReactiveValue.cjs +2 -0
- package/dist/react/hooks/useReactiveValue/useReactiveValue.cjs.map +1 -0
- package/dist/react/hooks/useReactiveValue/useReactiveValue.d.ts +16 -0
- package/dist/react/hooks/useReactiveValue/useReactiveValue.d.ts.map +1 -0
- package/dist/react/hooks/useReactiveValue/useReactiveValue.mjs +12 -0
- package/dist/react/hooks/useReactiveValue/useReactiveValue.mjs.map +1 -0
- package/dist/react/hooks/useReactiveValue/useReactiveValue.test.d.ts +2 -0
- package/dist/react/hooks/useReactiveValue/useReactiveValue.test.d.ts.map +1 -0
- package/dist/react/hooks/useReactiveValue0/index.cjs +1 -0
- package/dist/react/hooks/useReactiveValue0/index.d.ts +2 -0
- package/dist/react/hooks/useReactiveValue0/index.d.ts.map +1 -0
- package/dist/react/hooks/useReactiveValue0/index.mjs +2 -0
- package/dist/react/hooks/useReactiveValue0/useReactiveValue0.cjs +2 -0
- package/dist/react/hooks/useReactiveValue0/useReactiveValue0.cjs.map +1 -0
- package/dist/react/hooks/useReactiveValue0/useReactiveValue0.d.ts +15 -0
- package/dist/react/hooks/useReactiveValue0/useReactiveValue0.d.ts.map +1 -0
- package/dist/react/hooks/useReactiveValue0/useReactiveValue0.mjs +20 -0
- package/dist/react/hooks/useReactiveValue0/useReactiveValue0.mjs.map +1 -0
- package/dist/react/index.cjs +1 -0
- package/dist/react/index.d.ts +4 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.mjs +7 -0
- package/dist/react/types.d.ts +2 -0
- package/dist/react/types.d.ts.map +1 -0
- package/dist/utils/getExtractedValues.cjs +2 -0
- package/dist/utils/getExtractedValues.cjs.map +1 -0
- package/dist/utils/getExtractedValues.d.ts +6 -0
- package/dist/utils/getExtractedValues.d.ts.map +1 -0
- package/dist/utils/getExtractedValues.mjs +21 -0
- package/dist/utils/getExtractedValues.mjs.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/package.json +25 -4
- package/dist/index.cjs.map +0 -1
- package/dist/index.iife.js +0 -6
- package/dist/index.iife.js.map +0 -1
- package/dist/index.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/decorators/withThrottleAndCache/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface ThrottleAndCacheOptions {
|
|
2
|
+
/** Интервал троттлинга в миллисекундах. По умолчанию 300 мс */
|
|
3
|
+
limit?: number;
|
|
4
|
+
/** Время жизни кэша в миллисекундах. По умолчанию 5 минут (300000 мс) */
|
|
5
|
+
ttl?: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Комбинированный декоратор: сначала применяет троттлинг к частоте вызовов,
|
|
9
|
+
* а затем проверяет кэш перед отправкой реального fetcher-запроса.
|
|
10
|
+
*/
|
|
11
|
+
export declare const withThrottleAndCache: <S, T>(fetcher: (source: S, signal: AbortSignal) => Promise<T>, options?: ThrottleAndCacheOptions) => (source: S, signal: AbortSignal) => Promise<T>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=withThrottleAndCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withThrottleAndCache.d.ts","sourceRoot":"","sources":["../../../src/decorators/withThrottleAndCache/withThrottleAndCache.ts"],"names":[],"mappings":"AAAA,UAAU,uBAAuB;IAC/B,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAOD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,EAAE,CAAC,EACvC,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,EACvD,UAAS,uBAA4B,MAuB7B,QAAQ,CAAC,EAAE,QAAQ,WAAW,KAAG,OAAO,CAAC,CAAC,CAkGnD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withThrottleAndCache.test.d.ts","sourceRoot":"","sources":["../../../src/decorators/withThrottleAndCache/withThrottleAndCache.test.ts"],"names":[],"mappings":""}
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});
|
|
2
|
-
[Reactive Error]: engine.use() получил некорректный объект!
|
|
3
|
-
Скорее всего, вы пытаетесь подписаться на свойство сервиса, которое не было инициализировано.
|
|
4
|
-
Проверьте, что в классе написано: public mySignal = this.engine.signal(...)
|
|
5
|
-
`;throw console.error(t,{item:e}),Error(t)}let[t,n]=this.reactAdapters.useState(e.value);return this.reactAdapters.useEffect(()=>e.subscribe(n),[e]),t}safeRun(e,t){try{t()}catch(e){console.error(`%c[Reactive Error] %cОшибка в эффекте/computed:`,`color: white; background: red; padding: 2px 4px; border-radius: 3px;`,`font-weight: bold;`,e)}}},m=e=>({children:t})=>{let n=(0,c.useRef)(0),r=(0,c.useRef)(null),i=(0,c.useRef)(null),a=(0,c.useRef)(null),o=(0,c.useMemo)(()=>({subscribe(e){return r.current=e,()=>{r.current=null,i.current&&(i.current(),i.current=null,a.current=null)}},getSnapshot(){return n.current}}),[]);(0,c.useEffect)(()=>()=>{i.current&&i.current()},[]),i.current||(i.current=e.effect(()=>{r.current&&(n.current++,queueMicrotask(()=>{r.current&&r.current()}))}),a.current=Array.from(e.allEffects).pop());let s=e.activeEffect;e.activeEffect=a.current;let l=null;try{l=t()}finally{e.activeEffect=s}return(0,c.useSyncExternalStore)(o.subscribe,o.getSnapshot),l},h=e=>t=>{let n=n=>{let r=(0,c.useRef)(0),i=e,a=`activeEffect`in i?`activeEffect`:`_activeEffect`,o=(0,c.useRef)(null),{subscribe:s,getSnapshot:l}=(0,c.useMemo)(()=>({subscribe:t=>{let n=e.effect(()=>{r.current++,t()}),a=Array.from(i.allEffects||[]);return o.current=a[a.length-1],()=>{n(),o.current=null}},getSnapshot:()=>r.current}),[]);(0,c.useSyncExternalStore)(s,l,l);let u={cleanups:new Set,run:()=>{}},d=o.current||u,f=i[a];i[a]=d;let p=null;try{p=typeof t==`function`&&!t.prototype?.isReactComponent?t(n):c.default.createElement(t,n)}finally{i[a]=f}return p};return n.displayName=`Observer(${t.displayName||t.name||`Component`})`,n},g=(e,t={})=>{let n=t.ttl??300*1e3,r=new Map;return async(t,i)=>{let a=typeof t==`object`&&t?JSON.stringify(t):String(t),o=Date.now(),s=r.get(a);if(s&&o-s.timestamp<n)return s.data;let c=await e(t,i);return r.set(a,{data:c,timestamp:Date.now()}),c}},_=(e,t={})=>{let n=t.delay??300,r=null,i=null;return(t,a)=>(r&&clearTimeout(r),i&&i(new DOMException(`Aborted due to debounce`,`AbortError`)),new Promise((o,s)=>{i=s;let c=()=>{r&&clearTimeout(r),s(new DOMException(`Aborted by resource signal`,`AbortError`))};if(a.aborted)return c();a.addEventListener(`abort`,c),r=setTimeout(async()=>{a.removeEventListener(`abort`,c),i=null,r=null;try{o(await e(t,a))}catch(e){s(e)}},n)}))},v=(e,t)=>{let{onNextTick:n,onError:r,externalSignal:i,delay:a=500,errorInitialDelay:o=2e3,errorMaxDelay:s=8e3}=t,c=o,l=0;return(t,u)=>{let d=++l;return new Promise((f,p)=>{let m=async()=>{if(u.aborted||i?.aborted){p(new DOMException(`Aborted by long polling lifecycle`,`AbortError`));return}try{let r=await e(t,u);if(c=o,u.aborted||i?.aborted){p(new DOMException(`Aborted by long polling lifecycle`,`AbortError`));return}f(r),setTimeout(()=>{d===l&&!u.aborted&&!i?.aborted&&n()},a)}catch(e){if(e instanceof DOMException&&e.name===`AbortError`){p(e);return}p(e);let t=c;r(t,()=>{d===l&&(c=Math.min(c*2,s))}),setTimeout(()=>{d===l&&!u.aborted&&!i?.aborted&&n()},t)}},h=()=>{p(new DOMException(`Aborted by lifecycle event`,`AbortError`))};if(u.addEventListener(`abort`,h),i&&i.addEventListener(`abort`,h),u.aborted||i?.aborted)return h();m()})}},y=(e,t={})=>{let n=t.limit??300,r=0,i=null,a=null,o=null,s=null,c=null;return(t,l)=>{let u=Date.now(),d=n-(u-r),f=()=>{i&&=(clearTimeout(i),null),s&&=(s(new DOMException(`Aborted by resource signal during throttle`,`AbortError`)),o=null,null)};return d<=0?(i&&=(clearTimeout(i),null),s&&=(s(new DOMException(`Aborted due to newer direct throttle execution`,`AbortError`)),o=null,null),r=u,e(t,l)):(s&&s(new DOMException(`Aborted due to newer throttled value`,`AbortError`)),new Promise((n,u)=>{if(a=t,o=n,s=u,c=l,l.aborted)return f();l.addEventListener(`abort`,f),i||=setTimeout(async()=>{i=null;let t=a,n=o,l=s,u=c;a=null,o=null,s=null,c=null,u.removeEventListener(`abort`,f);try{r=Date.now(),n(await e(t,u))}catch(e){l(e)}},d)}))}},b=(e,t={})=>{let n=t.limit??300,r=t.ttl??300*1e3,i=0,a=null,o=null,s=null,c=null,l=null,u=new Map,d=e=>typeof e==`object`&&e?JSON.stringify(e):String(e);return(t,f)=>{let p=Date.now(),m=n-(p-i);d(t);let h=()=>{a&&=(clearTimeout(a),null),c&&=(c(new DOMException(`Aborted by resource signal during throttle`,`AbortError`)),s=null,null)},g=async(t,n)=>{let i=Date.now(),a=d(t),o=u.get(a);if(o&&i-o.timestamp<r)return o.data;let s=await e(t,n);return u.set(a,{data:s,timestamp:Date.now()}),s};return m<=0?(a&&=(clearTimeout(a),null),c&&=(c(new DOMException(`Aborted due to newer direct execution`,`AbortError`)),s=null,null),i=p,g(t,f)):(c&&c(new DOMException(`Aborted due to newer throttled value`,`AbortError`)),new Promise((e,n)=>{if(o=t,s=e,c=n,l=f,f.aborted)return h();f.addEventListener(`abort`,h),a||=setTimeout(async()=>{a=null;let e=o,t=s,n=c,r=l;o=null,s=null,c=null,l=null,r.removeEventListener(`abort`,h);try{i=Date.now(),t(await g(e,r))}catch(e){n(e)}},m)}))}},x=(e,t)=>{let n=(0,c.useRef)(t);(0,c.useEffect)(()=>{n.current=t},[t]),(0,c.useEffect)(()=>e.subscribe(e=>{n.current(e)}),[e])},S=e=>{let t=(0,c.useMemo)(()=>typeof e==`function`?e():e,[e]),n=(0,c.useCallback)(e=>t.subscribe(e),[t]),r=(0,c.useCallback)(()=>t.value,[t]);return(0,c.useEffect)(()=>()=>{t&&typeof t.destroy==`function`&&t.destroy()},[t]),(0,c.useSyncExternalStore)(n,r)},C=e=>{let t=(0,c.useMemo)(()=>typeof e==`function`?e():e,[e]),[n,r]=(0,c.useState)(t.value),i=(0,c.useRef)(r);return(0,c.useEffect)(()=>{i.current=r},[r]),(0,c.useEffect)(()=>{i.current(t.value);let e=t.subscribe(e=>{i.current(e)});return()=>{e(),t&&typeof t.destroy==`function`&&t.destroy()}},[t]),n};exports.AbstractService=l,exports.BaseREService=u,exports.BaseREServiceEnhanced=d,exports.ReactiveEngine=p,exports.createObserver=h,exports.createObserverComponent=m,exports.useReactiveSubscription=x,exports.useReactiveValue=S,exports.useReactiveValue0=C,exports.withCache=g,exports.withDebounce=_,exports.withLongPolling=v,exports.withThrottle=y,exports.withThrottleAndCache=b;
|
|
6
|
-
//# sourceMappingURL=index.cjs.map
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./core.cjs"),t=require("./AbstractService.cjs"),n=require("./BaseREServiceEnhanced.cjs");exports.AbstractService=t.AbstractService,exports.BaseREService=t.BaseREService,exports.BaseREServiceEnhanced=n.BaseREServiceEnhanced,exports.ReactiveEngine=e.ReactiveEngine;
|