@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.
Files changed (155) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +407 -0
  3. package/lib/module/HtmlRenderer.js +183 -0
  4. package/lib/module/HtmlRenderer.js.map +1 -0
  5. package/lib/module/context/index.js +32 -0
  6. package/lib/module/context/index.js.map +1 -0
  7. package/lib/module/hooks/index.js +6 -0
  8. package/lib/module/hooks/index.js.map +1 -0
  9. package/lib/module/hooks/useContentWidth.js +12 -0
  10. package/lib/module/hooks/useContentWidth.js.map +1 -0
  11. package/lib/module/hooks/useHtmlParser.js +16 -0
  12. package/lib/module/hooks/useHtmlParser.js.map +1 -0
  13. package/lib/module/hooks/useTagStyle.js +26 -0
  14. package/lib/module/hooks/useTagStyle.js.map +1 -0
  15. package/lib/module/index.js +23 -0
  16. package/lib/module/index.js.map +1 -0
  17. package/lib/module/package.json +1 -0
  18. package/lib/module/parser/index.js +62 -0
  19. package/lib/module/parser/index.js.map +1 -0
  20. package/lib/module/renderer/ErrorBoundary.js +66 -0
  21. package/lib/module/renderer/ErrorBoundary.js.map +1 -0
  22. package/lib/module/renderer/NodeRenderer.js +279 -0
  23. package/lib/module/renderer/NodeRenderer.js.map +1 -0
  24. package/lib/module/renderer/index.js +5 -0
  25. package/lib/module/renderer/index.js.map +1 -0
  26. package/lib/module/renderer/tags/BlockTags.js +28 -0
  27. package/lib/module/renderer/tags/BlockTags.js.map +1 -0
  28. package/lib/module/renderer/tags/FormTags.js +129 -0
  29. package/lib/module/renderer/tags/FormTags.js.map +1 -0
  30. package/lib/module/renderer/tags/ImageTag.js +163 -0
  31. package/lib/module/renderer/tags/ImageTag.js.map +1 -0
  32. package/lib/module/renderer/tags/LinkTag.js +50 -0
  33. package/lib/module/renderer/tags/LinkTag.js.map +1 -0
  34. package/lib/module/renderer/tags/ListTags.js +96 -0
  35. package/lib/module/renderer/tags/ListTags.js.map +1 -0
  36. package/lib/module/renderer/tags/MediaTags.js +69 -0
  37. package/lib/module/renderer/tags/MediaTags.js.map +1 -0
  38. package/lib/module/renderer/tags/TableTags.js +48 -0
  39. package/lib/module/renderer/tags/TableTags.js.map +1 -0
  40. package/lib/module/renderer/tags/TextTags.js +87 -0
  41. package/lib/module/renderer/tags/TextTags.js.map +1 -0
  42. package/lib/module/renderer/tags/index.js +11 -0
  43. package/lib/module/renderer/tags/index.js.map +1 -0
  44. package/lib/module/styles/cssToRn.js +34 -0
  45. package/lib/module/styles/cssToRn.js.map +1 -0
  46. package/lib/module/styles/darkModeStyles.js +81 -0
  47. package/lib/module/styles/darkModeStyles.js.map +1 -0
  48. package/lib/module/styles/defaultStyles.js +218 -0
  49. package/lib/module/styles/defaultStyles.js.map +1 -0
  50. package/lib/module/styles/index.js +7 -0
  51. package/lib/module/styles/index.js.map +1 -0
  52. package/lib/module/styles/mergeStyles.js +47 -0
  53. package/lib/module/styles/mergeStyles.js.map +1 -0
  54. package/lib/module/types/index.js +4 -0
  55. package/lib/module/types/index.js.map +1 -0
  56. package/lib/module/utils/accessibility.js +108 -0
  57. package/lib/module/utils/accessibility.js.map +1 -0
  58. package/lib/module/utils/cache.js +69 -0
  59. package/lib/module/utils/cache.js.map +1 -0
  60. package/lib/module/utils/index.js +95 -0
  61. package/lib/module/utils/index.js.map +1 -0
  62. package/lib/module/utils/sanitize.js +102 -0
  63. package/lib/module/utils/sanitize.js.map +1 -0
  64. package/lib/typescript/package.json +1 -0
  65. package/lib/typescript/src/HtmlRenderer.d.ts +15 -0
  66. package/lib/typescript/src/HtmlRenderer.d.ts.map +1 -0
  67. package/lib/typescript/src/context/index.d.ts +5 -0
  68. package/lib/typescript/src/context/index.d.ts.map +1 -0
  69. package/lib/typescript/src/hooks/index.d.ts +4 -0
  70. package/lib/typescript/src/hooks/index.d.ts.map +1 -0
  71. package/lib/typescript/src/hooks/useContentWidth.d.ts +6 -0
  72. package/lib/typescript/src/hooks/useContentWidth.d.ts.map +1 -0
  73. package/lib/typescript/src/hooks/useHtmlParser.d.ts +11 -0
  74. package/lib/typescript/src/hooks/useHtmlParser.d.ts.map +1 -0
  75. package/lib/typescript/src/hooks/useTagStyle.d.ts +11 -0
  76. package/lib/typescript/src/hooks/useTagStyle.d.ts.map +1 -0
  77. package/lib/typescript/src/index.d.ts +9 -0
  78. package/lib/typescript/src/index.d.ts.map +1 -0
  79. package/lib/typescript/src/parser/index.d.ts +10 -0
  80. package/lib/typescript/src/parser/index.d.ts.map +1 -0
  81. package/lib/typescript/src/renderer/ErrorBoundary.d.ts +22 -0
  82. package/lib/typescript/src/renderer/ErrorBoundary.d.ts.map +1 -0
  83. package/lib/typescript/src/renderer/NodeRenderer.d.ts +7 -0
  84. package/lib/typescript/src/renderer/NodeRenderer.d.ts.map +1 -0
  85. package/lib/typescript/src/renderer/index.d.ts +3 -0
  86. package/lib/typescript/src/renderer/index.d.ts.map +1 -0
  87. package/lib/typescript/src/renderer/tags/BlockTags.d.ts +18 -0
  88. package/lib/typescript/src/renderer/tags/BlockTags.d.ts.map +1 -0
  89. package/lib/typescript/src/renderer/tags/FormTags.d.ts +16 -0
  90. package/lib/typescript/src/renderer/tags/FormTags.d.ts.map +1 -0
  91. package/lib/typescript/src/renderer/tags/ImageTag.d.ts +18 -0
  92. package/lib/typescript/src/renderer/tags/ImageTag.d.ts.map +1 -0
  93. package/lib/typescript/src/renderer/tags/LinkTag.d.ts +19 -0
  94. package/lib/typescript/src/renderer/tags/LinkTag.d.ts.map +1 -0
  95. package/lib/typescript/src/renderer/tags/ListTags.d.ts +15 -0
  96. package/lib/typescript/src/renderer/tags/ListTags.d.ts.map +1 -0
  97. package/lib/typescript/src/renderer/tags/MediaTags.d.ts +14 -0
  98. package/lib/typescript/src/renderer/tags/MediaTags.d.ts.map +1 -0
  99. package/lib/typescript/src/renderer/tags/TableTags.d.ts +15 -0
  100. package/lib/typescript/src/renderer/tags/TableTags.d.ts.map +1 -0
  101. package/lib/typescript/src/renderer/tags/TextTags.d.ts +22 -0
  102. package/lib/typescript/src/renderer/tags/TextTags.d.ts.map +1 -0
  103. package/lib/typescript/src/renderer/tags/index.d.ts +9 -0
  104. package/lib/typescript/src/renderer/tags/index.d.ts.map +1 -0
  105. package/lib/typescript/src/styles/cssToRn.d.ts +11 -0
  106. package/lib/typescript/src/styles/cssToRn.d.ts.map +1 -0
  107. package/lib/typescript/src/styles/darkModeStyles.d.ts +7 -0
  108. package/lib/typescript/src/styles/darkModeStyles.d.ts.map +1 -0
  109. package/lib/typescript/src/styles/defaultStyles.d.ts +8 -0
  110. package/lib/typescript/src/styles/defaultStyles.d.ts.map +1 -0
  111. package/lib/typescript/src/styles/index.d.ts +5 -0
  112. package/lib/typescript/src/styles/index.d.ts.map +1 -0
  113. package/lib/typescript/src/styles/mergeStyles.d.ts +10 -0
  114. package/lib/typescript/src/styles/mergeStyles.d.ts.map +1 -0
  115. package/lib/typescript/src/types/index.d.ts +158 -0
  116. package/lib/typescript/src/types/index.d.ts.map +1 -0
  117. package/lib/typescript/src/utils/accessibility.d.ts +32 -0
  118. package/lib/typescript/src/utils/accessibility.d.ts.map +1 -0
  119. package/lib/typescript/src/utils/cache.d.ts +24 -0
  120. package/lib/typescript/src/utils/cache.d.ts.map +1 -0
  121. package/lib/typescript/src/utils/index.d.ts +33 -0
  122. package/lib/typescript/src/utils/index.d.ts.map +1 -0
  123. package/lib/typescript/src/utils/sanitize.d.ts +11 -0
  124. package/lib/typescript/src/utils/sanitize.d.ts.map +1 -0
  125. package/package.json +171 -0
  126. package/src/HtmlRenderer.tsx +216 -0
  127. package/src/context/index.tsx +30 -0
  128. package/src/hooks/index.ts +3 -0
  129. package/src/hooks/useContentWidth.ts +9 -0
  130. package/src/hooks/useHtmlParser.ts +18 -0
  131. package/src/hooks/useTagStyle.ts +23 -0
  132. package/src/index.tsx +39 -0
  133. package/src/parser/index.ts +80 -0
  134. package/src/renderer/ErrorBoundary.tsx +80 -0
  135. package/src/renderer/NodeRenderer.tsx +345 -0
  136. package/src/renderer/index.tsx +2 -0
  137. package/src/renderer/tags/BlockTags.tsx +49 -0
  138. package/src/renderer/tags/FormTags.tsx +169 -0
  139. package/src/renderer/tags/ImageTag.tsx +215 -0
  140. package/src/renderer/tags/LinkTag.tsx +76 -0
  141. package/src/renderer/tags/ListTags.tsx +148 -0
  142. package/src/renderer/tags/MediaTags.tsx +81 -0
  143. package/src/renderer/tags/TableTags.tsx +94 -0
  144. package/src/renderer/tags/TextTags.tsx +139 -0
  145. package/src/renderer/tags/index.ts +8 -0
  146. package/src/styles/cssToRn.ts +45 -0
  147. package/src/styles/darkModeStyles.ts +80 -0
  148. package/src/styles/defaultStyles.ts +176 -0
  149. package/src/styles/index.ts +4 -0
  150. package/src/styles/mergeStyles.ts +59 -0
  151. package/src/types/index.ts +229 -0
  152. package/src/utils/accessibility.ts +132 -0
  153. package/src/utils/cache.ts +83 -0
  154. package/src/utils/index.ts +151 -0
  155. package/src/utils/sanitize.ts +149 -0
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ // ---------------------------------------------------------------------------
4
+ // Image Dimension Cache (LRU, bounded)
5
+ // ---------------------------------------------------------------------------
6
+
7
+ const imageDimensionCache = new Map();
8
+ const IMAGE_CACHE_MAX_SIZE = 200;
9
+
10
+ /** Get cached image dimensions for a URL. */
11
+ export function getCachedImageDimensions(uri) {
12
+ return imageDimensionCache.get(uri);
13
+ }
14
+
15
+ /** Cache image dimensions for a URL. */
16
+ export function setCachedImageDimensions(uri, dimensions) {
17
+ if (imageDimensionCache.size >= IMAGE_CACHE_MAX_SIZE) {
18
+ const firstKey = imageDimensionCache.keys().next().value;
19
+ if (firstKey !== undefined) {
20
+ imageDimensionCache.delete(firstKey);
21
+ }
22
+ }
23
+ imageDimensionCache.set(uri, dimensions);
24
+ }
25
+
26
+ /** Clear the image dimension cache (useful for testing). */
27
+ export function clearImageDimensionCache() {
28
+ imageDimensionCache.clear();
29
+ }
30
+
31
+ // ---------------------------------------------------------------------------
32
+ // Parsed DOM Cache (LRU, bounded)
33
+ // Cache key includes html + allowDangerousHtml + ignoredTags to prevent
34
+ // cache poisoning when these parameters change.
35
+ // ---------------------------------------------------------------------------
36
+
37
+ const domCache = new Map();
38
+ const DOM_CACHE_MAX_SIZE = 50;
39
+
40
+ /**
41
+ * Build a composite cache key that incorporates all parameters affecting
42
+ * the parse/sanitize result, preventing cache poisoning.
43
+ */
44
+ export function buildDOMCacheKey(html, allowDangerousHtml, ignoredTags) {
45
+ const tagsSuffix = ignoredTags.size > 0 ? [...ignoredTags].sort().join(',') : '';
46
+ return `${allowDangerousHtml ? '1' : '0'}|${tagsSuffix}|${html}`;
47
+ }
48
+
49
+ /** Get cached parsed DOM for a cache key. */
50
+ export function getCachedDOM(cacheKey) {
51
+ return domCache.get(cacheKey);
52
+ }
53
+
54
+ /** Cache parsed DOM for a cache key. */
55
+ export function setCachedDOM(cacheKey, nodes) {
56
+ if (domCache.size >= DOM_CACHE_MAX_SIZE) {
57
+ const firstKey = domCache.keys().next().value;
58
+ if (firstKey !== undefined) {
59
+ domCache.delete(firstKey);
60
+ }
61
+ }
62
+ domCache.set(cacheKey, nodes);
63
+ }
64
+
65
+ /** Clear the DOM cache (useful for testing). */
66
+ export function clearDOMCache() {
67
+ domCache.clear();
68
+ }
69
+ //# sourceMappingURL=cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["imageDimensionCache","Map","IMAGE_CACHE_MAX_SIZE","getCachedImageDimensions","uri","get","setCachedImageDimensions","dimensions","size","firstKey","keys","next","value","undefined","delete","set","clearImageDimensionCache","clear","domCache","DOM_CACHE_MAX_SIZE","buildDOMCacheKey","html","allowDangerousHtml","ignoredTags","tagsSuffix","sort","join","getCachedDOM","cacheKey","setCachedDOM","nodes","clearDOMCache"],"sourceRoot":"../../../src","sources":["utils/cache.ts"],"mappings":";;AAEA;AACA;AACA;;AAOA,MAAMA,mBAAmB,GAAG,IAAIC,GAAG,CAA0B,CAAC;AAC9D,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QAAgB,EAAEE,KAAgB,EAAQ;EACrE,IAAIZ,QAAQ,CAACV,IAAI,IAAIW,kBAAkB,EAAE;IACvC,MAAMV,QAAQ,GAAGS,QAAQ,CAACR,IAAI,CAAC,CAAC,CAACC,IAAI,CAAC,CAAC,CAACC,KAAK;IAC7C,IAAIH,QAAQ,KAAKI,SAAS,EAAE;MAC1BK,QAAQ,CAACJ,MAAM,CAACL,QAAQ,CAAC;IAC3B;EACF;EACAS,QAAQ,CAACH,GAAG,CAACa,QAAQ,EAAEE,KAAK,CAAC;AAC/B;;AAEA;AACA,OAAO,SAASC,aAAaA,CAAA,EAAS;EACpCb,QAAQ,CAACD,KAAK,CAAC,CAAC;AAClB","ignoreList":[]}
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+
3
+ // Re-export sub-modules
4
+ export { sanitizeDOM } from "./sanitize.js";
5
+ export { getAccessibilityProps, getImageA11yLabel, getLinkA11yLabel } from "./accessibility.js";
6
+ export { getCachedImageDimensions, setCachedImageDimensions, clearImageDimensionCache, getCachedDOM, setCachedDOM, clearDOMCache, buildDOMCacheKey } from "./cache.js";
7
+
8
+ // ---------------------------------------------------------------------------
9
+ // CSS unit conversion
10
+ // ---------------------------------------------------------------------------
11
+
12
+ /**
13
+ * Convert a CSS value string to a numeric pixel value.
14
+ * Supports: px, em, rem, bare numbers. Percentage returns NaN (handled upstream).
15
+ */
16
+ export function cssValueToNumeric(value, emSize) {
17
+ const trimmed = value.trim();
18
+ if (trimmed.endsWith('px')) {
19
+ return parseFloat(trimmed);
20
+ }
21
+ if (trimmed.endsWith('em') || trimmed.endsWith('rem')) {
22
+ return parseFloat(trimmed) * emSize;
23
+ }
24
+ if (trimmed.endsWith('%')) {
25
+ // Percentage — return undefined, caller must handle contextually
26
+ return undefined;
27
+ }
28
+ const num = parseFloat(trimmed);
29
+ return isNaN(num) ? undefined : num;
30
+ }
31
+
32
+ // ---------------------------------------------------------------------------
33
+ // DOM helpers
34
+ // ---------------------------------------------------------------------------
35
+
36
+ /** Tags that are inherently inline (text-level). */
37
+ export const INLINE_TAGS = new Set(['span', 'strong', 'b', 'em', 'i', 'u', 's', 'strike', 'del', 'ins', 'mark', 'small', 'sub', 'sup', 'a', 'code', 'br']);
38
+
39
+ /** Tags that are text containers (rendered as `<Text>` at block level). */
40
+ export const TEXT_BLOCK_TAGS = new Set(['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'li', 'th', 'td', 'pre', 'label', 'dt', 'dd']);
41
+
42
+ /** Tags that should be silently skipped (no output). */
43
+ export const ALWAYS_IGNORED_TAGS = new Set(['script', 'style', 'head', 'meta', 'link', 'title', 'noscript']);
44
+
45
+ /**
46
+ * Returns true if every child of the given list is either a text node
47
+ * or an inline-level element whose descendants are also all inline.
48
+ */
49
+ export function isInlineContent(nodes) {
50
+ return nodes.every(node => {
51
+ if (node.type === 'text') return true;
52
+ if (node.type === 'element') {
53
+ return INLINE_TAGS.has(node.tag) && isInlineContent(node.children);
54
+ }
55
+ return false;
56
+ });
57
+ }
58
+
59
+ /**
60
+ * Resolve a potentially relative URL against a base URL.
61
+ */
62
+ export function resolveUrl(url, baseUrl) {
63
+ if (!baseUrl || /^https?:\/\//i.test(url) || url.startsWith('data:')) {
64
+ return url;
65
+ }
66
+ const base = baseUrl.endsWith('/') ? baseUrl : baseUrl + '/';
67
+ return url.startsWith('/') ? base + url.slice(1) : base + url;
68
+ }
69
+
70
+ /**
71
+ * Type-guard: checks if a DOMNode is a DOMElement.
72
+ */
73
+ export function isDOMElement(node) {
74
+ return node.type === 'element';
75
+ }
76
+
77
+ /**
78
+ * Extract all text content from a node tree (for accessibility labels, etc.).
79
+ */
80
+ export function extractTextContent(nodes) {
81
+ let text = '';
82
+ for (const node of nodes) {
83
+ if (node.type === 'text') {
84
+ text += node.data;
85
+ } else if (node.type === 'element') {
86
+ if (node.tag === 'br') {
87
+ text += '\n';
88
+ } else {
89
+ text += extractTextContent(node.children);
90
+ }
91
+ }
92
+ }
93
+ return text;
94
+ }
95
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["sanitizeDOM","getAccessibilityProps","getImageA11yLabel","getLinkA11yLabel","getCachedImageDimensions","setCachedImageDimensions","clearImageDimensionCache","getCachedDOM","setCachedDOM","clearDOMCache","buildDOMCacheKey","cssValueToNumeric","value","emSize","trimmed","trim","endsWith","parseFloat","undefined","num","isNaN","INLINE_TAGS","Set","TEXT_BLOCK_TAGS","ALWAYS_IGNORED_TAGS","isInlineContent","nodes","every","node","type","has","tag","children","resolveUrl","url","baseUrl","test","startsWith","base","slice","isDOMElement","extractTextContent","text","data"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":";;AAEA;AACA,SAASA,WAAW,QAAQ,eAAY;AACxC,SACEC,qBAAqB,EACrBC,iBAAiB,EACjBC,gBAAgB,QAEX,oBAAiB;AACxB,SACEC,wBAAwB,EACxBC,wBAAwB,EACxBC,wBAAwB,EACxBC,YAAY,EACZC,YAAY,EACZC,aAAa,EACbC,gBAAgB,QACX,YAAS;;AAEhB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAC/BC,KAAa,EACbC,MAAc,EACM;EACpB,MAAMC,OAAO,GAAGF,KAAK,CAACG,IAAI,CAAC,CAAC;EAC5B,IAAID,OAAO,CAACE,QAAQ,CAAC,IAAI,CAAC,EAAE;IAC1B,OAAOC,UAAU,CAACH,OAAO,CAAC;EAC5B;EACA,IAAIA,OAAO,CAACE,QAAQ,CAAC,IAAI,CAAC,IAAIF,OAAO,CAACE,QAAQ,CAAC,KAAK,CAAC,EAAE;IACrD,OAAOC,UAAU,CAACH,OAAO,CAAC,GAAGD,MAAM;EACrC;EACA,IAAIC,OAAO,CAACE,QAAQ,CAAC,GAAG,CAAC,EAAE;IACzB;IACA,OAAOE,SAAS;EAClB;EACA,MAAMC,GAAG,GAAGF,UAAU,CAACH,OAAO,CAAC;EAC/B,OAAOM,KAAK,CAACD,GAAG,CAAC,GAA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O,CAAC,EAAE;IACpE,OAAOH,GAAG;EACZ;EACA,MAAMI,IAAI,GAAGH,OAAO,CAACnB,QAAQ,CAAC,GAAG,CAAC,GAAGmB,OAAO,GAAGA,OAAO,GAAG,GAAG;EAC5D,OAAOD,GAAG,CAACG,UAAU,CAAC,GAAG,CAAC,GAAGC,IAAI,GAAGJ,GAAG,CAACK,KAAK,CAAC,CAAC,CAAC,GAAGD,IAAI,GAAGJ,GAAG;AAC/D;;AAEA;AACA;AACA;AACA,OAAO,SAASM,YAAYA,CAACZ,IAAa,EAAsB;EAC9D,OAAOA,IAAI,CAACC,IAAI,KAAK,SAAS;AAChC;;AAEA;AACA;AACA;AACA,OAAO,SAASY,kBAAkBA,CAACf,KAAgB,EAAU;EAC3D,IAAIgB,IAAI,GAAG,EAAE;EACb,KAAK,MAAMd,IAAI,IAAIF,KAAK,EAAE;IACxB,IAAIE,IAAI,CAACC,IAAI,KAAK,MAAM,EAAE;MACxBa,IAAI,IAAId,IAAI,CAACe,IAAI;IACnB,CAAC,MAAM,IAAIf,IAAI,CAACC,IAAI,KAAK,SAAS,EAAE;MAClC,IAAID,IAAI,CAACG,GAAG,KAAK,IAAI,EAAE;QACrBW,IAAI,IAAI,IAAI;MACd,CAAC,MAAM;QACLA,IAAI,IAAID,kBAAkB,CAACb,IAAI,CAACI,QAAQ,CAAC;MAC3C;IACF;EACF;EACA,OAAOU,IAAI;AACb","ignoreList":[]}
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+
3
+ /** Tags considered dangerous and stripped when `allowDangerousHtml` is false. */
4
+ const DANGEROUS_TAGS = new Set(['script', 'iframe', 'object', 'embed', 'form', 'applet', 'base', 'svg', 'math', 'frame', 'frameset', 'template', 'noscript']);
5
+
6
+ /** Attributes that carry URLs and must be checked for dangerous schemes. */
7
+ const URL_ATTRIBUTES = new Set(['href', 'src', 'srcset', 'poster', 'action', 'formaction', 'data', 'background', 'xlink:href', 'srcdoc']);
8
+
9
+ /** Attribute keys that should never be copied to the output. */
10
+ const BLOCKED_ATTR_KEYS = new Set(['__proto__', 'constructor', 'prototype']);
11
+
12
+ /** Allowed URL schemes for links and resources. Everything else is blocked. */
13
+ const SAFE_SCHEMES = new Set(['http:', 'https:', 'mailto:', 'tel:', 'sms:', 'geo:', 'data:image/' // only data: images are safe
14
+ ]);
15
+
16
+ /** Max recursion depth for sanitizing nested DOM trees. */
17
+ const MAX_DEPTH = 100;
18
+
19
+ /**
20
+ * Strip ASCII control characters (0x00–0x1F), tabs, newlines, and carriage
21
+ * returns from a string before checking schemes. This prevents bypass via
22
+ * null-byte injection or embedded whitespace (e.g. `java\tscript:`).
23
+ */
24
+ function normalizeUrl(url) {
25
+ return url.replace(/[\x00-\x1f\x7f]/g, '').trim().toLowerCase();
26
+ }
27
+
28
+ /**
29
+ * Returns true if the URL uses a safe, allowed scheme.
30
+ * Blocks `javascript:`, `vbscript:`, `data:text/*`, and any other unknown scheme.
31
+ */
32
+ function isSafeUrl(url) {
33
+ const normalized = normalizeUrl(url);
34
+
35
+ // Relative URLs and fragment-only URLs are safe
36
+ if (normalized.startsWith('/') || normalized.startsWith('#') || normalized.startsWith('?') || !normalized.includes(':')) {
37
+ return true;
38
+ }
39
+
40
+ // Check against allowed schemes
41
+ for (const scheme of SAFE_SCHEMES) {
42
+ if (normalized.startsWith(scheme)) return true;
43
+ }
44
+ return false;
45
+ }
46
+
47
+ /**
48
+ * Recursively sanitize a DOM tree:
49
+ * - Remove dangerous tags entirely (including children)
50
+ * - Strip ALL event handler attributes (any attribute starting with `on`)
51
+ * - Neutralize dangerous URLs in all URL-bearing attributes
52
+ * - Guard against prototype pollution via attribute keys
53
+ * - Enforce a max recursion depth to prevent stack overflow
54
+ */
55
+ export function sanitizeDOM(nodes, depth = 0) {
56
+ if (depth > MAX_DEPTH) return [];
57
+ const result = [];
58
+ for (const node of nodes) {
59
+ if (node.type === 'text') {
60
+ result.push(node);
61
+ continue;
62
+ }
63
+
64
+ // Strip dangerous tags entirely (including children)
65
+ if (DANGEROUS_TAGS.has(node.tag)) {
66
+ continue;
67
+ }
68
+
69
+ // Clean attributes
70
+ const cleanAttrs = Object.create(null);
71
+ for (const [key, value] of Object.entries(node.attributes)) {
72
+ const keyLower = key.toLowerCase();
73
+
74
+ // Strip event handlers (any attribute starting with "on")
75
+ if (keyLower.startsWith('on')) continue;
76
+
77
+ // Guard against prototype pollution
78
+ if (BLOCKED_ATTR_KEYS.has(keyLower)) continue;
79
+
80
+ // Sanitize URL-bearing attributes
81
+ if (URL_ATTRIBUTES.has(keyLower)) {
82
+ if (!isSafeUrl(value)) {
83
+ // For href, replace with #; for others, drop entirely
84
+ if (keyLower === 'href') {
85
+ cleanAttrs[key] = '#';
86
+ }
87
+ continue;
88
+ }
89
+ }
90
+ cleanAttrs[key] = value;
91
+ }
92
+ const sanitizedElement = {
93
+ type: 'element',
94
+ tag: node.tag,
95
+ attributes: cleanAttrs,
96
+ children: sanitizeDOM(node.children, depth + 1)
97
+ };
98
+ result.push(sanitizedElement);
99
+ }
100
+ return result;
101
+ }
102
+ //# sourceMappingURL=sanitize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DANGEROUS_TAGS","Set","URL_ATTRIBUTES","BLOCKED_ATTR_KEYS","SAFE_SCHEMES","MAX_DEPTH","normalizeUrl","url","replace","trim","toLowerCase","isSafeUrl","normalized","startsWith","includes","scheme","sanitizeDOM","nodes","depth","result","node","type","push","has","tag","cleanAttrs","Object","create","key","value","entries","attributes","keyLower","sanitizedElement","children"],"sourceRoot":"../../../src","sources":["utils/sanitize.ts"],"mappings":";;AAEA;AACA,MAAMA,cAAc,GAAG,IAAIC,GAAG,CAAC,CAC7B,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,MAAM,EACN,QAAQ,EACR,MAAM,EACN,KAAK,EACL,MAAM,EACN,OAAO,EACP,UAAU,EACV,UAAU,EACV,UAAU,CACX,CAAC;;AAEF;AACA,MAAMC,cAAc,GAAG,IAAID,GAAG,CAAC,CAC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,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,15 @@
1
+ import type { HtmlRendererProps } from './types';
2
+ /**
3
+ * Renders an HTML string into native React Native components.
4
+ *
5
+ * @example
6
+ * ```tsx
7
+ * <HtmlRenderer
8
+ * html="<h1>Hello</h1><p>World</p>"
9
+ * contentWidth={350}
10
+ * onLinkPress={(href) => Linking.openURL(href)}
11
+ * />
12
+ * ```
13
+ */
14
+ export declare function HtmlRenderer({ html, contentWidth, baseStyle, tagsStyles, classesStyles, idsStyles, customRenderers, onLinkPress, onImagePress, onError, fallback, ignoredTags, ignoredStyles, allowedStyles, defaultTextProps, defaultViewProps, renderersProps, maxImagesWidth, imagesInitialDimensions, listsPrefixesRenderers, emSize, systemFonts, fallbackFonts, debug, allowDangerousHtml, darkModeStyles, colorScheme: colorSchemeProp, allowFontScaling, maxFontSizeMultiplier, }: HtmlRendererProps): import("react/jsx-runtime").JSX.Element;
15
+ //# sourceMappingURL=HtmlRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HtmlRenderer.d.ts","sourceRoot":"","sources":["../../../src/HtmlRenderer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,iBAAiB,EAGlB,MAAM,SAAS,CAAC;AASjB;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,EAC3B,IAAI,EACJ,YAAY,EACZ,SAAS,EACT,UAAU,EACV,aAAa,EACb,SAAS,EACT,eAAe,EACf,WAAW,EACX,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,WAAW,EACX,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,uBAAuB,EACvB,sBAAsB,EACtB,MAAW,EACX,WAAW,EACX,aAAa,EACb,KAAa,EACb,kBAA0B,EAC1B,cAAc,EACd,WAAW,EAAE,eAAe,EAC5B,gBAAuB,EACvB,qBAAqB,GACtB,EAAE,iBAAiB,2CA4JnB"}
@@ -0,0 +1,5 @@
1
+ import type { HtmlRendererContextValue } from '../types';
2
+ export declare const HtmlRendererContext: import("react").Context<HtmlRendererContextValue>;
3
+ /** Access the HtmlRenderer context from inside the render tree. */
4
+ export declare function useHtmlRendererContext(): HtmlRendererContextValue;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/context/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAsBzD,eAAO,MAAM,mBAAmB,mDAC0B,CAAC;AAE3D,mEAAmE;AACnE,wBAAgB,sBAAsB,IAAI,wBAAwB,CAEjE"}
@@ -0,0 +1,4 @@
1
+ export { useHtmlParser } from './useHtmlParser';
2
+ export { useContentWidth } from './useContentWidth';
3
+ export { useTagStyle } from './useTagStyle';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Returns the current `contentWidth` from the HtmlRenderer context.
3
+ * Useful inside custom renderers that need to know the available layout width.
4
+ */
5
+ export declare function useContentWidth(): number;
6
+ //# sourceMappingURL=useContentWidth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useContentWidth.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useContentWidth.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC"}
@@ -0,0 +1,11 @@
1
+ import type { DOMNode } from '../types';
2
+ /**
3
+ * Hook that parses an HTML string into a DOM tree.
4
+ * The result is memoized and only recomputed when `html` or `ignoredTags` change.
5
+ *
6
+ * @param html - Raw HTML string.
7
+ * @param ignoredTags - Optional set of tag names to skip.
8
+ * @returns Array of parsed DOMNode objects.
9
+ */
10
+ export declare function useHtmlParser(html: string, ignoredTags?: Set<string>): DOMNode[];
11
+ //# sourceMappingURL=useHtmlParser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHtmlParser.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useHtmlParser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GACxB,OAAO,EAAE,CAEX"}
@@ -0,0 +1,11 @@
1
+ import type { RNStyle } from '../types';
2
+ /**
3
+ * Returns the fully merged style for a given HTML tag, combining:
4
+ * default tag styles → user `tagsStyles` override.
5
+ *
6
+ * Useful inside custom renderers that want access to the computed base style.
7
+ *
8
+ * @param tag - The HTML tag name (e.g. `'p'`, `'h1'`).
9
+ */
10
+ export declare function useTagStyle(tag: string): RNStyle;
11
+ //# sourceMappingURL=useTagStyle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTagStyle.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTagStyle.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAShD"}
@@ -0,0 +1,9 @@
1
+ export { HtmlRenderer } from './HtmlRenderer';
2
+ export { parseHTML } from './parser';
3
+ export { parseInlineStyle, getDefaultTagStyles, getDefaultDarkModeStyles, } from './styles';
4
+ export { useHtmlParser, useContentWidth, useTagStyle } from './hooks';
5
+ export { useHtmlRendererContext } from './context';
6
+ export { sanitizeDOM } from './utils/sanitize';
7
+ export { clearImageDimensionCache, clearDOMCache } from './utils/cache';
8
+ export type { HtmlRendererProps, DOMNode, DOMElement, DOMText, RNStyle, CustomRenderer, CustomRendererProps, TagsStyles, ClassesStyles, IdsStyles, HtmlRendererContextValue, ListPrefixRendererProps, ListsPrefixesRenderers, } from './types';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGrC,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAGnD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGxE,YAAY,EACV,iBAAiB,EACjB,OAAO,EACP,UAAU,EACV,OAAO,EACP,OAAO,EACP,cAAc,EACd,mBAAmB,EACnB,UAAU,EACV,aAAa,EACb,SAAS,EACT,wBAAwB,EACxB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { DOMNode } from '../types';
2
+ /**
3
+ * Parse an HTML string into an array of `DOMNode` objects.
4
+ *
5
+ * @param html - Raw HTML string.
6
+ * @param ignoredTags - Optional set of tag names to skip entirely.
7
+ * @returns Array of parsed DOM nodes.
8
+ */
9
+ export declare function parseHTML(html: string, ignoredTags?: Set<string>): DOMNode[];
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/parser/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAuB,MAAM,UAAU,CAAC;AA0D7D;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,WAAW,GAAE,GAAG,CAAC,MAAM,CAAa,GACnC,OAAO,EAAE,CAUX"}
@@ -0,0 +1,22 @@
1
+ import { Component, type ReactNode, type ErrorInfo } from 'react';
2
+ interface ErrorBoundaryProps {
3
+ onError?: (error: Error) => void;
4
+ fallback?: ReactNode;
5
+ children: ReactNode;
6
+ }
7
+ interface ErrorBoundaryState {
8
+ hasError: boolean;
9
+ error: Error | null;
10
+ }
11
+ /**
12
+ * Catches rendering errors in the HTML renderer tree and
13
+ * displays a fallback UI instead of crashing the host app.
14
+ */
15
+ export declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
16
+ constructor(props: ErrorBoundaryProps);
17
+ static getDerivedStateFromError(error: Error): ErrorBoundaryState;
18
+ componentDidCatch(error: Error, info: ErrorInfo): void;
19
+ render(): ReactNode;
20
+ }
21
+ export {};
22
+ //# sourceMappingURL=ErrorBoundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorBoundary.d.ts","sourceRoot":"","sources":["../../../../src/renderer/ErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlE,UAAU,kBAAkB;IAC1B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED;;;GAGG;AACH,qBAAa,aAAc,SAAQ,SAAS,CAC1C,kBAAkB,EAClB,kBAAkB,CACnB;gBACa,KAAK,EAAE,kBAAkB;IAKrC,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK,GAAG,kBAAkB;IAIxD,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI;IAWtD,MAAM,IAAI,SAAS;CAiB7B"}
@@ -0,0 +1,7 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { DOMNode, HtmlRendererContextValue } from '../types';
3
+ /**
4
+ * Recursively render an array of DOMNodes into React Native components.
5
+ */
6
+ export declare function renderNodes(nodes: DOMNode[], ctx: HtmlRendererContextValue, keyPrefix: string): ReactNode[];
7
+ //# sourceMappingURL=NodeRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NodeRenderer.d.ts","sourceRoot":"","sources":["../../../../src/renderer/NodeRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAQjD,OAAO,KAAK,EACV,OAAO,EAEP,wBAAwB,EAEzB,MAAM,UAAU,CAAC;AAoBlB;;GAEG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,OAAO,EAAE,EAChB,GAAG,EAAE,wBAAwB,EAC7B,SAAS,EAAE,MAAM,GAChB,SAAS,EAAE,CAkFb"}
@@ -0,0 +1,3 @@
1
+ export { renderNodes } from './NodeRenderer';
2
+ export { ErrorBoundary } from './ErrorBoundary';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/renderer/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { DOMNode, DOMElement, RNStyle, HtmlRendererContextValue } from '../../types';
3
+ interface BlockTagProps {
4
+ node: DOMElement;
5
+ style: RNStyle;
6
+ children: DOMNode[];
7
+ nodeKey: string;
8
+ ctx: HtmlRendererContextValue;
9
+ renderNodes: (nodes: DOMNode[], ctx: HtmlRendererContextValue, keyPrefix: string) => ReactNode[];
10
+ }
11
+ /**
12
+ * Generic block-level tag renderer.
13
+ * Used for `<div>`, `<section>`, `<article>`, `<header>`, `<footer>`,
14
+ * `<main>`, `<nav>`, `<aside>`, `<blockquote>`, `<figure>`, etc.
15
+ */
16
+ export declare const BlockTag: import("react").MemoExoticComponent<({ node, style, children, nodeKey, ctx, renderNodes, }: BlockTagProps) => import("react/jsx-runtime").JSX.Element>;
17
+ export {};
18
+ //# sourceMappingURL=BlockTags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BlockTags.d.ts","sourceRoot":"","sources":["../../../../../src/renderer/tags/BlockTags.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,KAAK,EACV,OAAO,EACP,UAAU,EACV,OAAO,EACP,wBAAwB,EACzB,MAAM,aAAa,CAAC;AAGrB,UAAU,aAAa;IACrB,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,wBAAwB,CAAC;IAC9B,WAAW,EAAE,CACX,KAAK,EAAE,OAAO,EAAE,EAChB,GAAG,EAAE,wBAAwB,EAC7B,SAAS,EAAE,MAAM,KACd,SAAS,EAAE,CAAC;CAClB;AAED;;;;GAIG;AACH,eAAO,MAAM,QAAQ,8FAOlB,aAAa,6CAad,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { DOMElement, RNStyle, HtmlRendererContextValue } from '../../types';
2
+ interface FormTagProps {
3
+ node: DOMElement;
4
+ style: RNStyle;
5
+ nodeKey: string;
6
+ ctx: HtmlRendererContextValue;
7
+ }
8
+ /**
9
+ * Read-only renderers for form elements.
10
+ */
11
+ export declare const InputTag: import("react").MemoExoticComponent<({ node, style, nodeKey, ctx, }: FormTagProps) => import("react/jsx-runtime").JSX.Element | null>;
12
+ export declare const TextareaTag: import("react").MemoExoticComponent<({ node, style, nodeKey, ctx, }: FormTagProps) => import("react/jsx-runtime").JSX.Element>;
13
+ export declare const ButtonTag: import("react").MemoExoticComponent<({ node, style, nodeKey, ctx, }: FormTagProps) => import("react/jsx-runtime").JSX.Element>;
14
+ export declare const SelectTag: import("react").MemoExoticComponent<({ node, style, nodeKey, ctx, }: FormTagProps) => import("react/jsx-runtime").JSX.Element>;
15
+ export {};
16
+ //# sourceMappingURL=FormTags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormTags.d.ts","sourceRoot":"","sources":["../../../../../src/renderer/tags/FormTags.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,OAAO,EACP,wBAAwB,EACzB,MAAM,aAAa,CAAC;AAIrB,UAAU,YAAY;IACpB,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,wBAAwB,CAAC;CAC/B;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,uEAKlB,YAAY,oDA0Cb,CAAC;AAEH,eAAO,MAAM,WAAW,uEAKrB,YAAY,6CAiBb,CAAC;AAEH,eAAO,MAAM,SAAS,uEAKnB,YAAY,6CAqBb,CAAC;AAEH,eAAO,MAAM,SAAS,uEAKnB,YAAY,6CA8Bb,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { DOMElement, HtmlRendererContextValue, RNStyle } from '../../types';
2
+ interface ImageTagProps {
3
+ node: DOMElement;
4
+ style: RNStyle;
5
+ nodeKey: string;
6
+ ctx: HtmlRendererContextValue;
7
+ }
8
+ /**
9
+ * Renders an `<img>` tag with:
10
+ * - Cached dimension fetching via `Image.getSize()`
11
+ * - Proportional scaling to fit `contentWidth` / `maxImagesWidth`
12
+ * - Loading placeholder and error fallback
13
+ * - Optional `onImagePress` callback
14
+ * - Accessibility labels from `alt`, `aria-label`, `title`
15
+ */
16
+ export declare const ImageTag: import("react").MemoExoticComponent<({ node, style, nodeKey, ctx, }: ImageTagProps) => import("react/jsx-runtime").JSX.Element | null>;
17
+ export {};
18
+ //# sourceMappingURL=ImageTag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageTag.d.ts","sourceRoot":"","sources":["../../../../../src/renderer/tags/ImageTag.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,UAAU,EACV,wBAAwB,EACxB,OAAO,EACR,MAAM,aAAa,CAAC;AAOrB,UAAU,aAAa;IACrB,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,wBAAwB,CAAC;CAC/B;AAOD;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,uEAKlB,aAAa,oDAgBd,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { DOMNode, RNStyle, HtmlRendererContextValue } from '../../types';
3
+ interface LinkTagProps {
4
+ node: {
5
+ attributes: Record<string, string>;
6
+ children: DOMNode[];
7
+ };
8
+ style: RNStyle;
9
+ nodeKey: string;
10
+ ctx: HtmlRendererContextValue;
11
+ renderNodes: (nodes: DOMNode[], ctx: HtmlRendererContextValue, keyPrefix: string) => ReactNode[];
12
+ }
13
+ /**
14
+ * Renders a block-level `<a>` tag as a TouchableOpacity wrapping a Text.
15
+ * Includes accessibility role, label, and hint.
16
+ */
17
+ export declare const LinkTag: import("react").MemoExoticComponent<({ node, style, nodeKey, ctx, renderNodes, }: LinkTagProps) => import("react/jsx-runtime").JSX.Element>;
18
+ export {};
19
+ //# sourceMappingURL=LinkTag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinkTag.d.ts","sourceRoot":"","sources":["../../../../../src/renderer/tags/LinkTag.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE1D,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAQ9E,UAAU,YAAY;IACpB,IAAI,EAAE;QACJ,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACnC,QAAQ,EAAE,OAAO,EAAE,CAAC;KACrB,CAAC;IACF,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,wBAAwB,CAAC;IAC9B,WAAW,EAAE,CACX,KAAK,EAAE,OAAO,EAAE,EAChB,GAAG,EAAE,wBAAwB,EAC7B,SAAS,EAAE,MAAM,KACd,SAAS,EAAE,CAAC;CAClB;AAED;;;GAGG;AACH,eAAO,MAAM,OAAO,oFAMjB,YAAY,6CAwCb,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { DOMNode, DOMElement, RNStyle, HtmlRendererContextValue } from '../../types';
3
+ interface ListTagProps {
4
+ node: DOMElement;
5
+ style: RNStyle;
6
+ nodeKey: string;
7
+ ctx: HtmlRendererContextValue;
8
+ renderNodes: (nodes: DOMNode[], ctx: HtmlRendererContextValue, keyPrefix: string) => ReactNode[];
9
+ }
10
+ /**
11
+ * Renders `<ul>` and `<ol>` lists with proper bullets/numbers and nesting.
12
+ */
13
+ export declare const ListTag: import("react").MemoExoticComponent<({ node, style, nodeKey, ctx, renderNodes, }: ListTagProps) => import("react/jsx-runtime").JSX.Element>;
14
+ export {};
15
+ //# sourceMappingURL=ListTags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ListTags.d.ts","sourceRoot":"","sources":["../../../../../src/renderer/tags/ListTags.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,KAAK,EACV,OAAO,EACP,UAAU,EACV,OAAO,EACP,wBAAwB,EACzB,MAAM,aAAa,CAAC;AAOrB,UAAU,YAAY;IACpB,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,wBAAwB,CAAC;IAC9B,WAAW,EAAE,CACX,KAAK,EAAE,OAAO,EAAE,EAChB,GAAG,EAAE,wBAAwB,EAC7B,SAAS,EAAE,MAAM,KACd,SAAS,EAAE,CAAC;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,OAAO,oFAMjB,YAAY,6CAqGb,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { DOMElement, RNStyle, HtmlRendererContextValue } from '../../types';
2
+ interface MediaTagProps {
3
+ node: DOMElement;
4
+ style: RNStyle;
5
+ nodeKey: string;
6
+ ctx: HtmlRendererContextValue;
7
+ }
8
+ /**
9
+ * Placeholder renderers for `<video>` and `<audio>` tags.
10
+ */
11
+ export declare const VideoTag: import("react").MemoExoticComponent<({ node, style, nodeKey, ctx, }: MediaTagProps) => import("react/jsx-runtime").JSX.Element>;
12
+ export declare const AudioTag: import("react").MemoExoticComponent<({ node, style, nodeKey, }: MediaTagProps) => import("react/jsx-runtime").JSX.Element>;
13
+ export {};
14
+ //# sourceMappingURL=MediaTags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MediaTags.d.ts","sourceRoot":"","sources":["../../../../../src/renderer/tags/MediaTags.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,OAAO,EACP,wBAAwB,EACzB,MAAM,aAAa,CAAC;AAErB,UAAU,aAAa;IACrB,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,wBAAwB,CAAC;CAC/B;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,uEAKlB,aAAa,6CAkBd,CAAC;AAEH,eAAO,MAAM,QAAQ,kEAIlB,aAAa,6CAad,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { DOMNode, DOMElement, RNStyle, HtmlRendererContextValue } from '../../types';
3
+ interface TableTagProps {
4
+ node: DOMElement;
5
+ style: RNStyle;
6
+ nodeKey: string;
7
+ ctx: HtmlRendererContextValue;
8
+ renderNodes: (nodes: DOMNode[], ctx: HtmlRendererContextValue, keyPrefix: string) => ReactNode[];
9
+ }
10
+ /**
11
+ * Renders a `<table>` wrapped in a horizontal ScrollView for overflow.
12
+ */
13
+ export declare const TableTag: import("react").MemoExoticComponent<({ node, style, nodeKey, ctx, renderNodes, }: TableTagProps) => import("react/jsx-runtime").JSX.Element>;
14
+ export {};
15
+ //# sourceMappingURL=TableTags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableTags.d.ts","sourceRoot":"","sources":["../../../../../src/renderer/tags/TableTags.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,KAAK,EACV,OAAO,EACP,UAAU,EACV,OAAO,EACP,wBAAwB,EACzB,MAAM,aAAa,CAAC;AAGrB,UAAU,aAAa;IACrB,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,wBAAwB,CAAC;IAC9B,WAAW,EAAE,CACX,KAAK,EAAE,OAAO,EAAE,EAChB,GAAG,EAAE,wBAAwB,EAC7B,SAAS,EAAE,MAAM,KACd,SAAS,EAAE,CAAC;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,oFAMlB,aAAa,6CAkBd,CAAC"}