@qretaio/html2json 0.5.2 → 0.5.4
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/html2json.d.ts +32 -0
- package/html2json.js +111 -0
- package/html2json_bg.wasm +0 -0
- package/package.json +15 -40
package/html2json.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
5
|
+
|
|
6
|
+
export interface InitOutput {
|
|
7
|
+
readonly memory: WebAssembly.Memory;
|
|
8
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
9
|
+
readonly __wbindgen_start: () => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
16
|
+
* a precompiled `WebAssembly.Module`.
|
|
17
|
+
*
|
|
18
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
19
|
+
*
|
|
20
|
+
* @returns {InitOutput}
|
|
21
|
+
*/
|
|
22
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
26
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
27
|
+
*
|
|
28
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
29
|
+
*
|
|
30
|
+
* @returns {Promise<InitOutput>}
|
|
31
|
+
*/
|
|
32
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/html2json.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/* @ts-self-types="./html2json.d.ts" */
|
|
2
|
+
|
|
3
|
+
function __wbg_get_imports() {
|
|
4
|
+
const import0 = {
|
|
5
|
+
__proto__: null,
|
|
6
|
+
__wbindgen_init_externref_table: function() {
|
|
7
|
+
const table = wasm.__wbindgen_externrefs;
|
|
8
|
+
const offset = table.grow(4);
|
|
9
|
+
table.set(0, undefined);
|
|
10
|
+
table.set(offset + 0, undefined);
|
|
11
|
+
table.set(offset + 1, null);
|
|
12
|
+
table.set(offset + 2, true);
|
|
13
|
+
table.set(offset + 3, false);
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
__proto__: null,
|
|
18
|
+
"./html2json_bg.js": import0,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let wasmModule, wasm;
|
|
23
|
+
function __wbg_finalize_init(instance, module) {
|
|
24
|
+
wasm = instance.exports;
|
|
25
|
+
wasmModule = module;
|
|
26
|
+
wasm.__wbindgen_start();
|
|
27
|
+
return wasm;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function __wbg_load(module, imports) {
|
|
31
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
32
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
33
|
+
try {
|
|
34
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
35
|
+
} catch (e) {
|
|
36
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
37
|
+
|
|
38
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
39
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
40
|
+
|
|
41
|
+
} else { throw e; }
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const bytes = await module.arrayBuffer();
|
|
46
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
47
|
+
} else {
|
|
48
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
49
|
+
|
|
50
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
51
|
+
return { instance, module };
|
|
52
|
+
} else {
|
|
53
|
+
return instance;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function expectedResponseType(type) {
|
|
58
|
+
switch (type) {
|
|
59
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function initSync(module) {
|
|
66
|
+
if (wasm !== undefined) return wasm;
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
if (module !== undefined) {
|
|
70
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
71
|
+
({module} = module)
|
|
72
|
+
} else {
|
|
73
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const imports = __wbg_get_imports();
|
|
78
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
79
|
+
module = new WebAssembly.Module(module);
|
|
80
|
+
}
|
|
81
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
82
|
+
return __wbg_finalize_init(instance, module);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function __wbg_init(module_or_path) {
|
|
86
|
+
if (wasm !== undefined) return wasm;
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
if (module_or_path !== undefined) {
|
|
90
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
91
|
+
({module_or_path} = module_or_path)
|
|
92
|
+
} else {
|
|
93
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (module_or_path === undefined) {
|
|
98
|
+
module_or_path = new URL('html2json_bg.wasm', import.meta.url);
|
|
99
|
+
}
|
|
100
|
+
const imports = __wbg_get_imports();
|
|
101
|
+
|
|
102
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
103
|
+
module_or_path = fetch(module_or_path);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
107
|
+
|
|
108
|
+
return __wbg_finalize_init(instance, module);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,49 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qretaio/html2json",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
"html",
|
|
7
|
-
"json",
|
|
8
|
-
"parser",
|
|
9
|
-
"scraper",
|
|
10
|
-
"web-scraping",
|
|
11
|
-
"css-selector",
|
|
12
|
-
"html-parser",
|
|
13
|
-
"wasm",
|
|
14
|
-
"webassembly",
|
|
15
|
-
"extraction",
|
|
16
|
-
"cheerio"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"collaborators": [
|
|
5
|
+
"Qreta Dev <qretadev@gmail.com>"
|
|
17
6
|
],
|
|
7
|
+
"description": "HTML to JSON extractor",
|
|
8
|
+
"version": "0.5.4",
|
|
18
9
|
"license": "MIT",
|
|
19
|
-
"author": "Qreta Dev <qretadev@gmail.com>",
|
|
20
10
|
"repository": {
|
|
21
11
|
"type": "git",
|
|
22
|
-
"url": "
|
|
12
|
+
"url": "https://github.com/qretaio/html2json"
|
|
23
13
|
},
|
|
24
|
-
"homepage": "https://github.com/qretaio/html2json#readme",
|
|
25
|
-
"bugs": {
|
|
26
|
-
"url": "https://github.com/qretaio/html2json/issues"
|
|
27
|
-
},
|
|
28
|
-
"main": "pkg/html2json.js",
|
|
29
|
-
"browser": "pkg/html2json.js",
|
|
30
|
-
"types": "pkg/html2json.d.ts",
|
|
31
14
|
"files": [
|
|
32
|
-
"
|
|
33
|
-
"
|
|
15
|
+
"html2json_bg.wasm",
|
|
16
|
+
"html2json.js",
|
|
17
|
+
"html2json.d.ts"
|
|
34
18
|
],
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"prepublishOnly": "npm run build:release"
|
|
42
|
-
},
|
|
43
|
-
"engines": {
|
|
44
|
-
"node": ">=16"
|
|
45
|
-
},
|
|
46
|
-
"devDependencies": {
|
|
47
|
-
"wasm-pack": "^0.13.0"
|
|
48
|
-
}
|
|
49
|
-
}
|
|
19
|
+
"main": "html2json.js",
|
|
20
|
+
"types": "html2json.d.ts",
|
|
21
|
+
"sideEffects": [
|
|
22
|
+
"./snippets/*"
|
|
23
|
+
]
|
|
24
|
+
}
|