@shopify/react-cookie
Advanced tools
Comparing version 0.0.0-snapshot-20240308174203 to 0.0.0-snapshot-20240620045713
@@ -16,3 +16,2 @@ 'use strict'; | ||
} | ||
getCookies() { | ||
@@ -22,3 +21,2 @@ const cookies = this.parse(document.cookie || ''); | ||
} | ||
setCookie(name, value) { | ||
@@ -34,3 +32,2 @@ const fullCookie = typeof value === 'string' ? { | ||
} | ||
removeCookie(name) { | ||
@@ -41,6 +38,6 @@ document.cookie = cookie__default["default"].serialize(name, '', { | ||
} | ||
parse(cookies) { | ||
const parsedCookies = cookie__default["default"].parse(cookies); | ||
return Object.entries(parsedCookies).reduce((newCookies, [key, value]) => ({ ...newCookies, | ||
return Object.entries(parsedCookies).reduce((newCookies, [key, value]) => ({ | ||
...newCookies, | ||
[key]: { | ||
@@ -51,5 +48,4 @@ value | ||
} | ||
} | ||
exports.BrowserCookieManager = BrowserCookieManager; |
@@ -26,7 +26,5 @@ 'use strict'; | ||
} | ||
if (manager == null) { | ||
throw new Error(NO_MANAGER_ERROR); | ||
} | ||
return manager.cookies; | ||
@@ -33,0 +31,0 @@ }).current; |
@@ -11,7 +11,5 @@ 'use strict'; | ||
const manager = React.useContext(context.CookieContext); | ||
if (!manager) { | ||
throw new Error(NO_MANAGER_ERROR); | ||
} | ||
const [cookie, setCookieValue] = React.useState(() => manager === null || manager === void 0 ? void 0 : manager.getCookie(key)); | ||
@@ -24,3 +22,2 @@ const setCookie = React.useCallback((value, options) => { | ||
} | ||
setCookieValue(value); | ||
@@ -27,0 +24,0 @@ manager.setCookie(key, { |
@@ -10,7 +10,5 @@ 'use strict'; | ||
const allCookies = cookies.getCookies(); | ||
for (const key of Object.keys(allCookies)) { | ||
cookies.removeCookie(key); | ||
} | ||
return cookies; | ||
@@ -20,7 +18,5 @@ } | ||
const cookies = new BrowserCookieManager.BrowserCookieManager(); | ||
for (const [key, value] of Object.entries(initialCookies)) { | ||
cookies.setCookie(key, value); | ||
} | ||
return cookies; | ||
@@ -27,0 +23,0 @@ } |
{ | ||
"name": "@shopify/react-cookie", | ||
"version": "0.0.0-snapshot-20240308174203", | ||
"version": "0.0.0-snapshot-20240620045713", | ||
"license": "MIT", | ||
@@ -24,11 +24,11 @@ "description": "Cookies in React for the server and client", | ||
"engines": { | ||
"node": "^14.17.0 || >=16.0.0" | ||
"node": ">=18.12.0" | ||
}, | ||
"dependencies": { | ||
"@shopify/react-hooks": "0.0.0-snapshot-20240308174203", | ||
"@shopify/react-network": "0.0.0-snapshot-20240308174203", | ||
"@shopify/react-hooks": "0.0.0-snapshot-20240620045713", | ||
"@shopify/react-network": "0.0.0-snapshot-20240620045713", | ||
"cookie": "^0.4.0" | ||
}, | ||
"peerDependencies": { | ||
"react": ">=16.8.0 <19.0.0", | ||
"react": ">=18.0.0 <19.0.0", | ||
"react-dom": ">=16.8.0 <19.0.0" | ||
@@ -35,0 +35,0 @@ }, |
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
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
305
23562
+ Added@shopify/react-effect@0.0.0-snapshot-20240620045713(transitive)
+ Added@shopify/react-hooks@0.0.0-snapshot-20240620045713(transitive)
+ Added@shopify/react-html@0.0.0-snapshot-20240620045713(transitive)
+ Added@shopify/react-hydrate@0.0.0-snapshot-20240620045713(transitive)
+ Added@shopify/react-network@0.0.0-snapshot-20240620045713(transitive)
+ Added@shopify/react-universal-provider@0.0.0-snapshot-20240620045713(transitive)
- Removed@shopify/react-effect@5.2.0(transitive)
- Removed@shopify/react-hooks@0.0.0-snapshot-20240308174203(transitive)
- Removed@shopify/react-html@0.0.0-snapshot-20240308174203(transitive)
- Removed@shopify/react-hydrate@0.0.0-snapshot-20240308174203(transitive)
- Removed@shopify/react-network@0.0.0-snapshot-20240308174203(transitive)
- Removed@shopify/react-universal-provider@0.0.0-snapshot-20240308174203(transitive)