Comparing version 1.2.0 to 1.2.1
@@ -1,1 +0,1 @@ | ||
import{SWR as S}from"swrev";import{onDestroy as p,onMount as D}from"svelte";import{writable as c}from"svelte/store";var l=class extends S{useSvelte(t,r){let e,s=c(void 0,()=>()=>e?.()),d=c(void 0,()=>()=>e?.());return D(()=>{s.set(this.get(this.resolveKey(t)));let a=o=>s.set(o),i=o=>d.set(o);e=this.use(t,a,i,{loadInitialCache:!1,...r}).unsubscribe}),p(()=>e?.()),{data:s,error:d,mutate:(a,i)=>this.mutate(this.resolveKey(t),a,i),revalidate:a=>this.revalidate(this.resolveKey(t),a),clear:a=>this.clear(this.resolveKey(t),a)}}},R=u=>{let t=new l(u);return{useSWR:(r,e)=>t.useSvelte(r,e),mutate:(r,e,s)=>t.mutate(r,e,s),revalidate:(r,e)=>t.revalidate(r,e),clear:(r,e)=>t.clear(r,e)}},n=R(),W=n.useSWR,v=n.mutate,h=n.revalidate,m=n.clear;export{l as SSWR,m as clear,R as createSWR,v as mutate,h as revalidate,W as useSWR}; | ||
import{SWR as W}from"swrev";import{onDestroy as v,onMount as f}from"svelte";import{writable as c}from"svelte/store";var l=class extends W{useSvelte(t,r){let e,s=c(void 0,()=>()=>e?.()),d=c(void 0,()=>()=>e?.());typeof window!="undefined"&&(f(()=>{s.set(this.get(this.resolveKey(t)));let a=o=>s.set(o),i=o=>d.set(o);e=this.use(t,a,i,{loadInitialCache:!1,...r}).unsubscribe}),v(()=>e?.()));let p=(a,i)=>this.mutate(this.resolveKey(t),a,i),S=a=>this.revalidate(this.resolveKey(t),a),D=a=>this.clear(this.resolveKey(t),a);return{data:s,error:d,mutate:p,revalidate:S,clear:D}}},R=u=>{let t=new l(u);return{useSWR:(r,e)=>t.useSvelte(r,e),mutate:(r,e,s)=>t.mutate(r,e,s),revalidate:(r,e)=>t.revalidate(r,e),clear:(r,e)=>t.clear(r,e)}},n=R(),h=n.useSWR,O=n.mutate,m=n.revalidate,y=n.clear;export{l as SSWR,y as clear,R as createSWR,O as mutate,m as revalidate,h as useSWR}; |
@@ -1,1 +0,1 @@ | ||
(()=>{var W=Object.create,d=Object.defineProperty,v=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty,m=Object.getOwnPropertyNames,O=Object.getOwnPropertyDescriptor;var f=t=>d(t,"__esModule",{value:!0});var K=(t,r,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of m(r))!h.call(t,e)&&e!=="default"&&d(t,e,{get:()=>r[e],enumerable:!(a=O(r,e))||a.enumerable});return t},c=t=>K(f(d(t!=null?W(v(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var p=c(require("swrev")),i=c(require("svelte")),R=c(require("svelte/store")),D=class extends p.SWR{useSvelte(r,a){let e,n=(0,R.writable)(void 0,()=>()=>e?.()),S=(0,R.writable)(void 0,()=>()=>e?.());return(0,i.onMount)(()=>{n.set(this.get(this.resolveKey(r)));let s=u=>n.set(u),l=u=>S.set(u);e=this.use(r,s,l,{loadInitialCache:!1,...a}).unsubscribe}),(0,i.onDestroy)(()=>e?.()),{data:n,error:S,mutate:(s,l)=>this.mutate(this.resolveKey(r),s,l),revalidate:s=>this.revalidate(this.resolveKey(r),s),clear:s=>this.clear(this.resolveKey(r),s)}}},E=t=>{let r=new D(t);return{useSWR:(a,e)=>r.useSvelte(a,e),mutate:(a,e,n)=>r.mutate(a,e,n),revalidate:(a,e)=>r.revalidate(a,e),clear:(a,e)=>r.clear(a,e)}},o=E(),j=o.useSWR,q=o.mutate,z=o.revalidate,A=o.clear;})(); | ||
(()=>{var h=Object.create,d=Object.defineProperty,O=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty,y=Object.getOwnPropertyNames,K=Object.getOwnPropertyDescriptor,E=t=>d(t,"__esModule",{value:!0}),P=(t,r,a)=>{if(E(t),r&&typeof r=="object"||typeof r=="function")for(let e of y(r))!m.call(t,e)&&e!=="default"&&d(t,e,{get:()=>r[e],enumerable:!(a=K(r,e))||a.enumerable});return t},c=t=>t&&t.__esModule?t:P(d(t!=null?h(O(t)):{},"default",{value:t,enumerable:!0}),t),S=c(require("swrev")),i=c(require("svelte")),R=c(require("svelte/store")),D=class extends S.SWR{useSvelte(r,a){let e,n=R.writable(void 0,()=>()=>e?.()),p=R.writable(void 0,()=>()=>e?.());typeof window!="undefined"&&(i.onMount(()=>{n.set(this.get(this.resolveKey(r)));let s=u=>n.set(u),l=u=>p.set(u);e=this.use(r,s,l,{loadInitialCache:!1,...a}).unsubscribe}),i.onDestroy(()=>e?.()));let W=(s,l)=>this.mutate(this.resolveKey(r),s,l),v=s=>this.revalidate(this.resolveKey(r),s),f=s=>this.clear(this.resolveKey(r),s);return{data:n,error:p,mutate:W,revalidate:v,clear:f}}},w=t=>{let r=new D(t);return{useSWR:(a,e)=>r.useSvelte(a,e),mutate:(a,e,n)=>r.mutate(a,e,n),revalidate:(a,e)=>r.revalidate(a,e),clear:(a,e)=>r.clear(a,e)}},o=w(),j=o.useSWR,q=o.mutate,z=o.revalidate,A=o.clear;})(); |
@@ -1,2 +0,2 @@ | ||
import * as svelte_store from 'svelte/store'; | ||
import { Writable } from 'svelte/store'; | ||
import { SWR, SWRKey, SWROptions, SWRMutateOptions, SWRRevalidateOptions, CacheClearOptions } from 'swrev'; | ||
@@ -13,4 +13,4 @@ | ||
useSvelte<D = any, E = Error>(key: SWRKey | undefined | (() => SWRKey | undefined), options?: Partial<SWROptions<D>>): { | ||
data: svelte_store.Writable<D | undefined>; | ||
error: svelte_store.Writable<E | undefined>; | ||
data: Writable<D | undefined>; | ||
error: Writable<E | undefined>; | ||
mutate: (value: D, options: Partial<SWRMutateOptions<D>>) => void; | ||
@@ -25,6 +25,6 @@ revalidate: (options: Partial<SWRRevalidateOptions<D>>) => void; | ||
*/ | ||
declare const createSWR: <G = unknown>(options?: Partial<SWROptions<G>> | undefined) => { | ||
declare const createSWR: <G = any>(options?: Partial<SWROptions<G>> | undefined) => { | ||
useSWR: <D = G, E = Error>(key: SWRKey, options?: Partial<SWROptions<D>> | undefined) => { | ||
data: svelte_store.Writable<D | undefined>; | ||
error: svelte_store.Writable<E | undefined>; | ||
data: Writable<D | undefined>; | ||
error: Writable<E | undefined>; | ||
mutate: (value: D, options: Partial<SWRMutateOptions<D>>) => void; | ||
@@ -38,5 +38,5 @@ revalidate: (options: Partial<SWRRevalidateOptions<D>>) => void; | ||
}; | ||
declare const useSWR: <D = unknown, E = Error>(key: SWRKey, options?: Partial<SWROptions<D>> | undefined) => { | ||
data: svelte_store.Writable<D | undefined>; | ||
error: svelte_store.Writable<E | undefined>; | ||
declare const useSWR: <D = any, E = Error>(key: SWRKey, options?: Partial<SWROptions<D>> | undefined) => { | ||
data: Writable<D | undefined>; | ||
error: Writable<E | undefined>; | ||
mutate: (value: D, options: Partial<SWRMutateOptions<D>>) => void; | ||
@@ -46,6 +46,6 @@ revalidate: (options: Partial<SWRRevalidateOptions<D>>) => void; | ||
}; | ||
declare const mutate: <D = unknown>(key: SWRKey, value: D, options?: Partial<SWRMutateOptions<D>> | undefined) => void; | ||
declare const revalidate: <D = unknown>(key: SWRKey, options?: Partial<SWRRevalidateOptions<D>> | undefined) => void; | ||
declare const mutate: <D = any>(key: SWRKey, value: D, options?: Partial<SWRMutateOptions<D>> | undefined) => void; | ||
declare const revalidate: <D = any>(key: SWRKey, options?: Partial<SWRRevalidateOptions<D>> | undefined) => void; | ||
declare const clear: (keys?: string | string[] | undefined, options?: Partial<CacheClearOptions> | undefined) => void; | ||
export { SSWR, clear, createSWR, mutate, revalidate, useSWR }; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _swrev = require('swrev');var _svelte = require('svelte');var _store = require('svelte/store');var l=class extends _swrev.SWR{useSvelte(t,r){let e,s=_store.writable.call(void 0, void 0,()=>()=>_optionalChain([e, 'optionalCall', _ => _()])),d=_store.writable.call(void 0, void 0,()=>()=>_optionalChain([e, 'optionalCall', _2 => _2()]));return _svelte.onMount.call(void 0, ()=>{s.set(this.get(this.resolveKey(t)));let a=o=>s.set(o),i=o=>d.set(o);e=this.use(t,a,i,{loadInitialCache:!1,...r}).unsubscribe}),_svelte.onDestroy.call(void 0, ()=>_optionalChain([e, 'optionalCall', _3 => _3()])),{data:s,error:d,mutate:(a,i)=>this.mutate(this.resolveKey(t),a,i),revalidate:a=>this.revalidate(this.resolveKey(t),a),clear:a=>this.clear(this.resolveKey(t),a)}}},R= exports.createSWR =u=>{let t=new l(u);return{useSWR:(r,e)=>t.useSvelte(r,e),mutate:(r,e,s)=>t.mutate(r,e,s),revalidate:(r,e)=>t.revalidate(r,e),clear:(r,e)=>t.clear(r,e)}},n=R(),W= exports.useSWR =n.useSWR,v= exports.mutate =n.mutate,h= exports.revalidate =n.revalidate,m= exports.clear =n.clear;exports.SSWR = l; exports.clear = m; exports.createSWR = R; exports.mutate = v; exports.revalidate = h; exports.useSWR = W; | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _swrev = require('swrev');var _svelte = require('svelte');var _store = require('svelte/store');var l=class extends _swrev.SWR{useSvelte(t,r){let e,s=_store.writable.call(void 0, void 0,()=>()=>_optionalChain([e, 'optionalCall', _ => _()])),d=_store.writable.call(void 0, void 0,()=>()=>_optionalChain([e, 'optionalCall', _2 => _2()]));typeof window!="undefined"&&(_svelte.onMount.call(void 0, ()=>{s.set(this.get(this.resolveKey(t)));let a=o=>s.set(o),i=o=>d.set(o);e=this.use(t,a,i,{loadInitialCache:!1,...r}).unsubscribe}),_svelte.onDestroy.call(void 0, ()=>_optionalChain([e, 'optionalCall', _3 => _3()])));let p=(a,i)=>this.mutate(this.resolveKey(t),a,i),S=a=>this.revalidate(this.resolveKey(t),a),D=a=>this.clear(this.resolveKey(t),a);return{data:s,error:d,mutate:p,revalidate:S,clear:D}}},R= exports.createSWR =u=>{let t=new l(u);return{useSWR:(r,e)=>t.useSvelte(r,e),mutate:(r,e,s)=>t.mutate(r,e,s),revalidate:(r,e)=>t.revalidate(r,e),clear:(r,e)=>t.clear(r,e)}},n=R(),h= exports.useSWR =n.useSWR,O= exports.mutate =n.mutate,m= exports.revalidate =n.revalidate,y= exports.clear =n.clear;exports.SSWR = l; exports.clear = y; exports.createSWR = R; exports.mutate = O; exports.revalidate = m; exports.useSWR = h; |
{ | ||
"name": "sswr", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Svelte stale while revalidate (SWR) data fetching strategy", | ||
@@ -5,0 +5,0 @@ "repository": "github.com/ConsoleTVs/sswr", |
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
21658