Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@citeproc-rs/wasm

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@citeproc-rs/wasm - npm Package Compare versions

Comparing version 0.0.0-canary-3f5d731 to 0.0.0-canary-404d2bd

_cjs/snippets/wasm-1883a0b9dcad429e/src/js/include.js

34

_cjs/citeproc_rs_wasm_bg.wasm.d.ts
/* tslint:disable */
/* eslint-disable */
export const memory: WebAssembly.Memory;
export function parseStyleMetadata(a: number, b: number): number;
export function __wbg_driver_free(a: number): void;
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): 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_new(a: number): number;
export function driver_setStyle(a: number, b: number, c: number): number;
export function driver_resetReferences(a: number, b: number, c: number): number;
export function driver_insertReferences(a: number, b: number, c: number): number;
export function driver_insertReference(a: number, b: number): number;
export function driver_removeReference(a: number, b: number, c: number): number;
export function driver_includeUncited(a: number, b: number): number;
export function driver_toFetch(a: number): number;
export function driver_insertCluster(a: number, b: number): void;
export function driver_removeCluster(a: number, b: number): void;
export function driver_initClusters(a: number, b: number, c: number): void;
export function driver_builtCluster(a: number, b: number): number;
export function driver_randomClusterId(a: number, b: number): void;
export function driver_insertCluster(a: number, b: number): number;
export function driver_removeCluster(a: number, b: number, c: number): number;
export function driver_initClusters(a: number, b: number, c: number): number;
export function driver_builtCluster(a: number, b: number, c: 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;
export function driver_bibliographyMeta(a: number): number;
export function driver_renumberClusters(a: number, b: number, c: number): void;
export function driver_setClusterOrder(a: number, b: number, c: number): void;
export function driver_setClusterOrder(a: number, b: number, c: number): number;
export function driver_batchedUpdates(a: number): number;
export function driver_fullRender(a: number): number;
export function driver_drain(a: number): void;
export function driver_fetchAll(a: number): number;
export function driver_fetchLocales(a: number): number;
export function __wbindgen_malloc(a: number): number;
export function __wbindgen_realloc(a: number, b: number, c: 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__hd125291c94f17248(a: number, b: number, c: number): void;
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2b1b33880a98c55e(a: number, b: number, c: number): void;
export function __wbindgen_add_to_stack_pointer(a: number): number;
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__h48fd5816c723cd64(a: number, b: number, c: number, d: number): void;
export function wasm_bindgen__convert__closures__invoke2_mut__h4915090d68cfd6bd(a: number, b: number, c: number, d: number): void;
/* tslint:disable */
/* eslint-disable */
/**
* Parses a CSL style, either independent or dependent, and returns its metadata.
* @param {string} style
* @returns {WasmResult<StyleMeta>}
*/
export function parseStyleMetadata(style: string): WasmResult<StyleMeta>;
interface InitOptions {
/** A CSL style as an XML string */
style: string,
/** A Fetcher implementation for fetching locales.
*
* If not provided, then no locales can be fetched, and default-locale and localeOverride will
* not be respected; the only locale used will be the bundled en-US. */
fetcher?: Fetcher,
/** The output format for this driver instance */
format: "html" | "rtf" | "plain",
/** A locale to use instead of the style's default-locale.
*
* For dependent styles, use parseStyleMetadata to find out which locale it prefers, and pass
* in the parent style with a localeOverride set to that value.
*/
localeOverride?: string,
/** Disables sorting in the bibliography; items appear in cited order. */
bibliographyNoSort?: bool,
}
/** This interface lets citeproc retrieve locales or modules asynchronously,
according to which ones are needed. */
export interface Lifecycle {
export interface Fetcher {
/** Return locale XML for a particular locale. */

@@ -12,2 +41,4 @@ fetchLocale(lang: string): Promise<string>;

export type DateLiteral = { "literal": string; };

@@ -21,2 +52,4 @@ export type DateRaw = { "raw": string; };

/** Locator type, and a locator string */

@@ -29,24 +62,28 @@ export type Locator = {

export type CiteLocator = Locator | { locator: undefined; locators: Locator[] };
export type CiteLocator = Locator | { locator: undefined; locators: Locator[]; };
export type CiteMode = { mode?: "SuppressAuthor" | "AuthorOnly"; };
export type Cite<Affix = string> = {
export type Cite = {
id: string;
prefix?: Affix;
suffix?: Affix;
suppression?: "InText" | "Rest" | null;
} & Partial<CiteLocator>;
prefix?: string;
suffix?: string;
} & Partial<CiteLocator> & CiteMode;
export type ClusterNumber = {
note: number | [number, number]
} | {
inText: number
};
export type ClusterMode
= { mode: "Composite"; infix?: string; suppressFirst?: number; }
| { mode: "SuppressAuthor"; suppressFirst?: number; }
| { mode: "AuthorOnly"; }
| {};
export type Cluster = {
id: number;
id: string;
cites: Cite[];
};
} & ClusterMode;
export type PreviewCluster {
cites: Cite[];
} & ClusterMode;
export type ClusterPosition = {
id: number;
id: string;
/** Leaving off this field means this cluster is in-text. */

@@ -56,2 +93,4 @@ note?: number;

export type Reference = {

@@ -63,6 +102,8 @@ id: string;

export type CslType = "book" | "article" | "legal_case" | "article-journal";
export type CslType = "book" | "article" | "legal_case" | "article-journal" | string;
export interface BibliographyUpdate {
updatedEntries: { [key: string]: string };
updatedEntries: Map<string, string>;
entryIds?: string[];

@@ -72,23 +113,6 @@ }

export type UpdateSummary<Output = string> = {
clusters: [number, Output][];
clusters: [string, Output][];
bibliography?: BibliographyUpdate;
};
type InvalidCsl = {
severity: "Error" | "Warning";
range: {
start: number;
end: number;
};
message: string;
hint: string;
};
type ParseError = {
ParseError: string;
};
type Invalid = {
Invalid: InvalidCsl[];
};
type StyleError = Partial<ParseError & Invalid>;
type IncludeUncited = "None" | "All" | { Specific: string[] };

@@ -104,3 +128,3 @@

type FullRender = {
allClusters: { [clusterId: string]: string },
allClusters: Map<string, string>,
bibEntries: BibEntries,

@@ -110,6 +134,6 @@ };

type BibliographyMeta = {
max_offset: number;
entry_spacing: number;
line_spacing: number;
hanging_indent: boolean;
maxOffset: number;
entrySpacing: number;
lineSpacing: number;
hangingIndent: boolean;
/** the second-field-align value of the CSL style */

@@ -122,2 +146,128 @@ secondFieldAlign: null | "flush" | "margin";

type Severity = "Error" | "Warning";
interface InvalidCsl {
severity: Severity;
/** Relevant bytes in the provided XML */
range: {
start: number,
end: number,
};
message: string;
hint: string | undefined;
};
type StyleError = {
tag: "Invalid",
content: InvalidCsl[],
} | {
tag: "ParseError",
content: string,
} | {
/** Cannot use a dependent style to format citations, pass the parent style instead. */
tag: "DependentStyle",
content: {
requiredParent: string,
}
};
type DriverError = {
tag: "UnknownOutputFormat",
content: string,
} | {
tag: "JsonError",
} | {
tag: "GetFetcherError",
} | {
tag: "NonExistentCluster",
content: string,
} | {
tag: "ReorderingError"
} | {
tag: "ReorderingErrorNumericId"
};
declare global {
/** Catch-all citeproc-rs Error subclass. */
declare class CiteprocRsError extends Error {
constructor(message: string);
}
declare class CiteprocRsDriverError extends CiteprocRsError {
data: DriverError;
constructor(message: string, data: DriverError);
}
declare class CslStyleError extends CiteprocRsError {
data: StyleError;
constructor(message: string, data: StyleError);
}
}
interface WasmResult<T> {
/** If this is an error, throws the error. */
unwrap(): T;
/** If this is an error, returns it, else throws. */
unwrap_err(): Error;
is_ok(): boolean;
is_err(): boolean;
/** If this is an error, returns the default value. */
unwrap_or(default: T): T;
/** If this is Ok, returns f(ok_val), else returns Err unmodified. */
map<R>(f: (t: T) => R): WasmResult<T>;
/** If this is Ok, returns f(ok_val), else returns the default value. */
map_or<R>(default: R, f: (t: T) => R): R;
}
type CitationFormat = "author-date" | "author" | "numeric" | "label" | "note";
interface LocalizedString {
value: string,
lang?: string,
}
interface ParentLink {
href: string,
lang?: string,
}
interface Link {
href: string,
rel: "self" | "documentation" | "template",
lang?: string,
}
interface Rights {
value: string,
lang?: string,
license?: string,
}
interface StyleInfo {
id: string,
updated: string,
title: LocalizedString,
titleShort?: LocalizedString,
parent?: ParentLink,
links: Link[],
rights?: Rights,
citationFormat?: CitationFormat,
categories: string[],
issn?: string,
eissn?: string,
issnl?: string,
}
interface IndependentMeta {
/** A list of languages for which a locale override was specified.
* Does not include the language-less final override. */
localeOverrides: string[],
hasBibliography: bool,
}
interface StyleMeta {
info: StyleInfo,
features: { [feature: string]: bool },
defaultLocale: string,
/** May be absent on a dependent style */
class?: "in-text" | "note",
cslVersionRequired: string,
/** May be absent on a dependent style */
independentMeta?: IndependentMeta,
};
/**

@@ -131,17 +281,16 @@ */

* * `style` is a CSL style as a string. Independent styles only.
* * `lifecycle` must implement the `Lifecycle` interface
* * `fetcher` must implement the `Fetcher` interface
* * `format` is one of { "html", "rtf" }
*
* Throws an error if it cannot parse the style you gave it.
* @param {string} style
* @param {any} lifecycle
* @param {string} format
* @returns {Driver}
* @param {InitOptions} options
* @returns {WasmResult<Driver>}
*/
static new(style: string, lifecycle: any, format: string): Driver;
static new(options: InitOptions): WasmResult<Driver>;
/**
* Sets the style (which will also cause everything to be recomputed)
* @param {string} style_text
* @returns {WasmResult<undefined>}
*/
setStyle(style_text: string): void;
setStyle(style_text: string): WasmResult<undefined>;
/**

@@ -151,4 +300,5 @@ * Completely overwrites the references library.

* @param {any[]} refs
* @returns {WasmResult<undefined>}
*/
resetReferences(refs: any[]): void;
resetReferences(refs: any[]): WasmResult<undefined>;
/**

@@ -158,4 +308,5 @@ * Inserts or overwrites references as a batch operation.

* @param {any[]} refs
* @returns {WasmResult<undefined>}
*/
insertReferences(refs: any[]): void;
insertReferences(refs: any[]): WasmResult<undefined>;
/**

@@ -166,4 +317,5 @@ * Inserts or overwrites a reference.

* @param {Reference} refr
* @returns {WasmResult<undefined>}
*/
insertReference(refr: Reference): void;
insertReference(refr: Reference): WasmResult<undefined>;
/**

@@ -173,4 +325,5 @@ * Removes a reference by id. If it is cited, any cites will be dangling. It will also

* @param {string} id
* @returns {WasmResult<undefined>}
*/
removeReference(id: string): void;
removeReference(id: string): WasmResult<undefined>;
/**

@@ -181,4 +334,5 @@ * Sets the references to be included in the bibliography despite not being directly cited.

* @param {IncludeUncited} uncited
* @returns {WasmResult<undefined>}
*/
includeUncited(uncited: IncludeUncited): void;
includeUncited(uncited: IncludeUncited): WasmResult<undefined>;
/**

@@ -188,15 +342,22 @@ * Gets a list of locales in use by the references currently loaded.

* Note that Driver comes pre-loaded with the `en-US` locale.
* @returns {any}
* @returns {WasmResult<string[]>}
*/
toFetch(): any;
toFetch(): WasmResult<string[]>;
/**
* Returns a random cluster id, with an extra guarantee that it isn't already in use.
* @returns {string}
*/
randomClusterId(): string;
/**
* Inserts or replaces a cluster with a matching `id`.
* @param {any} cluster
* @param {Cluster} cluster
* @returns {WasmResult<undefined>}
*/
insertCluster(cluster: any): void;
insertCluster(cluster: Cluster): WasmResult<undefined>;
/**
* Removes a cluster with a matching `id`
* @param {number} cluster_id
* @param {string} cluster_id
* @returns {WasmResult<undefined>}
*/
removeCluster(cluster_id: number): void;
removeCluster(cluster_id: string): WasmResult<undefined>;
/**

@@ -207,4 +368,5 @@ * Resets all the clusters in the processor to a new list.

* @param {any[]} clusters
* @returns {WasmResult<undefined>}
*/
initClusters(clusters: any[]): void;
initClusters(clusters: any[]): WasmResult<undefined>;
/**

@@ -215,6 +377,6 @@ * Returns the formatted citation cluster for `cluster_id`.

* still useful for initialization.
* @param {number} id
* @returns {any}
* @param {string} id
* @returns {WasmResult<string>}
*/
builtCluster(id: number): any;
builtCluster(id: string): WasmResult<string>;
/**

@@ -231,37 +393,14 @@ * Previews a formatted citation cluster, in a particular position.

* @param {string} format
* @returns {any}
* @returns {WasmResult<string>}
*/
previewCitationCluster(cites: any[], positions: any[], format: string): any;
previewCitationCluster(cites: any[], positions: any[], format: string): WasmResult<string>;
/**
* @returns {BibEntries}
* @returns {WasmResult<BibEntries>}
*/
makeBibliography(): BibEntries;
makeBibliography(): WasmResult<BibEntries>;
/**
* @returns {BibliographyMeta}
* @returns {WasmResult<BibliographyMeta>}
*/
bibliographyMeta(): BibliographyMeta;
bibliographyMeta(): WasmResult<BibliographyMeta>;
/**
* Replaces cluster numberings in one go.
*
* * `mappings` is an `Array<[ ClusterId, ClusterNumber ]>` where `ClusterNumber`
* is, e.g. `{ note: 1 }`, `{ note: [3, 1] }` or `{ inText: 5 }` in the same way a
* Cluster must contain one of those three numberings.
*
* Not every ClusterId must appear in the array, just the ones you wish to renumber.
*
* The library consumer is responsible for ensuring that clusters are well-ordered. Clusters
* are sorted for determining cite positions (ibid, subsequent, etc). If a footnote is
* deleted, you will likely need to shift all cluster numbers after it back by one.
*
* The second note numbering, `{note: [3, 1]}`, is for having multiple clusters in a single
* footnote. This is possible in many editors. The second number acts as a second sorting
* key.
*
* The third note numbering, `{ inText: 5 }`, is for ordering in-text references that appear
* within the body of a document. These will be sorted but won't cause
* `first-reference-note-number` to become available.
* @param {any[]} mappings
*/
renumberClusters(mappings: any[]): void;
/**
* Specifies which clusters are actually considered to be in the document, and sets their

@@ -291,4 +430,5 @@ * order. You may insert as many clusters as you like, but the ones provided here are the only

* @param {any[]} positions
* @returns {WasmResult<undefined>}
*/
setClusterOrder(positions: any[]): void;
setClusterOrder(positions: any[]): WasmResult<undefined>;
/**

@@ -302,5 +442,5 @@ * Retrieve any clusters that have been touched since last time `batchedUpdates` was

* * returns an `UpdateSummary`
* @returns {UpdateSummary}
* @returns {WasmResult<UpdateSummary>}
*/
batchedUpdates(): UpdateSummary;
batchedUpdates(): WasmResult<UpdateSummary>;
/**

@@ -310,5 +450,5 @@ * Returns all the clusters and bibliography entries in the document.

* Use this to rehydrate a document or run non-interactively.
* @returns {FullRender}
* @returns {WasmResult<FullRender>}
*/
fullRender(): FullRender;
fullRender(): WasmResult<FullRender>;
/**

@@ -320,6 +460,6 @@ * Drains the `batchedUpdates` queue manually.

* Asynchronously fetches all the locales that may be required, and saves them into the
* engine. Uses your provided `Lifecycle.fetchLocale` function.
* engine. Uses your provided `Fetcher.fetchLocale` function.
* @returns {Promise<any>}
*/
fetchAll(): Promise<any>;
fetchLocales(): Promise<any>;
}
let imports = {};
imports['__wbindgen_placeholder__'] = module.exports;
let wasm;
const { TextDecoder } = require(String.raw`util`);
const { WasmResult, CiteprocRsError, CiteprocRsDriverError, CslStyleError } = require(String.raw`./snippets/wasm-1883a0b9dcad429e/src/js/include.js`);
const { TextEncoder, TextDecoder } = require(String.raw`util`);

@@ -12,18 +13,76 @@ const heap = new Array(32).fill(undefined);

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;
let cachegetNodeBufferMemory0 = null;
function getNodeBufferMemory0() {
if (cachegetNodeBufferMemory0 === null || cachegetNodeBufferMemory0.buffer !== wasm.memory.buffer) {
cachegetNodeBufferMemory0 = Buffer.from(wasm.memory.buffer);
let cachegetUint8Memory0 = null;
function getUint8Memory0() {
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
}
return cachegetNodeBufferMemory0;
return cachegetUint8Memory0;
}
function passStringToWasm0(arg, malloc) {
let cachedTextEncoder = new TextEncoder('utf-8');
const len = Buffer.byteLength(arg);
const ptr = malloc(len);
getNodeBufferMemory0().write(arg, ptr, len);
WASM_VECTOR_LEN = len;
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
? function (arg, view) {
return cachedTextEncoder.encodeInto(arg, view);
}
: function (arg, view) {
const buf = cachedTextEncoder.encode(arg);
view.set(buf);
return {
read: arg.length,
written: buf.length
};
});
function passStringToWasm0(arg, malloc, realloc) {
if (realloc === undefined) {
const buf = cachedTextEncoder.encode(arg);
const ptr = malloc(buf.length);
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
WASM_VECTOR_LEN = buf.length;
return ptr;
}
let len = arg.length;
let ptr = malloc(len);
const mem = getUint8Memory0();
let offset = 0;
for (; offset < len; offset++) {
const code = arg.charCodeAt(offset);
if (code > 0x7F) break;
mem[ptr + offset] = code;
}
if (offset !== len) {
if (offset !== 0) {
arg = arg.slice(offset);
}
ptr = realloc(ptr, len, len = offset + arg.length * 3);
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
const ret = encodeString(arg, view);
offset += ret.written;
}
WASM_VECTOR_LEN = offset;
return ptr;

@@ -44,10 +103,2 @@ }

let cachegetUint8Memory0 = null;
function getUint8Memory0() {
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
}
return cachegetUint8Memory0;
}
function getStringFromWasm0(ptr, len) {

@@ -57,4 +108,2 @@ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));

let heap_next = heap.length;
function addHeapObject(obj) {

@@ -69,14 +118,2 @@ if (heap_next === heap.length) heap.push(heap.length + 1);

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,6 +147,18 @@ 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__hd125291c94f17248(arg0, arg1, addHeapObject(arg2));
function __wbg_adapter_24(arg0, arg1, arg2) {
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2b1b33880a98c55e(arg0, arg1, addHeapObject(arg2));
}
/**
* Parses a CSL style, either independent or dependent, and returns its metadata.
* @param {string} style
* @returns {WasmResult<StyleMeta>}
*/
module.exports.parseStyleMetadata = function(style) {
var ptr0 = passStringToWasm0(style, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
var ret = wasm.parseStyleMetadata(ptr0, len0);
return takeObject(ret);
};
let cachegetUint32Memory0 = null;

@@ -143,6 +192,9 @@ function getUint32Memory0() {

}
function __wbg_adapter_64(arg0, arg1, arg2, arg3) {
wasm.wasm_bindgen__convert__closures__invoke2_mut__h48fd5816c723cd64(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
function __wbg_adapter_81(arg0, arg1, arg2, arg3) {
wasm.wasm_bindgen__convert__closures__invoke2_mut__h4915090d68cfd6bd(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
}
function getArrayU8FromWasm0(ptr, len) {
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
}
/**

@@ -159,6 +211,11 @@ */

free() {
__destroy_into_raw() {
const ptr = this.ptr;
this.ptr = 0;
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_driver_free(ptr);

@@ -170,18 +227,12 @@ }

* * `style` is a CSL style as a string. Independent styles only.
* * `lifecycle` must implement the `Lifecycle` interface
* * `fetcher` must implement the `Fetcher` interface
* * `format` is one of { "html", "rtf" }
*
* Throws an error if it cannot parse the style you gave it.
* @param {string} style
* @param {any} lifecycle
* @param {string} format
* @returns {Driver}
* @param {InitOptions} options
* @returns {WasmResult<Driver>}
*/
static new(style, lifecycle, format) {
var ptr0 = passStringToWasm0(style, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
var ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len1 = WASM_VECTOR_LEN;
var ret = wasm.driver_new(ptr0, len0, addHeapObject(lifecycle), ptr1, len1);
return Driver.__wrap(ret);
static new(options) {
var ret = wasm.driver_new(addHeapObject(options));
return takeObject(ret);
}

@@ -191,2 +242,3 @@ /**

* @param {string} style_text
* @returns {WasmResult<undefined>}
*/

@@ -196,3 +248,4 @@ setStyle(style_text) {

var len0 = WASM_VECTOR_LEN;
wasm.driver_setStyle(this.ptr, ptr0, len0);
var ret = wasm.driver_setStyle(this.ptr, ptr0, len0);
return takeObject(ret);
}

@@ -203,2 +256,3 @@ /**

* @param {any[]} refs
* @returns {WasmResult<undefined>}
*/

@@ -208,3 +262,4 @@ resetReferences(refs) {

var len0 = WASM_VECTOR_LEN;
wasm.driver_resetReferences(this.ptr, ptr0, len0);
var ret = wasm.driver_resetReferences(this.ptr, ptr0, len0);
return takeObject(ret);
}

@@ -215,2 +270,3 @@ /**

* @param {any[]} refs
* @returns {WasmResult<undefined>}
*/

@@ -220,3 +276,4 @@ insertReferences(refs) {

var len0 = WASM_VECTOR_LEN;
wasm.driver_insertReferences(this.ptr, ptr0, len0);
var ret = wasm.driver_insertReferences(this.ptr, ptr0, len0);
return takeObject(ret);
}

@@ -228,5 +285,7 @@ /**

* @param {Reference} refr
* @returns {WasmResult<undefined>}
*/
insertReference(refr) {
wasm.driver_insertReference(this.ptr, addHeapObject(refr));
var ret = wasm.driver_insertReference(this.ptr, addHeapObject(refr));
return takeObject(ret);
}

@@ -237,2 +296,3 @@ /**

* @param {string} id
* @returns {WasmResult<undefined>}
*/

@@ -242,3 +302,4 @@ removeReference(id) {

var len0 = WASM_VECTOR_LEN;
wasm.driver_removeReference(this.ptr, ptr0, len0);
var ret = wasm.driver_removeReference(this.ptr, ptr0, len0);
return takeObject(ret);
}

@@ -250,5 +311,7 @@ /**

* @param {IncludeUncited} uncited
* @returns {WasmResult<undefined>}
*/
includeUncited(uncited) {
wasm.driver_includeUncited(this.ptr, addHeapObject(uncited));
var ret = wasm.driver_includeUncited(this.ptr, addHeapObject(uncited));
return takeObject(ret);
}

@@ -259,3 +322,3 @@ /**

* Note that Driver comes pre-loaded with the `en-US` locale.
* @returns {any}
* @returns {WasmResult<string[]>}
*/

@@ -267,14 +330,36 @@ toFetch() {

/**
* Returns a random cluster id, with an extra guarantee that it isn't already in use.
* @returns {string}
*/
randomClusterId() {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.driver_randomClusterId(retptr, this.ptr);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
return getStringFromWasm0(r0, r1);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
wasm.__wbindgen_free(r0, r1);
}
}
/**
* Inserts or replaces a cluster with a matching `id`.
* @param {any} cluster
* @param {Cluster} cluster
* @returns {WasmResult<undefined>}
*/
insertCluster(cluster) {
wasm.driver_insertCluster(this.ptr, addHeapObject(cluster));
var ret = wasm.driver_insertCluster(this.ptr, addHeapObject(cluster));
return takeObject(ret);
}
/**
* Removes a cluster with a matching `id`
* @param {number} cluster_id
* @param {string} cluster_id
* @returns {WasmResult<undefined>}
*/
removeCluster(cluster_id) {
wasm.driver_removeCluster(this.ptr, cluster_id);
var ptr0 = passStringToWasm0(cluster_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
var ret = wasm.driver_removeCluster(this.ptr, ptr0, len0);
return takeObject(ret);
}

@@ -286,2 +371,3 @@ /**

* @param {any[]} clusters
* @returns {WasmResult<undefined>}
*/

@@ -291,3 +377,4 @@ initClusters(clusters) {

var len0 = WASM_VECTOR_LEN;
wasm.driver_initClusters(this.ptr, ptr0, len0);
var ret = wasm.driver_initClusters(this.ptr, ptr0, len0);
return takeObject(ret);
}

@@ -299,7 +386,9 @@ /**

* still useful for initialization.
* @param {number} id
* @returns {any}
* @param {string} id
* @returns {WasmResult<string>}
*/
builtCluster(id) {
var ret = wasm.driver_builtCluster(this.ptr, id);
var ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
var ret = wasm.driver_builtCluster(this.ptr, ptr0, len0);
return takeObject(ret);

@@ -318,3 +407,3 @@ }

* @param {string} format
* @returns {any}
* @returns {WasmResult<string>}
*/

@@ -332,3 +421,3 @@ previewCitationCluster(cites, positions, format) {

/**
* @returns {BibEntries}
* @returns {WasmResult<BibEntries>}
*/

@@ -340,3 +429,3 @@ makeBibliography() {

/**
* @returns {BibliographyMeta}
* @returns {WasmResult<BibliographyMeta>}
*/

@@ -348,29 +437,2 @@ bibliographyMeta() {

/**
* Replaces cluster numberings in one go.
*
* * `mappings` is an `Array<[ ClusterId, ClusterNumber ]>` where `ClusterNumber`
* is, e.g. `{ note: 1 }`, `{ note: [3, 1] }` or `{ inText: 5 }` in the same way a
* Cluster must contain one of those three numberings.
*
* Not every ClusterId must appear in the array, just the ones you wish to renumber.
*
* The library consumer is responsible for ensuring that clusters are well-ordered. Clusters
* are sorted for determining cite positions (ibid, subsequent, etc). If a footnote is
* deleted, you will likely need to shift all cluster numbers after it back by one.
*
* The second note numbering, `{note: [3, 1]}`, is for having multiple clusters in a single
* footnote. This is possible in many editors. The second number acts as a second sorting
* key.
*
* The third note numbering, `{ inText: 5 }`, is for ordering in-text references that appear
* within the body of a document. These will be sorted but won't cause
* `first-reference-note-number` to become available.
* @param {any[]} mappings
*/
renumberClusters(mappings) {
var ptr0 = passArrayJsValueToWasm0(mappings, wasm.__wbindgen_malloc);
var len0 = WASM_VECTOR_LEN;
wasm.driver_renumberClusters(this.ptr, ptr0, len0);
}
/**
* Specifies which clusters are actually considered to be in the document, and sets their

@@ -400,2 +462,3 @@ * order. You may insert as many clusters as you like, but the ones provided here are the only

* @param {any[]} positions
* @returns {WasmResult<undefined>}
*/

@@ -405,3 +468,4 @@ setClusterOrder(positions) {

var len0 = WASM_VECTOR_LEN;
wasm.driver_setClusterOrder(this.ptr, ptr0, len0);
var ret = wasm.driver_setClusterOrder(this.ptr, ptr0, len0);
return takeObject(ret);
}

@@ -416,3 +480,3 @@ /**

* * returns an `UpdateSummary`
* @returns {UpdateSummary}
* @returns {WasmResult<UpdateSummary>}
*/

@@ -427,3 +491,3 @@ batchedUpdates() {

* Use this to rehydrate a document or run non-interactively.
* @returns {FullRender}
* @returns {WasmResult<FullRender>}
*/

@@ -442,7 +506,7 @@ fullRender() {

* Asynchronously fetches all the locales that may be required, and saves them into the
* engine. Uses your provided `Lifecycle.fetchLocale` function.
* engine. Uses your provided `Fetcher.fetchLocale` function.
* @returns {Promise<any>}
*/
fetchAll() {
var ret = wasm.driver_fetchAll(this.ptr);
fetchLocales() {
var ret = wasm.driver_fetchLocales(this.ptr);
return takeObject(ret);

@@ -453,16 +517,2 @@ }

module.exports.__wbindgen_json_serialize = function(arg0, arg1) {
const obj = getObject(arg1);
var ret = JSON.stringify(obj === undefined ? null : obj);
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.__wbindgen_json_parse = function(arg0, arg1) {
var ret = JSON.parse(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
};
module.exports.__wbindgen_object_drop_ref = function(arg0) {

@@ -472,5 +522,4 @@ takeObject(arg0);

module.exports.__wbg_fetchLocale_8f52b973b0739a6c = function(arg0, arg1, arg2) {
var ret = getObject(arg0).fetchLocale(getStringFromWasm0(arg1, arg2));
return addHeapObject(ret);
module.exports.__wbg_error_e549f7fed6d655aa = function(arg0) {
console.error(takeObject(arg0));
};

@@ -498,9 +547,14 @@

module.exports.__wbindgen_object_clone_ref = function(arg0) {
var ret = getObject(arg0);
return addHeapObject(ret);
module.exports.__wbindgen_json_serialize = function(arg0, arg1) {
const obj = getObject(arg1);
var ret = JSON.stringify(obj === undefined ? null : obj);
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_e549f7fed6d655aa = function(arg0) {
console.error(takeObject(arg0));
module.exports.__wbindgen_string_new = function(arg0, arg1) {
var ret = getStringFromWasm0(arg0, arg1);
return addHeapObject(ret);
};

@@ -518,2 +572,63 @@

module.exports.__wbindgen_json_parse = function(arg0, arg1) {
var ret = JSON.parse(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
};
module.exports.__wbg_driver_new = function(arg0) {
var ret = Driver.__wrap(arg0);
return addHeapObject(ret);
};
module.exports.__wbg_new_f12987d5c30f0ab7 = function(arg0) {
var ret = new CiteprocRsError(takeObject(arg0));
return addHeapObject(ret);
};
module.exports.__wbg_new_c5e56e6577bc2b6a = function(arg0, arg1) {
var ret = new CslStyleError(takeObject(arg0), takeObject(arg1));
return addHeapObject(ret);
};
module.exports.__wbg_new_6edca5ab9ee61764 = function(arg0) {
var ret = new WasmResult(takeObject(arg0));
return addHeapObject(ret);
};
module.exports.__wbg_get_1edc26456ed84f9b = function(arg0, arg1) {
var ret = getObject(arg0)[takeObject(arg1)];
return addHeapObject(ret);
};
module.exports.__wbg_new_8d5f3cd64eaaa8b5 = function(arg0, arg1) {
var ret = new CiteprocRsDriverError(takeObject(arg0), takeObject(arg1));
return addHeapObject(ret);
};
module.exports.__wbindgen_object_clone_ref = function(arg0) {
var ret = getObject(arg0);
return addHeapObject(ret);
};
module.exports.__wbindgen_is_undefined = function(arg0) {
var ret = getObject(arg0) === undefined;
return ret;
};
module.exports.__wbindgen_is_object = function(arg0) {
const val = getObject(arg0);
var ret = typeof(val) === 'object' && val !== null;
return ret;
};
module.exports.__wbindgen_is_function = function(arg0) {
var ret = typeof(getObject(arg0)) === 'function';
return ret;
};
module.exports.__wbg_fetchLocale_d644d4ae2ca50f81 = function(arg0, arg1, arg2) {
var ret = getObject(arg0).fetchLocale(getStringFromWasm0(arg1, arg2));
return addHeapObject(ret);
};
module.exports.__wbg_new_59cb74e423758ede = function() {

@@ -540,8 +655,3 @@ var ret = new Error();

module.exports.__wbg_new_1192d65414040ad9 = function(arg0, arg1) {
var ret = new Error(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
};
module.exports.__wbg_call_d713ea0274dfc6d2 = handleError(function(arg0, arg1, arg2) {
module.exports.__wbg_call_f5e0576f61ee7461 = handleError(function(arg0, arg1, arg2) {
var ret = getObject(arg0).call(getObject(arg1), getObject(arg2));

@@ -551,3 +661,3 @@ return addHeapObject(ret);

module.exports.__wbg_new_d0c63652ab4d825c = function(arg0, arg1) {
module.exports.__wbg_new_3ea8490cd276c848 = function(arg0, arg1) {
try {

@@ -559,3 +669,3 @@ var state0 = {a: arg0, b: arg1};

try {
return __wbg_adapter_64(a, state0.b, arg0, arg1);
return __wbg_adapter_81(a, state0.b, arg0, arg1);
} finally {

@@ -572,3 +682,3 @@ state0.a = a;

module.exports.__wbg_resolve_2529512c3bb73938 = function(arg0) {
module.exports.__wbg_resolve_778af3f90b8e2b59 = function(arg0) {
var ret = Promise.resolve(getObject(arg0));

@@ -578,3 +688,3 @@ return addHeapObject(ret);

module.exports.__wbg_then_4a7a614abbbe6d81 = function(arg0, arg1) {
module.exports.__wbg_then_367b3e718069cfb9 = function(arg0, arg1) {
var ret = getObject(arg0).then(getObject(arg1));

@@ -584,3 +694,3 @@ return addHeapObject(ret);

module.exports.__wbg_then_3b7ac098cfda2fa5 = function(arg0, arg1, arg2) {
module.exports.__wbg_then_ac66ca61394bfd21 = function(arg0, arg1, arg2) {
var ret = getObject(arg0).then(getObject(arg1), getObject(arg2));

@@ -590,2 +700,40 @@ return addHeapObject(ret);

module.exports.__wbg_self_1c83eb4471d9eb9b = handleError(function() {
var ret = self.self;
return addHeapObject(ret);
});
module.exports.__wbg_static_accessor_MODULE_abf5ae284bffdf45 = function() {
var ret = module;
return addHeapObject(ret);
};
module.exports.__wbg_require_5b2b5b594d809d9f = function(arg0, arg1, arg2) {
var ret = getObject(arg0).require(getStringFromWasm0(arg1, arg2));
return addHeapObject(ret);
};
module.exports.__wbg_crypto_c12f14e810edcaa2 = function(arg0) {
var ret = getObject(arg0).crypto;
return addHeapObject(ret);
};
module.exports.__wbg_msCrypto_679be765111ba775 = function(arg0) {
var ret = getObject(arg0).msCrypto;
return addHeapObject(ret);
};
module.exports.__wbg_getRandomValues_05a60bf171bfc2be = function(arg0) {
var ret = getObject(arg0).getRandomValues;
return addHeapObject(ret);
};
module.exports.__wbg_getRandomValues_3ac1b33c90b52596 = function(arg0, arg1, arg2) {
getObject(arg0).getRandomValues(getArrayU8FromWasm0(arg1, arg2));
};
module.exports.__wbg_randomFillSync_6f956029658662ec = function(arg0, arg1, arg2) {
getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
};
module.exports.__wbindgen_string_get = function(arg0, arg1) {

@@ -604,8 +752,4 @@ const obj = getObject(arg1);

module.exports.__wbindgen_rethrow = function(arg0) {
throw takeObject(arg0);
};
module.exports.__wbindgen_closure_wrapper836 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 195, __wbg_adapter_18);
module.exports.__wbindgen_closure_wrapper952 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 227, __wbg_adapter_24);
return addHeapObject(ret);

@@ -612,0 +756,0 @@ };

@@ -0,1 +1,2 @@

import { WasmResult, CiteprocRsError, CiteprocRsDriverError, CslStyleError } from './snippets/wasm-1883a0b9dcad429e/src/js/include.js';
import * as wasm from './citeproc_rs_wasm_bg.wasm';

@@ -9,2 +10,16 @@

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;

@@ -93,4 +108,2 @@

let heap_next = heap.length;
function addHeapObject(obj) {

@@ -105,14 +118,2 @@ if (heap_next === heap.length) heap.push(heap.length + 1);

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) {

@@ -146,6 +147,18 @@ 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__hd125291c94f17248(arg0, arg1, addHeapObject(arg2));
function __wbg_adapter_24(arg0, arg1, arg2) {
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2b1b33880a98c55e(arg0, arg1, addHeapObject(arg2));
}
/**
* Parses a CSL style, either independent or dependent, and returns its metadata.
* @param {string} style
* @returns {WasmResult<StyleMeta>}
*/
export function parseStyleMetadata(style) {
var ptr0 = passStringToWasm0(style, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
var ret = wasm.parseStyleMetadata(ptr0, len0);
return takeObject(ret);
}
let cachegetUint32Memory0 = null;

@@ -179,6 +192,9 @@ function getUint32Memory0() {

}
function __wbg_adapter_64(arg0, arg1, arg2, arg3) {
wasm.wasm_bindgen__convert__closures__invoke2_mut__h48fd5816c723cd64(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
function __wbg_adapter_81(arg0, arg1, arg2, arg3) {
wasm.wasm_bindgen__convert__closures__invoke2_mut__h4915090d68cfd6bd(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
}
function getArrayU8FromWasm0(ptr, len) {
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
}
/**

@@ -195,6 +211,11 @@ */

free() {
__destroy_into_raw() {
const ptr = this.ptr;
this.ptr = 0;
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_driver_free(ptr);

@@ -206,18 +227,12 @@ }

* * `style` is a CSL style as a string. Independent styles only.
* * `lifecycle` must implement the `Lifecycle` interface
* * `fetcher` must implement the `Fetcher` interface
* * `format` is one of { "html", "rtf" }
*
* Throws an error if it cannot parse the style you gave it.
* @param {string} style
* @param {any} lifecycle
* @param {string} format
* @returns {Driver}
* @param {InitOptions} options
* @returns {WasmResult<Driver>}
*/
static new(style, lifecycle, format) {
var ptr0 = passStringToWasm0(style, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
var ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len1 = WASM_VECTOR_LEN;
var ret = wasm.driver_new(ptr0, len0, addHeapObject(lifecycle), ptr1, len1);
return Driver.__wrap(ret);
static new(options) {
var ret = wasm.driver_new(addHeapObject(options));
return takeObject(ret);
}

@@ -227,2 +242,3 @@ /**

* @param {string} style_text
* @returns {WasmResult<undefined>}
*/

@@ -232,3 +248,4 @@ setStyle(style_text) {

var len0 = WASM_VECTOR_LEN;
wasm.driver_setStyle(this.ptr, ptr0, len0);
var ret = wasm.driver_setStyle(this.ptr, ptr0, len0);
return takeObject(ret);
}

@@ -239,2 +256,3 @@ /**

* @param {any[]} refs
* @returns {WasmResult<undefined>}
*/

@@ -244,3 +262,4 @@ resetReferences(refs) {

var len0 = WASM_VECTOR_LEN;
wasm.driver_resetReferences(this.ptr, ptr0, len0);
var ret = wasm.driver_resetReferences(this.ptr, ptr0, len0);
return takeObject(ret);
}

@@ -251,2 +270,3 @@ /**

* @param {any[]} refs
* @returns {WasmResult<undefined>}
*/

@@ -256,3 +276,4 @@ insertReferences(refs) {

var len0 = WASM_VECTOR_LEN;
wasm.driver_insertReferences(this.ptr, ptr0, len0);
var ret = wasm.driver_insertReferences(this.ptr, ptr0, len0);
return takeObject(ret);
}

@@ -264,5 +285,7 @@ /**

* @param {Reference} refr
* @returns {WasmResult<undefined>}
*/
insertReference(refr) {
wasm.driver_insertReference(this.ptr, addHeapObject(refr));
var ret = wasm.driver_insertReference(this.ptr, addHeapObject(refr));
return takeObject(ret);
}

@@ -273,2 +296,3 @@ /**

* @param {string} id
* @returns {WasmResult<undefined>}
*/

@@ -278,3 +302,4 @@ removeReference(id) {

var len0 = WASM_VECTOR_LEN;
wasm.driver_removeReference(this.ptr, ptr0, len0);
var ret = wasm.driver_removeReference(this.ptr, ptr0, len0);
return takeObject(ret);
}

@@ -286,5 +311,7 @@ /**

* @param {IncludeUncited} uncited
* @returns {WasmResult<undefined>}
*/
includeUncited(uncited) {
wasm.driver_includeUncited(this.ptr, addHeapObject(uncited));
var ret = wasm.driver_includeUncited(this.ptr, addHeapObject(uncited));
return takeObject(ret);
}

@@ -295,3 +322,3 @@ /**

* Note that Driver comes pre-loaded with the `en-US` locale.
* @returns {any}
* @returns {WasmResult<string[]>}
*/

@@ -303,14 +330,36 @@ toFetch() {

/**
* Returns a random cluster id, with an extra guarantee that it isn't already in use.
* @returns {string}
*/
randomClusterId() {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.driver_randomClusterId(retptr, this.ptr);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
return getStringFromWasm0(r0, r1);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
wasm.__wbindgen_free(r0, r1);
}
}
/**
* Inserts or replaces a cluster with a matching `id`.
* @param {any} cluster
* @param {Cluster} cluster
* @returns {WasmResult<undefined>}
*/
insertCluster(cluster) {
wasm.driver_insertCluster(this.ptr, addHeapObject(cluster));
var ret = wasm.driver_insertCluster(this.ptr, addHeapObject(cluster));
return takeObject(ret);
}
/**
* Removes a cluster with a matching `id`
* @param {number} cluster_id
* @param {string} cluster_id
* @returns {WasmResult<undefined>}
*/
removeCluster(cluster_id) {
wasm.driver_removeCluster(this.ptr, cluster_id);
var ptr0 = passStringToWasm0(cluster_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
var ret = wasm.driver_removeCluster(this.ptr, ptr0, len0);
return takeObject(ret);
}

@@ -322,2 +371,3 @@ /**

* @param {any[]} clusters
* @returns {WasmResult<undefined>}
*/

@@ -327,3 +377,4 @@ initClusters(clusters) {

var len0 = WASM_VECTOR_LEN;
wasm.driver_initClusters(this.ptr, ptr0, len0);
var ret = wasm.driver_initClusters(this.ptr, ptr0, len0);
return takeObject(ret);
}

@@ -335,7 +386,9 @@ /**

* still useful for initialization.
* @param {number} id
* @returns {any}
* @param {string} id
* @returns {WasmResult<string>}
*/
builtCluster(id) {
var ret = wasm.driver_builtCluster(this.ptr, id);
var ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
var ret = wasm.driver_builtCluster(this.ptr, ptr0, len0);
return takeObject(ret);

@@ -354,3 +407,3 @@ }

* @param {string} format
* @returns {any}
* @returns {WasmResult<string>}
*/

@@ -368,3 +421,3 @@ previewCitationCluster(cites, positions, format) {

/**
* @returns {BibEntries}
* @returns {WasmResult<BibEntries>}
*/

@@ -376,3 +429,3 @@ makeBibliography() {

/**
* @returns {BibliographyMeta}
* @returns {WasmResult<BibliographyMeta>}
*/

@@ -384,29 +437,2 @@ bibliographyMeta() {

/**
* Replaces cluster numberings in one go.
*
* * `mappings` is an `Array<[ ClusterId, ClusterNumber ]>` where `ClusterNumber`
* is, e.g. `{ note: 1 }`, `{ note: [3, 1] }` or `{ inText: 5 }` in the same way a
* Cluster must contain one of those three numberings.
*
* Not every ClusterId must appear in the array, just the ones you wish to renumber.
*
* The library consumer is responsible for ensuring that clusters are well-ordered. Clusters
* are sorted for determining cite positions (ibid, subsequent, etc). If a footnote is
* deleted, you will likely need to shift all cluster numbers after it back by one.
*
* The second note numbering, `{note: [3, 1]}`, is for having multiple clusters in a single
* footnote. This is possible in many editors. The second number acts as a second sorting
* key.
*
* The third note numbering, `{ inText: 5 }`, is for ordering in-text references that appear
* within the body of a document. These will be sorted but won't cause
* `first-reference-note-number` to become available.
* @param {any[]} mappings
*/
renumberClusters(mappings) {
var ptr0 = passArrayJsValueToWasm0(mappings, wasm.__wbindgen_malloc);
var len0 = WASM_VECTOR_LEN;
wasm.driver_renumberClusters(this.ptr, ptr0, len0);
}
/**
* Specifies which clusters are actually considered to be in the document, and sets their

@@ -436,2 +462,3 @@ * order. You may insert as many clusters as you like, but the ones provided here are the only

* @param {any[]} positions
* @returns {WasmResult<undefined>}
*/

@@ -441,3 +468,4 @@ setClusterOrder(positions) {

var len0 = WASM_VECTOR_LEN;
wasm.driver_setClusterOrder(this.ptr, ptr0, len0);
var ret = wasm.driver_setClusterOrder(this.ptr, ptr0, len0);
return takeObject(ret);
}

@@ -452,3 +480,3 @@ /**

* * returns an `UpdateSummary`
* @returns {UpdateSummary}
* @returns {WasmResult<UpdateSummary>}
*/

@@ -463,3 +491,3 @@ batchedUpdates() {

* Use this to rehydrate a document or run non-interactively.
* @returns {FullRender}
* @returns {WasmResult<FullRender>}
*/

@@ -478,7 +506,7 @@ fullRender() {

* Asynchronously fetches all the locales that may be required, and saves them into the
* engine. Uses your provided `Lifecycle.fetchLocale` function.
* engine. Uses your provided `Fetcher.fetchLocale` function.
* @returns {Promise<any>}
*/
fetchAll() {
var ret = wasm.driver_fetchAll(this.ptr);
fetchLocales() {
var ret = wasm.driver_fetchLocales(this.ptr);
return takeObject(ret);

@@ -488,16 +516,2 @@ }

export const __wbindgen_json_serialize = function(arg0, arg1) {
const obj = getObject(arg1);
var ret = JSON.stringify(obj === undefined ? null : obj);
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 __wbindgen_json_parse = function(arg0, arg1) {
var ret = JSON.parse(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
};
export const __wbindgen_object_drop_ref = function(arg0) {

@@ -507,5 +521,4 @@ takeObject(arg0);

export const __wbg_fetchLocale_8f52b973b0739a6c = function(arg0, arg1, arg2) {
var ret = getObject(arg0).fetchLocale(getStringFromWasm0(arg1, arg2));
return addHeapObject(ret);
export const __wbg_error_e549f7fed6d655aa = function(arg0) {
console.error(takeObject(arg0));
};

@@ -533,9 +546,14 @@

export const __wbindgen_object_clone_ref = function(arg0) {
var ret = getObject(arg0);
return addHeapObject(ret);
export const __wbindgen_json_serialize = function(arg0, arg1) {
const obj = getObject(arg1);
var ret = JSON.stringify(obj === undefined ? null : obj);
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_e549f7fed6d655aa = function(arg0) {
console.error(takeObject(arg0));
export const __wbindgen_string_new = function(arg0, arg1) {
var ret = getStringFromWasm0(arg0, arg1);
return addHeapObject(ret);
};

@@ -553,2 +571,63 @@

export const __wbindgen_json_parse = function(arg0, arg1) {
var ret = JSON.parse(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
};
export const __wbg_driver_new = function(arg0) {
var ret = Driver.__wrap(arg0);
return addHeapObject(ret);
};
export const __wbg_new_f12987d5c30f0ab7 = function(arg0) {
var ret = new CiteprocRsError(takeObject(arg0));
return addHeapObject(ret);
};
export const __wbg_new_c5e56e6577bc2b6a = function(arg0, arg1) {
var ret = new CslStyleError(takeObject(arg0), takeObject(arg1));
return addHeapObject(ret);
};
export const __wbg_new_6edca5ab9ee61764 = function(arg0) {
var ret = new WasmResult(takeObject(arg0));
return addHeapObject(ret);
};
export const __wbg_get_1edc26456ed84f9b = function(arg0, arg1) {
var ret = getObject(arg0)[takeObject(arg1)];
return addHeapObject(ret);
};
export const __wbg_new_8d5f3cd64eaaa8b5 = function(arg0, arg1) {
var ret = new CiteprocRsDriverError(takeObject(arg0), takeObject(arg1));
return addHeapObject(ret);
};
export const __wbindgen_object_clone_ref = function(arg0) {
var ret = getObject(arg0);
return addHeapObject(ret);
};
export const __wbindgen_is_undefined = function(arg0) {
var ret = getObject(arg0) === undefined;
return ret;
};
export const __wbindgen_is_object = function(arg0) {
const val = getObject(arg0);
var ret = typeof(val) === 'object' && val !== null;
return ret;
};
export const __wbindgen_is_function = function(arg0) {
var ret = typeof(getObject(arg0)) === 'function';
return ret;
};
export const __wbg_fetchLocale_d644d4ae2ca50f81 = function(arg0, arg1, arg2) {
var ret = getObject(arg0).fetchLocale(getStringFromWasm0(arg1, arg2));
return addHeapObject(ret);
};
export const __wbg_new_59cb74e423758ede = function() {

@@ -575,8 +654,3 @@ var ret = new Error();

export const __wbg_new_1192d65414040ad9 = function(arg0, arg1) {
var ret = new Error(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
};
export const __wbg_call_d713ea0274dfc6d2 = handleError(function(arg0, arg1, arg2) {
export const __wbg_call_f5e0576f61ee7461 = handleError(function(arg0, arg1, arg2) {
var ret = getObject(arg0).call(getObject(arg1), getObject(arg2));

@@ -586,3 +660,3 @@ return addHeapObject(ret);

export const __wbg_new_d0c63652ab4d825c = function(arg0, arg1) {
export const __wbg_new_3ea8490cd276c848 = function(arg0, arg1) {
try {

@@ -594,3 +668,3 @@ var state0 = {a: arg0, b: arg1};

try {
return __wbg_adapter_64(a, state0.b, arg0, arg1);
return __wbg_adapter_81(a, state0.b, arg0, arg1);
} finally {

@@ -607,3 +681,3 @@ state0.a = a;

export const __wbg_resolve_2529512c3bb73938 = function(arg0) {
export const __wbg_resolve_778af3f90b8e2b59 = function(arg0) {
var ret = Promise.resolve(getObject(arg0));

@@ -613,3 +687,3 @@ return addHeapObject(ret);

export const __wbg_then_4a7a614abbbe6d81 = function(arg0, arg1) {
export const __wbg_then_367b3e718069cfb9 = function(arg0, arg1) {
var ret = getObject(arg0).then(getObject(arg1));

@@ -619,3 +693,3 @@ return addHeapObject(ret);

export const __wbg_then_3b7ac098cfda2fa5 = function(arg0, arg1, arg2) {
export const __wbg_then_ac66ca61394bfd21 = function(arg0, arg1, arg2) {
var ret = getObject(arg0).then(getObject(arg1), getObject(arg2));

@@ -625,2 +699,40 @@ return addHeapObject(ret);

export const __wbg_self_1c83eb4471d9eb9b = handleError(function() {
var ret = self.self;
return addHeapObject(ret);
});
export const __wbg_static_accessor_MODULE_abf5ae284bffdf45 = function() {
var ret = module;
return addHeapObject(ret);
};
export const __wbg_require_5b2b5b594d809d9f = function(arg0, arg1, arg2) {
var ret = getObject(arg0).require(getStringFromWasm0(arg1, arg2));
return addHeapObject(ret);
};
export const __wbg_crypto_c12f14e810edcaa2 = function(arg0) {
var ret = getObject(arg0).crypto;
return addHeapObject(ret);
};
export const __wbg_msCrypto_679be765111ba775 = function(arg0) {
var ret = getObject(arg0).msCrypto;
return addHeapObject(ret);
};
export const __wbg_getRandomValues_05a60bf171bfc2be = function(arg0) {
var ret = getObject(arg0).getRandomValues;
return addHeapObject(ret);
};
export const __wbg_getRandomValues_3ac1b33c90b52596 = function(arg0, arg1, arg2) {
getObject(arg0).getRandomValues(getArrayU8FromWasm0(arg1, arg2));
};
export const __wbg_randomFillSync_6f956029658662ec = function(arg0, arg1, arg2) {
getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
};
export const __wbindgen_string_get = function(arg0, arg1) {

@@ -639,10 +751,6 @@ const obj = getObject(arg1);

export const __wbindgen_rethrow = function(arg0) {
throw takeObject(arg0);
};
export const __wbindgen_closure_wrapper836 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 195, __wbg_adapter_18);
export const __wbindgen_closure_wrapper952 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 227, __wbg_adapter_24);
return addHeapObject(ret);
};
/* tslint:disable */
/* eslint-disable */
export const memory: WebAssembly.Memory;
export function parseStyleMetadata(a: number, b: number): number;
export function __wbg_driver_free(a: number): void;
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): 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_new(a: number): number;
export function driver_setStyle(a: number, b: number, c: number): number;
export function driver_resetReferences(a: number, b: number, c: number): number;
export function driver_insertReferences(a: number, b: number, c: number): number;
export function driver_insertReference(a: number, b: number): number;
export function driver_removeReference(a: number, b: number, c: number): number;
export function driver_includeUncited(a: number, b: number): number;
export function driver_toFetch(a: number): number;
export function driver_insertCluster(a: number, b: number): void;
export function driver_removeCluster(a: number, b: number): void;
export function driver_initClusters(a: number, b: number, c: number): void;
export function driver_builtCluster(a: number, b: number): number;
export function driver_randomClusterId(a: number, b: number): void;
export function driver_insertCluster(a: number, b: number): number;
export function driver_removeCluster(a: number, b: number, c: number): number;
export function driver_initClusters(a: number, b: number, c: number): number;
export function driver_builtCluster(a: number, b: number, c: 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;
export function driver_bibliographyMeta(a: number): number;
export function driver_renumberClusters(a: number, b: number, c: number): void;
export function driver_setClusterOrder(a: number, b: number, c: number): void;
export function driver_setClusterOrder(a: number, b: number, c: number): number;
export function driver_batchedUpdates(a: number): number;
export function driver_fullRender(a: number): number;
export function driver_drain(a: number): void;
export function driver_fetchAll(a: number): number;
export function driver_fetchLocales(a: number): number;
export function __wbindgen_malloc(a: number): number;
export function __wbindgen_realloc(a: number, b: number, c: 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__hd125291c94f17248(a: number, b: number, c: number): void;
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2b1b33880a98c55e(a: number, b: number, c: number): void;
export function __wbindgen_add_to_stack_pointer(a: number): number;
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__h48fd5816c723cd64(a: number, b: number, c: number, d: number): void;
export function wasm_bindgen__convert__closures__invoke2_mut__h4915090d68cfd6bd(a: number, b: number, c: number, d: number): void;
/* tslint:disable */
/* eslint-disable */
/**
* Parses a CSL style, either independent or dependent, and returns its metadata.
* @param {string} style
* @returns {WasmResult<StyleMeta>}
*/
export function parseStyleMetadata(style: string): WasmResult<StyleMeta>;
interface InitOptions {
/** A CSL style as an XML string */
style: string,
/** A Fetcher implementation for fetching locales.
*
* If not provided, then no locales can be fetched, and default-locale and localeOverride will
* not be respected; the only locale used will be the bundled en-US. */
fetcher?: Fetcher,
/** The output format for this driver instance */
format: "html" | "rtf" | "plain",
/** A locale to use instead of the style's default-locale.
*
* For dependent styles, use parseStyleMetadata to find out which locale it prefers, and pass
* in the parent style with a localeOverride set to that value.
*/
localeOverride?: string,
/** Disables sorting in the bibliography; items appear in cited order. */
bibliographyNoSort?: bool,
}
/** This interface lets citeproc retrieve locales or modules asynchronously,
according to which ones are needed. */
export interface Lifecycle {
export interface Fetcher {
/** Return locale XML for a particular locale. */

@@ -12,2 +41,4 @@ fetchLocale(lang: string): Promise<string>;

export type DateLiteral = { "literal": string; };

@@ -21,2 +52,4 @@ export type DateRaw = { "raw": string; };

/** Locator type, and a locator string */

@@ -29,24 +62,28 @@ export type Locator = {

export type CiteLocator = Locator | { locator: undefined; locators: Locator[] };
export type CiteLocator = Locator | { locator: undefined; locators: Locator[]; };
export type CiteMode = { mode?: "SuppressAuthor" | "AuthorOnly"; };
export type Cite<Affix = string> = {
export type Cite = {
id: string;
prefix?: Affix;
suffix?: Affix;
suppression?: "InText" | "Rest" | null;
} & Partial<CiteLocator>;
prefix?: string;
suffix?: string;
} & Partial<CiteLocator> & CiteMode;
export type ClusterNumber = {
note: number | [number, number]
} | {
inText: number
};
export type ClusterMode
= { mode: "Composite"; infix?: string; suppressFirst?: number; }
| { mode: "SuppressAuthor"; suppressFirst?: number; }
| { mode: "AuthorOnly"; }
| {};
export type Cluster = {
id: number;
id: string;
cites: Cite[];
};
} & ClusterMode;
export type PreviewCluster {
cites: Cite[];
} & ClusterMode;
export type ClusterPosition = {
id: number;
id: string;
/** Leaving off this field means this cluster is in-text. */

@@ -56,2 +93,4 @@ note?: number;

export type Reference = {

@@ -63,6 +102,8 @@ id: string;

export type CslType = "book" | "article" | "legal_case" | "article-journal";
export type CslType = "book" | "article" | "legal_case" | "article-journal" | string;
export interface BibliographyUpdate {
updatedEntries: { [key: string]: string };
updatedEntries: Map<string, string>;
entryIds?: string[];

@@ -72,23 +113,6 @@ }

export type UpdateSummary<Output = string> = {
clusters: [number, Output][];
clusters: [string, Output][];
bibliography?: BibliographyUpdate;
};
type InvalidCsl = {
severity: "Error" | "Warning";
range: {
start: number;
end: number;
};
message: string;
hint: string;
};
type ParseError = {
ParseError: string;
};
type Invalid = {
Invalid: InvalidCsl[];
};
type StyleError = Partial<ParseError & Invalid>;
type IncludeUncited = "None" | "All" | { Specific: string[] };

@@ -104,3 +128,3 @@

type FullRender = {
allClusters: { [clusterId: string]: string },
allClusters: Map<string, string>,
bibEntries: BibEntries,

@@ -110,6 +134,6 @@ };

type BibliographyMeta = {
max_offset: number;
entry_spacing: number;
line_spacing: number;
hanging_indent: boolean;
maxOffset: number;
entrySpacing: number;
lineSpacing: number;
hangingIndent: boolean;
/** the second-field-align value of the CSL style */

@@ -122,2 +146,128 @@ secondFieldAlign: null | "flush" | "margin";

type Severity = "Error" | "Warning";
interface InvalidCsl {
severity: Severity;
/** Relevant bytes in the provided XML */
range: {
start: number,
end: number,
};
message: string;
hint: string | undefined;
};
type StyleError = {
tag: "Invalid",
content: InvalidCsl[],
} | {
tag: "ParseError",
content: string,
} | {
/** Cannot use a dependent style to format citations, pass the parent style instead. */
tag: "DependentStyle",
content: {
requiredParent: string,
}
};
type DriverError = {
tag: "UnknownOutputFormat",
content: string,
} | {
tag: "JsonError",
} | {
tag: "GetFetcherError",
} | {
tag: "NonExistentCluster",
content: string,
} | {
tag: "ReorderingError"
} | {
tag: "ReorderingErrorNumericId"
};
declare global {
/** Catch-all citeproc-rs Error subclass. */
declare class CiteprocRsError extends Error {
constructor(message: string);
}
declare class CiteprocRsDriverError extends CiteprocRsError {
data: DriverError;
constructor(message: string, data: DriverError);
}
declare class CslStyleError extends CiteprocRsError {
data: StyleError;
constructor(message: string, data: StyleError);
}
}
interface WasmResult<T> {
/** If this is an error, throws the error. */
unwrap(): T;
/** If this is an error, returns it, else throws. */
unwrap_err(): Error;
is_ok(): boolean;
is_err(): boolean;
/** If this is an error, returns the default value. */
unwrap_or(default: T): T;
/** If this is Ok, returns f(ok_val), else returns Err unmodified. */
map<R>(f: (t: T) => R): WasmResult<T>;
/** If this is Ok, returns f(ok_val), else returns the default value. */
map_or<R>(default: R, f: (t: T) => R): R;
}
type CitationFormat = "author-date" | "author" | "numeric" | "label" | "note";
interface LocalizedString {
value: string,
lang?: string,
}
interface ParentLink {
href: string,
lang?: string,
}
interface Link {
href: string,
rel: "self" | "documentation" | "template",
lang?: string,
}
interface Rights {
value: string,
lang?: string,
license?: string,
}
interface StyleInfo {
id: string,
updated: string,
title: LocalizedString,
titleShort?: LocalizedString,
parent?: ParentLink,
links: Link[],
rights?: Rights,
citationFormat?: CitationFormat,
categories: string[],
issn?: string,
eissn?: string,
issnl?: string,
}
interface IndependentMeta {
/** A list of languages for which a locale override was specified.
* Does not include the language-less final override. */
localeOverrides: string[],
hasBibliography: bool,
}
interface StyleMeta {
info: StyleInfo,
features: { [feature: string]: bool },
defaultLocale: string,
/** May be absent on a dependent style */
class?: "in-text" | "note",
cslVersionRequired: string,
/** May be absent on a dependent style */
independentMeta?: IndependentMeta,
};
/**

@@ -131,17 +281,16 @@ */

* * `style` is a CSL style as a string. Independent styles only.
* * `lifecycle` must implement the `Lifecycle` interface
* * `fetcher` must implement the `Fetcher` interface
* * `format` is one of { "html", "rtf" }
*
* Throws an error if it cannot parse the style you gave it.
* @param {string} style
* @param {any} lifecycle
* @param {string} format
* @returns {Driver}
* @param {InitOptions} options
* @returns {WasmResult<Driver>}
*/
static new(style: string, lifecycle: any, format: string): Driver;
static new(options: InitOptions): WasmResult<Driver>;
/**
* Sets the style (which will also cause everything to be recomputed)
* @param {string} style_text
* @returns {WasmResult<undefined>}
*/
setStyle(style_text: string): void;
setStyle(style_text: string): WasmResult<undefined>;
/**

@@ -151,4 +300,5 @@ * Completely overwrites the references library.

* @param {any[]} refs
* @returns {WasmResult<undefined>}
*/
resetReferences(refs: any[]): void;
resetReferences(refs: any[]): WasmResult<undefined>;
/**

@@ -158,4 +308,5 @@ * Inserts or overwrites references as a batch operation.

* @param {any[]} refs
* @returns {WasmResult<undefined>}
*/
insertReferences(refs: any[]): void;
insertReferences(refs: any[]): WasmResult<undefined>;
/**

@@ -166,4 +317,5 @@ * Inserts or overwrites a reference.

* @param {Reference} refr
* @returns {WasmResult<undefined>}
*/
insertReference(refr: Reference): void;
insertReference(refr: Reference): WasmResult<undefined>;
/**

@@ -173,4 +325,5 @@ * Removes a reference by id. If it is cited, any cites will be dangling. It will also

* @param {string} id
* @returns {WasmResult<undefined>}
*/
removeReference(id: string): void;
removeReference(id: string): WasmResult<undefined>;
/**

@@ -181,4 +334,5 @@ * Sets the references to be included in the bibliography despite not being directly cited.

* @param {IncludeUncited} uncited
* @returns {WasmResult<undefined>}
*/
includeUncited(uncited: IncludeUncited): void;
includeUncited(uncited: IncludeUncited): WasmResult<undefined>;
/**

@@ -188,15 +342,22 @@ * Gets a list of locales in use by the references currently loaded.

* Note that Driver comes pre-loaded with the `en-US` locale.
* @returns {any}
* @returns {WasmResult<string[]>}
*/
toFetch(): any;
toFetch(): WasmResult<string[]>;
/**
* Returns a random cluster id, with an extra guarantee that it isn't already in use.
* @returns {string}
*/
randomClusterId(): string;
/**
* Inserts or replaces a cluster with a matching `id`.
* @param {any} cluster
* @param {Cluster} cluster
* @returns {WasmResult<undefined>}
*/
insertCluster(cluster: any): void;
insertCluster(cluster: Cluster): WasmResult<undefined>;
/**
* Removes a cluster with a matching `id`
* @param {number} cluster_id
* @param {string} cluster_id
* @returns {WasmResult<undefined>}
*/
removeCluster(cluster_id: number): void;
removeCluster(cluster_id: string): WasmResult<undefined>;
/**

@@ -207,4 +368,5 @@ * Resets all the clusters in the processor to a new list.

* @param {any[]} clusters
* @returns {WasmResult<undefined>}
*/
initClusters(clusters: any[]): void;
initClusters(clusters: any[]): WasmResult<undefined>;
/**

@@ -215,6 +377,6 @@ * Returns the formatted citation cluster for `cluster_id`.

* still useful for initialization.
* @param {number} id
* @returns {any}
* @param {string} id
* @returns {WasmResult<string>}
*/
builtCluster(id: number): any;
builtCluster(id: string): WasmResult<string>;
/**

@@ -231,37 +393,14 @@ * Previews a formatted citation cluster, in a particular position.

* @param {string} format
* @returns {any}
* @returns {WasmResult<string>}
*/
previewCitationCluster(cites: any[], positions: any[], format: string): any;
previewCitationCluster(cites: any[], positions: any[], format: string): WasmResult<string>;
/**
* @returns {BibEntries}
* @returns {WasmResult<BibEntries>}
*/
makeBibliography(): BibEntries;
makeBibliography(): WasmResult<BibEntries>;
/**
* @returns {BibliographyMeta}
* @returns {WasmResult<BibliographyMeta>}
*/
bibliographyMeta(): BibliographyMeta;
bibliographyMeta(): WasmResult<BibliographyMeta>;
/**
* Replaces cluster numberings in one go.
*
* * `mappings` is an `Array<[ ClusterId, ClusterNumber ]>` where `ClusterNumber`
* is, e.g. `{ note: 1 }`, `{ note: [3, 1] }` or `{ inText: 5 }` in the same way a
* Cluster must contain one of those three numberings.
*
* Not every ClusterId must appear in the array, just the ones you wish to renumber.
*
* The library consumer is responsible for ensuring that clusters are well-ordered. Clusters
* are sorted for determining cite positions (ibid, subsequent, etc). If a footnote is
* deleted, you will likely need to shift all cluster numbers after it back by one.
*
* The second note numbering, `{note: [3, 1]}`, is for having multiple clusters in a single
* footnote. This is possible in many editors. The second number acts as a second sorting
* key.
*
* The third note numbering, `{ inText: 5 }`, is for ordering in-text references that appear
* within the body of a document. These will be sorted but won't cause
* `first-reference-note-number` to become available.
* @param {any[]} mappings
*/
renumberClusters(mappings: any[]): void;
/**
* Specifies which clusters are actually considered to be in the document, and sets their

@@ -291,4 +430,5 @@ * order. You may insert as many clusters as you like, but the ones provided here are the only

* @param {any[]} positions
* @returns {WasmResult<undefined>}
*/
setClusterOrder(positions: any[]): void;
setClusterOrder(positions: any[]): WasmResult<undefined>;
/**

@@ -302,5 +442,5 @@ * Retrieve any clusters that have been touched since last time `batchedUpdates` was

* * returns an `UpdateSummary`
* @returns {UpdateSummary}
* @returns {WasmResult<UpdateSummary>}
*/
batchedUpdates(): UpdateSummary;
batchedUpdates(): WasmResult<UpdateSummary>;
/**

@@ -310,5 +450,5 @@ * Returns all the clusters and bibliography entries in the document.

* Use this to rehydrate a document or run non-interactively.
* @returns {FullRender}
* @returns {WasmResult<FullRender>}
*/
fullRender(): FullRender;
fullRender(): WasmResult<FullRender>;
/**

@@ -320,6 +460,6 @@ * Drains the `batchedUpdates` queue manually.

* Asynchronously fetches all the locales that may be required, and saves them into the
* engine. Uses your provided `Lifecycle.fetchLocale` function.
* engine. Uses your provided `Fetcher.fetchLocale` function.
* @returns {Promise<any>}
*/
fetchAll(): Promise<any>;
fetchLocales(): Promise<any>;
}
/* tslint:disable */
/* eslint-disable */
export const memory: WebAssembly.Memory;
export function parseStyleMetadata(a: number, b: number): number;
export function __wbg_driver_free(a: number): void;
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): 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_new(a: number): number;
export function driver_setStyle(a: number, b: number, c: number): number;
export function driver_resetReferences(a: number, b: number, c: number): number;
export function driver_insertReferences(a: number, b: number, c: number): number;
export function driver_insertReference(a: number, b: number): number;
export function driver_removeReference(a: number, b: number, c: number): number;
export function driver_includeUncited(a: number, b: number): number;
export function driver_toFetch(a: number): number;
export function driver_insertCluster(a: number, b: number): void;
export function driver_removeCluster(a: number, b: number): void;
export function driver_initClusters(a: number, b: number, c: number): void;
export function driver_builtCluster(a: number, b: number): number;
export function driver_randomClusterId(a: number, b: number): void;
export function driver_insertCluster(a: number, b: number): number;
export function driver_removeCluster(a: number, b: number, c: number): number;
export function driver_initClusters(a: number, b: number, c: number): number;
export function driver_builtCluster(a: number, b: number, c: 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;
export function driver_bibliographyMeta(a: number): number;
export function driver_renumberClusters(a: number, b: number, c: number): void;
export function driver_setClusterOrder(a: number, b: number, c: number): void;
export function driver_setClusterOrder(a: number, b: number, c: number): number;
export function driver_batchedUpdates(a: number): number;
export function driver_fullRender(a: number): number;
export function driver_drain(a: number): void;
export function driver_fetchAll(a: number): number;
export function driver_fetchLocales(a: number): number;
export function __wbindgen_malloc(a: number): number;
export function __wbindgen_realloc(a: number, b: number, c: 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__hd125291c94f17248(a: number, b: number, c: number): void;
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2b1b33880a98c55e(a: number, b: number, c: number): void;
export function __wbindgen_add_to_stack_pointer(a: number): number;
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__h48fd5816c723cd64(a: number, b: number, c: number, d: number): void;
export function wasm_bindgen__convert__closures__invoke2_mut__h4915090d68cfd6bd(a: number, b: number, c: number, d: number): void;
/* tslint:disable */
/* eslint-disable */
/**
* Parses a CSL style, either independent or dependent, and returns its metadata.
* @param {string} style
* @returns {WasmResult<StyleMeta>}
*/
export function parseStyleMetadata(style: string): WasmResult<StyleMeta>;
interface InitOptions {
/** A CSL style as an XML string */
style: string,
/** A Fetcher implementation for fetching locales.
*
* If not provided, then no locales can be fetched, and default-locale and localeOverride will
* not be respected; the only locale used will be the bundled en-US. */
fetcher?: Fetcher,
/** The output format for this driver instance */
format: "html" | "rtf" | "plain",
/** A locale to use instead of the style's default-locale.
*
* For dependent styles, use parseStyleMetadata to find out which locale it prefers, and pass
* in the parent style with a localeOverride set to that value.
*/
localeOverride?: string,
/** Disables sorting in the bibliography; items appear in cited order. */
bibliographyNoSort?: bool,
}
/** This interface lets citeproc retrieve locales or modules asynchronously,
according to which ones are needed. */
export interface Lifecycle {
export interface Fetcher {
/** Return locale XML for a particular locale. */

@@ -12,2 +41,4 @@ fetchLocale(lang: string): Promise<string>;

export type DateLiteral = { "literal": string; };

@@ -21,2 +52,4 @@ export type DateRaw = { "raw": string; };

/** Locator type, and a locator string */

@@ -29,24 +62,28 @@ export type Locator = {

export type CiteLocator = Locator | { locator: undefined; locators: Locator[] };
export type CiteLocator = Locator | { locator: undefined; locators: Locator[]; };
export type CiteMode = { mode?: "SuppressAuthor" | "AuthorOnly"; };
export type Cite<Affix = string> = {
export type Cite = {
id: string;
prefix?: Affix;
suffix?: Affix;
suppression?: "InText" | "Rest" | null;
} & Partial<CiteLocator>;
prefix?: string;
suffix?: string;
} & Partial<CiteLocator> & CiteMode;
export type ClusterNumber = {
note: number | [number, number]
} | {
inText: number
};
export type ClusterMode
= { mode: "Composite"; infix?: string; suppressFirst?: number; }
| { mode: "SuppressAuthor"; suppressFirst?: number; }
| { mode: "AuthorOnly"; }
| {};
export type Cluster = {
id: number;
id: string;
cites: Cite[];
};
} & ClusterMode;
export type PreviewCluster {
cites: Cite[];
} & ClusterMode;
export type ClusterPosition = {
id: number;
id: string;
/** Leaving off this field means this cluster is in-text. */

@@ -56,2 +93,4 @@ note?: number;

export type Reference = {

@@ -63,6 +102,8 @@ id: string;

export type CslType = "book" | "article" | "legal_case" | "article-journal";
export type CslType = "book" | "article" | "legal_case" | "article-journal" | string;
export interface BibliographyUpdate {
updatedEntries: { [key: string]: string };
updatedEntries: Map<string, string>;
entryIds?: string[];

@@ -72,23 +113,6 @@ }

export type UpdateSummary<Output = string> = {
clusters: [number, Output][];
clusters: [string, Output][];
bibliography?: BibliographyUpdate;
};
type InvalidCsl = {
severity: "Error" | "Warning";
range: {
start: number;
end: number;
};
message: string;
hint: string;
};
type ParseError = {
ParseError: string;
};
type Invalid = {
Invalid: InvalidCsl[];
};
type StyleError = Partial<ParseError & Invalid>;
type IncludeUncited = "None" | "All" | { Specific: string[] };

@@ -104,3 +128,3 @@

type FullRender = {
allClusters: { [clusterId: string]: string },
allClusters: Map<string, string>,
bibEntries: BibEntries,

@@ -110,6 +134,6 @@ };

type BibliographyMeta = {
max_offset: number;
entry_spacing: number;
line_spacing: number;
hanging_indent: boolean;
maxOffset: number;
entrySpacing: number;
lineSpacing: number;
hangingIndent: boolean;
/** the second-field-align value of the CSL style */

@@ -122,2 +146,128 @@ secondFieldAlign: null | "flush" | "margin";

type Severity = "Error" | "Warning";
interface InvalidCsl {
severity: Severity;
/** Relevant bytes in the provided XML */
range: {
start: number,
end: number,
};
message: string;
hint: string | undefined;
};
type StyleError = {
tag: "Invalid",
content: InvalidCsl[],
} | {
tag: "ParseError",
content: string,
} | {
/** Cannot use a dependent style to format citations, pass the parent style instead. */
tag: "DependentStyle",
content: {
requiredParent: string,
}
};
type DriverError = {
tag: "UnknownOutputFormat",
content: string,
} | {
tag: "JsonError",
} | {
tag: "GetFetcherError",
} | {
tag: "NonExistentCluster",
content: string,
} | {
tag: "ReorderingError"
} | {
tag: "ReorderingErrorNumericId"
};
declare global {
/** Catch-all citeproc-rs Error subclass. */
declare class CiteprocRsError extends Error {
constructor(message: string);
}
declare class CiteprocRsDriverError extends CiteprocRsError {
data: DriverError;
constructor(message: string, data: DriverError);
}
declare class CslStyleError extends CiteprocRsError {
data: StyleError;
constructor(message: string, data: StyleError);
}
}
interface WasmResult<T> {
/** If this is an error, throws the error. */
unwrap(): T;
/** If this is an error, returns it, else throws. */
unwrap_err(): Error;
is_ok(): boolean;
is_err(): boolean;
/** If this is an error, returns the default value. */
unwrap_or(default: T): T;
/** If this is Ok, returns f(ok_val), else returns Err unmodified. */
map<R>(f: (t: T) => R): WasmResult<T>;
/** If this is Ok, returns f(ok_val), else returns the default value. */
map_or<R>(default: R, f: (t: T) => R): R;
}
type CitationFormat = "author-date" | "author" | "numeric" | "label" | "note";
interface LocalizedString {
value: string,
lang?: string,
}
interface ParentLink {
href: string,
lang?: string,
}
interface Link {
href: string,
rel: "self" | "documentation" | "template",
lang?: string,
}
interface Rights {
value: string,
lang?: string,
license?: string,
}
interface StyleInfo {
id: string,
updated: string,
title: LocalizedString,
titleShort?: LocalizedString,
parent?: ParentLink,
links: Link[],
rights?: Rights,
citationFormat?: CitationFormat,
categories: string[],
issn?: string,
eissn?: string,
issnl?: string,
}
interface IndependentMeta {
/** A list of languages for which a locale override was specified.
* Does not include the language-less final override. */
localeOverrides: string[],
hasBibliography: bool,
}
interface StyleMeta {
info: StyleInfo,
features: { [feature: string]: bool },
defaultLocale: string,
/** May be absent on a dependent style */
class?: "in-text" | "note",
cslVersionRequired: string,
/** May be absent on a dependent style */
independentMeta?: IndependentMeta,
};
/**

@@ -131,17 +281,16 @@ */

* * `style` is a CSL style as a string. Independent styles only.
* * `lifecycle` must implement the `Lifecycle` interface
* * `fetcher` must implement the `Fetcher` interface
* * `format` is one of { "html", "rtf" }
*
* Throws an error if it cannot parse the style you gave it.
* @param {string} style
* @param {any} lifecycle
* @param {string} format
* @returns {Driver}
* @param {InitOptions} options
* @returns {WasmResult<Driver>}
*/
static new(style: string, lifecycle: any, format: string): Driver;
static new(options: InitOptions): WasmResult<Driver>;
/**
* Sets the style (which will also cause everything to be recomputed)
* @param {string} style_text
* @returns {WasmResult<undefined>}
*/
setStyle(style_text: string): void;
setStyle(style_text: string): WasmResult<undefined>;
/**

@@ -151,4 +300,5 @@ * Completely overwrites the references library.

* @param {any[]} refs
* @returns {WasmResult<undefined>}
*/
resetReferences(refs: any[]): void;
resetReferences(refs: any[]): WasmResult<undefined>;
/**

@@ -158,4 +308,5 @@ * Inserts or overwrites references as a batch operation.

* @param {any[]} refs
* @returns {WasmResult<undefined>}
*/
insertReferences(refs: any[]): void;
insertReferences(refs: any[]): WasmResult<undefined>;
/**

@@ -166,4 +317,5 @@ * Inserts or overwrites a reference.

* @param {Reference} refr
* @returns {WasmResult<undefined>}
*/
insertReference(refr: Reference): void;
insertReference(refr: Reference): WasmResult<undefined>;
/**

@@ -173,4 +325,5 @@ * Removes a reference by id. If it is cited, any cites will be dangling. It will also

* @param {string} id
* @returns {WasmResult<undefined>}
*/
removeReference(id: string): void;
removeReference(id: string): WasmResult<undefined>;
/**

@@ -181,4 +334,5 @@ * Sets the references to be included in the bibliography despite not being directly cited.

* @param {IncludeUncited} uncited
* @returns {WasmResult<undefined>}
*/
includeUncited(uncited: IncludeUncited): void;
includeUncited(uncited: IncludeUncited): WasmResult<undefined>;
/**

@@ -188,15 +342,22 @@ * Gets a list of locales in use by the references currently loaded.

* Note that Driver comes pre-loaded with the `en-US` locale.
* @returns {any}
* @returns {WasmResult<string[]>}
*/
toFetch(): any;
toFetch(): WasmResult<string[]>;
/**
* Returns a random cluster id, with an extra guarantee that it isn't already in use.
* @returns {string}
*/
randomClusterId(): string;
/**
* Inserts or replaces a cluster with a matching `id`.
* @param {any} cluster
* @param {Cluster} cluster
* @returns {WasmResult<undefined>}
*/
insertCluster(cluster: any): void;
insertCluster(cluster: Cluster): WasmResult<undefined>;
/**
* Removes a cluster with a matching `id`
* @param {number} cluster_id
* @param {string} cluster_id
* @returns {WasmResult<undefined>}
*/
removeCluster(cluster_id: number): void;
removeCluster(cluster_id: string): WasmResult<undefined>;
/**

@@ -207,4 +368,5 @@ * Resets all the clusters in the processor to a new list.

* @param {any[]} clusters
* @returns {WasmResult<undefined>}
*/
initClusters(clusters: any[]): void;
initClusters(clusters: any[]): WasmResult<undefined>;
/**

@@ -215,6 +377,6 @@ * Returns the formatted citation cluster for `cluster_id`.

* still useful for initialization.
* @param {number} id
* @returns {any}
* @param {string} id
* @returns {WasmResult<string>}
*/
builtCluster(id: number): any;
builtCluster(id: string): WasmResult<string>;
/**

@@ -231,37 +393,14 @@ * Previews a formatted citation cluster, in a particular position.

* @param {string} format
* @returns {any}
* @returns {WasmResult<string>}
*/
previewCitationCluster(cites: any[], positions: any[], format: string): any;
previewCitationCluster(cites: any[], positions: any[], format: string): WasmResult<string>;
/**
* @returns {BibEntries}
* @returns {WasmResult<BibEntries>}
*/
makeBibliography(): BibEntries;
makeBibliography(): WasmResult<BibEntries>;
/**
* @returns {BibliographyMeta}
* @returns {WasmResult<BibliographyMeta>}
*/
bibliographyMeta(): BibliographyMeta;
bibliographyMeta(): WasmResult<BibliographyMeta>;
/**
* Replaces cluster numberings in one go.
*
* * `mappings` is an `Array<[ ClusterId, ClusterNumber ]>` where `ClusterNumber`
* is, e.g. `{ note: 1 }`, `{ note: [3, 1] }` or `{ inText: 5 }` in the same way a
* Cluster must contain one of those three numberings.
*
* Not every ClusterId must appear in the array, just the ones you wish to renumber.
*
* The library consumer is responsible for ensuring that clusters are well-ordered. Clusters
* are sorted for determining cite positions (ibid, subsequent, etc). If a footnote is
* deleted, you will likely need to shift all cluster numbers after it back by one.
*
* The second note numbering, `{note: [3, 1]}`, is for having multiple clusters in a single
* footnote. This is possible in many editors. The second number acts as a second sorting
* key.
*
* The third note numbering, `{ inText: 5 }`, is for ordering in-text references that appear
* within the body of a document. These will be sorted but won't cause
* `first-reference-note-number` to become available.
* @param {any[]} mappings
*/
renumberClusters(mappings: any[]): void;
/**
* Specifies which clusters are actually considered to be in the document, and sets their

@@ -291,4 +430,5 @@ * order. You may insert as many clusters as you like, but the ones provided here are the only

* @param {any[]} positions
* @returns {WasmResult<undefined>}
*/
setClusterOrder(positions: any[]): void;
setClusterOrder(positions: any[]): WasmResult<undefined>;
/**

@@ -302,5 +442,5 @@ * Retrieve any clusters that have been touched since last time `batchedUpdates` was

* * returns an `UpdateSummary`
* @returns {UpdateSummary}
* @returns {WasmResult<UpdateSummary>}
*/
batchedUpdates(): UpdateSummary;
batchedUpdates(): WasmResult<UpdateSummary>;
/**

@@ -310,5 +450,5 @@ * Returns all the clusters and bibliography entries in the document.

* Use this to rehydrate a document or run non-interactively.
* @returns {FullRender}
* @returns {WasmResult<FullRender>}
*/
fullRender(): FullRender;
fullRender(): WasmResult<FullRender>;
/**

@@ -320,6 +460,6 @@ * Drains the `batchedUpdates` queue manually.

* Asynchronously fetches all the locales that may be required, and saves them into the
* engine. Uses your provided `Lifecycle.fetchLocale` function.
* engine. Uses your provided `Fetcher.fetchLocale` function.
* @returns {Promise<any>}
*/
fetchAll(): Promise<any>;
fetchLocales(): Promise<any>;
}

@@ -331,31 +471,33 @@

readonly memory: WebAssembly.Memory;
readonly parseStyleMetadata: (a: number, b: number) => number;
readonly __wbg_driver_free: (a: number) => void;
readonly driver_new: (a: number, b: number, c: number, d: number, e: number) => number;
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_new: (a: number) => number;
readonly driver_setStyle: (a: number, b: number, c: number) => number;
readonly driver_resetReferences: (a: number, b: number, c: number) => number;
readonly driver_insertReferences: (a: number, b: number, c: number) => number;
readonly driver_insertReference: (a: number, b: number) => number;
readonly driver_removeReference: (a: number, b: number, c: number) => number;
readonly driver_includeUncited: (a: number, b: number) => number;
readonly driver_toFetch: (a: number) => number;
readonly driver_insertCluster: (a: number, b: number) => void;
readonly driver_removeCluster: (a: number, b: number) => void;
readonly driver_initClusters: (a: number, b: number, c: number) => void;
readonly driver_builtCluster: (a: number, b: number) => number;
readonly driver_randomClusterId: (a: number, b: number) => void;
readonly driver_insertCluster: (a: number, b: number) => number;
readonly driver_removeCluster: (a: number, b: number, c: number) => number;
readonly driver_initClusters: (a: number, b: number, c: number) => number;
readonly driver_builtCluster: (a: number, b: number, c: 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;
readonly driver_bibliographyMeta: (a: number) => number;
readonly driver_renumberClusters: (a: number, b: number, c: number) => void;
readonly driver_setClusterOrder: (a: number, b: number, c: number) => void;
readonly driver_setClusterOrder: (a: number, b: number, c: number) => number;
readonly driver_batchedUpdates: (a: number) => number;
readonly driver_fullRender: (a: number) => number;
readonly driver_drain: (a: number) => void;
readonly driver_fetchAll: (a: number) => number;
readonly driver_fetchLocales: (a: number) => number;
readonly __wbindgen_malloc: (a: number) => number;
readonly __wbindgen_realloc: (a: number, b: number, c: number) => number;
readonly __wbindgen_export_2: WebAssembly.Table;
readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hd125291c94f17248: (a: number, b: number, c: number) => void;
readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2b1b33880a98c55e: (a: number, b: number, c: number) => void;
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
readonly __wbindgen_free: (a: number, b: number) => void;
readonly __wbindgen_exn_store: (a: number) => void;
readonly wasm_bindgen__convert__closures__invoke2_mut__h48fd5816c723cd64: (a: number, b: number, c: number, d: number) => void;
readonly wasm_bindgen__convert__closures__invoke2_mut__h4915090d68cfd6bd: (a: number, b: number, c: number, d: number) => void;
}

@@ -372,2 +514,1 @@

export default function init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;

@@ -0,1 +1,2 @@

import { WasmResult, CiteprocRsError, CiteprocRsDriverError, CslStyleError } from './snippets/wasm-1883a0b9dcad429e/src/js/include.js';

@@ -10,2 +11,16 @@ let 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;

@@ -90,4 +105,2 @@

let heap_next = heap.length;
function addHeapObject(obj) {

@@ -102,14 +115,2 @@ if (heap_next === heap.length) heap.push(heap.length + 1);

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) {

@@ -143,6 +144,18 @@ 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__hd125291c94f17248(arg0, arg1, addHeapObject(arg2));
function __wbg_adapter_24(arg0, arg1, arg2) {
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2b1b33880a98c55e(arg0, arg1, addHeapObject(arg2));
}
/**
* Parses a CSL style, either independent or dependent, and returns its metadata.
* @param {string} style
* @returns {WasmResult<StyleMeta>}
*/
export function parseStyleMetadata(style) {
var ptr0 = passStringToWasm0(style, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
var ret = wasm.parseStyleMetadata(ptr0, len0);
return takeObject(ret);
}
let cachegetUint32Memory0 = null;

@@ -176,6 +189,9 @@ function getUint32Memory0() {

}
function __wbg_adapter_64(arg0, arg1, arg2, arg3) {
wasm.wasm_bindgen__convert__closures__invoke2_mut__h48fd5816c723cd64(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
function __wbg_adapter_81(arg0, arg1, arg2, arg3) {
wasm.wasm_bindgen__convert__closures__invoke2_mut__h4915090d68cfd6bd(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
}
function getArrayU8FromWasm0(ptr, len) {
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
}
/**

@@ -192,6 +208,11 @@ */

free() {
__destroy_into_raw() {
const ptr = this.ptr;
this.ptr = 0;
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_driver_free(ptr);

@@ -203,18 +224,12 @@ }

* * `style` is a CSL style as a string. Independent styles only.
* * `lifecycle` must implement the `Lifecycle` interface
* * `fetcher` must implement the `Fetcher` interface
* * `format` is one of { "html", "rtf" }
*
* Throws an error if it cannot parse the style you gave it.
* @param {string} style
* @param {any} lifecycle
* @param {string} format
* @returns {Driver}
* @param {InitOptions} options
* @returns {WasmResult<Driver>}
*/
static new(style, lifecycle, format) {
var ptr0 = passStringToWasm0(style, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
var ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len1 = WASM_VECTOR_LEN;
var ret = wasm.driver_new(ptr0, len0, addHeapObject(lifecycle), ptr1, len1);
return Driver.__wrap(ret);
static new(options) {
var ret = wasm.driver_new(addHeapObject(options));
return takeObject(ret);
}

@@ -224,2 +239,3 @@ /**

* @param {string} style_text
* @returns {WasmResult<undefined>}
*/

@@ -229,3 +245,4 @@ setStyle(style_text) {

var len0 = WASM_VECTOR_LEN;
wasm.driver_setStyle(this.ptr, ptr0, len0);
var ret = wasm.driver_setStyle(this.ptr, ptr0, len0);
return takeObject(ret);
}

@@ -236,2 +253,3 @@ /**

* @param {any[]} refs
* @returns {WasmResult<undefined>}
*/

@@ -241,3 +259,4 @@ resetReferences(refs) {

var len0 = WASM_VECTOR_LEN;
wasm.driver_resetReferences(this.ptr, ptr0, len0);
var ret = wasm.driver_resetReferences(this.ptr, ptr0, len0);
return takeObject(ret);
}

@@ -248,2 +267,3 @@ /**

* @param {any[]} refs
* @returns {WasmResult<undefined>}
*/

@@ -253,3 +273,4 @@ insertReferences(refs) {

var len0 = WASM_VECTOR_LEN;
wasm.driver_insertReferences(this.ptr, ptr0, len0);
var ret = wasm.driver_insertReferences(this.ptr, ptr0, len0);
return takeObject(ret);
}

@@ -261,5 +282,7 @@ /**

* @param {Reference} refr
* @returns {WasmResult<undefined>}
*/
insertReference(refr) {
wasm.driver_insertReference(this.ptr, addHeapObject(refr));
var ret = wasm.driver_insertReference(this.ptr, addHeapObject(refr));
return takeObject(ret);
}

@@ -270,2 +293,3 @@ /**

* @param {string} id
* @returns {WasmResult<undefined>}
*/

@@ -275,3 +299,4 @@ removeReference(id) {

var len0 = WASM_VECTOR_LEN;
wasm.driver_removeReference(this.ptr, ptr0, len0);
var ret = wasm.driver_removeReference(this.ptr, ptr0, len0);
return takeObject(ret);
}

@@ -283,5 +308,7 @@ /**

* @param {IncludeUncited} uncited
* @returns {WasmResult<undefined>}
*/
includeUncited(uncited) {
wasm.driver_includeUncited(this.ptr, addHeapObject(uncited));
var ret = wasm.driver_includeUncited(this.ptr, addHeapObject(uncited));
return takeObject(ret);
}

@@ -292,3 +319,3 @@ /**

* Note that Driver comes pre-loaded with the `en-US` locale.
* @returns {any}
* @returns {WasmResult<string[]>}
*/

@@ -300,14 +327,36 @@ toFetch() {

/**
* Returns a random cluster id, with an extra guarantee that it isn't already in use.
* @returns {string}
*/
randomClusterId() {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.driver_randomClusterId(retptr, this.ptr);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
return getStringFromWasm0(r0, r1);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
wasm.__wbindgen_free(r0, r1);
}
}
/**
* Inserts or replaces a cluster with a matching `id`.
* @param {any} cluster
* @param {Cluster} cluster
* @returns {WasmResult<undefined>}
*/
insertCluster(cluster) {
wasm.driver_insertCluster(this.ptr, addHeapObject(cluster));
var ret = wasm.driver_insertCluster(this.ptr, addHeapObject(cluster));
return takeObject(ret);
}
/**
* Removes a cluster with a matching `id`
* @param {number} cluster_id
* @param {string} cluster_id
* @returns {WasmResult<undefined>}
*/
removeCluster(cluster_id) {
wasm.driver_removeCluster(this.ptr, cluster_id);
var ptr0 = passStringToWasm0(cluster_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
var ret = wasm.driver_removeCluster(this.ptr, ptr0, len0);
return takeObject(ret);
}

@@ -319,2 +368,3 @@ /**

* @param {any[]} clusters
* @returns {WasmResult<undefined>}
*/

@@ -324,3 +374,4 @@ initClusters(clusters) {

var len0 = WASM_VECTOR_LEN;
wasm.driver_initClusters(this.ptr, ptr0, len0);
var ret = wasm.driver_initClusters(this.ptr, ptr0, len0);
return takeObject(ret);
}

@@ -332,7 +383,9 @@ /**

* still useful for initialization.
* @param {number} id
* @returns {any}
* @param {string} id
* @returns {WasmResult<string>}
*/
builtCluster(id) {
var ret = wasm.driver_builtCluster(this.ptr, id);
var ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
var ret = wasm.driver_builtCluster(this.ptr, ptr0, len0);
return takeObject(ret);

@@ -351,3 +404,3 @@ }

* @param {string} format
* @returns {any}
* @returns {WasmResult<string>}
*/

@@ -365,3 +418,3 @@ previewCitationCluster(cites, positions, format) {

/**
* @returns {BibEntries}
* @returns {WasmResult<BibEntries>}
*/

@@ -373,3 +426,3 @@ makeBibliography() {

/**
* @returns {BibliographyMeta}
* @returns {WasmResult<BibliographyMeta>}
*/

@@ -381,29 +434,2 @@ bibliographyMeta() {

/**
* Replaces cluster numberings in one go.
*
* * `mappings` is an `Array<[ ClusterId, ClusterNumber ]>` where `ClusterNumber`
* is, e.g. `{ note: 1 }`, `{ note: [3, 1] }` or `{ inText: 5 }` in the same way a
* Cluster must contain one of those three numberings.
*
* Not every ClusterId must appear in the array, just the ones you wish to renumber.
*
* The library consumer is responsible for ensuring that clusters are well-ordered. Clusters
* are sorted for determining cite positions (ibid, subsequent, etc). If a footnote is
* deleted, you will likely need to shift all cluster numbers after it back by one.
*
* The second note numbering, `{note: [3, 1]}`, is for having multiple clusters in a single
* footnote. This is possible in many editors. The second number acts as a second sorting
* key.
*
* The third note numbering, `{ inText: 5 }`, is for ordering in-text references that appear
* within the body of a document. These will be sorted but won't cause
* `first-reference-note-number` to become available.
* @param {any[]} mappings
*/
renumberClusters(mappings) {
var ptr0 = passArrayJsValueToWasm0(mappings, wasm.__wbindgen_malloc);
var len0 = WASM_VECTOR_LEN;
wasm.driver_renumberClusters(this.ptr, ptr0, len0);
}
/**
* Specifies which clusters are actually considered to be in the document, and sets their

@@ -433,2 +459,3 @@ * order. You may insert as many clusters as you like, but the ones provided here are the only

* @param {any[]} positions
* @returns {WasmResult<undefined>}
*/

@@ -438,3 +465,4 @@ setClusterOrder(positions) {

var len0 = WASM_VECTOR_LEN;
wasm.driver_setClusterOrder(this.ptr, ptr0, len0);
var ret = wasm.driver_setClusterOrder(this.ptr, ptr0, len0);
return takeObject(ret);
}

@@ -449,3 +477,3 @@ /**

* * returns an `UpdateSummary`
* @returns {UpdateSummary}
* @returns {WasmResult<UpdateSummary>}
*/

@@ -460,3 +488,3 @@ batchedUpdates() {

* Use this to rehydrate a document or run non-interactively.
* @returns {FullRender}
* @returns {WasmResult<FullRender>}
*/

@@ -475,7 +503,7 @@ fullRender() {

* Asynchronously fetches all the locales that may be required, and saves them into the
* engine. Uses your provided `Lifecycle.fetchLocale` function.
* engine. Uses your provided `Fetcher.fetchLocale` function.
* @returns {Promise<any>}
*/
fetchAll() {
var ret = wasm.driver_fetchAll(this.ptr);
fetchLocales() {
var ret = wasm.driver_fetchLocales(this.ptr);
return takeObject(ret);

@@ -487,3 +515,2 @@ }

if (typeof Response === 'function' && module instanceof Response) {
if (typeof WebAssembly.instantiateStreaming === 'function') {

@@ -507,3 +534,2 @@ try {

} else {
const instance = await WebAssembly.instantiate(module, imports);

@@ -522,24 +548,11 @@

if (typeof input === 'undefined') {
input = import.meta.url.replace(/\.js$/, '_bg.wasm');
input = new URL('citeproc_rs_wasm_bg.wasm', import.meta.url);
}
const imports = {};
imports.wbg = {};
imports.wbg.__wbindgen_json_serialize = function(arg0, arg1) {
const obj = getObject(arg1);
var ret = JSON.stringify(obj === undefined ? null : obj);
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.__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.__wbg_fetchLocale_8f52b973b0739a6c = function(arg0, arg1, arg2) {
var ret = getObject(arg0).fetchLocale(getStringFromWasm0(arg1, arg2));
return addHeapObject(ret);
imports.wbg.__wbg_error_e549f7fed6d655aa = function(arg0) {
console.error(takeObject(arg0));
};

@@ -561,9 +574,14 @@ imports.wbg.__wbg_debug_4885c3f7d6f044a3 = function(arg0, arg1) {

};
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
var ret = getObject(arg0);
imports.wbg.__wbindgen_json_serialize = function(arg0, arg1) {
const obj = getObject(arg1);
var ret = JSON.stringify(obj === undefined ? null : obj);
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.__wbindgen_string_new = function(arg0, arg1) {
var ret = getStringFromWasm0(arg0, arg1);
return addHeapObject(ret);
};
imports.wbg.__wbg_error_e549f7fed6d655aa = function(arg0) {
console.error(takeObject(arg0));
};
imports.wbg.__wbindgen_cb_drop = function(arg0) {

@@ -578,2 +596,51 @@ const obj = takeObject(arg0).original;

};
imports.wbg.__wbindgen_json_parse = function(arg0, arg1) {
var ret = JSON.parse(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
};
imports.wbg.__wbg_driver_new = function(arg0) {
var ret = Driver.__wrap(arg0);
return addHeapObject(ret);
};
imports.wbg.__wbg_new_f12987d5c30f0ab7 = function(arg0) {
var ret = new CiteprocRsError(takeObject(arg0));
return addHeapObject(ret);
};
imports.wbg.__wbg_new_c5e56e6577bc2b6a = function(arg0, arg1) {
var ret = new CslStyleError(takeObject(arg0), takeObject(arg1));
return addHeapObject(ret);
};
imports.wbg.__wbg_new_6edca5ab9ee61764 = function(arg0) {
var ret = new WasmResult(takeObject(arg0));
return addHeapObject(ret);
};
imports.wbg.__wbg_get_1edc26456ed84f9b = function(arg0, arg1) {
var ret = getObject(arg0)[takeObject(arg1)];
return addHeapObject(ret);
};
imports.wbg.__wbg_new_8d5f3cd64eaaa8b5 = function(arg0, arg1) {
var ret = new CiteprocRsDriverError(takeObject(arg0), takeObject(arg1));
return addHeapObject(ret);
};
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
var ret = getObject(arg0);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_is_undefined = function(arg0) {
var ret = getObject(arg0) === undefined;
return ret;
};
imports.wbg.__wbindgen_is_object = function(arg0) {
const val = getObject(arg0);
var ret = typeof(val) === 'object' && val !== null;
return ret;
};
imports.wbg.__wbindgen_is_function = function(arg0) {
var ret = typeof(getObject(arg0)) === 'function';
return ret;
};
imports.wbg.__wbg_fetchLocale_d644d4ae2ca50f81 = function(arg0, arg1, arg2) {
var ret = getObject(arg0).fetchLocale(getStringFromWasm0(arg1, arg2));
return addHeapObject(ret);
};
imports.wbg.__wbg_new_59cb74e423758ede = function() {

@@ -597,11 +664,7 @@ var ret = new Error();

};
imports.wbg.__wbg_new_1192d65414040ad9 = function(arg0, arg1) {
var ret = new Error(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
};
imports.wbg.__wbg_call_d713ea0274dfc6d2 = handleError(function(arg0, arg1, arg2) {
imports.wbg.__wbg_call_f5e0576f61ee7461 = handleError(function(arg0, arg1, arg2) {
var ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
return addHeapObject(ret);
});
imports.wbg.__wbg_new_d0c63652ab4d825c = function(arg0, arg1) {
imports.wbg.__wbg_new_3ea8490cd276c848 = function(arg0, arg1) {
try {

@@ -613,3 +676,3 @@ var state0 = {a: arg0, b: arg1};

try {
return __wbg_adapter_64(a, state0.b, arg0, arg1);
return __wbg_adapter_81(a, state0.b, arg0, arg1);
} finally {

@@ -625,14 +688,44 @@ state0.a = a;

};
imports.wbg.__wbg_resolve_2529512c3bb73938 = function(arg0) {
imports.wbg.__wbg_resolve_778af3f90b8e2b59 = function(arg0) {
var ret = Promise.resolve(getObject(arg0));
return addHeapObject(ret);
};
imports.wbg.__wbg_then_4a7a614abbbe6d81 = function(arg0, arg1) {
imports.wbg.__wbg_then_367b3e718069cfb9 = function(arg0, arg1) {
var ret = getObject(arg0).then(getObject(arg1));
return addHeapObject(ret);
};
imports.wbg.__wbg_then_3b7ac098cfda2fa5 = function(arg0, arg1, arg2) {
imports.wbg.__wbg_then_ac66ca61394bfd21 = function(arg0, arg1, arg2) {
var ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
return addHeapObject(ret);
};
imports.wbg.__wbg_self_1c83eb4471d9eb9b = handleError(function() {
var ret = self.self;
return addHeapObject(ret);
});
imports.wbg.__wbg_static_accessor_MODULE_abf5ae284bffdf45 = function() {
var ret = module;
return addHeapObject(ret);
};
imports.wbg.__wbg_require_5b2b5b594d809d9f = function(arg0, arg1, arg2) {
var ret = getObject(arg0).require(getStringFromWasm0(arg1, arg2));
return addHeapObject(ret);
};
imports.wbg.__wbg_crypto_c12f14e810edcaa2 = function(arg0) {
var ret = getObject(arg0).crypto;
return addHeapObject(ret);
};
imports.wbg.__wbg_msCrypto_679be765111ba775 = function(arg0) {
var ret = getObject(arg0).msCrypto;
return addHeapObject(ret);
};
imports.wbg.__wbg_getRandomValues_05a60bf171bfc2be = function(arg0) {
var ret = getObject(arg0).getRandomValues;
return addHeapObject(ret);
};
imports.wbg.__wbg_getRandomValues_3ac1b33c90b52596 = function(arg0, arg1, arg2) {
getObject(arg0).getRandomValues(getArrayU8FromWasm0(arg1, arg2));
};
imports.wbg.__wbg_randomFillSync_6f956029658662ec = function(arg0, arg1, arg2) {
getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
};
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {

@@ -649,7 +742,4 @@ const obj = getObject(arg1);

};
imports.wbg.__wbindgen_rethrow = function(arg0) {
throw takeObject(arg0);
};
imports.wbg.__wbindgen_closure_wrapper836 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 195, __wbg_adapter_18);
imports.wbg.__wbindgen_closure_wrapper952 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 227, __wbg_adapter_24);
return addHeapObject(ret);

@@ -662,2 +752,4 @@ };

const { instance, module } = await load(await input, imports);

@@ -664,0 +756,0 @@

@@ -7,3 +7,3 @@ {

"description": "citeproc-rs, compiled to WebAssembly",
"version": "0.0.0-canary-3f5d731",
"version": "0.0.0-canary-404d2bd",
"license": "MPL-2.0",

@@ -18,2 +18,4 @@ "repository": {

"_web/*",
"_no_modules/*",
"_zotero/*",
"README.md"

@@ -20,0 +22,0 @@ ],

@@ -49,2 +49,8 @@ # `@citeproc-rs/wasm`

##### Microsoft Edge
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).
#### Using Webpack

@@ -76,12 +82,23 @@

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).
##### React
If you're writing a React app, you may wish to use `React.lazy` like so:
```typescript
// App.tsx
import React, { Suspense } from "react";
const AsyncCiteprocEnabledComponent = React.lazy(async () => {
await import("@citeproc-rs/wasm");
return await import("./CiteprocEnabledComponent");
});
const App = () => (
<Suspense
fallback={<div>Loading citation formatting engine...</div>}>
<AsyncCiteprocEnabledComponent />
</Suspense>
);
// CiteprocEnabledComponent
import { Driver } from "@citeproc-rs/wasm";
function doSomethingWithDriver(driver: Driver) {
// ...
}
// ...
```

@@ -109,10 +126,17 @@

**Careful**: This method does not ensure the package is loaded only once. If
you call init again, it will invalidate any previous Drivers you created.
#### Importing it in a script tag (`no-modules` target)
This replicates the [wasm-bindgen guide
This is *based on* 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.
available on a webserver or via a CDN. But it has **ONE ADDITIONAL FILE** to
import via a script tag.
**Careful**: This method does not ensure the package is loaded only once. If
you call init again, it will invalidate any previous Drivers you created.
```

@@ -124,3 +148,4 @@ <html>

<body>
<!-- Include the JS generated by `wasm-pack build` -->
<!-- Include these TWO JS files -->
<script src='path/to/@citeproc-rs/wasm/_no_modules/citeproc_rs_wasm_include.js'></script>
<script src='path/to/@citeproc-rs/wasm/_no_modules/citeproc_rs_wasm.js'></script>

@@ -154,3 +179,43 @@

#### Usage in Zotero
There is a special build for Zotero and the legacy Firefox ESR extensions API,
which wants a CommonJS module format but without the Node.js `fs` APIs, and
`no-modules`' loading mechanisms but without the use of `window` as a global as
it doesn't exist. The files are in the `_zotero` directory of the NPM package.
Usage is essentially the same as no-modules; you'll need all three files:
* `@citeproc-rs/wasm/_zotero/citeproc_rs_wasm_include.js`
* `@citeproc-rs/wasm/_zotero/citeproc_rs_wasm.js`
* `@citeproc-rs/wasm/_zotero/citeproc_rs_wasm_bg.wasm`
Apart from the CommonJS shims, the main difference is that the API will be
loaded onto the `Zotero.CiteprocRs` object, in order for it all to be linked
together.
**Careful**: This method does not ensure the package is loaded only once. If
you call `initWasmModule` again, it will invalidate any previous Drivers you
created.
```javascript
require("citeproc_rs_wasm_include");
const initWasmModule = require("citeproc_rs_wasm");
const wasmBinaryPromise = Zotero.HTTP
.request('GET',
'resource://zotero/citeproc_rs_wasm_bg.wasm',
{ responseType: "arraybuffer" })
.then(xhr => xhr.response);
await initWasmModule(wasmBinaryPromise);
let driver;
try {
driver = Zotero.CiteprocRs.Driver.new({...}).unwrap();
} catch (e) {
if (e instanceof Zotero.CiteprocRs.CslStyleError) {
// ...
}
}
```
## Usage

@@ -177,3 +242,36 @@

### Error handling
To avoid [this issue][1963], almost every API wraps its return value in a
JavaScript object that contains either a successful result or an error, which
is a JavaScript Error object. This is called `WasmResult`, and it is modelled
on the Rust [`Result` type][rust-result]. If you just want your errors thrown,
simply tack `.unwrap()` onto nearly every API call. If you want to handle them
manually, you can, and this is mainly useful for showing style parse or
validation errors. Some error types have structured data attached to them.
```typescript
let result = Driver.new({ ... });
if (result.is_err()) {
let error = result.unwrap_err();
if (error instanceof CslStyleError) {
console.warn("Could not parse CSL, error:", error);
// You can also
// throw error;
}
} else {
let driver = result.unwrap();
}
// ...
driver.free(); // No unwrap.
```
The error types must unfortunately be global exports, on window/global/self.
In this document, `.unwrap()` used after an example means it returns a
WasmResult.
[1963]: https://github.com/rustwasm/wasm-bindgen/issues/1963
[rust-result]: https://doc.rust-lang.org/stable/std/result/enum.Result.html
### 1. Creating a driver instance

@@ -186,7 +284,21 @@

A driver needs an XML style string, a fetcher (below), and an output format
(one of `"html"`, `"rtf"` or `"plain"`).
A driver needs at least 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");
let fetcher = ...; // see below
let driverResult = Driver.new({
style: "<style version=\"1.0\" class=\"note\" ... > ... </style>",
format: "html", // optional, html is the default
formatOptions: { // optional
linkAnchors: true, // optional, default true
},
localeOverride: "de-DE", // optional, like setting default-locale on the style
// bibliographyNoSort: true // disables sorting on the bibliography
fetcher,
});
// Throw any errors, get the inner Driver
let driver = driverResult.unwrap();
// Fetch the chain of locale files required to use the specified locale
await driver.fetchLocales();
// ... use the driver ...

@@ -197,13 +309,12 @@ 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.
reported, with byte offsets to find the CSL fragment responsible, a descriptive
and useful message (in English) and sometimes even a hint for how to fix it.
See [Error Handling](#error-handling) for how to access this.
#### 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:
There are hundreds of locales, and the locales you need depend on the style
default, any overrides and any fallback locales defined, so the procedure for
retrieving one is asynchronous to allow for fetching one over HTTP. There's not
much more to it than this:

@@ -213,3 +324,3 @@ ```javascript

async fetchLocale(lang) {
return fetch("https://some-cdn-with-locales.com/locales-${lang}.xml")
return await fetch("https://some-cdn-with-locales.com/locales-${lang}.xml")
.then(res => res.text());

@@ -226,3 +337,6 @@

let fetcher = new Fetcher(); // Pass to Driver.new()
let fetcher = new Fetcher();
let driver = Driver.new({ ..., fetcher }).unwrap();
// Make sure you actually fetch them!
await driver.fetchLocales();
```

@@ -233,5 +347,8 @@

Declining to provide a locale fetcher in `Driver.new` or forgetting to call
`await driver.fetchLocales()` results in use of the bundled `en-US` locale. You
should also never attempt to use the driver instance while it is fetching locales.
### 2. Edit the references or the citation clusters
#### References

@@ -244,21 +361,12 @@

```javascript
driver.insertReference({ id: "citekey", type: "book", title: "Title" });
driver.insertReferences([ ... many references ... ]);
driver.resetReferences([ ... deletes any others ... ]);
driver.removeReference("citekey");
driver.insertReference({ id: "citekey", type: "book", title: "Title" }).unwrap();
driver.insertReferences([ ... many references ... ]).unwrap();
driver.resetReferences([ ... deletes any others ... ]).unwrap();
driver.removeReference("citekey").unwrap();
```
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.
cluster has an `id`, which is any old string.

@@ -268,8 +376,10 @@ ```javascript

driver.initClusters([
{ id: 1, cites: [ {id: "citekey"} ] },
{ id: 2, cites: [ {id: "citekey", locator: "56", label: "page" } ] },
]);
{ id: "one", cites: [ {id: "citekey"} ] },
{ id: "two", cites: [ {id: "citekey", locator: "56", label: "page" } ] },
]).unwrap();
// 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" } ] });
driver.insertCluster({ id: "one", cites: [ { id: "updated_citekey" } ] }).unwrap();
// (You can use `driver.randomClusterId()` to generate a new one at random.)
let three = driver.randomClusterId();
driver.insertCluster({ id: three, cites: [ { id: "new_cluster_here" } ] }).unwrap();
```

@@ -288,3 +398,3 @@

```javascript
driver.setClusterOrder([ { id: 1, note: 1 }, { id: 2, note: 4 } ]);
driver.setClusterOrder([ { id: "one", note: 1 }, { id: "two", note: 4 } ]).unwrap();
```

@@ -304,5 +414,5 @@

```javascript
driver.includeUncited("None"); // Default
driver.includeUncited("All");
driver.includeUncited({ Specific: ["citekeyA", "citekeyB"] });
driver.includeUncited("None").unwrap(); // Default
driver.includeUncited("All").unwrap();
driver.includeUncited({ Specific: ["citekeyA", "citekeyB"] }).unwrap();
```

@@ -325,5 +435,8 @@

// Get the diff since last time batchedUpdates, fullRender or drain was called.
let diff = driver.batchedUpdates();
let diff = driver.batchedUpdates().unwrap();
// apply cluster changes to the UI.
// ("myDocument" is an imaginary API.)
for (let changedCluster of diff.clusters) {

@@ -362,6 +475,6 @@ let [id, html] = changedCluster;

// lay out the bibliography. There is a similar API in citeproc-js.
let meta = driver.bibliographyMeta();
let meta = driver.bibliographyMeta().unwrap();
// This is an array of BibEntry
let bibliography = driver.makeBibliography();
let bibliography = driver.makeBibliography().unwrap();
for (let entry of bibliography) {

@@ -379,8 +492,12 @@ console.log(entry.id, entry.value);

let cites = [ { id: "citekey", locator: "45" }, { ... } ];
let positions = [ ... before, { id: 0, note: 34 }, ... after ];
let preview = driver.previewCitationCluster(cites, positions, "html");
let positions = [ ... before, { note: 34 }, ... after ];
let preview = driver.previewCitationCluster(cites, positions, "html").unwrap();
```
The format argument is like the format passed to `Driver.new`: one of `"html"`,
`"rtf"` or `"plain"`. The driver will use that instead of its normal output
format.
The positions array is exactly like a call to `setClusterOrder`, except exactly
one of the positions has an id of 0. This could either:
one of the positions omits the id field. This could either:

@@ -397,3 +514,59 @@ - Replace an existing cluster's position, and preview a cluster replacement; or

### `AuthorOnly`, `SuppressAuthor` & `Composite`
`@citeproc-rs/wasm` supports these flags on clusters (all 3) and cites (except
`Composite`), in a similar way to `citeproc-js`. See the [`citeproc-js`
documentation on Special Citation
Forms](https://citeproc-js.readthedocs.io/en/latest/running.html#special-citation-forms)
for reference.
```javascript
// only two modes for cites
let citeAO = { id: "jones2006", mode: "AuthorOnly" };
let citeSA = { id: "jones2006", mode: "SuppressAuthor" };
// additional options for clusters
let clusterAO = { id: "one", cites: [...], mode: "AuthorOnly" };
let clusterSA = { id: "one", cites: [...], mode: "SuppressAuthor" };
let clusterSA_First = { id: "one", cites: [...], mode: "SuppressAuthor", suppressFirst: 3 };
let clusterC = { id: "one", cites: [...], mode: "Composite" };
let clusterC_Infix = { id: "one", cites: [...], mode: "Composite", infix: ", whose book" };
let clusterC_Full = { id: "one", cites: [...], mode: "Composite", infix: ", whose books", suppressFirst: 0 };
```
It does support one extra option with `SuppressAuthor` and `Composite` on
clusters: `suppressFirst`, which limits the effect to the first N name groups
(or if cite grouping is disabled, first N names). Setting it to 0 means
unlimited.
#### `<intext>` element with `AuthorOnly` etc.
`citeproc-rs` supports the `<intext>` element described in the `citeproc-js`
docs linked above, but it is not enabled by default. It also supports `<intext
and="symbol">` or `and="text"`, which will swap out the last intext layout
delimiter (`<layout delimiter="; ">`) for either the ampersand or the `and`
term.
If you want to use the `<intext>` element in CSL, you may either:
##### Option 1: Add a feature flag to the style wishing to use it
```xml
<style class="in-text">
<features>
<feature name="custom-intext" />
</features>
...
</style>
```
AFAIK no other processors support this syntax yet.
##### Option 2: Enable the `custom-intext` feature for all styles via `Driver.new`
```javascript
let driver = Driver.new({ ..., cslFeatures: ["custom-intext"] }).unwrap();
// ... driver.free();
```
### Non-Interactive use, or re-hydrating a previously created document

@@ -414,5 +587,5 @@

// document's clusters
driver.resetReferences(myDocument.allReferences);
driver.initClusters(allNotes.map(fn => fn.cluster));
driver.setClusterOrder(allNotes.map(fn => { id: fn.cluster.id, note: fn.number }));
driver.resetReferences(myDocument.allReferences).unwrap();
driver.initClusters(allNotes.map(fn => fn.cluster)).unwrap();
driver.setClusterOrder(allNotes.map(fn => { id: fn.cluster.id, note: fn.number })).unwrap();

@@ -422,3 +595,3 @@ // Render every cluster and bibliography item.

// see the FullRender typescript type
let render = driver.fullRender();
let render = driver.fullRender().unwrap();

@@ -440,1 +613,50 @@ // Write out the rendered clusters into the doc

### `parseStyleMetadata`
Sometimes you want information about a CSL style without actually booting up a
whole driver. One important use case is a dependent style, which can't be used
with `Driver.new()` because it doesn't have the ability to render citations on
its own, and is essentially just a container for three pieces of information:
- A journal name
- An independent parent style
- A possible default-locale override
`@citeproc-rs/wasm` provides an API for finding out what's in a CSL style file.
```typescript
let result = parseStyleMetadata("<style ...> ... </style>").unwrap();
```
The result could be a `CslStyleError`, but this is less likely than with
Driver.new() as it will not actually attempt to parse and validate all the
parts of a style.
Here's how to use `parseStyleMetadata` to parse and use a dependent style.
```typescript
let dependentStyle = "<style ...> ... </style>";
let meta = parseStyleMetadata(dependentStyle).unwrap();
let isDependent = meta.info.parent != null;
let parentStyleId = isDependent && meta.info.parent.href;
let localeOverride = meta.defaultLocale;
// ...
let parentStyle = await downloadStyleWithId(parentStyleId);
let driver = Driver.new({
style: parentStyle,
localeOverride,
...
}).unwrap();
await driver.fetchLocales();
// Here you might also want to know if the style can render a bibliography or not
let parentMeta = parseStyleMetadata(parentStyle).unwrap();
if (parentMeta.independentMeta.hasBibliography) {
let bib = driver.makeBibliography().unwrap();
// ...
}
// ...
driver.free();
```

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc