react-native-fast-html-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/FastHtmlParser.podspec +36 -0
- package/LICENSE +20 -0
- package/README.md +435 -0
- package/android/CMakeLists.txt +31 -0
- package/android/build.gradle +121 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +11 -0
- package/android/src/main/java/com/margelo/nitro/fasthtmlparser/FastHtmlParserPackage.kt +22 -0
- package/android/src/main/jniLibs/arm64-v8a/libhtml_2_json.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libhtml_2_json.so +0 -0
- package/android/src/main/jniLibs/x86/libhtml_2_json.so +0 -0
- package/android/src/main/jniLibs/x86_64/libhtml_2_json.so +0 -0
- package/cpp/HybridFastHtmlParser.cpp +178 -0
- package/cpp/HybridFastHtmlParser.hpp +224 -0
- package/ios/libs/libhtml_2_json.xcframework/Info.plist +44 -0
- package/ios/libs/libhtml_2_json.xcframework/ios-arm64/libhtml_2_json.a +0 -0
- package/ios/libs/libhtml_2_json.xcframework/ios-arm64_x86_64-simulator/libhtml_2_json.a +0 -0
- package/lib/module/FastHtmlParser.nitro.js +4 -0
- package/lib/module/FastHtmlParser.nitro.js.map +1 -0
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/parser.js +6 -0
- package/lib/module/parser.js.map +1 -0
- package/lib/module/parser.native.js +8 -0
- package/lib/module/parser.native.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/FastHtmlParser.nitro.d.ts +81 -0
- package/lib/typescript/src/FastHtmlParser.nitro.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/parser.d.ts +3 -0
- package/lib/typescript/src/parser.d.ts.map +1 -0
- package/lib/typescript/src/parser.native.d.ts +3 -0
- package/lib/typescript/src/parser.native.d.ts.map +1 -0
- package/nitro.json +23 -0
- package/nitrogen/generated/android/fasthtmlparser+autolinking.cmake +88 -0
- package/nitrogen/generated/android/fasthtmlparser+autolinking.gradle +27 -0
- package/nitrogen/generated/android/fasthtmlparserOnLoad.cpp +49 -0
- package/nitrogen/generated/android/fasthtmlparserOnLoad.hpp +34 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/fasthtmlparser/fasthtmlparserOnLoad.kt +35 -0
- package/nitrogen/generated/ios/FastHtmlParser+autolinking.rb +62 -0
- package/nitrogen/generated/ios/FastHtmlParser-Swift-Cxx-Bridge.cpp +17 -0
- package/nitrogen/generated/ios/FastHtmlParser-Swift-Cxx-Bridge.hpp +27 -0
- package/nitrogen/generated/ios/FastHtmlParser-Swift-Cxx-Umbrella.hpp +38 -0
- package/nitrogen/generated/ios/FastHtmlParserAutolinking.mm +35 -0
- package/nitrogen/generated/ios/FastHtmlParserAutolinking.swift +16 -0
- package/nitrogen/generated/shared/c++/HybridContentBlockSpec.cpp +39 -0
- package/nitrogen/generated/shared/c++/HybridContentBlockSpec.hpp +96 -0
- package/nitrogen/generated/shared/c++/HybridDefinitionItemSpec.cpp +24 -0
- package/nitrogen/generated/shared/c++/HybridDefinitionItemSpec.hpp +68 -0
- package/nitrogen/generated/shared/c++/HybridFastHtmlParserSpec.cpp +21 -0
- package/nitrogen/generated/shared/c++/HybridFastHtmlParserSpec.hpp +67 -0
- package/nitrogen/generated/shared/c++/HybridInlineNodeSpec.cpp +25 -0
- package/nitrogen/generated/shared/c++/HybridInlineNodeSpec.hpp +70 -0
- package/nitrogen/generated/shared/c++/HybridListItemSpec.cpp +24 -0
- package/nitrogen/generated/shared/c++/HybridListItemSpec.hpp +71 -0
- package/nitrogen/generated/shared/c++/HybridParsedArticleSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridParsedArticleSpec.hpp +66 -0
- package/nitrogen/generated/shared/c++/HybridTableCellSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridTableCellSpec.hpp +66 -0
- package/nitrogen/generated/shared/c++/HybridTableRowSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridTableRowSpec.hpp +66 -0
- package/package.json +153 -0
- package/scripts/postinstall.js +234 -0
- package/src/FastHtmlParser.nitro.ts +86 -0
- package/src/index.tsx +12 -0
- package/src/parser.native.tsx +9 -0
- package/src/parser.tsx +7 -0
package/package.json
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-native-fast-html-parser",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A lightning-fast HTML parser library for React Native that converts raw HTML fragments into a structured JSON AST tree. Built on a high-performance Rust core and integrated via direct C++ JSI HostObjects, it achieves pure zero-copy shared-memory access on-device. This avoids standard string/JSON serialization overhead and Hermes garbage collection pauses during render loops.",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"react-native-fast-html-parser-source": "./src/index.tsx",
|
|
10
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
11
|
+
"default": "./lib/module/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src",
|
|
17
|
+
"lib",
|
|
18
|
+
"android",
|
|
19
|
+
"ios",
|
|
20
|
+
"cpp",
|
|
21
|
+
"nitrogen",
|
|
22
|
+
"nitro.json",
|
|
23
|
+
"*.podspec",
|
|
24
|
+
"react-native.config.js",
|
|
25
|
+
"!ios/build",
|
|
26
|
+
"!android/build",
|
|
27
|
+
"!android/gradle",
|
|
28
|
+
"!android/gradlew",
|
|
29
|
+
"!android/gradlew.bat",
|
|
30
|
+
"!android/local.properties",
|
|
31
|
+
"!**/__tests__",
|
|
32
|
+
"!**/__fixtures__",
|
|
33
|
+
"!**/__mocks__",
|
|
34
|
+
"!**/.*",
|
|
35
|
+
"scripts"
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"example": "yarn workspace react-native-fast-html-parser-example",
|
|
39
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
40
|
+
"prepare": "bob build",
|
|
41
|
+
"nitrogen": "nitrogen",
|
|
42
|
+
"typecheck": "tsc",
|
|
43
|
+
"test": "jest",
|
|
44
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
45
|
+
"postinstall": "node scripts/postinstall.js"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"react-native",
|
|
49
|
+
"ios",
|
|
50
|
+
"android"
|
|
51
|
+
],
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "git+https://github.com/abhishekce17/react-native-fast-html-parser.git"
|
|
55
|
+
},
|
|
56
|
+
"author": "abhishekce17 <abhisheklprajapati18@gmail.com> (https://github.com/abhishekce17)",
|
|
57
|
+
"license": "MIT",
|
|
58
|
+
"bugs": {
|
|
59
|
+
"url": "https://github.com/abhishekce17/react-native-fast-html-parser/issues"
|
|
60
|
+
},
|
|
61
|
+
"homepage": "https://github.com/abhishekce17/react-native-fast-html-parser#readme",
|
|
62
|
+
"publishConfig": {
|
|
63
|
+
"registry": "https://registry.npmjs.org/"
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@eslint/compat": "^2.1.0",
|
|
67
|
+
"@eslint/eslintrc": "^3.3.5",
|
|
68
|
+
"@eslint/js": "^10.0.1",
|
|
69
|
+
"@jest/globals": "^29.7.0",
|
|
70
|
+
"@react-native/babel-preset": "0.85.0",
|
|
71
|
+
"@react-native/eslint-config": "0.85.0",
|
|
72
|
+
"@react-native/jest-preset": "0.85.0",
|
|
73
|
+
"@types/react": "^19.2.0",
|
|
74
|
+
"del-cli": "^7.0.0",
|
|
75
|
+
"eslint": "^9.39.4",
|
|
76
|
+
"eslint-config-prettier": "^10.1.8",
|
|
77
|
+
"eslint-plugin-ft-flow": "^3.0.11",
|
|
78
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
79
|
+
"jest": "^29.7.0",
|
|
80
|
+
"nitrogen": "^0.37.1",
|
|
81
|
+
"prettier": "^3.8.3",
|
|
82
|
+
"react": "19.2.3",
|
|
83
|
+
"react-native": "0.85.0",
|
|
84
|
+
"react-native-builder-bob": "^0.43.0",
|
|
85
|
+
"react-native-nitro-modules": "^0.37.1",
|
|
86
|
+
"turbo": "^2.9.16",
|
|
87
|
+
"typescript": "^6.0.3"
|
|
88
|
+
},
|
|
89
|
+
"peerDependencies": {
|
|
90
|
+
"react": "*",
|
|
91
|
+
"react-native": "*",
|
|
92
|
+
"react-native-nitro-modules": "^0.37.1"
|
|
93
|
+
},
|
|
94
|
+
"workspaces": [
|
|
95
|
+
"example"
|
|
96
|
+
],
|
|
97
|
+
"packageManager": "yarn@4.11.0",
|
|
98
|
+
"react-native-builder-bob": {
|
|
99
|
+
"source": "src",
|
|
100
|
+
"output": "lib",
|
|
101
|
+
"targets": [
|
|
102
|
+
[
|
|
103
|
+
"custom",
|
|
104
|
+
{
|
|
105
|
+
"script": "nitrogen",
|
|
106
|
+
"clean": "nitrogen/"
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
[
|
|
110
|
+
"module",
|
|
111
|
+
{
|
|
112
|
+
"esm": true
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
[
|
|
116
|
+
"typescript",
|
|
117
|
+
{
|
|
118
|
+
"project": "tsconfig.build.json"
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
"jest": {
|
|
124
|
+
"preset": "@react-native/jest-preset",
|
|
125
|
+
"testEnvironmentOptions": {
|
|
126
|
+
"customExportConditions": [
|
|
127
|
+
"require",
|
|
128
|
+
"react-native",
|
|
129
|
+
"<%- project.sourceCondition -%>"
|
|
130
|
+
]
|
|
131
|
+
},
|
|
132
|
+
"modulePathIgnorePatterns": [
|
|
133
|
+
"<rootDir>/example/node_modules",
|
|
134
|
+
"<rootDir>/lib/"
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
"prettier": {
|
|
138
|
+
"quoteProps": "consistent",
|
|
139
|
+
"singleQuote": true,
|
|
140
|
+
"tabWidth": 2,
|
|
141
|
+
"trailingComma": "es5",
|
|
142
|
+
"useTabs": false
|
|
143
|
+
},
|
|
144
|
+
"create-react-native-library": {
|
|
145
|
+
"type": "nitro-module",
|
|
146
|
+
"languages": "kotlin-swift",
|
|
147
|
+
"tools": [
|
|
148
|
+
"jest",
|
|
149
|
+
"eslint"
|
|
150
|
+
],
|
|
151
|
+
"version": "0.63.0"
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Postinstall script for react-native-fast-html-parser
|
|
4
|
+
*
|
|
5
|
+
* Downloads precompiled Rust native binaries from GitHub Releases
|
|
6
|
+
* so developers do not need Rust installed on their machines.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
const https = require('https');
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
const path = require('path');
|
|
14
|
+
|
|
15
|
+
const pkg = require('../package.json');
|
|
16
|
+
const VERSION = pkg.version;
|
|
17
|
+
const REPO = 'abhishekce17/react-native-fast-html-parser';
|
|
18
|
+
const BASE_URL =
|
|
19
|
+
'https://github.com/' + REPO + '/releases/download/v' + VERSION;
|
|
20
|
+
const PKG_ROOT = path.resolve(__dirname, '..');
|
|
21
|
+
|
|
22
|
+
const BINARIES = [
|
|
23
|
+
{
|
|
24
|
+
name: 'libhtml_2_json-ios-device.a',
|
|
25
|
+
dest: path.join(PKG_ROOT, 'ios', 'libs', 'device', 'libhtml_2_json.a'),
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'libhtml_2_json-ios-sim.a',
|
|
29
|
+
dest: path.join(PKG_ROOT, 'ios', 'libs', 'sim', 'libhtml_2_json.a'),
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'libhtml_2_json-android-arm64-v8a.so',
|
|
33
|
+
dest: path.join(
|
|
34
|
+
PKG_ROOT,
|
|
35
|
+
'android',
|
|
36
|
+
'src',
|
|
37
|
+
'main',
|
|
38
|
+
'jniLibs',
|
|
39
|
+
'arm64-v8a',
|
|
40
|
+
'libhtml_2_json.so'
|
|
41
|
+
),
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'libhtml_2_json-android-armeabi-v7a.so',
|
|
45
|
+
dest: path.join(
|
|
46
|
+
PKG_ROOT,
|
|
47
|
+
'android',
|
|
48
|
+
'src',
|
|
49
|
+
'main',
|
|
50
|
+
'jniLibs',
|
|
51
|
+
'armeabi-v7a',
|
|
52
|
+
'libhtml_2_json.so'
|
|
53
|
+
),
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'libhtml_2_json-android-x86.so',
|
|
57
|
+
dest: path.join(
|
|
58
|
+
PKG_ROOT,
|
|
59
|
+
'android',
|
|
60
|
+
'src',
|
|
61
|
+
'main',
|
|
62
|
+
'jniLibs',
|
|
63
|
+
'x86',
|
|
64
|
+
'libhtml_2_json.so'
|
|
65
|
+
),
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'libhtml_2_json-android-x86_64.so',
|
|
69
|
+
dest: path.join(
|
|
70
|
+
PKG_ROOT,
|
|
71
|
+
'android',
|
|
72
|
+
'src',
|
|
73
|
+
'main',
|
|
74
|
+
'jniLibs',
|
|
75
|
+
'x86_64',
|
|
76
|
+
'libhtml_2_json.so'
|
|
77
|
+
),
|
|
78
|
+
},
|
|
79
|
+
];
|
|
80
|
+
|
|
81
|
+
function download(url, destPath) {
|
|
82
|
+
return new Promise(function (resolve, reject) {
|
|
83
|
+
fs.mkdirSync(path.dirname(destPath), { recursive: true });
|
|
84
|
+
const file = fs.createWriteStream(destPath);
|
|
85
|
+
|
|
86
|
+
function get(currentUrl) {
|
|
87
|
+
https
|
|
88
|
+
.get(
|
|
89
|
+
currentUrl,
|
|
90
|
+
{
|
|
91
|
+
headers: {
|
|
92
|
+
'User-Agent': 'react-native-fast-html-parser-postinstall',
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
function (res) {
|
|
96
|
+
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
97
|
+
file.close();
|
|
98
|
+
return get(res.headers.location);
|
|
99
|
+
}
|
|
100
|
+
if (res.statusCode !== 200) {
|
|
101
|
+
file.close();
|
|
102
|
+
try {
|
|
103
|
+
fs.unlinkSync(destPath);
|
|
104
|
+
} catch {}
|
|
105
|
+
return reject(
|
|
106
|
+
new Error(
|
|
107
|
+
'Failed to download ' +
|
|
108
|
+
currentUrl +
|
|
109
|
+
': HTTP ' +
|
|
110
|
+
res.statusCode
|
|
111
|
+
)
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
res.pipe(file);
|
|
115
|
+
file.on('finish', function () {
|
|
116
|
+
file.close(resolve);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
)
|
|
120
|
+
.on('error', function (err) {
|
|
121
|
+
file.close();
|
|
122
|
+
try {
|
|
123
|
+
fs.unlinkSync(destPath);
|
|
124
|
+
} catch {}
|
|
125
|
+
reject(err);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
get(url);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
async function main() {
|
|
134
|
+
console.log(
|
|
135
|
+
'\n[react-native-fast-html-parser] Downloading native binaries v' +
|
|
136
|
+
VERSION +
|
|
137
|
+
'...'
|
|
138
|
+
);
|
|
139
|
+
console.log('[react-native-fast-html-parser] Source: ' + BASE_URL + '\n');
|
|
140
|
+
|
|
141
|
+
let failed = false;
|
|
142
|
+
|
|
143
|
+
for (const binary of BINARIES) {
|
|
144
|
+
if (fs.existsSync(binary.dest)) {
|
|
145
|
+
console.log(' \u2713 Already exists: ' + binary.name);
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const url = BASE_URL + '/' + binary.name;
|
|
150
|
+
process.stdout.write(' \u2193 Downloading ' + binary.name + '...');
|
|
151
|
+
|
|
152
|
+
try {
|
|
153
|
+
await download(url, binary.dest);
|
|
154
|
+
console.log(' \u2713');
|
|
155
|
+
} catch (err) {
|
|
156
|
+
console.log(' \u2717');
|
|
157
|
+
console.error(' Error: ' + err.message);
|
|
158
|
+
failed = true;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Assemble iOS XCFramework on macOS machines
|
|
163
|
+
if (process.platform === 'darwin') {
|
|
164
|
+
const xcframeworkPath = path.join(
|
|
165
|
+
PKG_ROOT,
|
|
166
|
+
'ios',
|
|
167
|
+
'libs',
|
|
168
|
+
'libhtml_2_json.xcframework'
|
|
169
|
+
);
|
|
170
|
+
if (!fs.existsSync(xcframeworkPath)) {
|
|
171
|
+
console.log(' ⚙ Assembling iOS XCFramework...');
|
|
172
|
+
const devicePath = path.join(
|
|
173
|
+
PKG_ROOT,
|
|
174
|
+
'ios',
|
|
175
|
+
'libs',
|
|
176
|
+
'device',
|
|
177
|
+
'libhtml_2_json.a'
|
|
178
|
+
);
|
|
179
|
+
const simPath = path.join(
|
|
180
|
+
PKG_ROOT,
|
|
181
|
+
'ios',
|
|
182
|
+
'libs',
|
|
183
|
+
'sim',
|
|
184
|
+
'libhtml_2_json.a'
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
try {
|
|
188
|
+
const { execSync } = require('child_process');
|
|
189
|
+
execSync(
|
|
190
|
+
'xcodebuild -create-xcframework -library "' +
|
|
191
|
+
devicePath +
|
|
192
|
+
'" -library "' +
|
|
193
|
+
simPath +
|
|
194
|
+
'" -output "' +
|
|
195
|
+
xcframeworkPath +
|
|
196
|
+
'"',
|
|
197
|
+
{ stdio: 'ignore' }
|
|
198
|
+
);
|
|
199
|
+
console.log(' ✓ XCFramework assembled successfully.');
|
|
200
|
+
} catch (err) {
|
|
201
|
+
console.error(' ✗ Failed to assemble XCFramework: ' + err.message);
|
|
202
|
+
failed = true;
|
|
203
|
+
}
|
|
204
|
+
} else {
|
|
205
|
+
console.log(' ✓ XCFramework already exists.');
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (failed) {
|
|
210
|
+
console.error(
|
|
211
|
+
[
|
|
212
|
+
'',
|
|
213
|
+
'[react-native-fast-html-parser] Some binaries failed to download.',
|
|
214
|
+
' This may happen if:',
|
|
215
|
+
' - You are offline',
|
|
216
|
+
' - Release v' + VERSION + ' has not been published yet on GitHub',
|
|
217
|
+
'',
|
|
218
|
+
' Manually download them from:',
|
|
219
|
+
' https://github.com/' + REPO + '/releases/tag/v' + VERSION,
|
|
220
|
+
'',
|
|
221
|
+
' Place them in:',
|
|
222
|
+
' ios/libs/device/libhtml_2_json.a',
|
|
223
|
+
' ios/libs/sim/libhtml_2_json.a',
|
|
224
|
+
' android/src/main/jniLibs/<ABI>/libhtml_2_json.so',
|
|
225
|
+
'',
|
|
226
|
+
].join('\n')
|
|
227
|
+
);
|
|
228
|
+
process.exit(0);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
console.log('\n[react-native-fast-html-parser] All binaries ready.\n');
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
main();
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
+
|
|
3
|
+
export interface InlineNode extends HybridObject<{
|
|
4
|
+
ios: 'c++';
|
|
5
|
+
android: 'c++';
|
|
6
|
+
}> {
|
|
7
|
+
readonly type: string;
|
|
8
|
+
readonly text: string;
|
|
9
|
+
readonly url: string;
|
|
10
|
+
readonly childCount: number;
|
|
11
|
+
getChild(index: number): InlineNode | null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ListItem extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
|
|
15
|
+
readonly childCount: number;
|
|
16
|
+
getChild(index: number): InlineNode | null;
|
|
17
|
+
readonly nestedCount: number;
|
|
18
|
+
getNested(index: number): ContentBlock | null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface TableCell extends HybridObject<{
|
|
22
|
+
ios: 'c++';
|
|
23
|
+
android: 'c++';
|
|
24
|
+
}> {
|
|
25
|
+
readonly childCount: number;
|
|
26
|
+
getChild(index: number): InlineNode | null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface TableRow extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
|
|
30
|
+
readonly cellCount: number;
|
|
31
|
+
getCell(index: number): TableCell | null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface DefinitionItem extends HybridObject<{
|
|
35
|
+
ios: 'c++';
|
|
36
|
+
android: 'c++';
|
|
37
|
+
}> {
|
|
38
|
+
readonly termCount: number;
|
|
39
|
+
getTerm(index: number): InlineNode | null;
|
|
40
|
+
readonly defCount: number;
|
|
41
|
+
getDef(index: number): InlineNode | null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface ContentBlock extends HybridObject<{
|
|
45
|
+
ios: 'c++';
|
|
46
|
+
android: 'c++';
|
|
47
|
+
}> {
|
|
48
|
+
readonly type: string;
|
|
49
|
+
readonly level: number;
|
|
50
|
+
readonly url: string;
|
|
51
|
+
readonly alt: string;
|
|
52
|
+
readonly caption: string;
|
|
53
|
+
readonly code: string;
|
|
54
|
+
readonly language: string;
|
|
55
|
+
readonly src: string;
|
|
56
|
+
readonly poster: string;
|
|
57
|
+
readonly title: string;
|
|
58
|
+
|
|
59
|
+
readonly childCount: number;
|
|
60
|
+
getChild(index: number): InlineNode | null;
|
|
61
|
+
getQuoteChild(index: number): ContentBlock | null;
|
|
62
|
+
|
|
63
|
+
readonly ordered: boolean;
|
|
64
|
+
readonly itemCount: number;
|
|
65
|
+
getItem(index: number): ListItem | null;
|
|
66
|
+
|
|
67
|
+
readonly rowCount: number;
|
|
68
|
+
getRow(index: number): TableRow | null;
|
|
69
|
+
|
|
70
|
+
getDefItem(index: number): DefinitionItem | null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface ParsedArticle extends HybridObject<{
|
|
74
|
+
ios: 'c++';
|
|
75
|
+
android: 'c++';
|
|
76
|
+
}> {
|
|
77
|
+
readonly length: number;
|
|
78
|
+
getBlock(index: number): ContentBlock | null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface FastHtmlParser extends HybridObject<{
|
|
82
|
+
ios: 'c++';
|
|
83
|
+
android: 'c++';
|
|
84
|
+
}> {
|
|
85
|
+
parse(html: string): ParsedArticle | null;
|
|
86
|
+
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NitroModules } from 'react-native-nitro-modules';
|
|
2
|
+
import type { FastHtmlParser, ParsedArticle } from './FastHtmlParser.nitro';
|
|
3
|
+
|
|
4
|
+
const FastHtmlParserHybridObject =
|
|
5
|
+
NitroModules.createHybridObject<FastHtmlParser>('FastHtmlParser');
|
|
6
|
+
|
|
7
|
+
export function parseHTML(html: string): ParsedArticle | null {
|
|
8
|
+
return FastHtmlParserHybridObject.parse(html);
|
|
9
|
+
}
|