applesauce-content 0.12.0 → 1.2.0

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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import * as exports from "../index.js";
3
+ describe("exports", () => {
4
+ it("should export the expected functions", () => {
5
+ expect(Object.keys(exports).sort()).toMatchInlineSnapshot(`
6
+ [
7
+ "Expressions",
8
+ "Tokens",
9
+ "getMediaAttachmentURLsFromContent",
10
+ ]
11
+ `);
12
+ });
13
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,244 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { Expressions, Tokens } from "../regexp.js";
3
+ describe("Regular Expressions", () => {
4
+ describe("Expressions.link", () => {
5
+ it("should match valid HTTP URLs", () => {
6
+ const text = "Check out https://example.com";
7
+ const matches = Array.from(text.matchAll(Expressions.link));
8
+ expect(matches).toHaveLength(1);
9
+ expect(matches[0][0]).toBe("https://example.com");
10
+ });
11
+ it("should match valid HTTPS URLs with paths and query parameters", () => {
12
+ const text = "Visit https://example.com/path?query=value#fragment";
13
+ const matches = Array.from(text.matchAll(Expressions.link));
14
+ expect(matches).toHaveLength(1);
15
+ expect(matches[0][0]).toBe("https://example.com/path?query=value#fragment");
16
+ });
17
+ it("should match URLs with ports", () => {
18
+ const text = "Server at http://example.com:3000/api";
19
+ const matches = Array.from(text.matchAll(Expressions.link));
20
+ expect(matches).toHaveLength(1);
21
+ expect(matches[0][0]).toBe("http://example.com:3000/api");
22
+ });
23
+ it("should match multiple URLs in text", () => {
24
+ const text = "First https://example.com and second https://test.org/path";
25
+ const matches = Array.from(text.matchAll(Expressions.link));
26
+ expect(matches).toHaveLength(2);
27
+ expect(matches[0][0]).toBe("https://example.com");
28
+ expect(matches[1][0]).toBe("https://test.org/path");
29
+ });
30
+ });
31
+ describe("Expressions.cashu", () => {
32
+ const cashuA = "cashuAeyJ0b2tlbiI6W3sibWludCI6Imh0dHBzOi8vdGVzdG51dC5jYXNodS5zcGFjZSIsInByb29mcyI6W3sic2VjcmV0IjoiMTFhYmQxZjY1OWI1MzE5MjhjYTEwMmEyYjgxYzQ2MTQxYzY3NTg1MjU2ZmZmZGNlNzRiMWY4NWFmZWRkM2M2NiIsIkMiOiIwM2FmYjZiMzE5YjAyYzkyODc3ZjkxY2VjMjM4NmNiZjcwMzVhZDRkMWFiNWUzNmRjY2VkNDdjZWY4NDRjYzNiMWUiLCJhbW91bnQiOjgsImlkIjoiMDA5YTFmMjkzMjUzZTQxZSJ9XX1dLCJ1bml0Ijoic2F0In0";
33
+ const cashuB = "cashuBo2FteBtodHRwczovL3Rlc3RudXQuY2FzaHUuc3BhY2VhdWNzYXRhdIGiYWlIAJofKTJT5B5hcIOkYWEQYXN4QDQ4ZjIwNmM5ODI2NWQ2YjlmYTU1Zjc0ZjQ5ZDU0NjI1NTE4MDBjMDc4NjE1OWQ0YzE4ZDNmMWZiYzE0Nzc3MzhhY1ghA8xqu_uJfIZ-m5UdaauOX1owIFwXeNQ0zQlnLTFsdVaOYWSjYWVYINcRIASTRc17HjOzj-s66ftGh78y4jdvYG4Hx3yh1pDIYXNYILteFXHFo9vo-NEZF2W3ofEvIY63AZxp8MgueyMJuBRYYXJYIBl_RnxlsZMsh4tmgd5K4XsIhgxDM9w5NyhD6F3UEAJSo2FhBGFzeEAxODgzYTc4MmNhMTgzMDNlMmFhMmIyMzRhYjUyMTFhY2Y1NTNjMWVlYWQ3ZWQ1YjBhMzdhYjFlZjcwZWRhMmEyYWNYIQNU8wZs14BtQPHbdOs5Rb3wSh0KXx9AdBigW1mgJwZo4KNhYQFhc3hAMDA1MDMzY2EzNDBjNjE3Njc3OGQxNWYwMTVkOTMyZDEwZjA0YWE1ZTA3ZDQyOTg0ZTUyNWYwMjk1MjM1YWIzNWFjWCECXRsBpeSyn5gUQ7_gvsljKBNCUy0VPvkrTS5HD5BCko0";
34
+ it("should match valid cashu tokens", () => {
35
+ const text = `Here is a token: ${cashuA}`;
36
+ const matches = Array.from(text.matchAll(Expressions.cashu));
37
+ expect(matches).toHaveLength(1);
38
+ expect(matches[0][1]).toBe(cashuA);
39
+ });
40
+ it("should match cashuB tokens", () => {
41
+ const text = `Here is a token: ${cashuB}`;
42
+ const matches = Array.from(text.matchAll(Expressions.cashu));
43
+ expect(matches).toHaveLength(1);
44
+ expect(matches[0][1]).toBe(cashuB);
45
+ });
46
+ it("should match cashu tokens with prefix", () => {
47
+ const text = `Here is a token cashu:${cashuA}`;
48
+ const matches = Array.from(text.matchAll(Expressions.cashu));
49
+ expect(matches).toHaveLength(1);
50
+ expect(matches[0][1]).toBe(cashuA);
51
+ });
52
+ });
53
+ describe("Expressions.nostrLink", () => {
54
+ it("should match npub links", () => {
55
+ const npub = "npub180cvv07tjdrrgpa0j7j7tmnyl2yr6yr7l8j4s3evf6u64th6gkwsyjh6w6";
56
+ const text = `Check out ${npub}`;
57
+ const matches = Array.from(text.matchAll(Expressions.nostrLink));
58
+ expect(matches).toHaveLength(1);
59
+ expect(matches[0][1]).toBe(npub);
60
+ });
61
+ it("should match note links", () => {
62
+ const note = "note1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqsrjtey";
63
+ const text = `Check out ${note}`;
64
+ const matches = Array.from(text.matchAll(Expressions.nostrLink));
65
+ expect(matches).toHaveLength(1);
66
+ expect(matches[0][1]).toBe(note);
67
+ });
68
+ it("should match nprofile links", () => {
69
+ const nprofile = "nprofile1qqsrhuxx8l9ex335q7he0f09aej04zpazpl0ne2cgukyawd24mayt8gpp4mhxue69uhhytnc9e3k7mgpz4mhxue69uhkg6nzv9ejuumpv34kytnrdakp7qgzwaehxw309aex2mrp0yhxummnw3ezuamfdejsygrwv3jx2mtedfhk6tcpzamhxue69uhkummnw3ezuamfdejsygrwv3jx2mtedfhk6tcpzamhxue69uhkzemp9qy";
70
+ const text = `Check out ${nprofile}`;
71
+ const matches = Array.from(text.matchAll(Expressions.nostrLink));
72
+ expect(matches).toHaveLength(1);
73
+ expect(matches[0][1]).toBe(nprofile);
74
+ });
75
+ it("should match nevent links", () => {
76
+ const nevent = "nevent1qvzqqqqqqypzqwlsccluhy6xxsr6l9a9uhhxf75g85g8a709tprjcn4e42h053vaqyd8wumn8ghj7urewfsk66ty9enxjct5dfskvtnrdakj7qgmwaehxw309aex2mrp0yh8wetnw3jhymnzw33jucm0d5hsqgqqqrzq4vghcurgc2p3k70xka03m0wsvhwh244gh2f8tnk6dl49vgx9mgmd";
77
+ const text = `Check out ${nevent}`;
78
+ const matches = Array.from(text.matchAll(Expressions.nostrLink));
79
+ expect(matches).toHaveLength(1);
80
+ expect(matches[0][1]).toBe(nevent);
81
+ });
82
+ it("should match naddr links", () => {
83
+ const naddr = "naddr1qqjx2wtzx93rycmz94nrqvf3956rqep3943xgvec956xxvnxxucxze33v93rvq3qeaz6dwsnvwkha5sn5puwwyxjgy26uusundrm684lg3vw4ma5c2jsxpqqqpmxw6td7rf";
84
+ const text = `Check out ${naddr}`;
85
+ const matches = Array.from(text.matchAll(Expressions.nostrLink));
86
+ expect(matches).toHaveLength(1);
87
+ expect(matches[0][1]).toBe(naddr);
88
+ });
89
+ it("should match nostr: prefixed links", () => {
90
+ const text = "Check out nostr:npub180cvv07tjdrrgpa0j7j7tmnyl2yr6yr7l8j4s3evf6u64th6gkwsyjh6w6";
91
+ const matches = Array.from(text.matchAll(Expressions.nostrLink));
92
+ expect(matches).toHaveLength(1);
93
+ expect(matches[0][1]).toBe("npub180cvv07tjdrrgpa0j7j7tmnyl2yr6yr7l8j4s3evf6u64th6gkwsyjh6w6");
94
+ });
95
+ });
96
+ describe("Expressions.emoji", () => {
97
+ it("should match emoji shortcodes", () => {
98
+ const text = "Hello :smile: world :thumbsup:";
99
+ const matches = Array.from(text.matchAll(Expressions.emoji));
100
+ expect(matches).toHaveLength(2);
101
+ expect(matches[0][1]).toBe("smile");
102
+ expect(matches[1][1]).toBe("thumbsup");
103
+ });
104
+ it("should match emoji shortcodes with underscores and hyphens", () => {
105
+ const text = "Hello :smiling_face: and :thumbs-up:";
106
+ const matches = Array.from(text.matchAll(Expressions.emoji));
107
+ expect(matches).toHaveLength(2);
108
+ expect(matches[0][1]).toBe("smiling_face");
109
+ expect(matches[1][1]).toBe("thumbs-up");
110
+ });
111
+ it("should match emoji shortcodes with numbers", () => {
112
+ const text = "Hello :smile123: world :thumbs2up:";
113
+ const matches = Array.from(text.matchAll(Expressions.emoji));
114
+ expect(matches).toHaveLength(2);
115
+ expect(matches[0][1]).toBe("smile123");
116
+ expect(matches[1][1]).toBe("thumbs2up");
117
+ });
118
+ });
119
+ describe("Expressions.hashtag", () => {
120
+ it("should match simple hashtags", () => {
121
+ const text = "Hello #world and #nostr";
122
+ const matches = Array.from(text.matchAll(Expressions.hashtag));
123
+ expect(matches).toHaveLength(2);
124
+ expect(matches[0][1]).toBe("world");
125
+ expect(matches[1][1]).toBe("nostr");
126
+ });
127
+ it("should match hashtags with numbers", () => {
128
+ const text = "Hello #world2023 and #nostr42";
129
+ const matches = Array.from(text.matchAll(Expressions.hashtag));
130
+ expect(matches).toHaveLength(2);
131
+ expect(matches[0][1]).toBe("world2023");
132
+ expect(matches[1][1]).toBe("nostr42");
133
+ });
134
+ it("should match hashtags at the beginning of text", () => {
135
+ const text = "#hello world";
136
+ const matches = Array.from(text.matchAll(Expressions.hashtag));
137
+ expect(matches).toHaveLength(1);
138
+ expect(matches[0][1]).toBe("hello");
139
+ });
140
+ it("should not match hashtags within words", () => {
141
+ const text = "word#hashtag is not a hashtag";
142
+ const matches = Array.from(text.matchAll(Expressions.hashtag));
143
+ expect(matches).toHaveLength(0);
144
+ });
145
+ it("should match non-Latin hashtags", () => {
146
+ const text = "Hello #世界 and #привет";
147
+ const matches = Array.from(text.matchAll(Expressions.hashtag));
148
+ expect(matches).toHaveLength(2);
149
+ expect(matches[0][1]).toBe("世界");
150
+ expect(matches[1][1]).toBe("привет");
151
+ });
152
+ });
153
+ describe("Expressions.lightning", () => {
154
+ it("should match lightning invoices", () => {
155
+ const invoice = "lnbc100n1p5pjxjk9qypqqqdqqxqrrsssp54ttukd5xxy2nmdzf864yjereuf9v3pyzl66hpqgxa0e8fvlzf6aspp5z6twjtwde82ec7wfcqw2m63v48r6fyw78753wxh7zjlvuru7tapsp6c9lq6m4d55u9jkxuqpepdknnzznfu05wl73swyn52z3pnkzyxrlkqf3t5jkw2hq7ukasuh5wgazvfwkkzrf0aqk4k0zluzu4rx8wqq8sut0l";
156
+ const text = `Pay with ${invoice}`;
157
+ const matches = Array.from(text.matchAll(Expressions.lightning));
158
+ expect(matches).toHaveLength(1);
159
+ expect(matches[0][1]).toBe(invoice);
160
+ });
161
+ it("should match lightning: prefixed invoices", () => {
162
+ const invoice = "lnbc100n1p5pjxjk9qypqqqdqqxqrrsssp54ttukd5xxy2nmdzf864yjereuf9v3pyzl66hpqgxa0e8fvlzf6aspp5z6twjtwde82ec7wfcqw2m63v48r6fyw78753wxh7zjlvuru7tapsp6c9lq6m4d55u9jkxuqpepdknnzznfu05wl73swyn52z3pnkzyxrlkqf3t5jkw2hq7ukasuh5wgazvfwkkzrf0aqk4k0zluzu4rx8wqq8sut0l";
163
+ const text = `Pay with lightning:${invoice}`;
164
+ const matches = Array.from(text.matchAll(Expressions.lightning));
165
+ expect(matches).toHaveLength(1);
166
+ expect(matches[0][1]).toBe(invoice);
167
+ });
168
+ it("should be case insensitive", () => {
169
+ const invoice = "lnbc100n1p5pjxjk9qypqqqdqqxqrrsssp54ttukd5xxy2nmdzf864yjereuf9v3pyzl66hpqgxa0e8fvlzf6aspp5z6twjtwde82ec7wfcqw2m63v48r6fyw78753wxh7zjlvuru7tapsp6c9lq6m4d55u9jkxuqpepdknnzznfu05wl73swyn52z3pnkzyxrlkqf3t5jkw2hq7ukasuh5wgazvfwkkzrf0aqk4k0zluzu4rx8wqq8sut0l".toUpperCase();
170
+ const text = `Pay with ${invoice}`;
171
+ const matches = Array.from(text.matchAll(Expressions.lightning));
172
+ expect(matches).toHaveLength(1);
173
+ expect(matches[0][1].toUpperCase()).toBe(invoice.toUpperCase());
174
+ });
175
+ });
176
+ });
177
+ describe("Token Regular Expressions", () => {
178
+ describe("Tokens.link", () => {
179
+ it("should match links surrounded by whitespace", () => {
180
+ const text = "Check out https://example.com and https://test.org";
181
+ const matches = Array.from(text.matchAll(Tokens.link));
182
+ expect(matches).toHaveLength(2);
183
+ expect(matches[0][0].trim()).toBe("https://example.com");
184
+ expect(matches[1][0].trim()).toBe("https://test.org");
185
+ });
186
+ it("should match links at the beginning of text", () => {
187
+ const text = "https://example.com is a website";
188
+ const matches = Array.from(text.matchAll(Tokens.link));
189
+ expect(matches).toHaveLength(1);
190
+ expect(matches[0][0].trim()).toBe("https://example.com");
191
+ });
192
+ it("should match links at the end of text", () => {
193
+ const text = "Visit https://example.com";
194
+ const matches = Array.from(text.matchAll(Tokens.link));
195
+ expect(matches).toHaveLength(1);
196
+ expect(matches[0][0].trim()).toBe("https://example.com");
197
+ });
198
+ });
199
+ describe("Tokens.cashu", () => {
200
+ it("should match cashu tokens surrounded by whitespace", () => {
201
+ const token = "cashuAeyJ0b2tlbiI6W3sicHJvb2ZzIjpbeyJpZCI6IjAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAiLCJzZWNyZXQiOiIwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAiLCJDIjoiMDMwZGQwMTQxMGY2ZTIwZjk4YzRkZTlhMDhkOTM5ZDQyMjRkYjUxMzIzZWM1YWM2MThhMzA3NjRjNzJiMDFiMDg2In1dLCJtaW50IjoiaHR0cHM6Ly9leGFtcGxlLmNvbSIsInZhbHVlIjoxfV19";
202
+ const text = `Here is a token: ${token} end`;
203
+ const matches = Array.from(text.matchAll(Tokens.cashu));
204
+ expect(matches).toHaveLength(1);
205
+ expect(matches[0][0].trim()).toBe(token);
206
+ });
207
+ });
208
+ describe("Tokens.nostrLink", () => {
209
+ it("should match nostr links surrounded by whitespace", () => {
210
+ const npub = "npub180cvv07tjdrrgpa0j7j7tmnyl2yr6yr7l8j4s3evf6u64th6gkwsyjh6w6";
211
+ const text = `Check out ${npub} and more`;
212
+ const matches = Array.from(text.matchAll(Tokens.nostrLink));
213
+ expect(matches).toHaveLength(1);
214
+ expect(matches[0][0].trim()).toBe(npub);
215
+ });
216
+ });
217
+ describe("Tokens.emoji", () => {
218
+ it("should match emoji shortcodes surrounded by whitespace", () => {
219
+ const text = "Hello :smile: world :thumbsup: end";
220
+ const matches = Array.from(text.matchAll(Tokens.emoji));
221
+ expect(matches).toHaveLength(2);
222
+ expect(matches[0][0].trim()).toBe(":smile:");
223
+ expect(matches[1][0].trim()).toBe(":thumbsup:");
224
+ });
225
+ });
226
+ describe("Tokens.hashtag", () => {
227
+ it("should match hashtags surrounded by whitespace", () => {
228
+ const text = "Hello #world and #nostr end";
229
+ const matches = Array.from(text.matchAll(Tokens.hashtag));
230
+ expect(matches).toHaveLength(2);
231
+ expect(matches[0][0].trim()).toBe("#world");
232
+ expect(matches[1][0].trim()).toBe("#nostr");
233
+ });
234
+ });
235
+ describe("Tokens.lightning", () => {
236
+ it("should match lightning invoices surrounded by whitespace", () => {
237
+ const invoice = "LNBC1500N1PJQJJ5SPP5FSP3ZZAR0GZPJ9YHKQVSD7CQPGWG4XSULZP4TCG6VYVK63KM5USDQQCQZPGXQYZ5VQSP5USYC4LK9CHSFP53KH0DUDVH0GWDWLWLVJRSZGQTW8QF99XWCPS9QYYSSQJCEWM5CJWZ4A6RFJX77C490YCED6PEMK0UPKXHY89CMM7SCT66K8GNEANWYKZGDRWRFJE69H9U5U0W57RRCSYSAS7GADWMZXC8C6GQPVXHNRC";
238
+ const text = `Pay with ${invoice} now`;
239
+ const matches = Array.from(text.matchAll(Tokens.lightning));
240
+ expect(matches).toHaveLength(1);
241
+ expect(matches[0][0].trim()).toBe(invoice);
242
+ });
243
+ });
244
+ });
@@ -1,8 +1,8 @@
1
1
  import { getSha256FromURL } from "applesauce-core/helpers/file-metadata";
2
- import Expressions from "./regexp.js";
2
+ import { Tokens } from "./regexp.js";
3
3
  /** Returns all URLs in a content string that contain a sha256 hash */
4
4
  export function getMediaAttachmentURLsFromContent(content) {
5
- return (Array.from(content.matchAll(Expressions.link))
5
+ return (Array.from(content.matchAll(Tokens.link))
6
6
  .map((match) => match[0])
7
7
  // filter out invalid URLs
8
8
  .filter((str) => URL.canParse(str))
@@ -6,4 +6,12 @@ export declare const Expressions: {
6
6
  readonly hashtag: RegExp;
7
7
  readonly lightning: RegExp;
8
8
  };
9
- export default Expressions;
9
+ /** A list of Regular Expressions that match tokens surrounded by whitespace to avoid matching in URLs */
10
+ export declare const Tokens: {
11
+ readonly link: RegExp;
12
+ readonly cashu: RegExp;
13
+ readonly nostrLink: RegExp;
14
+ readonly emoji: RegExp;
15
+ readonly hashtag: RegExp;
16
+ readonly lightning: RegExp;
17
+ };
@@ -3,10 +3,10 @@ export const Expressions = {
3
3
  return /https?:\/\/([a-zA-Z0-9\.\-]+\.[a-zA-Z]+(?::\d+)?)([\/\?#][\p{L}\p{N}\p{M}&\.-\/\?=#\-@%\+_,:!~*]*)?/gu;
4
4
  },
5
5
  get cashu() {
6
- return /(cashu(?:A|B)[A-Za-z0-9_-]{100,10000}={0,3})/gi;
6
+ return /(?:cashu:\/{0,2})?(cashu(?:A|B)[A-Za-z0-9_-]{100,10000}={0,3})/gi;
7
7
  },
8
8
  get nostrLink() {
9
- return /nostr:((npub|note|nprofile|nevent|naddr)1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{58,})/gi;
9
+ return /(?:nostr:)?((npub|note|nprofile|nevent|naddr)1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{58,})/gi;
10
10
  },
11
11
  get emoji() {
12
12
  return /:([a-zA-Z0-9_-]+):/gi;
@@ -18,4 +18,24 @@ export const Expressions = {
18
18
  return /(?:lightning:)?(LNBC[A-Za-z0-9]+)/gim;
19
19
  },
20
20
  };
21
- export default Expressions;
21
+ /** A list of Regular Expressions that match tokens surrounded by whitespace to avoid matching in URLs */
22
+ export const Tokens = {
23
+ get link() {
24
+ return new RegExp(`(?<=\\s|^)${Expressions.link.source}(?=\\s|$)`, "gu");
25
+ },
26
+ get cashu() {
27
+ return new RegExp(`(?<=\\s|^)${Expressions.cashu.source}(?=\\s|$)`, "gi");
28
+ },
29
+ get nostrLink() {
30
+ return new RegExp(`(?<=\\s|^)${Expressions.nostrLink.source}(?=\\s|$)`, "gi");
31
+ },
32
+ get emoji() {
33
+ return Expressions.emoji;
34
+ },
35
+ get hashtag() {
36
+ return Expressions.hashtag;
37
+ },
38
+ get lightning() {
39
+ return new RegExp(`(?<=\\s|^)${Expressions.lightning.source}(?=\\s|$)`, "gim");
40
+ },
41
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import * as exports from "../index.js";
3
+ describe("exports", () => {
4
+ it("should export the expected functions", () => {
5
+ expect(Object.keys(exports).sort()).toMatchInlineSnapshot(`
6
+ [
7
+ "remarkNostrMentions",
8
+ ]
9
+ `);
10
+ });
11
+ });
@@ -1,10 +1,10 @@
1
1
  import { findAndReplace } from "mdast-util-find-and-replace";
2
2
  import { decode } from "nostr-tools/nip19";
3
- import Expressions from "../helpers/regexp.js";
3
+ import { Tokens } from "../helpers/regexp.js";
4
4
  export function remarkNostrMentions() {
5
5
  return (tree) => {
6
6
  findAndReplace(tree, [
7
- Expressions.nostrLink,
7
+ Tokens.nostrLink,
8
8
  (_, $1) => {
9
9
  try {
10
10
  return {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import * as exports from "../index.js";
3
+ describe("exports", () => {
4
+ it("should export the expected functions", () => {
5
+ expect(Object.keys(exports).sort()).toMatchInlineSnapshot(`
6
+ [
7
+ "eolMetadata",
8
+ "findAndReplace",
9
+ "truncateContent",
10
+ ]
11
+ `);
12
+ });
13
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import * as exports from "../index.js";
3
+ describe("exports", () => {
4
+ it("should export the expected functions", () => {
5
+ expect(Object.keys(exports).sort()).toMatchInlineSnapshot(`
6
+ [
7
+ "TextNoteContentSymbol",
8
+ "cashuTokens",
9
+ "createTextNoteATS",
10
+ "emojis",
11
+ "galleries",
12
+ "getParsedContent",
13
+ "hashtags",
14
+ "lightningInvoices",
15
+ "links",
16
+ "nostrMentions",
17
+ "removeParsedTextContent",
18
+ "textNoteTransformers",
19
+ ]
20
+ `);
21
+ });
22
+ });
@@ -1,12 +1,12 @@
1
1
  import { getDecodedToken } from "@cashu/cashu-ts";
2
- import Expressions from "../helpers/regexp.js";
2
+ import { Tokens } from "../helpers/regexp.js";
3
3
  import { findAndReplace } from "../nast/find-and-replace.js";
4
4
  /** Parse cashu tokens from an ATS tree */
5
5
  export function cashuTokens() {
6
6
  return (tree) => {
7
7
  findAndReplace(tree, [
8
8
  [
9
- Expressions.cashu,
9
+ Tokens.cashu,
10
10
  (_, $1) => {
11
11
  try {
12
12
  const token = getDecodedToken($1);
@@ -1,5 +1,5 @@
1
1
  import { getEmojiTag } from "applesauce-core/helpers/emoji";
2
- import Expressions from "../helpers/regexp.js";
2
+ import { Tokens } from "../helpers/regexp.js";
3
3
  import { findAndReplace } from "../nast/find-and-replace.js";
4
4
  /** Adds emoji tags to text ATS */
5
5
  export function emojis() {
@@ -9,7 +9,7 @@ export function emojis() {
9
9
  return;
10
10
  findAndReplace(tree, [
11
11
  [
12
- Expressions.emoji,
12
+ Tokens.emoji,
13
13
  (full, $1) => {
14
14
  try {
15
15
  const tag = getEmojiTag(event, $1);
@@ -1,5 +1,5 @@
1
1
  import { getHashtagTag } from "applesauce-core/helpers/hashtag";
2
- import Expressions from "../helpers/regexp.js";
2
+ import { Tokens } from "../helpers/regexp.js";
3
3
  import { findAndReplace } from "../nast/find-and-replace.js";
4
4
  export function hashtags() {
5
5
  return (tree) => {
@@ -8,7 +8,7 @@ export function hashtags() {
8
8
  return;
9
9
  findAndReplace(tree, [
10
10
  [
11
- Expressions.hashtag,
11
+ Tokens.hashtag,
12
12
  (_, $1) => {
13
13
  try {
14
14
  const tag = getHashtagTag(event, $1);
@@ -1,11 +1,11 @@
1
1
  import { parseBolt11 } from "applesauce-core/helpers/bolt11";
2
- import Expressions from "../helpers/regexp.js";
2
+ import { Tokens } from "../helpers/regexp.js";
3
3
  import { findAndReplace } from "../nast/find-and-replace.js";
4
4
  export function lightningInvoices() {
5
5
  return (tree) => {
6
6
  findAndReplace(tree, [
7
7
  [
8
- Expressions.lightning,
8
+ Tokens.lightning,
9
9
  (_, $1) => {
10
10
  try {
11
11
  const invoice = $1;
@@ -1,10 +1,10 @@
1
- import Expressions from "../helpers/regexp.js";
1
+ import { Tokens } from "../helpers/regexp.js";
2
2
  import { findAndReplace } from "../nast/find-and-replace.js";
3
3
  export function links() {
4
4
  return (tree) => {
5
5
  findAndReplace(tree, [
6
6
  [
7
- Expressions.link,
7
+ Tokens.link,
8
8
  (_) => {
9
9
  try {
10
10
  return {
@@ -1,11 +1,11 @@
1
1
  import { decode } from "nostr-tools/nip19";
2
- import Expressions from "../helpers/regexp.js";
2
+ import { Tokens } from "../helpers/regexp.js";
3
3
  import { findAndReplace } from "../nast/find-and-replace.js";
4
4
  export function nostrMentions() {
5
5
  return (tree) => {
6
6
  findAndReplace(tree, [
7
7
  [
8
- Expressions.nostrLink,
8
+ Tokens.nostrLink,
9
9
  (_, $1) => {
10
10
  try {
11
11
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applesauce-content",
3
- "version": "0.12.0",
3
+ "version": "1.2.0",
4
4
  "description": "Unified plugins for processing event content",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -52,7 +52,7 @@
52
52
  "@types/hast": "^3.0.4",
53
53
  "@types/mdast": "^4.0.4",
54
54
  "@types/unist": "^3.0.3",
55
- "applesauce-core": "^0.12.0",
55
+ "applesauce-core": "^1.2.0",
56
56
  "mdast-util-find-and-replace": "^3.0.2",
57
57
  "nostr-tools": "^2.10.4",
58
58
  "remark": "^15.0.1",
@@ -61,8 +61,8 @@
61
61
  "unist-util-visit-parents": "^6.0.1"
62
62
  },
63
63
  "devDependencies": {
64
- "typescript": "^5.7.3",
65
- "vitest": "^3.0.5"
64
+ "typescript": "^5.8.3",
65
+ "vitest": "^3.1.1"
66
66
  },
67
67
  "funding": {
68
68
  "type": "lightning",