Comparing version 1.6.0 to 1.6.1
@@ -18,2 +18,3 @@ var __defProp = Object.defineProperty; | ||
import { SWR } from "swrev"; | ||
import { onMount, onDestroy } from "svelte"; | ||
function noop() { | ||
@@ -40,12 +41,2 @@ } | ||
} | ||
let current_component; | ||
function get_current_component() { | ||
throw new Error("Function called outside component initialization"); | ||
} | ||
function onMount(fn) { | ||
get_current_component().$$.on_mount.push(fn); | ||
} | ||
function onDestroy(fn) { | ||
get_current_component().$$.on_destroy.push(fn); | ||
} | ||
Promise.resolve(); | ||
@@ -52,0 +43,0 @@ const subscriber_queue = []; |
@@ -1,1 +0,1 @@ | ||
var Q=Object.defineProperty;var O=Object.getOwnPropertySymbols;var U=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable;var $=(t,u,i)=>u in t?Q(t,u,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[u]=i,S=(t,u)=>{for(var i in u||(u={}))U.call(u,i)&&$(t,i,u[i]);if(O)for(var i of O(u))X.call(u,i)&&$(t,i,u[i]);return t};(function(t,u){typeof exports=="object"&&typeof module!="undefined"?u(exports,require("swrev")):typeof define=="function"&&define.amd?define(["exports","swrev"],u):(t=typeof globalThis!="undefined"?globalThis:t||self,u(t.sswr={},t.swrev))})(this,function(t,u){"use strict";function i(){}function q(e){return e()}function D(e){e.forEach(q)}function K(e){return typeof e=="function"}function j(e,n){return e!=e?n==n:e!==n||e&&typeof e=="object"||typeof e=="function"}function z(e,...n){if(e==null)return i;const s=e.subscribe(...n);return s.unsubscribe?()=>s.unsubscribe():s}let Y;function _(){throw new Error("Function called outside component initialization")}function M(e){_().$$.on_mount.push(e)}function T(e){_().$$.on_destroy.push(e)}Promise.resolve();const v=[];function A(e,n){return{subscribe:m(e,n).subscribe}}function m(e,n=i){let s;const r=new Set;function l(a){if(j(e,a)&&(e=a,s)){const b=!v.length;for(const c of r)c[1](),v.push(c,e);if(b){for(let c=0;c<v.length;c+=2)v[c][0](v[c+1]);v.length=0}}}function d(a){l(a(e))}function w(a,b=i){const c=[a,b];return r.add(c),r.size===1&&(s=n(l)||i),a(e),()=>{r.delete(c),r.size===0&&(s(),s=null)}}return{set:l,update:d,subscribe:w}}function R(e,n,s){const r=!Array.isArray(e),l=r?[e]:e,d=n.length<2;return A(s,w=>{let a=!1;const b=[];let c=0,g=i;const o=()=>{if(c)return;g();const f=n(r?b[0]:b,w);d?w(f):g=K(f)?f:i},h=l.map((f,y)=>z(f,N=>{b[y]=N,c&=~(1<<y),a&&o()},()=>{c|=1<<y}));return a=!0,o(),function(){D(h),g()}})}class E extends u.SWR{useSWR(n,s){let r;const l=m(void 0,()=>()=>r==null?void 0:r()),d=m(void 0,()=>()=>r==null?void 0:r());M(()=>{l.set(this.get(this.resolveKey(n)));const o=f=>{d.set(void 0),l.set(f)},h=f=>d.set(f);r=this.use(n,o,h,S({loadInitialCache:!1},s)).unsubscribe}),T(()=>r==null?void 0:r());const w=(o,h)=>this.mutate(this.resolveKey(n),o,S({revalidateOptions:s},h)),a=o=>this.revalidate(this.resolveKey(n),S(S({},s),o)),b=o=>this.clear(this.resolveKey(n),o),c=R([l,d],([o,h])=>o===void 0&&h===void 0),g=R([l,d],([o,h])=>o!==void 0&&h===void 0);return{data:l,error:d,mutate:w,revalidate:a,clear:b,isLoading:c,isValid:g}}}const W=e=>new E(e);t.swr=W();const P=e=>(t.swr=W(e),t.swr),C=(e,n)=>t.swr.subscribe(e,n),F=(e,n)=>t.swr.subscribeErrors(e,n),I=e=>t.swr.get(e),L=e=>t.swr.getOrWait(e),V=(e,n,s,r)=>t.swr.use(e,n,s,r),B=(e,n)=>t.swr.useSWR(e,n),G=(e,n,s)=>t.swr.mutate(e,n,s),H=(e,n)=>t.swr.revalidate(e,n),J=(e,n)=>t.swr.clear(e,n);t.SSWR=E,t.clear=J,t.createDefaultSWR=P,t.createSWR=W,t.get=I,t.getOrWait=L,t.mutate=G,t.revalidate=H,t.subscribe=C,t.subscribeErrors=F,t.use=V,t.useSWR=B,Object.defineProperty(t,"__esModule",{value:!0}),t[Symbol.toStringTag]="Module"}); | ||
var J=Object.defineProperty;var E=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable;var O=(t,i,o)=>i in t?J(t,i,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[i]=o,W=(t,i)=>{for(var o in i||(i={}))N.call(i,o)&&O(t,o,i[o]);if(E)for(var o of E(i))Q.call(i,o)&&O(t,o,i[o]);return t};(function(t,i){typeof exports=="object"&&typeof module!="undefined"?i(exports,require("swrev"),require("svelte")):typeof define=="function"&&define.amd?define(["exports","swrev","svelte"],i):(t=typeof globalThis!="undefined"?globalThis:t||self,i(t.sswr={},t.swrev,t.svelte))})(this,function(t,i,o){"use strict";function h(){}function D(e){return e()}function K(e){e.forEach(D)}function j(e){return typeof e=="function"}function M(e,n){return e!=e?n==n:e!==n||e&&typeof e=="object"||typeof e=="function"}function T(e,...n){if(e==null)return h;const s=e.subscribe(...n);return s.unsubscribe?()=>s.unsubscribe():s}Promise.resolve();const w=[];function z(e,n){return{subscribe:y(e,n).subscribe}}function y(e,n=h){let s;const r=new Set;function l(a){if(M(e,a)&&(e=a,s)){const b=!w.length;for(const u of r)u[1](),w.push(u,e);if(b){for(let u=0;u<w.length;u+=2)w[u][0](w[u+1]);w.length=0}}}function d(a){l(a(e))}function S(a,b=h){const u=[a,b];return r.add(u),r.size===1&&(s=n(l)||h),a(e),()=>{r.delete(u),r.size===0&&(s(),s=null)}}return{set:l,update:d,subscribe:S}}function _(e,n,s){const r=!Array.isArray(e),l=r?[e]:e,d=n.length<2;return z(s,S=>{let a=!1;const b=[];let u=0,g=h;const c=()=>{if(u)return;g();const f=n(r?b[0]:b,S);d?S(f):g=j(f)?f:h},v=l.map((f,R)=>T(f,H=>{b[R]=H,u&=~(1<<R),a&&c()},()=>{u|=1<<R}));return a=!0,c(),function(){K(v),g()}})}class q extends i.SWR{useSWR(n,s){let r;const l=y(void 0,()=>()=>r==null?void 0:r()),d=y(void 0,()=>()=>r==null?void 0:r());o.onMount(()=>{l.set(this.get(this.resolveKey(n)));const c=f=>{d.set(void 0),l.set(f)},v=f=>d.set(f);r=this.use(n,c,v,W({loadInitialCache:!1},s)).unsubscribe}),o.onDestroy(()=>r==null?void 0:r());const S=(c,v)=>this.mutate(this.resolveKey(n),c,W({revalidateOptions:s},v)),a=c=>this.revalidate(this.resolveKey(n),W(W({},s),c)),b=c=>this.clear(this.resolveKey(n),c),u=_([l,d],([c,v])=>c===void 0&&v===void 0),g=_([l,d],([c,v])=>c!==void 0&&v===void 0);return{data:l,error:d,mutate:S,revalidate:a,clear:b,isLoading:u,isValid:g}}}const m=e=>new q(e);t.swr=m();const A=e=>(t.swr=m(e),t.swr),P=(e,n)=>t.swr.subscribe(e,n),C=(e,n)=>t.swr.subscribeErrors(e,n),I=e=>t.swr.get(e),L=e=>t.swr.getOrWait(e),V=(e,n,s,r)=>t.swr.use(e,n,s,r),$=(e,n)=>t.swr.useSWR(e,n),B=(e,n,s)=>t.swr.mutate(e,n,s),F=(e,n)=>t.swr.revalidate(e,n),G=(e,n)=>t.swr.clear(e,n);t.SSWR=q,t.clear=G,t.createDefaultSWR=A,t.createSWR=m,t.get=I,t.getOrWait=L,t.mutate=B,t.revalidate=F,t.subscribe=P,t.subscribeErrors=C,t.use=V,t.useSWR=$,Object.defineProperty(t,"__esModule",{value:!0}),t[Symbol.toStringTag]="Module"}); |
{ | ||
"name": "sswr", | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"description": "Svelte stale while revalidate (SWR) data fetching strategy", | ||
@@ -11,2 +11,3 @@ "repository": "github.com/ConsoleTVs/sswr", | ||
"module": "./dist/sswr.es.js", | ||
"svelte": "./src/sswr.ts", | ||
"exports": { | ||
@@ -19,3 +20,4 @@ ".": { | ||
"files": [ | ||
"dist" | ||
"dist", | ||
"package.json" | ||
], | ||
@@ -35,4 +37,4 @@ "scripts": { | ||
"dependencies": { | ||
"swrev": "^1.10.2" | ||
"swrev": "^1.10.3" | ||
} | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
28115
298
Updatedswrev@^1.10.3