@sockethub/platform-metadata 1.0.1-alpha.14 → 1.0.1-alpha.16
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/README.md +6 -6
- package/dist/index.d.ts +12 -0
- package/dist/index.js +649 -354
- package/dist/index.js.map +7 -7
- package/dist/resolvers.d.ts +39 -0
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -96,11 +96,11 @@ so those URLs are resolved through preview services built for this purpose:
|
|
|
96
96
|
thumbnail), and the canonical `x.com` URL. If the API is unavailable or the
|
|
97
97
|
post can't be resolved, the platform falls back to the regular scrape
|
|
98
98
|
(which still yields the post text).
|
|
99
|
-
* **Reddit URLs**
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
* **Reddit post URLs** use `old.reddit.com`'s structured JSON response, avoiding
|
|
100
|
+
Reddit's unreliable HTML and Open Graph crawler behavior. The post title,
|
|
101
|
+
self-text, and direct `i.redd.it` image are mapped into the preview; text posts
|
|
102
|
+
intentionally have no image. oEmbed remains a title-only failure fallback.
|
|
103
|
+
See `compatUserAgent` below.
|
|
104
104
|
* **Facebook** remains best-effort: post text usually comes through, but
|
|
105
105
|
media requires authentication and no public preview service exists.
|
|
106
106
|
|
|
@@ -124,7 +124,7 @@ default UA. Override per deployment via `packageConfig`:
|
|
|
124
124
|
|
|
125
125
|
### `compatUserAgent`
|
|
126
126
|
|
|
127
|
-
Sites that only serve
|
|
127
|
+
Sites that only serve metadata to *recognized* embed crawlers (Reddit)
|
|
128
128
|
are fetched with a link-preview crawler user agent instead — the established
|
|
129
129
|
practice for self-hosted preview fetchers. Defaults to
|
|
130
130
|
`Mozilla/5.0 (compatible; Discordbot/2.0; +https://discordapp.com)`;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { ActivityStream, PlatformCallback, PlatformConfig, PlatformInterface, PlatformSession } from "@sockethub/schemas";
|
|
2
|
+
/** Enforce a deadline independently of a dependency's AbortSignal handling. */
|
|
3
|
+
export declare function withDeadline<T>(promise: Promise<T>, timeoutMs: number): Promise<T>;
|
|
2
4
|
export default class Metadata implements PlatformInterface {
|
|
3
5
|
private readonly log;
|
|
6
|
+
private readonly fetchImpl;
|
|
4
7
|
private dispatcher?;
|
|
5
8
|
config: PlatformConfig;
|
|
6
9
|
constructor(session: PlatformSession);
|
|
@@ -158,6 +161,15 @@ export default class Metadata implements PlatformInterface {
|
|
|
158
161
|
private compatUserAgent;
|
|
159
162
|
fetch(job: ActivityStream, cb: PlatformCallback): void;
|
|
160
163
|
private fetchTweet;
|
|
164
|
+
private fetchReddit;
|
|
165
|
+
/**
|
|
166
|
+
* Fetch Reddit's fixed-host JSON endpoint without the Undici dispatcher.
|
|
167
|
+
* The platform child runtime has exhibited stuck Undici requests even when
|
|
168
|
+
* AbortSignal fires. node:https gives us an independently enforced socket
|
|
169
|
+
* timeout; the outer withDeadline still guarantees callback completion.
|
|
170
|
+
*/
|
|
171
|
+
private fetchRedditJson;
|
|
172
|
+
private fetchRedditEmbed;
|
|
161
173
|
private scrape;
|
|
162
174
|
cleanup(cb: PlatformCallback): void;
|
|
163
175
|
}
|