citeme-engine-wasm 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/index.d.ts +35 -0
- package/index.js +14 -0
- package/package.json +29 -0
- package/pkg/citeme_engine_wasm.d.ts +127 -0
- package/pkg/citeme_engine_wasm.js +715 -0
- package/pkg/citeme_engine_wasm_bg.wasm +0 -0
- package/pkg/citeme_engine_wasm_bg.wasm.d.ts +24 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// js/index.d.ts
|
|
2
|
+
|
|
3
|
+
export interface FormatResult {
|
|
4
|
+
reference: string;
|
|
5
|
+
inText: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface ParseResult {
|
|
9
|
+
entries: unknown[];
|
|
10
|
+
errors: Array<{ preview: string; error: string }>;
|
|
11
|
+
format: string;
|
|
12
|
+
truncated: boolean;
|
|
13
|
+
scannedEntries: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export declare class WasmCitationEngine {
|
|
17
|
+
constructor();
|
|
18
|
+
loadStyle(name: string, cslXml: string): void;
|
|
19
|
+
loadLocale(localeCode: string, localeXml: string): void;
|
|
20
|
+
hasStyle(name: string): boolean;
|
|
21
|
+
formatBatch(cslJsonStr: string, styleName: string, localeCode: string, abntPostProcess: boolean): string;
|
|
22
|
+
formatOne(cslJsonStr: string, styleName: string, localeCode: string, abntPostProcess: boolean): string;
|
|
23
|
+
parseBibtex(input: string, maxEntries?: number): string;
|
|
24
|
+
parseRis(input: string, maxEntries?: number): string;
|
|
25
|
+
parseCslJson(input: string, maxEntries?: number): string;
|
|
26
|
+
parseMedline(input: string, maxEntries?: number): string;
|
|
27
|
+
detectFormat(input: string): 'bibtex' | 'ris' | 'csl-json' | 'medline' | 'unknown';
|
|
28
|
+
parseAuto(input: string, maxEntries?: number): string;
|
|
29
|
+
exportBibtex(cslJsonStr: string): string;
|
|
30
|
+
exportRis(cslJsonStr: string): string;
|
|
31
|
+
exportHayagriva(cslJsonStr: string): string;
|
|
32
|
+
version(): string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export declare function createEngine(): Promise<WasmCitationEngine>;
|
package/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// js/index.js
|
|
2
|
+
import init, { WasmCitationEngine } from './pkg/citeme_engine_wasm.js';
|
|
3
|
+
|
|
4
|
+
let initPromise = null;
|
|
5
|
+
|
|
6
|
+
export async function createEngine() {
|
|
7
|
+
if (!initPromise) {
|
|
8
|
+
initPromise = init();
|
|
9
|
+
}
|
|
10
|
+
await initPromise;
|
|
11
|
+
return new WasmCitationEngine();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { WasmCitationEngine };
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "citeme-engine-wasm",
|
|
3
|
+
"author": "danielnichiata",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/danielnichiata96/citeme-engine"
|
|
7
|
+
},
|
|
8
|
+
"version": "0.1.0",
|
|
9
|
+
"description": "High-performance citation formatting engine powered by Rust/Wasm",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "index.js",
|
|
12
|
+
"types": "index.d.ts",
|
|
13
|
+
"files": [
|
|
14
|
+
"index.js",
|
|
15
|
+
"index.d.ts",
|
|
16
|
+
"pkg/citeme_engine_wasm.js",
|
|
17
|
+
"pkg/citeme_engine_wasm.d.ts",
|
|
18
|
+
"pkg/citeme_engine_wasm_bg.wasm",
|
|
19
|
+
"pkg/citeme_engine_wasm_bg.wasm.d.ts"
|
|
20
|
+
],
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"import": "./index.js",
|
|
24
|
+
"types": "./index.d.ts"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"keywords": ["citation", "csl", "bibtex", "wasm", "academic"],
|
|
28
|
+
"license": "MIT"
|
|
29
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The main engine struct exposed to JavaScript.
|
|
6
|
+
* Holds compiled CSL styles and locales in Wasm linear memory.
|
|
7
|
+
*/
|
|
8
|
+
export class WasmCitationEngine {
|
|
9
|
+
free(): void;
|
|
10
|
+
[Symbol.dispose](): void;
|
|
11
|
+
/**
|
|
12
|
+
* Detect input format (returns "bibtex", "ris", "csl-json", or "unknown").
|
|
13
|
+
*/
|
|
14
|
+
detectFormat(input: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Export CSL-JSON to BibTeX string. Input: JSON string (object or array).
|
|
17
|
+
*/
|
|
18
|
+
exportBibtex(csl_json_str: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Export CSL-JSON to Hayagriva YAML string. Input: JSON string (object or array).
|
|
21
|
+
*/
|
|
22
|
+
exportHayagriva(csl_json_str: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Export CSL-JSON to RIS string. Input: JSON string (object or array).
|
|
25
|
+
*/
|
|
26
|
+
exportRis(csl_json_str: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Format a batch of CSL-JSON items.
|
|
29
|
+
* Input: JSON string of CSL-JSON array. Output: JSON string of FormatResult array.
|
|
30
|
+
*/
|
|
31
|
+
formatBatch(csl_json_str: string, style_name: string, locale_code: string, abnt_post_process: boolean): string;
|
|
32
|
+
/**
|
|
33
|
+
* Format a single CSL-JSON item.
|
|
34
|
+
* Input: JSON string of one CSL-JSON item. Output: JSON string of FormatResult.
|
|
35
|
+
*/
|
|
36
|
+
formatOne(csl_json_str: string, style_name: string, locale_code: string, abnt_post_process: boolean): string;
|
|
37
|
+
/**
|
|
38
|
+
* Check if a style is loaded.
|
|
39
|
+
*/
|
|
40
|
+
hasStyle(name: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Load a locale from XML string.
|
|
43
|
+
*/
|
|
44
|
+
loadLocale(locale_code: string, locale_xml: string): void;
|
|
45
|
+
/**
|
|
46
|
+
* Load a CSL style from XML string. Compiled and cached.
|
|
47
|
+
*/
|
|
48
|
+
loadStyle(name: string, csl_xml: string): void;
|
|
49
|
+
/**
|
|
50
|
+
* Create a new engine instance.
|
|
51
|
+
* Installs panic hook so Rust panics produce readable JS console errors.
|
|
52
|
+
*/
|
|
53
|
+
constructor();
|
|
54
|
+
/**
|
|
55
|
+
* Auto-detect format and parse. Returns JSON string of ParseResult.
|
|
56
|
+
*/
|
|
57
|
+
parseAuto(input: string, max_entries?: number | null): string;
|
|
58
|
+
/**
|
|
59
|
+
* Parse BibTeX content and return CSL-JSON array.
|
|
60
|
+
*/
|
|
61
|
+
parseBibtex(input: string, max_entries?: number | null): string;
|
|
62
|
+
/**
|
|
63
|
+
* Validate and pass through CSL-JSON input. Accepts single object or array.
|
|
64
|
+
*/
|
|
65
|
+
parseCslJson(input: string, max_entries?: number | null): string;
|
|
66
|
+
/**
|
|
67
|
+
* Parse MEDLINE/NBIB content and return CSL-JSON array.
|
|
68
|
+
*/
|
|
69
|
+
parseMedline(input: string, max_entries?: number | null): string;
|
|
70
|
+
/**
|
|
71
|
+
* Parse RIS content and return CSL-JSON array.
|
|
72
|
+
*/
|
|
73
|
+
parseRis(input: string, max_entries?: number | null): string;
|
|
74
|
+
/**
|
|
75
|
+
* Get engine version.
|
|
76
|
+
*/
|
|
77
|
+
version(): string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
81
|
+
|
|
82
|
+
export interface InitOutput {
|
|
83
|
+
readonly memory: WebAssembly.Memory;
|
|
84
|
+
readonly __wbg_wasmcitationengine_free: (a: number, b: number) => void;
|
|
85
|
+
readonly wasmcitationengine_detectFormat: (a: number, b: number, c: number, d: number) => void;
|
|
86
|
+
readonly wasmcitationengine_exportBibtex: (a: number, b: number, c: number, d: number) => void;
|
|
87
|
+
readonly wasmcitationengine_exportHayagriva: (a: number, b: number, c: number, d: number) => void;
|
|
88
|
+
readonly wasmcitationengine_exportRis: (a: number, b: number, c: number, d: number) => void;
|
|
89
|
+
readonly wasmcitationengine_formatBatch: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
90
|
+
readonly wasmcitationengine_formatOne: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
91
|
+
readonly wasmcitationengine_hasStyle: (a: number, b: number, c: number) => number;
|
|
92
|
+
readonly wasmcitationengine_loadLocale: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
93
|
+
readonly wasmcitationengine_loadStyle: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
94
|
+
readonly wasmcitationengine_new: () => number;
|
|
95
|
+
readonly wasmcitationengine_parseAuto: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
96
|
+
readonly wasmcitationengine_parseBibtex: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
97
|
+
readonly wasmcitationengine_parseCslJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
98
|
+
readonly wasmcitationengine_parseMedline: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
99
|
+
readonly wasmcitationengine_parseRis: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
100
|
+
readonly wasmcitationengine_version: (a: number, b: number) => void;
|
|
101
|
+
readonly __wbindgen_export: (a: number, b: number, c: number) => void;
|
|
102
|
+
readonly __wbindgen_export2: (a: number, b: number) => number;
|
|
103
|
+
readonly __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
|
|
104
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
111
|
+
* a precompiled `WebAssembly.Module`.
|
|
112
|
+
*
|
|
113
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
114
|
+
*
|
|
115
|
+
* @returns {InitOutput}
|
|
116
|
+
*/
|
|
117
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
121
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
122
|
+
*
|
|
123
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
124
|
+
*
|
|
125
|
+
* @returns {Promise<InitOutput>}
|
|
126
|
+
*/
|
|
127
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -0,0 +1,715 @@
|
|
|
1
|
+
/* @ts-self-types="./citeme_engine_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The main engine struct exposed to JavaScript.
|
|
5
|
+
* Holds compiled CSL styles and locales in Wasm linear memory.
|
|
6
|
+
*/
|
|
7
|
+
export class WasmCitationEngine {
|
|
8
|
+
__destroy_into_raw() {
|
|
9
|
+
const ptr = this.__wbg_ptr;
|
|
10
|
+
this.__wbg_ptr = 0;
|
|
11
|
+
WasmCitationEngineFinalization.unregister(this);
|
|
12
|
+
return ptr;
|
|
13
|
+
}
|
|
14
|
+
free() {
|
|
15
|
+
const ptr = this.__destroy_into_raw();
|
|
16
|
+
wasm.__wbg_wasmcitationengine_free(ptr, 0);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Detect input format (returns "bibtex", "ris", "csl-json", or "unknown").
|
|
20
|
+
* @param {string} input
|
|
21
|
+
* @returns {string}
|
|
22
|
+
*/
|
|
23
|
+
detectFormat(input) {
|
|
24
|
+
let deferred2_0;
|
|
25
|
+
let deferred2_1;
|
|
26
|
+
try {
|
|
27
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
28
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
29
|
+
const len0 = WASM_VECTOR_LEN;
|
|
30
|
+
wasm.wasmcitationengine_detectFormat(retptr, this.__wbg_ptr, ptr0, len0);
|
|
31
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
32
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
33
|
+
deferred2_0 = r0;
|
|
34
|
+
deferred2_1 = r1;
|
|
35
|
+
return getStringFromWasm0(r0, r1);
|
|
36
|
+
} finally {
|
|
37
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
38
|
+
wasm.__wbindgen_export(deferred2_0, deferred2_1, 1);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Export CSL-JSON to BibTeX string. Input: JSON string (object or array).
|
|
43
|
+
* @param {string} csl_json_str
|
|
44
|
+
* @returns {string}
|
|
45
|
+
*/
|
|
46
|
+
exportBibtex(csl_json_str) {
|
|
47
|
+
let deferred3_0;
|
|
48
|
+
let deferred3_1;
|
|
49
|
+
try {
|
|
50
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
51
|
+
const ptr0 = passStringToWasm0(csl_json_str, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
52
|
+
const len0 = WASM_VECTOR_LEN;
|
|
53
|
+
wasm.wasmcitationengine_exportBibtex(retptr, this.__wbg_ptr, ptr0, len0);
|
|
54
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
55
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
56
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
57
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
58
|
+
var ptr2 = r0;
|
|
59
|
+
var len2 = r1;
|
|
60
|
+
if (r3) {
|
|
61
|
+
ptr2 = 0; len2 = 0;
|
|
62
|
+
throw takeObject(r2);
|
|
63
|
+
}
|
|
64
|
+
deferred3_0 = ptr2;
|
|
65
|
+
deferred3_1 = len2;
|
|
66
|
+
return getStringFromWasm0(ptr2, len2);
|
|
67
|
+
} finally {
|
|
68
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
69
|
+
wasm.__wbindgen_export(deferred3_0, deferred3_1, 1);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Export CSL-JSON to Hayagriva YAML string. Input: JSON string (object or array).
|
|
74
|
+
* @param {string} csl_json_str
|
|
75
|
+
* @returns {string}
|
|
76
|
+
*/
|
|
77
|
+
exportHayagriva(csl_json_str) {
|
|
78
|
+
let deferred3_0;
|
|
79
|
+
let deferred3_1;
|
|
80
|
+
try {
|
|
81
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
82
|
+
const ptr0 = passStringToWasm0(csl_json_str, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
83
|
+
const len0 = WASM_VECTOR_LEN;
|
|
84
|
+
wasm.wasmcitationengine_exportHayagriva(retptr, this.__wbg_ptr, ptr0, len0);
|
|
85
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
86
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
87
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
88
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
89
|
+
var ptr2 = r0;
|
|
90
|
+
var len2 = r1;
|
|
91
|
+
if (r3) {
|
|
92
|
+
ptr2 = 0; len2 = 0;
|
|
93
|
+
throw takeObject(r2);
|
|
94
|
+
}
|
|
95
|
+
deferred3_0 = ptr2;
|
|
96
|
+
deferred3_1 = len2;
|
|
97
|
+
return getStringFromWasm0(ptr2, len2);
|
|
98
|
+
} finally {
|
|
99
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
100
|
+
wasm.__wbindgen_export(deferred3_0, deferred3_1, 1);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Export CSL-JSON to RIS string. Input: JSON string (object or array).
|
|
105
|
+
* @param {string} csl_json_str
|
|
106
|
+
* @returns {string}
|
|
107
|
+
*/
|
|
108
|
+
exportRis(csl_json_str) {
|
|
109
|
+
let deferred3_0;
|
|
110
|
+
let deferred3_1;
|
|
111
|
+
try {
|
|
112
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
113
|
+
const ptr0 = passStringToWasm0(csl_json_str, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
114
|
+
const len0 = WASM_VECTOR_LEN;
|
|
115
|
+
wasm.wasmcitationengine_exportRis(retptr, this.__wbg_ptr, ptr0, len0);
|
|
116
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
117
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
118
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
119
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
120
|
+
var ptr2 = r0;
|
|
121
|
+
var len2 = r1;
|
|
122
|
+
if (r3) {
|
|
123
|
+
ptr2 = 0; len2 = 0;
|
|
124
|
+
throw takeObject(r2);
|
|
125
|
+
}
|
|
126
|
+
deferred3_0 = ptr2;
|
|
127
|
+
deferred3_1 = len2;
|
|
128
|
+
return getStringFromWasm0(ptr2, len2);
|
|
129
|
+
} finally {
|
|
130
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
131
|
+
wasm.__wbindgen_export(deferred3_0, deferred3_1, 1);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Format a batch of CSL-JSON items.
|
|
136
|
+
* Input: JSON string of CSL-JSON array. Output: JSON string of FormatResult array.
|
|
137
|
+
* @param {string} csl_json_str
|
|
138
|
+
* @param {string} style_name
|
|
139
|
+
* @param {string} locale_code
|
|
140
|
+
* @param {boolean} abnt_post_process
|
|
141
|
+
* @returns {string}
|
|
142
|
+
*/
|
|
143
|
+
formatBatch(csl_json_str, style_name, locale_code, abnt_post_process) {
|
|
144
|
+
let deferred5_0;
|
|
145
|
+
let deferred5_1;
|
|
146
|
+
try {
|
|
147
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
148
|
+
const ptr0 = passStringToWasm0(csl_json_str, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
149
|
+
const len0 = WASM_VECTOR_LEN;
|
|
150
|
+
const ptr1 = passStringToWasm0(style_name, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
151
|
+
const len1 = WASM_VECTOR_LEN;
|
|
152
|
+
const ptr2 = passStringToWasm0(locale_code, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
153
|
+
const len2 = WASM_VECTOR_LEN;
|
|
154
|
+
wasm.wasmcitationengine_formatBatch(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, abnt_post_process);
|
|
155
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
156
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
157
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
158
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
159
|
+
var ptr4 = r0;
|
|
160
|
+
var len4 = r1;
|
|
161
|
+
if (r3) {
|
|
162
|
+
ptr4 = 0; len4 = 0;
|
|
163
|
+
throw takeObject(r2);
|
|
164
|
+
}
|
|
165
|
+
deferred5_0 = ptr4;
|
|
166
|
+
deferred5_1 = len4;
|
|
167
|
+
return getStringFromWasm0(ptr4, len4);
|
|
168
|
+
} finally {
|
|
169
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
170
|
+
wasm.__wbindgen_export(deferred5_0, deferred5_1, 1);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Format a single CSL-JSON item.
|
|
175
|
+
* Input: JSON string of one CSL-JSON item. Output: JSON string of FormatResult.
|
|
176
|
+
* @param {string} csl_json_str
|
|
177
|
+
* @param {string} style_name
|
|
178
|
+
* @param {string} locale_code
|
|
179
|
+
* @param {boolean} abnt_post_process
|
|
180
|
+
* @returns {string}
|
|
181
|
+
*/
|
|
182
|
+
formatOne(csl_json_str, style_name, locale_code, abnt_post_process) {
|
|
183
|
+
let deferred5_0;
|
|
184
|
+
let deferred5_1;
|
|
185
|
+
try {
|
|
186
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
187
|
+
const ptr0 = passStringToWasm0(csl_json_str, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
188
|
+
const len0 = WASM_VECTOR_LEN;
|
|
189
|
+
const ptr1 = passStringToWasm0(style_name, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
190
|
+
const len1 = WASM_VECTOR_LEN;
|
|
191
|
+
const ptr2 = passStringToWasm0(locale_code, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
192
|
+
const len2 = WASM_VECTOR_LEN;
|
|
193
|
+
wasm.wasmcitationengine_formatOne(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, abnt_post_process);
|
|
194
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
195
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
196
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
197
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
198
|
+
var ptr4 = r0;
|
|
199
|
+
var len4 = r1;
|
|
200
|
+
if (r3) {
|
|
201
|
+
ptr4 = 0; len4 = 0;
|
|
202
|
+
throw takeObject(r2);
|
|
203
|
+
}
|
|
204
|
+
deferred5_0 = ptr4;
|
|
205
|
+
deferred5_1 = len4;
|
|
206
|
+
return getStringFromWasm0(ptr4, len4);
|
|
207
|
+
} finally {
|
|
208
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
209
|
+
wasm.__wbindgen_export(deferred5_0, deferred5_1, 1);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Check if a style is loaded.
|
|
214
|
+
* @param {string} name
|
|
215
|
+
* @returns {boolean}
|
|
216
|
+
*/
|
|
217
|
+
hasStyle(name) {
|
|
218
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
219
|
+
const len0 = WASM_VECTOR_LEN;
|
|
220
|
+
const ret = wasm.wasmcitationengine_hasStyle(this.__wbg_ptr, ptr0, len0);
|
|
221
|
+
return ret !== 0;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Load a locale from XML string.
|
|
225
|
+
* @param {string} locale_code
|
|
226
|
+
* @param {string} locale_xml
|
|
227
|
+
*/
|
|
228
|
+
loadLocale(locale_code, locale_xml) {
|
|
229
|
+
try {
|
|
230
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
231
|
+
const ptr0 = passStringToWasm0(locale_code, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
232
|
+
const len0 = WASM_VECTOR_LEN;
|
|
233
|
+
const ptr1 = passStringToWasm0(locale_xml, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
234
|
+
const len1 = WASM_VECTOR_LEN;
|
|
235
|
+
wasm.wasmcitationengine_loadLocale(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
236
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
237
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
238
|
+
if (r1) {
|
|
239
|
+
throw takeObject(r0);
|
|
240
|
+
}
|
|
241
|
+
} finally {
|
|
242
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Load a CSL style from XML string. Compiled and cached.
|
|
247
|
+
* @param {string} name
|
|
248
|
+
* @param {string} csl_xml
|
|
249
|
+
*/
|
|
250
|
+
loadStyle(name, csl_xml) {
|
|
251
|
+
try {
|
|
252
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
253
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
254
|
+
const len0 = WASM_VECTOR_LEN;
|
|
255
|
+
const ptr1 = passStringToWasm0(csl_xml, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
256
|
+
const len1 = WASM_VECTOR_LEN;
|
|
257
|
+
wasm.wasmcitationengine_loadStyle(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
258
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
259
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
260
|
+
if (r1) {
|
|
261
|
+
throw takeObject(r0);
|
|
262
|
+
}
|
|
263
|
+
} finally {
|
|
264
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Create a new engine instance.
|
|
269
|
+
* Installs panic hook so Rust panics produce readable JS console errors.
|
|
270
|
+
*/
|
|
271
|
+
constructor() {
|
|
272
|
+
const ret = wasm.wasmcitationengine_new();
|
|
273
|
+
this.__wbg_ptr = ret >>> 0;
|
|
274
|
+
WasmCitationEngineFinalization.register(this, this.__wbg_ptr, this);
|
|
275
|
+
return this;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Auto-detect format and parse. Returns JSON string of ParseResult.
|
|
279
|
+
* @param {string} input
|
|
280
|
+
* @param {number | null} [max_entries]
|
|
281
|
+
* @returns {string}
|
|
282
|
+
*/
|
|
283
|
+
parseAuto(input, max_entries) {
|
|
284
|
+
let deferred3_0;
|
|
285
|
+
let deferred3_1;
|
|
286
|
+
try {
|
|
287
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
288
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
289
|
+
const len0 = WASM_VECTOR_LEN;
|
|
290
|
+
wasm.wasmcitationengine_parseAuto(retptr, this.__wbg_ptr, ptr0, len0, isLikeNone(max_entries) ? 0x100000001 : (max_entries) >>> 0);
|
|
291
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
292
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
293
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
294
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
295
|
+
var ptr2 = r0;
|
|
296
|
+
var len2 = r1;
|
|
297
|
+
if (r3) {
|
|
298
|
+
ptr2 = 0; len2 = 0;
|
|
299
|
+
throw takeObject(r2);
|
|
300
|
+
}
|
|
301
|
+
deferred3_0 = ptr2;
|
|
302
|
+
deferred3_1 = len2;
|
|
303
|
+
return getStringFromWasm0(ptr2, len2);
|
|
304
|
+
} finally {
|
|
305
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
306
|
+
wasm.__wbindgen_export(deferred3_0, deferred3_1, 1);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Parse BibTeX content and return CSL-JSON array.
|
|
311
|
+
* @param {string} input
|
|
312
|
+
* @param {number | null} [max_entries]
|
|
313
|
+
* @returns {string}
|
|
314
|
+
*/
|
|
315
|
+
parseBibtex(input, max_entries) {
|
|
316
|
+
let deferred3_0;
|
|
317
|
+
let deferred3_1;
|
|
318
|
+
try {
|
|
319
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
320
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
321
|
+
const len0 = WASM_VECTOR_LEN;
|
|
322
|
+
wasm.wasmcitationengine_parseBibtex(retptr, this.__wbg_ptr, ptr0, len0, isLikeNone(max_entries) ? 0x100000001 : (max_entries) >>> 0);
|
|
323
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
324
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
325
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
326
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
327
|
+
var ptr2 = r0;
|
|
328
|
+
var len2 = r1;
|
|
329
|
+
if (r3) {
|
|
330
|
+
ptr2 = 0; len2 = 0;
|
|
331
|
+
throw takeObject(r2);
|
|
332
|
+
}
|
|
333
|
+
deferred3_0 = ptr2;
|
|
334
|
+
deferred3_1 = len2;
|
|
335
|
+
return getStringFromWasm0(ptr2, len2);
|
|
336
|
+
} finally {
|
|
337
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
338
|
+
wasm.__wbindgen_export(deferred3_0, deferred3_1, 1);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Validate and pass through CSL-JSON input. Accepts single object or array.
|
|
343
|
+
* @param {string} input
|
|
344
|
+
* @param {number | null} [max_entries]
|
|
345
|
+
* @returns {string}
|
|
346
|
+
*/
|
|
347
|
+
parseCslJson(input, max_entries) {
|
|
348
|
+
let deferred3_0;
|
|
349
|
+
let deferred3_1;
|
|
350
|
+
try {
|
|
351
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
352
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
353
|
+
const len0 = WASM_VECTOR_LEN;
|
|
354
|
+
wasm.wasmcitationengine_parseCslJson(retptr, this.__wbg_ptr, ptr0, len0, isLikeNone(max_entries) ? 0x100000001 : (max_entries) >>> 0);
|
|
355
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
356
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
357
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
358
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
359
|
+
var ptr2 = r0;
|
|
360
|
+
var len2 = r1;
|
|
361
|
+
if (r3) {
|
|
362
|
+
ptr2 = 0; len2 = 0;
|
|
363
|
+
throw takeObject(r2);
|
|
364
|
+
}
|
|
365
|
+
deferred3_0 = ptr2;
|
|
366
|
+
deferred3_1 = len2;
|
|
367
|
+
return getStringFromWasm0(ptr2, len2);
|
|
368
|
+
} finally {
|
|
369
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
370
|
+
wasm.__wbindgen_export(deferred3_0, deferred3_1, 1);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Parse MEDLINE/NBIB content and return CSL-JSON array.
|
|
375
|
+
* @param {string} input
|
|
376
|
+
* @param {number | null} [max_entries]
|
|
377
|
+
* @returns {string}
|
|
378
|
+
*/
|
|
379
|
+
parseMedline(input, max_entries) {
|
|
380
|
+
let deferred3_0;
|
|
381
|
+
let deferred3_1;
|
|
382
|
+
try {
|
|
383
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
384
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
385
|
+
const len0 = WASM_VECTOR_LEN;
|
|
386
|
+
wasm.wasmcitationengine_parseMedline(retptr, this.__wbg_ptr, ptr0, len0, isLikeNone(max_entries) ? 0x100000001 : (max_entries) >>> 0);
|
|
387
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
388
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
389
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
390
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
391
|
+
var ptr2 = r0;
|
|
392
|
+
var len2 = r1;
|
|
393
|
+
if (r3) {
|
|
394
|
+
ptr2 = 0; len2 = 0;
|
|
395
|
+
throw takeObject(r2);
|
|
396
|
+
}
|
|
397
|
+
deferred3_0 = ptr2;
|
|
398
|
+
deferred3_1 = len2;
|
|
399
|
+
return getStringFromWasm0(ptr2, len2);
|
|
400
|
+
} finally {
|
|
401
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
402
|
+
wasm.__wbindgen_export(deferred3_0, deferred3_1, 1);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Parse RIS content and return CSL-JSON array.
|
|
407
|
+
* @param {string} input
|
|
408
|
+
* @param {number | null} [max_entries]
|
|
409
|
+
* @returns {string}
|
|
410
|
+
*/
|
|
411
|
+
parseRis(input, max_entries) {
|
|
412
|
+
let deferred3_0;
|
|
413
|
+
let deferred3_1;
|
|
414
|
+
try {
|
|
415
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
416
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
417
|
+
const len0 = WASM_VECTOR_LEN;
|
|
418
|
+
wasm.wasmcitationengine_parseRis(retptr, this.__wbg_ptr, ptr0, len0, isLikeNone(max_entries) ? 0x100000001 : (max_entries) >>> 0);
|
|
419
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
420
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
421
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
422
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
423
|
+
var ptr2 = r0;
|
|
424
|
+
var len2 = r1;
|
|
425
|
+
if (r3) {
|
|
426
|
+
ptr2 = 0; len2 = 0;
|
|
427
|
+
throw takeObject(r2);
|
|
428
|
+
}
|
|
429
|
+
deferred3_0 = ptr2;
|
|
430
|
+
deferred3_1 = len2;
|
|
431
|
+
return getStringFromWasm0(ptr2, len2);
|
|
432
|
+
} finally {
|
|
433
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
434
|
+
wasm.__wbindgen_export(deferred3_0, deferred3_1, 1);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Get engine version.
|
|
439
|
+
* @returns {string}
|
|
440
|
+
*/
|
|
441
|
+
version() {
|
|
442
|
+
let deferred1_0;
|
|
443
|
+
let deferred1_1;
|
|
444
|
+
try {
|
|
445
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
446
|
+
wasm.wasmcitationengine_version(retptr, this.__wbg_ptr);
|
|
447
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
448
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
449
|
+
deferred1_0 = r0;
|
|
450
|
+
deferred1_1 = r1;
|
|
451
|
+
return getStringFromWasm0(r0, r1);
|
|
452
|
+
} finally {
|
|
453
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
454
|
+
wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
if (Symbol.dispose) WasmCitationEngine.prototype[Symbol.dispose] = WasmCitationEngine.prototype.free;
|
|
459
|
+
|
|
460
|
+
function __wbg_get_imports() {
|
|
461
|
+
const import0 = {
|
|
462
|
+
__proto__: null,
|
|
463
|
+
__wbg_Error_83742b46f01ce22d: function(arg0, arg1) {
|
|
464
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
465
|
+
return addHeapObject(ret);
|
|
466
|
+
},
|
|
467
|
+
__wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
|
|
468
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
469
|
+
},
|
|
470
|
+
__wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
|
|
471
|
+
let deferred0_0;
|
|
472
|
+
let deferred0_1;
|
|
473
|
+
try {
|
|
474
|
+
deferred0_0 = arg0;
|
|
475
|
+
deferred0_1 = arg1;
|
|
476
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
477
|
+
} finally {
|
|
478
|
+
wasm.__wbindgen_export(deferred0_0, deferred0_1, 1);
|
|
479
|
+
}
|
|
480
|
+
},
|
|
481
|
+
__wbg_new_227d7c05414eb861: function() {
|
|
482
|
+
const ret = new Error();
|
|
483
|
+
return addHeapObject(ret);
|
|
484
|
+
},
|
|
485
|
+
__wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
|
|
486
|
+
const ret = getObject(arg1).stack;
|
|
487
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
488
|
+
const len1 = WASM_VECTOR_LEN;
|
|
489
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
490
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
491
|
+
},
|
|
492
|
+
__wbindgen_object_drop_ref: function(arg0) {
|
|
493
|
+
takeObject(arg0);
|
|
494
|
+
},
|
|
495
|
+
};
|
|
496
|
+
return {
|
|
497
|
+
__proto__: null,
|
|
498
|
+
"./citeme_engine_wasm_bg.js": import0,
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
const WasmCitationEngineFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
503
|
+
? { register: () => {}, unregister: () => {} }
|
|
504
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmcitationengine_free(ptr >>> 0, 1));
|
|
505
|
+
|
|
506
|
+
function addHeapObject(obj) {
|
|
507
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
508
|
+
const idx = heap_next;
|
|
509
|
+
heap_next = heap[idx];
|
|
510
|
+
|
|
511
|
+
heap[idx] = obj;
|
|
512
|
+
return idx;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
function dropObject(idx) {
|
|
516
|
+
if (idx < 1028) return;
|
|
517
|
+
heap[idx] = heap_next;
|
|
518
|
+
heap_next = idx;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
let cachedDataViewMemory0 = null;
|
|
522
|
+
function getDataViewMemory0() {
|
|
523
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
524
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
525
|
+
}
|
|
526
|
+
return cachedDataViewMemory0;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
function getStringFromWasm0(ptr, len) {
|
|
530
|
+
ptr = ptr >>> 0;
|
|
531
|
+
return decodeText(ptr, len);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
let cachedUint8ArrayMemory0 = null;
|
|
535
|
+
function getUint8ArrayMemory0() {
|
|
536
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
537
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
538
|
+
}
|
|
539
|
+
return cachedUint8ArrayMemory0;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
function getObject(idx) { return heap[idx]; }
|
|
543
|
+
|
|
544
|
+
let heap = new Array(1024).fill(undefined);
|
|
545
|
+
heap.push(undefined, null, true, false);
|
|
546
|
+
|
|
547
|
+
let heap_next = heap.length;
|
|
548
|
+
|
|
549
|
+
function isLikeNone(x) {
|
|
550
|
+
return x === undefined || x === null;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
554
|
+
if (realloc === undefined) {
|
|
555
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
556
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
557
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
558
|
+
WASM_VECTOR_LEN = buf.length;
|
|
559
|
+
return ptr;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
let len = arg.length;
|
|
563
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
564
|
+
|
|
565
|
+
const mem = getUint8ArrayMemory0();
|
|
566
|
+
|
|
567
|
+
let offset = 0;
|
|
568
|
+
|
|
569
|
+
for (; offset < len; offset++) {
|
|
570
|
+
const code = arg.charCodeAt(offset);
|
|
571
|
+
if (code > 0x7F) break;
|
|
572
|
+
mem[ptr + offset] = code;
|
|
573
|
+
}
|
|
574
|
+
if (offset !== len) {
|
|
575
|
+
if (offset !== 0) {
|
|
576
|
+
arg = arg.slice(offset);
|
|
577
|
+
}
|
|
578
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
579
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
580
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
581
|
+
|
|
582
|
+
offset += ret.written;
|
|
583
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
WASM_VECTOR_LEN = offset;
|
|
587
|
+
return ptr;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
function takeObject(idx) {
|
|
591
|
+
const ret = getObject(idx);
|
|
592
|
+
dropObject(idx);
|
|
593
|
+
return ret;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
597
|
+
cachedTextDecoder.decode();
|
|
598
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
599
|
+
let numBytesDecoded = 0;
|
|
600
|
+
function decodeText(ptr, len) {
|
|
601
|
+
numBytesDecoded += len;
|
|
602
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
603
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
604
|
+
cachedTextDecoder.decode();
|
|
605
|
+
numBytesDecoded = len;
|
|
606
|
+
}
|
|
607
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
const cachedTextEncoder = new TextEncoder();
|
|
611
|
+
|
|
612
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
613
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
614
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
615
|
+
view.set(buf);
|
|
616
|
+
return {
|
|
617
|
+
read: arg.length,
|
|
618
|
+
written: buf.length
|
|
619
|
+
};
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
let WASM_VECTOR_LEN = 0;
|
|
624
|
+
|
|
625
|
+
let wasmModule, wasm;
|
|
626
|
+
function __wbg_finalize_init(instance, module) {
|
|
627
|
+
wasm = instance.exports;
|
|
628
|
+
wasmModule = module;
|
|
629
|
+
cachedDataViewMemory0 = null;
|
|
630
|
+
cachedUint8ArrayMemory0 = null;
|
|
631
|
+
return wasm;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
async function __wbg_load(module, imports) {
|
|
635
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
636
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
637
|
+
try {
|
|
638
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
639
|
+
} catch (e) {
|
|
640
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
641
|
+
|
|
642
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
643
|
+
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);
|
|
644
|
+
|
|
645
|
+
} else { throw e; }
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
const bytes = await module.arrayBuffer();
|
|
650
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
651
|
+
} else {
|
|
652
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
653
|
+
|
|
654
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
655
|
+
return { instance, module };
|
|
656
|
+
} else {
|
|
657
|
+
return instance;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
function expectedResponseType(type) {
|
|
662
|
+
switch (type) {
|
|
663
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
664
|
+
}
|
|
665
|
+
return false;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
function initSync(module) {
|
|
670
|
+
if (wasm !== undefined) return wasm;
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
if (module !== undefined) {
|
|
674
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
675
|
+
({module} = module)
|
|
676
|
+
} else {
|
|
677
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
const imports = __wbg_get_imports();
|
|
682
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
683
|
+
module = new WebAssembly.Module(module);
|
|
684
|
+
}
|
|
685
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
686
|
+
return __wbg_finalize_init(instance, module);
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
async function __wbg_init(module_or_path) {
|
|
690
|
+
if (wasm !== undefined) return wasm;
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
if (module_or_path !== undefined) {
|
|
694
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
695
|
+
({module_or_path} = module_or_path)
|
|
696
|
+
} else {
|
|
697
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
if (module_or_path === undefined) {
|
|
702
|
+
module_or_path = new URL('citeme_engine_wasm_bg.wasm', import.meta.url);
|
|
703
|
+
}
|
|
704
|
+
const imports = __wbg_get_imports();
|
|
705
|
+
|
|
706
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
707
|
+
module_or_path = fetch(module_or_path);
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
711
|
+
|
|
712
|
+
return __wbg_finalize_init(instance, module);
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_wasmcitationengine_free: (a: number, b: number) => void;
|
|
5
|
+
export const wasmcitationengine_detectFormat: (a: number, b: number, c: number, d: number) => void;
|
|
6
|
+
export const wasmcitationengine_exportBibtex: (a: number, b: number, c: number, d: number) => void;
|
|
7
|
+
export const wasmcitationengine_exportHayagriva: (a: number, b: number, c: number, d: number) => void;
|
|
8
|
+
export const wasmcitationengine_exportRis: (a: number, b: number, c: number, d: number) => void;
|
|
9
|
+
export const wasmcitationengine_formatBatch: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
10
|
+
export const wasmcitationengine_formatOne: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
11
|
+
export const wasmcitationengine_hasStyle: (a: number, b: number, c: number) => number;
|
|
12
|
+
export const wasmcitationengine_loadLocale: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
13
|
+
export const wasmcitationengine_loadStyle: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
14
|
+
export const wasmcitationengine_new: () => number;
|
|
15
|
+
export const wasmcitationengine_parseAuto: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
16
|
+
export const wasmcitationengine_parseBibtex: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
17
|
+
export const wasmcitationengine_parseCslJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
18
|
+
export const wasmcitationengine_parseMedline: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
19
|
+
export const wasmcitationengine_parseRis: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
20
|
+
export const wasmcitationengine_version: (a: number, b: number) => void;
|
|
21
|
+
export const __wbindgen_export: (a: number, b: number, c: number) => void;
|
|
22
|
+
export const __wbindgen_export2: (a: number, b: number) => number;
|
|
23
|
+
export const __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
|
|
24
|
+
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|