@linkprobe/core 0.1.0 → 0.1.1
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/LICENSE +21 -21
- package/README.md +155 -155
- package/package.json +11 -6
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Hossein Hosseini
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Hossein Hosseini
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,155 +1,155 @@
|
|
|
1
|
-
# @linkprobe/core
|
|
2
|
-
|
|
3
|
-
The framework-agnostic metadata extraction engine for LinkProbe.
|
|
4
|
-
|
|
5
|
-
`@linkprobe/core` provides utilities for extracting and resolving webpage metadata from URLs. It supports Open Graph, Twitter Cards, and standard HTML metadata, making it ideal for building link previews, content cards, social embeds, and metadata-driven experiences.
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
pnpm add @linkprobe/core
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Quick Start
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
import {probe} from "@linkprobe/core";
|
|
17
|
-
|
|
18
|
-
const result = await probe("https://github.com");
|
|
19
|
-
|
|
20
|
-
if (result.status === "success") {
|
|
21
|
-
console.log(result.metadata);
|
|
22
|
-
}
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## Example Response
|
|
26
|
-
|
|
27
|
-
```ts
|
|
28
|
-
{
|
|
29
|
-
status: "success",
|
|
30
|
-
metadata: {
|
|
31
|
-
url: "https://github.com",
|
|
32
|
-
openGraph: {
|
|
33
|
-
title: "GitHub",
|
|
34
|
-
description: "...",
|
|
35
|
-
image: "..."
|
|
36
|
-
},
|
|
37
|
-
twitter: {
|
|
38
|
-
title: "GitHub"
|
|
39
|
-
},
|
|
40
|
-
html: {
|
|
41
|
-
title: "GitHub"
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
page: {
|
|
45
|
-
requestedUrl: "https://github.com",
|
|
46
|
-
finalUrl: "https://github.com",
|
|
47
|
-
contentType: "text/html"
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## Metadata Resolution
|
|
53
|
-
|
|
54
|
-
Metadata may be available from multiple sources.
|
|
55
|
-
|
|
56
|
-
Use `resolveMetadata()` to create a unified representation using customizable priority rules.
|
|
57
|
-
|
|
58
|
-
```ts
|
|
59
|
-
import {probe, resolveMetadata} from "@linkprobe/core";
|
|
60
|
-
|
|
61
|
-
const result = await probe("https://github.com");
|
|
62
|
-
|
|
63
|
-
if (result.status === "success") {
|
|
64
|
-
const metadata = resolveMetadata(result.metadata);
|
|
65
|
-
|
|
66
|
-
console.log(metadata);
|
|
67
|
-
}
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
Example output:
|
|
71
|
-
|
|
72
|
-
```ts
|
|
73
|
-
{
|
|
74
|
-
title: "GitHub",
|
|
75
|
-
description: "...",
|
|
76
|
-
image: "...",
|
|
77
|
-
favicon: "...",
|
|
78
|
-
siteName: "GitHub"
|
|
79
|
-
}
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
## Custom Priorities
|
|
83
|
-
|
|
84
|
-
```ts
|
|
85
|
-
const metadata = resolveMetadata(result.metadata, {
|
|
86
|
-
titlePriority: ["twitter", "openGraph", "html"],
|
|
87
|
-
});
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
## Options
|
|
91
|
-
|
|
92
|
-
### probe(url, options)
|
|
93
|
-
|
|
94
|
-
```ts
|
|
95
|
-
await probe("https://github.com", {
|
|
96
|
-
timeout: 5000,
|
|
97
|
-
});
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
| Option | Type | Description |
|
|
101
|
-
| ------- | ------ | ------------------------------- |
|
|
102
|
-
| timeout | number | Request timeout in milliseconds |
|
|
103
|
-
|
|
104
|
-
## Supported Sources
|
|
105
|
-
|
|
106
|
-
### Open Graph
|
|
107
|
-
|
|
108
|
-
```html
|
|
109
|
-
<meta property="og:title" />
|
|
110
|
-
<meta property="og:description" />
|
|
111
|
-
<meta property="og:image" />
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### Twitter Cards
|
|
115
|
-
|
|
116
|
-
```html
|
|
117
|
-
<meta name="twitter:title" />
|
|
118
|
-
<meta name="twitter:description" />
|
|
119
|
-
<meta name="twitter:image" />
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### HTML Metadata
|
|
123
|
-
|
|
124
|
-
```html
|
|
125
|
-
<title>...</title>
|
|
126
|
-
<meta name="description" />
|
|
127
|
-
<link rel="icon" />
|
|
128
|
-
<link rel="canonical" />
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
## Error Handling
|
|
132
|
-
|
|
133
|
-
```ts
|
|
134
|
-
const result = await probe(url);
|
|
135
|
-
|
|
136
|
-
if (result.status === "failed") {
|
|
137
|
-
console.error(result.error.code, result.error.message);
|
|
138
|
-
}
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
Possible error codes:
|
|
142
|
-
|
|
143
|
-
```txt
|
|
144
|
-
FETCH_FAILED
|
|
145
|
-
TIMEOUT
|
|
146
|
-
UNKNOWN_ERROR
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
## TypeScript
|
|
150
|
-
|
|
151
|
-
All public APIs are fully typed and exported by the package.
|
|
152
|
-
|
|
153
|
-
```ts
|
|
154
|
-
import type {Metadata, ProbeResult, ProbeOptions, ResolvedMetadata} from "@linkprobe/core";
|
|
155
|
-
```
|
|
1
|
+
# @linkprobe/core
|
|
2
|
+
|
|
3
|
+
The framework-agnostic metadata extraction engine for LinkProbe.
|
|
4
|
+
|
|
5
|
+
`@linkprobe/core` provides utilities for extracting and resolving webpage metadata from URLs. It supports Open Graph, Twitter Cards, and standard HTML metadata, making it ideal for building link previews, content cards, social embeds, and metadata-driven experiences.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @linkprobe/core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import {probe} from "@linkprobe/core";
|
|
17
|
+
|
|
18
|
+
const result = await probe("https://github.com");
|
|
19
|
+
|
|
20
|
+
if (result.status === "success") {
|
|
21
|
+
console.log(result.metadata);
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Example Response
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
{
|
|
29
|
+
status: "success",
|
|
30
|
+
metadata: {
|
|
31
|
+
url: "https://github.com",
|
|
32
|
+
openGraph: {
|
|
33
|
+
title: "GitHub",
|
|
34
|
+
description: "...",
|
|
35
|
+
image: "..."
|
|
36
|
+
},
|
|
37
|
+
twitter: {
|
|
38
|
+
title: "GitHub"
|
|
39
|
+
},
|
|
40
|
+
html: {
|
|
41
|
+
title: "GitHub"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
page: {
|
|
45
|
+
requestedUrl: "https://github.com",
|
|
46
|
+
finalUrl: "https://github.com",
|
|
47
|
+
contentType: "text/html"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Metadata Resolution
|
|
53
|
+
|
|
54
|
+
Metadata may be available from multiple sources.
|
|
55
|
+
|
|
56
|
+
Use `resolveMetadata()` to create a unified representation using customizable priority rules.
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import {probe, resolveMetadata} from "@linkprobe/core";
|
|
60
|
+
|
|
61
|
+
const result = await probe("https://github.com");
|
|
62
|
+
|
|
63
|
+
if (result.status === "success") {
|
|
64
|
+
const metadata = resolveMetadata(result.metadata);
|
|
65
|
+
|
|
66
|
+
console.log(metadata);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Example output:
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
{
|
|
74
|
+
title: "GitHub",
|
|
75
|
+
description: "...",
|
|
76
|
+
image: "...",
|
|
77
|
+
favicon: "...",
|
|
78
|
+
siteName: "GitHub"
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Custom Priorities
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
const metadata = resolveMetadata(result.metadata, {
|
|
86
|
+
titlePriority: ["twitter", "openGraph", "html"],
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Options
|
|
91
|
+
|
|
92
|
+
### probe(url, options)
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
await probe("https://github.com", {
|
|
96
|
+
timeout: 5000,
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
| Option | Type | Description |
|
|
101
|
+
| ------- | ------ | ------------------------------- |
|
|
102
|
+
| timeout | number | Request timeout in milliseconds |
|
|
103
|
+
|
|
104
|
+
## Supported Sources
|
|
105
|
+
|
|
106
|
+
### Open Graph
|
|
107
|
+
|
|
108
|
+
```html
|
|
109
|
+
<meta property="og:title" />
|
|
110
|
+
<meta property="og:description" />
|
|
111
|
+
<meta property="og:image" />
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Twitter Cards
|
|
115
|
+
|
|
116
|
+
```html
|
|
117
|
+
<meta name="twitter:title" />
|
|
118
|
+
<meta name="twitter:description" />
|
|
119
|
+
<meta name="twitter:image" />
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### HTML Metadata
|
|
123
|
+
|
|
124
|
+
```html
|
|
125
|
+
<title>...</title>
|
|
126
|
+
<meta name="description" />
|
|
127
|
+
<link rel="icon" />
|
|
128
|
+
<link rel="canonical" />
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Error Handling
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
const result = await probe(url);
|
|
135
|
+
|
|
136
|
+
if (result.status === "failed") {
|
|
137
|
+
console.error(result.error.code, result.error.message);
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Possible error codes:
|
|
142
|
+
|
|
143
|
+
```txt
|
|
144
|
+
FETCH_FAILED
|
|
145
|
+
TIMEOUT
|
|
146
|
+
UNKNOWN_ERROR
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## TypeScript
|
|
150
|
+
|
|
151
|
+
All public APIs are fully typed and exported by the package.
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
import type {Metadata, ProbeResult, ProbeOptions, ResolvedMetadata} from "@linkprobe/core";
|
|
155
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linkprobe/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Core metadata extraction engine for LinkProbe",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -9,16 +9,21 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"license": "MIT",
|
|
12
|
-
"author":
|
|
12
|
+
"author": {
|
|
13
|
+
"name": "Hossein-i",
|
|
14
|
+
"email": "sayhi@hossein-i.ir",
|
|
15
|
+
"url": "https://www.hossein-i.ir"
|
|
16
|
+
},
|
|
13
17
|
"repository": {
|
|
14
18
|
"type": "git",
|
|
15
|
-
"url": "git+https://github.com/
|
|
19
|
+
"url": "git+https://github.com/linkprobe/linkprobe.git",
|
|
16
20
|
"directory": "packages/core"
|
|
17
21
|
},
|
|
18
22
|
"bugs": {
|
|
19
|
-
"url": "https://github.com/
|
|
23
|
+
"url": "https://github.com/linkprobe/linkprobe/issues",
|
|
24
|
+
"email": "sayhi@hossein-i.ir"
|
|
20
25
|
},
|
|
21
|
-
"homepage": "https://github.com/
|
|
26
|
+
"homepage": "https://github.com/linkprobe/linkprobe",
|
|
22
27
|
"dependencies": {
|
|
23
28
|
"cheerio": "^1.2.0"
|
|
24
29
|
},
|
|
@@ -26,7 +31,7 @@
|
|
|
26
31
|
"tsup": "^8.5.1",
|
|
27
32
|
"typescript": "6.0.3",
|
|
28
33
|
"vitest": "^4.1.7",
|
|
29
|
-
"@linkprobe/standard": "0.1.
|
|
34
|
+
"@linkprobe/standard": "0.1.1"
|
|
30
35
|
},
|
|
31
36
|
"publishConfig": {
|
|
32
37
|
"access": "public"
|