universal-app-opener 0.1.0
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/index.d.mts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +75 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +49 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +42 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface DeepLinkResult {
|
|
2
|
+
webUrl: string;
|
|
3
|
+
ios: string | null;
|
|
4
|
+
android: string | null;
|
|
5
|
+
platform: 'youtube' | 'linkedin' | 'unknown';
|
|
6
|
+
}
|
|
7
|
+
declare function generateDeepLink(url: string): DeepLinkResult;
|
|
8
|
+
declare function detectOS(): 'ios' | 'android' | 'desktop';
|
|
9
|
+
|
|
10
|
+
export { type DeepLinkResult, detectOS, generateDeepLink };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface DeepLinkResult {
|
|
2
|
+
webUrl: string;
|
|
3
|
+
ios: string | null;
|
|
4
|
+
android: string | null;
|
|
5
|
+
platform: 'youtube' | 'linkedin' | 'unknown';
|
|
6
|
+
}
|
|
7
|
+
declare function generateDeepLink(url: string): DeepLinkResult;
|
|
8
|
+
declare function detectOS(): 'ios' | 'android' | 'desktop';
|
|
9
|
+
|
|
10
|
+
export { type DeepLinkResult, detectOS, generateDeepLink };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
detectOS: () => detectOS,
|
|
24
|
+
generateDeepLink: () => generateDeepLink
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
function generateDeepLink(url) {
|
|
28
|
+
const webUrl = url.trim();
|
|
29
|
+
const youtubeWatchMatch = webUrl.match(/youtube\.com\/watch\?v=([^&]+)/);
|
|
30
|
+
const youtubeShortMatch = webUrl.match(/youtu\.be\/([^?]+)/);
|
|
31
|
+
if (youtubeWatchMatch || youtubeShortMatch) {
|
|
32
|
+
const videoId = youtubeWatchMatch ? youtubeWatchMatch[1] : youtubeShortMatch[1];
|
|
33
|
+
return {
|
|
34
|
+
webUrl,
|
|
35
|
+
ios: `vnd.youtube://watch?v=${videoId}`,
|
|
36
|
+
android: `intent://watch?v=${videoId}#Intent;scheme=vnd.youtube;package=com.google.android.youtube;end`,
|
|
37
|
+
platform: "youtube"
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const linkedinMatch = webUrl.match(/linkedin\.com\/in\/([^/?]+)/);
|
|
41
|
+
if (linkedinMatch) {
|
|
42
|
+
const profileId = linkedinMatch[1];
|
|
43
|
+
return {
|
|
44
|
+
webUrl,
|
|
45
|
+
ios: `linkedin://in/${profileId}`,
|
|
46
|
+
android: `intent://in/${profileId}#Intent;scheme=linkedin;package=com.linkedin.android;end`,
|
|
47
|
+
platform: "linkedin"
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
webUrl,
|
|
52
|
+
ios: null,
|
|
53
|
+
android: null,
|
|
54
|
+
platform: "unknown"
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function detectOS() {
|
|
58
|
+
if (typeof window === "undefined") {
|
|
59
|
+
return "desktop";
|
|
60
|
+
}
|
|
61
|
+
const userAgent = window.navigator.userAgent.toLowerCase();
|
|
62
|
+
if (/iphone|ipad|ipod/.test(userAgent)) {
|
|
63
|
+
return "ios";
|
|
64
|
+
}
|
|
65
|
+
if (/android/.test(userAgent)) {
|
|
66
|
+
return "android";
|
|
67
|
+
}
|
|
68
|
+
return "desktop";
|
|
69
|
+
}
|
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
+
0 && (module.exports = {
|
|
72
|
+
detectOS,
|
|
73
|
+
generateDeepLink
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export interface DeepLinkResult {\n webUrl: string;\n ios: string | null;\n android: string | null;\n platform: 'youtube' | 'linkedin' | 'unknown';\n}\n\nexport function generateDeepLink(url: string): DeepLinkResult {\n const webUrl = url.trim();\n \n const youtubeWatchMatch = webUrl.match(/youtube\\.com\\/watch\\?v=([^&]+)/);\n const youtubeShortMatch = webUrl.match(/youtu\\.be\\/([^?]+)/);\n \n if (youtubeWatchMatch || youtubeShortMatch) {\n const videoId = youtubeWatchMatch ? youtubeWatchMatch[1] : youtubeShortMatch![1];\n return {\n webUrl,\n ios: `vnd.youtube://watch?v=${videoId}`,\n android: `intent://watch?v=${videoId}#Intent;scheme=vnd.youtube;package=com.google.android.youtube;end`,\n platform: 'youtube'\n };\n }\n \n const linkedinMatch = webUrl.match(/linkedin\\.com\\/in\\/([^/?]+)/);\n if (linkedinMatch) {\n const profileId = linkedinMatch[1];\n return {\n webUrl,\n ios: `linkedin://in/${profileId}`,\n android: `intent://in/${profileId}#Intent;scheme=linkedin;package=com.linkedin.android;end`,\n platform: 'linkedin'\n };\n }\n \n return {\n webUrl,\n ios: null,\n android: null,\n platform: 'unknown'\n };\n}\n\nexport function detectOS(): 'ios' | 'android' | 'desktop' {\n if (typeof window === 'undefined') {\n return 'desktop';\n }\n \n const userAgent = window.navigator.userAgent.toLowerCase();\n \n if (/iphone|ipad|ipod/.test(userAgent)) {\n return 'ios';\n }\n \n if (/android/.test(userAgent)) {\n return 'android';\n }\n \n return 'desktop';\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,SAAS,iBAAiB,KAA6B;AAC5D,QAAM,SAAS,IAAI,KAAK;AAExB,QAAM,oBAAoB,OAAO,MAAM,gCAAgC;AACvE,QAAM,oBAAoB,OAAO,MAAM,oBAAoB;AAE3D,MAAI,qBAAqB,mBAAmB;AAC1C,UAAM,UAAU,oBAAoB,kBAAkB,CAAC,IAAI,kBAAmB,CAAC;AAC/E,WAAO;AAAA,MACL;AAAA,MACA,KAAK,yBAAyB,OAAO;AAAA,MACrC,SAAS,oBAAoB,OAAO;AAAA,MACpC,UAAU;AAAA,IACZ;AAAA,EACF;AAEA,QAAM,gBAAgB,OAAO,MAAM,6BAA6B;AAChE,MAAI,eAAe;AACjB,UAAM,YAAY,cAAc,CAAC;AACjC,WAAO;AAAA,MACL;AAAA,MACA,KAAK,iBAAiB,SAAS;AAAA,MAC/B,SAAS,eAAe,SAAS;AAAA,MACjC,UAAU;AAAA,IACZ;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA,KAAK;AAAA,IACL,SAAS;AAAA,IACT,UAAU;AAAA,EACZ;AACF;AAEO,SAAS,WAA0C;AACxD,MAAI,OAAO,WAAW,aAAa;AACjC,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,OAAO,UAAU,UAAU,YAAY;AAEzD,MAAI,mBAAmB,KAAK,SAAS,GAAG;AACtC,WAAO;AAAA,EACT;AAEA,MAAI,UAAU,KAAK,SAAS,GAAG;AAC7B,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
function generateDeepLink(url) {
|
|
3
|
+
const webUrl = url.trim();
|
|
4
|
+
const youtubeWatchMatch = webUrl.match(/youtube\.com\/watch\?v=([^&]+)/);
|
|
5
|
+
const youtubeShortMatch = webUrl.match(/youtu\.be\/([^?]+)/);
|
|
6
|
+
if (youtubeWatchMatch || youtubeShortMatch) {
|
|
7
|
+
const videoId = youtubeWatchMatch ? youtubeWatchMatch[1] : youtubeShortMatch[1];
|
|
8
|
+
return {
|
|
9
|
+
webUrl,
|
|
10
|
+
ios: `vnd.youtube://watch?v=${videoId}`,
|
|
11
|
+
android: `intent://watch?v=${videoId}#Intent;scheme=vnd.youtube;package=com.google.android.youtube;end`,
|
|
12
|
+
platform: "youtube"
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
const linkedinMatch = webUrl.match(/linkedin\.com\/in\/([^/?]+)/);
|
|
16
|
+
if (linkedinMatch) {
|
|
17
|
+
const profileId = linkedinMatch[1];
|
|
18
|
+
return {
|
|
19
|
+
webUrl,
|
|
20
|
+
ios: `linkedin://in/${profileId}`,
|
|
21
|
+
android: `intent://in/${profileId}#Intent;scheme=linkedin;package=com.linkedin.android;end`,
|
|
22
|
+
platform: "linkedin"
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
webUrl,
|
|
27
|
+
ios: null,
|
|
28
|
+
android: null,
|
|
29
|
+
platform: "unknown"
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function detectOS() {
|
|
33
|
+
if (typeof window === "undefined") {
|
|
34
|
+
return "desktop";
|
|
35
|
+
}
|
|
36
|
+
const userAgent = window.navigator.userAgent.toLowerCase();
|
|
37
|
+
if (/iphone|ipad|ipod/.test(userAgent)) {
|
|
38
|
+
return "ios";
|
|
39
|
+
}
|
|
40
|
+
if (/android/.test(userAgent)) {
|
|
41
|
+
return "android";
|
|
42
|
+
}
|
|
43
|
+
return "desktop";
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
detectOS,
|
|
47
|
+
generateDeepLink
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export interface DeepLinkResult {\n webUrl: string;\n ios: string | null;\n android: string | null;\n platform: 'youtube' | 'linkedin' | 'unknown';\n}\n\nexport function generateDeepLink(url: string): DeepLinkResult {\n const webUrl = url.trim();\n \n const youtubeWatchMatch = webUrl.match(/youtube\\.com\\/watch\\?v=([^&]+)/);\n const youtubeShortMatch = webUrl.match(/youtu\\.be\\/([^?]+)/);\n \n if (youtubeWatchMatch || youtubeShortMatch) {\n const videoId = youtubeWatchMatch ? youtubeWatchMatch[1] : youtubeShortMatch![1];\n return {\n webUrl,\n ios: `vnd.youtube://watch?v=${videoId}`,\n android: `intent://watch?v=${videoId}#Intent;scheme=vnd.youtube;package=com.google.android.youtube;end`,\n platform: 'youtube'\n };\n }\n \n const linkedinMatch = webUrl.match(/linkedin\\.com\\/in\\/([^/?]+)/);\n if (linkedinMatch) {\n const profileId = linkedinMatch[1];\n return {\n webUrl,\n ios: `linkedin://in/${profileId}`,\n android: `intent://in/${profileId}#Intent;scheme=linkedin;package=com.linkedin.android;end`,\n platform: 'linkedin'\n };\n }\n \n return {\n webUrl,\n ios: null,\n android: null,\n platform: 'unknown'\n };\n}\n\nexport function detectOS(): 'ios' | 'android' | 'desktop' {\n if (typeof window === 'undefined') {\n return 'desktop';\n }\n \n const userAgent = window.navigator.userAgent.toLowerCase();\n \n if (/iphone|ipad|ipod/.test(userAgent)) {\n return 'ios';\n }\n \n if (/android/.test(userAgent)) {\n return 'android';\n }\n \n return 'desktop';\n}\n\n"],"mappings":";AAOO,SAAS,iBAAiB,KAA6B;AAC5D,QAAM,SAAS,IAAI,KAAK;AAExB,QAAM,oBAAoB,OAAO,MAAM,gCAAgC;AACvE,QAAM,oBAAoB,OAAO,MAAM,oBAAoB;AAE3D,MAAI,qBAAqB,mBAAmB;AAC1C,UAAM,UAAU,oBAAoB,kBAAkB,CAAC,IAAI,kBAAmB,CAAC;AAC/E,WAAO;AAAA,MACL;AAAA,MACA,KAAK,yBAAyB,OAAO;AAAA,MACrC,SAAS,oBAAoB,OAAO;AAAA,MACpC,UAAU;AAAA,IACZ;AAAA,EACF;AAEA,QAAM,gBAAgB,OAAO,MAAM,6BAA6B;AAChE,MAAI,eAAe;AACjB,UAAM,YAAY,cAAc,CAAC;AACjC,WAAO;AAAA,MACL;AAAA,MACA,KAAK,iBAAiB,SAAS;AAAA,MAC/B,SAAS,eAAe,SAAS;AAAA,MACjC,UAAU;AAAA,IACZ;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA,KAAK;AAAA,IACL,SAAS;AAAA,IACT,UAAU;AAAA,EACZ;AACF;AAEO,SAAS,WAA0C;AACxD,MAAI,OAAO,WAAW,aAAa;AACjC,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,OAAO,UAAU,UAAU,YAAY;AAEzD,MAAI,mBAAmB,KAAK,SAAS,GAAG;AACtC,WAAO;AAAA,EACT;AAEA,MAAI,UAAU,KAAK,SAAS,GAAG;AAC7B,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "universal-app-opener",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A zero-dependency library to generate deep links from HTTP URLs",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"require": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsup",
|
|
21
|
+
"dev": "tsup --watch",
|
|
22
|
+
"prepublishOnly": "pnpm build"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"deep-link",
|
|
26
|
+
"mobile",
|
|
27
|
+
"youtube",
|
|
28
|
+
"linkedin",
|
|
29
|
+
"ios",
|
|
30
|
+
"android",
|
|
31
|
+
"url-converter",
|
|
32
|
+
"native-app"
|
|
33
|
+
],
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/mdsaban/universal-app-opener.git"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"tsup": "^8.0.0",
|
|
40
|
+
"typescript": "^5.3.0"
|
|
41
|
+
}
|
|
42
|
+
}
|