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

jotai-location

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jotai-location - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

4

CHANGELOG.md

@@ -5,2 +5,6 @@ # Change Log

## [0.3.3] - 2023-01-05
### Changed
- fix: atomWithLocation without window #8
## [0.3.2] - 2023-01-01

@@ -7,0 +11,0 @@ ### Changed

2

dist/index.modern.js

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

import{atom as e}from"jotai";import{unstable_NO_STORAGE_VALUE as n,atomWithStorage as t}from"jotai/utils";const a=()=>({pathname:window.location.pathname,searchParams:new URLSearchParams(window.location.search)}),o=(e,n)=>{const t=new URL(window.location.href);e.pathname&&(t.pathname=e.pathname),e.searchParams&&(t.search=e.searchParams.toString()),null!=n&&n.replace?window.history.replaceState(null,"",t):window.history.pushState(null,"",t)},i=e=>(window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e));function r(n){var t;const r=(null==n?void 0:n.getLocation)||a,s=(null==n?void 0:n.applyLocation)||o,l=(null==n?void 0:n.subscribe)||i,c=e(null!=(t=null==n?void 0:n.preloaded)?t:r());return c.onMount=e=>{const n=()=>e(r()),t=l(n);return n(),t},e(e=>e(c),(e,t,a)=>{t(c,a),s(e(c),n)})}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},s.apply(this,arguments)}function l(e,a,o){const i=(null==o?void 0:o.serialize)||JSON.stringify;let r=i(a),l=a;const c=(null==o?void 0:o.deserialize)||(e=>{if(r!==(e=e||"")){try{l=JSON.parse(e)}catch(e){return n}r=e}return l}),w=(null==o?void 0:o.subscribe)||(e=>(window.addEventListener("hashchange",e),()=>{window.removeEventListener("hashchange",e)}));null!=o&&o.replaceState&&console.warn("[DEPRECATED] Use setHash=replaceState instead");const h=null==o?void 0:o.setHash;let d=e=>{window.location.hash=e};("replaceState"===h||null!=o&&o.replaceState)&&(d=e=>{window.history.replaceState(null,"",`${window.location.pathname}${window.location.search}#${e}`)}),"function"==typeof h&&(d=h);const u=s({getItem:e=>{if("undefined"==typeof window||!window.location)return n;const t=new URLSearchParams(window.location.hash.slice(1)).get(e);return c(t)},setItem:(e,n)=>{const t=new URLSearchParams(window.location.hash.slice(1)),a=i(n);t.set(e,a),d(t.toString()),r=a,l=n},removeItem:e=>{const n=new URLSearchParams(window.location.hash.slice(1));n.delete(e),d(n.toString())}},(null==o?void 0:o.delayInit)&&{delayInit:!0},{subscribe:(e,n)=>w(()=>{const t=new URLSearchParams(window.location.hash.slice(1)).get(e);n(null!==t?c(t):a)})});return t(e,a,u)}export{l as atomWithHash,r as atomWithLocation};
import{atom as e}from"jotai";import{unstable_NO_STORAGE_VALUE as n,atomWithStorage as t}from"jotai/utils";const o=()=>"undefined"!=typeof window&&window.location?{pathname:window.location.pathname,searchParams:new URLSearchParams(window.location.search)}:{},a=(e,n)=>{const t=new URL(window.location.href);e.pathname&&(t.pathname=e.pathname),e.searchParams&&(t.search=e.searchParams.toString()),null!=n&&n.replace?window.history.replaceState(null,"",t):window.history.pushState(null,"",t)},i=e=>(window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e));function r(n){var t;const r=(null==n?void 0:n.getLocation)||o,s=(null==n?void 0:n.applyLocation)||a,l=(null==n?void 0:n.subscribe)||i,c=e(null!=(t=null==n?void 0:n.preloaded)?t:r());return c.onMount=e=>{const n=()=>e(r()),t=l(n);return n(),t},e(e=>e(c),(e,t,o)=>{t(c,o),s(e(c),n)})}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},s.apply(this,arguments)}function l(e,o,a){const i=(null==a?void 0:a.serialize)||JSON.stringify;let r=i(o),l=o;const c=(null==a?void 0:a.deserialize)||(e=>{if(r!==(e=e||"")){try{l=JSON.parse(e)}catch(e){return n}r=e}return l}),w=(null==a?void 0:a.subscribe)||(e=>(window.addEventListener("hashchange",e),()=>{window.removeEventListener("hashchange",e)}));null!=a&&a.replaceState&&console.warn("[DEPRECATED] Use setHash=replaceState instead");const d=null==a?void 0:a.setHash;let h=e=>{window.location.hash=e};("replaceState"===d||null!=a&&a.replaceState)&&(h=e=>{window.history.replaceState(null,"",`${window.location.pathname}${window.location.search}#${e}`)}),"function"==typeof d&&(h=d);const u=s({getItem:e=>{if("undefined"==typeof window||!window.location)return n;const t=new URLSearchParams(window.location.hash.slice(1)).get(e);return c(t)},setItem:(e,n)=>{const t=new URLSearchParams(window.location.hash.slice(1)),o=i(n);t.set(e,o),h(t.toString()),r=o,l=n},removeItem:e=>{const n=new URLSearchParams(window.location.hash.slice(1));n.delete(e),h(n.toString())}},(null==a?void 0:a.delayInit)&&{delayInit:!0},{subscribe:(e,n)=>w(()=>{const t=new URLSearchParams(window.location.hash.slice(1)).get(e);n(null!==t?c(t):o)})});return t(e,o,u)}export{l as atomWithHash,r as atomWithLocation};
//# sourceMappingURL=index.modern.mjs.map

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

!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("jotai"),require("jotai/utils")):"function"==typeof define&&define.amd?define(["exports","jotai","jotai/utils"],t):t((n||self).jotaiLocation={},n.jotai,n.utils)}(this,function(n,t,e){var a=function(){return{pathname:window.location.pathname,searchParams:new URLSearchParams(window.location.search)}},o=function(n,t){var e=new URL(window.location.href);n.pathname&&(e.pathname=n.pathname),n.searchParams&&(e.search=n.searchParams.toString()),null!=t&&t.replace?window.history.replaceState(null,"",e):window.history.pushState(null,"",e)},i=function(n){return window.addEventListener("popstate",n),function(){return window.removeEventListener("popstate",n)}};function r(){return r=Object.assign?Object.assign.bind():function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=e[a])}return n},r.apply(this,arguments)}n.atomWithHash=function(n,t,a){var o=(null==a?void 0:a.serialize)||JSON.stringify,i=o(t),l=t,c=(null==a?void 0:a.deserialize)||function(n){if(i!==(n=n||"")){try{l=JSON.parse(n)}catch(n){return e.unstable_NO_STORAGE_VALUE}i=n}return l},u=(null==a?void 0:a.subscribe)||function(n){return window.addEventListener("hashchange",n),function(){window.removeEventListener("hashchange",n)}};null!=a&&a.replaceState&&console.warn("[DEPRECATED] Use setHash=replaceState instead");var s=null==a?void 0:a.setHash,d=function(n){window.location.hash=n};("replaceState"===s||null!=a&&a.replaceState)&&(d=function(n){window.history.replaceState(null,"",""+window.location.pathname+window.location.search+"#"+n)}),"function"==typeof s&&(d=s);var h=r({getItem:function(n){if("undefined"==typeof window||!window.location)return e.unstable_NO_STORAGE_VALUE;var t=new URLSearchParams(window.location.hash.slice(1)).get(n);return c(t)},setItem:function(n,t){var e=new URLSearchParams(window.location.hash.slice(1)),a=o(t);e.set(n,a),d(e.toString()),i=a,l=t},removeItem:function(n){var t=new URLSearchParams(window.location.hash.slice(1));t.delete(n),d(t.toString())}},(null==a?void 0:a.delayInit)&&{delayInit:!0},{subscribe:function(n,e){return u(function(){var a=new URLSearchParams(window.location.hash.slice(1)).get(n);e(null!==a?c(a):t)})}});return e.atomWithStorage(n,t,h)},n.atomWithLocation=function(n){var e,r=(null==n?void 0:n.getLocation)||a,l=(null==n?void 0:n.applyLocation)||o,c=(null==n?void 0:n.subscribe)||i,u=t.atom(null!=(e=null==n?void 0:n.preloaded)?e:r());return u.onMount=function(n){var t=function(){return n(r())},e=c(t);return t(),e},t.atom(function(n){return n(u)},function(t,e,a){e(u,a),l(t(u),n)})}});
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("jotai"),require("jotai/utils")):"function"==typeof define&&define.amd?define(["exports","jotai","jotai/utils"],t):t((n||self).jotaiLocation={},n.jotai,n.utils)}(this,function(n,t,e){var o=function(){return"undefined"!=typeof window&&window.location?{pathname:window.location.pathname,searchParams:new URLSearchParams(window.location.search)}:{}},a=function(n,t){var e=new URL(window.location.href);n.pathname&&(e.pathname=n.pathname),n.searchParams&&(e.search=n.searchParams.toString()),null!=t&&t.replace?window.history.replaceState(null,"",e):window.history.pushState(null,"",e)},i=function(n){return window.addEventListener("popstate",n),function(){return window.removeEventListener("popstate",n)}};function r(){return r=Object.assign?Object.assign.bind():function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o])}return n},r.apply(this,arguments)}n.atomWithHash=function(n,t,o){var a=(null==o?void 0:o.serialize)||JSON.stringify,i=a(t),l=t,c=(null==o?void 0:o.deserialize)||function(n){if(i!==(n=n||"")){try{l=JSON.parse(n)}catch(n){return e.unstable_NO_STORAGE_VALUE}i=n}return l},u=(null==o?void 0:o.subscribe)||function(n){return window.addEventListener("hashchange",n),function(){window.removeEventListener("hashchange",n)}};null!=o&&o.replaceState&&console.warn("[DEPRECATED] Use setHash=replaceState instead");var s=null==o?void 0:o.setHash,d=function(n){window.location.hash=n};("replaceState"===s||null!=o&&o.replaceState)&&(d=function(n){window.history.replaceState(null,"",""+window.location.pathname+window.location.search+"#"+n)}),"function"==typeof s&&(d=s);var h=r({getItem:function(n){if("undefined"==typeof window||!window.location)return e.unstable_NO_STORAGE_VALUE;var t=new URLSearchParams(window.location.hash.slice(1)).get(n);return c(t)},setItem:function(n,t){var e=new URLSearchParams(window.location.hash.slice(1)),o=a(t);e.set(n,o),d(e.toString()),i=o,l=t},removeItem:function(n){var t=new URLSearchParams(window.location.hash.slice(1));t.delete(n),d(t.toString())}},(null==o?void 0:o.delayInit)&&{delayInit:!0},{subscribe:function(n,e){return u(function(){var o=new URLSearchParams(window.location.hash.slice(1)).get(n);e(null!==o?c(o):t)})}});return e.atomWithStorage(n,t,h)},n.atomWithLocation=function(n){var e,r=(null==n?void 0:n.getLocation)||o,l=(null==n?void 0:n.applyLocation)||a,c=(null==n?void 0:n.subscribe)||i,u=t.atom(null!=(e=null==n?void 0:n.preloaded)?e:r());return u.onMount=function(n){var t=function(){return n(r())},e=c(t);return t(),e},t.atom(function(n){return n(u)},function(t,e,o){e(u,o),l(t(u),n)})}});
//# sourceMappingURL=index.umd.js.map
{
"name": "jotai-location",
"description": "👻🔗",
"version": "0.3.2",
"version": "0.3.3",
"author": "Daishi Kato",

@@ -6,0 +6,0 @@ "repository": {

@@ -11,1 +11,3 @@ # jotai-location

- [v0.2.0 announcement](https://twitter.com/dai_shi/status/1593219435896410114)
- [v0.3.0 announcement](https://twitter.com/dai_shi/status/1598153411605671936)
- [v0.3.2 announcement](https://twitter.com/dai_shi/status/1609704860869623809)

@@ -9,6 +9,11 @@ import { atom } from 'jotai';

const getLocation = (): Location => ({
pathname: window.location.pathname,
searchParams: new URLSearchParams(window.location.search),
});
const getLocation = (): Location => {
if (typeof window === 'undefined' || !window.location) {
return {};
}
return {
pathname: window.location.pathname,
searchParams: new URLSearchParams(window.location.search),
};
};

@@ -15,0 +20,0 @@ const applyLocation = (

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

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