@tinyhref/dynamic-link 1.0.0 → 1.0.1
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.
- package/dist/chunk-JR557W27.mjs +1 -0
- package/dist/chunk-LB45V7SR.mjs +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/sdk.d.mts +31 -0
- package/dist/sdk.d.ts +31 -0
- package/dist/sdk.js +1 -0
- package/dist/sdk.mjs +1 -0
- package/dist/types.d.mts +3 -1
- package/dist/types.d.ts +3 -1
- package/dist/types.js +1 -1
- package/dist/use-open-dynamic-link.mjs +1 -1
- package/package.json +7 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var d=Object.defineProperty;var e=(b,a,c)=>a in b?d(b,a,{enumerable:!0,configurable:!0,writable:!0,value:c}):b[a]=c;var f=(b,a,c)=>e(b,typeof a!="symbol"?a+"":a,c);export{f as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as n}from"./chunk-JR557W27.mjs";function c(s,i){if(!s)return null;i||(i=window.location.href);try{return new URL(i).searchParams.get(s)}catch{return null}}function d(s,i){let e=i==null?void 0:i.queryKey;if(i!=null&&i.isMainDomain){if(!s)return"";let l=`${s.replace(/\/+$/,"")}${window.location.pathname}${window.location.search}`;if(!e)return l;let o=new URL(l);return o.searchParams.delete(e),o.searchParams.delete("origin"),o.toString()}let t,r=i==null?void 0:i.targetUrl;return r?t=`${r}${r.includes("?")?"&":"?"}link=${encodeURIComponent(window.location.href)}`:s?t=`${s.replace(/\/+$/,"")}${window.location.pathname}${window.location.search}`:t=window.location.href,t.includes(`${e}=1`)?t:`${t}${t.includes("?")?"&":"?"}${e}=1&origin=${window.location.origin}`}var u=class u{constructor(i){n(this,"subdomainUrl");n(this,"appStoreUrl");n(this,"googlePlayUrl");n(this,"fallbackUrl");n(this,"originUrl");n(this,"userAgent");n(this,"platform");n(this,"timeout");n(this,"queryKey");n(this,"onOpenStore");var e;i&&((e=this.init)==null||e.call(this,i))}static instance(){return this.sdk||(this.sdk=new u),this.sdk}init({subdomainUrl:i,appStoreUrl:e,googlePlayUrl:t,fallbackUrl:r,originUrl:l,userAgent:o,platform:a={},timeout:f=100,queryKey:p="openStore",onOpenStore:g}){this.subdomainUrl=i,this.appStoreUrl=e,this.googlePlayUrl=t,this.fallbackUrl=r,this.userAgent=o,this.originUrl=l,this.platform=a,this.timeout=f,this.queryKey=p,this.onOpenStore=g}openStore(){var r,l,o,a;let i=(this==null?void 0:this.userAgent)||window.navigator.userAgent,e=this.fallbackUrl,t="";this.originUrl||(this.originUrl=c("origin")||""),(/iPhone|iPad|iPod/i.test(i)||(r=this.platform)!=null&&r.isIOS||(l=this.platform)!=null&&l.isIpad)&&(e=this.appStoreUrl,t=d(this.originUrl,{isMainDomain:!0,queryKey:this.queryKey})),(/Android/i.test(i)||(o=this.platform)!=null&&o.isAndroid)&&(e=this.googlePlayUrl,t=d(this.originUrl,{isMainDomain:!0,queryKey:this.queryKey})),t&&((a=this.onOpenStore)==null||a.call(this,{link:t})),e&&(window.location.href=e),t&&setTimeout(()=>{window.location.href=t},this.timeout)}openLink(i){window.location.href=d(this.subdomainUrl,{...i,queryKey:this.queryKey})}listener(){!!c(this.queryKey)&&this.openStore()}};n(u,"sdk");var h=u,y=h.instance(),w=y;export{c as a,d as b,y as c,w as d};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode, AnchorHTMLAttributes } from 'react';
|
|
3
3
|
export { default as useOpenDynamicLink } from './use-open-dynamic-link.mjs';
|
|
4
|
+
export { default as DynamicLinkSDK } from './sdk.mjs';
|
|
4
5
|
import { IProps } from './types.mjs';
|
|
5
6
|
|
|
6
7
|
interface DynamicLinkProps extends IProps {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode, AnchorHTMLAttributes } from 'react';
|
|
3
3
|
export { default as useOpenDynamicLink } from './use-open-dynamic-link.js';
|
|
4
|
+
export { default as DynamicLinkSDK } from './sdk.js';
|
|
4
5
|
import { IProps } from './types.js';
|
|
5
6
|
|
|
6
7
|
interface DynamicLinkProps extends IProps {
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var y=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var q=(i,e,t)=>e in i?y(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var v=(i,e)=>{for(var t in e)y(i,t,{get:e[t],enumerable:!0})},M=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of D(e))!b.call(i,r)&&r!==t&&y(i,r,{get:()=>e[r],enumerable:!(n=A(e,r))||n.enumerable});return i};var x=i=>M(y({},"__esModule",{value:!0}),i);var a=(i,e,t)=>q(i,typeof e!="symbol"?e+"":e,t);var N={};v(N,{DynamicLinkSDK:()=>S,default:()=>T,useOpenDynamicLink:()=>m});module.exports=x(N);var c=require("react");function O(i,e){e||(e=window.location.href);try{return new URL(e).searchParams.get(i)}catch{return null}}function w(i,e){let t=e==null?void 0:e.queryKey;if(e!=null&&e.isMainDomain){if(!i)return"";let o=`${i.replace(/\/+$/,"")}${window.location.pathname}${window.location.search}`;if(!t)return o;let s=new URL(o);return s.searchParams.delete(t),s.searchParams.delete("origin"),s.toString()}let n,r=e==null?void 0:e.targetUrl;return r?n=`${r}${r.includes("?")?"&":"?"}link=${encodeURIComponent(window.location.href)}`:i?n=`${i.replace(/\/+$/,"")}${window.location.pathname}${window.location.search}`:n=window.location.href,n.includes(`${t}=1`)?n:`${n}${n.includes("?")?"&":"?"}${t}=1&origin=${window.location.origin}`}var m=i=>{let{subdomainUrl:e,appStoreUrl:t,googlePlayUrl:n,fallbackUrl:r,platform:o={},timeout:s=100,queryKey:l="openStore",onOpenStore:h}=i,u=i==null?void 0:i.originUrl,U=(0,c.useCallback)(g=>{let d=w(e,{...g,queryKey:l});window.open(d)},[e,l]),k=(0,c.useCallback)(()=>{let g=(i==null?void 0:i.userAgent)||window.navigator.userAgent,d=r,f="";u||(u=O("origin")||""),(/iPhone|iPad|iPod/i.test(g)||o!=null&&o.isIOS||o!=null&&o.isIpad)&&(d=t,f=w(u,{isMainDomain:!0,queryKey:l})),(/Android/i.test(g)||o!=null&&o.isAndroid)&&(d=n,f=w(u,{isMainDomain:!0,queryKey:l})),f&&(h==null||h({link:f})),d&&(window.location.href=d),f&&setTimeout(()=>{window.location.href=f},s)},[l]),I=(0,c.useMemo)(()=>!!O(l),[l]);return(0,c.useEffect)(()=>{I&&k()},[I]),{link:w(e,{queryKey:l}),openDynamicLink:U,openStore:k}};function L(i,e){if(!i)return null;e||(e=window.location.href);try{return new URL(e).searchParams.get(i)}catch{return null}}function P(i,e){let t=e==null?void 0:e.queryKey;if(e!=null&&e.isMainDomain){if(!i)return"";let o=`${i.replace(/\/+$/,"")}${window.location.pathname}${window.location.search}`;if(!t)return o;let s=new URL(o);return s.searchParams.delete(t),s.searchParams.delete("origin"),s.toString()}let n,r=e==null?void 0:e.targetUrl;return r?n=`${r}${r.includes("?")?"&":"?"}link=${encodeURIComponent(window.location.href)}`:i?n=`${i.replace(/\/+$/,"")}${window.location.pathname}${window.location.search}`:n=window.location.href,n.includes(`${t}=1`)?n:`${n}${n.includes("?")?"&":"?"}${t}=1&origin=${window.location.origin}`}var p=class p{constructor(e){a(this,"subdomainUrl");a(this,"appStoreUrl");a(this,"googlePlayUrl");a(this,"fallbackUrl");a(this,"originUrl");a(this,"userAgent");a(this,"platform");a(this,"timeout");a(this,"queryKey");a(this,"onOpenStore");var t;e&&((t=this.init)==null||t.call(this,e))}static instance(){return this.sdk||(this.sdk=new p),this.sdk}init({subdomainUrl:e,appStoreUrl:t,googlePlayUrl:n,fallbackUrl:r,originUrl:o,userAgent:s,platform:l={},timeout:h=100,queryKey:u="openStore",onOpenStore:U}){this.subdomainUrl=e,this.appStoreUrl=t,this.googlePlayUrl=n,this.fallbackUrl=r,this.userAgent=s,this.originUrl=o,this.platform=l,this.timeout=h,this.queryKey=u,this.onOpenStore=U}openStore(){var r,o,s,l;let e=(this==null?void 0:this.userAgent)||window.navigator.userAgent,t=this.fallbackUrl,n="";this.originUrl||(this.originUrl=L("origin")||""),(/iPhone|iPad|iPod/i.test(e)||(r=this.platform)!=null&&r.isIOS||(o=this.platform)!=null&&o.isIpad)&&(t=this.appStoreUrl,n=P(this.originUrl,{isMainDomain:!0,queryKey:this.queryKey})),(/Android/i.test(e)||(s=this.platform)!=null&&s.isAndroid)&&(t=this.googlePlayUrl,n=P(this.originUrl,{isMainDomain:!0,queryKey:this.queryKey})),n&&((l=this.onOpenStore)==null||l.call(this,{link:n})),t&&(window.location.href=t),n&&setTimeout(()=>{window.location.href=n},this.timeout)}openLink(e){window.location.href=P(this.subdomainUrl,{...e,queryKey:this.queryKey})}listener(){!!L(this.queryKey)&&this.openStore()}};a(p,"sdk");var $=p,S=$.instance();var K=require("react/jsx-runtime");var R=i=>{let{children:e,className:t,htmlProps:n,...r}=i,{link:o}=m(r);return(0,K.jsx)("a",{...n,className:t,href:o,children:e})},T=R;0&&(module.exports={DynamicLinkSDK,useOpenDynamicLink});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as
|
|
1
|
+
import{c}from"./chunk-LB45V7SR.mjs";import{b as r}from"./chunk-ADVPAVLF.mjs";import"./chunk-JR557W27.mjs";import{jsx as p}from"react/jsx-runtime";var m=t=>{let{children:e,className:o,htmlProps:n,...s}=t,{link:i}=r(s);return p("a",{...n,className:o,href:i,children:e})},h=m;export{c as DynamicLinkSDK,h as default,r as useOpenDynamicLink};
|
package/dist/sdk.d.mts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { IOptions } from './types.mjs';
|
|
2
|
+
|
|
3
|
+
interface IParams {
|
|
4
|
+
targetUrl?: string;
|
|
5
|
+
isMainDomain?: boolean;
|
|
6
|
+
queryKey?: string;
|
|
7
|
+
}
|
|
8
|
+
declare function getQueryParam(key: string | undefined, url?: string): string | null;
|
|
9
|
+
declare function getLink(domainUrl: string | undefined, params?: IParams): string;
|
|
10
|
+
declare class DynamicLinkClass {
|
|
11
|
+
private static sdk;
|
|
12
|
+
private subdomainUrl;
|
|
13
|
+
private appStoreUrl;
|
|
14
|
+
private googlePlayUrl;
|
|
15
|
+
private fallbackUrl;
|
|
16
|
+
private originUrl;
|
|
17
|
+
private userAgent;
|
|
18
|
+
private platform;
|
|
19
|
+
private timeout;
|
|
20
|
+
private queryKey;
|
|
21
|
+
private onOpenStore;
|
|
22
|
+
static instance(): DynamicLinkClass;
|
|
23
|
+
constructor(opts?: IOptions);
|
|
24
|
+
init({ subdomainUrl, appStoreUrl, googlePlayUrl, fallbackUrl, originUrl, userAgent, platform, timeout, queryKey, onOpenStore }: IOptions): void;
|
|
25
|
+
openStore(): void;
|
|
26
|
+
openLink(params: IParams): void;
|
|
27
|
+
listener(): void;
|
|
28
|
+
}
|
|
29
|
+
declare const DynamicLinkSDK: DynamicLinkClass;
|
|
30
|
+
|
|
31
|
+
export { DynamicLinkSDK, DynamicLinkSDK as default, getLink, getQueryParam };
|
package/dist/sdk.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { IOptions } from './types.js';
|
|
2
|
+
|
|
3
|
+
interface IParams {
|
|
4
|
+
targetUrl?: string;
|
|
5
|
+
isMainDomain?: boolean;
|
|
6
|
+
queryKey?: string;
|
|
7
|
+
}
|
|
8
|
+
declare function getQueryParam(key: string | undefined, url?: string): string | null;
|
|
9
|
+
declare function getLink(domainUrl: string | undefined, params?: IParams): string;
|
|
10
|
+
declare class DynamicLinkClass {
|
|
11
|
+
private static sdk;
|
|
12
|
+
private subdomainUrl;
|
|
13
|
+
private appStoreUrl;
|
|
14
|
+
private googlePlayUrl;
|
|
15
|
+
private fallbackUrl;
|
|
16
|
+
private originUrl;
|
|
17
|
+
private userAgent;
|
|
18
|
+
private platform;
|
|
19
|
+
private timeout;
|
|
20
|
+
private queryKey;
|
|
21
|
+
private onOpenStore;
|
|
22
|
+
static instance(): DynamicLinkClass;
|
|
23
|
+
constructor(opts?: IOptions);
|
|
24
|
+
init({ subdomainUrl, appStoreUrl, googlePlayUrl, fallbackUrl, originUrl, userAgent, platform, timeout, queryKey, onOpenStore }: IOptions): void;
|
|
25
|
+
openStore(): void;
|
|
26
|
+
openLink(params: IParams): void;
|
|
27
|
+
listener(): void;
|
|
28
|
+
}
|
|
29
|
+
declare const DynamicLinkSDK: DynamicLinkClass;
|
|
30
|
+
|
|
31
|
+
export { DynamicLinkSDK, DynamicLinkSDK as default, getLink, getQueryParam };
|
package/dist/sdk.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var u=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var S=(e,i,t)=>i in e?u(e,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[i]=t;var $=(e,i)=>{for(var t in i)u(e,t,{get:i[t],enumerable:!0})},m=(e,i,t,n)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of O(i))!I.call(e,r)&&r!==t&&u(e,r,{get:()=>i[r],enumerable:!(n=U(i,r))||n.enumerable});return e};var K=e=>m(u({},"__esModule",{value:!0}),e);var o=(e,i,t)=>S(e,typeof i!="symbol"?i+"":i,t);var k={};$(k,{DynamicLinkSDK:()=>p,default:()=>P,getLink:()=>d,getQueryParam:()=>c});module.exports=K(k);function c(e,i){if(!e)return null;i||(i=window.location.href);try{return new URL(i).searchParams.get(e)}catch{return null}}function d(e,i){let t=i==null?void 0:i.queryKey;if(i!=null&&i.isMainDomain){if(!e)return"";let l=`${e.replace(/\/+$/,"")}${window.location.pathname}${window.location.search}`;if(!t)return l;let s=new URL(l);return s.searchParams.delete(t),s.searchParams.delete("origin"),s.toString()}let n,r=i==null?void 0:i.targetUrl;return r?n=`${r}${r.includes("?")?"&":"?"}link=${encodeURIComponent(window.location.href)}`:e?n=`${e.replace(/\/+$/,"")}${window.location.pathname}${window.location.search}`:n=window.location.href,n.includes(`${t}=1`)?n:`${n}${n.includes("?")?"&":"?"}${t}=1&origin=${window.location.origin}`}var h=class h{constructor(i){o(this,"subdomainUrl");o(this,"appStoreUrl");o(this,"googlePlayUrl");o(this,"fallbackUrl");o(this,"originUrl");o(this,"userAgent");o(this,"platform");o(this,"timeout");o(this,"queryKey");o(this,"onOpenStore");var t;i&&((t=this.init)==null||t.call(this,i))}static instance(){return this.sdk||(this.sdk=new h),this.sdk}init({subdomainUrl:i,appStoreUrl:t,googlePlayUrl:n,fallbackUrl:r,originUrl:l,userAgent:s,platform:a={},timeout:g=100,queryKey:y="openStore",onOpenStore:w}){this.subdomainUrl=i,this.appStoreUrl=t,this.googlePlayUrl=n,this.fallbackUrl=r,this.userAgent=s,this.originUrl=l,this.platform=a,this.timeout=g,this.queryKey=y,this.onOpenStore=w}openStore(){var r,l,s,a;let i=(this==null?void 0:this.userAgent)||window.navigator.userAgent,t=this.fallbackUrl,n="";this.originUrl||(this.originUrl=c("origin")||""),(/iPhone|iPad|iPod/i.test(i)||(r=this.platform)!=null&&r.isIOS||(l=this.platform)!=null&&l.isIpad)&&(t=this.appStoreUrl,n=d(this.originUrl,{isMainDomain:!0,queryKey:this.queryKey})),(/Android/i.test(i)||(s=this.platform)!=null&&s.isAndroid)&&(t=this.googlePlayUrl,n=d(this.originUrl,{isMainDomain:!0,queryKey:this.queryKey})),n&&((a=this.onOpenStore)==null||a.call(this,{link:n})),t&&(window.location.href=t),n&&setTimeout(()=>{window.location.href=n},this.timeout)}openLink(i){window.location.href=d(this.subdomainUrl,{...i,queryKey:this.queryKey})}listener(){!!c(this.queryKey)&&this.openStore()}};o(h,"sdk");var f=h,p=f.instance(),P=p;0&&(module.exports={DynamicLinkSDK,getLink,getQueryParam});
|
package/dist/sdk.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d}from"./chunk-LB45V7SR.mjs";import"./chunk-JR557W27.mjs";export{c as DynamicLinkSDK,d as default,b as getLink,a as getQueryParam};
|
package/dist/types.d.mts
CHANGED
package/dist/types.d.ts
CHANGED
package/dist/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=Object.defineProperty;var
|
|
1
|
+
"use strict";var t=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var g=(o,r,i,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of a(r))!l.call(o,e)&&e!==i&&t(o,e,{get:()=>r[e],enumerable:!(n=s(r,e))||n.enumerable});return o};var p=o=>g(t({},"__esModule",{value:!0}),o);var f={};module.exports=p(f);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c}from"./chunk-ADVPAVLF.mjs";export{c as default,a as getLink,b as useOpenDynamicLink};
|
|
1
|
+
import{a,b,c}from"./chunk-ADVPAVLF.mjs";import"./chunk-JR557W27.mjs";export{c as default,a as getLink,b as useOpenDynamicLink};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinyhref/dynamic-link",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "DynamicLink is a lightweight, Firebase-free alternative for handling dynamic links and deep links in web and mobile hybrid environments",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dynamic-link",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"react": ">=18"
|
|
48
48
|
},
|
|
49
49
|
"clean-package": "./clean-package.config.json",
|
|
50
|
+
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",
|
|
50
51
|
"module": "dist/index.mjs",
|
|
51
52
|
"types": "dist/index.d.ts",
|
|
52
53
|
"exports": {
|
|
@@ -60,6 +61,11 @@
|
|
|
60
61
|
"import": "./dist/use-open-dynamic-link.mjs",
|
|
61
62
|
"require": "./dist/use-open-dynamic-link.js"
|
|
62
63
|
},
|
|
64
|
+
"./sdk": {
|
|
65
|
+
"types": "./dist/sdk.d.ts",
|
|
66
|
+
"import": "./dist/sdk.mjs",
|
|
67
|
+
"require": "./dist/sdk.js"
|
|
68
|
+
},
|
|
63
69
|
"./package.json": "./package.json"
|
|
64
70
|
}
|
|
65
71
|
}
|