@neeleshyadav/react-native-html-renderer 1.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/LICENSE +20 -0
- package/README.md +407 -0
- package/lib/module/HtmlRenderer.js +183 -0
- package/lib/module/HtmlRenderer.js.map +1 -0
- package/lib/module/context/index.js +32 -0
- package/lib/module/context/index.js.map +1 -0
- package/lib/module/hooks/index.js +6 -0
- package/lib/module/hooks/index.js.map +1 -0
- package/lib/module/hooks/useContentWidth.js +12 -0
- package/lib/module/hooks/useContentWidth.js.map +1 -0
- package/lib/module/hooks/useHtmlParser.js +16 -0
- package/lib/module/hooks/useHtmlParser.js.map +1 -0
- package/lib/module/hooks/useTagStyle.js +26 -0
- package/lib/module/hooks/useTagStyle.js.map +1 -0
- package/lib/module/index.js +23 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/parser/index.js +62 -0
- package/lib/module/parser/index.js.map +1 -0
- package/lib/module/renderer/ErrorBoundary.js +66 -0
- package/lib/module/renderer/ErrorBoundary.js.map +1 -0
- package/lib/module/renderer/NodeRenderer.js +279 -0
- package/lib/module/renderer/NodeRenderer.js.map +1 -0
- package/lib/module/renderer/index.js +5 -0
- package/lib/module/renderer/index.js.map +1 -0
- package/lib/module/renderer/tags/BlockTags.js +28 -0
- package/lib/module/renderer/tags/BlockTags.js.map +1 -0
- package/lib/module/renderer/tags/FormTags.js +129 -0
- package/lib/module/renderer/tags/FormTags.js.map +1 -0
- package/lib/module/renderer/tags/ImageTag.js +163 -0
- package/lib/module/renderer/tags/ImageTag.js.map +1 -0
- package/lib/module/renderer/tags/LinkTag.js +50 -0
- package/lib/module/renderer/tags/LinkTag.js.map +1 -0
- package/lib/module/renderer/tags/ListTags.js +96 -0
- package/lib/module/renderer/tags/ListTags.js.map +1 -0
- package/lib/module/renderer/tags/MediaTags.js +69 -0
- package/lib/module/renderer/tags/MediaTags.js.map +1 -0
- package/lib/module/renderer/tags/TableTags.js +48 -0
- package/lib/module/renderer/tags/TableTags.js.map +1 -0
- package/lib/module/renderer/tags/TextTags.js +87 -0
- package/lib/module/renderer/tags/TextTags.js.map +1 -0
- package/lib/module/renderer/tags/index.js +11 -0
- package/lib/module/renderer/tags/index.js.map +1 -0
- package/lib/module/styles/cssToRn.js +34 -0
- package/lib/module/styles/cssToRn.js.map +1 -0
- package/lib/module/styles/darkModeStyles.js +81 -0
- package/lib/module/styles/darkModeStyles.js.map +1 -0
- package/lib/module/styles/defaultStyles.js +218 -0
- package/lib/module/styles/defaultStyles.js.map +1 -0
- package/lib/module/styles/index.js +7 -0
- package/lib/module/styles/index.js.map +1 -0
- package/lib/module/styles/mergeStyles.js +47 -0
- package/lib/module/styles/mergeStyles.js.map +1 -0
- package/lib/module/types/index.js +4 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/utils/accessibility.js +108 -0
- package/lib/module/utils/accessibility.js.map +1 -0
- package/lib/module/utils/cache.js +69 -0
- package/lib/module/utils/cache.js.map +1 -0
- package/lib/module/utils/index.js +95 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/module/utils/sanitize.js +102 -0
- package/lib/module/utils/sanitize.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/HtmlRenderer.d.ts +15 -0
- package/lib/typescript/src/HtmlRenderer.d.ts.map +1 -0
- package/lib/typescript/src/context/index.d.ts +5 -0
- package/lib/typescript/src/context/index.d.ts.map +1 -0
- package/lib/typescript/src/hooks/index.d.ts +4 -0
- package/lib/typescript/src/hooks/index.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useContentWidth.d.ts +6 -0
- package/lib/typescript/src/hooks/useContentWidth.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useHtmlParser.d.ts +11 -0
- package/lib/typescript/src/hooks/useHtmlParser.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useTagStyle.d.ts +11 -0
- package/lib/typescript/src/hooks/useTagStyle.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +9 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/parser/index.d.ts +10 -0
- package/lib/typescript/src/parser/index.d.ts.map +1 -0
- package/lib/typescript/src/renderer/ErrorBoundary.d.ts +22 -0
- package/lib/typescript/src/renderer/ErrorBoundary.d.ts.map +1 -0
- package/lib/typescript/src/renderer/NodeRenderer.d.ts +7 -0
- package/lib/typescript/src/renderer/NodeRenderer.d.ts.map +1 -0
- package/lib/typescript/src/renderer/index.d.ts +3 -0
- package/lib/typescript/src/renderer/index.d.ts.map +1 -0
- package/lib/typescript/src/renderer/tags/BlockTags.d.ts +18 -0
- package/lib/typescript/src/renderer/tags/BlockTags.d.ts.map +1 -0
- package/lib/typescript/src/renderer/tags/FormTags.d.ts +16 -0
- package/lib/typescript/src/renderer/tags/FormTags.d.ts.map +1 -0
- package/lib/typescript/src/renderer/tags/ImageTag.d.ts +18 -0
- package/lib/typescript/src/renderer/tags/ImageTag.d.ts.map +1 -0
- package/lib/typescript/src/renderer/tags/LinkTag.d.ts +19 -0
- package/lib/typescript/src/renderer/tags/LinkTag.d.ts.map +1 -0
- package/lib/typescript/src/renderer/tags/ListTags.d.ts +15 -0
- package/lib/typescript/src/renderer/tags/ListTags.d.ts.map +1 -0
- package/lib/typescript/src/renderer/tags/MediaTags.d.ts +14 -0
- package/lib/typescript/src/renderer/tags/MediaTags.d.ts.map +1 -0
- package/lib/typescript/src/renderer/tags/TableTags.d.ts +15 -0
- package/lib/typescript/src/renderer/tags/TableTags.d.ts.map +1 -0
- package/lib/typescript/src/renderer/tags/TextTags.d.ts +22 -0
- package/lib/typescript/src/renderer/tags/TextTags.d.ts.map +1 -0
- package/lib/typescript/src/renderer/tags/index.d.ts +9 -0
- package/lib/typescript/src/renderer/tags/index.d.ts.map +1 -0
- package/lib/typescript/src/styles/cssToRn.d.ts +11 -0
- package/lib/typescript/src/styles/cssToRn.d.ts.map +1 -0
- package/lib/typescript/src/styles/darkModeStyles.d.ts +7 -0
- package/lib/typescript/src/styles/darkModeStyles.d.ts.map +1 -0
- package/lib/typescript/src/styles/defaultStyles.d.ts +8 -0
- package/lib/typescript/src/styles/defaultStyles.d.ts.map +1 -0
- package/lib/typescript/src/styles/index.d.ts +5 -0
- package/lib/typescript/src/styles/index.d.ts.map +1 -0
- package/lib/typescript/src/styles/mergeStyles.d.ts +10 -0
- package/lib/typescript/src/styles/mergeStyles.d.ts.map +1 -0
- package/lib/typescript/src/types/index.d.ts +158 -0
- package/lib/typescript/src/types/index.d.ts.map +1 -0
- package/lib/typescript/src/utils/accessibility.d.ts +32 -0
- package/lib/typescript/src/utils/accessibility.d.ts.map +1 -0
- package/lib/typescript/src/utils/cache.d.ts +24 -0
- package/lib/typescript/src/utils/cache.d.ts.map +1 -0
- package/lib/typescript/src/utils/index.d.ts +33 -0
- package/lib/typescript/src/utils/index.d.ts.map +1 -0
- package/lib/typescript/src/utils/sanitize.d.ts +11 -0
- package/lib/typescript/src/utils/sanitize.d.ts.map +1 -0
- package/package.json +171 -0
- package/src/HtmlRenderer.tsx +216 -0
- package/src/context/index.tsx +30 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useContentWidth.ts +9 -0
- package/src/hooks/useHtmlParser.ts +18 -0
- package/src/hooks/useTagStyle.ts +23 -0
- package/src/index.tsx +39 -0
- package/src/parser/index.ts +80 -0
- package/src/renderer/ErrorBoundary.tsx +80 -0
- package/src/renderer/NodeRenderer.tsx +345 -0
- package/src/renderer/index.tsx +2 -0
- package/src/renderer/tags/BlockTags.tsx +49 -0
- package/src/renderer/tags/FormTags.tsx +169 -0
- package/src/renderer/tags/ImageTag.tsx +215 -0
- package/src/renderer/tags/LinkTag.tsx +76 -0
- package/src/renderer/tags/ListTags.tsx +148 -0
- package/src/renderer/tags/MediaTags.tsx +81 -0
- package/src/renderer/tags/TableTags.tsx +94 -0
- package/src/renderer/tags/TextTags.tsx +139 -0
- package/src/renderer/tags/index.ts +8 -0
- package/src/styles/cssToRn.ts +45 -0
- package/src/styles/darkModeStyles.ts +80 -0
- package/src/styles/defaultStyles.ts +176 -0
- package/src/styles/index.ts +4 -0
- package/src/styles/mergeStyles.ts +59 -0
- package/src/types/index.ts +229 -0
- package/src/utils/accessibility.ts +132 -0
- package/src/utils/cache.ts +83 -0
- package/src/utils/index.ts +151 -0
- package/src/utils/sanitize.ts +149 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useHtmlRendererContext","useContentWidth","contentWidth"],"sourceRoot":"../../../src","sources":["hooks/useContentWidth.ts"],"mappings":";;AAAA,SAASA,sBAAsB,QAAQ,qBAAY;;AAEnD;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAAA,EAAW;EACxC,OAAOD,sBAAsB,CAAC,CAAC,CAACE,YAAY;AAC9C","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { parseHTML } from "../parser/index.js";
|
|
5
|
+
/**
|
|
6
|
+
* Hook that parses an HTML string into a DOM tree.
|
|
7
|
+
* The result is memoized and only recomputed when `html` or `ignoredTags` change.
|
|
8
|
+
*
|
|
9
|
+
* @param html - Raw HTML string.
|
|
10
|
+
* @param ignoredTags - Optional set of tag names to skip.
|
|
11
|
+
* @returns Array of parsed DOMNode objects.
|
|
12
|
+
*/
|
|
13
|
+
export function useHtmlParser(html, ignoredTags) {
|
|
14
|
+
return useMemo(() => parseHTML(html, ignoredTags), [html, ignoredTags]);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=useHtmlParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useMemo","parseHTML","useHtmlParser","html","ignoredTags"],"sourceRoot":"../../../src","sources":["hooks/useHtmlParser.ts"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,SAAS,QAAQ,oBAAW;AAGrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAC3BC,IAAY,EACZC,WAAyB,EACd;EACX,OAAOJ,OAAO,CAAC,MAAMC,SAAS,CAACE,IAAI,EAAEC,WAAW,CAAC,EAAE,CAACD,IAAI,EAAEC,WAAW,CAAC,CAAC;AACzE","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { useHtmlRendererContext } from "../context/index.js";
|
|
5
|
+
import { getDefaultTagStyles } from "../styles/index.js";
|
|
6
|
+
/**
|
|
7
|
+
* Returns the fully merged style for a given HTML tag, combining:
|
|
8
|
+
* default tag styles → user `tagsStyles` override.
|
|
9
|
+
*
|
|
10
|
+
* Useful inside custom renderers that want access to the computed base style.
|
|
11
|
+
*
|
|
12
|
+
* @param tag - The HTML tag name (e.g. `'p'`, `'h1'`).
|
|
13
|
+
*/
|
|
14
|
+
export function useTagStyle(tag) {
|
|
15
|
+
const ctx = useHtmlRendererContext();
|
|
16
|
+
return useMemo(() => {
|
|
17
|
+
const defaults = getDefaultTagStyles(ctx.emSize);
|
|
18
|
+
const base = defaults[tag] ?? {};
|
|
19
|
+
const override = ctx.tagsStyles[tag] ?? {};
|
|
20
|
+
return {
|
|
21
|
+
...base,
|
|
22
|
+
...override
|
|
23
|
+
};
|
|
24
|
+
}, [tag, ctx.emSize, ctx.tagsStyles]);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=useTagStyle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useMemo","useHtmlRendererContext","getDefaultTagStyles","useTagStyle","tag","ctx","defaults","emSize","base","override","tagsStyles"],"sourceRoot":"../../../src","sources":["hooks/useTagStyle.ts"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,sBAAsB,QAAQ,qBAAY;AACnD,SAASC,mBAAmB,QAAQ,oBAAW;AAG/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAACC,GAAW,EAAW;EAChD,MAAMC,GAAG,GAAGJ,sBAAsB,CAAC,CAAC;EAEpC,OAAOD,OAAO,CAAC,MAAM;IACnB,MAAMM,QAAQ,GAAGJ,mBAAmB,CAACG,GAAG,CAACE,MAAM,CAAC;IAChD,MAAMC,IAAI,GAAGF,QAAQ,CAACF,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,MAAMK,QAAQ,GAAGJ,GAAG,CAACK,UAAU,CAACN,GAAG,CAAC,IAAI,CAAC,CAAC;IAC1C,OAAO;MAAE,GAAGI,IAAI;MAAE,GAAGC;IAAS,CAAC;EACjC,CAAC,EAAE,CAACL,GAAG,EAAEC,GAAG,CAACE,MAAM,EAAEF,GAAG,CAACK,UAAU,CAAC,CAAC;AACvC","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Main component
|
|
4
|
+
export { HtmlRenderer } from "./HtmlRenderer.js";
|
|
5
|
+
|
|
6
|
+
// Parser
|
|
7
|
+
export { parseHTML } from "./parser/index.js";
|
|
8
|
+
|
|
9
|
+
// Styles
|
|
10
|
+
export { parseInlineStyle, getDefaultTagStyles, getDefaultDarkModeStyles } from "./styles/index.js";
|
|
11
|
+
|
|
12
|
+
// Hooks
|
|
13
|
+
export { useHtmlParser, useContentWidth, useTagStyle } from "./hooks/index.js";
|
|
14
|
+
|
|
15
|
+
// Context (for advanced use inside custom renderers)
|
|
16
|
+
export { useHtmlRendererContext } from "./context/index.js";
|
|
17
|
+
|
|
18
|
+
// Utilities
|
|
19
|
+
export { sanitizeDOM } from "./utils/sanitize.js";
|
|
20
|
+
export { clearImageDimensionCache, clearDOMCache } from "./utils/cache.js";
|
|
21
|
+
|
|
22
|
+
// Types
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["HtmlRenderer","parseHTML","parseInlineStyle","getDefaultTagStyles","getDefaultDarkModeStyles","useHtmlParser","useContentWidth","useTagStyle","useHtmlRendererContext","sanitizeDOM","clearImageDimensionCache","clearDOMCache"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA;AACA,SAASA,YAAY,QAAQ,mBAAgB;;AAE7C;AACA,SAASC,SAAS,QAAQ,mBAAU;;AAEpC;AACA,SACEC,gBAAgB,EAChBC,mBAAmB,EACnBC,wBAAwB,QACnB,mBAAU;;AAEjB;AACA,SAASC,aAAa,EAAEC,eAAe,EAAEC,WAAW,QAAQ,kBAAS;;AAErE;AACA,SAASC,sBAAsB,QAAQ,oBAAW;;AAElD;AACA,SAASC,WAAW,QAAQ,qBAAkB;AAC9C,SAASC,wBAAwB,EAAEC,aAAa,QAAQ,kBAAe;;AAEvE","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { parseDocument } from 'htmlparser2';
|
|
4
|
+
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
// Internal htmlparser2 node shape (loosely typed to avoid coupling)
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
// Tags whose content should never appear in the rendered output.
|
|
10
|
+
const IGNORED_TAGS = new Set(['script', 'style', 'head', 'meta', 'link']);
|
|
11
|
+
|
|
12
|
+
/** Max depth to prevent stack overflow from deeply nested HTML. */
|
|
13
|
+
const MAX_DEPTH = 100;
|
|
14
|
+
function convertNode(node, ignoredTags, depth) {
|
|
15
|
+
if (depth > MAX_DEPTH) return null;
|
|
16
|
+
if (node.type === 'text') {
|
|
17
|
+
const data = node.data ?? '';
|
|
18
|
+
if (data.trim().length === 0) return null;
|
|
19
|
+
return {
|
|
20
|
+
type: 'text',
|
|
21
|
+
data
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
if (node.type === 'tag' || node.type === 'script' || node.type === 'style') {
|
|
25
|
+
const tag = (node.name ?? '').toLowerCase();
|
|
26
|
+
|
|
27
|
+
// Skip built-in ignored tags AND user-supplied ignored tags
|
|
28
|
+
if (IGNORED_TAGS.has(tag) || ignoredTags.has(tag)) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const children = [];
|
|
32
|
+
for (const child of node.children ?? []) {
|
|
33
|
+
const converted = convertNode(child, ignoredTags, depth + 1);
|
|
34
|
+
if (converted) children.push(converted);
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
type: 'element',
|
|
38
|
+
tag,
|
|
39
|
+
attributes: node.attribs ?? {},
|
|
40
|
+
children
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Parse an HTML string into an array of `DOMNode` objects.
|
|
48
|
+
*
|
|
49
|
+
* @param html - Raw HTML string.
|
|
50
|
+
* @param ignoredTags - Optional set of tag names to skip entirely.
|
|
51
|
+
* @returns Array of parsed DOM nodes.
|
|
52
|
+
*/
|
|
53
|
+
export function parseHTML(html, ignoredTags = new Set()) {
|
|
54
|
+
const doc = parseDocument(html);
|
|
55
|
+
const nodes = [];
|
|
56
|
+
for (const child of doc.children ?? []) {
|
|
57
|
+
const converted = convertNode(child, ignoredTags, 0);
|
|
58
|
+
if (converted) nodes.push(converted);
|
|
59
|
+
}
|
|
60
|
+
return nodes;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["parseDocument","IGNORED_TAGS","Set","MAX_DEPTH","convertNode","node","ignoredTags","depth","type","data","trim","length","tag","name","toLowerCase","has","children","child","converted","push","attributes","attribs","parseHTML","html","doc","nodes"],"sourceRoot":"../../../src","sources":["parser/index.ts"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,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Ef,IAAI,CAACgB,OAAO,IAAI,CAAC,CAAC;MAC9BL;IACF,CAAC;EACH;EAEA,OAAO,IAAI;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASM,SAASA,CACvBC,IAAY,EACZjB,WAAwB,GAAG,IAAIJ,GAAG,CAAC,CAAC,EACzB;EACX,MAAMsB,GAAG,GAAGxB,aAAa,CAACuB,IAAI,CAAC;EAC/B,MAAME,KAAgB,GAAG,EAAE;EAE3B,KAAK,MAAMR,KAAK,IAAKO,GAAG,CAACR,QAAQ,IAAI,EAAE,EAAgB;IACrD,MAAME,SAAS,GAAGd,WAAW,CAACa,KAAK,EAAEX,WAAW,EAAE,CAAC,CAAC;IACpD,IAAIY,SAAS,EAAEO,KAAK,CAACN,IAAI,CAACD,SAAS,CAAC;EACtC;EAEA,OAAOO,KAAK;AACd","ignoreList":[]}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Component } from 'react';
|
|
4
|
+
import { View, Text } from 'react-native';
|
|
5
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
/**
|
|
7
|
+
* Catches rendering errors in the HTML renderer tree and
|
|
8
|
+
* displays a fallback UI instead of crashing the host app.
|
|
9
|
+
*/
|
|
10
|
+
export class ErrorBoundary extends Component {
|
|
11
|
+
constructor(props) {
|
|
12
|
+
super(props);
|
|
13
|
+
this.state = {
|
|
14
|
+
hasError: false,
|
|
15
|
+
error: null
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
static getDerivedStateFromError(error) {
|
|
19
|
+
return {
|
|
20
|
+
hasError: true,
|
|
21
|
+
error
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
componentDidCatch(error, info) {
|
|
25
|
+
if (__DEV__) {
|
|
26
|
+
console.error('[HtmlRenderer] Render error caught by ErrorBoundary:', error, info.componentStack);
|
|
27
|
+
}
|
|
28
|
+
this.props.onError?.(error);
|
|
29
|
+
}
|
|
30
|
+
render() {
|
|
31
|
+
if (this.state.hasError) {
|
|
32
|
+
if (this.props.fallback !== undefined) {
|
|
33
|
+
return this.props.fallback;
|
|
34
|
+
}
|
|
35
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
36
|
+
style: fallbackContainer,
|
|
37
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
38
|
+
style: fallbackTitle,
|
|
39
|
+
children: "Unable to render HTML content"
|
|
40
|
+
}), __DEV__ && this.state.error && /*#__PURE__*/_jsx(Text, {
|
|
41
|
+
style: fallbackDetail,
|
|
42
|
+
children: this.state.error.message
|
|
43
|
+
})]
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return this.props.children;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const fallbackContainer = {
|
|
50
|
+
padding: 16,
|
|
51
|
+
backgroundColor: '#fef2f2',
|
|
52
|
+
borderRadius: 8,
|
|
53
|
+
borderWidth: 1,
|
|
54
|
+
borderColor: '#fecaca'
|
|
55
|
+
};
|
|
56
|
+
const fallbackTitle = {
|
|
57
|
+
color: '#991b1b',
|
|
58
|
+
fontSize: 14,
|
|
59
|
+
fontWeight: '600'
|
|
60
|
+
};
|
|
61
|
+
const fallbackDetail = {
|
|
62
|
+
color: '#b91c1c',
|
|
63
|
+
fontSize: 12,
|
|
64
|
+
marginTop: 4
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=ErrorBoundary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Component","View","Text","jsx","_jsx","jsxs","_jsxs","ErrorBoundary","constructor","props","state","hasError","error","getDerivedStateFromError","componentDidCatch","info","__DEV__","console","componentStack","onError","render","fallback","undefined","style","fallbackContainer","children","fallbackTitle","fallbackDetail","message","padding","backgroundColor","borderRadius","borderWidth","borderColor","color","fontSize","fontWeight","marginTop"],"sourceRoot":"../../../src","sources":["renderer/ErrorBoundary.tsx"],"mappings":";;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CAAC;IAEX;IACA,OAAO,IAAI,CAACnB,KAAK,CAACgB,QAAQ;EAC5B;AACF;AAEA,MAAMD,iBAA4B,GAAG;EACnCK,OAAO,EAAE,EAAE;EACXC,eAAe,EAAE,SAAS;EAC1BC,YAAY,EAAE,CAAC;EACfC,WAAW,EAAE,CAAC;EACdC,WAAW,EAAE;AACf,CAAC;AAED,MAAMP,aAAwB,GAAG;EAC/BQ,KAAK,EAAE,SAAS;EAChBC,QAAQ,EAAE,EAAE;EACZC,UAAU,EAAE;AACd,CAAC;AAED,MAAMT,cAAyB,GAAG;EAChCO,KAAK,EAAE,SAAS;EAChBC,QAAQ,EAAE,EAAE;EACZE,SAAS,EAAE;AACb,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Fragment } from 'react';
|
|
4
|
+
import { StyleSheet, View, Text } from 'react-native';
|
|
5
|
+
import { getDefaultTagStyles, mergeStylesForElement } from "../styles/index.js";
|
|
6
|
+
import { INLINE_TAGS, TEXT_BLOCK_TAGS, isInlineContent } from "../utils/index.js";
|
|
7
|
+
import { getAccessibilityProps } from "../utils/accessibility.js";
|
|
8
|
+
import { TextBlock, renderInlineNodes, ImageTag, LinkTag, ListTag, TableTag, BlockTag, InputTag, TextareaTag, ButtonTag, SelectTag, VideoTag, AudioTag } from "./tags/index.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Recursively render an array of DOMNodes into React Native components.
|
|
12
|
+
*/
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
export function renderNodes(nodes, ctx, keyPrefix) {
|
|
15
|
+
const defaults = getDefaultTagStyles(ctx.emSize);
|
|
16
|
+
return nodes.map((node, index) => {
|
|
17
|
+
const key = `${keyPrefix}_${index}`;
|
|
18
|
+
|
|
19
|
+
// --- Text node ---
|
|
20
|
+
if (node.type === 'text') {
|
|
21
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
22
|
+
allowFontScaling: ctx.allowFontScaling,
|
|
23
|
+
maxFontSizeMultiplier: ctx.maxFontSizeMultiplier,
|
|
24
|
+
...ctx.defaultTextProps,
|
|
25
|
+
children: node.data
|
|
26
|
+
}, key);
|
|
27
|
+
}
|
|
28
|
+
if (node.type !== 'element') return null;
|
|
29
|
+
|
|
30
|
+
// --- Ignored tags ---
|
|
31
|
+
if (ctx.ignoredTags.has(node.tag)) return null;
|
|
32
|
+
|
|
33
|
+
// --- Compute merged style ---
|
|
34
|
+
const style = mergeStylesForElement(node, defaults, ctx.tagsStyles, ctx.classesStyles, ctx.idsStyles, ctx.ignoredStyles.size > 0 ? ctx.ignoredStyles : undefined, ctx.allowedStyles);
|
|
35
|
+
|
|
36
|
+
// --- Debug logging ---
|
|
37
|
+
if (ctx.debug) {
|
|
38
|
+
console.log(`[HtmlRenderer] <${node.tag}>`, {
|
|
39
|
+
attributes: node.attributes,
|
|
40
|
+
style
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// --- Custom renderer ---
|
|
45
|
+
const customRenderer = ctx.customRenderers[node.tag];
|
|
46
|
+
if (customRenderer) {
|
|
47
|
+
try {
|
|
48
|
+
const passProps = ctx.renderersProps[node.tag] ?? {};
|
|
49
|
+
const result = customRenderer({
|
|
50
|
+
node,
|
|
51
|
+
children: renderNodes(node.children, ctx, key),
|
|
52
|
+
style,
|
|
53
|
+
attributes: node.attributes,
|
|
54
|
+
passProps,
|
|
55
|
+
renderChildren: childNodes => renderNodes(childNodes, ctx, key),
|
|
56
|
+
contentWidth: ctx.contentWidth
|
|
57
|
+
});
|
|
58
|
+
return /*#__PURE__*/_jsx(Fragment, {
|
|
59
|
+
children: result
|
|
60
|
+
}, key);
|
|
61
|
+
} catch (e) {
|
|
62
|
+
if (ctx.debug) {
|
|
63
|
+
console.error(`[HtmlRenderer] Custom renderer for <${node.tag}> threw:`, e);
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// --- Built-in tag handling ---
|
|
70
|
+
try {
|
|
71
|
+
return renderElement(node, style, key, ctx);
|
|
72
|
+
} catch (e) {
|
|
73
|
+
if (ctx.debug) {
|
|
74
|
+
console.error(`[HtmlRenderer] Error rendering <${node.tag}>:`, e);
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
}).filter(n => n != null);
|
|
79
|
+
}
|
|
80
|
+
function renderElement(node, style, key, ctx) {
|
|
81
|
+
const {
|
|
82
|
+
tag
|
|
83
|
+
} = node;
|
|
84
|
+
const a11y = getAccessibilityProps(node);
|
|
85
|
+
|
|
86
|
+
// Debug: red border around every node
|
|
87
|
+
const debugStyle = ctx.debug ? {
|
|
88
|
+
borderWidth: 1,
|
|
89
|
+
borderColor: 'red'
|
|
90
|
+
} : undefined;
|
|
91
|
+
|
|
92
|
+
// Self-closing tags
|
|
93
|
+
if (tag === 'br') {
|
|
94
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
95
|
+
allowFontScaling: ctx.allowFontScaling,
|
|
96
|
+
maxFontSizeMultiplier: ctx.maxFontSizeMultiplier,
|
|
97
|
+
...ctx.defaultTextProps,
|
|
98
|
+
children: '\n'
|
|
99
|
+
}, key);
|
|
100
|
+
}
|
|
101
|
+
if (tag === 'hr') {
|
|
102
|
+
return /*#__PURE__*/_jsx(View, {
|
|
103
|
+
style: [hrBaseStyle, style, debugStyle],
|
|
104
|
+
...a11y
|
|
105
|
+
}, key);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Image
|
|
109
|
+
if (tag === 'img') {
|
|
110
|
+
return /*#__PURE__*/_jsx(ImageTag, {
|
|
111
|
+
node: node,
|
|
112
|
+
style: style,
|
|
113
|
+
nodeKey: key,
|
|
114
|
+
ctx: ctx
|
|
115
|
+
}, key);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Link (block-level — inline links handled in renderInlineNodes)
|
|
119
|
+
if (tag === 'a') {
|
|
120
|
+
return /*#__PURE__*/_jsx(LinkTag, {
|
|
121
|
+
node: node,
|
|
122
|
+
style: style,
|
|
123
|
+
nodeKey: key,
|
|
124
|
+
ctx: ctx,
|
|
125
|
+
renderNodes: renderNodes
|
|
126
|
+
}, key);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Lists
|
|
130
|
+
if (tag === 'ul' || tag === 'ol') {
|
|
131
|
+
return /*#__PURE__*/_jsx(ListTag, {
|
|
132
|
+
node: node,
|
|
133
|
+
style: style,
|
|
134
|
+
nodeKey: key,
|
|
135
|
+
ctx: ctx,
|
|
136
|
+
renderNodes: renderNodes
|
|
137
|
+
}, key);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Table
|
|
141
|
+
if (tag === 'table') {
|
|
142
|
+
return /*#__PURE__*/_jsx(TableTag, {
|
|
143
|
+
node: node,
|
|
144
|
+
style: style,
|
|
145
|
+
nodeKey: key,
|
|
146
|
+
ctx: ctx,
|
|
147
|
+
renderNodes: renderNodes
|
|
148
|
+
}, key);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Table row
|
|
152
|
+
if (tag === 'tr') {
|
|
153
|
+
return /*#__PURE__*/_jsx(View, {
|
|
154
|
+
style: [style, {
|
|
155
|
+
flexDirection: 'row'
|
|
156
|
+
}],
|
|
157
|
+
...a11y,
|
|
158
|
+
children: renderNodes(node.children, ctx, key)
|
|
159
|
+
}, key);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Form elements (read-only)
|
|
163
|
+
if (tag === 'input') {
|
|
164
|
+
return /*#__PURE__*/_jsx(InputTag, {
|
|
165
|
+
node: node,
|
|
166
|
+
style: style,
|
|
167
|
+
nodeKey: key,
|
|
168
|
+
ctx: ctx
|
|
169
|
+
}, key);
|
|
170
|
+
}
|
|
171
|
+
if (tag === 'textarea') {
|
|
172
|
+
return /*#__PURE__*/_jsx(TextareaTag, {
|
|
173
|
+
node: node,
|
|
174
|
+
style: style,
|
|
175
|
+
nodeKey: key,
|
|
176
|
+
ctx: ctx
|
|
177
|
+
}, key);
|
|
178
|
+
}
|
|
179
|
+
if (tag === 'button') {
|
|
180
|
+
return /*#__PURE__*/_jsx(ButtonTag, {
|
|
181
|
+
node: node,
|
|
182
|
+
style: style,
|
|
183
|
+
nodeKey: key,
|
|
184
|
+
ctx: ctx
|
|
185
|
+
}, key);
|
|
186
|
+
}
|
|
187
|
+
if (tag === 'select') {
|
|
188
|
+
return /*#__PURE__*/_jsx(SelectTag, {
|
|
189
|
+
node: node,
|
|
190
|
+
style: style,
|
|
191
|
+
nodeKey: key,
|
|
192
|
+
ctx: ctx
|
|
193
|
+
}, key);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Media placeholders
|
|
197
|
+
if (tag === 'video') {
|
|
198
|
+
return /*#__PURE__*/_jsx(VideoTag, {
|
|
199
|
+
node: node,
|
|
200
|
+
style: style,
|
|
201
|
+
nodeKey: key,
|
|
202
|
+
ctx: ctx
|
|
203
|
+
}, key);
|
|
204
|
+
}
|
|
205
|
+
if (tag === 'audio') {
|
|
206
|
+
return /*#__PURE__*/_jsx(AudioTag, {
|
|
207
|
+
node: node,
|
|
208
|
+
style: style,
|
|
209
|
+
nodeKey: key,
|
|
210
|
+
ctx: ctx
|
|
211
|
+
}, key);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Inline tags at top level — wrap in Text
|
|
215
|
+
if (INLINE_TAGS.has(tag)) {
|
|
216
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
217
|
+
style: debugStyle ? [style, debugStyle] : style,
|
|
218
|
+
allowFontScaling: ctx.allowFontScaling,
|
|
219
|
+
maxFontSizeMultiplier: ctx.maxFontSizeMultiplier,
|
|
220
|
+
...a11y,
|
|
221
|
+
...ctx.defaultTextProps,
|
|
222
|
+
children: renderInlineNodes(node.children, ctx, key, renderNodes)
|
|
223
|
+
}, key);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Text-block tags (p, h1-h6, li, td, th, pre, label)
|
|
227
|
+
if (TEXT_BLOCK_TAGS.has(tag)) {
|
|
228
|
+
return /*#__PURE__*/_jsx(TextBlock, {
|
|
229
|
+
tag: tag,
|
|
230
|
+
node: node,
|
|
231
|
+
style: style,
|
|
232
|
+
children: node.children,
|
|
233
|
+
nodeKey: key,
|
|
234
|
+
ctx: ctx,
|
|
235
|
+
renderNodes: renderNodes
|
|
236
|
+
}, key);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// Unknown tag — log warning in debug mode
|
|
240
|
+
if (ctx.debug) {
|
|
241
|
+
console.warn(`[HtmlRenderer] Unknown tag <${tag}>, rendering children.`);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Unknown / generic block elements — render children, never crash
|
|
245
|
+
if (node.children.length === 0) {
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// If all children are inline, render as text
|
|
250
|
+
if (isInlineContent(node.children)) {
|
|
251
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
252
|
+
style: debugStyle ? [style, debugStyle] : style,
|
|
253
|
+
allowFontScaling: ctx.allowFontScaling,
|
|
254
|
+
maxFontSizeMultiplier: ctx.maxFontSizeMultiplier,
|
|
255
|
+
...a11y,
|
|
256
|
+
...ctx.defaultTextProps,
|
|
257
|
+
children: renderInlineNodes(node.children, ctx, key, renderNodes)
|
|
258
|
+
}, key);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// Otherwise render as a block container
|
|
262
|
+
return /*#__PURE__*/_jsx(BlockTag, {
|
|
263
|
+
node: node,
|
|
264
|
+
style: debugStyle ? {
|
|
265
|
+
...style,
|
|
266
|
+
...debugStyle
|
|
267
|
+
} : style,
|
|
268
|
+
children: node.children,
|
|
269
|
+
nodeKey: key,
|
|
270
|
+
ctx: ctx,
|
|
271
|
+
renderNodes: renderNodes
|
|
272
|
+
}, key);
|
|
273
|
+
}
|
|
274
|
+
const hrBaseStyle = {
|
|
275
|
+
width: '100%',
|
|
276
|
+
height: StyleSheet.hairlineWidth,
|
|
277
|
+
backgroundColor: '#ccc'
|
|
278
|
+
};
|
|
279
|
+
//# sourceMappingURL=NodeRenderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Fragment","StyleSheet","View","Text","getDefaultTagStyles","mergeStylesForElement","INLINE_TAGS","TEXT_BLOCK_TAGS","isInlineContent","getAccessibilityProps","TextBlock","renderInlineNodes","ImageTag","LinkTag","ListTag","TableTag","BlockTag","InputTag","TextareaTag","ButtonTag","SelectTag","VideoTag","AudioTag","jsx","_jsx","renderNodes","nodes","ctx","keyPrefix","defaults","emSize","map","node","index","key","type","allowFontScaling","maxFontSizeMultiplier","defaultTextProps","children","data","ignoredTags","has","tag","style","tagsStyles","classesStyles","idsStyles","ignoredStyles","size","undefined","allowedStyles","debug","console","log","attributes","customRenderer","customRenderers","passProps","renderersProps","result","renderChildren","childNodes","contentWidth","e","error","renderElement","filter","n","a11y","debugStyle","borderWidth","borderColor","hrBaseStyle","nodeKey","flexDirection","warn","length","width","height","hairlineWidth","backgroundColor"],"sourceRoot":"../../../src","sources":["renderer/NodeRenderer.tsx"],"mappings":";;AAAA,SAASA,QAAQ,QAAwB,OAAO;AAChD,SACEC,UAAU,EACVC,IAAI,EACJC,IAAI,QAGC,cAAc;AAOrB,SAASC,mBAAmB,EAAEC,qBAAqB,QAAQ,oBAAW;AACtE,SAASC,WAAW,EAAEC,eAAe,EAAEC,eAAe,QAAQ,mBAAU;AACxE,SAASC,qBAAqB,QAAQ,2BAAwB;AAC9D,SACEC,SAAS,EACTC,iBAAiB,EACjBC,QAAQ,EACRC,OAAO,EACPC,OAAO,EACPC,QAAQ,EACRC,QAAQ,EACRC,QAAQ,EACRC,WAAW,EACXC,SAAS,EACTC,SAAS,EACTC,QAAQ,EACRC,QAAQ,QACH,iBAAQ;;AAEf;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA;AAGA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AAa;EAChCC,eAAe,EAAE;AACnB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["renderNodes","ErrorBoundary"],"sourceRoot":"../../../src","sources":["renderer/index.tsx"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,mBAAgB;AAC5C,SAASC,aAAa,QAAQ,oBAAiB","ignoreList":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { memo } from 'react';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
import { getAccessibilityProps } from "../../utils/accessibility.js";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
/**
|
|
8
|
+
* Generic block-level tag renderer.
|
|
9
|
+
* Used for `<div>`, `<section>`, `<article>`, `<header>`, `<footer>`,
|
|
10
|
+
* `<main>`, `<nav>`, `<aside>`, `<blockquote>`, `<figure>`, etc.
|
|
11
|
+
*/
|
|
12
|
+
export const BlockTag = /*#__PURE__*/memo(function BlockTag({
|
|
13
|
+
node,
|
|
14
|
+
style,
|
|
15
|
+
children,
|
|
16
|
+
nodeKey,
|
|
17
|
+
ctx,
|
|
18
|
+
renderNodes
|
|
19
|
+
}) {
|
|
20
|
+
const a11y = getAccessibilityProps(node);
|
|
21
|
+
return /*#__PURE__*/_jsx(View, {
|
|
22
|
+
style: style,
|
|
23
|
+
...a11y,
|
|
24
|
+
...ctx.defaultViewProps,
|
|
25
|
+
children: renderNodes(children, ctx, nodeKey)
|
|
26
|
+
}, nodeKey);
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=BlockTags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["memo","View","getAccessibilityProps","jsx","_jsx","BlockTag","node","style","children","nodeKey","ctx","renderNodes","a11y","defaultViewProps"],"sourceRoot":"../../../../src","sources":["renderer/tags/BlockTags.tsx"],"mappings":";;AAAA,SAASA,IAAI,QAAwB,OAAO;AAC5C,SAASC,IAAI,QAAwB,cAAc;AAOnD,SAASC,qBAAqB,QAAQ,8BAA2B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAelE;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,QAAQ,gBAAGL,IAAI,CAAC,SAASK,QAAQA,CAAC;EAC7CC,IAAI;EACJC,KAAK;EACLC,QAAQ;EACRC,OAAO;EACPC,GAAG;EACHC;AACa,CAAC,EAAE;EAChB,MAAMC,IAAI,GAAGV,qBAAqB,CAACI,IAAI,CAAC;EAExC,oBACEF,IAAA,CAACH,IAAI;IAEHM,KAAK,EAAEA,KAAmB;IAAA,GACtBK,IAAI;IAAA,GACJF,GAAG,CAACG,gBAAgB;IAAAL,QAAA,EAEvBG,WAAW,CAACH,QAAQ,EAAEE,GAAG,EAAED,OAAO;EAAC,GAL/BA,OAMD,CAAC;AAEX,CAAC,CAAC","ignoreList":[]}
|