@pickaxeproject/react 6.8.6 → 6.8.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tldts");const t="PXE-uid",r=(e,t=!1)=>{let r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";t&&(r=r.replace(/[0-9]/g,""));let o="";for(let t=0;t<e;t++)o+=r.charAt(Math.floor(Math.random()*r.length));return o},o=e=>{try{const t=document.cookie.split("; ");for(const r of t){const[t,o]=r.split("=");if(t===e)return o}return null}catch(e){return console.error("[pxe] failed to get cookie",e),null}};exports.COOKIE_USER_ID=t,exports.buildUpgradeUrl=({baseUrl:e,redirectUrl:t,accessGroupId:r,currentUrl:o})=>{if(!e)return null;const n=null!=o?o:"undefined"!=typeof window?window.location.href:null;if(!n)return null;try{const o=new URL(e,n);return r&&o.searchParams.set("agid",r),t&&o.searchParams.set("redirectUrl",t),o.toString()}catch(e){return console.error("[pxe] failed to build upgrade url",e),null}},exports.deleteAuthToken=e=>{try{if("undefined"==typeof window)return;localStorage.removeItem(e)}catch(e){console.error("[pxe] failed to delete auth token",e)}},exports.deleteCookie=e=>{document.cookie=e+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"},exports.extractUrlsFromText=e=>{const t=e.match(/(https?:\/\/[^\s]+)/g)||[];return Array.from(new Set(t))},exports.formatBytes=(e,t=2)=>{if(!+e)return"0 Bytes";const r=t<0?0:t,o=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,o)).toFixed(r))} ${["Bytes","KB","MB","PB","EB"][o]}`},exports.generateId=(e,t="",r="")=>{let o="";for(let t=0;t<e;t++){o+="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[Math.floor(36*Math.random())]}return t+o+r},exports.getAuthToken=e=>{try{if("undefined"==typeof window)return null;let t=null;return t=new URLSearchParams(window.location.search).get("pxtoken"),t||(t=localStorage.getItem(`PXE-token-${e}`)),t||(t=o(`PXE-token-${e}`)),t||(t=o(`__Secure-PS-${e}.session-token`)),t?decodeURIComponent(t):null}catch(e){return null}},exports.getCookie=o,exports.initializeEmbedUserId=()=>{try{const n=o(t);if(!n){const o=r(28),n=new Date;n.setFullYear(n.getFullYear()+1);let l=window.location.hostname;const s=e.parse(l).domain;if(s)l=`.${s}`;else{const e=l.split(":")[0],t=e.split(".");l=e,t.length>=2&&(l=`.${t.slice(-2).join(".")}`)}return document.cookie=`${t}=${o};Path=/; Domain=${l}; Expires=${n.toUTCString()}`,o}return n}catch(e){return console.error("[pxe-embed] failed to initialized embed user id",e),r(28)}},exports.isInIframe=()=>{if("undefined"==typeof window)return!1;try{return window.self!==window.top}catch(e){return!0}},exports.mergeRefs=function(...e){return t=>{for(const r of e)r&&("function"==typeof r?r(t):r.current=t)}},exports.randomStr=r,exports.safeJSONParse=e=>{try{return JSON.parse(e)}catch(e){return null}},exports.setAuthToken=(e,t)=>{try{if("undefined"==typeof window)return;localStorage.setItem(e,t)}catch(e){console.error("[pxe] failed to set auth token",e)}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tldts");const t="PXE-uid",r=(e,t=!1)=>{let r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";t&&(r=r.replace(/[0-9]/g,""));let o="";for(let t=0;t<e;t++)o+=r.charAt(Math.floor(Math.random()*r.length));return o},o=e=>{try{const t=document.cookie.split("; ");for(const r of t){const[t,o]=r.split("=");if(t===e)return o}return null}catch(e){return console.error("[pxe] failed to get cookie",e),null}};exports.COOKIE_USER_ID=t,exports.buildUpgradeUrl=({baseUrl:e,redirectUrl:t,accessGroupId:r,currentUrl:o})=>{if(!e)return null;const n=null!=o?o:"undefined"!=typeof window?window.location.href:null;if(!n)return null;try{const o=new URL(e,n);if(r){const e=((e,t)=>{const r=e.pathname.split("/"),o=r.findIndex((e=>"ag-pricing"===e));return-1!==o&&!r[o+1]&&(r.splice(o+1,0,encodeURIComponent(t)),e.pathname=r.join("/"),!0)})(o,r);e||o.searchParams.set("agid",r)}return t&&o.searchParams.set("redirectUrl",t),o.toString()}catch(e){return console.error("[pxe] failed to build upgrade url",e),null}},exports.deleteAuthToken=e=>{try{if("undefined"==typeof window)return;localStorage.removeItem(e)}catch(e){console.error("[pxe] failed to delete auth token",e)}},exports.deleteCookie=e=>{document.cookie=e+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"},exports.extractUrlsFromText=e=>{const t=e.match(/(https?:\/\/[^\s]+)/g)||[];return Array.from(new Set(t))},exports.formatBytes=(e,t=2)=>{if(!+e)return"0 Bytes";const r=t<0?0:t,o=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,o)).toFixed(r))} ${["Bytes","KB","MB","PB","EB"][o]}`},exports.generateId=(e,t="",r="")=>{let o="";for(let t=0;t<e;t++){o+="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[Math.floor(36*Math.random())]}return t+o+r},exports.getAuthToken=e=>{try{if("undefined"==typeof window)return null;let t=null;return t=new URLSearchParams(window.location.search).get("pxtoken"),t||(t=localStorage.getItem(`PXE-token-${e}`)),t||(t=o(`PXE-token-${e}`)),t||(t=o(`__Secure-PS-${e}.session-token`)),t?decodeURIComponent(t):null}catch(e){return null}},exports.getCookie=o,exports.initializeEmbedUserId=()=>{try{const n=o(t);if(!n){const o=r(28),n=new Date;n.setFullYear(n.getFullYear()+1);let l=window.location.hostname;const s=e.parse(l).domain;if(s)l=`.${s}`;else{const e=l.split(":")[0],t=e.split(".");l=e,t.length>=2&&(l=`.${t.slice(-2).join(".")}`)}return document.cookie=`${t}=${o};Path=/; Domain=${l}; Expires=${n.toUTCString()}`,o}return n}catch(e){return console.error("[pxe-embed] failed to initialized embed user id",e),r(28)}},exports.isInIframe=()=>{if("undefined"==typeof window)return!1;try{return window.self!==window.top}catch(e){return!0}},exports.mergeRefs=function(...e){return t=>{for(const r of e)r&&("function"==typeof r?r(t):r.current=t)}},exports.randomStr=r,exports.safeJSONParse=e=>{try{return JSON.parse(e)}catch(e){return null}},exports.setAuthToken=(e,t)=>{try{if("undefined"==typeof window)return;localStorage.setItem(e,t)}catch(e){console.error("[pxe] failed to set auth token",e)}};
@@ -1 +1 @@
1
- import{parse as e}from"tldts";const t="PXE-uid",r=(e,t="",r="")=>{let o="";for(let t=0;t<e;t++){o+="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[Math.floor(36*Math.random())]}return t+o+r},o=(e,t=!1)=>{let r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";t&&(r=r.replace(/[0-9]/g,""));let o="";for(let t=0;t<e;t++)o+=r.charAt(Math.floor(Math.random()*r.length));return o},n=e=>{const t=e.match(/(https?:\/\/[^\s]+)/g)||[];return Array.from(new Set(t))},l=({baseUrl:e,redirectUrl:t,accessGroupId:r,currentUrl:o})=>{if(!e)return null;const n=null!=o?o:"undefined"!=typeof window?window.location.href:null;if(!n)return null;try{const o=new URL(e,n);return r&&o.searchParams.set("agid",r),t&&o.searchParams.set("redirectUrl",t),o.toString()}catch(e){return console.error("[pxe] failed to build upgrade url",e),null}},c=(e,t=2)=>{if(!+e)return"0 Bytes";const r=t<0?0:t,o=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,o)).toFixed(r))} ${["Bytes","KB","MB","PB","EB"][o]}`},a=e=>{try{const t=document.cookie.split("; ");for(const r of t){const[t,o]=r.split("=");if(t===e)return o}return null}catch(e){return console.error("[pxe] failed to get cookie",e),null}},i=e=>{document.cookie=e+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"},u=()=>{try{const r=a(t);if(!r){const r=o(28),n=new Date;n.setFullYear(n.getFullYear()+1);let l=window.location.hostname;const c=e(l).domain;if(c)l=`.${c}`;else{const e=l.split(":")[0],t=e.split(".");l=e,t.length>=2&&(l=`.${t.slice(-2).join(".")}`)}return document.cookie=`${t}=${r};Path=/; Domain=${l}; Expires=${n.toUTCString()}`,r}return r}catch(e){return console.error("[pxe-embed] failed to initialized embed user id",e),o(28)}},s=e=>{try{if("undefined"==typeof window)return null;let t=null;return t=new URLSearchParams(window.location.search).get("pxtoken"),t||(t=localStorage.getItem(`PXE-token-${e}`)),t||(t=a(`PXE-token-${e}`)),t||(t=a(`__Secure-PS-${e}.session-token`)),t?decodeURIComponent(t):null}catch(e){return null}},d=(e,t)=>{try{if("undefined"==typeof window)return;localStorage.setItem(e,t)}catch(e){console.error("[pxe] failed to set auth token",e)}},f=e=>{try{if("undefined"==typeof window)return;localStorage.removeItem(e)}catch(e){console.error("[pxe] failed to delete auth token",e)}};function h(...e){return t=>{for(const r of e)r&&("function"==typeof r?r(t):r.current=t)}}const p=()=>{if("undefined"==typeof window)return!1;try{return window.self!==window.top}catch(e){return!0}},w=e=>{try{return JSON.parse(e)}catch(e){return null}};export{t as COOKIE_USER_ID,l as buildUpgradeUrl,f as deleteAuthToken,i as deleteCookie,n as extractUrlsFromText,c as formatBytes,r as generateId,s as getAuthToken,a as getCookie,u as initializeEmbedUserId,p as isInIframe,h as mergeRefs,o as randomStr,w as safeJSONParse,d as setAuthToken};
1
+ import{parse as e}from"tldts";const t="PXE-uid",r=(e,t="",r="")=>{let n="";for(let t=0;t<e;t++){n+="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[Math.floor(36*Math.random())]}return t+n+r},n=(e,t=!1)=>{let r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";t&&(r=r.replace(/[0-9]/g,""));let n="";for(let t=0;t<e;t++)n+=r.charAt(Math.floor(Math.random()*r.length));return n},o=e=>{const t=e.match(/(https?:\/\/[^\s]+)/g)||[];return Array.from(new Set(t))},l=({baseUrl:e,redirectUrl:t,accessGroupId:r,currentUrl:n})=>{if(!e)return null;const o=null!=n?n:"undefined"!=typeof window?window.location.href:null;if(!o)return null;try{const n=new URL(e,o);if(r){const e=((e,t)=>{const r=e.pathname.split("/"),n=r.findIndex((e=>"ag-pricing"===e));return-1!==n&&!r[n+1]&&(r.splice(n+1,0,encodeURIComponent(t)),e.pathname=r.join("/"),!0)})(n,r);e||n.searchParams.set("agid",r)}return t&&n.searchParams.set("redirectUrl",t),n.toString()}catch(e){return console.error("[pxe] failed to build upgrade url",e),null}},c=(e,t=2)=>{if(!+e)return"0 Bytes";const r=t<0?0:t,n=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,n)).toFixed(r))} ${["Bytes","KB","MB","PB","EB"][n]}`},i=e=>{try{const t=document.cookie.split("; ");for(const r of t){const[t,n]=r.split("=");if(t===e)return n}return null}catch(e){return console.error("[pxe] failed to get cookie",e),null}},a=e=>{document.cookie=e+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"},u=()=>{try{const r=i(t);if(!r){const r=n(28),o=new Date;o.setFullYear(o.getFullYear()+1);let l=window.location.hostname;const c=e(l).domain;if(c)l=`.${c}`;else{const e=l.split(":")[0],t=e.split(".");l=e,t.length>=2&&(l=`.${t.slice(-2).join(".")}`)}return document.cookie=`${t}=${r};Path=/; Domain=${l}; Expires=${o.toUTCString()}`,r}return r}catch(e){return console.error("[pxe-embed] failed to initialized embed user id",e),n(28)}},s=e=>{try{if("undefined"==typeof window)return null;let t=null;return t=new URLSearchParams(window.location.search).get("pxtoken"),t||(t=localStorage.getItem(`PXE-token-${e}`)),t||(t=i(`PXE-token-${e}`)),t||(t=i(`__Secure-PS-${e}.session-token`)),t?decodeURIComponent(t):null}catch(e){return null}},d=(e,t)=>{try{if("undefined"==typeof window)return;localStorage.setItem(e,t)}catch(e){console.error("[pxe] failed to set auth token",e)}},f=e=>{try{if("undefined"==typeof window)return;localStorage.removeItem(e)}catch(e){console.error("[pxe] failed to delete auth token",e)}};function p(...e){return t=>{for(const r of e)r&&("function"==typeof r?r(t):r.current=t)}}const h=()=>{if("undefined"==typeof window)return!1;try{return window.self!==window.top}catch(e){return!0}},m=e=>{try{return JSON.parse(e)}catch(e){return null}};export{t as COOKIE_USER_ID,l as buildUpgradeUrl,f as deleteAuthToken,a as deleteCookie,o as extractUrlsFromText,c as formatBytes,r as generateId,s as getAuthToken,i as getCookie,u as initializeEmbedUserId,h as isInIframe,p as mergeRefs,n as randomStr,m as safeJSONParse,d as setAuthToken};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pickaxeproject/react",
3
- "version": "6.8.6",
3
+ "version": "6.8.7",
4
4
  "description": "Client utility library for Pickaxe",
5
5
  "repository": {
6
6
  "type": "git",