applesauce-content 0.0.0-next-20241106104112 → 0.0.0-next-20241108100553
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/helpers/regexp.d.ts +1 -0
- package/dist/helpers/regexp.js +3 -0
- package/dist/nast/types.d.ts +2 -0
- package/dist/text/content.js +2 -1
- package/dist/text/index.d.ts +1 -0
- package/dist/text/index.js +1 -0
- package/dist/text/lightning.d.ts +3 -0
- package/dist/text/lightning.js +25 -0
- package/package.json +2 -2
package/dist/helpers/regexp.d.ts
CHANGED
package/dist/helpers/regexp.js
CHANGED
package/dist/nast/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { EventTemplate, NostrEvent } from "nostr-tools";
|
|
|
2
2
|
import { DecodeResult } from "nostr-tools/nip19";
|
|
3
3
|
import { Node as UnistNode, Parent } from "unist";
|
|
4
4
|
import { type Token } from "@cashu/cashu-ts";
|
|
5
|
+
import { type ParsedInvoice } from "applesauce-core/helpers/bolt11";
|
|
5
6
|
export interface CommonData {
|
|
6
7
|
eol?: boolean;
|
|
7
8
|
}
|
|
@@ -34,6 +35,7 @@ export interface CashuToken extends Node {
|
|
|
34
35
|
export interface LightningInvoice extends Node {
|
|
35
36
|
type: "lightning";
|
|
36
37
|
invoice: string;
|
|
38
|
+
parsed: ParsedInvoice;
|
|
37
39
|
}
|
|
38
40
|
export interface Hashtag extends Node {
|
|
39
41
|
type: "hashtag";
|
package/dist/text/content.js
CHANGED
|
@@ -6,9 +6,10 @@ import { emojis } from "./emoji.js";
|
|
|
6
6
|
import { createTextNoteATS } from "./parser.js";
|
|
7
7
|
import { hashtags } from "./hashtag.js";
|
|
8
8
|
import { galleries } from "./gallery.js";
|
|
9
|
+
import { lightningInvoices } from "./lightning.js";
|
|
9
10
|
export const ParsedTextContentSymbol = Symbol.for("parsed-text-content");
|
|
10
11
|
// default kind 1 transformers
|
|
11
|
-
export const defaultTransformers = [nostrMentions, galleries, emojis, hashtags, cashuTokens];
|
|
12
|
+
export const defaultTransformers = [nostrMentions, galleries, emojis, hashtags, lightningInvoices, cashuTokens];
|
|
12
13
|
/** Parsed and process a note with custom transformers */
|
|
13
14
|
export function getParsedTextContent(event, content, transformers = defaultTransformers) {
|
|
14
15
|
// process strings
|
package/dist/text/index.d.ts
CHANGED
package/dist/text/index.js
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { parseBolt11 } from "applesauce-core/helpers/bolt11";
|
|
2
|
+
import Expressions from "../helpers/regexp.js";
|
|
3
|
+
import { findAndReplace } from "../nast/find-and-replace.js";
|
|
4
|
+
export function lightningInvoices() {
|
|
5
|
+
return (tree) => {
|
|
6
|
+
findAndReplace(tree, [
|
|
7
|
+
[
|
|
8
|
+
Expressions.lightning,
|
|
9
|
+
(_, $1) => {
|
|
10
|
+
try {
|
|
11
|
+
const invoice = $1;
|
|
12
|
+
const parsed = parseBolt11(invoice);
|
|
13
|
+
return {
|
|
14
|
+
type: "lightning",
|
|
15
|
+
invoice,
|
|
16
|
+
parsed,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
catch (error) { }
|
|
20
|
+
return false;
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
]);
|
|
24
|
+
};
|
|
25
|
+
}
|
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-20241108100553",
|
|
4
4
|
"description": "Unified plugins for processing event content",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@types/hast": "^3.0.4",
|
|
41
41
|
"@types/mdast": "^4.0.4",
|
|
42
42
|
"@types/unist": "^3.0.3",
|
|
43
|
-
"applesauce-core": "0.0.0-next-
|
|
43
|
+
"applesauce-core": "0.0.0-next-20241108100553",
|
|
44
44
|
"linkifyjs": "^4.1.3",
|
|
45
45
|
"mdast-util-find-and-replace": "^3.0.1",
|
|
46
46
|
"nostr-tools": "^2.10.1",
|