@singi-labs/sifa-sdk 0.12.12 → 0.12.13

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.cjs CHANGED
@@ -1907,6 +1907,27 @@ function detectPdsProvider(handle) {
1907
1907
  // src/format/embed.ts
1908
1908
  var LINK = { kind: "link" };
1909
1909
  var YOUTUBE_ID = /^[A-Za-z0-9_-]{6,}$/;
1910
+ function youtubeVideoId(url) {
1911
+ let parsed3;
1912
+ try {
1913
+ parsed3 = new URL(url);
1914
+ } catch {
1915
+ return null;
1916
+ }
1917
+ if (parsed3.protocol !== "https:") return null;
1918
+ const host = bareHost(parsed3.hostname);
1919
+ const segments = parsed3.pathname.split("/").filter(Boolean);
1920
+ let id = null;
1921
+ if (host === "youtu.be") id = segments[0] ?? null;
1922
+ else if (host === "youtube.com" || host === "m.youtube.com") {
1923
+ if (parsed3.pathname === "/watch") id = parsed3.searchParams.get("v");
1924
+ else if (segments[0] === "embed" || segments[0] === "shorts") id = segments[1] ?? null;
1925
+ }
1926
+ return id && YOUTUBE_ID.test(id) ? id : null;
1927
+ }
1928
+ function youtubeThumbnailUrl(videoId) {
1929
+ return `https://i.ytimg.com/vi/${videoId}/hqdefault.jpg`;
1930
+ }
1910
1931
  function bareHost(hostname) {
1911
1932
  return hostname.toLowerCase().replace(/^www\./, "");
1912
1933
  }
@@ -1920,24 +1941,9 @@ function resolveEmbed(url) {
1920
1941
  if (parsed3.protocol !== "https:") return LINK;
1921
1942
  const host = bareHost(parsed3.hostname);
1922
1943
  const segments = parsed3.pathname.split("/").filter(Boolean);
1923
- if (host === "youtu.be") {
1924
- const id = segments[0];
1925
- if (id && YOUTUBE_ID.test(id)) {
1926
- return youtubeEmbed(id);
1927
- }
1928
- return LINK;
1929
- }
1930
- if (host === "youtube.com" || host === "m.youtube.com") {
1931
- if (parsed3.pathname === "/watch") {
1932
- const id = parsed3.searchParams.get("v");
1933
- if (id && YOUTUBE_ID.test(id)) return youtubeEmbed(id);
1934
- return LINK;
1935
- }
1936
- if (segments[0] === "embed" || segments[0] === "shorts") {
1937
- const id = segments[1];
1938
- if (id && YOUTUBE_ID.test(id)) return youtubeEmbed(id);
1939
- }
1940
- return LINK;
1944
+ if (host === "youtu.be" || host === "youtube.com" || host === "m.youtube.com") {
1945
+ const id = youtubeVideoId(url);
1946
+ return id ? youtubeEmbed(id) : LINK;
1941
1947
  }
1942
1948
  if (host === "vimeo.com") {
1943
1949
  const id = segments[0];
@@ -1966,12 +1972,18 @@ function resolveEmbed(url) {
1966
1972
  if (segments[0] === "player" && segments[1]) {
1967
1973
  return { kind: "iframe", provider: "speakerdeck", src: parsed3.href, aspectRatio: "4:3" };
1968
1974
  }
1975
+ if (segments.length >= 2) {
1976
+ return { kind: "oembed", provider: "speakerdeck", aspectRatio: "4:3", pageUrl: parsed3.href };
1977
+ }
1969
1978
  return LINK;
1970
1979
  }
1971
1980
  if (host === "slideshare.net") {
1972
1981
  if (segments[0] === "slideshow" && segments[1] === "embed_code") {
1973
1982
  return { kind: "iframe", provider: "slideshare", src: parsed3.href, aspectRatio: "4:3" };
1974
1983
  }
1984
+ if (segments.length >= 2) {
1985
+ return { kind: "oembed", provider: "slideshare", aspectRatio: "4:3", pageUrl: parsed3.href };
1986
+ }
1975
1987
  return LINK;
1976
1988
  }
1977
1989
  if (host === "docs.google.com") {
@@ -4528,7 +4540,7 @@ var ProfileVolunteeringRecordSchema = zod.z.object({
4528
4540
  });
4529
4541
 
4530
4542
  // src/index.ts
4531
- var SIFA_SDK_VERSION = "0.12.12";
4543
+ var SIFA_SDK_VERSION = "0.12.13";
4532
4544
 
4533
4545
  exports.ACTIVITY_TIERS = ACTIVITY_TIERS;
4534
4546
  exports.ACTIVITY_VERBS = ACTIVITY_VERBS;
@@ -4772,5 +4784,7 @@ exports.truncateGraphemes = truncateGraphemes;
4772
4784
  exports.uriSchema = uriSchema;
4773
4785
  exports.verbForCollection = verbForCollection;
4774
4786
  exports.visibleItems = visibleItems;
4787
+ exports.youtubeThumbnailUrl = youtubeThumbnailUrl;
4788
+ exports.youtubeVideoId = youtubeVideoId;
4775
4789
  //# sourceMappingURL=index.cjs.map
4776
4790
  //# sourceMappingURL=index.cjs.map