applesauce-content 0.10.0 → 0.11.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.
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.js +1 -0
- package/dist/helpers/media.d.ts +3 -0
- package/dist/helpers/media.js +15 -0
- package/package.json +18 -7
package/dist/helpers/index.d.ts
CHANGED
package/dist/helpers/index.js
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getSha256FromURL } from "applesauce-core/helpers/file-metadata";
|
|
2
|
+
import Expressions from "./regexp.js";
|
|
3
|
+
/** Returns all URLs in a content string that contain a sha256 hash */
|
|
4
|
+
export function getMediaAttachmentURLsFromContent(content) {
|
|
5
|
+
return (Array.from(content.matchAll(Expressions.link))
|
|
6
|
+
.map((match) => match[0])
|
|
7
|
+
// filter out invalid URLs
|
|
8
|
+
.filter((str) => URL.canParse(str))
|
|
9
|
+
// convert to URLs
|
|
10
|
+
.map((url) => new URL(url))
|
|
11
|
+
// only keep urls with sha256 hashes in the
|
|
12
|
+
.filter((url) => !!getSha256FromURL(url))
|
|
13
|
+
// convert to media attachments
|
|
14
|
+
.map((url) => ({ url: url.toString(), sha256: getSha256FromURL(url) })));
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "applesauce-content",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Unified plugins for processing event content",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -11,27 +11,38 @@
|
|
|
11
11
|
"author": "hzrd149",
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"files": [
|
|
14
|
-
"dist"
|
|
14
|
+
"dist",
|
|
15
|
+
"applesauce"
|
|
15
16
|
],
|
|
16
17
|
"exports": {
|
|
17
18
|
".": {
|
|
18
19
|
"import": "./dist/index.js",
|
|
20
|
+
"require": "./dist/index.js",
|
|
19
21
|
"types": "./dist/index.d.ts"
|
|
20
22
|
},
|
|
21
23
|
"./helpers": {
|
|
22
24
|
"import": "./dist/helpers/index.js",
|
|
25
|
+
"require": "./dist/helpers/index.js",
|
|
23
26
|
"types": "./dist/helpers/index.d.ts"
|
|
24
27
|
},
|
|
28
|
+
"./helpers/*": {
|
|
29
|
+
"import": "./dist/helpers/*.js",
|
|
30
|
+
"require": "./dist/helpers/*.js",
|
|
31
|
+
"types": "./dist/helpers/*.d.ts"
|
|
32
|
+
},
|
|
25
33
|
"./nast": {
|
|
26
34
|
"import": "./dist/nast/index.js",
|
|
35
|
+
"require": "./dist/nast/index.js",
|
|
27
36
|
"types": "./dist/nast/index.d.ts"
|
|
28
37
|
},
|
|
29
38
|
"./markdown": {
|
|
30
39
|
"import": "./dist/markdown/index.js",
|
|
40
|
+
"require": "./dist/markdown/index.js",
|
|
31
41
|
"types": "./dist/markdown/index.d.ts"
|
|
32
42
|
},
|
|
33
43
|
"./text": {
|
|
34
44
|
"import": "./dist/text/index.js",
|
|
45
|
+
"require": "./dist/text/index.js",
|
|
35
46
|
"types": "./dist/text/index.d.ts"
|
|
36
47
|
}
|
|
37
48
|
},
|
|
@@ -40,17 +51,17 @@
|
|
|
40
51
|
"@types/hast": "^3.0.4",
|
|
41
52
|
"@types/mdast": "^4.0.4",
|
|
42
53
|
"@types/unist": "^3.0.3",
|
|
43
|
-
"applesauce-core": "^0.
|
|
44
|
-
"mdast-util-find-and-replace": "^3.0.
|
|
45
|
-
"nostr-tools": "^2.10.
|
|
54
|
+
"applesauce-core": "^0.11.0",
|
|
55
|
+
"mdast-util-find-and-replace": "^3.0.2",
|
|
56
|
+
"nostr-tools": "^2.10.4",
|
|
46
57
|
"remark": "^15.0.1",
|
|
47
58
|
"remark-parse": "^11.0.0",
|
|
48
59
|
"unified": "^11.0.5",
|
|
49
60
|
"unist-util-visit-parents": "^6.0.1"
|
|
50
61
|
},
|
|
51
62
|
"devDependencies": {
|
|
52
|
-
"typescript": "^5.
|
|
53
|
-
"vitest": "^
|
|
63
|
+
"typescript": "^5.7.3",
|
|
64
|
+
"vitest": "^3.0.5"
|
|
54
65
|
},
|
|
55
66
|
"funding": {
|
|
56
67
|
"type": "lightning",
|