applesauce-content 0.0.0-next-20250522030625 → 0.0.0-next-20250606170247
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/__tests__/exports.test.d.ts +1 -0
- package/dist/__tests__/exports.test.js +14 -0
- package/dist/__tests__/fake-user.d.ts +9 -0
- package/dist/__tests__/fake-user.js +23 -0
- package/dist/helpers/__test__/regexp.test.js +21 -0
- package/dist/helpers/regexp.d.ts +2 -0
- package/dist/helpers/regexp.js +12 -5
- package/dist/nast/types.d.ts +2 -1
- package/dist/text/__tests__/exports.test.js +1 -0
- package/dist/text/__tests__/gallery.test.d.ts +1 -0
- package/dist/text/__tests__/gallery.test.js +38 -0
- package/dist/text/__tests__/hashtag.test.d.ts +1 -0
- package/dist/text/__tests__/hashtag.test.js +48 -0
- package/dist/text/content.js +4 -4
- package/dist/text/emoji.d.ts +1 -1
- package/dist/text/emoji.js +1 -1
- package/dist/text/gallery.d.ts +1 -1
- package/dist/text/gallery.js +1 -1
- package/dist/text/hashtag.d.ts +1 -0
- package/dist/text/hashtag.js +5 -5
- package/dist/text/lightning.d.ts +1 -0
- package/dist/text/lightning.js +1 -0
- package/dist/text/links.d.ts +1 -0
- package/dist/text/links.js +1 -0
- package/dist/text/mentions.d.ts +1 -0
- package/dist/text/mentions.js +1 -0
- package/dist/text/parser.d.ts +3 -1
- package/dist/text/parser.js +3 -1
- package/package.json +3 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
"Helpers",
|
|
8
|
+
"Markdown",
|
|
9
|
+
"Nast",
|
|
10
|
+
"Text",
|
|
11
|
+
]
|
|
12
|
+
`);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SimpleSigner } from "applesauce-signers/signers/simple-signer";
|
|
2
|
+
import type { EventTemplate, NostrEvent } from "nostr-tools";
|
|
3
|
+
export declare class FakeUser extends SimpleSigner {
|
|
4
|
+
pubkey: string;
|
|
5
|
+
event(data?: Partial<EventTemplate>): NostrEvent;
|
|
6
|
+
note(content?: string, extra?: Partial<EventTemplate>): import("nostr-tools").Event;
|
|
7
|
+
profile(profile: any, extra?: Partial<EventTemplate>): import("nostr-tools").Event;
|
|
8
|
+
contacts(pubkeys?: string[]): import("nostr-tools").Event;
|
|
9
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { unixNow } from "applesauce-core/helpers";
|
|
2
|
+
import { SimpleSigner } from "applesauce-signers/signers/simple-signer";
|
|
3
|
+
import { finalizeEvent, getPublicKey, kinds } from "nostr-tools";
|
|
4
|
+
export class FakeUser extends SimpleSigner {
|
|
5
|
+
pubkey = getPublicKey(this.key);
|
|
6
|
+
event(data) {
|
|
7
|
+
return finalizeEvent({
|
|
8
|
+
kind: data?.kind ?? kinds.ShortTextNote,
|
|
9
|
+
content: data?.content || "",
|
|
10
|
+
created_at: data?.created_at ?? unixNow(),
|
|
11
|
+
tags: data?.tags || [],
|
|
12
|
+
}, this.key);
|
|
13
|
+
}
|
|
14
|
+
note(content = "Hello World", extra) {
|
|
15
|
+
return this.event({ kind: kinds.ShortTextNote, content, ...extra });
|
|
16
|
+
}
|
|
17
|
+
profile(profile, extra) {
|
|
18
|
+
return this.event({ kind: kinds.Metadata, content: JSON.stringify({ ...profile }), ...extra });
|
|
19
|
+
}
|
|
20
|
+
contacts(pubkeys = []) {
|
|
21
|
+
return this.event({ kind: kinds.Contacts, tags: pubkeys.map((p) => ["p", p]) });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -92,6 +92,17 @@ describe("Regular Expressions", () => {
|
|
|
92
92
|
expect(matches).toHaveLength(1);
|
|
93
93
|
expect(matches[0][1]).toBe("npub180cvv07tjdrrgpa0j7j7tmnyl2yr6yr7l8j4s3evf6u64th6gkwsyjh6w6");
|
|
94
94
|
});
|
|
95
|
+
it("should match nostr links in URLs", () => {
|
|
96
|
+
const text = "https://npub1wyuh3scfgzqmxn709a2fzuemps389rxnk7nfgege6s847zze3tuqfl87ez.nsite.lol/n/nevent1qvzqqqqqqypzp022u0n8u2vkf4y5zu3xrhz989wgna4a9em5vshrvcf8zuwlhq04qyghwumn8ghj7mn0wd68ytnhd9hx2tcppemhxue69uhkummn9ekx7mp0qqsz7ck33xzlpcf2338ufrarks2cxqzk2rp925qe38wvlevhxv9pg6syy7gc7";
|
|
97
|
+
const matches = Array.from(text.matchAll(Expressions.nostrLink));
|
|
98
|
+
expect(matches).toHaveLength(2);
|
|
99
|
+
expect(matches).toEqual([
|
|
100
|
+
expect.arrayContaining(["npub1wyuh3scfgzqmxn709a2fzuemps389rxnk7nfgege6s847zze3tuqfl87ez"]),
|
|
101
|
+
expect.arrayContaining([
|
|
102
|
+
"nevent1qvzqqqqqqypzp022u0n8u2vkf4y5zu3xrhz989wgna4a9em5vshrvcf8zuwlhq04qyghwumn8ghj7mn0wd68ytnhd9hx2tcppemhxue69uhkummn9ekx7mp0qqsz7ck33xzlpcf2338ufrarks2cxqzk2rp925qe38wvlevhxv9pg6syy7gc7",
|
|
103
|
+
]),
|
|
104
|
+
]);
|
|
105
|
+
});
|
|
95
106
|
});
|
|
96
107
|
describe("Expressions.emoji", () => {
|
|
97
108
|
it("should match emoji shortcodes", () => {
|
|
@@ -149,6 +160,11 @@ describe("Regular Expressions", () => {
|
|
|
149
160
|
expect(matches[0][1]).toBe("世界");
|
|
150
161
|
expect(matches[1][1]).toBe("привет");
|
|
151
162
|
});
|
|
163
|
+
it("should not match hashtags in URLs", () => {
|
|
164
|
+
const text = "testing urls wss://relay.damus.io ircs://irc.zeronode.net:6697/#nostr https://github.com/hzrd149/applesauce?tab=readme-ov-file#running-tests";
|
|
165
|
+
const matches = Array.from(text.matchAll(Expressions.hashtag));
|
|
166
|
+
expect(matches).toHaveLength(0);
|
|
167
|
+
});
|
|
152
168
|
});
|
|
153
169
|
describe("Expressions.lightning", () => {
|
|
154
170
|
it("should match lightning invoices", () => {
|
|
@@ -213,6 +229,11 @@ describe("Token Regular Expressions", () => {
|
|
|
213
229
|
expect(matches).toHaveLength(1);
|
|
214
230
|
expect(matches[0][0].trim()).toBe(npub);
|
|
215
231
|
});
|
|
232
|
+
it("should not match links in URLs", async () => {
|
|
233
|
+
const text = "Checkout my app https://zap.stream/naddr1qqjx2wtzx93rycmz94nrqvf3956rqep3943xgvec956xxvnxxucxze33v93rvq3qeaz6dwsnvwkha5sn5puwwyxjgy26uusundrm684lg3vw4ma5c2jsxpqqqpmxw6td7rf";
|
|
234
|
+
const matches = Array.from(text.matchAll(Tokens.nostrLink));
|
|
235
|
+
expect(matches).toHaveLength(0);
|
|
236
|
+
});
|
|
216
237
|
});
|
|
217
238
|
describe("Tokens.emoji", () => {
|
|
218
239
|
it("should match emoji shortcodes surrounded by whitespace", () => {
|
package/dist/helpers/regexp.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const Expressions: {
|
|
2
|
+
readonly url: RegExp;
|
|
2
3
|
readonly link: RegExp;
|
|
3
4
|
readonly cashu: RegExp;
|
|
4
5
|
readonly nostrLink: RegExp;
|
|
@@ -8,6 +9,7 @@ export declare const Expressions: {
|
|
|
8
9
|
};
|
|
9
10
|
/** A list of Regular Expressions that match tokens surrounded by whitespace to avoid matching in URLs */
|
|
10
11
|
export declare const Tokens: {
|
|
12
|
+
readonly url: RegExp;
|
|
11
13
|
readonly link: RegExp;
|
|
12
14
|
readonly cashu: RegExp;
|
|
13
15
|
readonly nostrLink: RegExp;
|
package/dist/helpers/regexp.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export const Expressions = {
|
|
2
|
+
get url() {
|
|
3
|
+
return /(?:https?|wss?|ircs?|s?ftp):\/\/([a-zA-Z0-9\.\-]+\.[a-zA-Z]+(?::\d+)?)([\/\?#][\p{L}\p{N}\p{M}&\.-\/\?=#\-@%\+_,:!~*]*)?/gu;
|
|
4
|
+
},
|
|
2
5
|
get link() {
|
|
3
6
|
return /https?:\/\/([a-zA-Z0-9\.\-]+\.[a-zA-Z]+(?::\d+)?)([\/\?#][\p{L}\p{N}\p{M}&\.-\/\?=#\-@%\+_,:!~*]*)?/gu;
|
|
4
7
|
},
|
|
@@ -12,7 +15,8 @@ export const Expressions = {
|
|
|
12
15
|
return /:([a-zA-Z0-9_-]+):/gi;
|
|
13
16
|
},
|
|
14
17
|
get hashtag() {
|
|
15
|
-
|
|
18
|
+
// NOTE: cant use \b here because it uses \w which only matches latin letters
|
|
19
|
+
return /(?<=^|[^\p{L}#\/])#([\p{L}\p{N}\p{M}]+)(?=\p{Z}|$|\s)/gu;
|
|
16
20
|
},
|
|
17
21
|
get lightning() {
|
|
18
22
|
return /(?:lightning:)?(LNBC[A-Za-z0-9]+)/gim;
|
|
@@ -20,14 +24,17 @@ export const Expressions = {
|
|
|
20
24
|
};
|
|
21
25
|
/** A list of Regular Expressions that match tokens surrounded by whitespace to avoid matching in URLs */
|
|
22
26
|
export const Tokens = {
|
|
27
|
+
get url() {
|
|
28
|
+
return Expressions.url;
|
|
29
|
+
},
|
|
23
30
|
get link() {
|
|
24
|
-
return
|
|
31
|
+
return Expressions.link;
|
|
25
32
|
},
|
|
26
33
|
get cashu() {
|
|
27
|
-
return new RegExp(
|
|
34
|
+
return new RegExp(`(?<=^|\\s)${Expressions.cashu.source}`, "gi");
|
|
28
35
|
},
|
|
29
36
|
get nostrLink() {
|
|
30
|
-
return new RegExp(
|
|
37
|
+
return new RegExp(`(?<=^|\\s)${Expressions.nostrLink.source}`, "gi");
|
|
31
38
|
},
|
|
32
39
|
get emoji() {
|
|
33
40
|
return Expressions.emoji;
|
|
@@ -36,6 +43,6 @@ export const Tokens = {
|
|
|
36
43
|
return Expressions.hashtag;
|
|
37
44
|
},
|
|
38
45
|
get lightning() {
|
|
39
|
-
return new RegExp(
|
|
46
|
+
return new RegExp(`(?<=^|\\s)${Expressions.lightning.source}`, "gim");
|
|
40
47
|
},
|
|
41
48
|
};
|
package/dist/nast/types.d.ts
CHANGED
|
@@ -43,7 +43,8 @@ export interface Hashtag extends Node {
|
|
|
43
43
|
name: string;
|
|
44
44
|
/** The lowercase canonical name */
|
|
45
45
|
hashtag: string;
|
|
46
|
-
tag
|
|
46
|
+
/** The indexable tag for the hashtag. will be undefined if none was found */
|
|
47
|
+
tag?: ["t", ...string[]];
|
|
47
48
|
}
|
|
48
49
|
export interface Emoji extends Node {
|
|
49
50
|
type: "emoji";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { getParsedContent } from "../content.js";
|
|
3
|
+
import { galleries } from "../gallery.js";
|
|
4
|
+
import { links } from "../links.js";
|
|
5
|
+
describe("gallery", () => {
|
|
6
|
+
it("should group image urls into galleries", () => {
|
|
7
|
+
expect(getParsedContent("Hello https://example.com/image.png https://example.com/image2.png", undefined, [
|
|
8
|
+
links,
|
|
9
|
+
galleries,
|
|
10
|
+
]).children).toEqual([
|
|
11
|
+
expect.objectContaining({ type: "text" }),
|
|
12
|
+
expect.objectContaining({
|
|
13
|
+
type: "gallery",
|
|
14
|
+
links: ["https://example.com/image.png", "https://example.com/image2.png"],
|
|
15
|
+
}),
|
|
16
|
+
]);
|
|
17
|
+
});
|
|
18
|
+
it("should not match a single image link", () => {
|
|
19
|
+
expect(getParsedContent("Hello https://example.com/image.png", undefined, [links, galleries]).children).toEqual([
|
|
20
|
+
expect.objectContaining({ type: "text" }),
|
|
21
|
+
expect.objectContaining({ type: "link" }),
|
|
22
|
+
]);
|
|
23
|
+
});
|
|
24
|
+
it("should match multiple galleries", () => {
|
|
25
|
+
expect(getParsedContent("Hello https://example.com/image.png\nhttps://example.com/image2.png\n\nAnd here are the other images https://example.com/image3.png\n\nhttps://example.com/image4.png", undefined, [links, galleries]).children).toEqual([
|
|
26
|
+
expect.objectContaining({ type: "text" }),
|
|
27
|
+
expect.objectContaining({
|
|
28
|
+
type: "gallery",
|
|
29
|
+
links: ["https://example.com/image.png", "https://example.com/image2.png"],
|
|
30
|
+
}),
|
|
31
|
+
expect.objectContaining({ type: "text" }),
|
|
32
|
+
expect.objectContaining({
|
|
33
|
+
type: "gallery",
|
|
34
|
+
links: ["https://example.com/image3.png", "https://example.com/image4.png"],
|
|
35
|
+
}),
|
|
36
|
+
]);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { getParsedContent } from "../content.js";
|
|
3
|
+
import { hashtags } from "../hashtag.js";
|
|
4
|
+
import { FakeUser } from "../../__tests__/fake-user.js";
|
|
5
|
+
const user = new FakeUser();
|
|
6
|
+
describe("hashtags", () => {
|
|
7
|
+
it("should match all hashtags if event is missing", () => {
|
|
8
|
+
expect(getParsedContent("Hello #hashtag", undefined, [hashtags]).children).toMatchInlineSnapshot(`
|
|
9
|
+
[
|
|
10
|
+
{
|
|
11
|
+
"type": "text",
|
|
12
|
+
"value": "Hello ",
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"hashtag": "hashtag",
|
|
16
|
+
"name": "hashtag",
|
|
17
|
+
"tag": undefined,
|
|
18
|
+
"type": "hashtag",
|
|
19
|
+
},
|
|
20
|
+
]
|
|
21
|
+
`);
|
|
22
|
+
});
|
|
23
|
+
describe("with event", () => {
|
|
24
|
+
it("should match all hashtags", () => {
|
|
25
|
+
expect(getParsedContent(user.event({ content: "Hello #hashtag", tags: [["t", "hashtag"]] }), undefined, [hashtags])
|
|
26
|
+
.children).toMatchInlineSnapshot(`
|
|
27
|
+
[
|
|
28
|
+
{
|
|
29
|
+
"type": "text",
|
|
30
|
+
"value": "Hello ",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"hashtag": "hashtag",
|
|
34
|
+
"name": "hashtag",
|
|
35
|
+
"tag": [
|
|
36
|
+
"t",
|
|
37
|
+
"hashtag",
|
|
38
|
+
],
|
|
39
|
+
"type": "hashtag",
|
|
40
|
+
},
|
|
41
|
+
]
|
|
42
|
+
`);
|
|
43
|
+
});
|
|
44
|
+
it("should not match hashtags with missing t tags", () => {
|
|
45
|
+
expect(getParsedContent(user.event({ content: "Hello #hashtag", tags: [] }), undefined, [hashtags]).children).not.toEqual(expect.arrayContaining([expect.objectContaining({ type: "hashtag" })]));
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
});
|
package/dist/text/content.js
CHANGED
|
@@ -3,7 +3,7 @@ import { getOrComputeCachedValue } from "applesauce-core/helpers/cache";
|
|
|
3
3
|
import { nostrMentions } from "./mentions.js";
|
|
4
4
|
import { cashuTokens } from "./cashu.js";
|
|
5
5
|
import { emojis } from "./emoji.js";
|
|
6
|
-
import {
|
|
6
|
+
import { createEventContentTree } from "./parser.js";
|
|
7
7
|
import { hashtags } from "./hashtag.js";
|
|
8
8
|
import { galleries } from "./gallery.js";
|
|
9
9
|
import { lightningInvoices } from "./lightning.js";
|
|
@@ -29,7 +29,7 @@ export function getParsedContent(event, content, transformers = textNoteTransfor
|
|
|
29
29
|
for (const transformer of transformers) {
|
|
30
30
|
processor.use(transformer);
|
|
31
31
|
}
|
|
32
|
-
return processor.runSync(
|
|
32
|
+
return processor.runSync(createEventContentTree(event, content));
|
|
33
33
|
}
|
|
34
34
|
// no caching
|
|
35
35
|
if (!cacheKey) {
|
|
@@ -37,14 +37,14 @@ export function getParsedContent(event, content, transformers = textNoteTransfor
|
|
|
37
37
|
for (const transformer of transformers) {
|
|
38
38
|
processor.use(transformer);
|
|
39
39
|
}
|
|
40
|
-
return processor.runSync(
|
|
40
|
+
return processor.runSync(createEventContentTree(event, content));
|
|
41
41
|
}
|
|
42
42
|
return getOrComputeCachedValue(event, cacheKey, () => {
|
|
43
43
|
const processor = unified();
|
|
44
44
|
for (const transformer of transformers) {
|
|
45
45
|
processor.use(transformer);
|
|
46
46
|
}
|
|
47
|
-
return processor.runSync(
|
|
47
|
+
return processor.runSync(createEventContentTree(event, content));
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
export function removeParsedTextContent(event) {
|
package/dist/text/emoji.d.ts
CHANGED
package/dist/text/emoji.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getEmojiTag } from "applesauce-core/helpers/emoji";
|
|
2
2
|
import { Tokens } from "../helpers/regexp.js";
|
|
3
3
|
import { findAndReplace } from "../nast/find-and-replace.js";
|
|
4
|
-
/**
|
|
4
|
+
/** Finds and creates emoji nodes in the tree */
|
|
5
5
|
export function emojis() {
|
|
6
6
|
return (tree) => {
|
|
7
7
|
const event = tree.event;
|
package/dist/text/gallery.d.ts
CHANGED
package/dist/text/gallery.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { convertToUrl, getURLFilename, IMAGE_EXT } from "applesauce-core/helpers/url";
|
|
2
|
-
/**
|
|
2
|
+
/** Group images into galleries in an ATS tree */
|
|
3
3
|
export function galleries(types = IMAGE_EXT) {
|
|
4
4
|
return (tree) => {
|
|
5
5
|
let links = [];
|
package/dist/text/hashtag.d.ts
CHANGED
package/dist/text/hashtag.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { getHashtagTag } from "applesauce-core/helpers/hashtag";
|
|
2
2
|
import { Tokens } from "../helpers/regexp.js";
|
|
3
3
|
import { findAndReplace } from "../nast/find-and-replace.js";
|
|
4
|
+
/** Find and create hashtag notes in provided tree */
|
|
4
5
|
export function hashtags() {
|
|
5
6
|
return (tree) => {
|
|
6
7
|
const event = tree.event;
|
|
7
|
-
if (!event)
|
|
8
|
-
return;
|
|
9
8
|
findAndReplace(tree, [
|
|
10
9
|
[
|
|
11
10
|
Tokens.hashtag,
|
|
12
11
|
(_, $1) => {
|
|
13
12
|
try {
|
|
14
|
-
const tag = getHashtagTag(event, $1);
|
|
15
|
-
if
|
|
13
|
+
const tag = event && getHashtagTag(event, $1);
|
|
14
|
+
// Skip if the match if no tag was found in the event
|
|
15
|
+
if (!tag && event)
|
|
16
16
|
return false;
|
|
17
17
|
return {
|
|
18
18
|
type: "hashtag",
|
|
19
19
|
tag,
|
|
20
20
|
name: $1,
|
|
21
|
-
hashtag: tag[1].toLowerCase(),
|
|
21
|
+
hashtag: tag?.[1].toLowerCase() || $1.toLowerCase(),
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
catch (error) { }
|
package/dist/text/lightning.d.ts
CHANGED
package/dist/text/lightning.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { parseBolt11 } from "applesauce-core/helpers/bolt11";
|
|
2
2
|
import { Tokens } from "../helpers/regexp.js";
|
|
3
3
|
import { findAndReplace } from "../nast/find-and-replace.js";
|
|
4
|
+
/** Finds and creates lightning invoice nodes in the tree */
|
|
4
5
|
export function lightningInvoices() {
|
|
5
6
|
return (tree) => {
|
|
6
7
|
findAndReplace(tree, [
|
package/dist/text/links.d.ts
CHANGED
package/dist/text/links.js
CHANGED
package/dist/text/mentions.d.ts
CHANGED
package/dist/text/mentions.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { decode } from "nostr-tools/nip19";
|
|
2
2
|
import { Tokens } from "../helpers/regexp.js";
|
|
3
3
|
import { findAndReplace } from "../nast/find-and-replace.js";
|
|
4
|
+
/** Finds and creates NIP-19 nostr mentions in the tree */
|
|
4
5
|
export function nostrMentions() {
|
|
5
6
|
return (tree) => {
|
|
6
7
|
findAndReplace(tree, [
|
package/dist/text/parser.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { EventTemplate, NostrEvent } from "nostr-tools";
|
|
2
2
|
import { Root } from "../nast/types.js";
|
|
3
3
|
/** Creates a {@link Root} ATS node for a text note */
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function createEventContentTree(event: NostrEvent | EventTemplate | string, content?: string): Root;
|
|
5
|
+
/** @deprecated use createEventContentTree instead */
|
|
6
|
+
export declare const createTextNoteATS: typeof createEventContentTree;
|
package/dist/text/parser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Creates a {@link Root} ATS node for a text note */
|
|
2
|
-
export function
|
|
2
|
+
export function createEventContentTree(event, content) {
|
|
3
3
|
return {
|
|
4
4
|
type: "root",
|
|
5
5
|
event: typeof event !== "string" ? event : undefined,
|
|
@@ -11,3 +11,5 @@ export function createTextNoteATS(event, content) {
|
|
|
11
11
|
],
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
+
/** @deprecated use createEventContentTree instead */
|
|
15
|
+
export const createTextNoteATS = createEventContentTree;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "applesauce-content",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20250606170247",
|
|
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.0.0-next-
|
|
55
|
+
"applesauce-core": "0.0.0-next-20250606170247",
|
|
56
56
|
"mdast-util-find-and-replace": "^3.0.2",
|
|
57
57
|
"nostr-tools": "^2.13",
|
|
58
58
|
"remark": "^15.0.1",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"typescript": "^5.8.3",
|
|
65
|
+
"applesauce-signers": "0.0.0-next-20250606170247",
|
|
65
66
|
"vitest": "^3.1.1"
|
|
66
67
|
},
|
|
67
68
|
"funding": {
|