@atcute/bluesky 2.1.0 → 2.1.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AppBskyEmbedRecordWithMedia, AppBskyFeedDefs, AppBskyFeedPost } from '@atcute/client/lexicons';
|
|
1
|
+
import type { AppBskyEmbedRecord, AppBskyEmbedRecordWithMedia, AppBskyFeedDefs, AppBskyFeedPost, Brand } from '@atcute/client/lexicons';
|
|
2
2
|
export interface RawEmbeds {
|
|
3
3
|
media?: AppBskyEmbedRecordWithMedia.Main['media'];
|
|
4
4
|
record?: AppBskyEmbedRecordWithMedia.Main['record'];
|
|
@@ -47,3 +47,10 @@ export declare const unwrapRecordEmbed: (embed: AppBskyFeedDefs.PostView["embed"
|
|
|
47
47
|
* @returns the extracted media and record embeds, if any
|
|
48
48
|
*/
|
|
49
49
|
export declare const unwrapEmbed: (embed: AppBskyFeedDefs.PostView["embed"]) => Embeds;
|
|
50
|
+
export type QuoteEmbed = Brand.Union<AppBskyEmbedRecord.ViewBlocked | AppBskyEmbedRecord.ViewDetached | AppBskyEmbedRecord.ViewNotFound | AppBskyEmbedRecord.ViewRecord>;
|
|
51
|
+
/**
|
|
52
|
+
* get quote embed from a record embed
|
|
53
|
+
* @param embed the record embed to extract from
|
|
54
|
+
* @returns the extracted quote embed, if any
|
|
55
|
+
*/
|
|
56
|
+
export declare const unwrapQuoteEmbed: (embed: RecordEmbed | undefined) => QuoteEmbed | undefined;
|
package/dist/utilities/embeds.js
CHANGED
|
@@ -74,4 +74,23 @@ export const unwrapEmbed = (embed) => {
|
|
|
74
74
|
record: unwrapRecordEmbed(embed),
|
|
75
75
|
};
|
|
76
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* get quote embed from a record embed
|
|
79
|
+
* @param embed the record embed to extract from
|
|
80
|
+
* @returns the extracted quote embed, if any
|
|
81
|
+
*/
|
|
82
|
+
export const unwrapQuoteEmbed = (embed) => {
|
|
83
|
+
switch (embed?.$type) {
|
|
84
|
+
case 'app.bsky.embed.record#viewRecord': {
|
|
85
|
+
return embed;
|
|
86
|
+
}
|
|
87
|
+
case 'app.bsky.embed.record#viewBlocked':
|
|
88
|
+
case 'app.bsky.embed.record#viewDetached':
|
|
89
|
+
case 'app.bsky.embed.record#viewNotFound': {
|
|
90
|
+
if (embed.uri.includes('/app.bsky.feed.post/')) {
|
|
91
|
+
return embed;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
77
96
|
//# sourceMappingURL=embeds.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embeds.js","sourceRoot":"","sources":["../../lib/utilities/embeds.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"embeds.js","sourceRoot":"","sources":["../../lib/utilities/embeds.ts"],"names":[],"mappings":"AAgBA;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAsC,EAAsB,EAAE;IACjG,QAAQ,KAAK,EAAE,KAAK,EAAE,CAAC;QACtB,KAAK,gCAAgC;YACpC,OAAO,KAAK,CAAC,KAAK,CAAC;QACpB,KAAK,uBAAuB;YAC3B,OAAO;IACT,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAsC,EAAuB,EAAE;IACnG,QAAQ,KAAK,EAAE,KAAK,EAAE,CAAC;QACtB,KAAK,gCAAgC;YACpC,OAAO,KAAK,CAAC,MAAM,CAAC;QAErB,KAAK,uBAAuB;YAC3B,OAAO,KAAK,CAAC;IACf,CAAC;AACF,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAsC,EAAa,EAAE;IACnF,OAAO;QACN,KAAK,EAAE,mBAAmB,CAAC,KAAK,CAAC;QACjC,MAAM,EAAE,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CAAC,CAAC"}
|
package/lib/utilities/embeds.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
AppBskyEmbedRecord,
|
|
3
|
+
AppBskyEmbedRecordWithMedia,
|
|
4
|
+
AppBskyFeedDefs,
|
|
5
|
+
AppBskyFeedPost,
|
|
6
|
+
Brand,
|
|
7
|
+
} from '@atcute/client/lexicons';
|
|
2
8
|
|
|
3
9
|
export interface RawEmbeds {
|
|
4
10
|
media?: AppBskyEmbedRecordWithMedia.Main['media'];
|
|
@@ -101,3 +107,31 @@ export const unwrapEmbed = (embed: AppBskyFeedDefs.PostView['embed']): Embeds =>
|
|
|
101
107
|
record: unwrapRecordEmbed(embed),
|
|
102
108
|
};
|
|
103
109
|
};
|
|
110
|
+
|
|
111
|
+
export type QuoteEmbed = Brand.Union<
|
|
112
|
+
| AppBskyEmbedRecord.ViewBlocked
|
|
113
|
+
| AppBskyEmbedRecord.ViewDetached
|
|
114
|
+
| AppBskyEmbedRecord.ViewNotFound
|
|
115
|
+
| AppBskyEmbedRecord.ViewRecord
|
|
116
|
+
>;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* get quote embed from a record embed
|
|
120
|
+
* @param embed the record embed to extract from
|
|
121
|
+
* @returns the extracted quote embed, if any
|
|
122
|
+
*/
|
|
123
|
+
export const unwrapQuoteEmbed = (embed: RecordEmbed | undefined): QuoteEmbed | undefined => {
|
|
124
|
+
switch (embed?.$type) {
|
|
125
|
+
case 'app.bsky.embed.record#viewRecord': {
|
|
126
|
+
return embed;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
case 'app.bsky.embed.record#viewBlocked':
|
|
130
|
+
case 'app.bsky.embed.record#viewDetached':
|
|
131
|
+
case 'app.bsky.embed.record#viewNotFound': {
|
|
132
|
+
if (embed.uri.includes('/app.bsky.feed.post/')) {
|
|
133
|
+
return embed;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@atcute/bluesky",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.1",
|
|
5
5
|
"description": "Bluesky type definitions for atcute",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"@atcute/client": "^3.0.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@atcute/client": "^3.0
|
|
26
|
-
"@atcute/lex-cli": "^1.1.
|
|
25
|
+
"@atcute/client": "^3.1.0",
|
|
26
|
+
"@atcute/lex-cli": "^1.1.2"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
29
|
"build": "tsc",
|