applesauce-content 0.0.0-next-20250930093922 → 0.0.0-next-20251205152544

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,2 +1 @@
1
- export * from "./regexp.js";
2
1
  export * from "./media.js";
@@ -1,2 +1 @@
1
- export * from "./regexp.js";
2
1
  export * from "./media.js";
@@ -1,3 +1,3 @@
1
- import { MediaAttachment } from "applesauce-core/helpers/file-metadata";
1
+ import { MediaAttachment } from "applesauce-common/helpers/file-metadata";
2
2
  /** Returns all URLs in a content string that contain a sha256 hash */
3
3
  export declare function getMediaAttachmentURLsFromContent(content: string): MediaAttachment[];
@@ -1,5 +1,5 @@
1
- import { getSha256FromURL } from "applesauce-core/helpers/file-metadata";
2
- import { Tokens } from "./regexp.js";
1
+ import { getSha256FromURL } from "applesauce-common/helpers/file-metadata";
2
+ import { Tokens } from "applesauce-core/helpers/regexp";
3
3
  /** Returns all URLs in a content string that contain a sha256 hash */
4
4
  export function getMediaAttachmentURLsFromContent(content) {
5
5
  return (Array.from(content.matchAll(Tokens.link))
@@ -1,6 +1,6 @@
1
+ import { decodePointer } from "applesauce-core/helpers/pointers";
2
+ import { Tokens } from "applesauce-core/helpers/regexp";
1
3
  import { findAndReplace } from "mdast-util-find-and-replace";
2
- import { decode } from "nostr-tools/nip19";
3
- import { Tokens } from "../helpers/regexp.js";
4
4
  export function remarkNostrMentions() {
5
5
  return (tree) => {
6
6
  findAndReplace(tree, [
@@ -9,7 +9,7 @@ export function remarkNostrMentions() {
9
9
  try {
10
10
  return {
11
11
  type: "link",
12
- data: decode($1),
12
+ data: decodePointer($1),
13
13
  children: [],
14
14
  url: "nostr:" + $1,
15
15
  };
@@ -1,7 +1,7 @@
1
1
  import { type Token } from "@cashu/cashu-ts";
2
- import { type DecodeResult } from "applesauce-core/helpers";
3
- import { type ParsedInvoice } from "applesauce-core/helpers/bolt11";
4
- import { type EventTemplate, type NostrEvent } from "nostr-tools";
2
+ import { type ParsedInvoice } from "applesauce-common/helpers/bolt11";
3
+ import { type EventTemplate, type NostrEvent } from "applesauce-core/helpers/event";
4
+ import { type DecodeResult } from "applesauce-core/helpers/pointers";
5
5
  import { type Parent, type Node as UnistNode } from "unist";
6
6
  export interface CommonData {
7
7
  eol?: boolean;
@@ -1,5 +1,5 @@
1
1
  import { getDecodedToken } from "@cashu/cashu-ts";
2
- import { Tokens } from "../helpers/regexp.js";
2
+ import { Tokens } from "applesauce-core/helpers/regexp";
3
3
  import { findAndReplace } from "../nast/find-and-replace.js";
4
4
  /** Parse cashu tokens from an ATS tree */
5
5
  export function cashuTokens() {
@@ -1,5 +1,5 @@
1
1
  import { Transformer } from "unified";
2
- import { EventTemplate, NostrEvent } from "nostr-tools";
2
+ import { EventTemplate, NostrEvent } from "applesauce-core/helpers/event";
3
3
  import { Root } from "../nast/types.js";
4
4
  import { galleries } from "./gallery.js";
5
5
  export declare const TextNoteContentSymbol: unique symbol;
@@ -48,6 +48,5 @@ export function getParsedContent(event, content, transformers = textNoteTransfor
48
48
  });
49
49
  }
50
50
  export function removeParsedTextContent(event) {
51
- // @ts-expect-error
52
- delete event[TextNoteContentSymbol];
51
+ Reflect.deleteProperty(event, TextNoteContentSymbol);
53
52
  }
@@ -1,5 +1,5 @@
1
- import { getEmojiTag } from "applesauce-core/helpers/emoji";
2
- import { Tokens } from "../helpers/regexp.js";
1
+ import { getEmojiTag } from "applesauce-common/helpers/emoji";
2
+ import { Tokens } from "applesauce-core/helpers/regexp";
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() {
@@ -1,5 +1,5 @@
1
- import { getHashtagTag } from "applesauce-core/helpers/hashtag";
2
- import { Tokens } from "../helpers/regexp.js";
1
+ import { getHashtagTag } from "applesauce-common/helpers/hashtag";
2
+ import { Tokens } from "applesauce-core/helpers/regexp";
3
3
  import { findAndReplace } from "../nast/find-and-replace.js";
4
4
  /** Find and create hashtag notes in provided tree */
5
5
  export function hashtags() {
@@ -1,5 +1,5 @@
1
- import { parseBolt11 } from "applesauce-core/helpers/bolt11";
2
- import { Tokens } from "../helpers/regexp.js";
1
+ import { parseBolt11 } from "applesauce-common/helpers/bolt11";
2
+ import { Tokens } from "applesauce-core/helpers/regexp";
3
3
  import { findAndReplace } from "../nast/find-and-replace.js";
4
4
  /** Finds and creates lightning invoice nodes in the tree */
5
5
  export function lightningInvoices() {
@@ -1,4 +1,4 @@
1
- import { Tokens } from "../helpers/regexp.js";
1
+ import { Tokens } from "applesauce-core/helpers";
2
2
  import { findAndReplace } from "../nast/find-and-replace.js";
3
3
  /** Finds and creates web links in the tree */
4
4
  export function links() {
@@ -1,5 +1,5 @@
1
- import { decode } from "nostr-tools/nip19";
2
- import { Tokens } from "../helpers/regexp.js";
1
+ import { decodePointer } from "applesauce-core/helpers/pointers";
2
+ import { Tokens } from "applesauce-core/helpers/regexp";
3
3
  import { findAndReplace } from "../nast/find-and-replace.js";
4
4
  /** Finds and creates NIP-19 nostr mentions in the tree */
5
5
  export function nostrMentions() {
@@ -11,7 +11,7 @@ export function nostrMentions() {
11
11
  try {
12
12
  return {
13
13
  type: "mention",
14
- decoded: decode($1),
14
+ decoded: decodePointer($1),
15
15
  encoded: $1,
16
16
  };
17
17
  }
@@ -1,4 +1,4 @@
1
- import { EventTemplate, NostrEvent } from "nostr-tools";
1
+ import { EventTemplate, NostrEvent } from "applesauce-core/helpers/event";
2
2
  import { Root } from "../nast/types.js";
3
3
  /** Creates a {@link Root} ATS node for a text note */
4
4
  export declare function createEventContentTree(event: NostrEvent | EventTemplate | string, content?: string): Root;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applesauce-content",
3
- "version": "0.0.0-next-20250930093922",
3
+ "version": "0.0.0-next-20251205152544",
4
4
  "description": "Unified plugins for processing event content",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -50,19 +50,19 @@
50
50
  "@types/hast": "^3.0.4",
51
51
  "@types/mdast": "^4.0.4",
52
52
  "@types/unist": "^3.0.3",
53
- "applesauce-core": "0.0.0-next-20250930093922",
53
+ "applesauce-common": "0.0.0-next-20251205152544",
54
+ "applesauce-core": "0.0.0-next-20251205152544",
54
55
  "mdast-util-find-and-replace": "^3.0.2",
55
- "nostr-tools": "~2.17",
56
56
  "remark": "^15.0.1",
57
57
  "remark-parse": "^11.0.0",
58
58
  "unified": "^11.0.5",
59
59
  "unist-util-visit-parents": "^6.0.1"
60
60
  },
61
61
  "devDependencies": {
62
- "applesauce-signers": "0.0.0-next-20250930093922",
62
+ "applesauce-signers": "0.0.0-next-20251205152544",
63
63
  "rimraf": "^6.0.1",
64
64
  "typescript": "^5.8.3",
65
- "vitest": "^3.2.4"
65
+ "vitest": "^4.0.15"
66
66
  },
67
67
  "funding": {
68
68
  "type": "lightning",
@@ -1,19 +0,0 @@
1
- export declare const Expressions: {
2
- readonly url: RegExp;
3
- readonly link: RegExp;
4
- readonly cashu: RegExp;
5
- readonly nostrLink: RegExp;
6
- readonly emoji: RegExp;
7
- readonly hashtag: RegExp;
8
- readonly lightning: RegExp;
9
- };
10
- /** A list of Regular Expressions that match tokens surrounded by whitespace to avoid matching in URLs */
11
- export declare const Tokens: {
12
- readonly url: RegExp;
13
- readonly link: RegExp;
14
- readonly cashu: RegExp;
15
- readonly nostrLink: RegExp;
16
- readonly emoji: RegExp;
17
- readonly hashtag: RegExp;
18
- readonly lightning: RegExp;
19
- };
@@ -1,48 +0,0 @@
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
- },
5
- get link() {
6
- return /https?:\/\/([a-zA-Z0-9\.\-]+\.[a-zA-Z]+(?::\d+)?)([\/\?#][\p{L}\p{N}\p{M}&\.-\/\?=#\-@%\+_,:!~*]*)?/gu;
7
- },
8
- get cashu() {
9
- return /(?:cashu:\/{0,2})?(cashu(?:A|B)[A-Za-z0-9_-]{100,}={0,3})/gi;
10
- },
11
- get nostrLink() {
12
- return /(?:nostr:)?((npub|note|nprofile|nevent|naddr)1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{58,})/gi;
13
- },
14
- get emoji() {
15
- return /:([a-zA-Z0-9_-]+):/gi;
16
- },
17
- get hashtag() {
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;
20
- },
21
- get lightning() {
22
- return /(?:lightning:)?(LNBC[A-Za-z0-9]+)/gim;
23
- },
24
- };
25
- /** A list of Regular Expressions that match tokens surrounded by whitespace to avoid matching in URLs */
26
- export const Tokens = {
27
- get url() {
28
- return Expressions.url;
29
- },
30
- get link() {
31
- return Expressions.link;
32
- },
33
- get cashu() {
34
- return new RegExp(`(?<=^|\\s)${Expressions.cashu.source}`, "gi");
35
- },
36
- get nostrLink() {
37
- return new RegExp(`(?<=^|\\s)${Expressions.nostrLink.source}`, "gi");
38
- },
39
- get emoji() {
40
- return Expressions.emoji;
41
- },
42
- get hashtag() {
43
- return Expressions.hashtag;
44
- },
45
- get lightning() {
46
- return new RegExp(`(?<=^|\\s)${Expressions.lightning.source}`, "gim");
47
- },
48
- };