oembed-spec 1.3.33 → 1.4.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.
Files changed (2) hide show
  1. package/package.json +6 -1
  2. package/src/index.d.ts +64 -0
package/package.json CHANGED
@@ -2,7 +2,8 @@
2
2
  "name": "oembed-spec",
3
3
  "description": "A parser for oEmbed specification",
4
4
  "homepage": "https://github.com/microlinkhq/oembed-spec",
5
- "version": "1.3.33",
5
+ "version": "1.4.1",
6
+ "types": "src/index.d.ts",
6
7
  "main": "src/index.js",
7
8
  "author": {
8
9
  "email": "hello@microlink.io",
@@ -21,6 +22,10 @@
21
22
  {
22
23
  "name": "Rémi Berson",
23
24
  "email": "remi@cliqz.com"
25
+ },
26
+ {
27
+ "name": "Michael Lip",
28
+ "email": "51033404+theluckystrike@users.noreply.github.com"
24
29
  }
25
30
  ],
26
31
  "repository": {
package/src/index.d.ts ADDED
@@ -0,0 +1,64 @@
1
+ 'use strict'
2
+
3
+ interface Provider {
4
+ name: string
5
+ url: string
6
+ oembedUrl: string
7
+ }
8
+
9
+ interface OembedOptions {
10
+ maxwidth?: number
11
+ maxheight?: number
12
+ [key: string]: string | number | undefined
13
+ }
14
+
15
+ interface OembedResponse {
16
+ type: string
17
+ version: string
18
+ title?: string
19
+ author_name?: string
20
+ author_url?: string
21
+ provider_name?: string
22
+ provider_url?: string
23
+ cache_age?: number
24
+ thumbnail_url?: string
25
+ thumbnail_width?: number
26
+ thumbnail_height?: number
27
+ html?: string
28
+ width?: number
29
+ height?: number
30
+ url?: string
31
+ }
32
+
33
+ /**
34
+ * oembed-spec - A parser for oEmbed specification
35
+ *
36
+ * @param url - The URL to get oembed data for
37
+ * @param opts - Optional oembed parameters
38
+ * @param gotOpts - Optional got library options for HTTP requests
39
+ * @returns Promise resolving to oembed response data, or undefined if no provider found
40
+ */
41
+ declare function oembed(
42
+ url: string,
43
+ opts?: OembedOptions,
44
+ gotOpts?: Record<string, any>
45
+ ): Promise<OembedResponse | undefined>
46
+
47
+ declare namespace oembed {
48
+ /**
49
+ * Find an oEmbed provider for a given URL
50
+ */
51
+ function findProvider(url: string): Provider | undefined
52
+
53
+ /**
54
+ * Fetch oEmbed data from a specific provider
55
+ */
56
+ function fetchProvider(
57
+ provider: Provider,
58
+ url: string,
59
+ opts?: OembedOptions,
60
+ gotOpts?: Record<string, any>
61
+ ): Promise<OembedResponse>
62
+ }
63
+
64
+ export = oembed