@stll/chat 0.3.1 → 0.3.5
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/html-to-markdown.js +3 -3
- package/dist/link-detection.d.ts +1 -0
- package/dist/link-detection.js +19 -13
- package/package.json +4 -5
package/dist/html-to-markdown.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { isTag, isText } from "
|
|
1
|
+
import { load } from "@stll/html";
|
|
2
|
+
import { isTag, isText } from "@stll/html/nodes";
|
|
3
3
|
//#region src/html-to-markdown.ts
|
|
4
4
|
const INLINE_ESCAPE = /(?<ch>[\\`*_~[\]<>|])/g;
|
|
5
5
|
const escapeText = (text) => text.replace(INLINE_ESCAPE, "\\$<ch>");
|
|
@@ -210,7 +210,7 @@ const trimTrailingNewlines = (text) => {
|
|
|
210
210
|
*/
|
|
211
211
|
const htmlToMarkdown = (html) => {
|
|
212
212
|
if (!html.trim()) return "";
|
|
213
|
-
const $ =
|
|
213
|
+
const $ = load(html, void 0, false);
|
|
214
214
|
const body = renderChildren($.root().contents().toArray());
|
|
215
215
|
return body ? `${body}\n` : "";
|
|
216
216
|
};
|
package/dist/link-detection.d.ts
CHANGED
package/dist/link-detection.js
CHANGED
|
@@ -5,18 +5,23 @@ const HTTP_SCHEME = /^https?:\/\//iu;
|
|
|
5
5
|
const BARE_HOST_LABEL_START = /^[\p{L}\p{N}]/u;
|
|
6
6
|
const UNSAFE_CHARACTERS = /[\s\p{Cc}\p{Cf}\\]/u;
|
|
7
7
|
const SPECIAL_USE_SUFFIX = /(?:^|\.)(?:localhost|local|internal|invalid|test|example|onion)$/iu;
|
|
8
|
-
const
|
|
9
|
-
"
|
|
8
|
+
const FILE_EXTENSION_TLDS = /* @__PURE__ */ new Set([
|
|
9
|
+
"ai",
|
|
10
|
+
"dot",
|
|
11
|
+
"java",
|
|
12
|
+
"md",
|
|
13
|
+
"mk",
|
|
14
|
+
"mobi",
|
|
10
15
|
"mov",
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
16
|
+
"one",
|
|
17
|
+
"pl",
|
|
18
|
+
"pm",
|
|
19
|
+
"ps",
|
|
20
|
+
"pub",
|
|
21
|
+
"py",
|
|
22
|
+
"rs",
|
|
23
|
+
"sh",
|
|
24
|
+
"zip"
|
|
20
25
|
]);
|
|
21
26
|
const normalizeChatLink = (input) => {
|
|
22
27
|
if (!input || UNSAFE_CHARACTERS.test(input)) return null;
|
|
@@ -32,7 +37,8 @@ const normalizeChatLink = (input) => {
|
|
|
32
37
|
if (!explicit) {
|
|
33
38
|
if (SPECIAL_USE_SUFFIX.test(url.hostname)) return null;
|
|
34
39
|
if (!domain.isIcann || !domain.domain || domain.isIp) return null;
|
|
35
|
-
|
|
40
|
+
const hasPath = url.pathname !== "/" || url.search !== "";
|
|
41
|
+
if (!/^www\./iu.test(input) && !hasPath && domain.publicSuffix && FILE_EXTENSION_TLDS.has(domain.publicSuffix)) return null;
|
|
36
42
|
}
|
|
37
43
|
return {
|
|
38
44
|
href: url.href,
|
|
@@ -66,4 +72,4 @@ const detectChatLinks = (text) => {
|
|
|
66
72
|
return spans;
|
|
67
73
|
};
|
|
68
74
|
//#endregion
|
|
69
|
-
export { detectChatLinks, getChatLinkSite, normalizeChatLink };
|
|
75
|
+
export { FILE_EXTENSION_TLDS, detectChatLinks, getChatLinkSite, normalizeChatLink };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/chat",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "Typed React chat composer, message stream, model selector, and transport runtime primitives.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -90,13 +90,12 @@
|
|
|
90
90
|
},
|
|
91
91
|
"dependencies": {
|
|
92
92
|
"@ag-ui/core": "1.0.3",
|
|
93
|
-
"@stll/ai-catalog": "^0.
|
|
94
|
-
"@stll/
|
|
93
|
+
"@stll/ai-catalog": "^0.10.1",
|
|
94
|
+
"@stll/html": "0.1.0",
|
|
95
|
+
"@stll/ui": "^0.65.0",
|
|
95
96
|
"@tanstack/ai-client": "0.38.0",
|
|
96
97
|
"@types/hast": "^3.0.5",
|
|
97
98
|
"better-result": "3.0.1",
|
|
98
|
-
"cheerio": "^1.2.0",
|
|
99
|
-
"domhandler": "^6.0.1",
|
|
100
99
|
"linkify-it": "6.1.0",
|
|
101
100
|
"tldts": "7.4.19",
|
|
102
101
|
"valibot": "1.5.0",
|