@collabchron/notiq 1.1.11 → 1.2.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/AICommandBarPlugin-ZEC755KY.mjs +27 -0
- package/dist/{AIDialog-2WZUFWSC.mjs → AIDialog-HJW6PQPR.mjs} +12 -13
- package/dist/{AudioComponent-CKLMLB5T.mjs → AudioComponent-W5XMZPQB.mjs} +10 -6
- package/dist/{DynamicBlockComponent-2LOADZUX.mjs → DynamicBlockComponent-CHRL2GAQ.mjs} +7 -6
- package/dist/{EquationComponent-4NFG55NQ.mjs → EquationComponent-GNQHG53L.mjs} +26 -7
- package/dist/{ExcalidrawComponent-SIMURTCA.mjs → ExcalidrawComponent-POMYXDSG.mjs} +34 -7
- package/dist/{FileComponent-Y56MX5QD.mjs → FileComponent-EOVCH4V5.mjs} +9 -5
- package/dist/{HintComponet-ET7M2Q7S.mjs → HintComponet-QXL5ESND.mjs} +32 -8
- package/dist/{InlineImageComponent-FVTA4LXZ.mjs → InlineImageComponent-KDN3VGZC.mjs} +8 -3
- package/dist/{StoryBuilderComponent-WQSNFPMM.mjs → StoryBuilderComponent-CBRFPFTR.mjs} +9 -10
- package/dist/{chunk-6UVNHT3T.mjs → chunk-4SYRK2NH.mjs} +23 -1
- package/dist/chunk-5CJZC5IB.mjs +9086 -0
- package/dist/{chunk-MW6MAUY3.mjs → chunk-6NK5DONB.mjs} +1 -1
- package/dist/{chunk-N6ILV6NF.mjs → chunk-ACW4DLVO.mjs} +21 -7
- package/dist/chunk-BCGD2YXP.mjs +574 -0
- package/dist/{chunk-TC3IISJZ.mjs → chunk-BTR3TPIN.mjs} +18 -5
- package/dist/{chunk-XAVQAXOJ.mjs → chunk-CQCS5YPS.mjs} +3 -5
- package/dist/{chunk-YTLUQJE2.mjs → chunk-D4UBNSUW.mjs} +1 -1
- package/dist/{chunk-KNW2CGIP.mjs → chunk-DBRZIA43.mjs} +4 -1
- package/dist/{chunk-CDAMHK63.mjs → chunk-GJK2L7ZM.mjs} +23 -2
- package/dist/{chunk-GYYLZ3MQ.mjs → chunk-IKYVBTCJ.mjs} +43 -20
- package/dist/chunk-IXRA5D53.mjs +10447 -0
- package/dist/{chunk-W6VQSFE5.mjs → chunk-J2CEQXG4.mjs} +1 -1
- package/dist/{chunk-43Z4Z2KD.mjs → chunk-JTNLN4JI.mjs} +1 -1
- package/dist/{chunk-OE5JRLCN.mjs → chunk-ONOHG5NB.mjs} +6 -4
- package/dist/{chunk-XZXGYNTY.mjs → chunk-OO42URWA.mjs} +27 -6
- package/dist/chunk-PBVRSNGU.mjs +129 -0
- package/dist/chunk-QCS57TIF.mjs +1794 -0
- package/dist/chunk-RNEIJRUS.mjs +60 -0
- package/dist/chunk-TJPTGECP.mjs +1556 -0
- package/dist/{chunk-XYMXGU4T.mjs → chunk-TMYRA2W4.mjs} +1 -1
- package/dist/{chunk-ZFV2HGD3.mjs → chunk-UNEFOZTS.mjs} +1 -1
- package/dist/chunk-X4NI7EQS.mjs +282 -0
- package/dist/chunk-XAJ4GACN.mjs +746 -0
- package/dist/{chunk-7QRJVZQY.mjs → chunk-YVUQRJVV.mjs} +63 -18
- package/dist/components/editor/Core.d.ts +15 -2
- package/dist/components/editor/index.d.ts +16 -5
- package/dist/components/editor/nodes/EquationNode/EquationNode.d.ts +1 -0
- package/dist/components/editor/nodes/Hint/index.d.ts +2 -1
- package/dist/components/editor/plugins/AICommandBarPlugin/index.d.ts +73 -1
- package/dist/components/editor/plugins/DraggableBlockPlugin/index.d.ts +25 -3
- package/dist/components/editor/plugins/InlineCopilotPlugin/index.d.ts +16 -3
- package/dist/components/editor/plugins/LinkWithMetaData/index.d.ts +20 -25
- package/dist/components/editor/plugins/MarkdownPastePlugin/index.d.ts +5 -0
- package/dist/components/editor/plugins/MarkdownTransformers/index.d.ts +2 -0
- package/dist/components/editor/plugins/SlashCommand/index.d.ts +18 -1
- package/dist/components/editor/plugins/SmartTypographyPlugin/index.d.ts +26 -0
- package/dist/components/editor/utils/aiStream.d.ts +27 -0
- package/dist/components/editor/utils/excalidrawDiagramBuilder.d.ts +29 -0
- package/dist/components/editor/utils/markdownTransformers.d.ts +4 -1
- package/dist/components/editor/utils/url.d.ts +16 -4
- package/dist/components/providers/AIContext.d.ts +8 -0
- package/dist/components/ui/equation/equationTypography.d.ts +23 -0
- package/dist/core/extension.d.ts +3 -1
- package/dist/core/extensions/blocks-kit.d.ts +22 -1
- package/dist/core/extensions/copilot-and-collab.d.ts +15 -1
- package/dist/core/index.d.ts +2 -1
- package/dist/core/react/NotiqContent.d.ts +4 -1
- package/dist/core/react/NotiqEditor.d.ts +8 -8
- package/dist/core/react/index.d.ts +1 -0
- package/dist/core/react/node-renderers.d.ts +73 -0
- package/dist/core/types.d.ts +1 -0
- package/dist/core.js +18136 -9084
- package/dist/core.mjs +58 -44
- package/dist/hooks/instructions-messages.d.ts +13 -4
- package/dist/{image-TPW7PZZK.mjs → image-AL6PHM2A.mjs} +18 -13
- package/dist/index.js +15180 -12858
- package/dist/index.mjs +121 -1641
- package/dist/{insert-audio-C66RZRKY.mjs → insert-audio-CRWR7EO5.mjs} +6 -8
- package/dist/{insert-file-3DTGRO7W.mjs → insert-file-I73AZW3L.mjs} +6 -8
- package/dist/{insert-gif-FIMCCBAI.mjs → insert-gif-KWRC3ACT.mjs} +4 -4
- package/dist/{insert-image-CZV6HWQZ.mjs → insert-image-XIY6BGW5.mjs} +6 -5
- package/dist/{insert-poll-6BCIFY5G.mjs → insert-poll-J5YVZNZ4.mjs} +4 -3
- package/dist/{insert-table-ZRJP6X52.mjs → insert-table-OIMJRFFK.mjs} +1 -1
- package/dist/{poll-component-VHMM5KKZ.mjs → poll-component-TVHXIKGQ.mjs} +3 -2
- package/dist/react.js +17933 -9531
- package/dist/react.mjs +41 -34
- package/dist/{stepper-4AO5XMO7.mjs → stepper-ILF7YXTO.mjs} +64 -74
- package/dist/styles/notiq.css +1 -1
- package/package.json +2 -2
- package/src/styles/notiq.css +20 -0
- package/dist/AICommandBarPlugin-TADJ3X2Y.mjs +0 -12
- package/dist/CodeActionMenuPlugin-MRKY67ED.mjs +0 -14
- package/dist/CollaborationPlugin-TIZOQBUT.mjs +0 -405
- package/dist/CollaboratorsBar-TMKBOBJI.mjs +0 -20
- package/dist/CommentsPlugin-5M4RD6YO.mjs +0 -19
- package/dist/ExcalidrawPlugin-2SGPIQ6U.mjs +0 -14
- package/dist/ExportPlugin-OKZOLBGS.mjs +0 -42
- package/dist/FloatingLinkEditorPlugin-MABB34L7.mjs +0 -12
- package/dist/FloatingTextFormatToolbarPlugin-SO5VON7Q.mjs +0 -45
- package/dist/InlineCopilotPlugin-PNS5Y6OO.mjs +0 -360
- package/dist/MobileToolbar-JKP2MLQJ.mjs +0 -984
- package/dist/SlashCommand-2TNOOUBM.mjs +0 -39
- package/dist/TableCellActionMenuPlugin-YWBA64J7.mjs +0 -838
- package/dist/TableHoverActionsPlugin-2EIXHEXN.mjs +0 -265
- package/dist/TemplatePlugin-HNTPEXBB.mjs +0 -9
- package/dist/ToolbarPlugin-IIAOU4P5.mjs +0 -35
- package/dist/VersionHistoryPlugin-23MAZB4G.mjs +0 -371
- package/dist/background-color-OZJCBYCT.mjs +0 -425
- package/dist/block-format-MTSIXWID.mjs +0 -14
- package/dist/chunk-2KESP7OU.mjs +0 -809
- package/dist/chunk-3AHNLIME.mjs +0 -1701
- package/dist/chunk-3IILA3IP.mjs +0 -28
- package/dist/chunk-4DVIYZVB.mjs +0 -193
- package/dist/chunk-4FFTOZGJ.mjs +0 -103
- package/dist/chunk-4UMUPCDK.mjs +0 -68
- package/dist/chunk-6D6QLRYR.mjs +0 -238
- package/dist/chunk-6SRMKQSD.mjs +0 -682
- package/dist/chunk-ACV47ZKE.mjs +0 -201
- package/dist/chunk-AYNKORDO.mjs +0 -6
- package/dist/chunk-BGV62GC2.mjs +0 -26
- package/dist/chunk-D3IOUQFR.mjs +0 -441
- package/dist/chunk-EEBA6OAH.mjs +0 -59
- package/dist/chunk-EIZMKFHF.mjs +0 -32
- package/dist/chunk-EVPWKNE4.mjs +0 -27
- package/dist/chunk-FMJ7DGWP.mjs +0 -144
- package/dist/chunk-FYLRS4BG.mjs +0 -88
- package/dist/chunk-HOZ4QRFV.mjs +0 -536
- package/dist/chunk-IAFCQV3Z.mjs +0 -349
- package/dist/chunk-IU2N42JJ.mjs +0 -1763
- package/dist/chunk-J6ZUY5BY.mjs +0 -202
- package/dist/chunk-K5OAFEVY.mjs +0 -191
- package/dist/chunk-KDA7ZYMJ.mjs +0 -431
- package/dist/chunk-KXRLARGI.mjs +0 -26
- package/dist/chunk-LAUAYRPC.mjs +0 -944
- package/dist/chunk-LLCP7NVE.mjs +0 -449
- package/dist/chunk-LU2XWLOE.mjs +0 -219
- package/dist/chunk-MPTE332I.mjs +0 -787
- package/dist/chunk-MTQZWJHR.mjs +0 -111
- package/dist/chunk-OXWTZV3U.mjs +0 -174
- package/dist/chunk-PD5K4AGP.mjs +0 -64
- package/dist/chunk-PFH63ZU4.mjs +0 -33
- package/dist/chunk-PHRVYPVM.mjs +0 -808
- package/dist/chunk-R7WFRENU.mjs +0 -262
- package/dist/chunk-RAVYEEIC.mjs +0 -36
- package/dist/chunk-RJQTA6HG.mjs +0 -358
- package/dist/chunk-SAOJHVPE.mjs +0 -153
- package/dist/chunk-VGAX6YEY.mjs +0 -399
- package/dist/chunk-W6GAJXUS.mjs +0 -334
- package/dist/chunk-XYDBUQ6Z.mjs +0 -1978
- package/dist/chunk-XYT6XM5S.mjs +0 -496
- package/dist/chunk-YDDBQZ77.mjs +0 -409
- package/dist/chunk-YE7M2VKR.mjs +0 -132
- package/dist/chunk-Z6JAFF55.mjs +0 -555
- package/dist/chunk-ZKZ7MLSS.mjs +0 -165
- package/dist/color-23323E3B.mjs +0 -13
- package/dist/font-IJKFR4BM.mjs +0 -12
- package/dist/font-size-GTL6UVQL.mjs +0 -15
- package/dist/insert-node-MA3FXEYN.mjs +0 -245
- package/dist/table-dropdown-4VCRSQB6.mjs +0 -391
- package/dist/text-align-CSDLJUDA.mjs +0 -121
- package/dist/text-format-6L5N3CHZ.mjs +0 -15
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "@lexical/react/LexicalDecoratorBlockNode";
|
|
13
13
|
import * as React from "react";
|
|
14
14
|
import { jsx } from "react/jsx-runtime";
|
|
15
|
-
var AudioComponent = React.lazy(() => import("./AudioComponent-
|
|
15
|
+
var AudioComponent = React.lazy(() => import("./AudioComponent-W5XMZPQB.mjs"));
|
|
16
16
|
var INSERT_AUDIO_COMMAND = createCommand("INSERT_AUDIO_COMMAND");
|
|
17
17
|
function $convertAudioElement(domNode) {
|
|
18
18
|
var _a;
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "@lexical/react/LexicalDecoratorBlockNode";
|
|
13
13
|
import * as React from "react";
|
|
14
14
|
import { jsx } from "react/jsx-runtime";
|
|
15
|
-
var FileComponent = React.lazy(() => import("./FileComponent-
|
|
15
|
+
var FileComponent = React.lazy(() => import("./FileComponent-EOVCH4V5.mjs"));
|
|
16
16
|
var INSERT_FILE_COMMAND = createCommand("INSERT_FILE_COMMAND");
|
|
17
17
|
function $convertFileElement(domNode) {
|
|
18
18
|
const link = domNode;
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import {
|
|
2
|
+
init_react_shim
|
|
3
|
+
} from "./chunk-WYCFGRFJ.mjs";
|
|
4
|
+
|
|
5
|
+
// src/components/editor/utils/url.ts
|
|
6
|
+
init_react_shim();
|
|
7
|
+
var SUPPORTED_URL_PROTOCOLS = /* @__PURE__ */ new Set([
|
|
8
|
+
"http:",
|
|
9
|
+
"https:",
|
|
10
|
+
"mailto:",
|
|
11
|
+
"sms:",
|
|
12
|
+
"tel:",
|
|
13
|
+
"ftp:"
|
|
14
|
+
]);
|
|
15
|
+
function sanitizeUrl(url) {
|
|
16
|
+
try {
|
|
17
|
+
const parsedUrl = new URL(url);
|
|
18
|
+
if (!SUPPORTED_URL_PROTOCOLS.has(parsedUrl.protocol)) {
|
|
19
|
+
return "about:blank";
|
|
20
|
+
}
|
|
21
|
+
} catch (e) {
|
|
22
|
+
return url;
|
|
23
|
+
}
|
|
24
|
+
return url;
|
|
25
|
+
}
|
|
26
|
+
var urlRegExp = new RegExp(
|
|
27
|
+
/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[\w]*))?)/
|
|
28
|
+
);
|
|
29
|
+
function validateUrl(url) {
|
|
30
|
+
return url === "https://" || urlRegExp.test(url);
|
|
31
|
+
}
|
|
32
|
+
function normalizeUrl(rawUrl) {
|
|
33
|
+
let trimmed = (rawUrl || "").trim();
|
|
34
|
+
if (/^www\./i.test(trimmed)) {
|
|
35
|
+
trimmed = `https://${trimmed}`;
|
|
36
|
+
}
|
|
37
|
+
return trimmed;
|
|
38
|
+
}
|
|
39
|
+
function extractYouTubeId(url) {
|
|
40
|
+
try {
|
|
41
|
+
const match = url.match(
|
|
42
|
+
/(?:youtube\.com\/(?:watch\?.*v=|embed\/|shorts\/|live\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/i
|
|
43
|
+
);
|
|
44
|
+
return match ? match[1] : null;
|
|
45
|
+
} catch (e) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function cleanTitleFromUrl(urlStr) {
|
|
50
|
+
try {
|
|
51
|
+
const parsed = new URL(urlStr);
|
|
52
|
+
const path = parsed.pathname.replace(/\/+$/, "");
|
|
53
|
+
if (!path || path === "/") {
|
|
54
|
+
return parsed.hostname.replace(/^www\./, "");
|
|
55
|
+
}
|
|
56
|
+
const segment = path.split("/").pop() || "";
|
|
57
|
+
const clean = segment.replace(/\.[a-zA-Z0-9]+$/, "").replace(/[-_]+/g, " ").trim();
|
|
58
|
+
if (clean.length > 2) {
|
|
59
|
+
return clean.split(" ").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
60
|
+
}
|
|
61
|
+
return parsed.hostname.replace(/^www\./, "");
|
|
62
|
+
} catch (e) {
|
|
63
|
+
return urlStr;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function getInitialMetadata(rawUrl) {
|
|
67
|
+
const url = normalizeUrl(rawUrl);
|
|
68
|
+
let hostname = "link";
|
|
69
|
+
try {
|
|
70
|
+
hostname = new URL(url).hostname.replace(/^www\./, "");
|
|
71
|
+
} catch (e) {
|
|
72
|
+
}
|
|
73
|
+
const defaultFavicon = `https://www.google.com/s2/favicons?domain=${hostname}&sz=64`;
|
|
74
|
+
const ytId = extractYouTubeId(url);
|
|
75
|
+
if (ytId) {
|
|
76
|
+
return {
|
|
77
|
+
title: "YouTube Video",
|
|
78
|
+
description: "Watch on YouTube",
|
|
79
|
+
image: `https://i.ytimg.com/vi/${ytId}/hqdefault.jpg`,
|
|
80
|
+
website: "YouTube",
|
|
81
|
+
logo: "https://www.youtube.com/s/desktop/28b0985e/img/favicon.ico"
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
const ghMatch = url.match(
|
|
85
|
+
/^https?:\/\/github\.com\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_.-]+)/i
|
|
86
|
+
);
|
|
87
|
+
if (ghMatch) {
|
|
88
|
+
const [, owner, repo] = ghMatch;
|
|
89
|
+
return {
|
|
90
|
+
title: `${owner}/${repo}`,
|
|
91
|
+
description: "GitHub repository",
|
|
92
|
+
image: `https://opengraph.githubassets.com/1/${owner}/${repo}`,
|
|
93
|
+
website: "GitHub",
|
|
94
|
+
logo: "https://github.githubassets.com/favicons/favicon.svg"
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
if (/\.(png|jpe?g|gif|webp|svg)(\?.*)?$/i.test(url)) {
|
|
98
|
+
return {
|
|
99
|
+
title: cleanTitleFromUrl(url),
|
|
100
|
+
description: "Image",
|
|
101
|
+
image: url,
|
|
102
|
+
website: hostname,
|
|
103
|
+
logo: defaultFavicon
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
title: cleanTitleFromUrl(url) || hostname,
|
|
108
|
+
description: `Open link on ${hostname}`,
|
|
109
|
+
image: void 0,
|
|
110
|
+
website: hostname,
|
|
111
|
+
logo: defaultFavicon
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
async function fetchMetadata(rawUrl) {
|
|
115
|
+
var _a, _b;
|
|
116
|
+
const url = normalizeUrl(rawUrl);
|
|
117
|
+
const fallback = getInitialMetadata(url);
|
|
118
|
+
const ytId = extractYouTubeId(url);
|
|
119
|
+
if (ytId) {
|
|
120
|
+
try {
|
|
121
|
+
const res = await fetch(
|
|
122
|
+
`https://noembed.com/embed?url=${encodeURIComponent(url)}`,
|
|
123
|
+
{ signal: AbortSignal.timeout(4e3) }
|
|
124
|
+
);
|
|
125
|
+
if (res.ok) {
|
|
126
|
+
const data = await res.json();
|
|
127
|
+
if (data && data.title) {
|
|
128
|
+
return {
|
|
129
|
+
title: data.title,
|
|
130
|
+
description: data.author_name ? `by ${data.author_name} \u2022 YouTube` : "Watch on YouTube",
|
|
131
|
+
image: data.thumbnail_url || `https://i.ytimg.com/vi/${ytId}/hqdefault.jpg`,
|
|
132
|
+
website: "YouTube",
|
|
133
|
+
logo: fallback.logo
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
} catch (e) {
|
|
138
|
+
}
|
|
139
|
+
return fallback;
|
|
140
|
+
}
|
|
141
|
+
const ghMatch = url.match(
|
|
142
|
+
/^https?:\/\/github\.com\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_.-]+)/i
|
|
143
|
+
);
|
|
144
|
+
if (ghMatch) {
|
|
145
|
+
const [, owner, repo] = ghMatch;
|
|
146
|
+
try {
|
|
147
|
+
const res = await fetch(
|
|
148
|
+
`https://api.github.com/repos/${owner}/${repo}`,
|
|
149
|
+
{
|
|
150
|
+
headers: { Accept: "application/vnd.github.v3+json" },
|
|
151
|
+
signal: AbortSignal.timeout(4e3)
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
if (res.ok) {
|
|
155
|
+
const data = await res.json();
|
|
156
|
+
return {
|
|
157
|
+
title: data.full_name || `${owner}/${repo}`,
|
|
158
|
+
description: data.description || (data.stargazers_count != null ? `\u2605 ${data.stargazers_count.toLocaleString()} on GitHub` : "GitHub repository"),
|
|
159
|
+
image: `https://opengraph.githubassets.com/1/${owner}/${repo}`,
|
|
160
|
+
website: "GitHub",
|
|
161
|
+
logo: fallback.logo
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
} catch (e) {
|
|
165
|
+
}
|
|
166
|
+
return fallback;
|
|
167
|
+
}
|
|
168
|
+
if (/vimeo\.com\/\d+/i.test(url)) {
|
|
169
|
+
try {
|
|
170
|
+
const res = await fetch(
|
|
171
|
+
`https://vimeo.com/api/oembed.json?url=${encodeURIComponent(url)}`,
|
|
172
|
+
{ signal: AbortSignal.timeout(4e3) }
|
|
173
|
+
);
|
|
174
|
+
if (res.ok) {
|
|
175
|
+
const data = await res.json();
|
|
176
|
+
return {
|
|
177
|
+
title: data.title || fallback.title,
|
|
178
|
+
description: data.description || (data.author_name ? `by ${data.author_name} \u2022 Vimeo` : "Vimeo Video"),
|
|
179
|
+
image: data.thumbnail_url || fallback.image,
|
|
180
|
+
website: "Vimeo",
|
|
181
|
+
logo: fallback.logo
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
} catch (e) {
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (/spotify\.com/i.test(url)) {
|
|
188
|
+
try {
|
|
189
|
+
const res = await fetch(
|
|
190
|
+
`https://open.spotify.com/oembed?url=${encodeURIComponent(url)}`,
|
|
191
|
+
{ signal: AbortSignal.timeout(4e3) }
|
|
192
|
+
);
|
|
193
|
+
if (res.ok) {
|
|
194
|
+
const data = await res.json();
|
|
195
|
+
return {
|
|
196
|
+
title: data.title || fallback.title,
|
|
197
|
+
description: "Listen on Spotify",
|
|
198
|
+
image: data.thumbnail_url || fallback.image,
|
|
199
|
+
website: "Spotify",
|
|
200
|
+
logo: fallback.logo
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
} catch (e) {
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (/soundcloud\.com/i.test(url)) {
|
|
207
|
+
try {
|
|
208
|
+
const res = await fetch(
|
|
209
|
+
`https://soundcloud.com/oembed?url=${encodeURIComponent(url)}&format=json`,
|
|
210
|
+
{ signal: AbortSignal.timeout(4e3) }
|
|
211
|
+
);
|
|
212
|
+
if (res.ok) {
|
|
213
|
+
const data = await res.json();
|
|
214
|
+
return {
|
|
215
|
+
title: data.title || fallback.title,
|
|
216
|
+
description: data.author_name ? `by ${data.author_name} \u2022 SoundCloud` : "SoundCloud",
|
|
217
|
+
image: data.thumbnail_url || fallback.image,
|
|
218
|
+
website: "SoundCloud",
|
|
219
|
+
logo: fallback.logo
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
} catch (e) {
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
try {
|
|
226
|
+
const res = await fetch(
|
|
227
|
+
`https://noembed.com/embed?url=${encodeURIComponent(url)}`,
|
|
228
|
+
{ signal: AbortSignal.timeout(4e3) }
|
|
229
|
+
);
|
|
230
|
+
if (res.ok) {
|
|
231
|
+
const data = await res.json();
|
|
232
|
+
if (data && data.title && !data.error) {
|
|
233
|
+
return {
|
|
234
|
+
title: data.title,
|
|
235
|
+
description: data.author_name ? `by ${data.author_name}` : data.provider_name || fallback.description,
|
|
236
|
+
image: data.thumbnail_url || fallback.image,
|
|
237
|
+
website: data.provider_name || fallback.website,
|
|
238
|
+
logo: fallback.logo
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
} catch (e) {
|
|
243
|
+
}
|
|
244
|
+
try {
|
|
245
|
+
const proxyUrl = "https://api.allorigins.win/get?url=";
|
|
246
|
+
const response = await fetch(`${proxyUrl}${encodeURIComponent(url)}`, {
|
|
247
|
+
signal: AbortSignal.timeout(4e3)
|
|
248
|
+
});
|
|
249
|
+
if (response.ok) {
|
|
250
|
+
const data = await response.json();
|
|
251
|
+
if (data && data.contents && typeof DOMParser !== "undefined") {
|
|
252
|
+
const parser = new DOMParser();
|
|
253
|
+
const doc = parser.parseFromString(data.contents, "text/html");
|
|
254
|
+
const getMetaTagContent = (property) => {
|
|
255
|
+
const element = doc.querySelector(`meta[property="${property}"]`) || doc.querySelector(`meta[name="${property}"]`);
|
|
256
|
+
return element ? element.getAttribute("content") : null;
|
|
257
|
+
};
|
|
258
|
+
const title = getMetaTagContent("og:title") || getMetaTagContent("twitter:title") || ((_b = (_a = doc.querySelector("title")) == null ? void 0 : _a.textContent) == null ? void 0 : _b.trim()) || fallback.title;
|
|
259
|
+
const description = getMetaTagContent("og:description") || getMetaTagContent("twitter:description") || getMetaTagContent("description") || fallback.description;
|
|
260
|
+
const image = getMetaTagContent("og:image") || getMetaTagContent("twitter:image") || fallback.image;
|
|
261
|
+
const website = getMetaTagContent("og:site_name") || fallback.website;
|
|
262
|
+
return {
|
|
263
|
+
title,
|
|
264
|
+
description,
|
|
265
|
+
image: image || void 0,
|
|
266
|
+
website,
|
|
267
|
+
logo: fallback.logo
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
} catch (e) {
|
|
272
|
+
}
|
|
273
|
+
return fallback;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export {
|
|
277
|
+
sanitizeUrl,
|
|
278
|
+
validateUrl,
|
|
279
|
+
normalizeUrl,
|
|
280
|
+
getInitialMetadata,
|
|
281
|
+
fetchMetadata
|
|
282
|
+
};
|