@atcute/bluesky-richtext-builder 2.0.5 → 3.0.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.
- package/README.md +22 -11
- package/dist/index.d.ts +11 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -16
- package/dist/index.js.map +1 -1
- package/lib/index.ts +17 -16
- package/package.json +9 -5
package/README.md
CHANGED
|
@@ -50,27 +50,35 @@ console.log(rt.facets);
|
|
|
50
50
|
|
|
51
51
|
use with `@atcute/client` to create a post:
|
|
52
52
|
|
|
53
|
+
```sh
|
|
54
|
+
npm install @atcute/client @atcute/password-session @atcute/bluesky
|
|
55
|
+
```
|
|
56
|
+
|
|
53
57
|
```ts
|
|
54
|
-
import { Client,
|
|
58
|
+
import { Client, ok } from '@atcute/client';
|
|
59
|
+
import { PasswordSession } from '@atcute/password-session';
|
|
55
60
|
import RichtextBuilder from '@atcute/bluesky-richtext-builder';
|
|
56
61
|
|
|
57
62
|
import type {} from '@atcute/bluesky';
|
|
58
63
|
|
|
59
|
-
const
|
|
60
|
-
|
|
64
|
+
const session = await PasswordSession.login({
|
|
65
|
+
service: 'https://bsky.social',
|
|
66
|
+
identifier: 'you.bsky.social',
|
|
67
|
+
password: 'your-app-password',
|
|
68
|
+
});
|
|
61
69
|
|
|
62
|
-
|
|
70
|
+
const rpc = new Client({ handler: session });
|
|
63
71
|
|
|
64
72
|
const rt = new RichtextBuilder()
|
|
65
73
|
.addText('hello ')
|
|
66
74
|
.addMention('@bsky.app', 'did:plc:z72i7hdynmk6r22z27h6tvur')
|
|
67
75
|
.addText('! ')
|
|
68
|
-
.addTag('atproto');
|
|
76
|
+
.addTag('#atproto', 'atproto');
|
|
69
77
|
|
|
70
78
|
await ok(
|
|
71
79
|
rpc.post('com.atproto.repo.createRecord', {
|
|
72
80
|
input: {
|
|
73
|
-
repo:
|
|
81
|
+
repo: session.did,
|
|
74
82
|
collection: 'app.bsky.feed.post',
|
|
75
83
|
record: {
|
|
76
84
|
$type: 'app.bsky.feed.post',
|
|
@@ -117,7 +125,9 @@ import {
|
|
|
117
125
|
|
|
118
126
|
const handleResolver = new CompositeHandleResolver({
|
|
119
127
|
methods: {
|
|
120
|
-
dns: new DohJsonHandleResolver({
|
|
128
|
+
dns: new DohJsonHandleResolver({
|
|
129
|
+
dohUrl: 'https://mozilla.cloudflare-dns.com/dns-query',
|
|
130
|
+
}),
|
|
121
131
|
http: new WellKnownHandleResolver(),
|
|
122
132
|
},
|
|
123
133
|
});
|
|
@@ -130,10 +140,11 @@ const rt = new RichtextBuilder().addMention(`@${handle}`, did);
|
|
|
130
140
|
|
|
131
141
|
### adding hashtags
|
|
132
142
|
|
|
133
|
-
hashtags are added without the `#` prefix - it's added automatically:
|
|
134
|
-
|
|
135
143
|
```ts
|
|
136
|
-
const rt = new RichtextBuilder()
|
|
144
|
+
const rt = new RichtextBuilder()
|
|
145
|
+
.addText('loving ')
|
|
146
|
+
.addTag('#atproto', 'atproto')
|
|
147
|
+
.addText(' development!');
|
|
137
148
|
|
|
138
149
|
// text: "loving #atproto development!"
|
|
139
150
|
```
|
|
@@ -158,7 +169,7 @@ const rt = new RichtextBuilder().addDecoratedText('custom link', feature);
|
|
|
158
169
|
there are multiple ways to get the composed rich text:
|
|
159
170
|
|
|
160
171
|
```ts
|
|
161
|
-
const rt = new RichtextBuilder().addText('hello ').addTag('world');
|
|
172
|
+
const rt = new RichtextBuilder().addText('hello ').addTag('#world', 'world');
|
|
162
173
|
|
|
163
174
|
// via getters
|
|
164
175
|
const text = rt.text;
|
package/dist/index.d.ts
CHANGED
|
@@ -23,37 +23,38 @@ declare class RichtextBuilder {
|
|
|
23
23
|
clone(): RichtextBuilder;
|
|
24
24
|
/**
|
|
25
25
|
* Add plain text to the rich text
|
|
26
|
-
* @param
|
|
26
|
+
* @param text The plain text
|
|
27
27
|
* @returns The builder instance, for chaining
|
|
28
28
|
*/
|
|
29
|
-
addText(
|
|
29
|
+
addText(text: string): this;
|
|
30
30
|
/**
|
|
31
31
|
* Add decorated text to the rich text
|
|
32
|
-
* @param
|
|
32
|
+
* @param text The text itself
|
|
33
33
|
* @param feature Feature to imbue on the text
|
|
34
34
|
* @returns The builder instance, for chaining
|
|
35
35
|
*/
|
|
36
|
-
addDecoratedText(
|
|
36
|
+
addDecoratedText(text: string, feature: FacetFeature): this;
|
|
37
37
|
/**
|
|
38
38
|
* Add link to the rich text
|
|
39
|
-
* @param
|
|
39
|
+
* @param text Text of the link
|
|
40
40
|
* @param uri Valid URL, for example: https://example.com
|
|
41
41
|
* @returns The builder instance, for chaining
|
|
42
42
|
*/
|
|
43
|
-
addLink(
|
|
43
|
+
addLink(text: string, uri: GenericUri): this;
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
46
|
-
* @param
|
|
45
|
+
* Mention a user in rich text
|
|
46
|
+
* @param text Text of the mention, usually in the form of `@handle`
|
|
47
47
|
* @param did Valid DID, for example: did:plc:ia76kvnndjutgedggx2ibrem
|
|
48
48
|
* @returns The builder instance, for chaining
|
|
49
49
|
*/
|
|
50
|
-
addMention(
|
|
50
|
+
addMention(text: string, did: Did): this;
|
|
51
51
|
/**
|
|
52
52
|
* Add inline hashtag to the rich text
|
|
53
|
+
* @param text Text to display
|
|
53
54
|
* @param tag The tag, without the pound prefix
|
|
54
55
|
* @returns The builder instance, for chaining
|
|
55
56
|
*/
|
|
56
|
-
addTag(tag: string): this;
|
|
57
|
+
addTag(text: string, tag: string): this;
|
|
57
58
|
}
|
|
58
59
|
export default RichtextBuilder;
|
|
59
60
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,kBAAkB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E,CAAC;CAChB;AAED,kDAAkD;AAClD,cAAM,eAAe;;IAMpB,8BAA8B;IAC9B,IAAI,IAAI,IAAI,MAAM,CASjB;IAED,gCAAgC;IAChC,IAAI,MAAM,IAAI,KAAK,EAAE,CASpB;IAED,sCAAsC;IACtC,KAAK,IAAI,aAAa,CAKrB;IAED,uCAAuC;IACvC,KAAK,IAAI,eAAe,CAKvB;IAED;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAK1B;IAED;;;;;OAKG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,CAyB1D;IAED;;;;;OAKG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,GAAG,IAAI,CAE3C;IAED;;;;;OAKG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,IAAI,CAEvC;IAED;;;;;OAKG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAEtC;CACD;eAEc,eAAe"}
|
package/dist/index.js
CHANGED
|
@@ -38,21 +38,21 @@ class RichtextBuilder {
|
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* Add plain text to the rich text
|
|
41
|
-
* @param
|
|
41
|
+
* @param text The plain text
|
|
42
42
|
* @returns The builder instance, for chaining
|
|
43
43
|
*/
|
|
44
|
-
addText(
|
|
44
|
+
addText(text) {
|
|
45
45
|
const segments = this.#segments;
|
|
46
|
-
segments[segments.length - 1] +=
|
|
46
|
+
segments[segments.length - 1] += text;
|
|
47
47
|
return this;
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* Add decorated text to the rich text
|
|
51
|
-
* @param
|
|
51
|
+
* @param text The text itself
|
|
52
52
|
* @param feature Feature to imbue on the text
|
|
53
53
|
* @returns The builder instance, for chaining
|
|
54
54
|
*/
|
|
55
|
-
addDecoratedText(
|
|
55
|
+
addDecoratedText(text, feature) {
|
|
56
56
|
const segments = this.#segments;
|
|
57
57
|
const last = segments.length - 1;
|
|
58
58
|
// Calculate the starting index
|
|
@@ -61,7 +61,7 @@ class RichtextBuilder {
|
|
|
61
61
|
if (last !== 0) {
|
|
62
62
|
start += segments[last - 1].index.byteEnd;
|
|
63
63
|
}
|
|
64
|
-
const byteLength = getUtf8Length(
|
|
64
|
+
const byteLength = getUtf8Length(text);
|
|
65
65
|
const facet = {
|
|
66
66
|
index: {
|
|
67
67
|
byteStart: start,
|
|
@@ -69,35 +69,36 @@ class RichtextBuilder {
|
|
|
69
69
|
},
|
|
70
70
|
features: [feature],
|
|
71
71
|
};
|
|
72
|
-
segments[last] +=
|
|
72
|
+
segments[last] += text;
|
|
73
73
|
segments.push(facet, '');
|
|
74
74
|
return this;
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
77
|
* Add link to the rich text
|
|
78
|
-
* @param
|
|
78
|
+
* @param text Text of the link
|
|
79
79
|
* @param uri Valid URL, for example: https://example.com
|
|
80
80
|
* @returns The builder instance, for chaining
|
|
81
81
|
*/
|
|
82
|
-
addLink(
|
|
83
|
-
return this.addDecoratedText(
|
|
82
|
+
addLink(text, uri) {
|
|
83
|
+
return this.addDecoratedText(text, { $type: 'app.bsky.richtext.facet#link', uri: uri });
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
|
-
*
|
|
87
|
-
* @param
|
|
86
|
+
* Mention a user in rich text
|
|
87
|
+
* @param text Text of the mention, usually in the form of `@handle`
|
|
88
88
|
* @param did Valid DID, for example: did:plc:ia76kvnndjutgedggx2ibrem
|
|
89
89
|
* @returns The builder instance, for chaining
|
|
90
90
|
*/
|
|
91
|
-
addMention(
|
|
92
|
-
return this.addDecoratedText(
|
|
91
|
+
addMention(text, did) {
|
|
92
|
+
return this.addDecoratedText(text, { $type: 'app.bsky.richtext.facet#mention', did: did });
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
95
|
* Add inline hashtag to the rich text
|
|
96
|
+
* @param text Text to display
|
|
96
97
|
* @param tag The tag, without the pound prefix
|
|
97
98
|
* @returns The builder instance, for chaining
|
|
98
99
|
*/
|
|
99
|
-
addTag(tag) {
|
|
100
|
-
return this.addDecoratedText(
|
|
100
|
+
addTag(text, tag) {
|
|
101
|
+
return this.addDecoratedText(text, { $type: 'app.bsky.richtext.facet#tag', tag: tag });
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
104
|
export default RichtextBuilder;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAenD,kDAAkD;AAClD,MAAM,eAAe;IACpB,wDAAwD;IACxD,4EAA4E;IAC5E,sCAAsC;IACtC,SAAS,GAAuB,CAAC,EAAE,CAAC,CAAC;IAErC,8BAA8B;IAC9B,IAAI,IAAI
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAenD,kDAAkD;AAClD,MAAM,eAAe;IACpB,wDAAwD;IACxD,4EAA4E;IAC5E,sCAAsC;IACtC,SAAS,GAAuB,CAAC,EAAE,CAAC,CAAC;IAErC,8BAA8B;IAC9B,IAAI,IAAI;QACP,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,GAAG,GAAG,EAAE,CAAC;QAEb,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,QAAQ,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;YAC9D,GAAG,IAAI,QAAQ,CAAC,GAAG,CAAW,CAAC;QAChC,CAAC;QAED,OAAO,GAAG,CAAC;IACZ,CAAC;IAED,gCAA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,CAAC,IAAI,GAAG,CAAC,CAAW,CAAC,KAAK,CAAC,OAAO,CAAC;QACtD,CAAC;QAED,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;QAEvC,MAAM,KAAK,GAAU;YACpB,KAAK,EAAE;gBACN,SAAS,EAAE,KAAK;gBAChB,OAAO,EAAE,KAAK,GAAG,UAAU;aAC3B;YACD,QAAQ,EAAE,CAAC,OAAO,CAAC;SACnB,CAAC;QAEF,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;QACvB,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACzB,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;;;OAKG;IACH,OAAO,CAAC,IAAY,EAAE,GAAe;QACpC,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,8BAA8B,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IACzF,CAAC;IAED;;;;;OAKG;IACH,UAAU,CAAC,IAAY,EAAE,GAAQ;QAChC,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,iCAAiC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IAC5F,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,IAAY,EAAE,GAAW;QAC/B,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,6BAA6B,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IACxF,CAAC;CACD;AAED,eAAe,eAAe,CAAC"}
|
package/lib/index.ts
CHANGED
|
@@ -64,23 +64,23 @@ class RichtextBuilder {
|
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* Add plain text to the rich text
|
|
67
|
-
* @param
|
|
67
|
+
* @param text The plain text
|
|
68
68
|
* @returns The builder instance, for chaining
|
|
69
69
|
*/
|
|
70
|
-
addText(
|
|
70
|
+
addText(text: string): this {
|
|
71
71
|
const segments = this.#segments;
|
|
72
|
-
segments[segments.length - 1] +=
|
|
72
|
+
segments[segments.length - 1] += text;
|
|
73
73
|
|
|
74
74
|
return this;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
/**
|
|
78
78
|
* Add decorated text to the rich text
|
|
79
|
-
* @param
|
|
79
|
+
* @param text The text itself
|
|
80
80
|
* @param feature Feature to imbue on the text
|
|
81
81
|
* @returns The builder instance, for chaining
|
|
82
82
|
*/
|
|
83
|
-
addDecoratedText(
|
|
83
|
+
addDecoratedText(text: string, feature: FacetFeature): this {
|
|
84
84
|
const segments = this.#segments;
|
|
85
85
|
const last = segments.length - 1;
|
|
86
86
|
|
|
@@ -92,7 +92,7 @@ class RichtextBuilder {
|
|
|
92
92
|
start += (segments[last - 1] as Facet).index.byteEnd;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
const byteLength = getUtf8Length(
|
|
95
|
+
const byteLength = getUtf8Length(text);
|
|
96
96
|
|
|
97
97
|
const facet: Facet = {
|
|
98
98
|
index: {
|
|
@@ -102,38 +102,39 @@ class RichtextBuilder {
|
|
|
102
102
|
features: [feature],
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
-
segments[last] +=
|
|
105
|
+
segments[last] += text;
|
|
106
106
|
segments.push(facet, '');
|
|
107
107
|
return this;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
111
|
* Add link to the rich text
|
|
112
|
-
* @param
|
|
112
|
+
* @param text Text of the link
|
|
113
113
|
* @param uri Valid URL, for example: https://example.com
|
|
114
114
|
* @returns The builder instance, for chaining
|
|
115
115
|
*/
|
|
116
|
-
addLink(
|
|
117
|
-
return this.addDecoratedText(
|
|
116
|
+
addLink(text: string, uri: GenericUri): this {
|
|
117
|
+
return this.addDecoratedText(text, { $type: 'app.bsky.richtext.facet#link', uri: uri });
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
/**
|
|
121
|
-
*
|
|
122
|
-
* @param
|
|
121
|
+
* Mention a user in rich text
|
|
122
|
+
* @param text Text of the mention, usually in the form of `@handle`
|
|
123
123
|
* @param did Valid DID, for example: did:plc:ia76kvnndjutgedggx2ibrem
|
|
124
124
|
* @returns The builder instance, for chaining
|
|
125
125
|
*/
|
|
126
|
-
addMention(
|
|
127
|
-
return this.addDecoratedText(
|
|
126
|
+
addMention(text: string, did: Did): this {
|
|
127
|
+
return this.addDecoratedText(text, { $type: 'app.bsky.richtext.facet#mention', did: did });
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
/**
|
|
131
131
|
* Add inline hashtag to the rich text
|
|
132
|
+
* @param text Text to display
|
|
132
133
|
* @param tag The tag, without the pound prefix
|
|
133
134
|
* @returns The builder instance, for chaining
|
|
134
135
|
*/
|
|
135
|
-
addTag(tag: string): this {
|
|
136
|
-
return this.addDecoratedText(
|
|
136
|
+
addTag(text: string, tag: string): this {
|
|
137
|
+
return this.addDecoratedText(text, { $type: 'app.bsky.richtext.facet#tag', tag: tag });
|
|
137
138
|
}
|
|
138
139
|
}
|
|
139
140
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atcute/bluesky-richtext-builder",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "builder pattern for Bluesky's rich text facets",
|
|
5
5
|
"license": "0BSD",
|
|
6
6
|
"repository": {
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"dist/",
|
|
12
12
|
"lib/",
|
|
13
13
|
"!lib/**/*.bench.ts",
|
|
14
|
-
"!lib/**/*.test.ts"
|
|
14
|
+
"!lib/**/*.test.ts",
|
|
15
|
+
"!dist/**/*.{test,bench}.*"
|
|
15
16
|
],
|
|
16
17
|
"type": "module",
|
|
17
18
|
"sideEffects": false,
|
|
@@ -22,12 +23,15 @@
|
|
|
22
23
|
"access": "public"
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
|
-
"@atcute/bluesky": "^3.
|
|
26
|
-
"@atcute/lexicons": "^1.
|
|
26
|
+
"@atcute/bluesky": "^3.3.4",
|
|
27
|
+
"@atcute/lexicons": "^1.3.1",
|
|
27
28
|
"@atcute/uint8array": "^1.1.1"
|
|
28
29
|
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"@atcute/lexicons": "^1.0.0"
|
|
32
|
+
},
|
|
29
33
|
"scripts": {
|
|
30
|
-
"build": "tsgo
|
|
34
|
+
"build": "tsgo",
|
|
31
35
|
"prepublish": "rm -rf dist; pnpm run build"
|
|
32
36
|
}
|
|
33
37
|
}
|