jotai-location
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -1,2 +0,2 @@ | ||
import{atom as e}from"jotai/vanilla";import{atomWithStorage as n,unstable_NO_STORAGE_VALUE as t}from"jotai/vanilla/utils";const a=()=>"undefined"!=typeof window&&window.location?{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,l=(null==n?void 0:n.applyLocation)||o,s=(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=s(n);return n(),t},e(e=>e(c),(e,t,a)=>{t(c,a),l(e(c),n)})}function l(e,a,o){const i=(null==o?void 0:o.serialize)||JSON.stringify;let r=i(a),l=a;const s=(null==o?void 0:o.deserialize)||(e=>{if(r!==(e=e||"")){try{l=JSON.parse(e)}catch(e){return t}r=e}return l}),c=(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 w=null==o?void 0:o.setHash;let d=e=>{window.location.hash=e};return("replaceState"===w||null!=o&&o.replaceState)&&(d=e=>{window.history.replaceState(null,"",`${window.location.pathname}${window.location.search}#${e}`)}),"function"==typeof w&&(d=w),n(e,a,{getItem:e=>{if("undefined"==typeof window||!window.location)return t;const n=new URLSearchParams(window.location.hash.slice(1)).get(e);return s(n)},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())},subscribe:(e,n)=>c(()=>{const t=new URLSearchParams(window.location.hash.slice(1)).get(e);n(null!==t?s(t):a)})})}export{l as atomWithHash,r as atomWithLocation}; | ||
import{atom as e}from"jotai/vanilla";import{atomWithStorage as n,unstable_NO_STORAGE_VALUE as t}from"jotai/vanilla/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,l=(null==n?void 0:n.applyLocation)||a,s=(null==n?void 0:n.subscribe)||i,c=e(null!=(t=null==n?void 0:n.preloaded)?t:r());return"production"!==process.env.NODE_ENV&&(c.debugPrivate=!0),c.onMount=e=>{const n=()=>e(r()),t=s(n);return n(),t},e(e=>e(c),(e,t,o)=>{t(c,o),l(e(c),n)})}function l(e,o,a){const i=(null==a?void 0:a.serialize)||JSON.stringify;let r=i(o),l=o;const s=(null==a?void 0:a.deserialize)||(e=>{if(r!==(e=e||"")){try{l=JSON.parse(e)}catch(e){return t}r=e}return l}),c=(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 w=null==a?void 0:a.setHash;let d=e=>{window.location.hash=e};return("replaceState"===w||null!=a&&a.replaceState)&&(d=e=>{window.history.replaceState(null,"",`${window.location.pathname}${window.location.search}#${e}`)}),"function"==typeof w&&(d=w),n(e,o,{getItem:e=>{if("undefined"==typeof window||!window.location)return t;const n=new URLSearchParams(window.location.hash.slice(1)).get(e);return s(n)},setItem:(e,n)=>{const t=new URLSearchParams(window.location.hash.slice(1)),o=i(n);t.set(e,o),d(t.toString()),r=o,l=n},removeItem:e=>{const n=new URLSearchParams(window.location.hash.slice(1));n.delete(e),d(n.toString())},subscribe:(e,n)=>c(()=>{const t=new URLSearchParams(window.location.hash.slice(1)).get(e);n(null!==t?s(t):o)})})}export{l as atomWithHash,r as atomWithLocation}; | ||
//# sourceMappingURL=index.modern.mjs.map |
@@ -1,2 +0,2 @@ | ||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("jotai/vanilla"),require("jotai/vanilla/utils")):"function"==typeof define&&define.amd?define(["exports","jotai/vanilla","jotai/vanilla/utils"],e):e((n||self).jotaiLocation={},n.vanilla,n.utils)}(this,function(n,e,t){var a=function(){return"undefined"!=typeof window&&window.location?{pathname:window.location.pathname,searchParams:new URLSearchParams(window.location.search)}:{}},o=function(n,e){var t=new URL(window.location.href);n.pathname&&(t.pathname=n.pathname),n.searchParams&&(t.search=n.searchParams.toString()),null!=e&&e.replace?window.history.replaceState(null,"",t):window.history.pushState(null,"",t)},i=function(n){return window.addEventListener("popstate",n),function(){return window.removeEventListener("popstate",n)}};n.atomWithHash=function(n,e,a){var o=(null==a?void 0:a.serialize)||JSON.stringify,i=o(e),r=e,l=(null==a?void 0:a.deserialize)||function(n){if(i!==(n=n||"")){try{r=JSON.parse(n)}catch(n){return t.unstable_NO_STORAGE_VALUE}i=n}return r},c=(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 u=null==a?void 0:a.setHash,s=function(n){window.location.hash=n};return("replaceState"===u||null!=a&&a.replaceState)&&(s=function(n){window.history.replaceState(null,"",""+window.location.pathname+window.location.search+"#"+n)}),"function"==typeof u&&(s=u),t.atomWithStorage(n,e,{getItem:function(n){if("undefined"==typeof window||!window.location)return t.unstable_NO_STORAGE_VALUE;var e=new URLSearchParams(window.location.hash.slice(1)).get(n);return l(e)},setItem:function(n,e){var t=new URLSearchParams(window.location.hash.slice(1)),a=o(e);t.set(n,a),s(t.toString()),i=a,r=e},removeItem:function(n){var e=new URLSearchParams(window.location.hash.slice(1));e.delete(n),s(e.toString())},subscribe:function(n,t){return c(function(){var a=new URLSearchParams(window.location.hash.slice(1)).get(n);t(null!==a?l(a):e)})}})},n.atomWithLocation=function(n){var t,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=e.atom(null!=(t=null==n?void 0:n.preloaded)?t:r());return u.onMount=function(n){var e=function(){return n(r())},t=c(e);return e(),t},e.atom(function(n){return n(u)},function(e,t,a){t(u,a),l(e(u),n)})}}); | ||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("jotai/vanilla"),require("jotai/vanilla/utils")):"function"==typeof define&&define.amd?define(["exports","jotai/vanilla","jotai/vanilla/utils"],e):e((n||self).jotaiLocation={},n.vanilla,n.utils)}(this,function(n,e,t){var a=function(){return"undefined"!=typeof window&&window.location?{pathname:window.location.pathname,searchParams:new URLSearchParams(window.location.search)}:{}},o=function(n,e){var t=new URL(window.location.href);n.pathname&&(t.pathname=n.pathname),n.searchParams&&(t.search=n.searchParams.toString()),null!=e&&e.replace?window.history.replaceState(null,"",t):window.history.pushState(null,"",t)},i=function(n){return window.addEventListener("popstate",n),function(){return window.removeEventListener("popstate",n)}};n.atomWithHash=function(n,e,a){var o=(null==a?void 0:a.serialize)||JSON.stringify,i=o(e),r=e,l=(null==a?void 0:a.deserialize)||function(n){if(i!==(n=n||"")){try{r=JSON.parse(n)}catch(n){return t.unstable_NO_STORAGE_VALUE}i=n}return r},c=(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 u=null==a?void 0:a.setHash,s=function(n){window.location.hash=n};return("replaceState"===u||null!=a&&a.replaceState)&&(s=function(n){window.history.replaceState(null,"",""+window.location.pathname+window.location.search+"#"+n)}),"function"==typeof u&&(s=u),t.atomWithStorage(n,e,{getItem:function(n){if("undefined"==typeof window||!window.location)return t.unstable_NO_STORAGE_VALUE;var e=new URLSearchParams(window.location.hash.slice(1)).get(n);return l(e)},setItem:function(n,e){var t=new URLSearchParams(window.location.hash.slice(1)),a=o(e);t.set(n,a),s(t.toString()),i=a,r=e},removeItem:function(n){var e=new URLSearchParams(window.location.hash.slice(1));e.delete(n),s(e.toString())},subscribe:function(n,t){return c(function(){var a=new URLSearchParams(window.location.hash.slice(1)).get(n);t(null!==a?l(a):e)})}})},n.atomWithLocation=function(n){var t,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=e.atom(null!=(t=null==n?void 0:n.preloaded)?t:r());return"production"!==process.env.NODE_ENV&&(u.debugPrivate=!0),u.onMount=function(n){var e=function(){return n(r())},t=c(e);return e(),t},e.atom(function(n){return n(u)},function(e,t,a){t(u,a),l(e(u),n)})}}); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "jotai-location", | ||
"description": "👻🔗", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"author": "Daishi Kato", | ||
@@ -49,3 +49,2 @@ "repository": { | ||
"license": "MIT", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
@@ -56,2 +55,3 @@ "@testing-library/dom": "^8.20.0", | ||
"@types/jest": "^29.4.0", | ||
"@types/node": "^18.14.1", | ||
"@types/react": "^18.0.27", | ||
@@ -71,3 +71,3 @@ "@types/react-dom": "^18.0.10", | ||
"jest-environment-jsdom": "^29.4.1", | ||
"jotai": "^2.0.0", | ||
"jotai": "^2.0.3", | ||
"microbundle": "^0.15.1", | ||
@@ -74,0 +74,0 @@ "npm-run-all": "^4.1.5", |
@@ -70,2 +70,7 @@ import { atom } from 'jotai/vanilla'; | ||
const baseAtom = atom(options?.preloaded ?? getL()); | ||
if (process.env.NODE_ENV !== 'production') { | ||
baseAtom.debugPrivate = true; | ||
} | ||
baseAtom.onMount = (set) => { | ||
@@ -72,0 +77,0 @@ const callback = () => set(getL()); |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
46645
253
32
15
3