@cloro-dev/response-parser 0.1.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/README.md +195 -0
- package/dist/core/detector.d.ts +17 -0
- package/dist/core/detector.d.ts.map +1 -0
- package/dist/core/parser.d.ts +40 -0
- package/dist/core/parser.d.ts.map +1 -0
- package/dist/core/types.d.ts +35 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/index.d.ts +170 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +2 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/ai-mode.d.ts +10 -0
- package/dist/providers/ai-mode.d.ts.map +1 -0
- package/dist/providers/ai-overview.d.ts +10 -0
- package/dist/providers/ai-overview.d.ts.map +1 -0
- package/dist/providers/base-provider.d.ts +31 -0
- package/dist/providers/base-provider.d.ts.map +1 -0
- package/dist/providers/chatgpt.d.ts +10 -0
- package/dist/providers/chatgpt.d.ts.map +1 -0
- package/dist/providers/copilot.d.ts +10 -0
- package/dist/providers/copilot.d.ts.map +1 -0
- package/dist/providers/gemini.d.ts +10 -0
- package/dist/providers/gemini.d.ts.map +1 -0
- package/dist/providers/perplexity.d.ts +10 -0
- package/dist/providers/perplexity.d.ts.map +1 -0
- package/dist/react/components/AiResponseRenderer.d.ts +24 -0
- package/dist/react/components/AiResponseRenderer.d.ts.map +1 -0
- package/dist/react/components/IframeRenderer.d.ts +12 -0
- package/dist/react/components/IframeRenderer.d.ts.map +1 -0
- package/dist/react/core/detector.d.ts +17 -0
- package/dist/react/core/detector.d.ts.map +1 -0
- package/dist/react/core/parser.d.ts +40 -0
- package/dist/react/core/parser.d.ts.map +1 -0
- package/dist/react/core/types.d.ts +35 -0
- package/dist/react/core/types.d.ts.map +1 -0
- package/dist/react/hooks/useAiResponse.d.ts +19 -0
- package/dist/react/hooks/useAiResponse.d.ts.map +1 -0
- package/dist/react/index.d.ts +87 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.esm.js +11 -0
- package/dist/react/index.esm.js.map +1 -0
- package/dist/react/index.js +11 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/providers/ai-mode.d.ts +10 -0
- package/dist/react/providers/ai-mode.d.ts.map +1 -0
- package/dist/react/providers/ai-overview.d.ts +10 -0
- package/dist/react/providers/ai-overview.d.ts.map +1 -0
- package/dist/react/providers/base-provider.d.ts +31 -0
- package/dist/react/providers/base-provider.d.ts.map +1 -0
- package/dist/react/providers/chatgpt.d.ts +10 -0
- package/dist/react/providers/chatgpt.d.ts.map +1 -0
- package/dist/react/providers/copilot.d.ts +10 -0
- package/dist/react/providers/copilot.d.ts.map +1 -0
- package/dist/react/providers/gemini.d.ts +10 -0
- package/dist/react/providers/gemini.d.ts.map +1 -0
- package/dist/react/providers/perplexity.d.ts +10 -0
- package/dist/react/providers/perplexity.d.ts.map +1 -0
- package/dist/react/react/components/AiResponseRenderer.d.ts +24 -0
- package/dist/react/react/components/AiResponseRenderer.d.ts.map +1 -0
- package/dist/react/react/components/IframeRenderer.d.ts +12 -0
- package/dist/react/react/components/IframeRenderer.d.ts.map +1 -0
- package/dist/react/react/hooks/useAiResponse.d.ts +19 -0
- package/dist/react/react/hooks/useAiResponse.d.ts.map +1 -0
- package/dist/react/react/index.d.ts +7 -0
- package/dist/react/react/index.d.ts.map +1 -0
- package/dist/react/styles/index.d.ts +1 -0
- package/dist/react/styles/index.d.ts.map +1 -0
- package/dist/react/utils/helpers.d.ts +28 -0
- package/dist/react/utils/helpers.d.ts.map +1 -0
- package/dist/styles/index.d.ts +1 -0
- package/dist/styles/index.d.ts.map +1 -0
- package/dist/utils/helpers.d.ts +28 -0
- package/dist/utils/helpers.d.ts.map +1 -0
- package/package.json +85 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface IframeRendererProps {
|
|
3
|
+
html: string;
|
|
4
|
+
className?: string;
|
|
5
|
+
style?: React.CSSProperties;
|
|
6
|
+
sandbox?: string;
|
|
7
|
+
title?: string;
|
|
8
|
+
onLoad?: () => void;
|
|
9
|
+
onError?: () => void;
|
|
10
|
+
}
|
|
11
|
+
export declare const IframeRenderer: React.ForwardRefExoticComponent<IframeRendererProps & React.RefAttributes<HTMLIFrameElement>>;
|
|
12
|
+
//# sourceMappingURL=IframeRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IframeRenderer.d.ts","sourceRoot":"","sources":["../../../src/react/components/IframeRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,eAAO,MAAM,cAAc,+FAmD1B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ParsedResponse, ParseOptions, AIProvider } from '../../index';
|
|
2
|
+
export interface UseAiResponseOptions extends ParseOptions {
|
|
3
|
+
autoDetect?: boolean;
|
|
4
|
+
provider?: AIProvider;
|
|
5
|
+
onProviderDetected?: (provider: AIProvider | null) => void;
|
|
6
|
+
onError?: (error: Error) => void;
|
|
7
|
+
}
|
|
8
|
+
export interface UseAiResponseReturn {
|
|
9
|
+
parsed: ParsedResponse | null;
|
|
10
|
+
provider: AIProvider | null;
|
|
11
|
+
isLoading: boolean;
|
|
12
|
+
error: Error | null;
|
|
13
|
+
html: string | null;
|
|
14
|
+
text: string | null;
|
|
15
|
+
sources: any[] | null;
|
|
16
|
+
reparse: (options?: Partial<UseAiResponseOptions>) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare function useAiResponse(response: any, options?: UseAiResponseOptions): UseAiResponseReturn;
|
|
19
|
+
//# sourceMappingURL=useAiResponse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAiResponse.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useAiResponse.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAExG,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,kBAAkB,CAAC,EAAE,CAAC,QAAQ,EAAE,UAAU,GAAG,IAAI,KAAK,IAAI,CAAC;IAC3D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IAC9B,QAAQ,EAAE,UAAU,GAAG,IAAI,CAAC;IAC5B,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,KAAK,IAAI,CAAC;CAC5D;AAED,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,GAAG,EACb,OAAO,GAAE,oBAAyB,GACjC,mBAAmB,CA8ErB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { AiResponseRenderer, IframeRenderer } from './components/AiResponseRenderer';
|
|
2
|
+
export type { AiResponseRendererProps } from './components/AiResponseRenderer';
|
|
3
|
+
export type { IframeRendererProps } from './components/IframeRenderer';
|
|
4
|
+
export { useAiResponse } from './hooks/useAiResponse';
|
|
5
|
+
export type { UseAiResponseOptions, UseAiResponseReturn } from './hooks/useAiResponse';
|
|
6
|
+
export type { AIProvider, ParsedResponse, ParseOptions, ProviderConfig, DetectedProvider, StyleOptions, ContentExtraction, } from '../core/types';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACrF,YAAY,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC/E,YAAY,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAGvE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAGvF,YAAY,EACV,UAAU,EACV,cAAc,EACd,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,GAClB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/styles/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for AI response parsing
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Check if a string is likely HTML
|
|
6
|
+
*/
|
|
7
|
+
export declare function isLikelyHtml(str: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Extract URLs from text
|
|
10
|
+
*/
|
|
11
|
+
export declare function extractUrls(text: string): string[];
|
|
12
|
+
/**
|
|
13
|
+
* Safely parse JSON with error handling
|
|
14
|
+
*/
|
|
15
|
+
export declare function safeJsonParse<T = any>(str: string, fallback: T): T;
|
|
16
|
+
/**
|
|
17
|
+
* Decode HTML entities
|
|
18
|
+
*/
|
|
19
|
+
export declare function decodeHtmlEntities(str: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Truncate text to a specified length
|
|
22
|
+
*/
|
|
23
|
+
export declare function truncateText(text: string, maxLength: number, suffix?: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Generate a unique ID for rendering
|
|
26
|
+
*/
|
|
27
|
+
export declare function generateId(): string;
|
|
28
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAOjD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAGlD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAMlE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAItD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,SAAQ,GAAG,MAAM,CAGpF;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAEnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/styles/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for AI response parsing
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Check if a string is likely HTML
|
|
6
|
+
*/
|
|
7
|
+
export declare function isLikelyHtml(str: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Extract URLs from text
|
|
10
|
+
*/
|
|
11
|
+
export declare function extractUrls(text: string): string[];
|
|
12
|
+
/**
|
|
13
|
+
* Safely parse JSON with error handling
|
|
14
|
+
*/
|
|
15
|
+
export declare function safeJsonParse<T = any>(str: string, fallback: T): T;
|
|
16
|
+
/**
|
|
17
|
+
* Decode HTML entities
|
|
18
|
+
*/
|
|
19
|
+
export declare function decodeHtmlEntities(str: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Truncate text to a specified length
|
|
22
|
+
*/
|
|
23
|
+
export declare function truncateText(text: string, maxLength: number, suffix?: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Generate a unique ID for rendering
|
|
26
|
+
*/
|
|
27
|
+
export declare function generateId(): string;
|
|
28
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAOjD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAGlD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAMlE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAItD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,SAAQ,GAAG,MAAM,CAGpF;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAEnC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cloro-dev/response-parser",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Parse and render AI model responses from ChatGPT, Gemini, Perplexity, and more",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.esm.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.esm.js",
|
|
12
|
+
"require": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
},
|
|
15
|
+
"./react": {
|
|
16
|
+
"import": "./dist/react/index.esm.js",
|
|
17
|
+
"require": "./dist/react/index.js",
|
|
18
|
+
"types": "./dist/react/index.d.ts"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"README.md"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "rollup -c",
|
|
27
|
+
"dev": "rollup -c -w",
|
|
28
|
+
"test": "jest",
|
|
29
|
+
"test:watch": "jest --watch",
|
|
30
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
31
|
+
"type-check": "tsc --noEmit",
|
|
32
|
+
"prepublishOnly": "npm run build"
|
|
33
|
+
},
|
|
34
|
+
"keywords": [
|
|
35
|
+
"ai",
|
|
36
|
+
"cloro",
|
|
37
|
+
"chatgpt",
|
|
38
|
+
"gemini",
|
|
39
|
+
"perplexity",
|
|
40
|
+
"copilot",
|
|
41
|
+
"html-parser",
|
|
42
|
+
"react",
|
|
43
|
+
"typescript"
|
|
44
|
+
],
|
|
45
|
+
"author": "cloro",
|
|
46
|
+
"license": "MIT",
|
|
47
|
+
"repository": {
|
|
48
|
+
"type": "git",
|
|
49
|
+
"url": "https://github.com/cloro/response-parser.git"
|
|
50
|
+
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"react": ">=16.8.0"
|
|
53
|
+
},
|
|
54
|
+
"peerDependenciesMeta": {
|
|
55
|
+
"react": {
|
|
56
|
+
"optional": true
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
61
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
62
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
63
|
+
"@rollup/plugin-typescript": "^11.1.5",
|
|
64
|
+
"@testing-library/jest-dom": "^6.1.5",
|
|
65
|
+
"@testing-library/react": "^14.1.2",
|
|
66
|
+
"@types/jest": "^29.5.8",
|
|
67
|
+
"@types/react": "^18.2.37",
|
|
68
|
+
"@typescript-eslint/eslint-plugin": "^6.11.0",
|
|
69
|
+
"@typescript-eslint/parser": "^6.11.0",
|
|
70
|
+
"eslint": "^8.54.0",
|
|
71
|
+
"eslint-plugin-react": "^7.33.2",
|
|
72
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
73
|
+
"jest": "^29.7.0",
|
|
74
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
75
|
+
"react": "^18.2.0",
|
|
76
|
+
"rollup": "^4.6.1",
|
|
77
|
+
"rollup-plugin-dts": "^6.1.0",
|
|
78
|
+
"ts-jest": "^29.1.1",
|
|
79
|
+
"tslib": "^2.6.2",
|
|
80
|
+
"typescript": "^5.2.2"
|
|
81
|
+
},
|
|
82
|
+
"publishConfig": {
|
|
83
|
+
"access": "public"
|
|
84
|
+
}
|
|
85
|
+
}
|