@citeproc-rs/wasm
Advanced tools
Comparing version 0.0.0-canary-029407d to 0.0.0-canary-108a426
@@ -6,5 +6,8 @@ /* tslint:disable */ | ||
export function driver_new(a: number, b: number, c: number, d: number, e: number): number; | ||
export function driver_setStyle(a: number, b: number, c: number): number; | ||
export function driver_setReferences(a: number, b: number, c: number): void; | ||
export function driver_setStyle(a: number, b: number, c: number): void; | ||
export function driver_resetReferences(a: number, b: number, c: number): void; | ||
export function driver_insertReferences(a: number, b: number, c: number): void; | ||
export function driver_insertReference(a: number, b: number): void; | ||
export function driver_removeReference(a: number, b: number, c: number): void; | ||
export function driver_includeUncited(a: number, b: number): void; | ||
export function driver_toFetch(a: number): number; | ||
@@ -15,2 +18,3 @@ export function driver_insertCluster(a: number, b: number): void; | ||
export function driver_builtCluster(a: number, b: number): number; | ||
export function driver_previewCitationCluster(a: number, b: number, c: number, d: number, e: number, f: number, g: number): number; | ||
export function driver_makeBibliography(a: number): number; | ||
@@ -26,4 +30,5 @@ export function driver_bibliographyMeta(a: number): number; | ||
export const __wbindgen_export_2: WebAssembly.Table; | ||
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h18b461775fab0812(a: number, b: number, c: number): void; | ||
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf77188239a1f71cd(a: number, b: number, c: number): void; | ||
export function __wbindgen_free(a: number, b: number): void; | ||
export function __wbindgen_exn_store(a: number): void; | ||
export function wasm_bindgen__convert__closures__invoke2_mut__h442d48e1eb0f8a8d(a: number, b: number, c: number, d: number): void; | ||
export function wasm_bindgen__convert__closures__invoke2_mut__h19f62226ce422262(a: number, b: number, c: number, d: number): void; |
@@ -34,3 +34,3 @@ /* tslint:disable */ | ||
suppression?: "InText" | "Rest" | null; | ||
} & CiteLocator; | ||
} & Partial<CiteLocator>; | ||
@@ -89,5 +89,5 @@ export type ClusterNumber = { | ||
type IncludeUncited = "None" | "All" | { Specific: string[] }; | ||
/** | ||
@@ -114,17 +114,36 @@ */ | ||
* @param {string} style_text | ||
* @returns {any} | ||
*/ | ||
setStyle(style_text: string): any; | ||
setStyle(style_text: string): void; | ||
/** | ||
* Completely overwrites the references library. | ||
* This **will** delete references that are not in the provided list. | ||
* @param {any[]} refs | ||
*/ | ||
resetReferences(refs: any[]): void; | ||
/** | ||
* Inserts or overwrites references as a batch operation. | ||
* This **will not** delete references that are not in the provided list. | ||
* @param {any[]} refs | ||
*/ | ||
setReferences(refs: any[]): void; | ||
insertReferences(refs: any[]): void; | ||
/** | ||
* Inserts or overwrites a reference. | ||
* | ||
* * `refr` is a Reference object. | ||
* @param {Reference} refr | ||
*/ | ||
insertReference(refr: Reference): void; | ||
/** | ||
* Removes a reference by id. If it is cited, any cites will be dangling. It will also | ||
* disappear from the bibliography. | ||
* @param {string} id | ||
*/ | ||
removeReference(id: string): void; | ||
/** | ||
* Sets the references to be included in the bibliography despite not being directly cited. | ||
* | ||
* * `refr` is a | ||
* @param {any} refr | ||
* @param {IncludeUncited} uncited | ||
*/ | ||
insertReference(refr: any): void; | ||
includeUncited(uncited: IncludeUncited): void; | ||
/** | ||
@@ -164,4 +183,18 @@ * Gets a list of locales in use by the references currently loaded. | ||
/** | ||
* Previews a formatted citation cluster, in a particular position. | ||
* | ||
* - `cites`: The cites to go in the cluster | ||
* - `positions`: An array of `ClusterPosition`s as in set_cluster_order, but with a single | ||
* cluster's id set to zero. The cluster with id=0 is the position to preview the cite. It | ||
* can replace another cluster, or be inserted before/after/between existing clusters, in | ||
* any location you can think of. | ||
* @param {any[]} cites | ||
* @param {any[]} positions | ||
* @param {string} format | ||
* @returns {any} | ||
*/ | ||
previewCitationCluster(cites: any[], positions: any[], format: string): any; | ||
/** | ||
* @returns {any} | ||
*/ | ||
makeBibliography(): any; | ||
@@ -219,5 +252,5 @@ /** | ||
* May error without having set_cluster_ids, but with some set_cluster_note_number-s executed. | ||
* @param {any[]} pieces | ||
* @param {any[]} positions | ||
*/ | ||
setClusterOrder(pieces: any[]): void; | ||
setClusterOrder(positions: any[]): void; | ||
/** | ||
@@ -231,5 +264,5 @@ * Retrieve any clusters that have been touched since last time `batchedUpdates` was | ||
* * returns an `UpdateSummary` | ||
* @returns {any} | ||
* @returns {UpdateSummary} | ||
*/ | ||
batchedUpdates(): any; | ||
batchedUpdates(): UpdateSummary; | ||
/** | ||
@@ -236,0 +269,0 @@ * Drains the `batchedUpdates` queue manually. Use it to avoid serializing an unneeded |
@@ -12,16 +12,2 @@ let imports = {}; | ||
let heap_next = heap.length; | ||
function dropObject(idx) { | ||
if (idx < 36) return; | ||
heap[idx] = heap_next; | ||
heap_next = idx; | ||
} | ||
function takeObject(idx) { | ||
const ret = getObject(idx); | ||
dropObject(idx); | ||
return ret; | ||
} | ||
let WASM_VECTOR_LEN = 0; | ||
@@ -54,11 +40,2 @@ | ||
function addHeapObject(obj) { | ||
if (heap_next === heap.length) heap.push(heap.length + 1); | ||
const idx = heap_next; | ||
heap_next = heap[idx]; | ||
heap[idx] = obj; | ||
return idx; | ||
} | ||
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
@@ -80,2 +57,25 @@ | ||
let heap_next = heap.length; | ||
function addHeapObject(obj) { | ||
if (heap_next === heap.length) heap.push(heap.length + 1); | ||
const idx = heap_next; | ||
heap_next = heap[idx]; | ||
heap[idx] = obj; | ||
return idx; | ||
} | ||
function dropObject(idx) { | ||
if (idx < 36) return; | ||
heap[idx] = heap_next; | ||
heap_next = idx; | ||
} | ||
function takeObject(idx) { | ||
const ret = getObject(idx); | ||
dropObject(idx); | ||
return ret; | ||
} | ||
function isLikeNone(x) { | ||
@@ -110,3 +110,3 @@ return x === undefined || x === null; | ||
function __wbg_adapter_18(arg0, arg1, arg2) { | ||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h18b461775fab0812(arg0, arg1, addHeapObject(arg2)); | ||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf77188239a1f71cd(arg0, arg1, addHeapObject(arg2)); | ||
} | ||
@@ -142,4 +142,4 @@ | ||
} | ||
function __wbg_adapter_43(arg0, arg1, arg2, arg3) { | ||
wasm.wasm_bindgen__convert__closures__invoke2_mut__h442d48e1eb0f8a8d(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); | ||
function __wbg_adapter_63(arg0, arg1, arg2, arg3) { | ||
wasm.wasm_bindgen__convert__closures__invoke2_mut__h19f62226ce422262(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); | ||
} | ||
@@ -188,3 +188,2 @@ | ||
* @param {string} style_text | ||
* @returns {any} | ||
*/ | ||
@@ -194,13 +193,23 @@ setStyle(style_text) { | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_setStyle(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
wasm.driver_setStyle(this.ptr, ptr0, len0); | ||
} | ||
/** | ||
* Completely overwrites the references library. | ||
* This **will** delete references that are not in the provided list. | ||
* @param {any[]} refs | ||
*/ | ||
resetReferences(refs) { | ||
var ptr0 = passArrayJsValueToWasm0(refs, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_resetReferences(this.ptr, ptr0, len0); | ||
} | ||
/** | ||
* Inserts or overwrites references as a batch operation. | ||
* This **will not** delete references that are not in the provided list. | ||
* @param {any[]} refs | ||
*/ | ||
setReferences(refs) { | ||
insertReferences(refs) { | ||
var ptr0 = passArrayJsValueToWasm0(refs, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_setReferences(this.ptr, ptr0, len0); | ||
wasm.driver_insertReferences(this.ptr, ptr0, len0); | ||
} | ||
@@ -210,4 +219,4 @@ /** | ||
* | ||
* * `refr` is a | ||
* @param {any} refr | ||
* * `refr` is a Reference object. | ||
* @param {Reference} refr | ||
*/ | ||
@@ -218,2 +227,21 @@ insertReference(refr) { | ||
/** | ||
* Removes a reference by id. If it is cited, any cites will be dangling. It will also | ||
* disappear from the bibliography. | ||
* @param {string} id | ||
*/ | ||
removeReference(id) { | ||
var ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_removeReference(this.ptr, ptr0, len0); | ||
} | ||
/** | ||
* Sets the references to be included in the bibliography despite not being directly cited. | ||
* | ||
* * `refr` is a | ||
* @param {IncludeUncited} uncited | ||
*/ | ||
includeUncited(uncited) { | ||
wasm.driver_includeUncited(this.ptr, addHeapObject(uncited)); | ||
} | ||
/** | ||
* Gets a list of locales in use by the references currently loaded. | ||
@@ -266,4 +294,27 @@ * | ||
/** | ||
* Previews a formatted citation cluster, in a particular position. | ||
* | ||
* - `cites`: The cites to go in the cluster | ||
* - `positions`: An array of `ClusterPosition`s as in set_cluster_order, but with a single | ||
* cluster's id set to zero. The cluster with id=0 is the position to preview the cite. It | ||
* can replace another cluster, or be inserted before/after/between existing clusters, in | ||
* any location you can think of. | ||
* @param {any[]} cites | ||
* @param {any[]} positions | ||
* @param {string} format | ||
* @returns {any} | ||
*/ | ||
previewCitationCluster(cites, positions, format) { | ||
var ptr0 = passArrayJsValueToWasm0(cites, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ptr1 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len1 = WASM_VECTOR_LEN; | ||
var ptr2 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len2 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_previewCitationCluster(this.ptr, ptr0, len0, ptr1, len1, ptr2, len2); | ||
return takeObject(ret); | ||
} | ||
/** | ||
* @returns {any} | ||
*/ | ||
makeBibliography() { | ||
@@ -331,6 +382,6 @@ var ret = wasm.driver_makeBibliography(this.ptr); | ||
* May error without having set_cluster_ids, but with some set_cluster_note_number-s executed. | ||
* @param {any[]} pieces | ||
* @param {any[]} positions | ||
*/ | ||
setClusterOrder(pieces) { | ||
var ptr0 = passArrayJsValueToWasm0(pieces, wasm.__wbindgen_malloc); | ||
setClusterOrder(positions) { | ||
var ptr0 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
@@ -347,3 +398,3 @@ wasm.driver_setClusterOrder(this.ptr, ptr0, len0); | ||
* * returns an `UpdateSummary` | ||
* @returns {any} | ||
* @returns {UpdateSummary} | ||
*/ | ||
@@ -373,10 +424,2 @@ batchedUpdates() { | ||
module.exports.__wbindgen_object_drop_ref = function(arg0) { | ||
takeObject(arg0); | ||
}; | ||
module.exports.__wbg_error_e549f7fed6d655aa = function(arg0) { | ||
console.error(takeObject(arg0)); | ||
}; | ||
module.exports.__wbindgen_json_serialize = function(arg0, arg1) { | ||
@@ -391,12 +434,16 @@ const obj = getObject(arg1); | ||
module.exports.__wbindgen_object_clone_ref = function(arg0) { | ||
var ret = getObject(arg0); | ||
module.exports.__wbg_fetchLocale_8f52b973b0739a6c = function(arg0, arg1, arg2) { | ||
var ret = getObject(arg0).fetchLocale(getStringFromWasm0(arg1, arg2)); | ||
return addHeapObject(ret); | ||
}; | ||
module.exports.__wbg_fetchLocale_8f52b973b0739a6c = function(arg0, arg1, arg2) { | ||
var ret = getObject(arg0).fetchLocale(getStringFromWasm0(arg1, arg2)); | ||
module.exports.__wbindgen_json_parse = function(arg0, arg1) { | ||
var ret = JSON.parse(getStringFromWasm0(arg0, arg1)); | ||
return addHeapObject(ret); | ||
}; | ||
module.exports.__wbindgen_object_drop_ref = function(arg0) { | ||
takeObject(arg0); | ||
}; | ||
module.exports.__wbindgen_cb_drop = function(arg0) { | ||
@@ -412,7 +459,52 @@ const obj = takeObject(arg0).original; | ||
module.exports.__wbindgen_json_parse = function(arg0, arg1) { | ||
var ret = JSON.parse(getStringFromWasm0(arg0, arg1)); | ||
module.exports.__wbg_error_e549f7fed6d655aa = function(arg0) { | ||
console.error(takeObject(arg0)); | ||
}; | ||
module.exports.__wbg_debug_4885c3f7d6f044a3 = function(arg0, arg1) { | ||
console.debug(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
module.exports.__wbg_log_bee3ea1a89f334d8 = function(arg0, arg1) { | ||
console.log(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
module.exports.__wbg_info_0547ff9513f2019b = function(arg0, arg1) { | ||
console.info(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
module.exports.__wbg_warn_a478dea6e6e05394 = function(arg0, arg1) { | ||
console.warn(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
module.exports.__wbg_error_72e88ba6901b6eee = function(arg0, arg1) { | ||
console.error(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
module.exports.__wbindgen_object_clone_ref = function(arg0) { | ||
var ret = getObject(arg0); | ||
return addHeapObject(ret); | ||
}; | ||
module.exports.__wbg_new_59cb74e423758ede = function() { | ||
var ret = new Error(); | ||
return addHeapObject(ret); | ||
}; | ||
module.exports.__wbg_stack_558ba5917b466edd = function(arg0, arg1) { | ||
var ret = getObject(arg1).stack; | ||
var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
getInt32Memory0()[arg0 / 4 + 1] = len0; | ||
getInt32Memory0()[arg0 / 4 + 0] = ptr0; | ||
}; | ||
module.exports.__wbg_error_4bb6c2a97407129a = function(arg0, arg1) { | ||
try { | ||
console.error(getStringFromWasm0(arg0, arg1)); | ||
} finally { | ||
wasm.__wbindgen_free(arg0, arg1); | ||
} | ||
}; | ||
module.exports.__wbg_new_4896ab6bba55e0d9 = function(arg0, arg1) { | ||
@@ -435,3 +527,3 @@ var ret = new Error(getStringFromWasm0(arg0, arg1)); | ||
try { | ||
return __wbg_adapter_43(a, state0.b, arg0, arg1); | ||
return __wbg_adapter_63(a, state0.b, arg0, arg1); | ||
} finally { | ||
@@ -480,4 +572,4 @@ state0.a = a; | ||
module.exports.__wbindgen_closure_wrapper847 = function(arg0, arg1, arg2) { | ||
var ret = makeMutClosure(arg0, arg1, 88, __wbg_adapter_18); | ||
module.exports.__wbindgen_closure_wrapper866 = function(arg0, arg1, arg2) { | ||
var ret = makeMutClosure(arg0, arg1, 228, __wbg_adapter_18); | ||
return addHeapObject(ret); | ||
@@ -484,0 +576,0 @@ }; |
@@ -6,5 +6,8 @@ /* tslint:disable */ | ||
export function driver_new(a: number, b: number, c: number, d: number, e: number): number; | ||
export function driver_setStyle(a: number, b: number, c: number): number; | ||
export function driver_setReferences(a: number, b: number, c: number): void; | ||
export function driver_setStyle(a: number, b: number, c: number): void; | ||
export function driver_resetReferences(a: number, b: number, c: number): void; | ||
export function driver_insertReferences(a: number, b: number, c: number): void; | ||
export function driver_insertReference(a: number, b: number): void; | ||
export function driver_removeReference(a: number, b: number, c: number): void; | ||
export function driver_includeUncited(a: number, b: number): void; | ||
export function driver_toFetch(a: number): number; | ||
@@ -15,2 +18,3 @@ export function driver_insertCluster(a: number, b: number): void; | ||
export function driver_builtCluster(a: number, b: number): number; | ||
export function driver_previewCitationCluster(a: number, b: number, c: number, d: number, e: number, f: number, g: number): number; | ||
export function driver_makeBibliography(a: number): number; | ||
@@ -26,4 +30,5 @@ export function driver_bibliographyMeta(a: number): number; | ||
export const __wbindgen_export_2: WebAssembly.Table; | ||
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h18b461775fab0812(a: number, b: number, c: number): void; | ||
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf77188239a1f71cd(a: number, b: number, c: number): void; | ||
export function __wbindgen_free(a: number, b: number): void; | ||
export function __wbindgen_exn_store(a: number): void; | ||
export function wasm_bindgen__convert__closures__invoke2_mut__h442d48e1eb0f8a8d(a: number, b: number, c: number, d: number): void; | ||
export function wasm_bindgen__convert__closures__invoke2_mut__h19f62226ce422262(a: number, b: number, c: number, d: number): void; |
@@ -9,16 +9,2 @@ import * as wasm from './citeproc_rs_wasm_bg.wasm'; | ||
let heap_next = heap.length; | ||
function dropObject(idx) { | ||
if (idx < 36) return; | ||
heap[idx] = heap_next; | ||
heap_next = idx; | ||
} | ||
function takeObject(idx) { | ||
const ret = getObject(idx); | ||
dropObject(idx); | ||
return ret; | ||
} | ||
let WASM_VECTOR_LEN = 0; | ||
@@ -97,2 +83,14 @@ | ||
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder; | ||
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
cachedTextDecoder.decode(); | ||
function getStringFromWasm0(ptr, len) { | ||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); | ||
} | ||
let heap_next = heap.length; | ||
function addHeapObject(obj) { | ||
@@ -107,10 +105,12 @@ if (heap_next === heap.length) heap.push(heap.length + 1); | ||
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder; | ||
function dropObject(idx) { | ||
if (idx < 36) return; | ||
heap[idx] = heap_next; | ||
heap_next = idx; | ||
} | ||
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
cachedTextDecoder.decode(); | ||
function getStringFromWasm0(ptr, len) { | ||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); | ||
function takeObject(idx) { | ||
const ret = getObject(idx); | ||
dropObject(idx); | ||
return ret; | ||
} | ||
@@ -147,3 +147,3 @@ | ||
function __wbg_adapter_18(arg0, arg1, arg2) { | ||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h18b461775fab0812(arg0, arg1, addHeapObject(arg2)); | ||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf77188239a1f71cd(arg0, arg1, addHeapObject(arg2)); | ||
} | ||
@@ -179,4 +179,4 @@ | ||
} | ||
function __wbg_adapter_43(arg0, arg1, arg2, arg3) { | ||
wasm.wasm_bindgen__convert__closures__invoke2_mut__h442d48e1eb0f8a8d(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); | ||
function __wbg_adapter_63(arg0, arg1, arg2, arg3) { | ||
wasm.wasm_bindgen__convert__closures__invoke2_mut__h19f62226ce422262(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); | ||
} | ||
@@ -225,3 +225,2 @@ | ||
* @param {string} style_text | ||
* @returns {any} | ||
*/ | ||
@@ -231,13 +230,23 @@ setStyle(style_text) { | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_setStyle(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
wasm.driver_setStyle(this.ptr, ptr0, len0); | ||
} | ||
/** | ||
* Completely overwrites the references library. | ||
* This **will** delete references that are not in the provided list. | ||
* @param {any[]} refs | ||
*/ | ||
resetReferences(refs) { | ||
var ptr0 = passArrayJsValueToWasm0(refs, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_resetReferences(this.ptr, ptr0, len0); | ||
} | ||
/** | ||
* Inserts or overwrites references as a batch operation. | ||
* This **will not** delete references that are not in the provided list. | ||
* @param {any[]} refs | ||
*/ | ||
setReferences(refs) { | ||
insertReferences(refs) { | ||
var ptr0 = passArrayJsValueToWasm0(refs, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_setReferences(this.ptr, ptr0, len0); | ||
wasm.driver_insertReferences(this.ptr, ptr0, len0); | ||
} | ||
@@ -247,4 +256,4 @@ /** | ||
* | ||
* * `refr` is a | ||
* @param {any} refr | ||
* * `refr` is a Reference object. | ||
* @param {Reference} refr | ||
*/ | ||
@@ -255,2 +264,21 @@ insertReference(refr) { | ||
/** | ||
* Removes a reference by id. If it is cited, any cites will be dangling. It will also | ||
* disappear from the bibliography. | ||
* @param {string} id | ||
*/ | ||
removeReference(id) { | ||
var ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_removeReference(this.ptr, ptr0, len0); | ||
} | ||
/** | ||
* Sets the references to be included in the bibliography despite not being directly cited. | ||
* | ||
* * `refr` is a | ||
* @param {IncludeUncited} uncited | ||
*/ | ||
includeUncited(uncited) { | ||
wasm.driver_includeUncited(this.ptr, addHeapObject(uncited)); | ||
} | ||
/** | ||
* Gets a list of locales in use by the references currently loaded. | ||
@@ -303,4 +331,27 @@ * | ||
/** | ||
* Previews a formatted citation cluster, in a particular position. | ||
* | ||
* - `cites`: The cites to go in the cluster | ||
* - `positions`: An array of `ClusterPosition`s as in set_cluster_order, but with a single | ||
* cluster's id set to zero. The cluster with id=0 is the position to preview the cite. It | ||
* can replace another cluster, or be inserted before/after/between existing clusters, in | ||
* any location you can think of. | ||
* @param {any[]} cites | ||
* @param {any[]} positions | ||
* @param {string} format | ||
* @returns {any} | ||
*/ | ||
previewCitationCluster(cites, positions, format) { | ||
var ptr0 = passArrayJsValueToWasm0(cites, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ptr1 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len1 = WASM_VECTOR_LEN; | ||
var ptr2 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len2 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_previewCitationCluster(this.ptr, ptr0, len0, ptr1, len1, ptr2, len2); | ||
return takeObject(ret); | ||
} | ||
/** | ||
* @returns {any} | ||
*/ | ||
makeBibliography() { | ||
@@ -368,6 +419,6 @@ var ret = wasm.driver_makeBibliography(this.ptr); | ||
* May error without having set_cluster_ids, but with some set_cluster_note_number-s executed. | ||
* @param {any[]} pieces | ||
* @param {any[]} positions | ||
*/ | ||
setClusterOrder(pieces) { | ||
var ptr0 = passArrayJsValueToWasm0(pieces, wasm.__wbindgen_malloc); | ||
setClusterOrder(positions) { | ||
var ptr0 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
@@ -384,3 +435,3 @@ wasm.driver_setClusterOrder(this.ptr, ptr0, len0); | ||
* * returns an `UpdateSummary` | ||
* @returns {any} | ||
* @returns {UpdateSummary} | ||
*/ | ||
@@ -409,10 +460,2 @@ batchedUpdates() { | ||
export const __wbindgen_object_drop_ref = function(arg0) { | ||
takeObject(arg0); | ||
}; | ||
export const __wbg_error_e549f7fed6d655aa = function(arg0) { | ||
console.error(takeObject(arg0)); | ||
}; | ||
export const __wbindgen_json_serialize = function(arg0, arg1) { | ||
@@ -427,12 +470,16 @@ const obj = getObject(arg1); | ||
export const __wbindgen_object_clone_ref = function(arg0) { | ||
var ret = getObject(arg0); | ||
export const __wbg_fetchLocale_8f52b973b0739a6c = function(arg0, arg1, arg2) { | ||
var ret = getObject(arg0).fetchLocale(getStringFromWasm0(arg1, arg2)); | ||
return addHeapObject(ret); | ||
}; | ||
export const __wbg_fetchLocale_8f52b973b0739a6c = function(arg0, arg1, arg2) { | ||
var ret = getObject(arg0).fetchLocale(getStringFromWasm0(arg1, arg2)); | ||
export const __wbindgen_json_parse = function(arg0, arg1) { | ||
var ret = JSON.parse(getStringFromWasm0(arg0, arg1)); | ||
return addHeapObject(ret); | ||
}; | ||
export const __wbindgen_object_drop_ref = function(arg0) { | ||
takeObject(arg0); | ||
}; | ||
export const __wbindgen_cb_drop = function(arg0) { | ||
@@ -448,7 +495,52 @@ const obj = takeObject(arg0).original; | ||
export const __wbindgen_json_parse = function(arg0, arg1) { | ||
var ret = JSON.parse(getStringFromWasm0(arg0, arg1)); | ||
export const __wbg_error_e549f7fed6d655aa = function(arg0) { | ||
console.error(takeObject(arg0)); | ||
}; | ||
export const __wbg_debug_4885c3f7d6f044a3 = function(arg0, arg1) { | ||
console.debug(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
export const __wbg_log_bee3ea1a89f334d8 = function(arg0, arg1) { | ||
console.log(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
export const __wbg_info_0547ff9513f2019b = function(arg0, arg1) { | ||
console.info(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
export const __wbg_warn_a478dea6e6e05394 = function(arg0, arg1) { | ||
console.warn(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
export const __wbg_error_72e88ba6901b6eee = function(arg0, arg1) { | ||
console.error(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
export const __wbindgen_object_clone_ref = function(arg0) { | ||
var ret = getObject(arg0); | ||
return addHeapObject(ret); | ||
}; | ||
export const __wbg_new_59cb74e423758ede = function() { | ||
var ret = new Error(); | ||
return addHeapObject(ret); | ||
}; | ||
export const __wbg_stack_558ba5917b466edd = function(arg0, arg1) { | ||
var ret = getObject(arg1).stack; | ||
var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
getInt32Memory0()[arg0 / 4 + 1] = len0; | ||
getInt32Memory0()[arg0 / 4 + 0] = ptr0; | ||
}; | ||
export const __wbg_error_4bb6c2a97407129a = function(arg0, arg1) { | ||
try { | ||
console.error(getStringFromWasm0(arg0, arg1)); | ||
} finally { | ||
wasm.__wbindgen_free(arg0, arg1); | ||
} | ||
}; | ||
export const __wbg_new_4896ab6bba55e0d9 = function(arg0, arg1) { | ||
@@ -471,3 +563,3 @@ var ret = new Error(getStringFromWasm0(arg0, arg1)); | ||
try { | ||
return __wbg_adapter_43(a, state0.b, arg0, arg1); | ||
return __wbg_adapter_63(a, state0.b, arg0, arg1); | ||
} finally { | ||
@@ -516,6 +608,6 @@ state0.a = a; | ||
export const __wbindgen_closure_wrapper847 = function(arg0, arg1, arg2) { | ||
var ret = makeMutClosure(arg0, arg1, 88, __wbg_adapter_18); | ||
export const __wbindgen_closure_wrapper866 = function(arg0, arg1, arg2) { | ||
var ret = makeMutClosure(arg0, arg1, 228, __wbg_adapter_18); | ||
return addHeapObject(ret); | ||
}; | ||
@@ -34,3 +34,3 @@ /* tslint:disable */ | ||
suppression?: "InText" | "Rest" | null; | ||
} & CiteLocator; | ||
} & Partial<CiteLocator>; | ||
@@ -89,5 +89,5 @@ export type ClusterNumber = { | ||
type IncludeUncited = "None" | "All" | { Specific: string[] }; | ||
/** | ||
@@ -114,17 +114,36 @@ */ | ||
* @param {string} style_text | ||
* @returns {any} | ||
*/ | ||
setStyle(style_text: string): any; | ||
setStyle(style_text: string): void; | ||
/** | ||
* Completely overwrites the references library. | ||
* This **will** delete references that are not in the provided list. | ||
* @param {any[]} refs | ||
*/ | ||
resetReferences(refs: any[]): void; | ||
/** | ||
* Inserts or overwrites references as a batch operation. | ||
* This **will not** delete references that are not in the provided list. | ||
* @param {any[]} refs | ||
*/ | ||
setReferences(refs: any[]): void; | ||
insertReferences(refs: any[]): void; | ||
/** | ||
* Inserts or overwrites a reference. | ||
* | ||
* * `refr` is a Reference object. | ||
* @param {Reference} refr | ||
*/ | ||
insertReference(refr: Reference): void; | ||
/** | ||
* Removes a reference by id. If it is cited, any cites will be dangling. It will also | ||
* disappear from the bibliography. | ||
* @param {string} id | ||
*/ | ||
removeReference(id: string): void; | ||
/** | ||
* Sets the references to be included in the bibliography despite not being directly cited. | ||
* | ||
* * `refr` is a | ||
* @param {any} refr | ||
* @param {IncludeUncited} uncited | ||
*/ | ||
insertReference(refr: any): void; | ||
includeUncited(uncited: IncludeUncited): void; | ||
/** | ||
@@ -164,4 +183,18 @@ * Gets a list of locales in use by the references currently loaded. | ||
/** | ||
* Previews a formatted citation cluster, in a particular position. | ||
* | ||
* - `cites`: The cites to go in the cluster | ||
* - `positions`: An array of `ClusterPosition`s as in set_cluster_order, but with a single | ||
* cluster's id set to zero. The cluster with id=0 is the position to preview the cite. It | ||
* can replace another cluster, or be inserted before/after/between existing clusters, in | ||
* any location you can think of. | ||
* @param {any[]} cites | ||
* @param {any[]} positions | ||
* @param {string} format | ||
* @returns {any} | ||
*/ | ||
previewCitationCluster(cites: any[], positions: any[], format: string): any; | ||
/** | ||
* @returns {any} | ||
*/ | ||
makeBibliography(): any; | ||
@@ -219,5 +252,5 @@ /** | ||
* May error without having set_cluster_ids, but with some set_cluster_note_number-s executed. | ||
* @param {any[]} pieces | ||
* @param {any[]} positions | ||
*/ | ||
setClusterOrder(pieces: any[]): void; | ||
setClusterOrder(positions: any[]): void; | ||
/** | ||
@@ -231,5 +264,5 @@ * Retrieve any clusters that have been touched since last time `batchedUpdates` was | ||
* * returns an `UpdateSummary` | ||
* @returns {any} | ||
* @returns {UpdateSummary} | ||
*/ | ||
batchedUpdates(): any; | ||
batchedUpdates(): UpdateSummary; | ||
/** | ||
@@ -236,0 +269,0 @@ * Drains the `batchedUpdates` queue manually. Use it to avoid serializing an unneeded |
@@ -6,5 +6,8 @@ /* tslint:disable */ | ||
export function driver_new(a: number, b: number, c: number, d: number, e: number): number; | ||
export function driver_setStyle(a: number, b: number, c: number): number; | ||
export function driver_setReferences(a: number, b: number, c: number): void; | ||
export function driver_setStyle(a: number, b: number, c: number): void; | ||
export function driver_resetReferences(a: number, b: number, c: number): void; | ||
export function driver_insertReferences(a: number, b: number, c: number): void; | ||
export function driver_insertReference(a: number, b: number): void; | ||
export function driver_removeReference(a: number, b: number, c: number): void; | ||
export function driver_includeUncited(a: number, b: number): void; | ||
export function driver_toFetch(a: number): number; | ||
@@ -15,2 +18,3 @@ export function driver_insertCluster(a: number, b: number): void; | ||
export function driver_builtCluster(a: number, b: number): number; | ||
export function driver_previewCitationCluster(a: number, b: number, c: number, d: number, e: number, f: number, g: number): number; | ||
export function driver_makeBibliography(a: number): number; | ||
@@ -26,4 +30,5 @@ export function driver_bibliographyMeta(a: number): number; | ||
export const __wbindgen_export_2: WebAssembly.Table; | ||
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h18b461775fab0812(a: number, b: number, c: number): void; | ||
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf77188239a1f71cd(a: number, b: number, c: number): void; | ||
export function __wbindgen_free(a: number, b: number): void; | ||
export function __wbindgen_exn_store(a: number): void; | ||
export function wasm_bindgen__convert__closures__invoke2_mut__h442d48e1eb0f8a8d(a: number, b: number, c: number, d: number): void; | ||
export function wasm_bindgen__convert__closures__invoke2_mut__h19f62226ce422262(a: number, b: number, c: number, d: number): void; |
@@ -34,3 +34,3 @@ /* tslint:disable */ | ||
suppression?: "InText" | "Rest" | null; | ||
} & CiteLocator; | ||
} & Partial<CiteLocator>; | ||
@@ -89,5 +89,5 @@ export type ClusterNumber = { | ||
type IncludeUncited = "None" | "All" | { Specific: string[] }; | ||
/** | ||
@@ -114,17 +114,36 @@ */ | ||
* @param {string} style_text | ||
* @returns {any} | ||
*/ | ||
setStyle(style_text: string): any; | ||
setStyle(style_text: string): void; | ||
/** | ||
* Completely overwrites the references library. | ||
* This **will** delete references that are not in the provided list. | ||
* @param {any[]} refs | ||
*/ | ||
resetReferences(refs: any[]): void; | ||
/** | ||
* Inserts or overwrites references as a batch operation. | ||
* This **will not** delete references that are not in the provided list. | ||
* @param {any[]} refs | ||
*/ | ||
setReferences(refs: any[]): void; | ||
insertReferences(refs: any[]): void; | ||
/** | ||
* Inserts or overwrites a reference. | ||
* | ||
* * `refr` is a Reference object. | ||
* @param {Reference} refr | ||
*/ | ||
insertReference(refr: Reference): void; | ||
/** | ||
* Removes a reference by id. If it is cited, any cites will be dangling. It will also | ||
* disappear from the bibliography. | ||
* @param {string} id | ||
*/ | ||
removeReference(id: string): void; | ||
/** | ||
* Sets the references to be included in the bibliography despite not being directly cited. | ||
* | ||
* * `refr` is a | ||
* @param {any} refr | ||
* @param {IncludeUncited} uncited | ||
*/ | ||
insertReference(refr: any): void; | ||
includeUncited(uncited: IncludeUncited): void; | ||
/** | ||
@@ -164,4 +183,18 @@ * Gets a list of locales in use by the references currently loaded. | ||
/** | ||
* Previews a formatted citation cluster, in a particular position. | ||
* | ||
* - `cites`: The cites to go in the cluster | ||
* - `positions`: An array of `ClusterPosition`s as in set_cluster_order, but with a single | ||
* cluster's id set to zero. The cluster with id=0 is the position to preview the cite. It | ||
* can replace another cluster, or be inserted before/after/between existing clusters, in | ||
* any location you can think of. | ||
* @param {any[]} cites | ||
* @param {any[]} positions | ||
* @param {string} format | ||
* @returns {any} | ||
*/ | ||
previewCitationCluster(cites: any[], positions: any[], format: string): any; | ||
/** | ||
* @returns {any} | ||
*/ | ||
makeBibliography(): any; | ||
@@ -219,5 +252,5 @@ /** | ||
* May error without having set_cluster_ids, but with some set_cluster_note_number-s executed. | ||
* @param {any[]} pieces | ||
* @param {any[]} positions | ||
*/ | ||
setClusterOrder(pieces: any[]): void; | ||
setClusterOrder(positions: any[]): void; | ||
/** | ||
@@ -231,5 +264,5 @@ * Retrieve any clusters that have been touched since last time `batchedUpdates` was | ||
* * returns an `UpdateSummary` | ||
* @returns {any} | ||
* @returns {UpdateSummary} | ||
*/ | ||
batchedUpdates(): any; | ||
batchedUpdates(): UpdateSummary; | ||
/** | ||
@@ -254,5 +287,8 @@ * Drains the `batchedUpdates` queue manually. Use it to avoid serializing an unneeded | ||
readonly driver_new: (a: number, b: number, c: number, d: number, e: number) => number; | ||
readonly driver_setStyle: (a: number, b: number, c: number) => number; | ||
readonly driver_setReferences: (a: number, b: number, c: number) => void; | ||
readonly driver_setStyle: (a: number, b: number, c: number) => void; | ||
readonly driver_resetReferences: (a: number, b: number, c: number) => void; | ||
readonly driver_insertReferences: (a: number, b: number, c: number) => void; | ||
readonly driver_insertReference: (a: number, b: number) => void; | ||
readonly driver_removeReference: (a: number, b: number, c: number) => void; | ||
readonly driver_includeUncited: (a: number, b: number) => void; | ||
readonly driver_toFetch: (a: number) => number; | ||
@@ -263,2 +299,3 @@ readonly driver_insertCluster: (a: number, b: number) => void; | ||
readonly driver_builtCluster: (a: number, b: number) => number; | ||
readonly driver_previewCitationCluster: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number; | ||
readonly driver_makeBibliography: (a: number) => number; | ||
@@ -274,5 +311,6 @@ readonly driver_bibliographyMeta: (a: number) => number; | ||
readonly __wbindgen_export_2: WebAssembly.Table; | ||
readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h18b461775fab0812: (a: number, b: number, c: number) => void; | ||
readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf77188239a1f71cd: (a: number, b: number, c: number) => void; | ||
readonly __wbindgen_free: (a: number, b: number) => void; | ||
readonly __wbindgen_exn_store: (a: number) => void; | ||
readonly wasm_bindgen__convert__closures__invoke2_mut__h442d48e1eb0f8a8d: (a: number, b: number, c: number, d: number) => void; | ||
readonly wasm_bindgen__convert__closures__invoke2_mut__h19f62226ce422262: (a: number, b: number, c: number, d: number) => void; | ||
} | ||
@@ -279,0 +317,0 @@ |
@@ -10,16 +10,2 @@ | ||
let heap_next = heap.length; | ||
function dropObject(idx) { | ||
if (idx < 36) return; | ||
heap[idx] = heap_next; | ||
heap_next = idx; | ||
} | ||
function takeObject(idx) { | ||
const ret = getObject(idx); | ||
dropObject(idx); | ||
return ret; | ||
} | ||
let WASM_VECTOR_LEN = 0; | ||
@@ -96,2 +82,12 @@ | ||
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
cachedTextDecoder.decode(); | ||
function getStringFromWasm0(ptr, len) { | ||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); | ||
} | ||
let heap_next = heap.length; | ||
function addHeapObject(obj) { | ||
@@ -106,8 +102,12 @@ if (heap_next === heap.length) heap.push(heap.length + 1); | ||
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
function dropObject(idx) { | ||
if (idx < 36) return; | ||
heap[idx] = heap_next; | ||
heap_next = idx; | ||
} | ||
cachedTextDecoder.decode(); | ||
function getStringFromWasm0(ptr, len) { | ||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); | ||
function takeObject(idx) { | ||
const ret = getObject(idx); | ||
dropObject(idx); | ||
return ret; | ||
} | ||
@@ -144,3 +144,3 @@ | ||
function __wbg_adapter_18(arg0, arg1, arg2) { | ||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h18b461775fab0812(arg0, arg1, addHeapObject(arg2)); | ||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf77188239a1f71cd(arg0, arg1, addHeapObject(arg2)); | ||
} | ||
@@ -176,4 +176,4 @@ | ||
} | ||
function __wbg_adapter_43(arg0, arg1, arg2, arg3) { | ||
wasm.wasm_bindgen__convert__closures__invoke2_mut__h442d48e1eb0f8a8d(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); | ||
function __wbg_adapter_63(arg0, arg1, arg2, arg3) { | ||
wasm.wasm_bindgen__convert__closures__invoke2_mut__h19f62226ce422262(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); | ||
} | ||
@@ -222,3 +222,2 @@ | ||
* @param {string} style_text | ||
* @returns {any} | ||
*/ | ||
@@ -228,13 +227,23 @@ setStyle(style_text) { | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_setStyle(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
wasm.driver_setStyle(this.ptr, ptr0, len0); | ||
} | ||
/** | ||
* Completely overwrites the references library. | ||
* This **will** delete references that are not in the provided list. | ||
* @param {any[]} refs | ||
*/ | ||
resetReferences(refs) { | ||
var ptr0 = passArrayJsValueToWasm0(refs, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_resetReferences(this.ptr, ptr0, len0); | ||
} | ||
/** | ||
* Inserts or overwrites references as a batch operation. | ||
* This **will not** delete references that are not in the provided list. | ||
* @param {any[]} refs | ||
*/ | ||
setReferences(refs) { | ||
insertReferences(refs) { | ||
var ptr0 = passArrayJsValueToWasm0(refs, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_setReferences(this.ptr, ptr0, len0); | ||
wasm.driver_insertReferences(this.ptr, ptr0, len0); | ||
} | ||
@@ -244,4 +253,4 @@ /** | ||
* | ||
* * `refr` is a | ||
* @param {any} refr | ||
* * `refr` is a Reference object. | ||
* @param {Reference} refr | ||
*/ | ||
@@ -252,2 +261,21 @@ insertReference(refr) { | ||
/** | ||
* Removes a reference by id. If it is cited, any cites will be dangling. It will also | ||
* disappear from the bibliography. | ||
* @param {string} id | ||
*/ | ||
removeReference(id) { | ||
var ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_removeReference(this.ptr, ptr0, len0); | ||
} | ||
/** | ||
* Sets the references to be included in the bibliography despite not being directly cited. | ||
* | ||
* * `refr` is a | ||
* @param {IncludeUncited} uncited | ||
*/ | ||
includeUncited(uncited) { | ||
wasm.driver_includeUncited(this.ptr, addHeapObject(uncited)); | ||
} | ||
/** | ||
* Gets a list of locales in use by the references currently loaded. | ||
@@ -300,4 +328,27 @@ * | ||
/** | ||
* Previews a formatted citation cluster, in a particular position. | ||
* | ||
* - `cites`: The cites to go in the cluster | ||
* - `positions`: An array of `ClusterPosition`s as in set_cluster_order, but with a single | ||
* cluster's id set to zero. The cluster with id=0 is the position to preview the cite. It | ||
* can replace another cluster, or be inserted before/after/between existing clusters, in | ||
* any location you can think of. | ||
* @param {any[]} cites | ||
* @param {any[]} positions | ||
* @param {string} format | ||
* @returns {any} | ||
*/ | ||
previewCitationCluster(cites, positions, format) { | ||
var ptr0 = passArrayJsValueToWasm0(cites, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ptr1 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len1 = WASM_VECTOR_LEN; | ||
var ptr2 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len2 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_previewCitationCluster(this.ptr, ptr0, len0, ptr1, len1, ptr2, len2); | ||
return takeObject(ret); | ||
} | ||
/** | ||
* @returns {any} | ||
*/ | ||
makeBibliography() { | ||
@@ -365,6 +416,6 @@ var ret = wasm.driver_makeBibliography(this.ptr); | ||
* May error without having set_cluster_ids, but with some set_cluster_note_number-s executed. | ||
* @param {any[]} pieces | ||
* @param {any[]} positions | ||
*/ | ||
setClusterOrder(pieces) { | ||
var ptr0 = passArrayJsValueToWasm0(pieces, wasm.__wbindgen_malloc); | ||
setClusterOrder(positions) { | ||
var ptr0 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
@@ -381,3 +432,3 @@ wasm.driver_setClusterOrder(this.ptr, ptr0, len0); | ||
* * returns an `UpdateSummary` | ||
* @returns {any} | ||
* @returns {UpdateSummary} | ||
*/ | ||
@@ -445,8 +496,2 @@ batchedUpdates() { | ||
imports.wbg = {}; | ||
imports.wbg.__wbindgen_object_drop_ref = function(arg0) { | ||
takeObject(arg0); | ||
}; | ||
imports.wbg.__wbg_error_e549f7fed6d655aa = function(arg0) { | ||
console.error(takeObject(arg0)); | ||
}; | ||
imports.wbg.__wbindgen_json_serialize = function(arg0, arg1) { | ||
@@ -460,6 +505,2 @@ const obj = getObject(arg1); | ||
}; | ||
imports.wbg.__wbindgen_object_clone_ref = function(arg0) { | ||
var ret = getObject(arg0); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_fetchLocale_8f52b973b0739a6c = function(arg0, arg1, arg2) { | ||
@@ -469,2 +510,9 @@ var ret = getObject(arg0).fetchLocale(getStringFromWasm0(arg1, arg2)); | ||
}; | ||
imports.wbg.__wbindgen_json_parse = function(arg0, arg1) { | ||
var ret = JSON.parse(getStringFromWasm0(arg0, arg1)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbindgen_object_drop_ref = function(arg0) { | ||
takeObject(arg0); | ||
}; | ||
imports.wbg.__wbindgen_cb_drop = function(arg0) { | ||
@@ -479,6 +527,42 @@ const obj = takeObject(arg0).original; | ||
}; | ||
imports.wbg.__wbindgen_json_parse = function(arg0, arg1) { | ||
var ret = JSON.parse(getStringFromWasm0(arg0, arg1)); | ||
imports.wbg.__wbg_error_e549f7fed6d655aa = function(arg0) { | ||
console.error(takeObject(arg0)); | ||
}; | ||
imports.wbg.__wbg_debug_4885c3f7d6f044a3 = function(arg0, arg1) { | ||
console.debug(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
imports.wbg.__wbg_log_bee3ea1a89f334d8 = function(arg0, arg1) { | ||
console.log(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
imports.wbg.__wbg_info_0547ff9513f2019b = function(arg0, arg1) { | ||
console.info(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
imports.wbg.__wbg_warn_a478dea6e6e05394 = function(arg0, arg1) { | ||
console.warn(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
imports.wbg.__wbg_error_72e88ba6901b6eee = function(arg0, arg1) { | ||
console.error(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
imports.wbg.__wbindgen_object_clone_ref = function(arg0) { | ||
var ret = getObject(arg0); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_new_59cb74e423758ede = function() { | ||
var ret = new Error(); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_stack_558ba5917b466edd = function(arg0, arg1) { | ||
var ret = getObject(arg1).stack; | ||
var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
getInt32Memory0()[arg0 / 4 + 1] = len0; | ||
getInt32Memory0()[arg0 / 4 + 0] = ptr0; | ||
}; | ||
imports.wbg.__wbg_error_4bb6c2a97407129a = function(arg0, arg1) { | ||
try { | ||
console.error(getStringFromWasm0(arg0, arg1)); | ||
} finally { | ||
wasm.__wbindgen_free(arg0, arg1); | ||
} | ||
}; | ||
imports.wbg.__wbg_new_4896ab6bba55e0d9 = function(arg0, arg1) { | ||
@@ -499,3 +583,3 @@ var ret = new Error(getStringFromWasm0(arg0, arg1)); | ||
try { | ||
return __wbg_adapter_43(a, state0.b, arg0, arg1); | ||
return __wbg_adapter_63(a, state0.b, arg0, arg1); | ||
} finally { | ||
@@ -537,4 +621,4 @@ state0.a = a; | ||
}; | ||
imports.wbg.__wbindgen_closure_wrapper847 = function(arg0, arg1, arg2) { | ||
var ret = makeMutClosure(arg0, arg1, 88, __wbg_adapter_18); | ||
imports.wbg.__wbindgen_closure_wrapper866 = function(arg0, arg1, arg2) { | ||
var ret = makeMutClosure(arg0, arg1, 228, __wbg_adapter_18); | ||
return addHeapObject(ret); | ||
@@ -541,0 +625,0 @@ }; |
@@ -7,3 +7,3 @@ { | ||
"description": "citeproc-rs, compiled to WebAssembly", | ||
"version": "0.0.0-canary-029407d", | ||
"version": "0.0.0-canary-108a426", | ||
"license": "MPL-2.0", | ||
@@ -10,0 +10,0 @@ "repository": { |
378
README.md
# `@citeproc-rs/wasm` | ||
This is a build of `citeproc` that is suitable for use in Node.js, a browser or | ||
a Firefox/Chromium-based application like Zotero. It consists of a WebAssembly | ||
(WASM) binary, and a fairly lightweight JavaScript wrapper for that binary. | ||
This is a front-end to | ||
[`citeproc-rs`](https://github.com/cormacrelf/citeproc-rs), a citation | ||
processor written in Rust and compiled to WebAssembly. | ||
README for newer version of the API forthcoming. | ||
It contains builds appropriate for: | ||
- Node.js | ||
- Browsers, using a bundler like Webpack.js | ||
- Browsers directly importing an ES Module from a webserver | ||
## Installation / Release channels | ||
There are two release channels: | ||
**Stable** is each versioned release. (*At the time of writing, there are no | ||
versioned releases.*) Install with: | ||
```sh | ||
yarn add @citeproc-rs/wasm | ||
``` | ||
**Canary** tracks the master branch [on | ||
GitHub](https://github.com/cormacrelf/citeproc-rs). Its version numbers follow | ||
the format `0.0.0-canary-GIT_COMMIT_SHA`, so version ranges in your | ||
`package.json` are not meaningful. But you can install the latest one with: | ||
```sh | ||
yarn add @citeproc-rs/wasm@canary | ||
# alternatively, a specific commit | ||
yarn add @citeproc-rs/wasm@0.0.0-canary-COMMIT_SHA | ||
``` | ||
If you use NPM, replace `yarn add` with `npm install`. | ||
### Including in your project | ||
For Node.js, simply import the package as normal. Typescript definitions are | ||
provided, though parts of the API that cannot have auto-generated type | ||
definitions are alluded to in doc comments with an accompanying type you can | ||
import. | ||
``` | ||
// Node.js | ||
const { Driver } = require("@citeproc-rs/wasm"); | ||
``` | ||
#### Using Webpack | ||
When loading on the web, for technical reasons and because the compiled | ||
WebAssembly is large, you must load the package asynchronously. Webpack comes | ||
with the ability to import packages asynchronously like so: | ||
```javascript | ||
// Webpack | ||
import("@citeproc-rs/wasm") | ||
.then(go) | ||
.catch(console.error); | ||
function go(wasm) { | ||
const { Driver } = wasm; | ||
// use Driver | ||
} | ||
``` | ||
When you do this, your code will trigger a download (and streaming parse) of | ||
the binary, and when that is complete, your `go` function will be called. The | ||
download can of course be cached if your web server is set up correctly, making | ||
the whole process very quick. | ||
You can use the regular-import Driver as a TypeScript type anywhere, just don't | ||
use it to call `.new()`. | ||
Note the caveats in around Microsoft Edge's TextEncoder/TextDecoder support in | ||
[the wasm-bindgen | ||
tutorial](https://rustwasm.github.io/docs/wasm-bindgen/examples/hello-world.html). | ||
```typescript | ||
import { Driver } from "@citeproc-rs/wasm"; | ||
function doSomethingWithDriver(driver: Driver) { | ||
// ... | ||
} | ||
``` | ||
#### Importing it in a script tag (`web` target) | ||
To directly import it without a bundler in a (modern) web browser with ES | ||
modules support, the procedure is different. You must: | ||
1. Make the `_web` subdirectory of the published NPM package available in a | ||
content directory on your webserver, or use a CDN like [unpkg](unpkg.com). | ||
2. Include a `<script type="module">` tag in your page's `<body>`, like so: | ||
```html | ||
<script type="module"> | ||
import init, { Driver } from './path/to/_web/citeproc_rs_wasm.js'; | ||
async function run() { | ||
await init(); | ||
// use Driver | ||
} | ||
run() | ||
</script> | ||
``` | ||
#### Importing it in a script tag (`no-modules` target) | ||
This replicates the [wasm-bindgen guide | ||
entry](https://rustwasm.github.io/docs/wasm-bindgen/examples/without-a-bundler.html?highlight=no-modules#using-the-older---target-no-modules), | ||
noting the caveats. You will, similarly to the `web` target, need to make the | ||
contents of the `_no_modules` subdirectory of the published NPM package | ||
available on a webserver or via a CDN. | ||
``` | ||
<html> | ||
<head> | ||
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"/> | ||
</head> | ||
<body> | ||
<!-- Include the JS generated by `wasm-pack build` --> | ||
<script src='path/to/@citeproc-rs/wasm/_no_modules/citeproc_rs_wasm.js'></script> | ||
<script> | ||
// Like with the `--target web` output the exports are immediately | ||
// available but they won't work until we initialize the module. Unlike | ||
// `--target web`, however, the globals are all stored on a | ||
// `wasm_bindgen` global. The global itself is the initialization | ||
// function and then the properties of the global are all the exported | ||
// functions. | ||
// | ||
// Note that the name `wasm_bindgen` will at some point be configurable with the | ||
// `--no-modules-global` CLI flag (https://github.com/rustwasm/wasm-pack/issues/729) | ||
const { Driver } = wasm_bindgen; | ||
async function run() { | ||
// Note the _bg.wasm ending | ||
await wasm_bindgen('path/to/@citeproc-rs/wasm/_no_modules/citeproc_rs_wasm_bg.wasm'); | ||
// Use Driver | ||
} | ||
run(); | ||
</script> | ||
</body> | ||
</html> | ||
``` | ||
## Usage | ||
### Overview | ||
The basic pattern of interactive use is: | ||
1. Create a driver instance with your style | ||
2. Edit the references or the citation clusters as you please | ||
3. **Call `driver.batchedUpdates()`** | ||
4. Apply the updates to your document (e.g. GUI) | ||
5. Go to step 2 when a user makes a change | ||
Step three is the important one. Each time you edit a cluster or a reference, | ||
it is common for only one or two visible modifications to result. Therefore, | ||
the driver only gives you those clusters or bibliography entries that have | ||
changed, or have been caused to change by an edit elsewhere. You can submit any | ||
number of edits between each call. | ||
The API also allows for non-interactive use. See below. | ||
### 1. Creating a driver instance | ||
First, create a driver. Note that for now, you must also call `.free()` on the | ||
Driver when you are finished with it to deallocate its memory, but [there is a TC39 | ||
proposal](https://rustwasm.github.io/docs/wasm-bindgen/reference/weak-references.html) | ||
in the implementation phase that will make this unnecessary. | ||
A driver needs an XML style string, a fetcher (below), and an output format | ||
(one of `"html"`, `"rtf"` or `"plain"`). | ||
```javascript | ||
let driver = Driver.new(cslStyleTextAsXML, fetcher, "html"); | ||
// ... use the driver ... | ||
driver.free() | ||
``` | ||
The library parses and validates the CSL style input. Any validation errors are | ||
reported, with line/column positions, the text at that location, a descriptive | ||
and useful message (only in English at the moment) and sometimes even a hint | ||
for how to fix it. This is thrown as an error, which you can catch in a `try {} | ||
catch (e) {}` block. | ||
#### Fetcher | ||
There are hundreds of locales, and the locales you need change depending on the | ||
references that are active in your document, so the procedure for retrieving | ||
one is asynchronous to allow for fetching one over HTTP. There's not much more | ||
to it than this: | ||
```javascript | ||
class Fetcher { | ||
async fetchLocale(lang) { | ||
return fetch("https://some-cdn-with-locales.com/locales-${lang}.xml") | ||
.then(res => res.text()); | ||
// or just | ||
// return "<locale> ... </locale>"; | ||
// return LOCALES_PRELOADED[lang]; | ||
// or if you don't support locales other than the bundled en-US! | ||
// return null; | ||
} | ||
} | ||
let fetcher = new Fetcher(); // Pass to Driver.new() | ||
``` | ||
Unless you don't have `async` syntax, in which case, return a `Promise` | ||
directly, e.g. `return Promise.resolve("<locale> ... </locale>")`. | ||
### 2. Edit the references or the citation clusters | ||
#### References | ||
You can insert a reference like so. This is a [CSL-JSON][schema] object. | ||
[schema]: https://github.com/citation-style-language/schema | ||
```javascript | ||
driver.insertReference({ id: "citekey", type: "book", title: "Title" }); | ||
driver.insertReferences([ ... many references ... ]); | ||
driver.resetReferences([ ... deletes any others ... ]); | ||
driver.removeReference("citekey"); | ||
``` | ||
When you do insert a reference, it may have locale information in it. This | ||
should be done after updating the references, so any new locales can be | ||
fetched. | ||
```javascript | ||
// May call your Fetcher instance. | ||
await driver.fetchAll(); | ||
``` | ||
#### Citation Clusters and their Cites | ||
A document consists of a series of clusters, each with a series of cites. Each | ||
cluster has an `id`, which is any integer except zero. | ||
```javascript | ||
// initClusters is like booting up an existing document and getting up to speed | ||
driver.initClusters([ | ||
{ id: 1, cites: [ {id: "citekey"} ] }, | ||
{ id: 2, cites: [ {id: "citekey", locator: "56", label: "page" } ] }, | ||
]); | ||
// Update or insert any one of them like so | ||
driver.insertCluster({ id: 1, cites: [ { id: "updated_citekey" } ] }); | ||
driver.insertCluster({ id: 3, cites: [ { id: "new_cluster_here" } ] }); | ||
``` | ||
These clusters do not contain position information, so reordering is a separate | ||
procedure. **Without calling setClusterOrder, the driver considers the document | ||
to be empty.** | ||
So, `setClusterOrder` expresses the ordering of the clusters within the | ||
document. Each one in the document should appear in this list. You can skip | ||
note numbers, which means there were non-citing footnotes in between. Omitting | ||
`note` means it's an in-text reference. Note numbers must be monotonic, but you | ||
can have more than one cluster in the same footnote. | ||
```javascript | ||
driver.setClusterOrder([ { id: 1, note: 1 }, { id: 2, note: 4 } ]); | ||
``` | ||
You will notice that if an interactive user cuts and pastes a paragraph | ||
containing citation clusters, the whole reordering operation can be expressed | ||
in two calls, one after the cut (with some clusters omitted) and one after the | ||
paste (with those same clusters placed somewhere else). No calls to | ||
`insertCluster` need be made. | ||
#### Uncited items | ||
Sometimes a user wishes to include references in the bibliography even though | ||
they are not mentioned in a citation anywhere in the document. | ||
```javascript | ||
driver.includeUncited("None"); // Default | ||
driver.includeUncited("All"); | ||
driver.includeUncited({ Specific: ["citekeyA", "citekeyB"] }); | ||
``` | ||
### 3. Call `driver.batchedUpdates()` and apply the diff | ||
This gets you a diff to apply to your document UI. It includes both clusters | ||
that have changed, and bibliography entries that have changed. | ||
```javascript | ||
import { UpdateSummary } from "@citeproc-rs/wasm"; // typescript users, annotate with this | ||
let diff = driver.batchedUpdates(); | ||
// apply to the UI | ||
diff.clusters.forEach(changedCluster => { | ||
let [id, html] = changedCluster; | ||
myDocument.updateCluster(id, html); | ||
}); | ||
diff.bibliography.entryIds.forEach(citekey => { | ||
let html = diff.updatedEntries[citekey]; | ||
myDocument.updateBibEntry(citekey, html); | ||
}); | ||
``` | ||
Note, for some intuition, if you call `batchedUpdates()` again immediately, the | ||
diff will be empty. | ||
### Preview citation clusters | ||
Sometimes, a user wants to see how a cluster will look while they are editing | ||
it, before confirming the change. | ||
```javascript | ||
let cites = [ { id: "citekey", locator: "45" }, { ... } ]; | ||
let positions = [ ... before, { id: 0, note: 34 }, ... after ]; | ||
let preview = driver.previewCitationCluster(cites, positions, "html"); | ||
``` | ||
The positions array is exactly like a call to `setClusterOrder`, except exactly | ||
one of the positions has an id of 0. This could either: | ||
- Replace an existing cluster's position, and preview a cluster replacement; or | ||
- Represent the position a cluster is hypothetically inserted. | ||
If you passed only one position, it would be like previewing an operation like | ||
"delete the entire document and replace it with this one cluster". **That would | ||
mean you would never see "ibid" in a preview.** So for maximum utility, | ||
assemble the positions array as you would a call to `setClusterOrder` with | ||
exactly the operation you're previewing applied. | ||
### Non-Interactive use, or re-hydrating a previously created document | ||
If you are working non-interactively, or re-hydrating a previously created | ||
document for interactive use, you may want to do one pass over all the clusters | ||
in the document, so that each cluster and bibliography entry reflects the | ||
correct value. | ||
```javascript | ||
// Get the clusters from your document (example) | ||
let allNotes = myDocument.footnotes.map(fn => { | ||
return { cluster: getCluster(fn), number: fn.number } | ||
}); | ||
// Re-hydrate the entire document | ||
driver.resetReferences(allReferences); | ||
driver.initClusters(allNotes.map(fn => fn.cluster)); | ||
driver.setClusterOrder(allNotes.map(fn => { id: note.cluster.id, note: note.number })); | ||
// Build every cluster, only after the driver knows about all of them | ||
allNotes.forEach(fn => { | ||
fn.renderedHtml = driver.builtCluster(fn.cluster.id); | ||
}); | ||
let bibliography = driver.makeBibliography(); | ||
// Drain the update queue, so the driver knows you're up to date and won't send | ||
// you a whole-document diff | ||
driver.drain(); | ||
// Update the UI | ||
updateUserInterface(allNotes, bibliography); | ||
``` | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2510
378
11872075