@dub/utils 0.0.26 → 0.0.28

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.
Files changed (111) hide show
  1. package/dist/chunk-2DN4J7N7.mjs +1 -0
  2. package/dist/chunk-2J47GIUG.mjs +1 -0
  3. package/dist/chunk-2OJAP233.mjs +1 -0
  4. package/dist/chunk-34MPJURK.mjs +1 -0
  5. package/dist/chunk-3B5DP3T4.mjs +1 -0
  6. package/dist/chunk-3BUV2ANI.mjs +1 -0
  7. package/dist/chunk-3PRW7SAO.mjs +1 -0
  8. package/dist/chunk-4BN7BHOL.mjs +1 -0
  9. package/dist/chunk-5PD4TPH7.mjs +1 -0
  10. package/dist/chunk-5SU2MWLU.mjs +0 -0
  11. package/dist/chunk-6N3NW2JB.mjs +1 -0
  12. package/dist/chunk-6TFUDH7S.mjs +1 -0
  13. package/dist/chunk-6XPTKHZD.mjs +1 -0
  14. package/dist/chunk-7CR3I247.mjs +1 -0
  15. package/dist/chunk-7OQSL4CI.mjs +2 -0
  16. package/dist/chunk-AI2STCLX.mjs +1 -0
  17. package/dist/chunk-BE3FE22D.mjs +1 -0
  18. package/dist/chunk-BMMTE4CL.mjs +1 -0
  19. package/dist/chunk-BQ3MQSVS.mjs +1 -0
  20. package/dist/chunk-C7CFYTBV.mjs +1 -0
  21. package/dist/chunk-DHOWTHOI.mjs +3 -0
  22. package/dist/chunk-EMO4MGOU.mjs +1 -0
  23. package/dist/chunk-F6C3QYRM.mjs +1 -0
  24. package/dist/chunk-FCP5HRN4.mjs +1 -0
  25. package/dist/chunk-FLUV3ASQ.mjs +1 -0
  26. package/dist/chunk-GQLUSHIW.mjs +1 -0
  27. package/dist/chunk-GTQBILTE.mjs +1 -0
  28. package/dist/chunk-HX6TVXHR.mjs +1 -0
  29. package/dist/chunk-I5Y5DKPK.mjs +1 -0
  30. package/dist/chunk-IGSNFZ4Y.mjs +1 -0
  31. package/dist/chunk-INKMK7VX.mjs +1 -0
  32. package/dist/chunk-J6V4PKNC.mjs +1 -0
  33. package/dist/chunk-KL7VCF4Y.mjs +1 -0
  34. package/dist/chunk-L2SFRDQT.mjs +1 -0
  35. package/dist/chunk-L7JSRS6V.mjs +1 -0
  36. package/dist/chunk-LXJVNY3R.mjs +1 -0
  37. package/dist/chunk-MK4UFVOH.mjs +1 -0
  38. package/dist/chunk-MPU6JRPV.mjs +1 -0
  39. package/dist/chunk-MT3GLHZG.mjs +1 -0
  40. package/dist/chunk-NEIHTFSW.mjs +1 -0
  41. package/dist/chunk-OANHZJ6X.mjs +1 -0
  42. package/dist/chunk-OSU5S2YT.mjs +3 -0
  43. package/dist/chunk-PEPVOMPB.mjs +1 -0
  44. package/dist/chunk-QQFYILG6.mjs +1 -0
  45. package/dist/chunk-QYPFWXDY.mjs +1 -0
  46. package/dist/chunk-SKVYWWBC.mjs +3 -0
  47. package/dist/chunk-SPSUTBZ7.mjs +0 -0
  48. package/dist/chunk-TLOL4ZCF.mjs +1 -0
  49. package/dist/chunk-TXEDXHC5.mjs +1 -0
  50. package/dist/chunk-UBCCNLBS.mjs +1 -0
  51. package/dist/chunk-UUWTKITJ.mjs +1 -0
  52. package/dist/chunk-VZYPOBKB.mjs +1 -0
  53. package/dist/chunk-W5LUKKPM.mjs +1 -0
  54. package/dist/chunk-WCUHRXGZ.mjs +1 -0
  55. package/dist/chunk-XWSEDYR7.mjs +1 -0
  56. package/dist/chunk-YUMUNL66.mjs +1 -0
  57. package/dist/chunk-YXHGPHL2.mjs +1 -0
  58. package/dist/chunk-YY4NGU5S.mjs +1 -0
  59. package/dist/chunk-ZBBENF7Y.mjs +1 -0
  60. package/dist/chunk-ZECUYKGD.mjs +1 -0
  61. package/dist/chunk-ZJKRLIJQ.mjs +1 -0
  62. package/dist/constants/cctlds.d.ts +1 -1
  63. package/dist/constants/cctlds.mjs +1 -1
  64. package/dist/constants/countries.d.ts +1 -1
  65. package/dist/constants/countries.mjs +1 -1
  66. package/dist/constants/index.d.ts +119 -6
  67. package/dist/constants/index.mjs +1 -1
  68. package/dist/functions/capitalize.d.ts +3 -0
  69. package/dist/functions/capitalize.mjs +1 -0
  70. package/dist/functions/chunk.d.ts +3 -0
  71. package/dist/functions/chunk.mjs +1 -0
  72. package/dist/functions/cn.d.ts +5 -0
  73. package/dist/functions/cn.mjs +1 -0
  74. package/dist/functions/construct-metadata.d.ts +11 -0
  75. package/dist/functions/construct-metadata.mjs +1 -0
  76. package/dist/functions/datetime.d.ts +11 -0
  77. package/dist/functions/datetime.mjs +1 -0
  78. package/dist/functions/deep-equal.d.ts +4 -0
  79. package/dist/functions/deep-equal.mjs +1 -0
  80. package/dist/functions/domains.d.ts +10 -0
  81. package/dist/functions/domains.mjs +1 -0
  82. package/dist/functions/fetch-with-timeout.d.ts +3 -0
  83. package/dist/functions/fetch-with-timeout.mjs +1 -0
  84. package/dist/functions/fetcher.d.ts +3 -0
  85. package/dist/functions/fetcher.mjs +1 -0
  86. package/dist/functions/hash.d.ts +3 -0
  87. package/dist/functions/hash.mjs +1 -0
  88. package/dist/functions/index.d.ts +21 -0
  89. package/dist/functions/index.mjs +1 -0
  90. package/dist/functions/is-iframeable.d.ts +6 -0
  91. package/dist/functions/is-iframeable.mjs +1 -0
  92. package/dist/functions/link-constructor.d.ts +9 -0
  93. package/dist/functions/link-constructor.mjs +1 -0
  94. package/dist/functions/log.d.ts +7 -0
  95. package/dist/functions/log.mjs +1 -0
  96. package/dist/functions/misc.d.ts +112 -0
  97. package/dist/functions/misc.mjs +1 -0
  98. package/dist/functions/nanoid.d.ts +3 -0
  99. package/dist/functions/nanoid.mjs +1 -0
  100. package/dist/functions/nformatter.d.ts +6 -0
  101. package/dist/functions/nformatter.mjs +1 -0
  102. package/dist/functions/time-ago.d.ts +5 -0
  103. package/dist/functions/time-ago.mjs +1 -0
  104. package/dist/functions/truncate.d.ts +3 -0
  105. package/dist/functions/truncate.mjs +1 -0
  106. package/dist/functions/urls.d.ts +13 -0
  107. package/dist/functions/urls.mjs +1 -0
  108. package/dist/index.d.ts +24 -181
  109. package/dist/index.mjs +1 -1
  110. package/dist/is-iframeable-4cf55b9f.d.ts +6 -0
  111. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -1,181 +1,24 @@
1
- import { ClassValue } from 'clsx';
2
- import { Metadata } from 'next';
3
- export { ADMIN_HOSTNAMES, ALL_TOOLS, API_DOMAIN, API_HOSTNAMES, APP_DOMAIN, APP_DOMAIN_WITH_NGROK, APP_HOSTNAMES, DEFAULT_LINK_PROPS, DEFAULT_REDIRECTS, DUB_DOMAINS, DUB_HEADERS, DUB_LOGO, DUB_PROJECT_ID, DUB_THUMBNAIL, FADE_IN_ANIMATION_SETTINGS, FRAMER_MOTION_LIST_ITEM_VARIANTS, GOOGLE_FAVICON_URL, HIDE_BACKGROUND_SEGMENTS, HOME_DOMAIN, LEGAL_PROJECT_ID, LEGAL_USER_ID, LOCALHOST_GEO_DATA, LOCALHOST_IP, PAGINATION_LIMIT, PLANS, SAML_PROVIDERS, SECOND_LEVEL_DOMAINS, SELF_SERVE_PAID_PLANS, SHORT_DOMAIN, SPECIAL_APEX_DOMAINS, STAGGER_CHILD_VARIANTS, SWIPE_REVEAL_ANIMATION_SETTINGS } from './constants/index.js';
4
- export { default as ccTLDs } from './constants/cctlds.js';
5
- export { default as COUNTRIES } from './constants/countries.js';
6
-
7
- declare function cn(...inputs: ClassValue[]): string;
8
- declare function constructMetadata({ title, description, image, icons, noIndex, }?: {
9
- title?: string;
10
- description?: string;
11
- image?: string;
12
- icons?: Metadata["icons"];
13
- noIndex?: boolean;
14
- }): Metadata;
15
- declare const nanoid: (size?: number | undefined) => string;
16
- declare function fetcher<JSON = any>(input: RequestInfo, init?: RequestInit): Promise<JSON>;
17
- declare function nFormatter(num?: number, opts?: {
18
- digits?: number;
19
- full?: boolean;
20
- }): string;
21
- declare function capitalize(str?: string | null): string | null | undefined;
22
- declare const chunk: <T>(array: T[], chunk_size: number) => T[][];
23
- declare function linkConstructor({ domain, key, localhost, pretty, noDomain, }: {
24
- domain?: string;
25
- key?: string;
26
- localhost?: boolean;
27
- pretty?: boolean;
28
- noDomain?: boolean;
29
- }): string;
30
- declare const timeAgo: (timestamp: Date | null, { withAgo, }?: {
31
- withAgo?: boolean | undefined;
32
- }) => string;
33
- declare const getDateTimeLocal: (timestamp?: Date) => string;
34
- declare const formatDate: (dateString: string) => string;
35
- declare const getFirstAndLastDay: (day: number) => {
36
- firstDay: Date;
37
- lastDay: Date;
38
- };
39
- declare const getLastDayOfMonth: () => number;
40
- declare const getAdjustedBillingCycleStart: (billingCycleStart: number) => number;
41
- declare const getBillingStartDate: (billingCycleStart: number) => Date;
42
- declare const getPlanFromPriceId: (priceId: string) => {
43
- name: string;
44
- tagline: string;
45
- price: {
46
- monthly: number;
47
- yearly: number;
48
- ids?: undefined;
49
- };
50
- limits: {
51
- links: number;
52
- clicks: number;
53
- domains: number;
54
- tags: number;
55
- users: number;
56
- };
57
- colors: {
58
- bg: string;
59
- text: string;
60
- };
61
- cta: {
62
- text: string;
63
- href: string;
64
- color: string;
65
- shortText?: undefined;
66
- };
67
- featureTitle: string;
68
- features: ({
69
- text: string;
70
- footnote?: undefined;
71
- } | {
72
- text: string;
73
- footnote: string;
74
- } | {
75
- text: string;
76
- footnote: {
77
- title: string;
78
- cta: string;
79
- href: string;
80
- };
81
- })[];
82
- } | {
83
- name: string;
84
- tagline: string;
85
- price: {
86
- monthly: number;
87
- yearly: number;
88
- ids: string[];
89
- };
90
- limits: {
91
- links: number;
92
- clicks: number;
93
- domains: number;
94
- tags: number;
95
- users: number;
96
- };
97
- colors: {
98
- bg: string;
99
- text: string;
100
- };
101
- cta: {
102
- text: string;
103
- shortText: string;
104
- href: string;
105
- color: string;
106
- };
107
- featureTitle: string;
108
- features: ({
109
- text: string;
110
- footnote?: undefined;
111
- } | {
112
- text: string;
113
- footnote: string;
114
- } | {
115
- text: string;
116
- footnote: {
117
- title: string;
118
- cta: string;
119
- href: string;
120
- };
121
- })[];
122
- } | {
123
- name: string;
124
- price: {
125
- monthly: null;
126
- yearly: null;
127
- ids?: undefined;
128
- };
129
- limits: {
130
- links: null;
131
- clicks: null;
132
- domains: null;
133
- tags?: undefined;
134
- users?: undefined;
135
- };
136
- colors: {
137
- bg: string;
138
- text: string;
139
- };
140
- cta: {
141
- text: string;
142
- href: string;
143
- color: string;
144
- shortText?: undefined;
145
- };
146
- featureTitle: string;
147
- features: {
148
- text: string;
149
- }[];
150
- tagline?: undefined;
151
- } | null;
152
- declare const generateDomainFromName: (name: string) => string;
153
- declare const validDomainRegex: RegExp;
154
- declare const validKeyRegex: RegExp;
155
- declare const validSlugRegex: RegExp;
156
- declare const getSubdomain: (name: string, apexName: string) => string | null;
157
- declare const getApexDomain: (url: string) => string;
158
- declare const isValidUrl: (url: string) => boolean;
159
- declare const getUrlFromString: (str: string) => string | null | undefined;
160
- declare const getDomainWithoutWWW: (url: string) => string | null | undefined;
161
- declare const isDubDomain: (domain: string) => boolean;
162
- declare const getSearchParams: (url: string) => Record<string, string>;
163
- declare const truncate: (str: string | null, length: number) => string | null;
164
- declare const getParamsFromURL: (url: string) => Record<string, string>;
165
- declare const constructURLFromUTMParams: (url: string, utmParams: Record<string, string>) => string;
166
- declare const paramsMetadata: {
167
- display: string;
168
- key: string;
169
- examples: string;
170
- }[];
171
- declare const getUrlWithoutUTMParams: (url: string) => string;
172
- declare function generateMD5Hash(message: string): Promise<string>;
173
- declare const log: ({ message, type, mention, }: {
174
- message: string;
175
- type: "cron" | "links";
176
- mention?: boolean | undefined;
177
- }) => Promise<Response | undefined>;
178
- type DeepEqual = (obj1: Record<string, any>, obj2: Record<string, any>) => boolean;
179
- declare const deepEqual: DeepEqual;
180
-
181
- export { capitalize, chunk, cn, constructMetadata, constructURLFromUTMParams, deepEqual, fetcher, formatDate, generateDomainFromName, generateMD5Hash, getAdjustedBillingCycleStart, getApexDomain, getBillingStartDate, getDateTimeLocal, getDomainWithoutWWW, getFirstAndLastDay, getLastDayOfMonth, getParamsFromURL, getPlanFromPriceId, getSearchParams, getSubdomain, getUrlFromString, getUrlWithoutUTMParams, isDubDomain, isValidUrl, linkConstructor, log, nFormatter, nanoid, paramsMetadata, timeAgo, truncate, validDomainRegex, validKeyRegex, validSlugRegex };
1
+ export { ADMIN_HOSTNAMES, ALL_TOOLS, API_DOMAIN, API_HOSTNAMES, APP_DOMAIN, APP_DOMAIN_WITH_NGROK, APP_HOSTNAMES, DEFAULT_LINK_PROPS, DEFAULT_REDIRECTS, DUB_DOMAINS, DUB_HEADERS, DUB_LOGO, DUB_PROJECT_ID, DUB_THUMBNAIL, FADE_IN_ANIMATION_SETTINGS, FRAMER_MOTION_LIST_ITEM_VARIANTS, FREE_PLAN, FREE_PROJECTS_LIMIT, GOOGLE_FAVICON_URL, HIDE_BACKGROUND_SEGMENTS, HOME_DOMAIN, LEGAL_PROJECT_ID, LEGAL_USER_ID, LOCALHOST_GEO_DATA, LOCALHOST_IP, PAGINATION_LIMIT, PLANS, SAML_PROVIDERS, SECOND_LEVEL_DOMAINS, SELF_SERVE_PAID_PLANS, SHORT_DOMAIN, SPECIAL_APEX_DOMAINS, STAGGER_CHILD_VARIANTS, SWIPE_REVEAL_ANIMATION_SETTINGS } from './constants/index.js';
2
+ export { capitalize } from './functions/capitalize.js';
3
+ export { chunk } from './functions/chunk.js';
4
+ export { cn } from './functions/cn.js';
5
+ export { constructMetadata } from './functions/construct-metadata.js';
6
+ export { formatDate, getAdjustedBillingCycleStart, getBillingStartDate, getDateTimeLocal, getFirstAndLastDay, getLastDayOfMonth } from './functions/datetime.js';
7
+ export { deepEqual } from './functions/deep-equal.js';
8
+ export { generateDomainFromName, getApexDomain, getDomainWithoutWWW, getSubdomain, isDubDomain, validDomainRegex, validKeyRegex, validSlugRegex } from './functions/domains.js';
9
+ export { fetchWithTimeout } from './functions/fetch-with-timeout.js';
10
+ export { fetcher } from './functions/fetcher.js';
11
+ export { generateMD5Hash } from './functions/hash.js';
12
+ export { isIframeable } from './functions/is-iframeable.js';
13
+ export { linkConstructor } from './functions/link-constructor.js';
14
+ export { log } from './functions/log.js';
15
+ export { getPlanFromPriceId } from './functions/misc.js';
16
+ export { nanoid } from './functions/nanoid.js';
17
+ export { nFormatter } from './functions/nformatter.js';
18
+ export { timeAgo } from './functions/time-ago.js';
19
+ export { truncate } from './functions/truncate.js';
20
+ export { constructURLFromUTMParams, getParamsFromURL, getSearchParams, getUrlFromString, getUrlWithoutUTMParams, isValidUrl, paramsMetadata } from './functions/urls.js';
21
+ export { ccTLDs } from './constants/cctlds.js';
22
+ export { COUNTRIES } from './constants/countries.js';
23
+ import 'clsx';
24
+ import 'next';
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{A as p,B as J,C as q,D as V,E as G,F as X,a as c,b as L,c as R,d as k,e as v,f as A,g as O,h as E,i as T,j as $,k as l,l as N,m as P,n as C,o as F,p as I,q as z,r as K,s as B,t as j,u as H,v as Y,w as Z,x as u,y as W,z as g}from"./chunk-JPCDHJLD.mjs";import{a as i}from"./chunk-MODISIUH.mjs";import{a as _}from"./chunk-3P54C65P.mjs";import h from"@sindresorhus/slugify";import{clsx as d}from"clsx";import y from"ms";import{customAlphabet as x}from"nanoid";import{twMerge as D}from"tailwind-merge";function se(...e){return D(d(e))}function ae({title:e=`${process.env.NEXT_PUBLIC_APP_NAME} - Link Management for Modern Marketing Teams`,description:t=`${process.env.NEXT_PUBLIC_APP_NAME} is the open-source link management infrastructure for modern marketing teams to create, share, and track short links.`,image:n="https://dub.co/_static/thumbnail.png",icons:o=[{rel:"apple-touch-icon",sizes:"32x32",url:"/apple-touch-icon.png"},{rel:"icon",type:"image/png",sizes:"32x32",url:"/favicon-32x32.png"},{rel:"icon",type:"image/png",sizes:"16x16",url:"/favicon-16x16.png"}],noIndex:r=!1}={}){return{title:e,description:t,openGraph:{title:e,description:t,images:[{url:n}]},twitter:{card:"summary_large_image",title:e,description:t,images:[n],creator:"@dubdotco"},icons:o,metadataBase:new URL(l),...r&&{robots:{index:!1,follow:!1}}}}var ie=x("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7);async function ce(e,t){let n=await fetch(e,t);if(!n.ok){let o=await n.text(),r=new Error(o);throw r.status=n.status,r}return n.json()}function le(e,t={digits:1}){if(!e)return"0";if(t.full)return Intl.NumberFormat("en-US").format(e);let n=[{value:1,symbol:""},{value:1e3,symbol:"K"},{value:1e6,symbol:"M"},{value:1e9,symbol:"G"},{value:1e12,symbol:"T"},{value:1e15,symbol:"P"},{value:1e18,symbol:"E"}],o=/\.0+$|(\.[0-9]*[1-9])0+$/;var r=n.slice().reverse().find(function(s){return e>=s.value});return r?(e/r.value).toFixed(t.digits).replace(o,"$1")+r.symbol:"0"}function ue(e){return!e||typeof e!="string"?e:e.charAt(0).toUpperCase()+e.slice(1)}var ge=(e,t)=>e.reduce((n,o,r)=>{let s=Math.floor(r/t);return n[s]||(n[s]=[]),n[s].push(o),n},[]);function pe({domain:e="dub.sh",key:t,localhost:n,pretty:o,noDomain:r}){let s=`${n?"http://home.localhost:8888":`https://${e}`}${t&&t!=="_root"?`/${t}`:""}`;return r?`/${t}`:o?s.replace(/^https?:\/\//,""):s}var me=(e,{withAgo:t}={})=>{if(!e)return"Never";let n=Date.now()-new Date(e).getTime();return n<1e3?"Just now":n>828e5?new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:new Date(e).getFullYear()!==new Date().getFullYear()?"numeric":void 0}):`${y(n)}${t?" ago":""}`},fe=e=>{let t=e?new Date(e):new Date;return t.toString()==="Invalid Date"?"":new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().split(":").slice(0,2).join(":")},he=e=>new Date(`${e}T00:00:00Z`).toLocaleDateString("en-US",{day:"numeric",month:"long",year:"numeric",timeZone:"UTC"}),de=e=>{let t=new Date,n=t.getDate(),o=t.getMonth(),r=t.getFullYear();if(n>=e)return{firstDay:new Date(r,o,e),lastDay:new Date(r,o+1,e-1)};{let s=o===0?r-1:r,a=o===0?11:o-1;return{firstDay:new Date(s,a,e),lastDay:new Date(r,o,e-1)}}},w=()=>{let e=new Date;return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()},b=e=>{let t=w();return e>t?t:e},ye=e=>{let t=new Date,n=t.getDate(),o=t.getMonth(),r=t.getFullYear(),s=b(e);if(n<=s){let a=o===0?11:o-1,f=o===0?r-1:r;return new Date(f,a,s)}else return new Date(r,o,s)},xe=e=>c.find(t=>{var n;return(n=t.price.ids)==null?void 0:n.includes(e)})||null,De=e=>{let t=h(e,{separator:""});if(t.length<3)return"";if(i.has(t.slice(-2)))return`${t.slice(0,-2)}.${t.slice(-2)}`;let n=t.replace(/[aeiou]/g,"");return n.length>=3&&i.has(n.slice(-2))?`${n.slice(0,-2)}.${n.slice(-2)}`:`${[t,n].reduce((r,s)=>r.length<s.length?r:s)}.to`},we=new RegExp(/^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/),be=new RegExp(/^[0-9A-Za-z\u0080-\uFFFF\/\-]*$/u),Se=new RegExp(/^[a-zA-Z0-9\-]+$/),Ue=(e,t)=>e===t?null:e.slice(0,e.length-t.length-1),Me=e=>{let t;try{t=new URL(e.replace(/^[a-zA-Z]+:\/\//,"https://")).hostname}catch{return""}if(t==="youtu.be")return"youtube.com";if(t==="raw.githubusercontent.com")return"github.com";if(t.endsWith(".vercel.app"))return"vercel.app";let n=t.split(".");return n.length>2?g.has(n[n.length-2])&&i.has(n[n.length-1])||p.has(n.slice(-2).join("."))?n.slice(-3).join("."):n.slice(-2).join("."):t},m=e=>{try{return new URL(e),!0}catch{return!1}},_e=e=>{if(m(e))return new URL(e).toString();try{if(e.includes(".")&&!e.includes(" "))return new URL(`https://${e}`).toString()}catch{return null}},Le=e=>{if(m(e))return new URL(e).hostname.replace(/^www\./,"");try{if(e.includes(".")&&!e.includes(" "))return new URL(`https://${e}`).hostname.replace(/^www\./,"")}catch{return null}},Re=e=>u.some(t=>t.slug===e),ke=e=>{let t={};return new URL(e).searchParams.forEach(function(n,o){t[o]=n}),t},ve=(e,t)=>!e||e.length<=t?e:`${e.slice(0,t-3)}...`,Ae=e=>{if(!e)return{};try{let t=new URL(e).searchParams,n={};for(let[o,r]of t.entries())r&&r!==""&&(n[o]=r);return n}catch{return{}}},Oe=(e,t)=>{if(!e)return"";try{let n=new URL(e);for(let[o,r]of Object.entries(t))r===""?n.searchParams.delete(o):n.searchParams.set(o,r);return n.toString()}catch{return""}},S=[{display:"Referral (ref)",key:"ref",examples:"twitter, facebook"},{display:"UTM Source",key:"utm_source",examples:"twitter, facebook"},{display:"UTM Medium",key:"utm_medium",examples:"social, email"},{display:"UTM Campaign",key:"utm_campaign",examples:"summer_sale"},{display:"UTM Term",key:"utm_term",examples:"blue_shoes"},{display:"UTM Content",key:"utm_content",examples:"logolink"}],Ee=e=>{try{let t=new URL(e);return S.forEach(n=>t.searchParams.delete(n.key)),t.toString()}catch{return e}};async function Te(e){let n=new TextEncoder().encode(e),o=await crypto.subtle.digest("MD5",n);return Array.from(new Uint8Array(o)).map(a=>a.toString(16).padStart(2,"0")).join("")}var U={cron:process.env.DUB_SLACK_HOOK_CRON,links:process.env.DUB_SLACK_HOOK_LINKS},$e=async({message:e,type:t,mention:n=!1})=>{(process.env.NODE_ENV==="development"||!process.env.DUB_SLACK_HOOK_CRON||!process.env.DUB_SLACK_HOOK_LINKS)&&console.log(e);let o=U[t];if(!!o)try{return await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({blocks:[{type:"section",text:{type:"mrkdwn",text:`${n?"<@U0404G6J3NJ> ":""}${e}`}}]})})}catch(r){console.log(`Failed to log to Dub Slack. Error: ${r}`)}},M=(e,t)=>{if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null)return!1;let n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(let r of n)if(!o.includes(r)||!M(e[r],t[r]))return!1;return!0};export{z as ADMIN_HOSTNAMES,W as ALL_TOOLS,I as API_DOMAIN,F as API_HOSTNAMES,P as APP_DOMAIN,C as APP_DOMAIN_WITH_NGROK,N as APP_HOSTNAMES,_ as COUNTRIES,J as DEFAULT_LINK_PROPS,K as DEFAULT_REDIRECTS,u as DUB_DOMAINS,B as DUB_HEADERS,H as DUB_LOGO,q as DUB_PROJECT_ID,Y as DUB_THUMBNAIL,E as FADE_IN_ANIMATION_SETTINGS,v as FRAMER_MOTION_LIST_ITEM_VARIANTS,j as GOOGLE_FAVICON_URL,Z as HIDE_BACKGROUND_SEGMENTS,l as HOME_DOMAIN,V as LEGAL_PROJECT_ID,G as LEGAL_USER_ID,R as LOCALHOST_GEO_DATA,k as LOCALHOST_IP,T as PAGINATION_LIMIT,c as PLANS,X as SAML_PROVIDERS,g as SECOND_LEVEL_DOMAINS,L as SELF_SERVE_PAID_PLANS,$ as SHORT_DOMAIN,p as SPECIAL_APEX_DOMAINS,A as STAGGER_CHILD_VARIANTS,O as SWIPE_REVEAL_ANIMATION_SETTINGS,ue as capitalize,i as ccTLDs,ge as chunk,se as cn,ae as constructMetadata,Oe as constructURLFromUTMParams,M as deepEqual,ce as fetcher,he as formatDate,De as generateDomainFromName,Te as generateMD5Hash,b as getAdjustedBillingCycleStart,Me as getApexDomain,ye as getBillingStartDate,fe as getDateTimeLocal,Le as getDomainWithoutWWW,de as getFirstAndLastDay,w as getLastDayOfMonth,Ae as getParamsFromURL,xe as getPlanFromPriceId,ke as getSearchParams,Ue as getSubdomain,_e as getUrlFromString,Ee as getUrlWithoutUTMParams,Re as isDubDomain,m as isValidUrl,pe as linkConstructor,$e as log,le as nFormatter,ie as nanoid,S as paramsMetadata,me as timeAgo,ve as truncate,we as validDomainRegex,be as validKeyRegex,Se as validSlugRegex};
1
+ import"./chunk-SPSUTBZ7.mjs";import{a as ho}from"./chunk-5PD4TPH7.mjs";import{a as io}from"./chunk-PEPVOMPB.mjs";import{a as jo}from"./chunk-FLUV3ASQ.mjs";import{a as ko}from"./chunk-KL7VCF4Y.mjs";import{a as lo}from"./chunk-I5Y5DKPK.mjs";import{a as no}from"./chunk-MPU6JRPV.mjs";import{a as qo}from"./chunk-ZJKRLIJQ.mjs";import{a as O,b as P,c as Q,d as R,e as S,f as T}from"./chunk-LXJVNY3R.mjs";import{a as U}from"./chunk-ZECUYKGD.mjs";import{a as oo,b as ro,c as eo,d as fo,e as mo,f as po,g as to,h as xo}from"./chunk-J6V4PKNC.mjs";import{a as V,b as W,c as X,d as Y,e as Z,f as _,g as $}from"./chunk-UUWTKITJ.mjs";import{a as ao}from"./chunk-EMO4MGOU.mjs";import{a as bo}from"./chunk-6XPTKHZD.mjs";import{a as co}from"./chunk-XWSEDYR7.mjs";import{a as go}from"./chunk-3BUV2ANI.mjs";import{a as K}from"./chunk-GTQBILTE.mjs";import{a as L}from"./chunk-2OJAP233.mjs";import{a as M}from"./chunk-NEIHTFSW.mjs";import{a as N}from"./chunk-C7CFYTBV.mjs";import{A as C,B as D,C as E,D as F,E as G,F as H,G as I,H as J,a as e,b as f,c as m,d as p,e as t,f as x,g as a,h as b,i as c,j as d,k as g,l as h,m as i,n as j,o as k,p as l,q as n,r as q,s,t as u,u as v,v as w,w as y,x as z,y as A,z as B}from"./chunk-F6C3QYRM.mjs";import{a as o}from"./chunk-YUMUNL66.mjs";import{a as r}from"./chunk-UBCCNLBS.mjs";export{s as ADMIN_HOSTNAMES,F as ALL_TOOLS,q as API_DOMAIN,n as API_HOSTNAMES,k as APP_DOMAIN,l as APP_DOMAIN_WITH_NGROK,j as APP_HOSTNAMES,r as COUNTRIES,I as DEFAULT_LINK_PROPS,u as DEFAULT_REDIRECTS,E as DUB_DOMAINS,v as DUB_HEADERS,y as DUB_LOGO,A as DUB_PROJECT_ID,z as DUB_THUMBNAIL,d as FADE_IN_ANIMATION_SETTINGS,a as FRAMER_MOTION_LIST_ITEM_VARIANTS,f as FREE_PLAN,p as FREE_PROJECTS_LIMIT,w as GOOGLE_FAVICON_URL,D as HIDE_BACKGROUND_SEGMENTS,i as HOME_DOMAIN,B as LEGAL_PROJECT_ID,C as LEGAL_USER_ID,t as LOCALHOST_GEO_DATA,x as LOCALHOST_IP,g as PAGINATION_LIMIT,e as PLANS,J as SAML_PROVIDERS,G as SECOND_LEVEL_DOMAINS,m as SELF_SERVE_PAID_PLANS,h as SHORT_DOMAIN,H as SPECIAL_APEX_DOMAINS,b as STAGGER_CHILD_VARIANTS,c as SWIPE_REVEAL_ANIMATION_SETTINGS,K as capitalize,o as ccTLDs,L as chunk,M as cn,N as constructMetadata,Z as constructURLFromUTMParams,U as deepEqual,ao as fetchWithTimeout,bo as fetcher,P as formatDate,oo as generateDomainFromName,co as generateMD5Hash,S as getAdjustedBillingCycleStart,po as getApexDomain,T as getBillingStartDate,O as getDateTimeLocal,to as getDomainWithoutWWW,Q as getFirstAndLastDay,R as getLastDayOfMonth,Y as getParamsFromURL,jo as getPlanFromPriceId,X as getSearchParams,mo as getSubdomain,W as getUrlFromString,$ as getUrlWithoutUTMParams,xo as isDubDomain,go as isIframeable,V as isValidUrl,ho as linkConstructor,io as log,lo as nFormatter,ko as nanoid,_ as paramsMetadata,no as timeAgo,qo as truncate,ro as validDomainRegex,eo as validKeyRegex,fo as validSlugRegex};
@@ -0,0 +1,6 @@
1
+ declare const isIframeable: ({ url, requestDomain, }: {
2
+ url: string;
3
+ requestDomain: string;
4
+ }) => Promise<boolean>;
5
+
6
+ export { isIframeable as i };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dub/utils",
3
3
  "description": "Utility functions and constants for Dub.co",
4
- "version": "0.0.26",
4
+ "version": "0.0.28",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",