@citeproc-rs/wasm
Advanced tools
Comparing version 0.0.0-canary-5252fbd to 0.0.0-canary-55a644c
/* tslint:disable */ | ||
/* eslint-disable */ | ||
export const memory: WebAssembly.Memory; | ||
export function parseStyleMetadata(a: number, b: number): number; | ||
export function parseStyleMetadata(a: number, b: number, c: number): void; | ||
export function __wbg_driver_free(a: 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_new(a: number, b: number): void; | ||
export function driver_setStyle(a: number, b: number, c: number, d: number): void; | ||
export function driver_setOutputFormat(a: number, b: number, c: number, d: number, e: number): void; | ||
export function driver_resetReferences(a: number, b: number, c: number, d: number): void; | ||
export function driver_insertReferences(a: number, b: number, c: number, d: number): void; | ||
export function driver_insertReference(a: number, b: number, c: number): void; | ||
export function driver_removeReference(a: number, b: number, c: number, d: number): void; | ||
export function driver_includeUncited(a: number, b: number, c: number): void; | ||
export function driver_toFetch(a: number, b: number): void; | ||
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_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_insertCluster(a: number, b: number, c: number): void; | ||
export function driver_removeCluster(a: number, b: number, c: number, d: number): void; | ||
export function driver_initClusters(a: number, b: number, c: number, d: number): void; | ||
export function driver_builtCluster(a: number, b: number, c: number, d: number): void; | ||
export function driver_previewCitationCluster(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): void; | ||
export function driver_previewCluster(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void; | ||
export function driver_makeBibliography(a: number, b: number): void; | ||
export function driver_bibliographyMeta(a: number, b: number): void; | ||
export function driver_setClusterOrder(a: number, b: number, c: number, d: number): void; | ||
export function driver_batchedUpdates(a: number, b: number): void; | ||
export function driver_fullRender(a: number, b: number): void; | ||
export function driver_drain(a: number): void; | ||
@@ -30,6 +32,6 @@ export function driver_fetchLocales(a: number): number; | ||
export const __wbindgen_export_2: WebAssembly.Table; | ||
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2c48d2b80cbc9988(a: number, b: number, c: number): void; | ||
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hee74a5b7602953f2(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__h1d8bf0ad0105b2cc(a: number, b: number, c: number, d: number): void; | ||
export function wasm_bindgen__convert__closures__invoke2_mut__h5e049d289685efc8(a: number, b: number, c: number, d: number): void; |
@@ -6,131 +6,6 @@ /* tslint:disable */ | ||
* @param {string} style | ||
* @returns {WasmResult<StyleMeta>} | ||
* @returns {StyleMeta} | ||
*/ | ||
export function parseStyleMetadata(style: string): WasmResult<StyleMeta>; | ||
export function parseStyleMetadata(style: string): 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 Fetcher { | ||
/** Return locale XML for a particular locale. */ | ||
fetchLocale(lang: string): Promise<string>; | ||
} | ||
export type DateLiteral = { "literal": string; }; | ||
export type DateRaw = { "raw": string; }; | ||
export type DatePartsDate = [number] | [number, number] | [number, number, number]; | ||
export type DatePartsSingle = { "date-parts": [DatePartsDate]; }; | ||
export type DatePartsRange = { "date-parts": [DatePartsDate, DatePartsDate]; }; | ||
export type DateParts = DatePartsSingle | DatePartsRange; | ||
export type DateOrRange = DateLiteral | DateRaw | DateParts; | ||
/** Locator type, and a locator string */ | ||
export type Locator = { | ||
label?: string; | ||
locator?: string; | ||
locators: undefined; | ||
}; | ||
export type CiteLocator = Locator | { locator: undefined; locators: Locator[] }; | ||
export type Cite<Affix = string> = { | ||
id: string; | ||
prefix?: Affix; | ||
suffix?: Affix; | ||
suppression?: "InText" | "Rest" | null; | ||
} & Partial<CiteLocator>; | ||
export type ClusterNumber = { | ||
note: number | [number, number] | ||
} | { | ||
inText: number | ||
}; | ||
export type Cluster = { | ||
id: string; | ||
cites: Cite[]; | ||
}; | ||
export type ClusterPosition = { | ||
id: string; | ||
/** Leaving off this field means this cluster is in-text. */ | ||
note?: number; | ||
} | ||
export type Reference = { | ||
id: string; | ||
type: CslType; | ||
[key: string]: any; | ||
}; | ||
export type CslType = "book" | "article" | "legal_case" | "article-journal"; | ||
export interface BibliographyUpdate { | ||
updatedEntries: Map<string, string>; | ||
entryIds?: string[]; | ||
} | ||
export type UpdateSummary<Output = string> = { | ||
clusters: [string, Output][]; | ||
bibliography?: BibliographyUpdate; | ||
}; | ||
type IncludeUncited = "None" | "All" | { Specific: string[] }; | ||
type BibEntry = { | ||
id: string; | ||
value: string; | ||
}; | ||
type BibEntries = BibEntry[]; | ||
type FullRender = { | ||
allClusters: Map<string, string>, | ||
bibEntries: BibEntries, | ||
}; | ||
type BibliographyMeta = { | ||
maxOffset: number; | ||
entrySpacing: number; | ||
lineSpacing: number; | ||
hangingIndent: boolean; | ||
/** the second-field-align value of the CSL style */ | ||
secondFieldAlign: null | "flush" | "margin"; | ||
/** Format-specific metadata */ | ||
formatMeta: any, | ||
}; | ||
type Severity = "Error" | "Warning"; | ||
@@ -146,3 +21,3 @@ interface InvalidCsl { | ||
hint: string | undefined; | ||
}; | ||
} | ||
type StyleError = { | ||
@@ -178,11 +53,23 @@ tag: "Invalid", | ||
declare global { | ||
/** Catch-all citeproc-rs Error subclass. */ | ||
declare class CiteprocRsError extends Error { | ||
/** Catch-all citeproc-rs Error subclass. | ||
* | ||
* CiteprocRsDriverError and CslStyleError are both subclasses of this, so checking instanceof | ||
* CiteprocRsError suffices to catch all errors thrown by @citeproc-rs/wasm itself. | ||
* | ||
* There may be errors that are not a subclass, but directly an instance of CitprocRsError, so | ||
* for completeness in a catch/instanceof check, one should test for this too. | ||
* | ||
* Using the library may also result in WASM runtime errors, and some generic Error objects | ||
* from e.g. using a Driver after you have called `.free()`. | ||
* */ | ||
class CiteprocRsError extends Error { | ||
constructor(message: string); | ||
} | ||
declare class CiteprocRsDriverError extends CiteprocRsError { | ||
/** Error in usage of Driver */ | ||
class CiteprocRsDriverError extends CiteprocRsError { | ||
data: DriverError; | ||
constructor(message: string, data: DriverError); | ||
} | ||
declare class CslStyleError extends CiteprocRsError { | ||
/** Error parsing a CSL file */ | ||
class CslStyleError extends CiteprocRsError { | ||
data: StyleError; | ||
@@ -195,51 +82,125 @@ 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; | ||
interface FormatOptions { | ||
linkAnchors?: boolean; | ||
} | ||
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 (default: html) */ | ||
format?: "html" | "rtf" | "plain"; | ||
/** Configuration for the formatter */ | ||
formatOptions?: FormatOptions; | ||
/** Optional array of CSL feature names to activate globally. Features are kebab-case. */ | ||
cslFeatures?: string[]; | ||
/** 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?: boolean; | ||
} | ||
/** This interface lets citeproc retrieve locales or modules asynchronously, | ||
according to which ones are needed. */ | ||
export interface Fetcher { | ||
/** Return locale XML for a particular locale. */ | ||
fetchLocale(lang: string): Promise<string>; | ||
} | ||
interface BibliographyUpdate { | ||
updatedEntries: Map<string, string>; | ||
entryIds?: string[]; | ||
} | ||
type UpdateSummary<Output = string> = { | ||
clusters: [string, Output][]; | ||
bibliography?: BibliographyUpdate; | ||
}; | ||
interface BibEntry { | ||
id: string; | ||
value: string; | ||
} | ||
interface FullRender { | ||
allClusters: Map<string, string>; | ||
bibEntries: BibEntry[]; | ||
} | ||
interface BibliographyMeta { | ||
maxOffset: number; | ||
entrySpacing: number; | ||
lineSpacing: number; | ||
hangingIndent: boolean; | ||
/** the second-field-align value of the CSL style */ | ||
secondFieldAlign: null | "flush" | "margin"; | ||
/** Format-specific metadata */ | ||
formatMeta: any; | ||
} | ||
interface StyleMeta { | ||
info: StyleInfo; | ||
features: { [feature: string]: boolean }; | ||
defaultLocale: string; | ||
/** May be absent on a dependent style */ | ||
class?: "in-text" | "note"; | ||
cslVersionRequired: string; | ||
/** May be absent on a dependent style */ | ||
independentMeta?: IndependentMeta; | ||
} | ||
type CitationFormat = "author-date" | "author" | "numeric" | "label" | "note"; | ||
interface LocalizedString { | ||
value: string, | ||
lang?: string, | ||
value: string; | ||
lang?: string; | ||
} | ||
interface ParentLink { | ||
href: string, | ||
lang?: string, | ||
href: string; | ||
lang?: string; | ||
} | ||
interface Link { | ||
href: string, | ||
rel: "self" | "documentation" | "template", | ||
lang?: string, | ||
href: string; | ||
rel: "self" | "documentation" | "template"; | ||
lang?: string; | ||
} | ||
interface Rights { | ||
value: string, | ||
lang?: string, | ||
license?: string, | ||
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, | ||
id: string; | ||
updated: string; | ||
title: LocalizedString; | ||
titleShort?: LocalizedString; | ||
parent?: ParentLink; | ||
links: Link[]; | ||
rights?: Rights; | ||
citationFormat?: CitationFormat; | ||
categories: string[]; | ||
issn?: string; | ||
eissn?: string; | ||
issnl?: string; | ||
} | ||
@@ -249,17 +210,69 @@ interface IndependentMeta { | ||
* Does not include the language-less final override. */ | ||
localeOverrides: string[], | ||
hasBibliography: bool, | ||
localeOverrides: string[]; | ||
hasBibliography: boolean; | ||
} | ||
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, | ||
/** Locator type, and a locator string */ | ||
export type Locator = { | ||
label?: string; | ||
locator?: string; | ||
locators: undefined; | ||
}; | ||
export type CiteLocator = Locator | { locator: undefined; locators: Locator[]; }; | ||
export type CiteMode = { mode?: "SuppressAuthor" | "AuthorOnly"; }; | ||
export type Cite = { | ||
id: string; | ||
prefix?: string; | ||
suffix?: string; | ||
} & Partial<CiteLocator> & CiteMode; | ||
export type ClusterMode | ||
= { mode: "Composite"; infix?: string; suppressFirst?: number; } | ||
| { mode: "SuppressAuthor"; suppressFirst?: number; } | ||
| { mode: "AuthorOnly"; } | ||
| {}; | ||
export type Cluster = { | ||
id: string; | ||
cites: Cite[]; | ||
} & ClusterMode; | ||
export type PreviewCluster = { | ||
cites: Cite[]; | ||
} & ClusterMode; | ||
export type ClusterPosition = { | ||
id: string; | ||
/** Leaving off this field means this cluster is in-text. */ | ||
note?: number; | ||
} | ||
type Reference = { | ||
id: string; | ||
type: CslType; | ||
[key: string]: any; | ||
}; | ||
export type CslType = "book" | "legal_case" | "article-journal" | string; | ||
type IncludeUncited = "None" | "All" | { Specific: string[] }; | ||
type DateLiteral = { "literal": string; }; | ||
type DateRaw = { "raw": string; }; | ||
type DatePartsDate = [number] | [number, number] | [number, number, number]; | ||
type DatePartsSingle = { "date-parts": [DatePartsDate]; }; | ||
type DatePartsRange = { "date-parts": [DatePartsDate, DatePartsDate]; }; | ||
type DateParts = DatePartsSingle | DatePartsRange; | ||
type DateOrRange = DateLiteral | DateRaw | DateParts; | ||
/** | ||
@@ -270,26 +283,33 @@ */ | ||
/** | ||
* Creates a new Driver. | ||
* Creates a new Driver. Use the InitOptions object, which has (for example): | ||
* | ||
* * `style` is a CSL style as a string. Independent styles only. | ||
* * `fetcher` must implement the `Fetcher` interface | ||
* * `format` is one of { "html", "rtf" } | ||
* * `format` is one of { "html", "rtf", "plain" } | ||
* | ||
* Throws an error if it cannot parse the style you gave it. | ||
* @param {InitOptions} options | ||
* @returns {WasmResult<Driver>} | ||
*/ | ||
static new(options: InitOptions): WasmResult<Driver>; | ||
constructor(options: InitOptions); | ||
/** | ||
* Sets the style (which will also cause everything to be recomputed) | ||
* Sets the style (which will also cause everything to be recomputed, use sparingly) | ||
* @param {string} style_text | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
setStyle(style_text: string): WasmResult<undefined>; | ||
setStyle(style_text: string): void; | ||
/** | ||
* Sets the output format (which will also cause everything to be recomputed, use sparingly) | ||
* | ||
* @param {"html" | "rtf" | "plain"} format The new output format as a string, same as `new Driver` | ||
* | ||
* @param {FormatOptions | null} options If absent, this is set to the default FormatOptions. | ||
* @param {string} format | ||
* @param {FormatOptions | undefined} options | ||
*/ | ||
setOutputFormat(format: string, options?: FormatOptions): void; | ||
/** | ||
* Completely overwrites the references library. | ||
* This **will** delete references that are not in the provided list. | ||
* @param {any[]} refs | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
resetReferences(refs: any[]): WasmResult<undefined>; | ||
resetReferences(refs: any[]): void; | ||
/** | ||
@@ -299,5 +319,4 @@ * Inserts or overwrites references as a batch operation. | ||
* @param {any[]} refs | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
insertReferences(refs: any[]): WasmResult<undefined>; | ||
insertReferences(refs: any[]): void; | ||
/** | ||
@@ -308,5 +327,4 @@ * Inserts or overwrites a reference. | ||
* @param {Reference} refr | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
insertReference(refr: Reference): WasmResult<undefined>; | ||
insertReference(refr: Reference): void; | ||
/** | ||
@@ -316,5 +334,4 @@ * 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): WasmResult<undefined>; | ||
removeReference(id: string): void; | ||
/** | ||
@@ -325,5 +342,4 @@ * Sets the references to be included in the bibliography despite not being directly cited. | ||
* @param {IncludeUncited} uncited | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
includeUncited(uncited: IncludeUncited): WasmResult<undefined>; | ||
includeUncited(uncited: IncludeUncited): void; | ||
/** | ||
@@ -333,5 +349,5 @@ * Gets a list of locales in use by the references currently loaded. | ||
* Note that Driver comes pre-loaded with the `en-US` locale. | ||
* @returns {WasmResult<string[]>} | ||
* @returns {string[]} | ||
*/ | ||
toFetch(): WasmResult<string[]>; | ||
toFetch(): string[]; | ||
/** | ||
@@ -344,12 +360,10 @@ * Returns a random cluster id, with an extra guarantee that it isn't already in use. | ||
* Inserts or replaces a cluster with a matching `id`. | ||
* @param {any} cluster | ||
* @returns {WasmResult<undefined>} | ||
* @param {Cluster} cluster | ||
*/ | ||
insertCluster(cluster: any): WasmResult<undefined>; | ||
insertCluster(cluster: Cluster): void; | ||
/** | ||
* Removes a cluster with a matching `id` | ||
* @param {string} cluster_id | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
removeCluster(cluster_id: string): WasmResult<undefined>; | ||
removeCluster(cluster_id: string): void; | ||
/** | ||
@@ -360,5 +374,4 @@ * Resets all the clusters in the processor to a new list. | ||
* @param {any[]} clusters | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
initClusters(clusters: any[]): WasmResult<undefined>; | ||
initClusters(clusters: any[]): void; | ||
/** | ||
@@ -370,9 +383,17 @@ * Returns the formatted citation cluster for `cluster_id`. | ||
* @param {string} id | ||
* @returns {WasmResult<string>} | ||
* @returns {string} | ||
*/ | ||
builtCluster(id: string): WasmResult<string>; | ||
builtCluster(id: string): string; | ||
/** | ||
* @deprecated Use `previewCluster` instead | ||
* @param {any[]} cites | ||
* @param {any[]} positions | ||
* @param {string | undefined} format | ||
* @returns {string} | ||
*/ | ||
previewCitationCluster(cites: any[], positions: any[], format?: string): string; | ||
/** | ||
* Previews a formatted citation cluster, in a particular position. | ||
* | ||
* - `cites`: The cites to go in the cluster | ||
* - `cluster`: A cluster, without an `id` field. You'll want this to contain some cites. | ||
* - `positions`: An array of `ClusterPosition`s as in set_cluster_order, but with a single | ||
@@ -382,16 +403,18 @@ * cluster's id set to zero. The cluster with id=0 is the position to preview the cite. It | ||
* any location you can think of. | ||
* @param {any[]} cites | ||
* - `format`: an optional argument, an output format as a string, that is used only for this | ||
* preview. | ||
* @param {PreviewCluster} preview_cluster | ||
* @param {any[]} positions | ||
* @param {string} format | ||
* @returns {WasmResult<string>} | ||
* @param {string | undefined} format | ||
* @returns {string} | ||
*/ | ||
previewCitationCluster(cites: any[], positions: any[], format: string): WasmResult<string>; | ||
previewCluster(preview_cluster: PreviewCluster, positions: any[], format?: string): string; | ||
/** | ||
* @returns {WasmResult<BibEntries>} | ||
* @returns {BibEntry[]} | ||
*/ | ||
makeBibliography(): WasmResult<BibEntries>; | ||
makeBibliography(): BibEntry[]; | ||
/** | ||
* @returns {WasmResult<BibliographyMeta>} | ||
* @returns {BibliographyMeta} | ||
*/ | ||
bibliographyMeta(): WasmResult<BibliographyMeta>; | ||
bibliographyMeta(): BibliographyMeta; | ||
/** | ||
@@ -422,5 +445,4 @@ * Specifies which clusters are actually considered to be in the document, and sets their | ||
* @param {any[]} positions | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
setClusterOrder(positions: any[]): WasmResult<undefined>; | ||
setClusterOrder(positions: any[]): void; | ||
/** | ||
@@ -434,5 +456,5 @@ * Retrieve any clusters that have been touched since last time `batchedUpdates` was | ||
* * returns an `UpdateSummary` | ||
* @returns {WasmResult<UpdateSummary>} | ||
* @returns {UpdateSummary} | ||
*/ | ||
batchedUpdates(): WasmResult<UpdateSummary>; | ||
batchedUpdates(): UpdateSummary; | ||
/** | ||
@@ -442,5 +464,5 @@ * Returns all the clusters and bibliography entries in the document. | ||
* Use this to rehydrate a document or run non-interactively. | ||
* @returns {WasmResult<FullRender>} | ||
* @returns {FullRender} | ||
*/ | ||
fullRender(): WasmResult<FullRender>; | ||
fullRender(): FullRender; | ||
/** | ||
@@ -447,0 +469,0 @@ * Drains the `batchedUpdates` queue manually. |
let imports = {}; | ||
imports['__wbindgen_placeholder__'] = module.exports; | ||
let wasm; | ||
const { WasmResult, CiteprocRsError, CiteprocRsDriverError, CslStyleError } = require(String.raw`./snippets/wasm-1883a0b9dcad429e/src/js/include.js`); | ||
const { TextEncoder, TextDecoder } = require(String.raw`util`); | ||
const { CiteprocRsError, CiteprocRsDriverError, CslStyleError } = require(String.raw`./snippets/wasm-1883a0b9dcad429e/src/js/include.js`); | ||
const { TextDecoder, TextEncoder } = require(`util`); | ||
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
cachedTextDecoder.decode(); | ||
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) { | ||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); | ||
} | ||
const heap = new Array(32).fill(undefined); | ||
@@ -11,6 +27,15 @@ | ||
let heap_next = heap.length; | ||
function addHeapObject(obj) { | ||
if (heap_next === heap.length) heap.push(heap.length + 1); | ||
const idx = heap_next; | ||
heap_next = heap[idx]; | ||
heap[idx] = obj; | ||
return idx; | ||
} | ||
function getObject(idx) { return heap[idx]; } | ||
let heap_next = heap.length; | ||
function dropObject(idx) { | ||
@@ -30,10 +55,2 @@ if (idx < 36) return; | ||
let cachegetUint8Memory0 = null; | ||
function getUint8Memory0() { | ||
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) { | ||
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer); | ||
} | ||
return cachegetUint8Memory0; | ||
} | ||
let cachedTextEncoder = new TextEncoder('utf-8'); | ||
@@ -92,2 +109,6 @@ | ||
function isLikeNone(x) { | ||
return x === undefined || x === null; | ||
} | ||
let cachegetInt32Memory0 = null; | ||
@@ -101,23 +122,2 @@ function getInt32Memory0() { | ||
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
cachedTextDecoder.decode(); | ||
function getStringFromWasm0(ptr, len) { | ||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); | ||
} | ||
function addHeapObject(obj) { | ||
if (heap_next === heap.length) heap.push(heap.length + 1); | ||
const idx = heap_next; | ||
heap_next = heap[idx]; | ||
heap[idx] = obj; | ||
return idx; | ||
} | ||
function isLikeNone(x) { | ||
return x === undefined || x === null; | ||
} | ||
function makeMutClosure(arg0, arg1, dtor, f) { | ||
@@ -148,3 +148,3 @@ const state = { a: arg0, b: arg1, cnt: 1, dtor }; | ||
function __wbg_adapter_24(arg0, arg1, arg2) { | ||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2c48d2b80cbc9988(arg0, arg1, addHeapObject(arg2)); | ||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hee74a5b7602953f2(arg0, arg1, addHeapObject(arg2)); | ||
} | ||
@@ -155,9 +155,20 @@ | ||
* @param {string} style | ||
* @returns {WasmResult<StyleMeta>} | ||
* @returns {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); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(style, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.parseStyleMetadata(retptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
}; | ||
@@ -183,14 +194,11 @@ | ||
function handleError(f) { | ||
return function () { | ||
try { | ||
return f.apply(this, arguments); | ||
} catch (e) { | ||
wasm.__wbindgen_exn_store(addHeapObject(e)); | ||
} | ||
}; | ||
function handleError(f, args) { | ||
try { | ||
return f.apply(this, args); | ||
} catch (e) { | ||
wasm.__wbindgen_exn_store(addHeapObject(e)); | ||
} | ||
} | ||
function __wbg_adapter_81(arg0, arg1, arg2, arg3) { | ||
wasm.wasm_bindgen__convert__closures__invoke2_mut__h1d8bf0ad0105b2cc(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); | ||
function __wbg_adapter_79(arg0, arg1, arg2, arg3) { | ||
wasm.wasm_bindgen__convert__closures__invoke2_mut__h5e049d289685efc8(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); | ||
} | ||
@@ -224,38 +232,88 @@ | ||
/** | ||
* Creates a new Driver. | ||
* Creates a new Driver. Use the InitOptions object, which has (for example): | ||
* | ||
* * `style` is a CSL style as a string. Independent styles only. | ||
* * `fetcher` must implement the `Fetcher` interface | ||
* * `format` is one of { "html", "rtf" } | ||
* * `format` is one of { "html", "rtf", "plain" } | ||
* | ||
* Throws an error if it cannot parse the style you gave it. | ||
* @param {InitOptions} options | ||
* @returns {WasmResult<Driver>} | ||
*/ | ||
static new(options) { | ||
var ret = wasm.driver_new(addHeapObject(options)); | ||
return takeObject(ret); | ||
constructor(options) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_new(retptr, addHeapObject(options)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return Driver.__wrap(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
/** | ||
* Sets the style (which will also cause everything to be recomputed) | ||
* Sets the style (which will also cause everything to be recomputed, use sparingly) | ||
* @param {string} style_text | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
setStyle(style_text) { | ||
var ptr0 = passStringToWasm0(style_text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_setStyle(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(style_text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_setStyle(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
/** | ||
* Sets the output format (which will also cause everything to be recomputed, use sparingly) | ||
* | ||
* @param {"html" | "rtf" | "plain"} format The new output format as a string, same as `new Driver` | ||
* | ||
* @param {FormatOptions | null} options If absent, this is set to the default FormatOptions. | ||
* @param {string} format | ||
* @param {FormatOptions | undefined} options | ||
*/ | ||
setOutputFormat(format, options) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_setOutputFormat(retptr, this.ptr, ptr0, len0, isLikeNone(options) ? 0 : addHeapObject(options)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
/** | ||
* Completely overwrites the references library. | ||
* This **will** delete references that are not in the provided list. | ||
* @param {any[]} refs | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
resetReferences(refs) { | ||
var ptr0 = passArrayJsValueToWasm0(refs, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_resetReferences(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(refs, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_resetReferences(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -266,9 +324,17 @@ /** | ||
* @param {any[]} refs | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
insertReferences(refs) { | ||
var ptr0 = passArrayJsValueToWasm0(refs, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_insertReferences(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(refs, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_insertReferences(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -280,7 +346,15 @@ /** | ||
* @param {Reference} refr | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
insertReference(refr) { | ||
var ret = wasm.driver_insertReference(this.ptr, addHeapObject(refr)); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_insertReference(retptr, this.ptr, addHeapObject(refr)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -291,9 +365,17 @@ /** | ||
* @param {string} id | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
removeReference(id) { | ||
var ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_removeReference(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_removeReference(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -305,7 +387,15 @@ /** | ||
* @param {IncludeUncited} uncited | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
includeUncited(uncited) { | ||
var ret = wasm.driver_includeUncited(this.ptr, addHeapObject(uncited)); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_includeUncited(retptr, this.ptr, addHeapObject(uncited)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -316,7 +406,18 @@ /** | ||
* Note that Driver comes pre-loaded with the `en-US` locale. | ||
* @returns {WasmResult<string[]>} | ||
* @returns {string[]} | ||
*/ | ||
toFetch() { | ||
var ret = wasm.driver_toFetch(this.ptr); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_toFetch(retptr, this.ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -341,8 +442,16 @@ /** | ||
* Inserts or replaces a cluster with a matching `id`. | ||
* @param {any} cluster | ||
* @returns {WasmResult<undefined>} | ||
* @param {Cluster} cluster | ||
*/ | ||
insertCluster(cluster) { | ||
var ret = wasm.driver_insertCluster(this.ptr, addHeapObject(cluster)); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_insertCluster(retptr, this.ptr, addHeapObject(cluster)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -352,9 +461,17 @@ /** | ||
* @param {string} cluster_id | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
removeCluster(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); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(cluster_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_removeCluster(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -366,9 +483,17 @@ /** | ||
* @param {any[]} clusters | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
initClusters(clusters) { | ||
var ptr0 = passArrayJsValueToWasm0(clusters, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_initClusters(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(clusters, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_initClusters(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -381,14 +506,63 @@ /** | ||
* @param {string} id | ||
* @returns {WasmResult<string>} | ||
* @returns {string} | ||
*/ | ||
builtCluster(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); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_builtCluster(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
var r3 = getInt32Memory0()[retptr / 4 + 3]; | ||
var ptr1 = r0; | ||
var len1 = r1; | ||
if (r3) { | ||
ptr1 = 0; len1 = 0; | ||
throw takeObject(r2); | ||
} | ||
return getStringFromWasm0(ptr1, len1); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
wasm.__wbindgen_free(ptr1, len1); | ||
} | ||
} | ||
/** | ||
* @deprecated Use `previewCluster` instead | ||
* @param {any[]} cites | ||
* @param {any[]} positions | ||
* @param {string | undefined} format | ||
* @returns {string} | ||
*/ | ||
previewCitationCluster(cites, positions, format) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(cites, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ptr1 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len1 = WASM_VECTOR_LEN; | ||
var ptr2 = isLikeNone(format) ? 0 : passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len2 = WASM_VECTOR_LEN; | ||
wasm.driver_previewCitationCluster(retptr, this.ptr, ptr0, len0, ptr1, len1, ptr2, len2); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
var r3 = getInt32Memory0()[retptr / 4 + 3]; | ||
var ptr3 = r0; | ||
var len3 = r1; | ||
if (r3) { | ||
ptr3 = 0; len3 = 0; | ||
throw takeObject(r2); | ||
} | ||
return getStringFromWasm0(ptr3, len3); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
wasm.__wbindgen_free(ptr3, len3); | ||
} | ||
} | ||
/** | ||
* Previews a formatted citation cluster, in a particular position. | ||
* | ||
* - `cites`: The cites to go in the cluster | ||
* - `cluster`: A cluster, without an `id` field. You'll want this to contain some cites. | ||
* - `positions`: An array of `ClusterPosition`s as in set_cluster_order, but with a single | ||
@@ -398,30 +572,68 @@ * cluster's id set to zero. The cluster with id=0 is the position to preview the cite. It | ||
* any location you can think of. | ||
* @param {any[]} cites | ||
* - `format`: an optional argument, an output format as a string, that is used only for this | ||
* preview. | ||
* @param {PreviewCluster} preview_cluster | ||
* @param {any[]} positions | ||
* @param {string} format | ||
* @returns {WasmResult<string>} | ||
* @param {string | undefined} format | ||
* @returns {string} | ||
*/ | ||
previewCitationCluster(cites, positions, format) { | ||
var ptr0 = passArrayJsValueToWasm0(cites, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ptr1 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len1 = WASM_VECTOR_LEN; | ||
var ptr2 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len2 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_previewCitationCluster(this.ptr, ptr0, len0, ptr1, len1, ptr2, len2); | ||
return takeObject(ret); | ||
previewCluster(preview_cluster, positions, format) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ptr1 = isLikeNone(format) ? 0 : passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len1 = WASM_VECTOR_LEN; | ||
wasm.driver_previewCluster(retptr, this.ptr, addHeapObject(preview_cluster), ptr0, len0, ptr1, len1); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
var r3 = getInt32Memory0()[retptr / 4 + 3]; | ||
var ptr2 = r0; | ||
var len2 = r1; | ||
if (r3) { | ||
ptr2 = 0; len2 = 0; | ||
throw takeObject(r2); | ||
} | ||
return getStringFromWasm0(ptr2, len2); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
wasm.__wbindgen_free(ptr2, len2); | ||
} | ||
} | ||
/** | ||
* @returns {WasmResult<BibEntries>} | ||
* @returns {BibEntry[]} | ||
*/ | ||
makeBibliography() { | ||
var ret = wasm.driver_makeBibliography(this.ptr); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_makeBibliography(retptr, this.ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
/** | ||
* @returns {WasmResult<BibliographyMeta>} | ||
* @returns {BibliographyMeta} | ||
*/ | ||
bibliographyMeta() { | ||
var ret = wasm.driver_bibliographyMeta(this.ptr); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_bibliographyMeta(retptr, this.ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -453,9 +665,17 @@ /** | ||
* @param {any[]} positions | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
setClusterOrder(positions) { | ||
var ptr0 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_setClusterOrder(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_setClusterOrder(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -470,7 +690,18 @@ /** | ||
* * returns an `UpdateSummary` | ||
* @returns {WasmResult<UpdateSummary>} | ||
* @returns {UpdateSummary} | ||
*/ | ||
batchedUpdates() { | ||
var ret = wasm.driver_batchedUpdates(this.ptr); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_batchedUpdates(retptr, this.ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -481,7 +712,18 @@ /** | ||
* Use this to rehydrate a document or run non-interactively. | ||
* @returns {WasmResult<FullRender>} | ||
* @returns {FullRender} | ||
*/ | ||
fullRender() { | ||
var ret = wasm.driver_fullRender(this.ptr); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_fullRender(retptr, this.ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -506,2 +748,22 @@ /** | ||
module.exports.__wbindgen_string_new = function(arg0, arg1) { | ||
var ret = getStringFromWasm0(arg0, 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.__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.__wbindgen_object_drop_ref = function(arg0) { | ||
@@ -511,2 +773,11 @@ takeObject(arg0); | ||
module.exports.__wbindgen_string_get = function(arg0, arg1) { | ||
const obj = getObject(arg1); | ||
var ret = typeof(obj) === 'string' ? obj : undefined; | ||
var ptr0 = isLikeNone(ret) ? 0 : 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) { | ||
@@ -536,2 +807,28 @@ console.error(takeObject(arg0)); | ||
module.exports.__wbindgen_object_clone_ref = function(arg0) { | ||
var ret = getObject(arg0); | ||
return addHeapObject(ret); | ||
}; | ||
module.exports.__wbg_get_1edc26456ed84f9b = function(arg0, arg1) { | ||
var ret = getObject(arg0)[takeObject(arg1)]; | ||
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.__wbindgen_json_serialize = function(arg0, arg1) { | ||
@@ -546,4 +843,4 @@ const obj = getObject(arg1); | ||
module.exports.__wbindgen_string_new = function(arg0, arg1) { | ||
var ret = getStringFromWasm0(arg0, arg1); | ||
module.exports.__wbg_fetchLocale_d644d4ae2ca50f81 = function(arg0, arg1, arg2) { | ||
var ret = getObject(arg0).fetchLocale(getStringFromWasm0(arg1, arg2)); | ||
return addHeapObject(ret); | ||
@@ -562,12 +859,2 @@ }; | ||
module.exports.__wbg_fetchLocale_d644d4ae2ca50f81 = function(arg0, arg1, arg2) { | ||
var ret = getObject(arg0).fetchLocale(getStringFromWasm0(arg1, arg2)); | ||
return addHeapObject(ret); | ||
}; | ||
module.exports.__wbg_get_1edc26456ed84f9b = function(arg0, arg1) { | ||
var ret = getObject(arg0)[takeObject(arg1)]; | ||
return addHeapObject(ret); | ||
}; | ||
module.exports.__wbindgen_json_parse = function(arg0, arg1) { | ||
@@ -578,49 +865,3 @@ var ret = JSON.parse(getStringFromWasm0(arg0, arg1)); | ||
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_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_new_59cb74e423758ede = function() { | ||
module.exports.__wbg_new_693216e109162396 = function() { | ||
var ret = new Error(); | ||
@@ -630,3 +871,3 @@ return addHeapObject(ret); | ||
module.exports.__wbg_stack_558ba5917b466edd = function(arg0, arg1) { | ||
module.exports.__wbg_stack_0ddaca5d1abfb52f = function(arg0, arg1) { | ||
var ret = getObject(arg1).stack; | ||
@@ -639,3 +880,3 @@ var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
module.exports.__wbg_error_4bb6c2a97407129a = function(arg0, arg1) { | ||
module.exports.__wbg_error_09919627ac0992f5 = function(arg0, arg1) { | ||
try { | ||
@@ -648,8 +889,8 @@ console.error(getStringFromWasm0(arg0, arg1)); | ||
module.exports.__wbg_call_f5e0576f61ee7461 = handleError(function(arg0, arg1, arg2) { | ||
module.exports.__wbg_call_346669c262382ad7 = function() { return handleError(function (arg0, arg1, arg2) { | ||
var ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); | ||
return addHeapObject(ret); | ||
}); | ||
}, arguments) }; | ||
module.exports.__wbg_new_3ea8490cd276c848 = function(arg0, arg1) { | ||
module.exports.__wbg_new_b1d61b5687f5e73a = function(arg0, arg1) { | ||
try { | ||
@@ -661,3 +902,3 @@ var state0 = {a: arg0, b: arg1}; | ||
try { | ||
return __wbg_adapter_81(a, state0.b, arg0, arg1); | ||
return __wbg_adapter_79(a, state0.b, arg0, arg1); | ||
} finally { | ||
@@ -674,3 +915,3 @@ state0.a = a; | ||
module.exports.__wbg_resolve_778af3f90b8e2b59 = function(arg0) { | ||
module.exports.__wbg_resolve_d23068002f584f22 = function(arg0) { | ||
var ret = Promise.resolve(getObject(arg0)); | ||
@@ -680,3 +921,3 @@ return addHeapObject(ret); | ||
module.exports.__wbg_then_367b3e718069cfb9 = function(arg0, arg1) { | ||
module.exports.__wbg_then_2fcac196782070cc = function(arg0, arg1) { | ||
var ret = getObject(arg0).then(getObject(arg1)); | ||
@@ -686,3 +927,3 @@ return addHeapObject(ret); | ||
module.exports.__wbg_then_ac66ca61394bfd21 = function(arg0, arg1, arg2) { | ||
module.exports.__wbg_then_8c2d62e8ae5978f7 = function(arg0, arg1, arg2) { | ||
var ret = getObject(arg0).then(getObject(arg1), getObject(arg2)); | ||
@@ -692,6 +933,6 @@ return addHeapObject(ret); | ||
module.exports.__wbg_self_1c83eb4471d9eb9b = handleError(function() { | ||
module.exports.__wbg_self_1c83eb4471d9eb9b = function() { return handleError(function () { | ||
var ret = self.self; | ||
return addHeapObject(ret); | ||
}); | ||
}, arguments) }; | ||
@@ -731,11 +972,2 @@ module.exports.__wbg_static_accessor_MODULE_abf5ae284bffdf45 = function() { | ||
module.exports.__wbindgen_string_get = function(arg0, arg1) { | ||
const obj = getObject(arg1); | ||
var ret = typeof(obj) === 'string' ? obj : undefined; | ||
var ptr0 = isLikeNone(ret) ? 0 : 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_throw = function(arg0, arg1) { | ||
@@ -745,4 +977,4 @@ throw new Error(getStringFromWasm0(arg0, arg1)); | ||
module.exports.__wbindgen_closure_wrapper917 = function(arg0, arg1, arg2) { | ||
var ret = makeMutClosure(arg0, arg1, 222, __wbg_adapter_24); | ||
module.exports.__wbindgen_closure_wrapper950 = function(arg0, arg1, arg2) { | ||
var ret = makeMutClosure(arg0, arg1, 232, __wbg_adapter_24); | ||
return addHeapObject(ret); | ||
@@ -749,0 +981,0 @@ }; |
@@ -1,52 +0,1 @@ | ||
class WasmResult { | ||
constructor(value) { | ||
if (value instanceof Error) { | ||
this.Err = value; | ||
} else { | ||
this.Ok = value; | ||
} | ||
} | ||
is_err() { | ||
return this.hasOwnProperty("Err"); | ||
} | ||
is_ok() { | ||
return !this.is_err(); | ||
} | ||
unwrap() { | ||
if (this.is_ok()) { | ||
return this.Ok; | ||
} else { | ||
throw this.Err; | ||
} | ||
} | ||
unwrap_err() { | ||
if (this.is_ok()) { | ||
throw new Error("Called unwrap_err on an Ok value"); | ||
} else { | ||
return this.Err; | ||
} | ||
} | ||
unwrap_or(otherwise) { | ||
if (this.is_ok()) { | ||
return this.Ok; | ||
} else { | ||
return otherwise; | ||
} | ||
} | ||
map(func) { | ||
if (this.is_ok()) { | ||
return new WasmResult(func(this.Ok)); | ||
} else { | ||
return this; | ||
} | ||
} | ||
map_or(otherwise, func) { | ||
if (this.is_ok()) { | ||
return func(this.Ok); | ||
} else { | ||
return otherwise; | ||
} | ||
} | ||
} | ||
class CiteprocRsError extends Error { | ||
@@ -74,3 +23,2 @@ constructor(message) { | ||
function doExport(onto) { | ||
onto.WasmResult = WasmResult; | ||
onto.CiteprocRsError = CiteprocRsError; | ||
@@ -77,0 +25,0 @@ onto.CslStyleError = CslStyleError; |
@@ -1,4 +0,22 @@ | ||
import { WasmResult, CiteprocRsError, CiteprocRsDriverError, CslStyleError } from './snippets/wasm-1883a0b9dcad429e/src/js/include.js'; | ||
import { CiteprocRsError, CiteprocRsDriverError, CslStyleError } from './snippets/wasm-1883a0b9dcad429e/src/js/include.js'; | ||
import * as wasm from './citeproc_rs_wasm_bg.wasm'; | ||
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder; | ||
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
cachedTextDecoder.decode(); | ||
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) { | ||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); | ||
} | ||
const heap = new Array(32).fill(undefined); | ||
@@ -8,6 +26,15 @@ | ||
let heap_next = heap.length; | ||
function addHeapObject(obj) { | ||
if (heap_next === heap.length) heap.push(heap.length + 1); | ||
const idx = heap_next; | ||
heap_next = heap[idx]; | ||
heap[idx] = obj; | ||
return idx; | ||
} | ||
function getObject(idx) { return heap[idx]; } | ||
let heap_next = heap.length; | ||
function dropObject(idx) { | ||
@@ -27,10 +54,2 @@ if (idx < 36) return; | ||
let cachegetUint8Memory0 = null; | ||
function getUint8Memory0() { | ||
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) { | ||
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer); | ||
} | ||
return cachegetUint8Memory0; | ||
} | ||
const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder; | ||
@@ -91,2 +110,6 @@ | ||
function isLikeNone(x) { | ||
return x === undefined || x === null; | ||
} | ||
let cachegetInt32Memory0 = null; | ||
@@ -100,25 +123,2 @@ function getInt32Memory0() { | ||
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder; | ||
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
cachedTextDecoder.decode(); | ||
function getStringFromWasm0(ptr, len) { | ||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); | ||
} | ||
function addHeapObject(obj) { | ||
if (heap_next === heap.length) heap.push(heap.length + 1); | ||
const idx = heap_next; | ||
heap_next = heap[idx]; | ||
heap[idx] = obj; | ||
return idx; | ||
} | ||
function isLikeNone(x) { | ||
return x === undefined || x === null; | ||
} | ||
function makeMutClosure(arg0, arg1, dtor, f) { | ||
@@ -149,3 +149,3 @@ const state = { a: arg0, b: arg1, cnt: 1, dtor }; | ||
function __wbg_adapter_24(arg0, arg1, arg2) { | ||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2c48d2b80cbc9988(arg0, arg1, addHeapObject(arg2)); | ||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hee74a5b7602953f2(arg0, arg1, addHeapObject(arg2)); | ||
} | ||
@@ -156,9 +156,20 @@ | ||
* @param {string} style | ||
* @returns {WasmResult<StyleMeta>} | ||
* @returns {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); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(style, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.parseStyleMetadata(retptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -184,14 +195,11 @@ | ||
function handleError(f) { | ||
return function () { | ||
try { | ||
return f.apply(this, arguments); | ||
} catch (e) { | ||
wasm.__wbindgen_exn_store(addHeapObject(e)); | ||
} | ||
}; | ||
function handleError(f, args) { | ||
try { | ||
return f.apply(this, args); | ||
} catch (e) { | ||
wasm.__wbindgen_exn_store(addHeapObject(e)); | ||
} | ||
} | ||
function __wbg_adapter_81(arg0, arg1, arg2, arg3) { | ||
wasm.wasm_bindgen__convert__closures__invoke2_mut__h1d8bf0ad0105b2cc(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); | ||
function __wbg_adapter_79(arg0, arg1, arg2, arg3) { | ||
wasm.wasm_bindgen__convert__closures__invoke2_mut__h5e049d289685efc8(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); | ||
} | ||
@@ -225,38 +233,88 @@ | ||
/** | ||
* Creates a new Driver. | ||
* Creates a new Driver. Use the InitOptions object, which has (for example): | ||
* | ||
* * `style` is a CSL style as a string. Independent styles only. | ||
* * `fetcher` must implement the `Fetcher` interface | ||
* * `format` is one of { "html", "rtf" } | ||
* * `format` is one of { "html", "rtf", "plain" } | ||
* | ||
* Throws an error if it cannot parse the style you gave it. | ||
* @param {InitOptions} options | ||
* @returns {WasmResult<Driver>} | ||
*/ | ||
static new(options) { | ||
var ret = wasm.driver_new(addHeapObject(options)); | ||
return takeObject(ret); | ||
constructor(options) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_new(retptr, addHeapObject(options)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return Driver.__wrap(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
/** | ||
* Sets the style (which will also cause everything to be recomputed) | ||
* Sets the style (which will also cause everything to be recomputed, use sparingly) | ||
* @param {string} style_text | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
setStyle(style_text) { | ||
var ptr0 = passStringToWasm0(style_text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_setStyle(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(style_text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_setStyle(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
/** | ||
* Sets the output format (which will also cause everything to be recomputed, use sparingly) | ||
* | ||
* @param {"html" | "rtf" | "plain"} format The new output format as a string, same as `new Driver` | ||
* | ||
* @param {FormatOptions | null} options If absent, this is set to the default FormatOptions. | ||
* @param {string} format | ||
* @param {FormatOptions | undefined} options | ||
*/ | ||
setOutputFormat(format, options) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_setOutputFormat(retptr, this.ptr, ptr0, len0, isLikeNone(options) ? 0 : addHeapObject(options)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
/** | ||
* Completely overwrites the references library. | ||
* This **will** delete references that are not in the provided list. | ||
* @param {any[]} refs | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
resetReferences(refs) { | ||
var ptr0 = passArrayJsValueToWasm0(refs, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_resetReferences(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(refs, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_resetReferences(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -267,9 +325,17 @@ /** | ||
* @param {any[]} refs | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
insertReferences(refs) { | ||
var ptr0 = passArrayJsValueToWasm0(refs, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_insertReferences(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(refs, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_insertReferences(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -281,7 +347,15 @@ /** | ||
* @param {Reference} refr | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
insertReference(refr) { | ||
var ret = wasm.driver_insertReference(this.ptr, addHeapObject(refr)); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_insertReference(retptr, this.ptr, addHeapObject(refr)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -292,9 +366,17 @@ /** | ||
* @param {string} id | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
removeReference(id) { | ||
var ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_removeReference(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_removeReference(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -306,7 +388,15 @@ /** | ||
* @param {IncludeUncited} uncited | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
includeUncited(uncited) { | ||
var ret = wasm.driver_includeUncited(this.ptr, addHeapObject(uncited)); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_includeUncited(retptr, this.ptr, addHeapObject(uncited)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -317,7 +407,18 @@ /** | ||
* Note that Driver comes pre-loaded with the `en-US` locale. | ||
* @returns {WasmResult<string[]>} | ||
* @returns {string[]} | ||
*/ | ||
toFetch() { | ||
var ret = wasm.driver_toFetch(this.ptr); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_toFetch(retptr, this.ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -342,8 +443,16 @@ /** | ||
* Inserts or replaces a cluster with a matching `id`. | ||
* @param {any} cluster | ||
* @returns {WasmResult<undefined>} | ||
* @param {Cluster} cluster | ||
*/ | ||
insertCluster(cluster) { | ||
var ret = wasm.driver_insertCluster(this.ptr, addHeapObject(cluster)); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_insertCluster(retptr, this.ptr, addHeapObject(cluster)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -353,9 +462,17 @@ /** | ||
* @param {string} cluster_id | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
removeCluster(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); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(cluster_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_removeCluster(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -367,9 +484,17 @@ /** | ||
* @param {any[]} clusters | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
initClusters(clusters) { | ||
var ptr0 = passArrayJsValueToWasm0(clusters, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_initClusters(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(clusters, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_initClusters(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -382,14 +507,63 @@ /** | ||
* @param {string} id | ||
* @returns {WasmResult<string>} | ||
* @returns {string} | ||
*/ | ||
builtCluster(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); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_builtCluster(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
var r3 = getInt32Memory0()[retptr / 4 + 3]; | ||
var ptr1 = r0; | ||
var len1 = r1; | ||
if (r3) { | ||
ptr1 = 0; len1 = 0; | ||
throw takeObject(r2); | ||
} | ||
return getStringFromWasm0(ptr1, len1); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
wasm.__wbindgen_free(ptr1, len1); | ||
} | ||
} | ||
/** | ||
* @deprecated Use `previewCluster` instead | ||
* @param {any[]} cites | ||
* @param {any[]} positions | ||
* @param {string | undefined} format | ||
* @returns {string} | ||
*/ | ||
previewCitationCluster(cites, positions, format) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(cites, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ptr1 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len1 = WASM_VECTOR_LEN; | ||
var ptr2 = isLikeNone(format) ? 0 : passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len2 = WASM_VECTOR_LEN; | ||
wasm.driver_previewCitationCluster(retptr, this.ptr, ptr0, len0, ptr1, len1, ptr2, len2); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
var r3 = getInt32Memory0()[retptr / 4 + 3]; | ||
var ptr3 = r0; | ||
var len3 = r1; | ||
if (r3) { | ||
ptr3 = 0; len3 = 0; | ||
throw takeObject(r2); | ||
} | ||
return getStringFromWasm0(ptr3, len3); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
wasm.__wbindgen_free(ptr3, len3); | ||
} | ||
} | ||
/** | ||
* Previews a formatted citation cluster, in a particular position. | ||
* | ||
* - `cites`: The cites to go in the cluster | ||
* - `cluster`: A cluster, without an `id` field. You'll want this to contain some cites. | ||
* - `positions`: An array of `ClusterPosition`s as in set_cluster_order, but with a single | ||
@@ -399,30 +573,68 @@ * cluster's id set to zero. The cluster with id=0 is the position to preview the cite. It | ||
* any location you can think of. | ||
* @param {any[]} cites | ||
* - `format`: an optional argument, an output format as a string, that is used only for this | ||
* preview. | ||
* @param {PreviewCluster} preview_cluster | ||
* @param {any[]} positions | ||
* @param {string} format | ||
* @returns {WasmResult<string>} | ||
* @param {string | undefined} format | ||
* @returns {string} | ||
*/ | ||
previewCitationCluster(cites, positions, format) { | ||
var ptr0 = passArrayJsValueToWasm0(cites, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ptr1 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len1 = WASM_VECTOR_LEN; | ||
var ptr2 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len2 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_previewCitationCluster(this.ptr, ptr0, len0, ptr1, len1, ptr2, len2); | ||
return takeObject(ret); | ||
previewCluster(preview_cluster, positions, format) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ptr1 = isLikeNone(format) ? 0 : passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len1 = WASM_VECTOR_LEN; | ||
wasm.driver_previewCluster(retptr, this.ptr, addHeapObject(preview_cluster), ptr0, len0, ptr1, len1); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
var r3 = getInt32Memory0()[retptr / 4 + 3]; | ||
var ptr2 = r0; | ||
var len2 = r1; | ||
if (r3) { | ||
ptr2 = 0; len2 = 0; | ||
throw takeObject(r2); | ||
} | ||
return getStringFromWasm0(ptr2, len2); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
wasm.__wbindgen_free(ptr2, len2); | ||
} | ||
} | ||
/** | ||
* @returns {WasmResult<BibEntries>} | ||
* @returns {BibEntry[]} | ||
*/ | ||
makeBibliography() { | ||
var ret = wasm.driver_makeBibliography(this.ptr); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_makeBibliography(retptr, this.ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
/** | ||
* @returns {WasmResult<BibliographyMeta>} | ||
* @returns {BibliographyMeta} | ||
*/ | ||
bibliographyMeta() { | ||
var ret = wasm.driver_bibliographyMeta(this.ptr); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_bibliographyMeta(retptr, this.ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -454,9 +666,17 @@ /** | ||
* @param {any[]} positions | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
setClusterOrder(positions) { | ||
var ptr0 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_setClusterOrder(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_setClusterOrder(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -471,7 +691,18 @@ /** | ||
* * returns an `UpdateSummary` | ||
* @returns {WasmResult<UpdateSummary>} | ||
* @returns {UpdateSummary} | ||
*/ | ||
batchedUpdates() { | ||
var ret = wasm.driver_batchedUpdates(this.ptr); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_batchedUpdates(retptr, this.ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -482,7 +713,18 @@ /** | ||
* Use this to rehydrate a document or run non-interactively. | ||
* @returns {WasmResult<FullRender>} | ||
* @returns {FullRender} | ||
*/ | ||
fullRender() { | ||
var ret = wasm.driver_fullRender(this.ptr); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_fullRender(retptr, this.ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -506,34 +748,30 @@ /** | ||
export const __wbindgen_object_drop_ref = function(arg0) { | ||
takeObject(arg0); | ||
export function __wbindgen_string_new(arg0, arg1) { | ||
var ret = getStringFromWasm0(arg0, arg1); | ||
return addHeapObject(ret); | ||
}; | ||
export const __wbg_error_e549f7fed6d655aa = function(arg0) { | ||
console.error(takeObject(arg0)); | ||
export function __wbg_new_8d5f3cd64eaaa8b5(arg0, arg1) { | ||
var ret = new CiteprocRsDriverError(takeObject(arg0), takeObject(arg1)); | ||
return addHeapObject(ret); | ||
}; | ||
export const __wbg_debug_4885c3f7d6f044a3 = function(arg0, arg1) { | ||
console.debug(getStringFromWasm0(arg0, arg1)); | ||
export function __wbg_new_f12987d5c30f0ab7(arg0) { | ||
var ret = new CiteprocRsError(takeObject(arg0)); | ||
return addHeapObject(ret); | ||
}; | ||
export const __wbg_log_bee3ea1a89f334d8 = function(arg0, arg1) { | ||
console.log(getStringFromWasm0(arg0, arg1)); | ||
export function __wbg_new_c5e56e6577bc2b6a(arg0, arg1) { | ||
var ret = new CslStyleError(takeObject(arg0), takeObject(arg1)); | ||
return addHeapObject(ret); | ||
}; | ||
export const __wbg_info_0547ff9513f2019b = function(arg0, arg1) { | ||
console.info(getStringFromWasm0(arg0, arg1)); | ||
export function __wbindgen_object_drop_ref(arg0) { | ||
takeObject(arg0); | ||
}; | ||
export const __wbg_warn_a478dea6e6e05394 = function(arg0, arg1) { | ||
console.warn(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
export const __wbg_error_72e88ba6901b6eee = function(arg0, arg1) { | ||
console.error(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
export const __wbindgen_json_serialize = function(arg0, arg1) { | ||
export function __wbindgen_string_get(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 ret = typeof(obj) === 'string' ? obj : undefined; | ||
var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
@@ -544,63 +782,37 @@ getInt32Memory0()[arg0 / 4 + 1] = len0; | ||
export const __wbindgen_string_new = function(arg0, arg1) { | ||
var ret = getStringFromWasm0(arg0, arg1); | ||
return addHeapObject(ret); | ||
export function __wbg_error_e549f7fed6d655aa(arg0) { | ||
console.error(takeObject(arg0)); | ||
}; | ||
export const __wbindgen_cb_drop = function(arg0) { | ||
const obj = takeObject(arg0).original; | ||
if (obj.cnt-- == 1) { | ||
obj.a = 0; | ||
return true; | ||
} | ||
var ret = false; | ||
return ret; | ||
export function __wbg_debug_4885c3f7d6f044a3(arg0, arg1) { | ||
console.debug(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
export const __wbg_fetchLocale_d644d4ae2ca50f81 = function(arg0, arg1, arg2) { | ||
var ret = getObject(arg0).fetchLocale(getStringFromWasm0(arg1, arg2)); | ||
return addHeapObject(ret); | ||
export function __wbg_log_bee3ea1a89f334d8(arg0, arg1) { | ||
console.log(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
export const __wbg_get_1edc26456ed84f9b = function(arg0, arg1) { | ||
var ret = getObject(arg0)[takeObject(arg1)]; | ||
return addHeapObject(ret); | ||
export function __wbg_info_0547ff9513f2019b(arg0, arg1) { | ||
console.info(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
export const __wbindgen_json_parse = function(arg0, arg1) { | ||
var ret = JSON.parse(getStringFromWasm0(arg0, arg1)); | ||
return addHeapObject(ret); | ||
export function __wbg_warn_a478dea6e6e05394(arg0, arg1) { | ||
console.warn(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
export const __wbg_driver_new = function(arg0) { | ||
var ret = Driver.__wrap(arg0); | ||
return addHeapObject(ret); | ||
export function __wbg_error_72e88ba6901b6eee(arg0, arg1) { | ||
console.error(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
export const __wbg_new_f12987d5c30f0ab7 = function(arg0) { | ||
var ret = new CiteprocRsError(takeObject(arg0)); | ||
export function __wbindgen_object_clone_ref(arg0) { | ||
var ret = getObject(arg0); | ||
return addHeapObject(ret); | ||
}; | ||
export const __wbg_new_c5e56e6577bc2b6a = function(arg0, arg1) { | ||
var ret = new CslStyleError(takeObject(arg0), takeObject(arg1)); | ||
export function __wbg_get_1edc26456ed84f9b(arg0, arg1) { | ||
var ret = getObject(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_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) { | ||
export function __wbindgen_is_undefined(arg0) { | ||
var ret = getObject(arg0) === undefined; | ||
@@ -610,3 +822,3 @@ return ret; | ||
export const __wbindgen_is_object = function(arg0) { | ||
export function __wbindgen_is_object(arg0) { | ||
const val = getObject(arg0); | ||
@@ -617,3 +829,3 @@ var ret = typeof(val) === 'object' && val !== null; | ||
export const __wbindgen_is_function = function(arg0) { | ||
export function __wbindgen_is_function(arg0) { | ||
var ret = typeof(getObject(arg0)) === 'function'; | ||
@@ -623,3 +835,32 @@ return ret; | ||
export const __wbg_new_59cb74e423758ede = function() { | ||
export function __wbindgen_json_serialize(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 function __wbg_fetchLocale_d644d4ae2ca50f81(arg0, arg1, arg2) { | ||
var ret = getObject(arg0).fetchLocale(getStringFromWasm0(arg1, arg2)); | ||
return addHeapObject(ret); | ||
}; | ||
export function __wbindgen_cb_drop(arg0) { | ||
const obj = takeObject(arg0).original; | ||
if (obj.cnt-- == 1) { | ||
obj.a = 0; | ||
return true; | ||
} | ||
var ret = false; | ||
return ret; | ||
}; | ||
export function __wbindgen_json_parse(arg0, arg1) { | ||
var ret = JSON.parse(getStringFromWasm0(arg0, arg1)); | ||
return addHeapObject(ret); | ||
}; | ||
export function __wbg_new_693216e109162396() { | ||
var ret = new Error(); | ||
@@ -629,3 +870,3 @@ return addHeapObject(ret); | ||
export const __wbg_stack_558ba5917b466edd = function(arg0, arg1) { | ||
export function __wbg_stack_0ddaca5d1abfb52f(arg0, arg1) { | ||
var ret = getObject(arg1).stack; | ||
@@ -638,3 +879,3 @@ var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
export const __wbg_error_4bb6c2a97407129a = function(arg0, arg1) { | ||
export function __wbg_error_09919627ac0992f5(arg0, arg1) { | ||
try { | ||
@@ -647,8 +888,8 @@ console.error(getStringFromWasm0(arg0, arg1)); | ||
export const __wbg_call_f5e0576f61ee7461 = handleError(function(arg0, arg1, arg2) { | ||
export function __wbg_call_346669c262382ad7() { return handleError(function (arg0, arg1, arg2) { | ||
var ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); | ||
return addHeapObject(ret); | ||
}); | ||
}, arguments) }; | ||
export const __wbg_new_3ea8490cd276c848 = function(arg0, arg1) { | ||
export function __wbg_new_b1d61b5687f5e73a(arg0, arg1) { | ||
try { | ||
@@ -660,3 +901,3 @@ var state0 = {a: arg0, b: arg1}; | ||
try { | ||
return __wbg_adapter_81(a, state0.b, arg0, arg1); | ||
return __wbg_adapter_79(a, state0.b, arg0, arg1); | ||
} finally { | ||
@@ -673,3 +914,3 @@ state0.a = a; | ||
export const __wbg_resolve_778af3f90b8e2b59 = function(arg0) { | ||
export function __wbg_resolve_d23068002f584f22(arg0) { | ||
var ret = Promise.resolve(getObject(arg0)); | ||
@@ -679,3 +920,3 @@ return addHeapObject(ret); | ||
export const __wbg_then_367b3e718069cfb9 = function(arg0, arg1) { | ||
export function __wbg_then_2fcac196782070cc(arg0, arg1) { | ||
var ret = getObject(arg0).then(getObject(arg1)); | ||
@@ -685,3 +926,3 @@ return addHeapObject(ret); | ||
export const __wbg_then_ac66ca61394bfd21 = function(arg0, arg1, arg2) { | ||
export function __wbg_then_8c2d62e8ae5978f7(arg0, arg1, arg2) { | ||
var ret = getObject(arg0).then(getObject(arg1), getObject(arg2)); | ||
@@ -691,8 +932,8 @@ return addHeapObject(ret); | ||
export const __wbg_self_1c83eb4471d9eb9b = handleError(function() { | ||
export function __wbg_self_1c83eb4471d9eb9b() { return handleError(function () { | ||
var ret = self.self; | ||
return addHeapObject(ret); | ||
}); | ||
}, arguments) }; | ||
export const __wbg_static_accessor_MODULE_abf5ae284bffdf45 = function() { | ||
export function __wbg_static_accessor_MODULE_abf5ae284bffdf45() { | ||
var ret = module; | ||
@@ -702,3 +943,3 @@ return addHeapObject(ret); | ||
export const __wbg_require_5b2b5b594d809d9f = function(arg0, arg1, arg2) { | ||
export function __wbg_require_5b2b5b594d809d9f(arg0, arg1, arg2) { | ||
var ret = getObject(arg0).require(getStringFromWasm0(arg1, arg2)); | ||
@@ -708,3 +949,3 @@ return addHeapObject(ret); | ||
export const __wbg_crypto_c12f14e810edcaa2 = function(arg0) { | ||
export function __wbg_crypto_c12f14e810edcaa2(arg0) { | ||
var ret = getObject(arg0).crypto; | ||
@@ -714,3 +955,3 @@ return addHeapObject(ret); | ||
export const __wbg_msCrypto_679be765111ba775 = function(arg0) { | ||
export function __wbg_msCrypto_679be765111ba775(arg0) { | ||
var ret = getObject(arg0).msCrypto; | ||
@@ -720,3 +961,3 @@ return addHeapObject(ret); | ||
export const __wbg_getRandomValues_05a60bf171bfc2be = function(arg0) { | ||
export function __wbg_getRandomValues_05a60bf171bfc2be(arg0) { | ||
var ret = getObject(arg0).getRandomValues; | ||
@@ -726,27 +967,18 @@ return addHeapObject(ret); | ||
export const __wbg_getRandomValues_3ac1b33c90b52596 = function(arg0, arg1, arg2) { | ||
export function __wbg_getRandomValues_3ac1b33c90b52596(arg0, arg1, arg2) { | ||
getObject(arg0).getRandomValues(getArrayU8FromWasm0(arg1, arg2)); | ||
}; | ||
export const __wbg_randomFillSync_6f956029658662ec = function(arg0, arg1, arg2) { | ||
export function __wbg_randomFillSync_6f956029658662ec(arg0, arg1, arg2) { | ||
getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2)); | ||
}; | ||
export const __wbindgen_string_get = function(arg0, arg1) { | ||
const obj = getObject(arg1); | ||
var ret = typeof(obj) === 'string' ? obj : undefined; | ||
var ptr0 = isLikeNone(ret) ? 0 : 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_throw = function(arg0, arg1) { | ||
export function __wbindgen_throw(arg0, arg1) { | ||
throw new Error(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
export const __wbindgen_closure_wrapper917 = function(arg0, arg1, arg2) { | ||
var ret = makeMutClosure(arg0, arg1, 222, __wbg_adapter_24); | ||
export function __wbindgen_closure_wrapper950(arg0, arg1, arg2) { | ||
var ret = makeMutClosure(arg0, arg1, 232, __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 parseStyleMetadata(a: number, b: number, c: number): void; | ||
export function __wbg_driver_free(a: 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_new(a: number, b: number): void; | ||
export function driver_setStyle(a: number, b: number, c: number, d: number): void; | ||
export function driver_setOutputFormat(a: number, b: number, c: number, d: number, e: number): void; | ||
export function driver_resetReferences(a: number, b: number, c: number, d: number): void; | ||
export function driver_insertReferences(a: number, b: number, c: number, d: number): void; | ||
export function driver_insertReference(a: number, b: number, c: number): void; | ||
export function driver_removeReference(a: number, b: number, c: number, d: number): void; | ||
export function driver_includeUncited(a: number, b: number, c: number): void; | ||
export function driver_toFetch(a: number, b: number): void; | ||
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_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_insertCluster(a: number, b: number, c: number): void; | ||
export function driver_removeCluster(a: number, b: number, c: number, d: number): void; | ||
export function driver_initClusters(a: number, b: number, c: number, d: number): void; | ||
export function driver_builtCluster(a: number, b: number, c: number, d: number): void; | ||
export function driver_previewCitationCluster(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): void; | ||
export function driver_previewCluster(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void; | ||
export function driver_makeBibliography(a: number, b: number): void; | ||
export function driver_bibliographyMeta(a: number, b: number): void; | ||
export function driver_setClusterOrder(a: number, b: number, c: number, d: number): void; | ||
export function driver_batchedUpdates(a: number, b: number): void; | ||
export function driver_fullRender(a: number, b: number): void; | ||
export function driver_drain(a: number): void; | ||
@@ -30,6 +32,6 @@ export function driver_fetchLocales(a: number): number; | ||
export const __wbindgen_export_2: WebAssembly.Table; | ||
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2c48d2b80cbc9988(a: number, b: number, c: number): void; | ||
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hee74a5b7602953f2(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__h1d8bf0ad0105b2cc(a: number, b: number, c: number, d: number): void; | ||
export function wasm_bindgen__convert__closures__invoke2_mut__h5e049d289685efc8(a: number, b: number, c: number, d: number): void; |
@@ -6,131 +6,6 @@ /* tslint:disable */ | ||
* @param {string} style | ||
* @returns {WasmResult<StyleMeta>} | ||
* @returns {StyleMeta} | ||
*/ | ||
export function parseStyleMetadata(style: string): WasmResult<StyleMeta>; | ||
export function parseStyleMetadata(style: string): 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 Fetcher { | ||
/** Return locale XML for a particular locale. */ | ||
fetchLocale(lang: string): Promise<string>; | ||
} | ||
export type DateLiteral = { "literal": string; }; | ||
export type DateRaw = { "raw": string; }; | ||
export type DatePartsDate = [number] | [number, number] | [number, number, number]; | ||
export type DatePartsSingle = { "date-parts": [DatePartsDate]; }; | ||
export type DatePartsRange = { "date-parts": [DatePartsDate, DatePartsDate]; }; | ||
export type DateParts = DatePartsSingle | DatePartsRange; | ||
export type DateOrRange = DateLiteral | DateRaw | DateParts; | ||
/** Locator type, and a locator string */ | ||
export type Locator = { | ||
label?: string; | ||
locator?: string; | ||
locators: undefined; | ||
}; | ||
export type CiteLocator = Locator | { locator: undefined; locators: Locator[] }; | ||
export type Cite<Affix = string> = { | ||
id: string; | ||
prefix?: Affix; | ||
suffix?: Affix; | ||
suppression?: "InText" | "Rest" | null; | ||
} & Partial<CiteLocator>; | ||
export type ClusterNumber = { | ||
note: number | [number, number] | ||
} | { | ||
inText: number | ||
}; | ||
export type Cluster = { | ||
id: string; | ||
cites: Cite[]; | ||
}; | ||
export type ClusterPosition = { | ||
id: string; | ||
/** Leaving off this field means this cluster is in-text. */ | ||
note?: number; | ||
} | ||
export type Reference = { | ||
id: string; | ||
type: CslType; | ||
[key: string]: any; | ||
}; | ||
export type CslType = "book" | "article" | "legal_case" | "article-journal"; | ||
export interface BibliographyUpdate { | ||
updatedEntries: Map<string, string>; | ||
entryIds?: string[]; | ||
} | ||
export type UpdateSummary<Output = string> = { | ||
clusters: [string, Output][]; | ||
bibliography?: BibliographyUpdate; | ||
}; | ||
type IncludeUncited = "None" | "All" | { Specific: string[] }; | ||
type BibEntry = { | ||
id: string; | ||
value: string; | ||
}; | ||
type BibEntries = BibEntry[]; | ||
type FullRender = { | ||
allClusters: Map<string, string>, | ||
bibEntries: BibEntries, | ||
}; | ||
type BibliographyMeta = { | ||
maxOffset: number; | ||
entrySpacing: number; | ||
lineSpacing: number; | ||
hangingIndent: boolean; | ||
/** the second-field-align value of the CSL style */ | ||
secondFieldAlign: null | "flush" | "margin"; | ||
/** Format-specific metadata */ | ||
formatMeta: any, | ||
}; | ||
type Severity = "Error" | "Warning"; | ||
@@ -146,3 +21,3 @@ interface InvalidCsl { | ||
hint: string | undefined; | ||
}; | ||
} | ||
type StyleError = { | ||
@@ -178,11 +53,23 @@ tag: "Invalid", | ||
declare global { | ||
/** Catch-all citeproc-rs Error subclass. */ | ||
declare class CiteprocRsError extends Error { | ||
/** Catch-all citeproc-rs Error subclass. | ||
* | ||
* CiteprocRsDriverError and CslStyleError are both subclasses of this, so checking instanceof | ||
* CiteprocRsError suffices to catch all errors thrown by @citeproc-rs/wasm itself. | ||
* | ||
* There may be errors that are not a subclass, but directly an instance of CitprocRsError, so | ||
* for completeness in a catch/instanceof check, one should test for this too. | ||
* | ||
* Using the library may also result in WASM runtime errors, and some generic Error objects | ||
* from e.g. using a Driver after you have called `.free()`. | ||
* */ | ||
class CiteprocRsError extends Error { | ||
constructor(message: string); | ||
} | ||
declare class CiteprocRsDriverError extends CiteprocRsError { | ||
/** Error in usage of Driver */ | ||
class CiteprocRsDriverError extends CiteprocRsError { | ||
data: DriverError; | ||
constructor(message: string, data: DriverError); | ||
} | ||
declare class CslStyleError extends CiteprocRsError { | ||
/** Error parsing a CSL file */ | ||
class CslStyleError extends CiteprocRsError { | ||
data: StyleError; | ||
@@ -195,51 +82,125 @@ 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; | ||
interface FormatOptions { | ||
linkAnchors?: boolean; | ||
} | ||
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 (default: html) */ | ||
format?: "html" | "rtf" | "plain"; | ||
/** Configuration for the formatter */ | ||
formatOptions?: FormatOptions; | ||
/** Optional array of CSL feature names to activate globally. Features are kebab-case. */ | ||
cslFeatures?: string[]; | ||
/** 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?: boolean; | ||
} | ||
/** This interface lets citeproc retrieve locales or modules asynchronously, | ||
according to which ones are needed. */ | ||
export interface Fetcher { | ||
/** Return locale XML for a particular locale. */ | ||
fetchLocale(lang: string): Promise<string>; | ||
} | ||
interface BibliographyUpdate { | ||
updatedEntries: Map<string, string>; | ||
entryIds?: string[]; | ||
} | ||
type UpdateSummary<Output = string> = { | ||
clusters: [string, Output][]; | ||
bibliography?: BibliographyUpdate; | ||
}; | ||
interface BibEntry { | ||
id: string; | ||
value: string; | ||
} | ||
interface FullRender { | ||
allClusters: Map<string, string>; | ||
bibEntries: BibEntry[]; | ||
} | ||
interface BibliographyMeta { | ||
maxOffset: number; | ||
entrySpacing: number; | ||
lineSpacing: number; | ||
hangingIndent: boolean; | ||
/** the second-field-align value of the CSL style */ | ||
secondFieldAlign: null | "flush" | "margin"; | ||
/** Format-specific metadata */ | ||
formatMeta: any; | ||
} | ||
interface StyleMeta { | ||
info: StyleInfo; | ||
features: { [feature: string]: boolean }; | ||
defaultLocale: string; | ||
/** May be absent on a dependent style */ | ||
class?: "in-text" | "note"; | ||
cslVersionRequired: string; | ||
/** May be absent on a dependent style */ | ||
independentMeta?: IndependentMeta; | ||
} | ||
type CitationFormat = "author-date" | "author" | "numeric" | "label" | "note"; | ||
interface LocalizedString { | ||
value: string, | ||
lang?: string, | ||
value: string; | ||
lang?: string; | ||
} | ||
interface ParentLink { | ||
href: string, | ||
lang?: string, | ||
href: string; | ||
lang?: string; | ||
} | ||
interface Link { | ||
href: string, | ||
rel: "self" | "documentation" | "template", | ||
lang?: string, | ||
href: string; | ||
rel: "self" | "documentation" | "template"; | ||
lang?: string; | ||
} | ||
interface Rights { | ||
value: string, | ||
lang?: string, | ||
license?: string, | ||
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, | ||
id: string; | ||
updated: string; | ||
title: LocalizedString; | ||
titleShort?: LocalizedString; | ||
parent?: ParentLink; | ||
links: Link[]; | ||
rights?: Rights; | ||
citationFormat?: CitationFormat; | ||
categories: string[]; | ||
issn?: string; | ||
eissn?: string; | ||
issnl?: string; | ||
} | ||
@@ -249,17 +210,69 @@ interface IndependentMeta { | ||
* Does not include the language-less final override. */ | ||
localeOverrides: string[], | ||
hasBibliography: bool, | ||
localeOverrides: string[]; | ||
hasBibliography: boolean; | ||
} | ||
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, | ||
/** Locator type, and a locator string */ | ||
export type Locator = { | ||
label?: string; | ||
locator?: string; | ||
locators: undefined; | ||
}; | ||
export type CiteLocator = Locator | { locator: undefined; locators: Locator[]; }; | ||
export type CiteMode = { mode?: "SuppressAuthor" | "AuthorOnly"; }; | ||
export type Cite = { | ||
id: string; | ||
prefix?: string; | ||
suffix?: string; | ||
} & Partial<CiteLocator> & CiteMode; | ||
export type ClusterMode | ||
= { mode: "Composite"; infix?: string; suppressFirst?: number; } | ||
| { mode: "SuppressAuthor"; suppressFirst?: number; } | ||
| { mode: "AuthorOnly"; } | ||
| {}; | ||
export type Cluster = { | ||
id: string; | ||
cites: Cite[]; | ||
} & ClusterMode; | ||
export type PreviewCluster = { | ||
cites: Cite[]; | ||
} & ClusterMode; | ||
export type ClusterPosition = { | ||
id: string; | ||
/** Leaving off this field means this cluster is in-text. */ | ||
note?: number; | ||
} | ||
type Reference = { | ||
id: string; | ||
type: CslType; | ||
[key: string]: any; | ||
}; | ||
export type CslType = "book" | "legal_case" | "article-journal" | string; | ||
type IncludeUncited = "None" | "All" | { Specific: string[] }; | ||
type DateLiteral = { "literal": string; }; | ||
type DateRaw = { "raw": string; }; | ||
type DatePartsDate = [number] | [number, number] | [number, number, number]; | ||
type DatePartsSingle = { "date-parts": [DatePartsDate]; }; | ||
type DatePartsRange = { "date-parts": [DatePartsDate, DatePartsDate]; }; | ||
type DateParts = DatePartsSingle | DatePartsRange; | ||
type DateOrRange = DateLiteral | DateRaw | DateParts; | ||
/** | ||
@@ -270,26 +283,33 @@ */ | ||
/** | ||
* Creates a new Driver. | ||
* Creates a new Driver. Use the InitOptions object, which has (for example): | ||
* | ||
* * `style` is a CSL style as a string. Independent styles only. | ||
* * `fetcher` must implement the `Fetcher` interface | ||
* * `format` is one of { "html", "rtf" } | ||
* * `format` is one of { "html", "rtf", "plain" } | ||
* | ||
* Throws an error if it cannot parse the style you gave it. | ||
* @param {InitOptions} options | ||
* @returns {WasmResult<Driver>} | ||
*/ | ||
static new(options: InitOptions): WasmResult<Driver>; | ||
constructor(options: InitOptions); | ||
/** | ||
* Sets the style (which will also cause everything to be recomputed) | ||
* Sets the style (which will also cause everything to be recomputed, use sparingly) | ||
* @param {string} style_text | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
setStyle(style_text: string): WasmResult<undefined>; | ||
setStyle(style_text: string): void; | ||
/** | ||
* Sets the output format (which will also cause everything to be recomputed, use sparingly) | ||
* | ||
* @param {"html" | "rtf" | "plain"} format The new output format as a string, same as `new Driver` | ||
* | ||
* @param {FormatOptions | null} options If absent, this is set to the default FormatOptions. | ||
* @param {string} format | ||
* @param {FormatOptions | undefined} options | ||
*/ | ||
setOutputFormat(format: string, options?: FormatOptions): void; | ||
/** | ||
* Completely overwrites the references library. | ||
* This **will** delete references that are not in the provided list. | ||
* @param {any[]} refs | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
resetReferences(refs: any[]): WasmResult<undefined>; | ||
resetReferences(refs: any[]): void; | ||
/** | ||
@@ -299,5 +319,4 @@ * Inserts or overwrites references as a batch operation. | ||
* @param {any[]} refs | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
insertReferences(refs: any[]): WasmResult<undefined>; | ||
insertReferences(refs: any[]): void; | ||
/** | ||
@@ -308,5 +327,4 @@ * Inserts or overwrites a reference. | ||
* @param {Reference} refr | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
insertReference(refr: Reference): WasmResult<undefined>; | ||
insertReference(refr: Reference): void; | ||
/** | ||
@@ -316,5 +334,4 @@ * 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): WasmResult<undefined>; | ||
removeReference(id: string): void; | ||
/** | ||
@@ -325,5 +342,4 @@ * Sets the references to be included in the bibliography despite not being directly cited. | ||
* @param {IncludeUncited} uncited | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
includeUncited(uncited: IncludeUncited): WasmResult<undefined>; | ||
includeUncited(uncited: IncludeUncited): void; | ||
/** | ||
@@ -333,5 +349,5 @@ * Gets a list of locales in use by the references currently loaded. | ||
* Note that Driver comes pre-loaded with the `en-US` locale. | ||
* @returns {WasmResult<string[]>} | ||
* @returns {string[]} | ||
*/ | ||
toFetch(): WasmResult<string[]>; | ||
toFetch(): string[]; | ||
/** | ||
@@ -344,12 +360,10 @@ * Returns a random cluster id, with an extra guarantee that it isn't already in use. | ||
* Inserts or replaces a cluster with a matching `id`. | ||
* @param {any} cluster | ||
* @returns {WasmResult<undefined>} | ||
* @param {Cluster} cluster | ||
*/ | ||
insertCluster(cluster: any): WasmResult<undefined>; | ||
insertCluster(cluster: Cluster): void; | ||
/** | ||
* Removes a cluster with a matching `id` | ||
* @param {string} cluster_id | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
removeCluster(cluster_id: string): WasmResult<undefined>; | ||
removeCluster(cluster_id: string): void; | ||
/** | ||
@@ -360,5 +374,4 @@ * Resets all the clusters in the processor to a new list. | ||
* @param {any[]} clusters | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
initClusters(clusters: any[]): WasmResult<undefined>; | ||
initClusters(clusters: any[]): void; | ||
/** | ||
@@ -370,9 +383,17 @@ * Returns the formatted citation cluster for `cluster_id`. | ||
* @param {string} id | ||
* @returns {WasmResult<string>} | ||
* @returns {string} | ||
*/ | ||
builtCluster(id: string): WasmResult<string>; | ||
builtCluster(id: string): string; | ||
/** | ||
* @deprecated Use `previewCluster` instead | ||
* @param {any[]} cites | ||
* @param {any[]} positions | ||
* @param {string | undefined} format | ||
* @returns {string} | ||
*/ | ||
previewCitationCluster(cites: any[], positions: any[], format?: string): string; | ||
/** | ||
* Previews a formatted citation cluster, in a particular position. | ||
* | ||
* - `cites`: The cites to go in the cluster | ||
* - `cluster`: A cluster, without an `id` field. You'll want this to contain some cites. | ||
* - `positions`: An array of `ClusterPosition`s as in set_cluster_order, but with a single | ||
@@ -382,16 +403,18 @@ * cluster's id set to zero. The cluster with id=0 is the position to preview the cite. It | ||
* any location you can think of. | ||
* @param {any[]} cites | ||
* - `format`: an optional argument, an output format as a string, that is used only for this | ||
* preview. | ||
* @param {PreviewCluster} preview_cluster | ||
* @param {any[]} positions | ||
* @param {string} format | ||
* @returns {WasmResult<string>} | ||
* @param {string | undefined} format | ||
* @returns {string} | ||
*/ | ||
previewCitationCluster(cites: any[], positions: any[], format: string): WasmResult<string>; | ||
previewCluster(preview_cluster: PreviewCluster, positions: any[], format?: string): string; | ||
/** | ||
* @returns {WasmResult<BibEntries>} | ||
* @returns {BibEntry[]} | ||
*/ | ||
makeBibliography(): WasmResult<BibEntries>; | ||
makeBibliography(): BibEntry[]; | ||
/** | ||
* @returns {WasmResult<BibliographyMeta>} | ||
* @returns {BibliographyMeta} | ||
*/ | ||
bibliographyMeta(): WasmResult<BibliographyMeta>; | ||
bibliographyMeta(): BibliographyMeta; | ||
/** | ||
@@ -422,5 +445,4 @@ * Specifies which clusters are actually considered to be in the document, and sets their | ||
* @param {any[]} positions | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
setClusterOrder(positions: any[]): WasmResult<undefined>; | ||
setClusterOrder(positions: any[]): void; | ||
/** | ||
@@ -434,5 +456,5 @@ * Retrieve any clusters that have been touched since last time `batchedUpdates` was | ||
* * returns an `UpdateSummary` | ||
* @returns {WasmResult<UpdateSummary>} | ||
* @returns {UpdateSummary} | ||
*/ | ||
batchedUpdates(): WasmResult<UpdateSummary>; | ||
batchedUpdates(): UpdateSummary; | ||
/** | ||
@@ -442,5 +464,5 @@ * Returns all the clusters and bibliography entries in the document. | ||
* Use this to rehydrate a document or run non-interactively. | ||
* @returns {WasmResult<FullRender>} | ||
* @returns {FullRender} | ||
*/ | ||
fullRender(): WasmResult<FullRender>; | ||
fullRender(): FullRender; | ||
/** | ||
@@ -447,0 +469,0 @@ * Drains the `batchedUpdates` queue manually. |
@@ -1,52 +0,1 @@ | ||
export class WasmResult { | ||
constructor(value) { | ||
if (value instanceof Error) { | ||
this.Err = value; | ||
} else { | ||
this.Ok = value; | ||
} | ||
} | ||
is_err() { | ||
return this.hasOwnProperty("Err"); | ||
} | ||
is_ok() { | ||
return !this.is_err(); | ||
} | ||
unwrap() { | ||
if (this.is_ok()) { | ||
return this.Ok; | ||
} else { | ||
throw this.Err; | ||
} | ||
} | ||
unwrap_err() { | ||
if (this.is_ok()) { | ||
throw new Error("Called unwrap_err on an Ok value"); | ||
} else { | ||
return this.Err; | ||
} | ||
} | ||
unwrap_or(otherwise) { | ||
if (this.is_ok()) { | ||
return this.Ok; | ||
} else { | ||
return otherwise; | ||
} | ||
} | ||
map(func) { | ||
if (this.is_ok()) { | ||
return new WasmResult(func(this.Ok)); | ||
} else { | ||
return this; | ||
} | ||
} | ||
map_or(otherwise, func) { | ||
if (this.is_ok()) { | ||
return func(this.Ok); | ||
} else { | ||
return otherwise; | ||
} | ||
} | ||
} | ||
export class CiteprocRsError extends Error { | ||
@@ -74,3 +23,2 @@ constructor(message) { | ||
function doExport(onto) { | ||
onto.WasmResult = WasmResult; | ||
onto.CiteprocRsError = CiteprocRsError; | ||
@@ -77,0 +25,0 @@ onto.CslStyleError = CslStyleError; |
/* tslint:disable */ | ||
/* eslint-disable */ | ||
export const memory: WebAssembly.Memory; | ||
export function parseStyleMetadata(a: number, b: number): number; | ||
export function parseStyleMetadata(a: number, b: number, c: number): void; | ||
export function __wbg_driver_free(a: 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_new(a: number, b: number): void; | ||
export function driver_setStyle(a: number, b: number, c: number, d: number): void; | ||
export function driver_setOutputFormat(a: number, b: number, c: number, d: number, e: number): void; | ||
export function driver_resetReferences(a: number, b: number, c: number, d: number): void; | ||
export function driver_insertReferences(a: number, b: number, c: number, d: number): void; | ||
export function driver_insertReference(a: number, b: number, c: number): void; | ||
export function driver_removeReference(a: number, b: number, c: number, d: number): void; | ||
export function driver_includeUncited(a: number, b: number, c: number): void; | ||
export function driver_toFetch(a: number, b: number): void; | ||
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_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_insertCluster(a: number, b: number, c: number): void; | ||
export function driver_removeCluster(a: number, b: number, c: number, d: number): void; | ||
export function driver_initClusters(a: number, b: number, c: number, d: number): void; | ||
export function driver_builtCluster(a: number, b: number, c: number, d: number): void; | ||
export function driver_previewCitationCluster(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): void; | ||
export function driver_previewCluster(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void; | ||
export function driver_makeBibliography(a: number, b: number): void; | ||
export function driver_bibliographyMeta(a: number, b: number): void; | ||
export function driver_setClusterOrder(a: number, b: number, c: number, d: number): void; | ||
export function driver_batchedUpdates(a: number, b: number): void; | ||
export function driver_fullRender(a: number, b: number): void; | ||
export function driver_drain(a: number): void; | ||
@@ -30,6 +32,6 @@ export function driver_fetchLocales(a: number): number; | ||
export const __wbindgen_export_2: WebAssembly.Table; | ||
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2c48d2b80cbc9988(a: number, b: number, c: number): void; | ||
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hee74a5b7602953f2(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__h1d8bf0ad0105b2cc(a: number, b: number, c: number, d: number): void; | ||
export function wasm_bindgen__convert__closures__invoke2_mut__h5e049d289685efc8(a: number, b: number, c: number, d: number): void; |
@@ -1,52 +0,1 @@ | ||
class WasmResult { | ||
constructor(value) { | ||
if (value instanceof Error) { | ||
this.Err = value; | ||
} else { | ||
this.Ok = value; | ||
} | ||
} | ||
is_err() { | ||
return this.hasOwnProperty("Err"); | ||
} | ||
is_ok() { | ||
return !this.is_err(); | ||
} | ||
unwrap() { | ||
if (this.is_ok()) { | ||
return this.Ok; | ||
} else { | ||
throw this.Err; | ||
} | ||
} | ||
unwrap_err() { | ||
if (this.is_ok()) { | ||
throw new Error("Called unwrap_err on an Ok value"); | ||
} else { | ||
return this.Err; | ||
} | ||
} | ||
unwrap_or(otherwise) { | ||
if (this.is_ok()) { | ||
return this.Ok; | ||
} else { | ||
return otherwise; | ||
} | ||
} | ||
map(func) { | ||
if (this.is_ok()) { | ||
return new WasmResult(func(this.Ok)); | ||
} else { | ||
return this; | ||
} | ||
} | ||
map_or(otherwise, func) { | ||
if (this.is_ok()) { | ||
return func(this.Ok); | ||
} else { | ||
return otherwise; | ||
} | ||
} | ||
} | ||
class CiteprocRsError extends Error { | ||
@@ -74,3 +23,2 @@ constructor(message) { | ||
function doExport(onto) { | ||
onto.WasmResult = WasmResult; | ||
onto.CiteprocRsError = CiteprocRsError; | ||
@@ -77,0 +25,0 @@ onto.CslStyleError = CslStyleError; |
@@ -7,131 +7,6 @@ declare namespace wasm_bindgen { | ||
* @param {string} style | ||
* @returns {WasmResult<StyleMeta>} | ||
* @returns {StyleMeta} | ||
*/ | ||
export function parseStyleMetadata(style: string): WasmResult<StyleMeta>; | ||
export function parseStyleMetadata(style: string): 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 Fetcher { | ||
/** Return locale XML for a particular locale. */ | ||
fetchLocale(lang: string): Promise<string>; | ||
} | ||
export type DateLiteral = { "literal": string; }; | ||
export type DateRaw = { "raw": string; }; | ||
export type DatePartsDate = [number] | [number, number] | [number, number, number]; | ||
export type DatePartsSingle = { "date-parts": [DatePartsDate]; }; | ||
export type DatePartsRange = { "date-parts": [DatePartsDate, DatePartsDate]; }; | ||
export type DateParts = DatePartsSingle | DatePartsRange; | ||
export type DateOrRange = DateLiteral | DateRaw | DateParts; | ||
/** Locator type, and a locator string */ | ||
export type Locator = { | ||
label?: string; | ||
locator?: string; | ||
locators: undefined; | ||
}; | ||
export type CiteLocator = Locator | { locator: undefined; locators: Locator[] }; | ||
export type Cite<Affix = string> = { | ||
id: string; | ||
prefix?: Affix; | ||
suffix?: Affix; | ||
suppression?: "InText" | "Rest" | null; | ||
} & Partial<CiteLocator>; | ||
export type ClusterNumber = { | ||
note: number | [number, number] | ||
} | { | ||
inText: number | ||
}; | ||
export type Cluster = { | ||
id: string; | ||
cites: Cite[]; | ||
}; | ||
export type ClusterPosition = { | ||
id: string; | ||
/** Leaving off this field means this cluster is in-text. */ | ||
note?: number; | ||
} | ||
export type Reference = { | ||
id: string; | ||
type: CslType; | ||
[key: string]: any; | ||
}; | ||
export type CslType = "book" | "article" | "legal_case" | "article-journal"; | ||
export interface BibliographyUpdate { | ||
updatedEntries: Map<string, string>; | ||
entryIds?: string[]; | ||
} | ||
export type UpdateSummary<Output = string> = { | ||
clusters: [string, Output][]; | ||
bibliography?: BibliographyUpdate; | ||
}; | ||
type IncludeUncited = "None" | "All" | { Specific: string[] }; | ||
type BibEntry = { | ||
id: string; | ||
value: string; | ||
}; | ||
type BibEntries = BibEntry[]; | ||
type FullRender = { | ||
allClusters: Map<string, string>, | ||
bibEntries: BibEntries, | ||
}; | ||
type BibliographyMeta = { | ||
maxOffset: number; | ||
entrySpacing: number; | ||
lineSpacing: number; | ||
hangingIndent: boolean; | ||
/** the second-field-align value of the CSL style */ | ||
secondFieldAlign: null | "flush" | "margin"; | ||
/** Format-specific metadata */ | ||
formatMeta: any, | ||
}; | ||
type Severity = "Error" | "Warning"; | ||
@@ -147,3 +22,3 @@ interface InvalidCsl { | ||
hint: string | undefined; | ||
}; | ||
} | ||
type StyleError = { | ||
@@ -179,11 +54,23 @@ tag: "Invalid", | ||
declare global { | ||
/** Catch-all citeproc-rs Error subclass. */ | ||
declare class CiteprocRsError extends Error { | ||
/** Catch-all citeproc-rs Error subclass. | ||
* | ||
* CiteprocRsDriverError and CslStyleError are both subclasses of this, so checking instanceof | ||
* CiteprocRsError suffices to catch all errors thrown by @citeproc-rs/wasm itself. | ||
* | ||
* There may be errors that are not a subclass, but directly an instance of CitprocRsError, so | ||
* for completeness in a catch/instanceof check, one should test for this too. | ||
* | ||
* Using the library may also result in WASM runtime errors, and some generic Error objects | ||
* from e.g. using a Driver after you have called `.free()`. | ||
* */ | ||
class CiteprocRsError extends Error { | ||
constructor(message: string); | ||
} | ||
declare class CiteprocRsDriverError extends CiteprocRsError { | ||
/** Error in usage of Driver */ | ||
class CiteprocRsDriverError extends CiteprocRsError { | ||
data: DriverError; | ||
constructor(message: string, data: DriverError); | ||
} | ||
declare class CslStyleError extends CiteprocRsError { | ||
/** Error parsing a CSL file */ | ||
class CslStyleError extends CiteprocRsError { | ||
data: StyleError; | ||
@@ -196,51 +83,125 @@ 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; | ||
interface FormatOptions { | ||
linkAnchors?: boolean; | ||
} | ||
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 (default: html) */ | ||
format?: "html" | "rtf" | "plain"; | ||
/** Configuration for the formatter */ | ||
formatOptions?: FormatOptions; | ||
/** Optional array of CSL feature names to activate globally. Features are kebab-case. */ | ||
cslFeatures?: string[]; | ||
/** 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?: boolean; | ||
} | ||
/** This interface lets citeproc retrieve locales or modules asynchronously, | ||
according to which ones are needed. */ | ||
export interface Fetcher { | ||
/** Return locale XML for a particular locale. */ | ||
fetchLocale(lang: string): Promise<string>; | ||
} | ||
interface BibliographyUpdate { | ||
updatedEntries: Map<string, string>; | ||
entryIds?: string[]; | ||
} | ||
type UpdateSummary<Output = string> = { | ||
clusters: [string, Output][]; | ||
bibliography?: BibliographyUpdate; | ||
}; | ||
interface BibEntry { | ||
id: string; | ||
value: string; | ||
} | ||
interface FullRender { | ||
allClusters: Map<string, string>; | ||
bibEntries: BibEntry[]; | ||
} | ||
interface BibliographyMeta { | ||
maxOffset: number; | ||
entrySpacing: number; | ||
lineSpacing: number; | ||
hangingIndent: boolean; | ||
/** the second-field-align value of the CSL style */ | ||
secondFieldAlign: null | "flush" | "margin"; | ||
/** Format-specific metadata */ | ||
formatMeta: any; | ||
} | ||
interface StyleMeta { | ||
info: StyleInfo; | ||
features: { [feature: string]: boolean }; | ||
defaultLocale: string; | ||
/** May be absent on a dependent style */ | ||
class?: "in-text" | "note"; | ||
cslVersionRequired: string; | ||
/** May be absent on a dependent style */ | ||
independentMeta?: IndependentMeta; | ||
} | ||
type CitationFormat = "author-date" | "author" | "numeric" | "label" | "note"; | ||
interface LocalizedString { | ||
value: string, | ||
lang?: string, | ||
value: string; | ||
lang?: string; | ||
} | ||
interface ParentLink { | ||
href: string, | ||
lang?: string, | ||
href: string; | ||
lang?: string; | ||
} | ||
interface Link { | ||
href: string, | ||
rel: "self" | "documentation" | "template", | ||
lang?: string, | ||
href: string; | ||
rel: "self" | "documentation" | "template"; | ||
lang?: string; | ||
} | ||
interface Rights { | ||
value: string, | ||
lang?: string, | ||
license?: string, | ||
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, | ||
id: string; | ||
updated: string; | ||
title: LocalizedString; | ||
titleShort?: LocalizedString; | ||
parent?: ParentLink; | ||
links: Link[]; | ||
rights?: Rights; | ||
citationFormat?: CitationFormat; | ||
categories: string[]; | ||
issn?: string; | ||
eissn?: string; | ||
issnl?: string; | ||
} | ||
@@ -250,17 +211,69 @@ interface IndependentMeta { | ||
* Does not include the language-less final override. */ | ||
localeOverrides: string[], | ||
hasBibliography: bool, | ||
localeOverrides: string[]; | ||
hasBibliography: boolean; | ||
} | ||
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, | ||
/** Locator type, and a locator string */ | ||
export type Locator = { | ||
label?: string; | ||
locator?: string; | ||
locators: undefined; | ||
}; | ||
export type CiteLocator = Locator | { locator: undefined; locators: Locator[]; }; | ||
export type CiteMode = { mode?: "SuppressAuthor" | "AuthorOnly"; }; | ||
export type Cite = { | ||
id: string; | ||
prefix?: string; | ||
suffix?: string; | ||
} & Partial<CiteLocator> & CiteMode; | ||
export type ClusterMode | ||
= { mode: "Composite"; infix?: string; suppressFirst?: number; } | ||
| { mode: "SuppressAuthor"; suppressFirst?: number; } | ||
| { mode: "AuthorOnly"; } | ||
| {}; | ||
export type Cluster = { | ||
id: string; | ||
cites: Cite[]; | ||
} & ClusterMode; | ||
export type PreviewCluster = { | ||
cites: Cite[]; | ||
} & ClusterMode; | ||
export type ClusterPosition = { | ||
id: string; | ||
/** Leaving off this field means this cluster is in-text. */ | ||
note?: number; | ||
} | ||
type Reference = { | ||
id: string; | ||
type: CslType; | ||
[key: string]: any; | ||
}; | ||
export type CslType = "book" | "legal_case" | "article-journal" | string; | ||
type IncludeUncited = "None" | "All" | { Specific: string[] }; | ||
type DateLiteral = { "literal": string; }; | ||
type DateRaw = { "raw": string; }; | ||
type DatePartsDate = [number] | [number, number] | [number, number, number]; | ||
type DatePartsSingle = { "date-parts": [DatePartsDate]; }; | ||
type DatePartsRange = { "date-parts": [DatePartsDate, DatePartsDate]; }; | ||
type DateParts = DatePartsSingle | DatePartsRange; | ||
type DateOrRange = DateLiteral | DateRaw | DateParts; | ||
/** | ||
@@ -271,26 +284,33 @@ */ | ||
/** | ||
* Creates a new Driver. | ||
* Creates a new Driver. Use the InitOptions object, which has (for example): | ||
* | ||
* * `style` is a CSL style as a string. Independent styles only. | ||
* * `fetcher` must implement the `Fetcher` interface | ||
* * `format` is one of { "html", "rtf" } | ||
* * `format` is one of { "html", "rtf", "plain" } | ||
* | ||
* Throws an error if it cannot parse the style you gave it. | ||
* @param {InitOptions} options | ||
* @returns {WasmResult<Driver>} | ||
*/ | ||
static new(options: InitOptions): WasmResult<Driver>; | ||
constructor(options: InitOptions); | ||
/** | ||
* Sets the style (which will also cause everything to be recomputed) | ||
* Sets the style (which will also cause everything to be recomputed, use sparingly) | ||
* @param {string} style_text | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
setStyle(style_text: string): WasmResult<undefined>; | ||
setStyle(style_text: string): void; | ||
/** | ||
* Sets the output format (which will also cause everything to be recomputed, use sparingly) | ||
* | ||
* @param {"html" | "rtf" | "plain"} format The new output format as a string, same as `new Driver` | ||
* | ||
* @param {FormatOptions | null} options If absent, this is set to the default FormatOptions. | ||
* @param {string} format | ||
* @param {FormatOptions | undefined} options | ||
*/ | ||
setOutputFormat(format: string, options?: FormatOptions): void; | ||
/** | ||
* Completely overwrites the references library. | ||
* This **will** delete references that are not in the provided list. | ||
* @param {any[]} refs | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
resetReferences(refs: any[]): WasmResult<undefined>; | ||
resetReferences(refs: any[]): void; | ||
/** | ||
@@ -300,5 +320,4 @@ * Inserts or overwrites references as a batch operation. | ||
* @param {any[]} refs | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
insertReferences(refs: any[]): WasmResult<undefined>; | ||
insertReferences(refs: any[]): void; | ||
/** | ||
@@ -309,5 +328,4 @@ * Inserts or overwrites a reference. | ||
* @param {Reference} refr | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
insertReference(refr: Reference): WasmResult<undefined>; | ||
insertReference(refr: Reference): void; | ||
/** | ||
@@ -317,5 +335,4 @@ * 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): WasmResult<undefined>; | ||
removeReference(id: string): void; | ||
/** | ||
@@ -326,5 +343,4 @@ * Sets the references to be included in the bibliography despite not being directly cited. | ||
* @param {IncludeUncited} uncited | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
includeUncited(uncited: IncludeUncited): WasmResult<undefined>; | ||
includeUncited(uncited: IncludeUncited): void; | ||
/** | ||
@@ -334,5 +350,5 @@ * Gets a list of locales in use by the references currently loaded. | ||
* Note that Driver comes pre-loaded with the `en-US` locale. | ||
* @returns {WasmResult<string[]>} | ||
* @returns {string[]} | ||
*/ | ||
toFetch(): WasmResult<string[]>; | ||
toFetch(): string[]; | ||
/** | ||
@@ -345,12 +361,10 @@ * Returns a random cluster id, with an extra guarantee that it isn't already in use. | ||
* Inserts or replaces a cluster with a matching `id`. | ||
* @param {any} cluster | ||
* @returns {WasmResult<undefined>} | ||
* @param {Cluster} cluster | ||
*/ | ||
insertCluster(cluster: any): WasmResult<undefined>; | ||
insertCluster(cluster: Cluster): void; | ||
/** | ||
* Removes a cluster with a matching `id` | ||
* @param {string} cluster_id | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
removeCluster(cluster_id: string): WasmResult<undefined>; | ||
removeCluster(cluster_id: string): void; | ||
/** | ||
@@ -361,5 +375,4 @@ * Resets all the clusters in the processor to a new list. | ||
* @param {any[]} clusters | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
initClusters(clusters: any[]): WasmResult<undefined>; | ||
initClusters(clusters: any[]): void; | ||
/** | ||
@@ -371,9 +384,17 @@ * Returns the formatted citation cluster for `cluster_id`. | ||
* @param {string} id | ||
* @returns {WasmResult<string>} | ||
* @returns {string} | ||
*/ | ||
builtCluster(id: string): WasmResult<string>; | ||
builtCluster(id: string): string; | ||
/** | ||
* @deprecated Use `previewCluster` instead | ||
* @param {any[]} cites | ||
* @param {any[]} positions | ||
* @param {string | undefined} format | ||
* @returns {string} | ||
*/ | ||
previewCitationCluster(cites: any[], positions: any[], format?: string): string; | ||
/** | ||
* Previews a formatted citation cluster, in a particular position. | ||
* | ||
* - `cites`: The cites to go in the cluster | ||
* - `cluster`: A cluster, without an `id` field. You'll want this to contain some cites. | ||
* - `positions`: An array of `ClusterPosition`s as in set_cluster_order, but with a single | ||
@@ -383,16 +404,18 @@ * cluster's id set to zero. The cluster with id=0 is the position to preview the cite. It | ||
* any location you can think of. | ||
* @param {any[]} cites | ||
* - `format`: an optional argument, an output format as a string, that is used only for this | ||
* preview. | ||
* @param {PreviewCluster} preview_cluster | ||
* @param {any[]} positions | ||
* @param {string} format | ||
* @returns {WasmResult<string>} | ||
* @param {string | undefined} format | ||
* @returns {string} | ||
*/ | ||
previewCitationCluster(cites: any[], positions: any[], format: string): WasmResult<string>; | ||
previewCluster(preview_cluster: PreviewCluster, positions: any[], format?: string): string; | ||
/** | ||
* @returns {WasmResult<BibEntries>} | ||
* @returns {BibEntry[]} | ||
*/ | ||
makeBibliography(): WasmResult<BibEntries>; | ||
makeBibliography(): BibEntry[]; | ||
/** | ||
* @returns {WasmResult<BibliographyMeta>} | ||
* @returns {BibliographyMeta} | ||
*/ | ||
bibliographyMeta(): WasmResult<BibliographyMeta>; | ||
bibliographyMeta(): BibliographyMeta; | ||
/** | ||
@@ -423,5 +446,4 @@ * Specifies which clusters are actually considered to be in the document, and sets their | ||
* @param {any[]} positions | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
setClusterOrder(positions: any[]): WasmResult<undefined>; | ||
setClusterOrder(positions: any[]): void; | ||
/** | ||
@@ -435,5 +457,5 @@ * Retrieve any clusters that have been touched since last time `batchedUpdates` was | ||
* * returns an `UpdateSummary` | ||
* @returns {WasmResult<UpdateSummary>} | ||
* @returns {UpdateSummary} | ||
*/ | ||
batchedUpdates(): WasmResult<UpdateSummary>; | ||
batchedUpdates(): UpdateSummary; | ||
/** | ||
@@ -443,5 +465,5 @@ * Returns all the clusters and bibliography entries in the document. | ||
* Use this to rehydrate a document or run non-interactively. | ||
* @returns {WasmResult<FullRender>} | ||
* @returns {FullRender} | ||
*/ | ||
fullRender(): WasmResult<FullRender>; | ||
fullRender(): FullRender; | ||
/** | ||
@@ -465,23 +487,25 @@ * Drains the `batchedUpdates` queue manually. | ||
readonly memory: WebAssembly.Memory; | ||
readonly parseStyleMetadata: (a: number, b: number) => number; | ||
readonly parseStyleMetadata: (a: number, b: number, c: number) => void; | ||
readonly __wbg_driver_free: (a: 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_new: (a: number, b: number) => void; | ||
readonly driver_setStyle: (a: number, b: number, c: number, d: number) => void; | ||
readonly driver_setOutputFormat: (a: number, b: number, c: number, d: number, e: number) => void; | ||
readonly driver_resetReferences: (a: number, b: number, c: number, d: number) => void; | ||
readonly driver_insertReferences: (a: number, b: number, c: number, d: number) => void; | ||
readonly driver_insertReference: (a: number, b: number, c: number) => void; | ||
readonly driver_removeReference: (a: number, b: number, c: number, d: number) => void; | ||
readonly driver_includeUncited: (a: number, b: number, c: number) => void; | ||
readonly driver_toFetch: (a: number, b: number) => void; | ||
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_setClusterOrder: (a: number, b: number, c: number) => number; | ||
readonly driver_batchedUpdates: (a: number) => number; | ||
readonly driver_fullRender: (a: number) => number; | ||
readonly driver_insertCluster: (a: number, b: number, c: number) => void; | ||
readonly driver_removeCluster: (a: number, b: number, c: number, d: number) => void; | ||
readonly driver_initClusters: (a: number, b: number, c: number, d: number) => void; | ||
readonly driver_builtCluster: (a: number, b: number, c: number, d: number) => void; | ||
readonly driver_previewCitationCluster: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void; | ||
readonly driver_previewCluster: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void; | ||
readonly driver_makeBibliography: (a: number, b: number) => void; | ||
readonly driver_bibliographyMeta: (a: number, b: number) => void; | ||
readonly driver_setClusterOrder: (a: number, b: number, c: number, d: number) => void; | ||
readonly driver_batchedUpdates: (a: number, b: number) => void; | ||
readonly driver_fullRender: (a: number, b: number) => void; | ||
readonly driver_drain: (a: number) => void; | ||
@@ -492,7 +516,7 @@ readonly driver_fetchLocales: (a: number) => number; | ||
readonly __wbindgen_export_2: WebAssembly.Table; | ||
readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2c48d2b80cbc9988: (a: number, b: number, c: number) => void; | ||
readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hee74a5b7602953f2: (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__h1d8bf0ad0105b2cc: (a: number, b: number, c: number, d: number) => void; | ||
readonly wasm_bindgen__convert__closures__invoke2_mut__h5e049d289685efc8: (a: number, b: number, c: number, d: number) => void; | ||
} | ||
@@ -499,0 +523,0 @@ |
@@ -6,2 +6,18 @@ let wasm_bindgen; | ||
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
cachedTextDecoder.decode(); | ||
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) { | ||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); | ||
} | ||
const heap = new Array(32).fill(undefined); | ||
@@ -11,6 +27,15 @@ | ||
let heap_next = heap.length; | ||
function addHeapObject(obj) { | ||
if (heap_next === heap.length) heap.push(heap.length + 1); | ||
const idx = heap_next; | ||
heap_next = heap[idx]; | ||
heap[idx] = obj; | ||
return idx; | ||
} | ||
function getObject(idx) { return heap[idx]; } | ||
let heap_next = heap.length; | ||
function dropObject(idx) { | ||
@@ -30,10 +55,2 @@ if (idx < 36) return; | ||
let cachegetUint8Memory0 = null; | ||
function getUint8Memory0() { | ||
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) { | ||
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer); | ||
} | ||
return cachegetUint8Memory0; | ||
} | ||
let cachedTextEncoder = new TextEncoder('utf-8'); | ||
@@ -92,2 +109,6 @@ | ||
function isLikeNone(x) { | ||
return x === undefined || x === null; | ||
} | ||
let cachegetInt32Memory0 = null; | ||
@@ -101,23 +122,2 @@ function getInt32Memory0() { | ||
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
cachedTextDecoder.decode(); | ||
function getStringFromWasm0(ptr, len) { | ||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); | ||
} | ||
function addHeapObject(obj) { | ||
if (heap_next === heap.length) heap.push(heap.length + 1); | ||
const idx = heap_next; | ||
heap_next = heap[idx]; | ||
heap[idx] = obj; | ||
return idx; | ||
} | ||
function isLikeNone(x) { | ||
return x === undefined || x === null; | ||
} | ||
function makeMutClosure(arg0, arg1, dtor, f) { | ||
@@ -148,3 +148,3 @@ const state = { a: arg0, b: arg1, cnt: 1, dtor }; | ||
function __wbg_adapter_24(arg0, arg1, arg2) { | ||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2c48d2b80cbc9988(arg0, arg1, addHeapObject(arg2)); | ||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hee74a5b7602953f2(arg0, arg1, addHeapObject(arg2)); | ||
} | ||
@@ -155,9 +155,20 @@ | ||
* @param {string} style | ||
* @returns {WasmResult<StyleMeta>} | ||
* @returns {StyleMeta} | ||
*/ | ||
__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); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(style, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.parseStyleMetadata(retptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
}; | ||
@@ -183,14 +194,11 @@ | ||
function handleError(f) { | ||
return function () { | ||
try { | ||
return f.apply(this, arguments); | ||
} catch (e) { | ||
wasm.__wbindgen_exn_store(addHeapObject(e)); | ||
} | ||
}; | ||
function handleError(f, args) { | ||
try { | ||
return f.apply(this, args); | ||
} catch (e) { | ||
wasm.__wbindgen_exn_store(addHeapObject(e)); | ||
} | ||
} | ||
function __wbg_adapter_81(arg0, arg1, arg2, arg3) { | ||
wasm.wasm_bindgen__convert__closures__invoke2_mut__h1d8bf0ad0105b2cc(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); | ||
function __wbg_adapter_79(arg0, arg1, arg2, arg3) { | ||
wasm.wasm_bindgen__convert__closures__invoke2_mut__h5e049d289685efc8(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); | ||
} | ||
@@ -224,38 +232,88 @@ | ||
/** | ||
* Creates a new Driver. | ||
* Creates a new Driver. Use the InitOptions object, which has (for example): | ||
* | ||
* * `style` is a CSL style as a string. Independent styles only. | ||
* * `fetcher` must implement the `Fetcher` interface | ||
* * `format` is one of { "html", "rtf" } | ||
* * `format` is one of { "html", "rtf", "plain" } | ||
* | ||
* Throws an error if it cannot parse the style you gave it. | ||
* @param {InitOptions} options | ||
* @returns {WasmResult<Driver>} | ||
*/ | ||
static new(options) { | ||
var ret = wasm.driver_new(addHeapObject(options)); | ||
return takeObject(ret); | ||
constructor(options) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_new(retptr, addHeapObject(options)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return Driver.__wrap(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
/** | ||
* Sets the style (which will also cause everything to be recomputed) | ||
* Sets the style (which will also cause everything to be recomputed, use sparingly) | ||
* @param {string} style_text | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
setStyle(style_text) { | ||
var ptr0 = passStringToWasm0(style_text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_setStyle(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(style_text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_setStyle(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
/** | ||
* Sets the output format (which will also cause everything to be recomputed, use sparingly) | ||
* | ||
* @param {"html" | "rtf" | "plain"} format The new output format as a string, same as `new Driver` | ||
* | ||
* @param {FormatOptions | null} options If absent, this is set to the default FormatOptions. | ||
* @param {string} format | ||
* @param {FormatOptions | undefined} options | ||
*/ | ||
setOutputFormat(format, options) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_setOutputFormat(retptr, this.ptr, ptr0, len0, isLikeNone(options) ? 0 : addHeapObject(options)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
/** | ||
* Completely overwrites the references library. | ||
* This **will** delete references that are not in the provided list. | ||
* @param {any[]} refs | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
resetReferences(refs) { | ||
var ptr0 = passArrayJsValueToWasm0(refs, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_resetReferences(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(refs, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_resetReferences(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -266,9 +324,17 @@ /** | ||
* @param {any[]} refs | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
insertReferences(refs) { | ||
var ptr0 = passArrayJsValueToWasm0(refs, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_insertReferences(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(refs, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_insertReferences(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -280,7 +346,15 @@ /** | ||
* @param {Reference} refr | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
insertReference(refr) { | ||
var ret = wasm.driver_insertReference(this.ptr, addHeapObject(refr)); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_insertReference(retptr, this.ptr, addHeapObject(refr)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -291,9 +365,17 @@ /** | ||
* @param {string} id | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
removeReference(id) { | ||
var ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_removeReference(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_removeReference(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -305,7 +387,15 @@ /** | ||
* @param {IncludeUncited} uncited | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
includeUncited(uncited) { | ||
var ret = wasm.driver_includeUncited(this.ptr, addHeapObject(uncited)); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_includeUncited(retptr, this.ptr, addHeapObject(uncited)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -316,7 +406,18 @@ /** | ||
* Note that Driver comes pre-loaded with the `en-US` locale. | ||
* @returns {WasmResult<string[]>} | ||
* @returns {string[]} | ||
*/ | ||
toFetch() { | ||
var ret = wasm.driver_toFetch(this.ptr); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_toFetch(retptr, this.ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -341,8 +442,16 @@ /** | ||
* Inserts or replaces a cluster with a matching `id`. | ||
* @param {any} cluster | ||
* @returns {WasmResult<undefined>} | ||
* @param {Cluster} cluster | ||
*/ | ||
insertCluster(cluster) { | ||
var ret = wasm.driver_insertCluster(this.ptr, addHeapObject(cluster)); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_insertCluster(retptr, this.ptr, addHeapObject(cluster)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -352,9 +461,17 @@ /** | ||
* @param {string} cluster_id | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
removeCluster(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); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(cluster_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_removeCluster(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -366,9 +483,17 @@ /** | ||
* @param {any[]} clusters | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
initClusters(clusters) { | ||
var ptr0 = passArrayJsValueToWasm0(clusters, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_initClusters(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(clusters, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_initClusters(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -381,14 +506,63 @@ /** | ||
* @param {string} id | ||
* @returns {WasmResult<string>} | ||
* @returns {string} | ||
*/ | ||
builtCluster(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); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_builtCluster(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
var r3 = getInt32Memory0()[retptr / 4 + 3]; | ||
var ptr1 = r0; | ||
var len1 = r1; | ||
if (r3) { | ||
ptr1 = 0; len1 = 0; | ||
throw takeObject(r2); | ||
} | ||
return getStringFromWasm0(ptr1, len1); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
wasm.__wbindgen_free(ptr1, len1); | ||
} | ||
} | ||
/** | ||
* @deprecated Use `previewCluster` instead | ||
* @param {any[]} cites | ||
* @param {any[]} positions | ||
* @param {string | undefined} format | ||
* @returns {string} | ||
*/ | ||
previewCitationCluster(cites, positions, format) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(cites, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ptr1 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len1 = WASM_VECTOR_LEN; | ||
var ptr2 = isLikeNone(format) ? 0 : passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len2 = WASM_VECTOR_LEN; | ||
wasm.driver_previewCitationCluster(retptr, this.ptr, ptr0, len0, ptr1, len1, ptr2, len2); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
var r3 = getInt32Memory0()[retptr / 4 + 3]; | ||
var ptr3 = r0; | ||
var len3 = r1; | ||
if (r3) { | ||
ptr3 = 0; len3 = 0; | ||
throw takeObject(r2); | ||
} | ||
return getStringFromWasm0(ptr3, len3); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
wasm.__wbindgen_free(ptr3, len3); | ||
} | ||
} | ||
/** | ||
* Previews a formatted citation cluster, in a particular position. | ||
* | ||
* - `cites`: The cites to go in the cluster | ||
* - `cluster`: A cluster, without an `id` field. You'll want this to contain some cites. | ||
* - `positions`: An array of `ClusterPosition`s as in set_cluster_order, but with a single | ||
@@ -398,30 +572,68 @@ * cluster's id set to zero. The cluster with id=0 is the position to preview the cite. It | ||
* any location you can think of. | ||
* @param {any[]} cites | ||
* - `format`: an optional argument, an output format as a string, that is used only for this | ||
* preview. | ||
* @param {PreviewCluster} preview_cluster | ||
* @param {any[]} positions | ||
* @param {string} format | ||
* @returns {WasmResult<string>} | ||
* @param {string | undefined} format | ||
* @returns {string} | ||
*/ | ||
previewCitationCluster(cites, positions, format) { | ||
var ptr0 = passArrayJsValueToWasm0(cites, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ptr1 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len1 = WASM_VECTOR_LEN; | ||
var ptr2 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len2 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_previewCitationCluster(this.ptr, ptr0, len0, ptr1, len1, ptr2, len2); | ||
return takeObject(ret); | ||
previewCluster(preview_cluster, positions, format) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ptr1 = isLikeNone(format) ? 0 : passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len1 = WASM_VECTOR_LEN; | ||
wasm.driver_previewCluster(retptr, this.ptr, addHeapObject(preview_cluster), ptr0, len0, ptr1, len1); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
var r3 = getInt32Memory0()[retptr / 4 + 3]; | ||
var ptr2 = r0; | ||
var len2 = r1; | ||
if (r3) { | ||
ptr2 = 0; len2 = 0; | ||
throw takeObject(r2); | ||
} | ||
return getStringFromWasm0(ptr2, len2); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
wasm.__wbindgen_free(ptr2, len2); | ||
} | ||
} | ||
/** | ||
* @returns {WasmResult<BibEntries>} | ||
* @returns {BibEntry[]} | ||
*/ | ||
makeBibliography() { | ||
var ret = wasm.driver_makeBibliography(this.ptr); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_makeBibliography(retptr, this.ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
/** | ||
* @returns {WasmResult<BibliographyMeta>} | ||
* @returns {BibliographyMeta} | ||
*/ | ||
bibliographyMeta() { | ||
var ret = wasm.driver_bibliographyMeta(this.ptr); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_bibliographyMeta(retptr, this.ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -453,9 +665,17 @@ /** | ||
* @param {any[]} positions | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
setClusterOrder(positions) { | ||
var ptr0 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_setClusterOrder(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_setClusterOrder(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -470,7 +690,18 @@ /** | ||
* * returns an `UpdateSummary` | ||
* @returns {WasmResult<UpdateSummary>} | ||
* @returns {UpdateSummary} | ||
*/ | ||
batchedUpdates() { | ||
var ret = wasm.driver_batchedUpdates(this.ptr); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_batchedUpdates(retptr, this.ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -481,7 +712,18 @@ /** | ||
* Use this to rehydrate a document or run non-interactively. | ||
* @returns {WasmResult<FullRender>} | ||
* @returns {FullRender} | ||
*/ | ||
fullRender() { | ||
var ret = wasm.driver_fullRender(this.ptr); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_fullRender(retptr, this.ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -549,5 +791,29 @@ /** | ||
imports.wbg = {}; | ||
imports.wbg.__wbindgen_string_new = function(arg0, arg1) { | ||
var ret = getStringFromWasm0(arg0, arg1); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_new_16465ddabcb4a719 = function(arg0, arg1) { | ||
var ret = new CiteprocRsDriverError(takeObject(arg0), takeObject(arg1)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_new_1f7db38dfd81bf2f = function(arg0) { | ||
var ret = new CiteprocRsError(takeObject(arg0)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_new_bb3cad8cb87701ce = function(arg0, arg1) { | ||
var ret = new CslStyleError(takeObject(arg0), takeObject(arg1)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbindgen_object_drop_ref = function(arg0) { | ||
takeObject(arg0); | ||
}; | ||
imports.wbg.__wbindgen_string_get = function(arg0, arg1) { | ||
const obj = getObject(arg1); | ||
var ret = typeof(obj) === 'string' ? obj : undefined; | ||
var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
getInt32Memory0()[arg0 / 4 + 1] = len0; | ||
getInt32Memory0()[arg0 / 4 + 0] = ptr0; | ||
}; | ||
imports.wbg.__wbg_error_e549f7fed6d655aa = function(arg0) { | ||
@@ -571,2 +837,23 @@ console.error(takeObject(arg0)); | ||
}; | ||
imports.wbg.__wbindgen_object_clone_ref = function(arg0) { | ||
var ret = getObject(arg0); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_get_1edc26456ed84f9b = function(arg0, arg1) { | ||
var ret = getObject(arg0)[takeObject(arg1)]; | ||
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.__wbindgen_json_serialize = function(arg0, arg1) { | ||
@@ -580,4 +867,4 @@ const obj = getObject(arg1); | ||
}; | ||
imports.wbg.__wbindgen_string_new = function(arg0, arg1) { | ||
var ret = getStringFromWasm0(arg0, arg1); | ||
imports.wbg.__wbg_fetchLocale_d644d4ae2ca50f81 = function(arg0, arg1, arg2) { | ||
var ret = getObject(arg0).fetchLocale(getStringFromWasm0(arg1, arg2)); | ||
return addHeapObject(ret); | ||
@@ -594,10 +881,2 @@ }; | ||
}; | ||
imports.wbg.__wbg_fetchLocale_d644d4ae2ca50f81 = function(arg0, arg1, arg2) { | ||
var ret = getObject(arg0).fetchLocale(getStringFromWasm0(arg1, arg2)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_get_1edc26456ed84f9b = function(arg0, arg1) { | ||
var ret = getObject(arg0)[takeObject(arg1)]; | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbindgen_json_parse = function(arg0, arg1) { | ||
@@ -607,44 +886,7 @@ var ret = JSON.parse(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
imports.wbg.__wbg_driver_new = function(arg0) { | ||
var ret = Driver.__wrap(arg0); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_new_1f7db38dfd81bf2f = function(arg0) { | ||
var ret = new CiteprocRsError(takeObject(arg0)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_new_bb3cad8cb87701ce = function(arg0, arg1) { | ||
var ret = new CslStyleError(takeObject(arg0), takeObject(arg1)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_new_90da75e9c7c4fa61 = function(arg0) { | ||
var ret = new WasmResult(takeObject(arg0)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_new_16465ddabcb4a719 = 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_new_59cb74e423758ede = function() { | ||
imports.wbg.__wbg_new_693216e109162396 = function() { | ||
var ret = new Error(); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_stack_558ba5917b466edd = function(arg0, arg1) { | ||
imports.wbg.__wbg_stack_0ddaca5d1abfb52f = function(arg0, arg1) { | ||
var ret = getObject(arg1).stack; | ||
@@ -656,3 +898,3 @@ var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
}; | ||
imports.wbg.__wbg_error_4bb6c2a97407129a = function(arg0, arg1) { | ||
imports.wbg.__wbg_error_09919627ac0992f5 = function(arg0, arg1) { | ||
try { | ||
@@ -664,7 +906,7 @@ console.error(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
imports.wbg.__wbg_call_f5e0576f61ee7461 = handleError(function(arg0, arg1, arg2) { | ||
imports.wbg.__wbg_call_346669c262382ad7 = function() { return handleError(function (arg0, arg1, arg2) { | ||
var ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); | ||
return addHeapObject(ret); | ||
}); | ||
imports.wbg.__wbg_new_3ea8490cd276c848 = function(arg0, arg1) { | ||
}, arguments) }; | ||
imports.wbg.__wbg_new_b1d61b5687f5e73a = function(arg0, arg1) { | ||
try { | ||
@@ -676,3 +918,3 @@ var state0 = {a: arg0, b: arg1}; | ||
try { | ||
return __wbg_adapter_81(a, state0.b, arg0, arg1); | ||
return __wbg_adapter_79(a, state0.b, arg0, arg1); | ||
} finally { | ||
@@ -688,18 +930,18 @@ state0.a = a; | ||
}; | ||
imports.wbg.__wbg_resolve_778af3f90b8e2b59 = function(arg0) { | ||
imports.wbg.__wbg_resolve_d23068002f584f22 = function(arg0) { | ||
var ret = Promise.resolve(getObject(arg0)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_then_367b3e718069cfb9 = function(arg0, arg1) { | ||
imports.wbg.__wbg_then_2fcac196782070cc = function(arg0, arg1) { | ||
var ret = getObject(arg0).then(getObject(arg1)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_then_ac66ca61394bfd21 = function(arg0, arg1, arg2) { | ||
imports.wbg.__wbg_then_8c2d62e8ae5978f7 = function(arg0, arg1, arg2) { | ||
var ret = getObject(arg0).then(getObject(arg1), getObject(arg2)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_self_1c83eb4471d9eb9b = handleError(function() { | ||
imports.wbg.__wbg_self_1c83eb4471d9eb9b = function() { return handleError(function () { | ||
var ret = self.self; | ||
return addHeapObject(ret); | ||
}); | ||
}, arguments) }; | ||
imports.wbg.__wbg_static_accessor_MODULE_abf5ae284bffdf45 = function() { | ||
@@ -731,15 +973,7 @@ var ret = module; | ||
}; | ||
imports.wbg.__wbindgen_string_get = function(arg0, arg1) { | ||
const obj = getObject(arg1); | ||
var ret = typeof(obj) === 'string' ? obj : undefined; | ||
var ptr0 = isLikeNone(ret) ? 0 : 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_throw = function(arg0, arg1) { | ||
throw new Error(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
imports.wbg.__wbindgen_closure_wrapper917 = function(arg0, arg1, arg2) { | ||
var ret = makeMutClosure(arg0, arg1, 222, __wbg_adapter_24); | ||
imports.wbg.__wbindgen_closure_wrapper950 = function(arg0, arg1, arg2) { | ||
var ret = makeMutClosure(arg0, arg1, 232, __wbg_adapter_24); | ||
return addHeapObject(ret); | ||
@@ -746,0 +980,0 @@ }; |
/* tslint:disable */ | ||
/* eslint-disable */ | ||
export const memory: WebAssembly.Memory; | ||
export function parseStyleMetadata(a: number, b: number): number; | ||
export function parseStyleMetadata(a: number, b: number, c: number): void; | ||
export function __wbg_driver_free(a: 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_new(a: number, b: number): void; | ||
export function driver_setStyle(a: number, b: number, c: number, d: number): void; | ||
export function driver_setOutputFormat(a: number, b: number, c: number, d: number, e: number): void; | ||
export function driver_resetReferences(a: number, b: number, c: number, d: number): void; | ||
export function driver_insertReferences(a: number, b: number, c: number, d: number): void; | ||
export function driver_insertReference(a: number, b: number, c: number): void; | ||
export function driver_removeReference(a: number, b: number, c: number, d: number): void; | ||
export function driver_includeUncited(a: number, b: number, c: number): void; | ||
export function driver_toFetch(a: number, b: number): void; | ||
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_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_insertCluster(a: number, b: number, c: number): void; | ||
export function driver_removeCluster(a: number, b: number, c: number, d: number): void; | ||
export function driver_initClusters(a: number, b: number, c: number, d: number): void; | ||
export function driver_builtCluster(a: number, b: number, c: number, d: number): void; | ||
export function driver_previewCitationCluster(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): void; | ||
export function driver_previewCluster(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void; | ||
export function driver_makeBibliography(a: number, b: number): void; | ||
export function driver_bibliographyMeta(a: number, b: number): void; | ||
export function driver_setClusterOrder(a: number, b: number, c: number, d: number): void; | ||
export function driver_batchedUpdates(a: number, b: number): void; | ||
export function driver_fullRender(a: number, b: number): void; | ||
export function driver_drain(a: number): void; | ||
@@ -30,6 +32,6 @@ export function driver_fetchLocales(a: number): number; | ||
export const __wbindgen_export_2: WebAssembly.Table; | ||
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2c48d2b80cbc9988(a: number, b: number, c: number): void; | ||
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hee74a5b7602953f2(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__h1d8bf0ad0105b2cc(a: number, b: number, c: number, d: number): void; | ||
export function wasm_bindgen__convert__closures__invoke2_mut__h5e049d289685efc8(a: number, b: number, c: number, d: number): void; |
@@ -6,131 +6,6 @@ /* tslint:disable */ | ||
* @param {string} style | ||
* @returns {WasmResult<StyleMeta>} | ||
* @returns {StyleMeta} | ||
*/ | ||
export function parseStyleMetadata(style: string): WasmResult<StyleMeta>; | ||
export function parseStyleMetadata(style: string): 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 Fetcher { | ||
/** Return locale XML for a particular locale. */ | ||
fetchLocale(lang: string): Promise<string>; | ||
} | ||
export type DateLiteral = { "literal": string; }; | ||
export type DateRaw = { "raw": string; }; | ||
export type DatePartsDate = [number] | [number, number] | [number, number, number]; | ||
export type DatePartsSingle = { "date-parts": [DatePartsDate]; }; | ||
export type DatePartsRange = { "date-parts": [DatePartsDate, DatePartsDate]; }; | ||
export type DateParts = DatePartsSingle | DatePartsRange; | ||
export type DateOrRange = DateLiteral | DateRaw | DateParts; | ||
/** Locator type, and a locator string */ | ||
export type Locator = { | ||
label?: string; | ||
locator?: string; | ||
locators: undefined; | ||
}; | ||
export type CiteLocator = Locator | { locator: undefined; locators: Locator[] }; | ||
export type Cite<Affix = string> = { | ||
id: string; | ||
prefix?: Affix; | ||
suffix?: Affix; | ||
suppression?: "InText" | "Rest" | null; | ||
} & Partial<CiteLocator>; | ||
export type ClusterNumber = { | ||
note: number | [number, number] | ||
} | { | ||
inText: number | ||
}; | ||
export type Cluster = { | ||
id: string; | ||
cites: Cite[]; | ||
}; | ||
export type ClusterPosition = { | ||
id: string; | ||
/** Leaving off this field means this cluster is in-text. */ | ||
note?: number; | ||
} | ||
export type Reference = { | ||
id: string; | ||
type: CslType; | ||
[key: string]: any; | ||
}; | ||
export type CslType = "book" | "article" | "legal_case" | "article-journal"; | ||
export interface BibliographyUpdate { | ||
updatedEntries: Map<string, string>; | ||
entryIds?: string[]; | ||
} | ||
export type UpdateSummary<Output = string> = { | ||
clusters: [string, Output][]; | ||
bibliography?: BibliographyUpdate; | ||
}; | ||
type IncludeUncited = "None" | "All" | { Specific: string[] }; | ||
type BibEntry = { | ||
id: string; | ||
value: string; | ||
}; | ||
type BibEntries = BibEntry[]; | ||
type FullRender = { | ||
allClusters: Map<string, string>, | ||
bibEntries: BibEntries, | ||
}; | ||
type BibliographyMeta = { | ||
maxOffset: number; | ||
entrySpacing: number; | ||
lineSpacing: number; | ||
hangingIndent: boolean; | ||
/** the second-field-align value of the CSL style */ | ||
secondFieldAlign: null | "flush" | "margin"; | ||
/** Format-specific metadata */ | ||
formatMeta: any, | ||
}; | ||
type Severity = "Error" | "Warning"; | ||
@@ -146,3 +21,3 @@ interface InvalidCsl { | ||
hint: string | undefined; | ||
}; | ||
} | ||
type StyleError = { | ||
@@ -178,11 +53,23 @@ tag: "Invalid", | ||
declare global { | ||
/** Catch-all citeproc-rs Error subclass. */ | ||
declare class CiteprocRsError extends Error { | ||
/** Catch-all citeproc-rs Error subclass. | ||
* | ||
* CiteprocRsDriverError and CslStyleError are both subclasses of this, so checking instanceof | ||
* CiteprocRsError suffices to catch all errors thrown by @citeproc-rs/wasm itself. | ||
* | ||
* There may be errors that are not a subclass, but directly an instance of CitprocRsError, so | ||
* for completeness in a catch/instanceof check, one should test for this too. | ||
* | ||
* Using the library may also result in WASM runtime errors, and some generic Error objects | ||
* from e.g. using a Driver after you have called `.free()`. | ||
* */ | ||
class CiteprocRsError extends Error { | ||
constructor(message: string); | ||
} | ||
declare class CiteprocRsDriverError extends CiteprocRsError { | ||
/** Error in usage of Driver */ | ||
class CiteprocRsDriverError extends CiteprocRsError { | ||
data: DriverError; | ||
constructor(message: string, data: DriverError); | ||
} | ||
declare class CslStyleError extends CiteprocRsError { | ||
/** Error parsing a CSL file */ | ||
class CslStyleError extends CiteprocRsError { | ||
data: StyleError; | ||
@@ -195,51 +82,125 @@ 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; | ||
interface FormatOptions { | ||
linkAnchors?: boolean; | ||
} | ||
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 (default: html) */ | ||
format?: "html" | "rtf" | "plain"; | ||
/** Configuration for the formatter */ | ||
formatOptions?: FormatOptions; | ||
/** Optional array of CSL feature names to activate globally. Features are kebab-case. */ | ||
cslFeatures?: string[]; | ||
/** 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?: boolean; | ||
} | ||
/** This interface lets citeproc retrieve locales or modules asynchronously, | ||
according to which ones are needed. */ | ||
export interface Fetcher { | ||
/** Return locale XML for a particular locale. */ | ||
fetchLocale(lang: string): Promise<string>; | ||
} | ||
interface BibliographyUpdate { | ||
updatedEntries: Map<string, string>; | ||
entryIds?: string[]; | ||
} | ||
type UpdateSummary<Output = string> = { | ||
clusters: [string, Output][]; | ||
bibliography?: BibliographyUpdate; | ||
}; | ||
interface BibEntry { | ||
id: string; | ||
value: string; | ||
} | ||
interface FullRender { | ||
allClusters: Map<string, string>; | ||
bibEntries: BibEntry[]; | ||
} | ||
interface BibliographyMeta { | ||
maxOffset: number; | ||
entrySpacing: number; | ||
lineSpacing: number; | ||
hangingIndent: boolean; | ||
/** the second-field-align value of the CSL style */ | ||
secondFieldAlign: null | "flush" | "margin"; | ||
/** Format-specific metadata */ | ||
formatMeta: any; | ||
} | ||
interface StyleMeta { | ||
info: StyleInfo; | ||
features: { [feature: string]: boolean }; | ||
defaultLocale: string; | ||
/** May be absent on a dependent style */ | ||
class?: "in-text" | "note"; | ||
cslVersionRequired: string; | ||
/** May be absent on a dependent style */ | ||
independentMeta?: IndependentMeta; | ||
} | ||
type CitationFormat = "author-date" | "author" | "numeric" | "label" | "note"; | ||
interface LocalizedString { | ||
value: string, | ||
lang?: string, | ||
value: string; | ||
lang?: string; | ||
} | ||
interface ParentLink { | ||
href: string, | ||
lang?: string, | ||
href: string; | ||
lang?: string; | ||
} | ||
interface Link { | ||
href: string, | ||
rel: "self" | "documentation" | "template", | ||
lang?: string, | ||
href: string; | ||
rel: "self" | "documentation" | "template"; | ||
lang?: string; | ||
} | ||
interface Rights { | ||
value: string, | ||
lang?: string, | ||
license?: string, | ||
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, | ||
id: string; | ||
updated: string; | ||
title: LocalizedString; | ||
titleShort?: LocalizedString; | ||
parent?: ParentLink; | ||
links: Link[]; | ||
rights?: Rights; | ||
citationFormat?: CitationFormat; | ||
categories: string[]; | ||
issn?: string; | ||
eissn?: string; | ||
issnl?: string; | ||
} | ||
@@ -249,17 +210,69 @@ interface IndependentMeta { | ||
* Does not include the language-less final override. */ | ||
localeOverrides: string[], | ||
hasBibliography: bool, | ||
localeOverrides: string[]; | ||
hasBibliography: boolean; | ||
} | ||
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, | ||
/** Locator type, and a locator string */ | ||
export type Locator = { | ||
label?: string; | ||
locator?: string; | ||
locators: undefined; | ||
}; | ||
export type CiteLocator = Locator | { locator: undefined; locators: Locator[]; }; | ||
export type CiteMode = { mode?: "SuppressAuthor" | "AuthorOnly"; }; | ||
export type Cite = { | ||
id: string; | ||
prefix?: string; | ||
suffix?: string; | ||
} & Partial<CiteLocator> & CiteMode; | ||
export type ClusterMode | ||
= { mode: "Composite"; infix?: string; suppressFirst?: number; } | ||
| { mode: "SuppressAuthor"; suppressFirst?: number; } | ||
| { mode: "AuthorOnly"; } | ||
| {}; | ||
export type Cluster = { | ||
id: string; | ||
cites: Cite[]; | ||
} & ClusterMode; | ||
export type PreviewCluster = { | ||
cites: Cite[]; | ||
} & ClusterMode; | ||
export type ClusterPosition = { | ||
id: string; | ||
/** Leaving off this field means this cluster is in-text. */ | ||
note?: number; | ||
} | ||
type Reference = { | ||
id: string; | ||
type: CslType; | ||
[key: string]: any; | ||
}; | ||
export type CslType = "book" | "legal_case" | "article-journal" | string; | ||
type IncludeUncited = "None" | "All" | { Specific: string[] }; | ||
type DateLiteral = { "literal": string; }; | ||
type DateRaw = { "raw": string; }; | ||
type DatePartsDate = [number] | [number, number] | [number, number, number]; | ||
type DatePartsSingle = { "date-parts": [DatePartsDate]; }; | ||
type DatePartsRange = { "date-parts": [DatePartsDate, DatePartsDate]; }; | ||
type DateParts = DatePartsSingle | DatePartsRange; | ||
type DateOrRange = DateLiteral | DateRaw | DateParts; | ||
/** | ||
@@ -270,26 +283,33 @@ */ | ||
/** | ||
* Creates a new Driver. | ||
* Creates a new Driver. Use the InitOptions object, which has (for example): | ||
* | ||
* * `style` is a CSL style as a string. Independent styles only. | ||
* * `fetcher` must implement the `Fetcher` interface | ||
* * `format` is one of { "html", "rtf" } | ||
* * `format` is one of { "html", "rtf", "plain" } | ||
* | ||
* Throws an error if it cannot parse the style you gave it. | ||
* @param {InitOptions} options | ||
* @returns {WasmResult<Driver>} | ||
*/ | ||
static new(options: InitOptions): WasmResult<Driver>; | ||
constructor(options: InitOptions); | ||
/** | ||
* Sets the style (which will also cause everything to be recomputed) | ||
* Sets the style (which will also cause everything to be recomputed, use sparingly) | ||
* @param {string} style_text | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
setStyle(style_text: string): WasmResult<undefined>; | ||
setStyle(style_text: string): void; | ||
/** | ||
* Sets the output format (which will also cause everything to be recomputed, use sparingly) | ||
* | ||
* @param {"html" | "rtf" | "plain"} format The new output format as a string, same as `new Driver` | ||
* | ||
* @param {FormatOptions | null} options If absent, this is set to the default FormatOptions. | ||
* @param {string} format | ||
* @param {FormatOptions | undefined} options | ||
*/ | ||
setOutputFormat(format: string, options?: FormatOptions): void; | ||
/** | ||
* Completely overwrites the references library. | ||
* This **will** delete references that are not in the provided list. | ||
* @param {any[]} refs | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
resetReferences(refs: any[]): WasmResult<undefined>; | ||
resetReferences(refs: any[]): void; | ||
/** | ||
@@ -299,5 +319,4 @@ * Inserts or overwrites references as a batch operation. | ||
* @param {any[]} refs | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
insertReferences(refs: any[]): WasmResult<undefined>; | ||
insertReferences(refs: any[]): void; | ||
/** | ||
@@ -308,5 +327,4 @@ * Inserts or overwrites a reference. | ||
* @param {Reference} refr | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
insertReference(refr: Reference): WasmResult<undefined>; | ||
insertReference(refr: Reference): void; | ||
/** | ||
@@ -316,5 +334,4 @@ * 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): WasmResult<undefined>; | ||
removeReference(id: string): void; | ||
/** | ||
@@ -325,5 +342,4 @@ * Sets the references to be included in the bibliography despite not being directly cited. | ||
* @param {IncludeUncited} uncited | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
includeUncited(uncited: IncludeUncited): WasmResult<undefined>; | ||
includeUncited(uncited: IncludeUncited): void; | ||
/** | ||
@@ -333,5 +349,5 @@ * Gets a list of locales in use by the references currently loaded. | ||
* Note that Driver comes pre-loaded with the `en-US` locale. | ||
* @returns {WasmResult<string[]>} | ||
* @returns {string[]} | ||
*/ | ||
toFetch(): WasmResult<string[]>; | ||
toFetch(): string[]; | ||
/** | ||
@@ -344,12 +360,10 @@ * Returns a random cluster id, with an extra guarantee that it isn't already in use. | ||
* Inserts or replaces a cluster with a matching `id`. | ||
* @param {any} cluster | ||
* @returns {WasmResult<undefined>} | ||
* @param {Cluster} cluster | ||
*/ | ||
insertCluster(cluster: any): WasmResult<undefined>; | ||
insertCluster(cluster: Cluster): void; | ||
/** | ||
* Removes a cluster with a matching `id` | ||
* @param {string} cluster_id | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
removeCluster(cluster_id: string): WasmResult<undefined>; | ||
removeCluster(cluster_id: string): void; | ||
/** | ||
@@ -360,5 +374,4 @@ * Resets all the clusters in the processor to a new list. | ||
* @param {any[]} clusters | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
initClusters(clusters: any[]): WasmResult<undefined>; | ||
initClusters(clusters: any[]): void; | ||
/** | ||
@@ -370,9 +383,17 @@ * Returns the formatted citation cluster for `cluster_id`. | ||
* @param {string} id | ||
* @returns {WasmResult<string>} | ||
* @returns {string} | ||
*/ | ||
builtCluster(id: string): WasmResult<string>; | ||
builtCluster(id: string): string; | ||
/** | ||
* @deprecated Use `previewCluster` instead | ||
* @param {any[]} cites | ||
* @param {any[]} positions | ||
* @param {string | undefined} format | ||
* @returns {string} | ||
*/ | ||
previewCitationCluster(cites: any[], positions: any[], format?: string): string; | ||
/** | ||
* Previews a formatted citation cluster, in a particular position. | ||
* | ||
* - `cites`: The cites to go in the cluster | ||
* - `cluster`: A cluster, without an `id` field. You'll want this to contain some cites. | ||
* - `positions`: An array of `ClusterPosition`s as in set_cluster_order, but with a single | ||
@@ -382,16 +403,18 @@ * cluster's id set to zero. The cluster with id=0 is the position to preview the cite. It | ||
* any location you can think of. | ||
* @param {any[]} cites | ||
* - `format`: an optional argument, an output format as a string, that is used only for this | ||
* preview. | ||
* @param {PreviewCluster} preview_cluster | ||
* @param {any[]} positions | ||
* @param {string} format | ||
* @returns {WasmResult<string>} | ||
* @param {string | undefined} format | ||
* @returns {string} | ||
*/ | ||
previewCitationCluster(cites: any[], positions: any[], format: string): WasmResult<string>; | ||
previewCluster(preview_cluster: PreviewCluster, positions: any[], format?: string): string; | ||
/** | ||
* @returns {WasmResult<BibEntries>} | ||
* @returns {BibEntry[]} | ||
*/ | ||
makeBibliography(): WasmResult<BibEntries>; | ||
makeBibliography(): BibEntry[]; | ||
/** | ||
* @returns {WasmResult<BibliographyMeta>} | ||
* @returns {BibliographyMeta} | ||
*/ | ||
bibliographyMeta(): WasmResult<BibliographyMeta>; | ||
bibliographyMeta(): BibliographyMeta; | ||
/** | ||
@@ -422,5 +445,4 @@ * Specifies which clusters are actually considered to be in the document, and sets their | ||
* @param {any[]} positions | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
setClusterOrder(positions: any[]): WasmResult<undefined>; | ||
setClusterOrder(positions: any[]): void; | ||
/** | ||
@@ -434,5 +456,5 @@ * Retrieve any clusters that have been touched since last time `batchedUpdates` was | ||
* * returns an `UpdateSummary` | ||
* @returns {WasmResult<UpdateSummary>} | ||
* @returns {UpdateSummary} | ||
*/ | ||
batchedUpdates(): WasmResult<UpdateSummary>; | ||
batchedUpdates(): UpdateSummary; | ||
/** | ||
@@ -442,5 +464,5 @@ * Returns all the clusters and bibliography entries in the document. | ||
* Use this to rehydrate a document or run non-interactively. | ||
* @returns {WasmResult<FullRender>} | ||
* @returns {FullRender} | ||
*/ | ||
fullRender(): WasmResult<FullRender>; | ||
fullRender(): FullRender; | ||
/** | ||
@@ -462,23 +484,25 @@ * Drains the `batchedUpdates` queue manually. | ||
readonly memory: WebAssembly.Memory; | ||
readonly parseStyleMetadata: (a: number, b: number) => number; | ||
readonly parseStyleMetadata: (a: number, b: number, c: number) => void; | ||
readonly __wbg_driver_free: (a: 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_new: (a: number, b: number) => void; | ||
readonly driver_setStyle: (a: number, b: number, c: number, d: number) => void; | ||
readonly driver_setOutputFormat: (a: number, b: number, c: number, d: number, e: number) => void; | ||
readonly driver_resetReferences: (a: number, b: number, c: number, d: number) => void; | ||
readonly driver_insertReferences: (a: number, b: number, c: number, d: number) => void; | ||
readonly driver_insertReference: (a: number, b: number, c: number) => void; | ||
readonly driver_removeReference: (a: number, b: number, c: number, d: number) => void; | ||
readonly driver_includeUncited: (a: number, b: number, c: number) => void; | ||
readonly driver_toFetch: (a: number, b: number) => void; | ||
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_setClusterOrder: (a: number, b: number, c: number) => number; | ||
readonly driver_batchedUpdates: (a: number) => number; | ||
readonly driver_fullRender: (a: number) => number; | ||
readonly driver_insertCluster: (a: number, b: number, c: number) => void; | ||
readonly driver_removeCluster: (a: number, b: number, c: number, d: number) => void; | ||
readonly driver_initClusters: (a: number, b: number, c: number, d: number) => void; | ||
readonly driver_builtCluster: (a: number, b: number, c: number, d: number) => void; | ||
readonly driver_previewCitationCluster: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void; | ||
readonly driver_previewCluster: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void; | ||
readonly driver_makeBibliography: (a: number, b: number) => void; | ||
readonly driver_bibliographyMeta: (a: number, b: number) => void; | ||
readonly driver_setClusterOrder: (a: number, b: number, c: number, d: number) => void; | ||
readonly driver_batchedUpdates: (a: number, b: number) => void; | ||
readonly driver_fullRender: (a: number, b: number) => void; | ||
readonly driver_drain: (a: number) => void; | ||
@@ -489,7 +513,7 @@ readonly driver_fetchLocales: (a: number) => number; | ||
readonly __wbindgen_export_2: WebAssembly.Table; | ||
readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2c48d2b80cbc9988: (a: number, b: number, c: number) => void; | ||
readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hee74a5b7602953f2: (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__h1d8bf0ad0105b2cc: (a: number, b: number, c: number, d: number) => void; | ||
readonly wasm_bindgen__convert__closures__invoke2_mut__h5e049d289685efc8: (a: number, b: number, c: number, d: number) => void; | ||
} | ||
@@ -496,0 +520,0 @@ |
@@ -1,5 +0,21 @@ | ||
import { WasmResult, CiteprocRsError, CiteprocRsDriverError, CslStyleError } from './snippets/wasm-1883a0b9dcad429e/src/js/include.js'; | ||
import { CiteprocRsError, CiteprocRsDriverError, CslStyleError } from './snippets/wasm-1883a0b9dcad429e/src/js/include.js'; | ||
let wasm; | ||
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
cachedTextDecoder.decode(); | ||
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) { | ||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); | ||
} | ||
const heap = new Array(32).fill(undefined); | ||
@@ -9,6 +25,15 @@ | ||
let heap_next = heap.length; | ||
function addHeapObject(obj) { | ||
if (heap_next === heap.length) heap.push(heap.length + 1); | ||
const idx = heap_next; | ||
heap_next = heap[idx]; | ||
heap[idx] = obj; | ||
return idx; | ||
} | ||
function getObject(idx) { return heap[idx]; } | ||
let heap_next = heap.length; | ||
function dropObject(idx) { | ||
@@ -28,10 +53,2 @@ if (idx < 36) return; | ||
let cachegetUint8Memory0 = null; | ||
function getUint8Memory0() { | ||
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) { | ||
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer); | ||
} | ||
return cachegetUint8Memory0; | ||
} | ||
let cachedTextEncoder = new TextEncoder('utf-8'); | ||
@@ -90,2 +107,6 @@ | ||
function isLikeNone(x) { | ||
return x === undefined || x === null; | ||
} | ||
let cachegetInt32Memory0 = null; | ||
@@ -99,23 +120,2 @@ function getInt32Memory0() { | ||
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
cachedTextDecoder.decode(); | ||
function getStringFromWasm0(ptr, len) { | ||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); | ||
} | ||
function addHeapObject(obj) { | ||
if (heap_next === heap.length) heap.push(heap.length + 1); | ||
const idx = heap_next; | ||
heap_next = heap[idx]; | ||
heap[idx] = obj; | ||
return idx; | ||
} | ||
function isLikeNone(x) { | ||
return x === undefined || x === null; | ||
} | ||
function makeMutClosure(arg0, arg1, dtor, f) { | ||
@@ -146,3 +146,3 @@ const state = { a: arg0, b: arg1, cnt: 1, dtor }; | ||
function __wbg_adapter_24(arg0, arg1, arg2) { | ||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2c48d2b80cbc9988(arg0, arg1, addHeapObject(arg2)); | ||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hee74a5b7602953f2(arg0, arg1, addHeapObject(arg2)); | ||
} | ||
@@ -153,9 +153,20 @@ | ||
* @param {string} style | ||
* @returns {WasmResult<StyleMeta>} | ||
* @returns {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); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(style, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.parseStyleMetadata(retptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -181,14 +192,11 @@ | ||
function handleError(f) { | ||
return function () { | ||
try { | ||
return f.apply(this, arguments); | ||
} catch (e) { | ||
wasm.__wbindgen_exn_store(addHeapObject(e)); | ||
} | ||
}; | ||
function handleError(f, args) { | ||
try { | ||
return f.apply(this, args); | ||
} catch (e) { | ||
wasm.__wbindgen_exn_store(addHeapObject(e)); | ||
} | ||
} | ||
function __wbg_adapter_81(arg0, arg1, arg2, arg3) { | ||
wasm.wasm_bindgen__convert__closures__invoke2_mut__h1d8bf0ad0105b2cc(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); | ||
function __wbg_adapter_79(arg0, arg1, arg2, arg3) { | ||
wasm.wasm_bindgen__convert__closures__invoke2_mut__h5e049d289685efc8(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); | ||
} | ||
@@ -222,38 +230,88 @@ | ||
/** | ||
* Creates a new Driver. | ||
* Creates a new Driver. Use the InitOptions object, which has (for example): | ||
* | ||
* * `style` is a CSL style as a string. Independent styles only. | ||
* * `fetcher` must implement the `Fetcher` interface | ||
* * `format` is one of { "html", "rtf" } | ||
* * `format` is one of { "html", "rtf", "plain" } | ||
* | ||
* Throws an error if it cannot parse the style you gave it. | ||
* @param {InitOptions} options | ||
* @returns {WasmResult<Driver>} | ||
*/ | ||
static new(options) { | ||
var ret = wasm.driver_new(addHeapObject(options)); | ||
return takeObject(ret); | ||
constructor(options) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_new(retptr, addHeapObject(options)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return Driver.__wrap(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
/** | ||
* Sets the style (which will also cause everything to be recomputed) | ||
* Sets the style (which will also cause everything to be recomputed, use sparingly) | ||
* @param {string} style_text | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
setStyle(style_text) { | ||
var ptr0 = passStringToWasm0(style_text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_setStyle(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(style_text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_setStyle(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
/** | ||
* Sets the output format (which will also cause everything to be recomputed, use sparingly) | ||
* | ||
* @param {"html" | "rtf" | "plain"} format The new output format as a string, same as `new Driver` | ||
* | ||
* @param {FormatOptions | null} options If absent, this is set to the default FormatOptions. | ||
* @param {string} format | ||
* @param {FormatOptions | undefined} options | ||
*/ | ||
setOutputFormat(format, options) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_setOutputFormat(retptr, this.ptr, ptr0, len0, isLikeNone(options) ? 0 : addHeapObject(options)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
/** | ||
* Completely overwrites the references library. | ||
* This **will** delete references that are not in the provided list. | ||
* @param {any[]} refs | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
resetReferences(refs) { | ||
var ptr0 = passArrayJsValueToWasm0(refs, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_resetReferences(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(refs, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_resetReferences(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -264,9 +322,17 @@ /** | ||
* @param {any[]} refs | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
insertReferences(refs) { | ||
var ptr0 = passArrayJsValueToWasm0(refs, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_insertReferences(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(refs, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_insertReferences(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -278,7 +344,15 @@ /** | ||
* @param {Reference} refr | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
insertReference(refr) { | ||
var ret = wasm.driver_insertReference(this.ptr, addHeapObject(refr)); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_insertReference(retptr, this.ptr, addHeapObject(refr)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -289,9 +363,17 @@ /** | ||
* @param {string} id | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
removeReference(id) { | ||
var ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_removeReference(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_removeReference(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -303,7 +385,15 @@ /** | ||
* @param {IncludeUncited} uncited | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
includeUncited(uncited) { | ||
var ret = wasm.driver_includeUncited(this.ptr, addHeapObject(uncited)); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_includeUncited(retptr, this.ptr, addHeapObject(uncited)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -314,7 +404,18 @@ /** | ||
* Note that Driver comes pre-loaded with the `en-US` locale. | ||
* @returns {WasmResult<string[]>} | ||
* @returns {string[]} | ||
*/ | ||
toFetch() { | ||
var ret = wasm.driver_toFetch(this.ptr); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_toFetch(retptr, this.ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -339,8 +440,16 @@ /** | ||
* Inserts or replaces a cluster with a matching `id`. | ||
* @param {any} cluster | ||
* @returns {WasmResult<undefined>} | ||
* @param {Cluster} cluster | ||
*/ | ||
insertCluster(cluster) { | ||
var ret = wasm.driver_insertCluster(this.ptr, addHeapObject(cluster)); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_insertCluster(retptr, this.ptr, addHeapObject(cluster)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -350,9 +459,17 @@ /** | ||
* @param {string} cluster_id | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
removeCluster(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); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(cluster_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_removeCluster(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -364,9 +481,17 @@ /** | ||
* @param {any[]} clusters | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
initClusters(clusters) { | ||
var ptr0 = passArrayJsValueToWasm0(clusters, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_initClusters(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(clusters, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_initClusters(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -379,14 +504,63 @@ /** | ||
* @param {string} id | ||
* @returns {WasmResult<string>} | ||
* @returns {string} | ||
*/ | ||
builtCluster(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); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_builtCluster(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
var r3 = getInt32Memory0()[retptr / 4 + 3]; | ||
var ptr1 = r0; | ||
var len1 = r1; | ||
if (r3) { | ||
ptr1 = 0; len1 = 0; | ||
throw takeObject(r2); | ||
} | ||
return getStringFromWasm0(ptr1, len1); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
wasm.__wbindgen_free(ptr1, len1); | ||
} | ||
} | ||
/** | ||
* @deprecated Use `previewCluster` instead | ||
* @param {any[]} cites | ||
* @param {any[]} positions | ||
* @param {string | undefined} format | ||
* @returns {string} | ||
*/ | ||
previewCitationCluster(cites, positions, format) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(cites, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ptr1 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len1 = WASM_VECTOR_LEN; | ||
var ptr2 = isLikeNone(format) ? 0 : passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len2 = WASM_VECTOR_LEN; | ||
wasm.driver_previewCitationCluster(retptr, this.ptr, ptr0, len0, ptr1, len1, ptr2, len2); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
var r3 = getInt32Memory0()[retptr / 4 + 3]; | ||
var ptr3 = r0; | ||
var len3 = r1; | ||
if (r3) { | ||
ptr3 = 0; len3 = 0; | ||
throw takeObject(r2); | ||
} | ||
return getStringFromWasm0(ptr3, len3); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
wasm.__wbindgen_free(ptr3, len3); | ||
} | ||
} | ||
/** | ||
* Previews a formatted citation cluster, in a particular position. | ||
* | ||
* - `cites`: The cites to go in the cluster | ||
* - `cluster`: A cluster, without an `id` field. You'll want this to contain some cites. | ||
* - `positions`: An array of `ClusterPosition`s as in set_cluster_order, but with a single | ||
@@ -396,30 +570,68 @@ * cluster's id set to zero. The cluster with id=0 is the position to preview the cite. It | ||
* any location you can think of. | ||
* @param {any[]} cites | ||
* - `format`: an optional argument, an output format as a string, that is used only for this | ||
* preview. | ||
* @param {PreviewCluster} preview_cluster | ||
* @param {any[]} positions | ||
* @param {string} format | ||
* @returns {WasmResult<string>} | ||
* @param {string | undefined} format | ||
* @returns {string} | ||
*/ | ||
previewCitationCluster(cites, positions, format) { | ||
var ptr0 = passArrayJsValueToWasm0(cites, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ptr1 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len1 = WASM_VECTOR_LEN; | ||
var ptr2 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len2 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_previewCitationCluster(this.ptr, ptr0, len0, ptr1, len1, ptr2, len2); | ||
return takeObject(ret); | ||
previewCluster(preview_cluster, positions, format) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ptr1 = isLikeNone(format) ? 0 : passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len1 = WASM_VECTOR_LEN; | ||
wasm.driver_previewCluster(retptr, this.ptr, addHeapObject(preview_cluster), ptr0, len0, ptr1, len1); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
var r3 = getInt32Memory0()[retptr / 4 + 3]; | ||
var ptr2 = r0; | ||
var len2 = r1; | ||
if (r3) { | ||
ptr2 = 0; len2 = 0; | ||
throw takeObject(r2); | ||
} | ||
return getStringFromWasm0(ptr2, len2); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
wasm.__wbindgen_free(ptr2, len2); | ||
} | ||
} | ||
/** | ||
* @returns {WasmResult<BibEntries>} | ||
* @returns {BibEntry[]} | ||
*/ | ||
makeBibliography() { | ||
var ret = wasm.driver_makeBibliography(this.ptr); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_makeBibliography(retptr, this.ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
/** | ||
* @returns {WasmResult<BibliographyMeta>} | ||
* @returns {BibliographyMeta} | ||
*/ | ||
bibliographyMeta() { | ||
var ret = wasm.driver_bibliographyMeta(this.ptr); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_bibliographyMeta(retptr, this.ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -451,9 +663,17 @@ /** | ||
* @param {any[]} positions | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
setClusterOrder(positions) { | ||
var ptr0 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_setClusterOrder(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_setClusterOrder(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -468,7 +688,18 @@ /** | ||
* * returns an `UpdateSummary` | ||
* @returns {WasmResult<UpdateSummary>} | ||
* @returns {UpdateSummary} | ||
*/ | ||
batchedUpdates() { | ||
var ret = wasm.driver_batchedUpdates(this.ptr); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_batchedUpdates(retptr, this.ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -479,7 +710,18 @@ /** | ||
* Use this to rehydrate a document or run non-interactively. | ||
* @returns {WasmResult<FullRender>} | ||
* @returns {FullRender} | ||
*/ | ||
fullRender() { | ||
var ret = wasm.driver_fullRender(this.ptr); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_fullRender(retptr, this.ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -540,5 +782,29 @@ /** | ||
imports.wbg = {}; | ||
imports.wbg.__wbindgen_string_new = function(arg0, arg1) { | ||
var ret = getStringFromWasm0(arg0, 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.__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.__wbindgen_object_drop_ref = function(arg0) { | ||
takeObject(arg0); | ||
}; | ||
imports.wbg.__wbindgen_string_get = function(arg0, arg1) { | ||
const obj = getObject(arg1); | ||
var ret = typeof(obj) === 'string' ? obj : undefined; | ||
var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
getInt32Memory0()[arg0 / 4 + 1] = len0; | ||
getInt32Memory0()[arg0 / 4 + 0] = ptr0; | ||
}; | ||
imports.wbg.__wbg_error_e549f7fed6d655aa = function(arg0) { | ||
@@ -562,2 +828,23 @@ console.error(takeObject(arg0)); | ||
}; | ||
imports.wbg.__wbindgen_object_clone_ref = function(arg0) { | ||
var ret = getObject(arg0); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_get_1edc26456ed84f9b = function(arg0, arg1) { | ||
var ret = getObject(arg0)[takeObject(arg1)]; | ||
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.__wbindgen_json_serialize = function(arg0, arg1) { | ||
@@ -571,4 +858,4 @@ const obj = getObject(arg1); | ||
}; | ||
imports.wbg.__wbindgen_string_new = function(arg0, arg1) { | ||
var ret = getStringFromWasm0(arg0, arg1); | ||
imports.wbg.__wbg_fetchLocale_d644d4ae2ca50f81 = function(arg0, arg1, arg2) { | ||
var ret = getObject(arg0).fetchLocale(getStringFromWasm0(arg1, arg2)); | ||
return addHeapObject(ret); | ||
@@ -585,10 +872,2 @@ }; | ||
}; | ||
imports.wbg.__wbg_fetchLocale_d644d4ae2ca50f81 = function(arg0, arg1, arg2) { | ||
var ret = getObject(arg0).fetchLocale(getStringFromWasm0(arg1, arg2)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_get_1edc26456ed84f9b = function(arg0, arg1) { | ||
var ret = getObject(arg0)[takeObject(arg1)]; | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbindgen_json_parse = function(arg0, arg1) { | ||
@@ -598,44 +877,7 @@ var ret = JSON.parse(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
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_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_new_59cb74e423758ede = function() { | ||
imports.wbg.__wbg_new_693216e109162396 = function() { | ||
var ret = new Error(); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_stack_558ba5917b466edd = function(arg0, arg1) { | ||
imports.wbg.__wbg_stack_0ddaca5d1abfb52f = function(arg0, arg1) { | ||
var ret = getObject(arg1).stack; | ||
@@ -647,3 +889,3 @@ var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
}; | ||
imports.wbg.__wbg_error_4bb6c2a97407129a = function(arg0, arg1) { | ||
imports.wbg.__wbg_error_09919627ac0992f5 = function(arg0, arg1) { | ||
try { | ||
@@ -655,7 +897,7 @@ console.error(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
imports.wbg.__wbg_call_f5e0576f61ee7461 = handleError(function(arg0, arg1, arg2) { | ||
imports.wbg.__wbg_call_346669c262382ad7 = function() { return handleError(function (arg0, arg1, arg2) { | ||
var ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); | ||
return addHeapObject(ret); | ||
}); | ||
imports.wbg.__wbg_new_3ea8490cd276c848 = function(arg0, arg1) { | ||
}, arguments) }; | ||
imports.wbg.__wbg_new_b1d61b5687f5e73a = function(arg0, arg1) { | ||
try { | ||
@@ -667,3 +909,3 @@ var state0 = {a: arg0, b: arg1}; | ||
try { | ||
return __wbg_adapter_81(a, state0.b, arg0, arg1); | ||
return __wbg_adapter_79(a, state0.b, arg0, arg1); | ||
} finally { | ||
@@ -679,18 +921,18 @@ state0.a = a; | ||
}; | ||
imports.wbg.__wbg_resolve_778af3f90b8e2b59 = function(arg0) { | ||
imports.wbg.__wbg_resolve_d23068002f584f22 = function(arg0) { | ||
var ret = Promise.resolve(getObject(arg0)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_then_367b3e718069cfb9 = function(arg0, arg1) { | ||
imports.wbg.__wbg_then_2fcac196782070cc = function(arg0, arg1) { | ||
var ret = getObject(arg0).then(getObject(arg1)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_then_ac66ca61394bfd21 = function(arg0, arg1, arg2) { | ||
imports.wbg.__wbg_then_8c2d62e8ae5978f7 = function(arg0, arg1, arg2) { | ||
var ret = getObject(arg0).then(getObject(arg1), getObject(arg2)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_self_1c83eb4471d9eb9b = handleError(function() { | ||
imports.wbg.__wbg_self_1c83eb4471d9eb9b = function() { return handleError(function () { | ||
var ret = self.self; | ||
return addHeapObject(ret); | ||
}); | ||
}, arguments) }; | ||
imports.wbg.__wbg_static_accessor_MODULE_abf5ae284bffdf45 = function() { | ||
@@ -722,15 +964,7 @@ var ret = module; | ||
}; | ||
imports.wbg.__wbindgen_string_get = function(arg0, arg1) { | ||
const obj = getObject(arg1); | ||
var ret = typeof(obj) === 'string' ? obj : undefined; | ||
var ptr0 = isLikeNone(ret) ? 0 : 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_throw = function(arg0, arg1) { | ||
throw new Error(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
imports.wbg.__wbindgen_closure_wrapper917 = function(arg0, arg1, arg2) { | ||
var ret = makeMutClosure(arg0, arg1, 222, __wbg_adapter_24); | ||
imports.wbg.__wbindgen_closure_wrapper950 = function(arg0, arg1, arg2) { | ||
var ret = makeMutClosure(arg0, arg1, 232, __wbg_adapter_24); | ||
return addHeapObject(ret); | ||
@@ -737,0 +971,0 @@ }; |
@@ -1,52 +0,1 @@ | ||
export class WasmResult { | ||
constructor(value) { | ||
if (value instanceof Error) { | ||
this.Err = value; | ||
} else { | ||
this.Ok = value; | ||
} | ||
} | ||
is_err() { | ||
return this.hasOwnProperty("Err"); | ||
} | ||
is_ok() { | ||
return !this.is_err(); | ||
} | ||
unwrap() { | ||
if (this.is_ok()) { | ||
return this.Ok; | ||
} else { | ||
throw this.Err; | ||
} | ||
} | ||
unwrap_err() { | ||
if (this.is_ok()) { | ||
throw new Error("Called unwrap_err on an Ok value"); | ||
} else { | ||
return this.Err; | ||
} | ||
} | ||
unwrap_or(otherwise) { | ||
if (this.is_ok()) { | ||
return this.Ok; | ||
} else { | ||
return otherwise; | ||
} | ||
} | ||
map(func) { | ||
if (this.is_ok()) { | ||
return new WasmResult(func(this.Ok)); | ||
} else { | ||
return this; | ||
} | ||
} | ||
map_or(otherwise, func) { | ||
if (this.is_ok()) { | ||
return func(this.Ok); | ||
} else { | ||
return otherwise; | ||
} | ||
} | ||
} | ||
export class CiteprocRsError extends Error { | ||
@@ -74,3 +23,2 @@ constructor(message) { | ||
function doExport(onto) { | ||
onto.WasmResult = WasmResult; | ||
onto.CiteprocRsError = CiteprocRsError; | ||
@@ -77,0 +25,0 @@ onto.CslStyleError = CslStyleError; |
/* tslint:disable */ | ||
/* eslint-disable */ | ||
export const memory: WebAssembly.Memory; | ||
export function parseStyleMetadata(a: number, b: number): number; | ||
export function parseStyleMetadata(a: number, b: number, c: number): void; | ||
export function __wbg_driver_free(a: 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_new(a: number, b: number): void; | ||
export function driver_setStyle(a: number, b: number, c: number, d: number): void; | ||
export function driver_setOutputFormat(a: number, b: number, c: number, d: number, e: number): void; | ||
export function driver_resetReferences(a: number, b: number, c: number, d: number): void; | ||
export function driver_insertReferences(a: number, b: number, c: number, d: number): void; | ||
export function driver_insertReference(a: number, b: number, c: number): void; | ||
export function driver_removeReference(a: number, b: number, c: number, d: number): void; | ||
export function driver_includeUncited(a: number, b: number, c: number): void; | ||
export function driver_toFetch(a: number, b: number): void; | ||
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_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_insertCluster(a: number, b: number, c: number): void; | ||
export function driver_removeCluster(a: number, b: number, c: number, d: number): void; | ||
export function driver_initClusters(a: number, b: number, c: number, d: number): void; | ||
export function driver_builtCluster(a: number, b: number, c: number, d: number): void; | ||
export function driver_previewCitationCluster(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): void; | ||
export function driver_previewCluster(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void; | ||
export function driver_makeBibliography(a: number, b: number): void; | ||
export function driver_bibliographyMeta(a: number, b: number): void; | ||
export function driver_setClusterOrder(a: number, b: number, c: number, d: number): void; | ||
export function driver_batchedUpdates(a: number, b: number): void; | ||
export function driver_fullRender(a: number, b: number): void; | ||
export function driver_drain(a: number): void; | ||
@@ -30,6 +32,6 @@ export function driver_fetchLocales(a: number): number; | ||
export const __wbindgen_export_2: WebAssembly.Table; | ||
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2c48d2b80cbc9988(a: number, b: number, c: number): void; | ||
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hee74a5b7602953f2(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__h1d8bf0ad0105b2cc(a: number, b: number, c: number, d: number): void; | ||
export function wasm_bindgen__convert__closures__invoke2_mut__h5e049d289685efc8(a: number, b: number, c: number, d: number): void; |
@@ -1,52 +0,1 @@ | ||
class WasmResult { | ||
constructor(value) { | ||
if (value instanceof Error) { | ||
this.Err = value; | ||
} else { | ||
this.Ok = value; | ||
} | ||
} | ||
is_err() { | ||
return this.hasOwnProperty("Err"); | ||
} | ||
is_ok() { | ||
return !this.is_err(); | ||
} | ||
unwrap() { | ||
if (this.is_ok()) { | ||
return this.Ok; | ||
} else { | ||
throw this.Err; | ||
} | ||
} | ||
unwrap_err() { | ||
if (this.is_ok()) { | ||
throw new Error("Called unwrap_err on an Ok value"); | ||
} else { | ||
return this.Err; | ||
} | ||
} | ||
unwrap_or(otherwise) { | ||
if (this.is_ok()) { | ||
return this.Ok; | ||
} else { | ||
return otherwise; | ||
} | ||
} | ||
map(func) { | ||
if (this.is_ok()) { | ||
return new WasmResult(func(this.Ok)); | ||
} else { | ||
return this; | ||
} | ||
} | ||
map_or(otherwise, func) { | ||
if (this.is_ok()) { | ||
return func(this.Ok); | ||
} else { | ||
return otherwise; | ||
} | ||
} | ||
} | ||
class CiteprocRsError extends Error { | ||
@@ -74,3 +23,2 @@ constructor(message) { | ||
function doExport(onto) { | ||
onto.WasmResult = WasmResult; | ||
onto.CiteprocRsError = CiteprocRsError; | ||
@@ -77,0 +25,0 @@ onto.CslStyleError = CslStyleError; |
@@ -7,131 +7,6 @@ declare namespace wasm_bindgen { | ||
* @param {string} style | ||
* @returns {WasmResult<StyleMeta>} | ||
* @returns {StyleMeta} | ||
*/ | ||
export function parseStyleMetadata(style: string): WasmResult<StyleMeta>; | ||
export function parseStyleMetadata(style: string): 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 Fetcher { | ||
/** Return locale XML for a particular locale. */ | ||
fetchLocale(lang: string): Promise<string>; | ||
} | ||
export type DateLiteral = { "literal": string; }; | ||
export type DateRaw = { "raw": string; }; | ||
export type DatePartsDate = [number] | [number, number] | [number, number, number]; | ||
export type DatePartsSingle = { "date-parts": [DatePartsDate]; }; | ||
export type DatePartsRange = { "date-parts": [DatePartsDate, DatePartsDate]; }; | ||
export type DateParts = DatePartsSingle | DatePartsRange; | ||
export type DateOrRange = DateLiteral | DateRaw | DateParts; | ||
/** Locator type, and a locator string */ | ||
export type Locator = { | ||
label?: string; | ||
locator?: string; | ||
locators: undefined; | ||
}; | ||
export type CiteLocator = Locator | { locator: undefined; locators: Locator[] }; | ||
export type Cite<Affix = string> = { | ||
id: string; | ||
prefix?: Affix; | ||
suffix?: Affix; | ||
suppression?: "InText" | "Rest" | null; | ||
} & Partial<CiteLocator>; | ||
export type ClusterNumber = { | ||
note: number | [number, number] | ||
} | { | ||
inText: number | ||
}; | ||
export type Cluster = { | ||
id: string; | ||
cites: Cite[]; | ||
}; | ||
export type ClusterPosition = { | ||
id: string; | ||
/** Leaving off this field means this cluster is in-text. */ | ||
note?: number; | ||
} | ||
export type Reference = { | ||
id: string; | ||
type: CslType; | ||
[key: string]: any; | ||
}; | ||
export type CslType = "book" | "article" | "legal_case" | "article-journal"; | ||
export interface BibliographyUpdate { | ||
updatedEntries: Map<string, string>; | ||
entryIds?: string[]; | ||
} | ||
export type UpdateSummary<Output = string> = { | ||
clusters: [string, Output][]; | ||
bibliography?: BibliographyUpdate; | ||
}; | ||
type IncludeUncited = "None" | "All" | { Specific: string[] }; | ||
type BibEntry = { | ||
id: string; | ||
value: string; | ||
}; | ||
type BibEntries = BibEntry[]; | ||
type FullRender = { | ||
allClusters: Map<string, string>, | ||
bibEntries: BibEntries, | ||
}; | ||
type BibliographyMeta = { | ||
maxOffset: number; | ||
entrySpacing: number; | ||
lineSpacing: number; | ||
hangingIndent: boolean; | ||
/** the second-field-align value of the CSL style */ | ||
secondFieldAlign: null | "flush" | "margin"; | ||
/** Format-specific metadata */ | ||
formatMeta: any, | ||
}; | ||
type Severity = "Error" | "Warning"; | ||
@@ -147,3 +22,3 @@ interface InvalidCsl { | ||
hint: string | undefined; | ||
}; | ||
} | ||
type StyleError = { | ||
@@ -179,11 +54,23 @@ tag: "Invalid", | ||
declare global { | ||
/** Catch-all citeproc-rs Error subclass. */ | ||
declare class CiteprocRsError extends Error { | ||
/** Catch-all citeproc-rs Error subclass. | ||
* | ||
* CiteprocRsDriverError and CslStyleError are both subclasses of this, so checking instanceof | ||
* CiteprocRsError suffices to catch all errors thrown by @citeproc-rs/wasm itself. | ||
* | ||
* There may be errors that are not a subclass, but directly an instance of CitprocRsError, so | ||
* for completeness in a catch/instanceof check, one should test for this too. | ||
* | ||
* Using the library may also result in WASM runtime errors, and some generic Error objects | ||
* from e.g. using a Driver after you have called `.free()`. | ||
* */ | ||
class CiteprocRsError extends Error { | ||
constructor(message: string); | ||
} | ||
declare class CiteprocRsDriverError extends CiteprocRsError { | ||
/** Error in usage of Driver */ | ||
class CiteprocRsDriverError extends CiteprocRsError { | ||
data: DriverError; | ||
constructor(message: string, data: DriverError); | ||
} | ||
declare class CslStyleError extends CiteprocRsError { | ||
/** Error parsing a CSL file */ | ||
class CslStyleError extends CiteprocRsError { | ||
data: StyleError; | ||
@@ -196,51 +83,125 @@ 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; | ||
interface FormatOptions { | ||
linkAnchors?: boolean; | ||
} | ||
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 (default: html) */ | ||
format?: "html" | "rtf" | "plain"; | ||
/** Configuration for the formatter */ | ||
formatOptions?: FormatOptions; | ||
/** Optional array of CSL feature names to activate globally. Features are kebab-case. */ | ||
cslFeatures?: string[]; | ||
/** 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?: boolean; | ||
} | ||
/** This interface lets citeproc retrieve locales or modules asynchronously, | ||
according to which ones are needed. */ | ||
export interface Fetcher { | ||
/** Return locale XML for a particular locale. */ | ||
fetchLocale(lang: string): Promise<string>; | ||
} | ||
interface BibliographyUpdate { | ||
updatedEntries: Map<string, string>; | ||
entryIds?: string[]; | ||
} | ||
type UpdateSummary<Output = string> = { | ||
clusters: [string, Output][]; | ||
bibliography?: BibliographyUpdate; | ||
}; | ||
interface BibEntry { | ||
id: string; | ||
value: string; | ||
} | ||
interface FullRender { | ||
allClusters: Map<string, string>; | ||
bibEntries: BibEntry[]; | ||
} | ||
interface BibliographyMeta { | ||
maxOffset: number; | ||
entrySpacing: number; | ||
lineSpacing: number; | ||
hangingIndent: boolean; | ||
/** the second-field-align value of the CSL style */ | ||
secondFieldAlign: null | "flush" | "margin"; | ||
/** Format-specific metadata */ | ||
formatMeta: any; | ||
} | ||
interface StyleMeta { | ||
info: StyleInfo; | ||
features: { [feature: string]: boolean }; | ||
defaultLocale: string; | ||
/** May be absent on a dependent style */ | ||
class?: "in-text" | "note"; | ||
cslVersionRequired: string; | ||
/** May be absent on a dependent style */ | ||
independentMeta?: IndependentMeta; | ||
} | ||
type CitationFormat = "author-date" | "author" | "numeric" | "label" | "note"; | ||
interface LocalizedString { | ||
value: string, | ||
lang?: string, | ||
value: string; | ||
lang?: string; | ||
} | ||
interface ParentLink { | ||
href: string, | ||
lang?: string, | ||
href: string; | ||
lang?: string; | ||
} | ||
interface Link { | ||
href: string, | ||
rel: "self" | "documentation" | "template", | ||
lang?: string, | ||
href: string; | ||
rel: "self" | "documentation" | "template"; | ||
lang?: string; | ||
} | ||
interface Rights { | ||
value: string, | ||
lang?: string, | ||
license?: string, | ||
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, | ||
id: string; | ||
updated: string; | ||
title: LocalizedString; | ||
titleShort?: LocalizedString; | ||
parent?: ParentLink; | ||
links: Link[]; | ||
rights?: Rights; | ||
citationFormat?: CitationFormat; | ||
categories: string[]; | ||
issn?: string; | ||
eissn?: string; | ||
issnl?: string; | ||
} | ||
@@ -250,17 +211,69 @@ interface IndependentMeta { | ||
* Does not include the language-less final override. */ | ||
localeOverrides: string[], | ||
hasBibliography: bool, | ||
localeOverrides: string[]; | ||
hasBibliography: boolean; | ||
} | ||
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, | ||
/** Locator type, and a locator string */ | ||
export type Locator = { | ||
label?: string; | ||
locator?: string; | ||
locators: undefined; | ||
}; | ||
export type CiteLocator = Locator | { locator: undefined; locators: Locator[]; }; | ||
export type CiteMode = { mode?: "SuppressAuthor" | "AuthorOnly"; }; | ||
export type Cite = { | ||
id: string; | ||
prefix?: string; | ||
suffix?: string; | ||
} & Partial<CiteLocator> & CiteMode; | ||
export type ClusterMode | ||
= { mode: "Composite"; infix?: string; suppressFirst?: number; } | ||
| { mode: "SuppressAuthor"; suppressFirst?: number; } | ||
| { mode: "AuthorOnly"; } | ||
| {}; | ||
export type Cluster = { | ||
id: string; | ||
cites: Cite[]; | ||
} & ClusterMode; | ||
export type PreviewCluster = { | ||
cites: Cite[]; | ||
} & ClusterMode; | ||
export type ClusterPosition = { | ||
id: string; | ||
/** Leaving off this field means this cluster is in-text. */ | ||
note?: number; | ||
} | ||
type Reference = { | ||
id: string; | ||
type: CslType; | ||
[key: string]: any; | ||
}; | ||
export type CslType = "book" | "legal_case" | "article-journal" | string; | ||
type IncludeUncited = "None" | "All" | { Specific: string[] }; | ||
type DateLiteral = { "literal": string; }; | ||
type DateRaw = { "raw": string; }; | ||
type DatePartsDate = [number] | [number, number] | [number, number, number]; | ||
type DatePartsSingle = { "date-parts": [DatePartsDate]; }; | ||
type DatePartsRange = { "date-parts": [DatePartsDate, DatePartsDate]; }; | ||
type DateParts = DatePartsSingle | DatePartsRange; | ||
type DateOrRange = DateLiteral | DateRaw | DateParts; | ||
/** | ||
@@ -271,26 +284,33 @@ */ | ||
/** | ||
* Creates a new Driver. | ||
* Creates a new Driver. Use the InitOptions object, which has (for example): | ||
* | ||
* * `style` is a CSL style as a string. Independent styles only. | ||
* * `fetcher` must implement the `Fetcher` interface | ||
* * `format` is one of { "html", "rtf" } | ||
* * `format` is one of { "html", "rtf", "plain" } | ||
* | ||
* Throws an error if it cannot parse the style you gave it. | ||
* @param {InitOptions} options | ||
* @returns {WasmResult<Driver>} | ||
*/ | ||
static new(options: InitOptions): WasmResult<Driver>; | ||
constructor(options: InitOptions); | ||
/** | ||
* Sets the style (which will also cause everything to be recomputed) | ||
* Sets the style (which will also cause everything to be recomputed, use sparingly) | ||
* @param {string} style_text | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
setStyle(style_text: string): WasmResult<undefined>; | ||
setStyle(style_text: string): void; | ||
/** | ||
* Sets the output format (which will also cause everything to be recomputed, use sparingly) | ||
* | ||
* @param {"html" | "rtf" | "plain"} format The new output format as a string, same as `new Driver` | ||
* | ||
* @param {FormatOptions | null} options If absent, this is set to the default FormatOptions. | ||
* @param {string} format | ||
* @param {FormatOptions | undefined} options | ||
*/ | ||
setOutputFormat(format: string, options?: FormatOptions): void; | ||
/** | ||
* Completely overwrites the references library. | ||
* This **will** delete references that are not in the provided list. | ||
* @param {any[]} refs | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
resetReferences(refs: any[]): WasmResult<undefined>; | ||
resetReferences(refs: any[]): void; | ||
/** | ||
@@ -300,5 +320,4 @@ * Inserts or overwrites references as a batch operation. | ||
* @param {any[]} refs | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
insertReferences(refs: any[]): WasmResult<undefined>; | ||
insertReferences(refs: any[]): void; | ||
/** | ||
@@ -309,5 +328,4 @@ * Inserts or overwrites a reference. | ||
* @param {Reference} refr | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
insertReference(refr: Reference): WasmResult<undefined>; | ||
insertReference(refr: Reference): void; | ||
/** | ||
@@ -317,5 +335,4 @@ * 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): WasmResult<undefined>; | ||
removeReference(id: string): void; | ||
/** | ||
@@ -326,5 +343,4 @@ * Sets the references to be included in the bibliography despite not being directly cited. | ||
* @param {IncludeUncited} uncited | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
includeUncited(uncited: IncludeUncited): WasmResult<undefined>; | ||
includeUncited(uncited: IncludeUncited): void; | ||
/** | ||
@@ -334,5 +350,5 @@ * Gets a list of locales in use by the references currently loaded. | ||
* Note that Driver comes pre-loaded with the `en-US` locale. | ||
* @returns {WasmResult<string[]>} | ||
* @returns {string[]} | ||
*/ | ||
toFetch(): WasmResult<string[]>; | ||
toFetch(): string[]; | ||
/** | ||
@@ -345,12 +361,10 @@ * Returns a random cluster id, with an extra guarantee that it isn't already in use. | ||
* Inserts or replaces a cluster with a matching `id`. | ||
* @param {any} cluster | ||
* @returns {WasmResult<undefined>} | ||
* @param {Cluster} cluster | ||
*/ | ||
insertCluster(cluster: any): WasmResult<undefined>; | ||
insertCluster(cluster: Cluster): void; | ||
/** | ||
* Removes a cluster with a matching `id` | ||
* @param {string} cluster_id | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
removeCluster(cluster_id: string): WasmResult<undefined>; | ||
removeCluster(cluster_id: string): void; | ||
/** | ||
@@ -361,5 +375,4 @@ * Resets all the clusters in the processor to a new list. | ||
* @param {any[]} clusters | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
initClusters(clusters: any[]): WasmResult<undefined>; | ||
initClusters(clusters: any[]): void; | ||
/** | ||
@@ -371,9 +384,17 @@ * Returns the formatted citation cluster for `cluster_id`. | ||
* @param {string} id | ||
* @returns {WasmResult<string>} | ||
* @returns {string} | ||
*/ | ||
builtCluster(id: string): WasmResult<string>; | ||
builtCluster(id: string): string; | ||
/** | ||
* @deprecated Use `previewCluster` instead | ||
* @param {any[]} cites | ||
* @param {any[]} positions | ||
* @param {string | undefined} format | ||
* @returns {string} | ||
*/ | ||
previewCitationCluster(cites: any[], positions: any[], format?: string): string; | ||
/** | ||
* Previews a formatted citation cluster, in a particular position. | ||
* | ||
* - `cites`: The cites to go in the cluster | ||
* - `cluster`: A cluster, without an `id` field. You'll want this to contain some cites. | ||
* - `positions`: An array of `ClusterPosition`s as in set_cluster_order, but with a single | ||
@@ -383,16 +404,18 @@ * cluster's id set to zero. The cluster with id=0 is the position to preview the cite. It | ||
* any location you can think of. | ||
* @param {any[]} cites | ||
* - `format`: an optional argument, an output format as a string, that is used only for this | ||
* preview. | ||
* @param {PreviewCluster} preview_cluster | ||
* @param {any[]} positions | ||
* @param {string} format | ||
* @returns {WasmResult<string>} | ||
* @param {string | undefined} format | ||
* @returns {string} | ||
*/ | ||
previewCitationCluster(cites: any[], positions: any[], format: string): WasmResult<string>; | ||
previewCluster(preview_cluster: PreviewCluster, positions: any[], format?: string): string; | ||
/** | ||
* @returns {WasmResult<BibEntries>} | ||
* @returns {BibEntry[]} | ||
*/ | ||
makeBibliography(): WasmResult<BibEntries>; | ||
makeBibliography(): BibEntry[]; | ||
/** | ||
* @returns {WasmResult<BibliographyMeta>} | ||
* @returns {BibliographyMeta} | ||
*/ | ||
bibliographyMeta(): WasmResult<BibliographyMeta>; | ||
bibliographyMeta(): BibliographyMeta; | ||
/** | ||
@@ -423,5 +446,4 @@ * Specifies which clusters are actually considered to be in the document, and sets their | ||
* @param {any[]} positions | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
setClusterOrder(positions: any[]): WasmResult<undefined>; | ||
setClusterOrder(positions: any[]): void; | ||
/** | ||
@@ -435,5 +457,5 @@ * Retrieve any clusters that have been touched since last time `batchedUpdates` was | ||
* * returns an `UpdateSummary` | ||
* @returns {WasmResult<UpdateSummary>} | ||
* @returns {UpdateSummary} | ||
*/ | ||
batchedUpdates(): WasmResult<UpdateSummary>; | ||
batchedUpdates(): UpdateSummary; | ||
/** | ||
@@ -443,5 +465,5 @@ * Returns all the clusters and bibliography entries in the document. | ||
* Use this to rehydrate a document or run non-interactively. | ||
* @returns {WasmResult<FullRender>} | ||
* @returns {FullRender} | ||
*/ | ||
fullRender(): WasmResult<FullRender>; | ||
fullRender(): FullRender; | ||
/** | ||
@@ -465,23 +487,25 @@ * Drains the `batchedUpdates` queue manually. | ||
readonly memory: WebAssembly.Memory; | ||
readonly parseStyleMetadata: (a: number, b: number) => number; | ||
readonly parseStyleMetadata: (a: number, b: number, c: number) => void; | ||
readonly __wbg_driver_free: (a: 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_new: (a: number, b: number) => void; | ||
readonly driver_setStyle: (a: number, b: number, c: number, d: number) => void; | ||
readonly driver_setOutputFormat: (a: number, b: number, c: number, d: number, e: number) => void; | ||
readonly driver_resetReferences: (a: number, b: number, c: number, d: number) => void; | ||
readonly driver_insertReferences: (a: number, b: number, c: number, d: number) => void; | ||
readonly driver_insertReference: (a: number, b: number, c: number) => void; | ||
readonly driver_removeReference: (a: number, b: number, c: number, d: number) => void; | ||
readonly driver_includeUncited: (a: number, b: number, c: number) => void; | ||
readonly driver_toFetch: (a: number, b: number) => void; | ||
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_setClusterOrder: (a: number, b: number, c: number) => number; | ||
readonly driver_batchedUpdates: (a: number) => number; | ||
readonly driver_fullRender: (a: number) => number; | ||
readonly driver_insertCluster: (a: number, b: number, c: number) => void; | ||
readonly driver_removeCluster: (a: number, b: number, c: number, d: number) => void; | ||
readonly driver_initClusters: (a: number, b: number, c: number, d: number) => void; | ||
readonly driver_builtCluster: (a: number, b: number, c: number, d: number) => void; | ||
readonly driver_previewCitationCluster: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void; | ||
readonly driver_previewCluster: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void; | ||
readonly driver_makeBibliography: (a: number, b: number) => void; | ||
readonly driver_bibliographyMeta: (a: number, b: number) => void; | ||
readonly driver_setClusterOrder: (a: number, b: number, c: number, d: number) => void; | ||
readonly driver_batchedUpdates: (a: number, b: number) => void; | ||
readonly driver_fullRender: (a: number, b: number) => void; | ||
readonly driver_drain: (a: number) => void; | ||
@@ -492,7 +516,7 @@ readonly driver_fetchLocales: (a: number) => number; | ||
readonly __wbindgen_export_2: WebAssembly.Table; | ||
readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2c48d2b80cbc9988: (a: number, b: number, c: number) => void; | ||
readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hee74a5b7602953f2: (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__h1d8bf0ad0105b2cc: (a: number, b: number, c: number, d: number) => void; | ||
readonly wasm_bindgen__convert__closures__invoke2_mut__h5e049d289685efc8: (a: number, b: number, c: number, d: number) => void; | ||
} | ||
@@ -499,0 +523,0 @@ |
@@ -6,2 +6,18 @@ let wasm_bindgen; | ||
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
cachedTextDecoder.decode(); | ||
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) { | ||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); | ||
} | ||
const heap = new Array(32).fill(undefined); | ||
@@ -11,6 +27,15 @@ | ||
let heap_next = heap.length; | ||
function addHeapObject(obj) { | ||
if (heap_next === heap.length) heap.push(heap.length + 1); | ||
const idx = heap_next; | ||
heap_next = heap[idx]; | ||
heap[idx] = obj; | ||
return idx; | ||
} | ||
function getObject(idx) { return heap[idx]; } | ||
let heap_next = heap.length; | ||
function dropObject(idx) { | ||
@@ -30,10 +55,2 @@ if (idx < 36) return; | ||
let cachegetUint8Memory0 = null; | ||
function getUint8Memory0() { | ||
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) { | ||
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer); | ||
} | ||
return cachegetUint8Memory0; | ||
} | ||
let cachedTextEncoder = new TextEncoder('utf-8'); | ||
@@ -92,2 +109,6 @@ | ||
function isLikeNone(x) { | ||
return x === undefined || x === null; | ||
} | ||
let cachegetInt32Memory0 = null; | ||
@@ -101,23 +122,2 @@ function getInt32Memory0() { | ||
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
cachedTextDecoder.decode(); | ||
function getStringFromWasm0(ptr, len) { | ||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); | ||
} | ||
function addHeapObject(obj) { | ||
if (heap_next === heap.length) heap.push(heap.length + 1); | ||
const idx = heap_next; | ||
heap_next = heap[idx]; | ||
heap[idx] = obj; | ||
return idx; | ||
} | ||
function isLikeNone(x) { | ||
return x === undefined || x === null; | ||
} | ||
function makeMutClosure(arg0, arg1, dtor, f) { | ||
@@ -148,3 +148,3 @@ const state = { a: arg0, b: arg1, cnt: 1, dtor }; | ||
function __wbg_adapter_24(arg0, arg1, arg2) { | ||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2c48d2b80cbc9988(arg0, arg1, addHeapObject(arg2)); | ||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hee74a5b7602953f2(arg0, arg1, addHeapObject(arg2)); | ||
} | ||
@@ -155,9 +155,20 @@ | ||
* @param {string} style | ||
* @returns {WasmResult<StyleMeta>} | ||
* @returns {StyleMeta} | ||
*/ | ||
__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); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(style, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.parseStyleMetadata(retptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
}; | ||
@@ -183,14 +194,11 @@ | ||
function handleError(f) { | ||
return function () { | ||
try { | ||
return f.apply(this, arguments); | ||
} catch (e) { | ||
wasm.__wbindgen_exn_store(addHeapObject(e)); | ||
} | ||
}; | ||
function handleError(f, args) { | ||
try { | ||
return f.apply(this, args); | ||
} catch (e) { | ||
wasm.__wbindgen_exn_store(addHeapObject(e)); | ||
} | ||
} | ||
function __wbg_adapter_81(arg0, arg1, arg2, arg3) { | ||
wasm.wasm_bindgen__convert__closures__invoke2_mut__h1d8bf0ad0105b2cc(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); | ||
function __wbg_adapter_79(arg0, arg1, arg2, arg3) { | ||
wasm.wasm_bindgen__convert__closures__invoke2_mut__h5e049d289685efc8(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); | ||
} | ||
@@ -224,38 +232,88 @@ | ||
/** | ||
* Creates a new Driver. | ||
* Creates a new Driver. Use the InitOptions object, which has (for example): | ||
* | ||
* * `style` is a CSL style as a string. Independent styles only. | ||
* * `fetcher` must implement the `Fetcher` interface | ||
* * `format` is one of { "html", "rtf" } | ||
* * `format` is one of { "html", "rtf", "plain" } | ||
* | ||
* Throws an error if it cannot parse the style you gave it. | ||
* @param {InitOptions} options | ||
* @returns {WasmResult<Driver>} | ||
*/ | ||
static new(options) { | ||
var ret = wasm.driver_new(addHeapObject(options)); | ||
return takeObject(ret); | ||
constructor(options) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_new(retptr, addHeapObject(options)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return Driver.__wrap(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
/** | ||
* Sets the style (which will also cause everything to be recomputed) | ||
* Sets the style (which will also cause everything to be recomputed, use sparingly) | ||
* @param {string} style_text | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
setStyle(style_text) { | ||
var ptr0 = passStringToWasm0(style_text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_setStyle(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(style_text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_setStyle(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
/** | ||
* Sets the output format (which will also cause everything to be recomputed, use sparingly) | ||
* | ||
* @param {"html" | "rtf" | "plain"} format The new output format as a string, same as `new Driver` | ||
* | ||
* @param {FormatOptions | null} options If absent, this is set to the default FormatOptions. | ||
* @param {string} format | ||
* @param {FormatOptions | undefined} options | ||
*/ | ||
setOutputFormat(format, options) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_setOutputFormat(retptr, this.ptr, ptr0, len0, isLikeNone(options) ? 0 : addHeapObject(options)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
/** | ||
* Completely overwrites the references library. | ||
* This **will** delete references that are not in the provided list. | ||
* @param {any[]} refs | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
resetReferences(refs) { | ||
var ptr0 = passArrayJsValueToWasm0(refs, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_resetReferences(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(refs, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_resetReferences(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -266,9 +324,17 @@ /** | ||
* @param {any[]} refs | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
insertReferences(refs) { | ||
var ptr0 = passArrayJsValueToWasm0(refs, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_insertReferences(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(refs, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_insertReferences(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -280,7 +346,15 @@ /** | ||
* @param {Reference} refr | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
insertReference(refr) { | ||
var ret = wasm.driver_insertReference(this.ptr, addHeapObject(refr)); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_insertReference(retptr, this.ptr, addHeapObject(refr)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -291,9 +365,17 @@ /** | ||
* @param {string} id | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
removeReference(id) { | ||
var ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_removeReference(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_removeReference(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -305,7 +387,15 @@ /** | ||
* @param {IncludeUncited} uncited | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
includeUncited(uncited) { | ||
var ret = wasm.driver_includeUncited(this.ptr, addHeapObject(uncited)); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_includeUncited(retptr, this.ptr, addHeapObject(uncited)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -316,7 +406,18 @@ /** | ||
* Note that Driver comes pre-loaded with the `en-US` locale. | ||
* @returns {WasmResult<string[]>} | ||
* @returns {string[]} | ||
*/ | ||
toFetch() { | ||
var ret = wasm.driver_toFetch(this.ptr); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_toFetch(retptr, this.ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -341,8 +442,16 @@ /** | ||
* Inserts or replaces a cluster with a matching `id`. | ||
* @param {any} cluster | ||
* @returns {WasmResult<undefined>} | ||
* @param {Cluster} cluster | ||
*/ | ||
insertCluster(cluster) { | ||
var ret = wasm.driver_insertCluster(this.ptr, addHeapObject(cluster)); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_insertCluster(retptr, this.ptr, addHeapObject(cluster)); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -352,9 +461,17 @@ /** | ||
* @param {string} cluster_id | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
removeCluster(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); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(cluster_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_removeCluster(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -366,9 +483,17 @@ /** | ||
* @param {any[]} clusters | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
initClusters(clusters) { | ||
var ptr0 = passArrayJsValueToWasm0(clusters, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_initClusters(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(clusters, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_initClusters(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -381,14 +506,63 @@ /** | ||
* @param {string} id | ||
* @returns {WasmResult<string>} | ||
* @returns {string} | ||
*/ | ||
builtCluster(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); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_builtCluster(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
var r3 = getInt32Memory0()[retptr / 4 + 3]; | ||
var ptr1 = r0; | ||
var len1 = r1; | ||
if (r3) { | ||
ptr1 = 0; len1 = 0; | ||
throw takeObject(r2); | ||
} | ||
return getStringFromWasm0(ptr1, len1); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
wasm.__wbindgen_free(ptr1, len1); | ||
} | ||
} | ||
/** | ||
* @deprecated Use `previewCluster` instead | ||
* @param {any[]} cites | ||
* @param {any[]} positions | ||
* @param {string | undefined} format | ||
* @returns {string} | ||
*/ | ||
previewCitationCluster(cites, positions, format) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(cites, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ptr1 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len1 = WASM_VECTOR_LEN; | ||
var ptr2 = isLikeNone(format) ? 0 : passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len2 = WASM_VECTOR_LEN; | ||
wasm.driver_previewCitationCluster(retptr, this.ptr, ptr0, len0, ptr1, len1, ptr2, len2); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
var r3 = getInt32Memory0()[retptr / 4 + 3]; | ||
var ptr3 = r0; | ||
var len3 = r1; | ||
if (r3) { | ||
ptr3 = 0; len3 = 0; | ||
throw takeObject(r2); | ||
} | ||
return getStringFromWasm0(ptr3, len3); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
wasm.__wbindgen_free(ptr3, len3); | ||
} | ||
} | ||
/** | ||
* Previews a formatted citation cluster, in a particular position. | ||
* | ||
* - `cites`: The cites to go in the cluster | ||
* - `cluster`: A cluster, without an `id` field. You'll want this to contain some cites. | ||
* - `positions`: An array of `ClusterPosition`s as in set_cluster_order, but with a single | ||
@@ -398,30 +572,68 @@ * cluster's id set to zero. The cluster with id=0 is the position to preview the cite. It | ||
* any location you can think of. | ||
* @param {any[]} cites | ||
* - `format`: an optional argument, an output format as a string, that is used only for this | ||
* preview. | ||
* @param {PreviewCluster} preview_cluster | ||
* @param {any[]} positions | ||
* @param {string} format | ||
* @returns {WasmResult<string>} | ||
* @param {string | undefined} format | ||
* @returns {string} | ||
*/ | ||
previewCitationCluster(cites, positions, format) { | ||
var ptr0 = passArrayJsValueToWasm0(cites, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ptr1 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len1 = WASM_VECTOR_LEN; | ||
var ptr2 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len2 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_previewCitationCluster(this.ptr, ptr0, len0, ptr1, len1, ptr2, len2); | ||
return takeObject(ret); | ||
previewCluster(preview_cluster, positions, format) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ptr1 = isLikeNone(format) ? 0 : passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len1 = WASM_VECTOR_LEN; | ||
wasm.driver_previewCluster(retptr, this.ptr, addHeapObject(preview_cluster), ptr0, len0, ptr1, len1); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
var r3 = getInt32Memory0()[retptr / 4 + 3]; | ||
var ptr2 = r0; | ||
var len2 = r1; | ||
if (r3) { | ||
ptr2 = 0; len2 = 0; | ||
throw takeObject(r2); | ||
} | ||
return getStringFromWasm0(ptr2, len2); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
wasm.__wbindgen_free(ptr2, len2); | ||
} | ||
} | ||
/** | ||
* @returns {WasmResult<BibEntries>} | ||
* @returns {BibEntry[]} | ||
*/ | ||
makeBibliography() { | ||
var ret = wasm.driver_makeBibliography(this.ptr); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_makeBibliography(retptr, this.ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
/** | ||
* @returns {WasmResult<BibliographyMeta>} | ||
* @returns {BibliographyMeta} | ||
*/ | ||
bibliographyMeta() { | ||
var ret = wasm.driver_bibliographyMeta(this.ptr); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_bibliographyMeta(retptr, this.ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -453,9 +665,17 @@ /** | ||
* @param {any[]} positions | ||
* @returns {WasmResult<undefined>} | ||
*/ | ||
setClusterOrder(positions) { | ||
var ptr0 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ret = wasm.driver_setClusterOrder(this.ptr, ptr0, len0); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passArrayJsValueToWasm0(positions, wasm.__wbindgen_malloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
wasm.driver_setClusterOrder(retptr, this.ptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -470,7 +690,18 @@ /** | ||
* * returns an `UpdateSummary` | ||
* @returns {WasmResult<UpdateSummary>} | ||
* @returns {UpdateSummary} | ||
*/ | ||
batchedUpdates() { | ||
var ret = wasm.driver_batchedUpdates(this.ptr); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_batchedUpdates(retptr, this.ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -481,7 +712,18 @@ /** | ||
* Use this to rehydrate a document or run non-interactively. | ||
* @returns {WasmResult<FullRender>} | ||
* @returns {FullRender} | ||
*/ | ||
fullRender() { | ||
var ret = wasm.driver_fullRender(this.ptr); | ||
return takeObject(ret); | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.driver_fullRender(retptr, this.ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return takeObject(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
} | ||
@@ -549,5 +791,29 @@ /** | ||
imports.wbg = {}; | ||
imports.wbg.__wbindgen_string_new = function(arg0, arg1) { | ||
var ret = getStringFromWasm0(arg0, arg1); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_new_16465ddabcb4a719 = function(arg0, arg1) { | ||
var ret = new Zotero.CiteprocRs.CiteprocRsDriverError(takeObject(arg0), takeObject(arg1)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_new_1f7db38dfd81bf2f = function(arg0) { | ||
var ret = new Zotero.CiteprocRs.CiteprocRsError(takeObject(arg0)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_new_bb3cad8cb87701ce = function(arg0, arg1) { | ||
var ret = new Zotero.CiteprocRs.CslStyleError(takeObject(arg0), takeObject(arg1)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbindgen_object_drop_ref = function(arg0) { | ||
takeObject(arg0); | ||
}; | ||
imports.wbg.__wbindgen_string_get = function(arg0, arg1) { | ||
const obj = getObject(arg1); | ||
var ret = typeof(obj) === 'string' ? obj : undefined; | ||
var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
getInt32Memory0()[arg0 / 4 + 1] = len0; | ||
getInt32Memory0()[arg0 / 4 + 0] = ptr0; | ||
}; | ||
imports.wbg.__wbg_error_e549f7fed6d655aa = function(arg0) { | ||
@@ -571,2 +837,23 @@ console.error(takeObject(arg0)); | ||
}; | ||
imports.wbg.__wbindgen_object_clone_ref = function(arg0) { | ||
var ret = getObject(arg0); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_get_1edc26456ed84f9b = function(arg0, arg1) { | ||
var ret = getObject(arg0)[takeObject(arg1)]; | ||
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.__wbindgen_json_serialize = function(arg0, arg1) { | ||
@@ -580,4 +867,4 @@ const obj = getObject(arg1); | ||
}; | ||
imports.wbg.__wbindgen_string_new = function(arg0, arg1) { | ||
var ret = getStringFromWasm0(arg0, arg1); | ||
imports.wbg.__wbg_fetchLocale_d644d4ae2ca50f81 = function(arg0, arg1, arg2) { | ||
var ret = getObject(arg0).fetchLocale(getStringFromWasm0(arg1, arg2)); | ||
return addHeapObject(ret); | ||
@@ -594,10 +881,2 @@ }; | ||
}; | ||
imports.wbg.__wbg_fetchLocale_d644d4ae2ca50f81 = function(arg0, arg1, arg2) { | ||
var ret = getObject(arg0).fetchLocale(getStringFromWasm0(arg1, arg2)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_get_1edc26456ed84f9b = function(arg0, arg1) { | ||
var ret = getObject(arg0)[takeObject(arg1)]; | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbindgen_json_parse = function(arg0, arg1) { | ||
@@ -607,44 +886,7 @@ var ret = JSON.parse(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
imports.wbg.__wbg_driver_new = function(arg0) { | ||
var ret = Driver.__wrap(arg0); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_new_1f7db38dfd81bf2f = function(arg0) { | ||
var ret = new Zotero.CiteprocRs.CiteprocRsError(takeObject(arg0)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_new_bb3cad8cb87701ce = function(arg0, arg1) { | ||
var ret = new Zotero.CiteprocRs.CslStyleError(takeObject(arg0), takeObject(arg1)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_new_90da75e9c7c4fa61 = function(arg0) { | ||
var ret = new Zotero.CiteprocRs.WasmResult(takeObject(arg0)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_new_16465ddabcb4a719 = function(arg0, arg1) { | ||
var ret = new Zotero.CiteprocRs.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_new_59cb74e423758ede = function() { | ||
imports.wbg.__wbg_new_693216e109162396 = function() { | ||
var ret = new Error(); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_stack_558ba5917b466edd = function(arg0, arg1) { | ||
imports.wbg.__wbg_stack_0ddaca5d1abfb52f = function(arg0, arg1) { | ||
var ret = getObject(arg1).stack; | ||
@@ -656,3 +898,3 @@ var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
}; | ||
imports.wbg.__wbg_error_4bb6c2a97407129a = function(arg0, arg1) { | ||
imports.wbg.__wbg_error_09919627ac0992f5 = function(arg0, arg1) { | ||
try { | ||
@@ -664,7 +906,7 @@ console.error(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
imports.wbg.__wbg_call_f5e0576f61ee7461 = handleError(function(arg0, arg1, arg2) { | ||
imports.wbg.__wbg_call_346669c262382ad7 = function() { return handleError(function (arg0, arg1, arg2) { | ||
var ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); | ||
return addHeapObject(ret); | ||
}); | ||
imports.wbg.__wbg_new_3ea8490cd276c848 = function(arg0, arg1) { | ||
}, arguments) }; | ||
imports.wbg.__wbg_new_b1d61b5687f5e73a = function(arg0, arg1) { | ||
try { | ||
@@ -676,3 +918,3 @@ var state0 = {a: arg0, b: arg1}; | ||
try { | ||
return __wbg_adapter_81(a, state0.b, arg0, arg1); | ||
return __wbg_adapter_79(a, state0.b, arg0, arg1); | ||
} finally { | ||
@@ -688,18 +930,18 @@ state0.a = a; | ||
}; | ||
imports.wbg.__wbg_resolve_778af3f90b8e2b59 = function(arg0) { | ||
imports.wbg.__wbg_resolve_d23068002f584f22 = function(arg0) { | ||
var ret = Promise.resolve(getObject(arg0)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_then_367b3e718069cfb9 = function(arg0, arg1) { | ||
imports.wbg.__wbg_then_2fcac196782070cc = function(arg0, arg1) { | ||
var ret = getObject(arg0).then(getObject(arg1)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_then_ac66ca61394bfd21 = function(arg0, arg1, arg2) { | ||
imports.wbg.__wbg_then_8c2d62e8ae5978f7 = function(arg0, arg1, arg2) { | ||
var ret = getObject(arg0).then(getObject(arg1), getObject(arg2)); | ||
return addHeapObject(ret); | ||
}; | ||
imports.wbg.__wbg_self_1c83eb4471d9eb9b = handleError(function() { | ||
imports.wbg.__wbg_self_1c83eb4471d9eb9b = function() { return handleError(function () { | ||
var ret = self.self; | ||
return addHeapObject(ret); | ||
}); | ||
}, arguments) }; | ||
imports.wbg.__wbg_static_accessor_MODULE_abf5ae284bffdf45 = function() { | ||
@@ -731,15 +973,7 @@ var ret = module; | ||
}; | ||
imports.wbg.__wbindgen_string_get = function(arg0, arg1) { | ||
const obj = getObject(arg1); | ||
var ret = typeof(obj) === 'string' ? obj : undefined; | ||
var ptr0 = isLikeNone(ret) ? 0 : 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_throw = function(arg0, arg1) { | ||
throw new Error(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
imports.wbg.__wbindgen_closure_wrapper917 = function(arg0, arg1, arg2) { | ||
var ret = makeMutClosure(arg0, arg1, 222, __wbg_adapter_24); | ||
imports.wbg.__wbindgen_closure_wrapper950 = function(arg0, arg1, arg2) { | ||
var ret = makeMutClosure(arg0, arg1, 232, __wbg_adapter_24); | ||
return addHeapObject(ret); | ||
@@ -746,0 +980,0 @@ }; |
@@ -7,3 +7,3 @@ { | ||
"description": "citeproc-rs, compiled to WebAssembly", | ||
"version": "0.0.0-canary-5252fbd", | ||
"version": "0.0.0-canary-55a644c", | ||
"license": "MPL-2.0", | ||
@@ -10,0 +10,0 @@ "repository": { |
214
README.md
@@ -79,3 +79,3 @@ # `@citeproc-rs/wasm` | ||
You can use the regular-import Driver as a TypeScript type anywhere, just don't | ||
use it to call `.new()`. | ||
use it to call `new Driver()`. | ||
@@ -209,3 +209,3 @@ ##### React | ||
try { | ||
driver = Zotero.CiteprocRs.Driver.new({...}).unwrap(); | ||
driver = new Zotero.CiteprocRs.Driver({...}); | ||
} catch (e) { | ||
@@ -241,24 +241,35 @@ if (e instanceof Zotero.CiteprocRs.CslStyleError) { | ||
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. | ||
Many Driver methods can throw errors. | ||
If you want to handle the errors from this library specifically, 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(); | ||
try { | ||
let driver = new Driver({ ... }); | ||
// do stuff with driver | ||
} catch (error) { | ||
if (error instanceof CslStyleError) { | ||
console.warn("Could not parse CSL, error:", error); | ||
// You can also | ||
// throw error; | ||
console.error("Could not parse CSL, error:", error); | ||
} else if (error instanceof CiteprocRsDriverError) { | ||
console.error("Error in usage of Driver", error); | ||
} else if (error instanceof CiteprocRsError) { | ||
// CslStyleError and CiteprocRsDriverError are both subclasses of | ||
// CiteprocRsError, so this branch would catch them too had they not | ||
// been checked already. | ||
// | ||
// There may be errors that are not a subclass, but directly an | ||
// instance of CitprocRsError, so for completeness one should test for | ||
// this too. | ||
console.error("Catch-all error", error); | ||
} else { | ||
throw error; | ||
} | ||
} else { | ||
let driver = result.unwrap(); | ||
} finally { | ||
// Driver is only undefined if `new Driver` threw an error. | ||
if (driver) { | ||
driver.free() | ||
} | ||
} | ||
// ... | ||
driver.free(); // No unwrap. | ||
``` | ||
@@ -268,8 +279,2 @@ | ||
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 | ||
@@ -287,5 +292,8 @@ | ||
let fetcher = ...; // see below | ||
let driverResult = Driver.new({ | ||
let driver = new Driver({ | ||
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 | ||
@@ -295,4 +303,2 @@ // bibliographyNoSort: true // disables sorting on the bibliography | ||
}); | ||
// Throw any errors, get the inner Driver | ||
let driver = driverResult.unwrap(); | ||
// Fetch the chain of locale files required to use the specified locale | ||
@@ -332,3 +338,3 @@ await driver.fetchLocales(); | ||
let fetcher = new Fetcher(); | ||
let driver = Driver.new({ ..., fetcher }).unwrap(); | ||
let driver = new Driver({ ..., fetcher }); | ||
// Make sure you actually fetch them! | ||
@@ -341,3 +347,3 @@ await driver.fetchLocales(); | ||
Declining to provide a locale fetcher in `Driver.new` or forgetting to call | ||
Declining to provide a locale fetcher in `new Driver` or forgetting to call | ||
`await driver.fetchLocales()` results in use of the bundled `en-US` locale. You | ||
@@ -355,6 +361,6 @@ should also never attempt to use the driver instance while it is fetching locales. | ||
```javascript | ||
driver.insertReference({ id: "citekey", type: "book", title: "Title" }).unwrap(); | ||
driver.insertReferences([ ... many references ... ]).unwrap(); | ||
driver.resetReferences([ ... deletes any others ... ]).unwrap(); | ||
driver.removeReference("citekey").unwrap(); | ||
driver.insertReference({ id: "citekey", type: "book", title: "Title" }); | ||
driver.insertReferences([ ... many references ... ]); | ||
driver.resetReferences([ ... deletes any others ... ]); | ||
driver.removeReference("citekey"); | ||
``` | ||
@@ -372,8 +378,8 @@ | ||
{ id: "two", cites: [ {id: "citekey", locator: "56", label: "page" } ] }, | ||
]).unwrap(); | ||
]); | ||
// Update or insert any one of them like so | ||
driver.insertCluster({ id: "one", cites: [ { id: "updated_citekey" } ] }).unwrap(); | ||
driver.insertCluster({ id: "one", cites: [ { id: "updated_citekey" } ] }); | ||
// (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(); | ||
driver.insertCluster({ id: three, cites: [ { id: "new_cluster_here" } ] }); | ||
``` | ||
@@ -392,3 +398,3 @@ | ||
```javascript | ||
driver.setClusterOrder([ { id: "one", note: 1 }, { id: "two", note: 4 } ]).unwrap(); | ||
driver.setClusterOrder([ { id: "one", note: 1 }, { id: "two", note: 4 } ]); | ||
``` | ||
@@ -408,5 +414,5 @@ | ||
```javascript | ||
driver.includeUncited("None").unwrap(); // Default | ||
driver.includeUncited("All").unwrap(); | ||
driver.includeUncited({ Specific: ["citekeyA", "citekeyB"] }).unwrap(); | ||
driver.includeUncited("None"); // Default | ||
driver.includeUncited("All"); | ||
driver.includeUncited({ Specific: ["citekeyA", "citekeyB"] }); | ||
``` | ||
@@ -429,3 +435,3 @@ | ||
// Get the diff since last time batchedUpdates, fullRender or drain was called. | ||
let diff = driver.batchedUpdates().unwrap(); | ||
let diff = driver.batchedUpdates(); | ||
@@ -469,6 +475,6 @@ // apply cluster changes to the UI. | ||
// lay out the bibliography. There is a similar API in citeproc-js. | ||
let meta = driver.bibliographyMeta().unwrap(); | ||
let meta = driver.bibliographyMeta(); | ||
// This is an array of BibEntry | ||
let bibliography = driver.makeBibliography().unwrap(); | ||
let bibliography = driver.makeBibliography(); | ||
for (let entry of bibliography) { | ||
@@ -485,10 +491,11 @@ console.log(entry.id, entry.value); | ||
```javascript | ||
let cites = [ { id: "citekey", locator: "45" }, { ... } ]; | ||
let cluster = { cites: [ { id: "citekey", locator: "45" }, { ... } ] }; | ||
let positions = [ ... before, { note: 34 }, ... after ]; | ||
let preview = driver.previewCitationCluster(cites, positions, "html").unwrap(); | ||
let preview = driver.previewCluster(cluster, positions); | ||
let plainPreview = driver.previewCluster(cluster, positions, "plain"); | ||
``` | ||
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 cluster argument is just a cluster, without an `id` field, since it's | ||
ephemeral. The lack of `id` field is reflected in the `positions` argument as | ||
well. | ||
@@ -507,4 +514,64 @@ The positions array is exactly like a call to `setClusterOrder`, except exactly | ||
The format argument is optional, and works like the format passed to | ||
`new Driver`: one of `"html"`, `"rtf"` or `"plain"`. The driver will use that | ||
instead of its normal output format. | ||
### `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 `new Driver` | ||
```javascript | ||
let driver = new Driver({ ..., cslFeatures: ["custom-intext"] }); | ||
// ... driver.free(); | ||
``` | ||
### Non-Interactive use, or re-hydrating a previously created document | ||
@@ -525,5 +592,5 @@ | ||
// document's clusters | ||
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(); | ||
driver.resetReferences(myDocument.allReferences); | ||
driver.initClusters(allNotes.map(fn => fn.cluster)); | ||
driver.setClusterOrder(allNotes.map(fn => { id: fn.cluster.id, note: fn.number })); | ||
@@ -533,3 +600,3 @@ // Render every cluster and bibliography item. | ||
// see the FullRender typescript type | ||
let render = driver.fullRender().unwrap(); | ||
let render = driver.fullRender(); | ||
@@ -555,3 +622,3 @@ // Write out the rendered clusters into the doc | ||
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 | ||
with `new Driver()` because it doesn't have the ability to render citations on | ||
its own, and is essentially just a container for three pieces of information: | ||
@@ -566,8 +633,9 @@ | ||
```typescript | ||
let result = parseStyleMetadata("<style ...> ... </style>").unwrap(); | ||
let styleMeta = parseStyleMetadata("<style ...> ... </style>"); | ||
``` | ||
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. | ||
This function can still throw a `CslStyleError`, but this is less likely than | ||
with new Driver() as it will not actually attempt to parse and validate all the | ||
parts of a style. It will throw if the XML is malformed or if the `<info>` | ||
block is too invalid to salvage. | ||
@@ -578,3 +646,3 @@ Here's how to use `parseStyleMetadata` to parse and use a dependent style. | ||
let dependentStyle = "<style ...> ... </style>"; | ||
let meta = parseStyleMetadata(dependentStyle).unwrap(); | ||
let meta = parseStyleMetadata(dependentStyle); | ||
let isDependent = meta.info.parent != null; | ||
@@ -586,13 +654,13 @@ let parentStyleId = isDependent && meta.info.parent.href; | ||
let parentStyle = await downloadStyleWithId(parentStyleId); | ||
let driver = Driver.new({ | ||
let driver = new Driver({ | ||
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(); | ||
let parentMeta = parseStyleMetadata(parentStyle); | ||
if (parentMeta.independentMeta.hasBibliography) { | ||
let bib = driver.makeBibliography().unwrap(); | ||
let bib = driver.makeBibliography(); | ||
// ... | ||
@@ -604,1 +672,21 @@ } | ||
``` | ||
### `setOutputFormat` and `setStyle` | ||
If you wish to change the output format of the entire driver, you can use | ||
`setOutputFormat(format, formatOptions)`. The format is a string, one of `"html" | | ||
"rtf" | "plain"` just like the `new Driver` method. The options is an optional | ||
argument with the same value as `formatOptions` in `new Driver`. | ||
`setStyle(xmlString)` will change the CSL style used by the driver. | ||
Both of these methods will require throwing out almost all cached computation, | ||
so use sparingly. | ||
If you need to render a preview in a different format, there is an argument on | ||
`previewCluster` for doing just that. It does not throw out all the | ||
computation. `citeproc-rs`' disambiguation procedures do take formatting into | ||
account, so `<i>Title</i>` can be distinct from `<b>Title</b>` in HTML and RTF, | ||
but not if the whole driver's output format is `"plain"`, since they both look | ||
identical in plain text. `previewCluster` will simply translate the formatting | ||
into another format, without re-computing all the disambiguation. |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
25248351
7083
670