nuxt-bluesky-comments 0.1.2 → 0.1.4
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/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -25,6 +25,9 @@ const module$1 = defineNuxtModule({
|
|
|
25
25
|
from: resolver.resolve("./runtime/composables/useBlueskyComments")
|
|
26
26
|
});
|
|
27
27
|
nuxt.options.build.transpile.push("@atproto/api");
|
|
28
|
+
nuxt.options.nitro.externals ||= {};
|
|
29
|
+
nuxt.options.nitro.externals.inline ||= [];
|
|
30
|
+
nuxt.options.nitro.externals.inline.push("@atproto/api");
|
|
28
31
|
}
|
|
29
32
|
});
|
|
30
33
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { AppBskyFeedDefs } from "@atproto/api";
|
|
2
2
|
import type { FlattenedComment } from "../types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Parse a Bluesky web URL into handle/DID and rkey.
|
|
@@ -23,4 +23,4 @@ export type ProcessRepliesOptions = {
|
|
|
23
23
|
*/
|
|
24
24
|
flattenSameAuthorThreads?: boolean;
|
|
25
25
|
};
|
|
26
|
-
export declare function processReplies(replies:
|
|
26
|
+
export declare function processReplies(replies: AppBskyFeedDefs.ThreadViewPost["replies"], parentAuthorDid?: string, depth?: number, options?: ProcessRepliesOptions): FlattenedComment[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { AppBskyFeedDefs } from "@atproto/api";
|
|
2
2
|
export function parseBlueskyUrl(url) {
|
|
3
3
|
const match = url.match(/https?:\/\/bsky\.app\/profile\/([^/]+)\/post\/([^/?#]+)/);
|
|
4
4
|
if (!match) return null;
|
|
@@ -19,7 +19,7 @@ export function processReplies(replies, parentAuthorDid, depth = 0, options = {}
|
|
|
19
19
|
const flattenSameAuthorThreads = options.flattenSameAuthorThreads ?? true;
|
|
20
20
|
const groups = [];
|
|
21
21
|
for (const reply of replies) {
|
|
22
|
-
if (!
|
|
22
|
+
if (!AppBskyFeedDefs.isThreadViewPost(reply)) continue;
|
|
23
23
|
const post = reply.post;
|
|
24
24
|
const author = post.author;
|
|
25
25
|
const record = post.record;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ref, computed } from "vue";
|
|
2
|
-
import
|
|
2
|
+
import { AtpAgent, AppBskyFeedDefs } from "@atproto/api";
|
|
3
3
|
import {
|
|
4
4
|
parseBlueskyUrl,
|
|
5
5
|
processReplies,
|
|
6
6
|
uriToUrl
|
|
7
7
|
} from "./blueskyComments.logic.js";
|
|
8
|
-
const agent = new
|
|
8
|
+
const agent = new AtpAgent({
|
|
9
9
|
service: "https://public.api.bsky.app"
|
|
10
10
|
});
|
|
11
11
|
export function useBlueskyComments(uriOrUrl, options = {}) {
|
|
@@ -51,11 +51,11 @@ export function useBlueskyComments(uriOrUrl, options = {}) {
|
|
|
51
51
|
throw new Error(`Failed to fetch post: ${uri}`);
|
|
52
52
|
}
|
|
53
53
|
const { data } = response;
|
|
54
|
-
if (!
|
|
55
|
-
if (
|
|
54
|
+
if (!AppBskyFeedDefs.isThreadViewPost(data.thread)) {
|
|
55
|
+
if (AppBskyFeedDefs.isBlockedPost(data.thread)) {
|
|
56
56
|
throw new Error("This post is from a blocked account");
|
|
57
57
|
}
|
|
58
|
-
if (
|
|
58
|
+
if (AppBskyFeedDefs.isNotFoundPost(data.thread)) {
|
|
59
59
|
throw new Error(`Post not found: ${uri}`);
|
|
60
60
|
}
|
|
61
61
|
throw new Error("Post not found or not accessible");
|