New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

next-urql

Package Overview
Dependencies
Maintainers
30
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-urql - npm Package Compare versions

Comparing version 3.1.0 to 3.1.1

6

CHANGELOG.md
# Changelog
## 3.1.1
### Patch Changes
- ⚠️ Fix `resetUrqlClient` not resetting the SSR cache itself and instead restoring data when all data related to this `Client` and session should've been deleted, by [@Biboswan](https://github.com/Biboswan) (See [#1715](https://github.com/FormidableLabs/urql/pull/1715))
## 3.1.0

@@ -4,0 +10,0 @@

115

dist/next-urql.es.js

@@ -1,6 +0,6 @@

import e, { useState as t, createElement as n } from "react";
import { useReducer as e, useMemo as t, useCallback as n, createElement as r } from "react";
import r from "react-ssr-prepass";
import i from "react-ssr-prepass";
import { createClient as i, ssrExchange as o, dedupExchange as a, cacheExchange as l, fetchExchange as u, Provider as s } from "urql";
import { createClient as a, ssrExchange as o, dedupExchange as l, cacheExchange as u, fetchExchange as s, Provider as p } from "urql";

@@ -21,6 +21,6 @@ function _extends() {

var p = null;
var f = null;
function resetClient() {
p = null;
f = null;
}

@@ -30,4 +30,4 @@

var n = "undefined" == typeof window;
if (n || !p) {
(p = i(_extends({}, e, {
if (n || !f) {
(f = a(_extends({}, e, {
suspense: t && (n || e.suspense)

@@ -38,18 +38,18 @@ }))).toJSON = function() {

}
return p;
return f;
}
var f;
var v;
function withUrqlClient(i, p) {
if (!p) {
p = {};
function withUrqlClient(a, f) {
if (!f) {
f = {};
}
return function(c) {
var v = Boolean((c.getInitialProps || p.ssr) && !p.neverSuspend);
var WithUrql = function(r) {
var p = r.pageProps;
var d = r.urqlClient;
var m = r.urqlState;
var q = function objectWithoutProperties(e, t) {
var d = Boolean((c.getInitialProps || f.ssr) && !f.neverSuspend);
var WithUrql = function(i) {
var f = i.pageProps;
var m = i.urqlClient;
var q = i.urqlState;
var C = function objectWithoutProperties(e, t) {
var n = {};

@@ -62,39 +62,44 @@ for (var r in e) {

return n;
}(r, [ "pageProps", "urqlClient", "urqlState" ]);
var C = t(0);
var h = p && p.urqlState || m;
var P = e.useMemo((function() {
if (d) {
return d;
}(i, [ "pageProps", "urqlClient", "urqlState" ]);
var h = e((function(e) {
return e + 1;
}), 0);
var P = h[0];
var g = h[1];
var x = f && f.urqlState || q;
var _ = t((function() {
if (m && !P) {
return m;
}
if (!f || "undefined" == typeof window) {
f = o({
initialState: h,
if (!v || "undefined" == typeof window) {
v = o({
initialState: x,
isClient: !0
});
} else if (f && "undefined" != typeof window) {
f.restoreData(h);
} else if (!P) {
v.restoreData(x);
}
var e = i(f);
var e = a(v);
if (!e.exchanges) {
e.exchanges = [ a, l, f, u ];
e.exchanges = [ l, u, v, s ];
}
return initUrqlClient(e, v);
}), [ d, h, C[0] ]);
return n(s, {
value: P
}, n(c, _extends({}, q, {
pageProps: p,
urqlClient: P,
resetUrqlClient: function() {
resetClient();
f = o({
initialState: void 0
});
C[1](C[0] + 1);
}
return initUrqlClient(e, d);
}), [ m, x, P ]);
var w = n((function() {
resetClient();
v = o({
initialState: void 0
});
g();
}), []);
return r(p, {
value: _
}, r(c, _extends({}, C, {
pageProps: f,
urqlClient: _,
resetUrqlClient: w
})));
};
WithUrql.displayName = "withUrqlClient(" + (c.displayName || c.name || "Component") + ")";
if (c.getInitialProps || p.ssr) {
if (c.getInitialProps || f.ssr) {
WithUrql.getInitialProps = function(e) {

@@ -117,8 +122,8 @@ try {

});
var i = s ? e : {
var a = n ? e : {
pageProps: e
};
const o = function() {
if (!p.neverSuspend) {
return Promise.resolve(r(n(t, i))).then((function() {}));
if (!f.neverSuspend) {
return Promise.resolve(i(r(t, a))).then((function() {}));
}

@@ -129,14 +134,14 @@ }();

var t = e.AppTree;
var s = !!e.Component;
var f = s ? e.ctx : e;
var n = !!e.Component;
var p = n ? e.ctx : e;
var v = o({
initialState: void 0
});
var d = i(v, f);
var d = a(v, p);
if (!d.exchanges) {
d.exchanges = [ a, l, v, u ];
d.exchanges = [ l, u, v, s ];
}
var m = initUrqlClient(d, !p.neverSuspend);
var m = initUrqlClient(d, !f.neverSuspend);
if (m) {
f.urqlClient = m;
p.urqlClient = m;
}

@@ -143,0 +148,0 @@ var q = {};

@@ -11,6 +11,4 @@ var e = require("react");

var r = _interopDefaultLegacy(e);
var r = _interopDefaultLegacy(t);
var i = _interopDefaultLegacy(t);
function _extends() {

@@ -30,6 +28,6 @@ return (_extends = Object.assign || function(e) {

var a = null;
var i = null;
function resetClient() {
a = null;
i = null;
}

@@ -39,4 +37,4 @@

var r = "undefined" == typeof window;
if (r || !a) {
(a = n.createClient(_extends({}, e, {
if (r || !i) {
(i = n.createClient(_extends({}, e, {
suspense: t && (r || e.suspense)

@@ -47,20 +45,20 @@ }))).toJSON = function() {

}
return a;
return i;
}
var l;
var a;
exports.initUrqlClient = initUrqlClient;
exports.withUrqlClient = function withUrqlClient(t, a) {
if (!a) {
a = {};
exports.withUrqlClient = function withUrqlClient(t, i) {
if (!i) {
i = {};
}
return function(o) {
var u = Boolean((o.getInitialProps || a.ssr) && !a.neverSuspend);
var WithUrql = function(i) {
var a = i.pageProps;
var s = i.urqlClient;
var c = i.urqlState;
var f = function objectWithoutProperties(e, t) {
return function(l) {
var u = Boolean((l.getInitialProps || i.ssr) && !i.neverSuspend);
var WithUrql = function(r) {
var i = r.pageProps;
var o = r.urqlClient;
var s = r.urqlState;
var c = function objectWithoutProperties(e, t) {
var n = {};

@@ -73,40 +71,45 @@ for (var r in e) {

return n;
}(i, [ "pageProps", "urqlClient", "urqlState" ]);
var p = e.useState(0);
var v = a && a.urqlState || c;
var d = r.useMemo((function() {
if (s) {
return s;
}(r, [ "pageProps", "urqlClient", "urqlState" ]);
var f = e.useReducer((function(e) {
return e + 1;
}), 0);
var p = f[0];
var v = f[1];
var d = i && i.urqlState || s;
var h = e.useMemo((function() {
if (o && !p) {
return o;
}
if (!l || "undefined" == typeof window) {
l = n.ssrExchange({
initialState: v,
if (!a || "undefined" == typeof window) {
a = n.ssrExchange({
initialState: d,
isClient: !0
});
} else if (l && "undefined" != typeof window) {
l.restoreData(v);
} else if (!p) {
a.restoreData(d);
}
var e = t(l);
var e = t(a);
if (!e.exchanges) {
e.exchanges = [ n.dedupExchange, n.cacheExchange, l, n.fetchExchange ];
e.exchanges = [ n.dedupExchange, n.cacheExchange, a, n.fetchExchange ];
}
return initUrqlClient(e, u);
}), [ s, v, p[0] ]);
}), [ o, d, p ]);
var g = e.useCallback((function() {
resetClient();
a = n.ssrExchange({
initialState: void 0
});
v();
}), []);
return e.createElement(n.Provider, {
value: d
}, e.createElement(o, _extends({}, f, {
pageProps: a,
urqlClient: d,
resetUrqlClient: function() {
resetClient();
l = n.ssrExchange({
initialState: void 0
});
p[1](p[0] + 1);
}
value: h
}, e.createElement(l, _extends({}, c, {
pageProps: i,
urqlClient: h,
resetUrqlClient: g
})));
};
WithUrql.displayName = "withUrqlClient(" + (o.displayName || o.name || "Component") + ")";
if (o.getInitialProps || a.ssr) {
WithUrql.getInitialProps = function(r) {
WithUrql.displayName = "withUrqlClient(" + (l.displayName || l.name || "Component") + ")";
if (l.getInitialProps || i.ssr) {
WithUrql.getInitialProps = function(a) {
try {

@@ -128,15 +131,15 @@ function _temp4() {

});
var n = u ? t : {
var n = o ? t : {
pageProps: t
};
const r = function() {
if (!a.neverSuspend) {
return Promise.resolve(i(e.createElement(l, n))).then((function() {}));
const a = function() {
if (!i.neverSuspend) {
return Promise.resolve(r(e.createElement(u, n))).then((function() {}));
}
}();
return r && r.then ? r.then(_temp2) : _temp2();
return a && a.then ? a.then(_temp2) : _temp2();
}
var l = r.AppTree;
var u = !!r.Component;
var s = u ? r.ctx : r;
var u = a.AppTree;
var o = !!a.Component;
var s = o ? a.ctx : a;
var c = n.ssrExchange({

@@ -149,3 +152,3 @@ initialState: void 0

}
var p = initUrqlClient(f, !a.neverSuspend);
var p = initUrqlClient(f, !i.neverSuspend);
if (p) {

@@ -156,4 +159,4 @@ s.urqlClient = p;

const d = function() {
if (o.getInitialProps) {
return Promise.resolve(o.getInitialProps(r)).then((function(e) {
if (l.getInitialProps) {
return Promise.resolve(l.getInitialProps(a)).then((function(e) {
v = e;

@@ -160,0 +163,0 @@ }));

@@ -1,2 +0,2 @@

import e,{useState as n,createElement as t}from"react";import r from"react-ssr-prepass";import{createClient as i,ssrExchange as o,dedupExchange as u,cacheExchange as a,fetchExchange as l,Provider as s}from"urql";function p(){return(p=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}var f,c=null;function v(){c=null}function d(e,n){var t="undefined"==typeof window;return!t&&c||((c=i(p({},e,{suspense:n&&(t||e.suspense)}))).toJSON=function(){return null}),c}function h(i,c){return c||(c={}),function(h){var m=Boolean((h.getInitialProps||c.ssr)&&!c.neverSuspend),g=function(r){var c=r.pageProps,g=r.urqlClient,P=r.urqlState,q=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&-1===n.indexOf(r)&&(t[r]=e[r]);return t}(r,["pageProps","urqlClient","urqlState"]),y=n(0),C=c&&c.urqlState||P,w=e.useMemo((function(){if(g)return g;f&&"undefined"!=typeof window?f&&"undefined"!=typeof window&&f.restoreData(C):f=o({initialState:C,isClient:!0});var e=i(f);return e.exchanges||(e.exchanges=[u,a,f,l]),d(e,m)}),[g,C,y[0]]);return t(s,{value:w},t(h,p({},q,{pageProps:c,urqlClient:w,resetUrqlClient:function(){v(),f=o({initialState:void 0}),y[1](y[0]+1)}})))};return g.displayName="withUrqlClient("+(h.displayName||h.name||"Component")+")",(h.getInitialProps||c.ssr)&&(g.getInitialProps=function(e){try{function n(){function e(){return p({},q,{urqlState:m?m.extractData():void 0,urqlClient:P})}if("undefined"!=typeof window)return p({},q,{urqlClient:P});var n=p({},q,{urqlClient:P}),i=f?n:{pageProps:n};const o=function(){if(!c.neverSuspend)return Promise.resolve(r(t(s,i))).then((function(){}))}();return o&&o.then?o.then(e):e()}var s=e.AppTree,f=!!e.Component,v=f?e.ctx:e,m=o({initialState:void 0}),g=i(m,v);g.exchanges||(g.exchanges=[u,a,m,l]);var P=d(g,!c.neverSuspend);P&&(v.urqlClient=P);var q={};const y=function(){if(h.getInitialProps)return Promise.resolve(h.getInitialProps(e)).then((function(e){q=e}))}();return Promise.resolve(y&&y.then?y.then(n):n())}catch(e){return Promise.reject(e)}}),g}}export{d as initUrqlClient,h as withUrqlClient};
import{useReducer as e,useMemo as n,useCallback as t,createElement as r}from"react";import i from"react-ssr-prepass";import{createClient as o,ssrExchange as u,dedupExchange as a,cacheExchange as l,fetchExchange as s,Provider as p}from"urql";function c(){return(c=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}var f,v=null;function d(){v=null}function h(e,n){var t="undefined"==typeof window;return!t&&v||((v=o(c({},e,{suspense:n&&(t||e.suspense)}))).toJSON=function(){return null}),v}function g(o,v){return v||(v={}),function(g){var m=Boolean((g.getInitialProps||v.ssr)&&!v.neverSuspend),P=function(i){var v=i.pageProps,P=i.urqlClient,q=i.urqlState,C=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&-1===n.indexOf(r)&&(t[r]=e[r]);return t}(i,["pageProps","urqlClient","urqlState"]),y=e((function(e){return e+1}),0),S=y[0],w=y[1],x=v&&v.urqlState||q,O=n((function(){if(P&&!S)return P;f&&"undefined"!=typeof window?S||f.restoreData(x):f=u({initialState:x,isClient:!0});var e=o(f);return e.exchanges||(e.exchanges=[a,l,f,s]),h(e,m)}),[P,x,S]),I=t((function(){d(),f=u({initialState:void 0}),w()}),[]);return r(p,{value:O},r(g,c({},C,{pageProps:v,urqlClient:O,resetUrqlClient:I})))};return P.displayName="withUrqlClient("+(g.displayName||g.name||"Component")+")",(g.getInitialProps||v.ssr)&&(P.getInitialProps=function(e){try{function n(){function e(){return c({},q,{urqlState:d?d.extractData():void 0,urqlClient:P})}if("undefined"!=typeof window)return c({},q,{urqlClient:P});var n=c({},q,{urqlClient:P}),o=p?n:{pageProps:n};const u=function(){if(!v.neverSuspend)return Promise.resolve(i(r(t,o))).then((function(){}))}();return u&&u.then?u.then(e):e()}var t=e.AppTree,p=!!e.Component,f=p?e.ctx:e,d=u({initialState:void 0}),m=o(d,f);m.exchanges||(m.exchanges=[a,l,d,s]);var P=h(m,!v.neverSuspend);P&&(f.urqlClient=P);var q={};const C=function(){if(g.getInitialProps)return Promise.resolve(g.getInitialProps(e)).then((function(e){q=e}))}();return Promise.resolve(C&&C.then?C.then(n):n())}catch(e){return Promise.reject(e)}}),P}}export{h as initUrqlClient,g as withUrqlClient};
//# sourceMappingURL=next-urql.min.es.js.map

@@ -1,2 +0,2 @@

var e=require("react"),n=require("react-ssr-prepass"),t=require("urql");function r(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var i=r(e),a=r(n);function o(){return(o=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}var u,l=null;function s(){l=null}function c(e,n){var r="undefined"==typeof window;return!r&&l||((l=t.createClient(o({},e,{suspense:n&&(r||e.suspense)}))).toJSON=function(){return null}),l}exports.initUrqlClient=c,exports.withUrqlClient=function(n,r){return r||(r={}),function(l){var p=Boolean((l.getInitialProps||r.ssr)&&!r.neverSuspend),f=function(r){var a=r.pageProps,f=r.urqlClient,h=r.urqlState,d=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&-1===n.indexOf(r)&&(t[r]=e[r]);return t}(r,["pageProps","urqlClient","urqlState"]),v=e.useState(0),g=a&&a.urqlState||h,q=i.useMemo((function(){if(f)return f;u&&"undefined"!=typeof window?u&&"undefined"!=typeof window&&u.restoreData(g):u=t.ssrExchange({initialState:g,isClient:!0});var e=n(u);return e.exchanges||(e.exchanges=[t.dedupExchange,t.cacheExchange,u,t.fetchExchange]),c(e,p)}),[f,g,v[0]]);return e.createElement(t.Provider,{value:q},e.createElement(l,o({},d,{pageProps:a,urqlClient:q,resetUrqlClient:function(){s(),u=t.ssrExchange({initialState:void 0}),v[1](v[0]+1)}})))};return f.displayName="withUrqlClient("+(l.displayName||l.name||"Component")+")",(l.getInitialProps||r.ssr)&&(f.getInitialProps=function(i){try{function u(){function n(){return o({},g,{urqlState:h?h.extractData():void 0,urqlClient:v})}if("undefined"!=typeof window)return o({},g,{urqlClient:v});var t=o({},g,{urqlClient:v}),i=p?t:{pageProps:t};const u=function(){if(!r.neverSuspend)return Promise.resolve(a(e.createElement(s,i))).then((function(){}))}();return u&&u.then?u.then(n):n()}var s=i.AppTree,p=!!i.Component,f=p?i.ctx:i,h=t.ssrExchange({initialState:void 0}),d=n(h,f);d.exchanges||(d.exchanges=[t.dedupExchange,t.cacheExchange,h,t.fetchExchange]);var v=c(d,!r.neverSuspend);v&&(f.urqlClient=v);var g={};const q=function(){if(l.getInitialProps)return Promise.resolve(l.getInitialProps(i)).then((function(e){g=e}))}();return Promise.resolve(q&&q.then?q.then(u):u())}catch(e){return Promise.reject(e)}}),f}};
var e=require("react"),n=require("react-ssr-prepass"),t=require("urql");function r(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var i=r(n);function a(){return(a=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}var u,o=null;function l(){o=null}function c(e,n){var r="undefined"==typeof window;return!r&&o||((o=t.createClient(a({},e,{suspense:n&&(r||e.suspense)}))).toJSON=function(){return null}),o}exports.initUrqlClient=c,exports.withUrqlClient=function(n,r){return r||(r={}),function(o){var s=Boolean((o.getInitialProps||r.ssr)&&!r.neverSuspend),p=function(r){var i=r.pageProps,p=r.urqlClient,f=r.urqlState,h=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&-1===n.indexOf(r)&&(t[r]=e[r]);return t}(r,["pageProps","urqlClient","urqlState"]),v=e.useReducer((function(e){return e+1}),0),d=v[0],g=v[1],q=i&&i.urqlState||f,x=e.useMemo((function(){if(p&&!d)return p;u&&"undefined"!=typeof window?d||u.restoreData(q):u=t.ssrExchange({initialState:q,isClient:!0});var e=n(u);return e.exchanges||(e.exchanges=[t.dedupExchange,t.cacheExchange,u,t.fetchExchange]),c(e,s)}),[p,q,d]),C=e.useCallback((function(){l(),u=t.ssrExchange({initialState:void 0}),g()}),[]);return e.createElement(t.Provider,{value:x},e.createElement(o,a({},h,{pageProps:i,urqlClient:x,resetUrqlClient:C})))};return p.displayName="withUrqlClient("+(o.displayName||o.name||"Component")+")",(o.getInitialProps||r.ssr)&&(p.getInitialProps=function(u){try{function l(){function n(){return a({},g,{urqlState:h?h.extractData():void 0,urqlClient:d})}if("undefined"!=typeof window)return a({},g,{urqlClient:d});var t=a({},g,{urqlClient:d}),u=p?t:{pageProps:t};const o=function(){if(!r.neverSuspend)return Promise.resolve(i(e.createElement(s,u))).then((function(){}))}();return o&&o.then?o.then(n):n()}var s=u.AppTree,p=!!u.Component,f=p?u.ctx:u,h=t.ssrExchange({initialState:void 0}),v=n(h,f);v.exchanges||(v.exchanges=[t.dedupExchange,t.cacheExchange,h,t.fetchExchange]);var d=c(v,!r.neverSuspend);d&&(f.urqlClient=d);var g={};const q=function(){if(o.getInitialProps)return Promise.resolve(o.getInitialProps(u)).then((function(e){g=e}))}();return Promise.resolve(q&&q.then?q.then(l):l())}catch(e){return Promise.reject(e)}}),p}};
//# sourceMappingURL=next-urql.min.js.map
{
"name": "next-urql",
"version": "3.1.0",
"version": "3.1.1",
"description": "Convenience wrappers for using urql with NextJS.",

@@ -28,2 +28,3 @@ "sideEffects": false,

"check": "tsc --noEmit",
"lint": "eslint --ext=js,jsx,ts,tsx .",
"build": "rollup -c ../../scripts/rollup/config.js",

@@ -30,0 +31,0 @@ "prepare": "node ../../scripts/prepare/index.js",

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc