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

@citeproc-rs/wasm

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@citeproc-rs/wasm - npm Package Compare versions

Comparing version 0.0.0-canary-8d2904e to 0.0.0-canary-b724318

3

_cjs/citeproc_rs_wasm_bg.d.ts

@@ -6,3 +6,3 @@ /* tslint:disable */

export function driver_new(a: number, b: number, c: number, d: number, e: number): number;
export function driver_setStyle(a: number, b: number, c: number): number;
export function driver_setStyle(a: number, b: number, c: number): void;
export function driver_resetReferences(a: number, b: number, c: number): void;

@@ -24,2 +24,3 @@ export function driver_insertReferences(a: number, b: number, c: number): void;

export function driver_batchedUpdates(a: number): number;
export function driver_fullRender(a: number): number;
export function driver_drain(a: number): void;

@@ -26,0 +27,0 @@ export function driver_fetchAll(a: number): number;

@@ -90,3 +90,26 @@ /* tslint:disable */

type BibEntry = {
id: string;
value: string;
};
type BibEntries = BibEntry[];
type FullRender = {
allClusters: { [clusterId: string]: string },
bibEntries: BibEntries,
};
type BibliographyMeta = {
max_offset: number;
entry_spacing: number;
line_spacing: number;
hanging_indent: boolean;
/** the second-field-align value of the CSL style */
secondFieldAlign: null | "flush" | "margin";
/** Format-specific metadata */
formatMeta: any,
};
/**

@@ -113,5 +136,4 @@ */

* @param {string} style_text
* @returns {any}
*/
setStyle(style_text: string): any;
setStyle(style_text: string): void;
/**

@@ -197,9 +219,9 @@ * Completely overwrites the references library.

/**
* @returns {any}
* @returns {BibEntries}
*/
makeBibliography(): any;
makeBibliography(): BibEntries;
/**
* @returns {any}
* @returns {BibliographyMeta}
*/
bibliographyMeta(): any;
bibliographyMeta(): BibliographyMeta;
/**

@@ -267,5 +289,11 @@ * Replaces cluster numberings in one go.

/**
* Drains the `batchedUpdates` queue manually. Use it to avoid serializing an unneeded
* `UpdateSummary`.
* Returns all the clusters and bibliography entries in the document.
* Also drains the queue, just like batchedUpdates().
* Use this to rehydrate a document or run non-interactively.
* @returns {FullRender}
*/
fullRender(): FullRender;
/**
* Drains the `batchedUpdates` queue manually.
*/
drain(): void;

@@ -272,0 +300,0 @@ /**

@@ -12,16 +12,2 @@ let imports = {};

let heap_next = heap.length;
function dropObject(idx) {
if (idx < 36) return;
heap[idx] = heap_next;
heap_next = idx;
}
function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
}
let WASM_VECTOR_LEN = 0;

@@ -54,11 +40,2 @@

function addHeapObject(obj) {
if (heap_next === heap.length) heap.push(heap.length + 1);
const idx = heap_next;
heap_next = heap[idx];
heap[idx] = obj;
return idx;
}
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });

@@ -80,2 +57,25 @@

let heap_next = heap.length;
function addHeapObject(obj) {
if (heap_next === heap.length) heap.push(heap.length + 1);
const idx = heap_next;
heap_next = heap[idx];
heap[idx] = obj;
return idx;
}
function dropObject(idx) {
if (idx < 36) return;
heap[idx] = heap_next;
heap_next = idx;
}
function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
}
function isLikeNone(x) {

@@ -141,3 +141,3 @@ return x === undefined || x === null;

}
function __wbg_adapter_63(arg0, arg1, arg2, arg3) {
function __wbg_adapter_64(arg0, arg1, arg2, arg3) {
wasm.wasm_bindgen__convert__closures__invoke2_mut__h19f62226ce422262(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));

@@ -187,3 +187,2 @@ }

* @param {string} style_text
* @returns {any}
*/

@@ -193,4 +192,3 @@ setStyle(style_text) {

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

@@ -316,3 +314,3 @@ /**

/**
* @returns {any}
* @returns {BibEntries}
*/

@@ -324,3 +322,3 @@ makeBibliography() {

/**
* @returns {any}
* @returns {BibliographyMeta}
*/

@@ -404,5 +402,14 @@ bibliographyMeta() {

/**
* Drains the `batchedUpdates` queue manually. Use it to avoid serializing an unneeded
* `UpdateSummary`.
* Returns all the clusters and bibliography entries in the document.
* Also drains the queue, just like batchedUpdates().
* Use this to rehydrate a document or run non-interactively.
* @returns {FullRender}
*/
fullRender() {
var ret = wasm.driver_fullRender(this.ptr);
return takeObject(ret);
}
/**
* Drains the `batchedUpdates` queue manually.
*/
drain() {

@@ -423,6 +430,2 @@ wasm.driver_drain(this.ptr);

module.exports.__wbindgen_object_drop_ref = function(arg0) {
takeObject(arg0);
};
module.exports.__wbindgen_json_serialize = function(arg0, arg1) {

@@ -437,7 +440,11 @@ const obj = getObject(arg1);

module.exports.__wbindgen_object_clone_ref = function(arg0) {
var ret = getObject(arg0);
module.exports.__wbindgen_json_parse = function(arg0, arg1) {
var ret = JSON.parse(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
};
module.exports.__wbindgen_object_drop_ref = function(arg0) {
takeObject(arg0);
};
module.exports.__wbg_fetchLocale_8f52b973b0739a6c = function(arg0, arg1, arg2) {

@@ -448,6 +455,2 @@ var ret = getObject(arg0).fetchLocale(getStringFromWasm0(arg1, arg2));

module.exports.__wbg_error_e549f7fed6d655aa = function(arg0) {
console.error(takeObject(arg0));
};
module.exports.__wbg_debug_4885c3f7d6f044a3 = function(arg0, arg1) {

@@ -473,7 +476,11 @@ console.debug(getStringFromWasm0(arg0, arg1));

module.exports.__wbindgen_json_parse = function(arg0, arg1) {
var ret = JSON.parse(getStringFromWasm0(arg0, arg1));
module.exports.__wbindgen_object_clone_ref = function(arg0) {
var ret = getObject(arg0);
return addHeapObject(ret);
};
module.exports.__wbg_error_e549f7fed6d655aa = function(arg0) {
console.error(takeObject(arg0));
};
module.exports.__wbindgen_cb_drop = function(arg0) {

@@ -527,3 +534,3 @@ const obj = takeObject(arg0).original;

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

@@ -572,4 +579,4 @@ state0.a = a;

module.exports.__wbindgen_closure_wrapper839 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 197, __wbg_adapter_18);
module.exports.__wbindgen_closure_wrapper877 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 227, __wbg_adapter_18);
return addHeapObject(ret);

@@ -576,0 +583,0 @@ };

@@ -6,3 +6,3 @@ /* tslint:disable */

export function driver_new(a: number, b: number, c: number, d: number, e: number): number;
export function driver_setStyle(a: number, b: number, c: number): number;
export function driver_setStyle(a: number, b: number, c: number): void;
export function driver_resetReferences(a: number, b: number, c: number): void;

@@ -24,2 +24,3 @@ export function driver_insertReferences(a: number, b: number, c: number): void;

export function driver_batchedUpdates(a: number): number;
export function driver_fullRender(a: number): number;
export function driver_drain(a: number): void;

@@ -26,0 +27,0 @@ export function driver_fetchAll(a: number): number;

@@ -9,16 +9,2 @@ import * as wasm from './citeproc_rs_wasm_bg.wasm';

let heap_next = heap.length;
function dropObject(idx) {
if (idx < 36) return;
heap[idx] = heap_next;
heap_next = idx;
}
function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
}
let WASM_VECTOR_LEN = 0;

@@ -97,2 +83,14 @@

const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
cachedTextDecoder.decode();
function getStringFromWasm0(ptr, len) {
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}
let heap_next = heap.length;
function addHeapObject(obj) {

@@ -107,10 +105,12 @@ if (heap_next === heap.length) heap.push(heap.length + 1);

const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
function dropObject(idx) {
if (idx < 36) return;
heap[idx] = heap_next;
heap_next = idx;
}
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
cachedTextDecoder.decode();
function getStringFromWasm0(ptr, len) {
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
}

@@ -178,3 +178,3 @@

}
function __wbg_adapter_63(arg0, arg1, arg2, arg3) {
function __wbg_adapter_64(arg0, arg1, arg2, arg3) {
wasm.wasm_bindgen__convert__closures__invoke2_mut__h19f62226ce422262(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));

@@ -224,3 +224,2 @@ }

* @param {string} style_text
* @returns {any}
*/

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

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

@@ -353,3 +351,3 @@ /**

/**
* @returns {any}
* @returns {BibEntries}
*/

@@ -361,3 +359,3 @@ makeBibliography() {

/**
* @returns {any}
* @returns {BibliographyMeta}
*/

@@ -441,5 +439,14 @@ bibliographyMeta() {

/**
* Drains the `batchedUpdates` queue manually. Use it to avoid serializing an unneeded
* `UpdateSummary`.
* Returns all the clusters and bibliography entries in the document.
* Also drains the queue, just like batchedUpdates().
* Use this to rehydrate a document or run non-interactively.
* @returns {FullRender}
*/
fullRender() {
var ret = wasm.driver_fullRender(this.ptr);
return takeObject(ret);
}
/**
* Drains the `batchedUpdates` queue manually.
*/
drain() {

@@ -459,6 +466,2 @@ wasm.driver_drain(this.ptr);

export const __wbindgen_object_drop_ref = function(arg0) {
takeObject(arg0);
};
export const __wbindgen_json_serialize = function(arg0, arg1) {

@@ -473,7 +476,11 @@ const obj = getObject(arg1);

export const __wbindgen_object_clone_ref = function(arg0) {
var ret = getObject(arg0);
export const __wbindgen_json_parse = function(arg0, arg1) {
var ret = JSON.parse(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
};
export const __wbindgen_object_drop_ref = function(arg0) {
takeObject(arg0);
};
export const __wbg_fetchLocale_8f52b973b0739a6c = function(arg0, arg1, arg2) {

@@ -484,6 +491,2 @@ var ret = getObject(arg0).fetchLocale(getStringFromWasm0(arg1, arg2));

export const __wbg_error_e549f7fed6d655aa = function(arg0) {
console.error(takeObject(arg0));
};
export const __wbg_debug_4885c3f7d6f044a3 = function(arg0, arg1) {

@@ -509,7 +512,11 @@ console.debug(getStringFromWasm0(arg0, arg1));

export const __wbindgen_json_parse = function(arg0, arg1) {
var ret = JSON.parse(getStringFromWasm0(arg0, arg1));
export const __wbindgen_object_clone_ref = function(arg0) {
var ret = getObject(arg0);
return addHeapObject(ret);
};
export const __wbg_error_e549f7fed6d655aa = function(arg0) {
console.error(takeObject(arg0));
};
export const __wbindgen_cb_drop = function(arg0) {

@@ -563,3 +570,3 @@ const obj = takeObject(arg0).original;

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

@@ -608,6 +615,6 @@ state0.a = a;

export const __wbindgen_closure_wrapper839 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 197, __wbg_adapter_18);
export const __wbindgen_closure_wrapper877 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 227, __wbg_adapter_18);
return addHeapObject(ret);
};

@@ -90,3 +90,26 @@ /* tslint:disable */

type BibEntry = {
id: string;
value: string;
};
type BibEntries = BibEntry[];
type FullRender = {
allClusters: { [clusterId: string]: string },
bibEntries: BibEntries,
};
type BibliographyMeta = {
max_offset: number;
entry_spacing: number;
line_spacing: number;
hanging_indent: boolean;
/** the second-field-align value of the CSL style */
secondFieldAlign: null | "flush" | "margin";
/** Format-specific metadata */
formatMeta: any,
};
/**

@@ -113,5 +136,4 @@ */

* @param {string} style_text
* @returns {any}
*/
setStyle(style_text: string): any;
setStyle(style_text: string): void;
/**

@@ -197,9 +219,9 @@ * Completely overwrites the references library.

/**
* @returns {any}
* @returns {BibEntries}
*/
makeBibliography(): any;
makeBibliography(): BibEntries;
/**
* @returns {any}
* @returns {BibliographyMeta}
*/
bibliographyMeta(): any;
bibliographyMeta(): BibliographyMeta;
/**

@@ -267,5 +289,11 @@ * Replaces cluster numberings in one go.

/**
* Drains the `batchedUpdates` queue manually. Use it to avoid serializing an unneeded
* `UpdateSummary`.
* Returns all the clusters and bibliography entries in the document.
* Also drains the queue, just like batchedUpdates().
* Use this to rehydrate a document or run non-interactively.
* @returns {FullRender}
*/
fullRender(): FullRender;
/**
* Drains the `batchedUpdates` queue manually.
*/
drain(): void;

@@ -272,0 +300,0 @@ /**

@@ -6,3 +6,3 @@ /* tslint:disable */

export function driver_new(a: number, b: number, c: number, d: number, e: number): number;
export function driver_setStyle(a: number, b: number, c: number): number;
export function driver_setStyle(a: number, b: number, c: number): void;
export function driver_resetReferences(a: number, b: number, c: number): void;

@@ -24,2 +24,3 @@ export function driver_insertReferences(a: number, b: number, c: number): void;

export function driver_batchedUpdates(a: number): number;
export function driver_fullRender(a: number): number;
export function driver_drain(a: number): void;

@@ -26,0 +27,0 @@ export function driver_fetchAll(a: number): number;

@@ -90,3 +90,26 @@ /* tslint:disable */

type BibEntry = {
id: string;
value: string;
};
type BibEntries = BibEntry[];
type FullRender = {
allClusters: { [clusterId: string]: string },
bibEntries: BibEntries,
};
type BibliographyMeta = {
max_offset: number;
entry_spacing: number;
line_spacing: number;
hanging_indent: boolean;
/** the second-field-align value of the CSL style */
secondFieldAlign: null | "flush" | "margin";
/** Format-specific metadata */
formatMeta: any,
};
/**

@@ -113,5 +136,4 @@ */

* @param {string} style_text
* @returns {any}
*/
setStyle(style_text: string): any;
setStyle(style_text: string): void;
/**

@@ -197,9 +219,9 @@ * Completely overwrites the references library.

/**
* @returns {any}
* @returns {BibEntries}
*/
makeBibliography(): any;
makeBibliography(): BibEntries;
/**
* @returns {any}
* @returns {BibliographyMeta}
*/
bibliographyMeta(): any;
bibliographyMeta(): BibliographyMeta;
/**

@@ -267,5 +289,11 @@ * Replaces cluster numberings in one go.

/**
* Drains the `batchedUpdates` queue manually. Use it to avoid serializing an unneeded
* `UpdateSummary`.
* Returns all the clusters and bibliography entries in the document.
* Also drains the queue, just like batchedUpdates().
* Use this to rehydrate a document or run non-interactively.
* @returns {FullRender}
*/
fullRender(): FullRender;
/**
* Drains the `batchedUpdates` queue manually.
*/
drain(): void;

@@ -286,3 +314,3 @@ /**

readonly driver_new: (a: number, b: number, c: number, d: number, e: number) => number;
readonly driver_setStyle: (a: number, b: number, c: number) => number;
readonly driver_setStyle: (a: number, b: number, c: number) => void;
readonly driver_resetReferences: (a: number, b: number, c: number) => void;

@@ -304,2 +332,3 @@ readonly driver_insertReferences: (a: number, b: number, c: number) => void;

readonly driver_batchedUpdates: (a: number) => number;
readonly driver_fullRender: (a: number) => number;
readonly driver_drain: (a: number) => void;

@@ -306,0 +335,0 @@ readonly driver_fetchAll: (a: number) => number;

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

let heap_next = heap.length;
function dropObject(idx) {
if (idx < 36) return;
heap[idx] = heap_next;
heap_next = idx;
}
function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
}
let WASM_VECTOR_LEN = 0;

@@ -96,2 +82,12 @@

let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
cachedTextDecoder.decode();
function getStringFromWasm0(ptr, len) {
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}
let heap_next = heap.length;
function addHeapObject(obj) {

@@ -106,8 +102,12 @@ if (heap_next === heap.length) heap.push(heap.length + 1);

let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
function dropObject(idx) {
if (idx < 36) return;
heap[idx] = heap_next;
heap_next = idx;
}
cachedTextDecoder.decode();
function getStringFromWasm0(ptr, len) {
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
}

@@ -175,3 +175,3 @@

}
function __wbg_adapter_63(arg0, arg1, arg2, arg3) {
function __wbg_adapter_64(arg0, arg1, arg2, arg3) {
wasm.wasm_bindgen__convert__closures__invoke2_mut__h19f62226ce422262(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));

@@ -221,3 +221,2 @@ }

* @param {string} style_text
* @returns {any}
*/

@@ -227,4 +226,3 @@ setStyle(style_text) {

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

@@ -350,3 +348,3 @@ /**

/**
* @returns {any}
* @returns {BibEntries}
*/

@@ -358,3 +356,3 @@ makeBibliography() {

/**
* @returns {any}
* @returns {BibliographyMeta}
*/

@@ -438,5 +436,14 @@ bibliographyMeta() {

/**
* Drains the `batchedUpdates` queue manually. Use it to avoid serializing an unneeded
* `UpdateSummary`.
* Returns all the clusters and bibliography entries in the document.
* Also drains the queue, just like batchedUpdates().
* Use this to rehydrate a document or run non-interactively.
* @returns {FullRender}
*/
fullRender() {
var ret = wasm.driver_fullRender(this.ptr);
return takeObject(ret);
}
/**
* Drains the `batchedUpdates` queue manually.
*/
drain() {

@@ -495,5 +502,2 @@ wasm.driver_drain(this.ptr);

imports.wbg = {};
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
takeObject(arg0);
};
imports.wbg.__wbindgen_json_serialize = function(arg0, arg1) {

@@ -507,6 +511,9 @@ const obj = getObject(arg1);

};
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
var ret = getObject(arg0);
imports.wbg.__wbindgen_json_parse = function(arg0, arg1) {
var ret = JSON.parse(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
};
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
takeObject(arg0);
};
imports.wbg.__wbg_fetchLocale_8f52b973b0739a6c = function(arg0, arg1, arg2) {

@@ -516,5 +523,2 @@ var ret = getObject(arg0).fetchLocale(getStringFromWasm0(arg1, arg2));

};
imports.wbg.__wbg_error_e549f7fed6d655aa = function(arg0) {
console.error(takeObject(arg0));
};
imports.wbg.__wbg_debug_4885c3f7d6f044a3 = function(arg0, arg1) {

@@ -535,6 +539,9 @@ console.debug(getStringFromWasm0(arg0, arg1));

};
imports.wbg.__wbindgen_json_parse = function(arg0, arg1) {
var ret = JSON.parse(getStringFromWasm0(arg0, arg1));
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
var ret = getObject(arg0);
return addHeapObject(ret);
};
imports.wbg.__wbg_error_e549f7fed6d655aa = function(arg0) {
console.error(takeObject(arg0));
};
imports.wbg.__wbindgen_cb_drop = function(arg0) {

@@ -582,3 +589,3 @@ const obj = takeObject(arg0).original;

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

@@ -620,4 +627,4 @@ state0.a = a;

};
imports.wbg.__wbindgen_closure_wrapper839 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 197, __wbg_adapter_18);
imports.wbg.__wbindgen_closure_wrapper877 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 227, __wbg_adapter_18);
return addHeapObject(ret);

@@ -624,0 +631,0 @@ };

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

"description": "citeproc-rs, compiled to WebAssembly",
"version": "0.0.0-canary-8d2904e",
"version": "0.0.0-canary-b724318",
"license": "MPL-2.0",

@@ -10,0 +10,0 @@ "repository": {

@@ -39,6 +39,6 @@ # `@citeproc-rs/wasm`

For Node.js or Webpack, simply import the package as normal. Typescript
definitions are provided, though parts of the API that cannot have
auto-generated type definitions are alluded to in doc comments with an
accompanying type you can import.
For Node.js, simply import the package as normal. Typescript definitions are
provided, though parts of the API that cannot have auto-generated type
definitions are alluded to in doc comments with an accompanying type you can
import.

@@ -48,12 +48,50 @@ ```

const { Driver } = require("@citeproc-rs/wasm");
```
// Webpack, anything using compiled ES Modules
#### Using Webpack
When loading on the web, for technical reasons and because the compiled
WebAssembly is large, you must load the package asynchronously. Webpack comes
with the ability to import packages asynchronously like so:
```javascript
// Webpack
import("@citeproc-rs/wasm")
.then(go)
.catch(console.error);
function go(wasm) {
const { Driver } = wasm;
// use Driver
}
```
When you do this, your code will trigger a download (and streaming parse) of
the binary, and when that is complete, your `go` function will be called. The
download can of course be cached if your web server is set up correctly, making
the whole process very quick.
You can use the regular-import Driver as a TypeScript type anywhere, just don't
use it to call `.new()`.
Note the caveats in around Microsoft Edge's TextEncoder/TextDecoder support in
[the wasm-bindgen
tutorial](https://rustwasm.github.io/docs/wasm-bindgen/examples/hello-world.html).
```typescript
import { Driver } from "@citeproc-rs/wasm";
function doSomethingWithDriver(driver: Driver) {
// ...
}
```
To directly import it in a (modern) web browser, you must:
#### Importing it in a script tag (`web` target)
To directly import it without a bundler in a (modern) web browser with ES
modules support, the procedure is different. You must:
1. Make the `_web` subdirectory of the published NPM package available in a
content directory on your webserver, or use a CDN like [unpkg](unpkg.com).
2. Include a `<script type="module">` tag on your page, like so:
2. Include a `<script type="module">` tag in your page's `<body>`, like so:

@@ -71,2 +109,46 @@ ```html

#### Importing it in a script tag (`no-modules` target)
This replicates the [wasm-bindgen guide
entry](https://rustwasm.github.io/docs/wasm-bindgen/examples/without-a-bundler.html?highlight=no-modules#using-the-older---target-no-modules),
noting the caveats. You will, similarly to the `web` target, need to make the
contents of the `_no_modules` subdirectory of the published NPM package
available on a webserver or via a CDN.
```
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
</head>
<body>
<!-- Include the JS generated by `wasm-pack build` -->
<script src='path/to/@citeproc-rs/wasm/_no_modules/citeproc_rs_wasm.js'></script>
<script>
// Like with the `--target web` output the exports are immediately
// available but they won't work until we initialize the module. Unlike
// `--target web`, however, the globals are all stored on a
// `wasm_bindgen` global. The global itself is the initialization
// function and then the properties of the global are all the exported
// functions.
//
// Note that the name `wasm_bindgen` will at some point be configurable with the
// `--no-modules-global` CLI flag (https://github.com/rustwasm/wasm-pack/issues/729)
const { Driver } = wasm_bindgen;
async function run() {
// Note the _bg.wasm ending
await wasm_bindgen('path/to/@citeproc-rs/wasm/_no_modules/citeproc_rs_wasm_bg.wasm');
// Use Driver
}
run();
</script>
</body>
</html>
```
## Usage

@@ -216,2 +298,10 @@

The "All" is based on which references your driver knows about. If you have
this set to "All", simply calling `driver.insertReference()` with a new
reference ID will result in an entry being added to the bibliography. Entries
in Specific mode do not have to exist when they are provided here; they can be,
for instance, the citekeys of collection of references in a reference library
which are subsequently provided in full to the driver, at which point they
appear in the bibliography, but not items from elsewhere in the library.
### 3. Call `driver.batchedUpdates()` and apply the diff

@@ -223,15 +313,26 @@

```javascript
import { UpdateSummary } from "@citeproc-rs/wasm"; // typescript users, annotate with this
// Get the diff since last time batchedUpdates, fullRender or drain was called.
let diff = driver.batchedUpdates();
// apply to the UI
diff.clusters.forEach(changedCluster => {
// apply cluster changes to the UI.
for (let changedCluster of diff.clusters) {
let [id, html] = changedCluster;
myDocument.updateCluster(id, html);
});
diff.bibliography.entryIds.forEach(citekey => {
let html = diff.updatedEntries[citekey];
myDocument.updateBibEntry(citekey, html);
});
}
// Null? No change to the bibliography.
if (diff.bibliography != null) {
let bib = diff.bibliography;
// Save the entries that have actually changed
for (let key of Object.keys(bib.updatedEntries)) {
let rendered = bib.updatedEntries[key];
myDocument.updateBibEntry(key, rendered);
}
// entryIds is the full list of entries in the bibliography.
// If a citekey isn't in there, it should be removed.
// It is non-null when it has changed.
if (bib.entryIds != null) {
myDocument.setBibliographyOrder(bib.entryIds);
}
}
```

@@ -242,3 +343,19 @@

### Bibliographies
Beyond the interactive batchedUpdates method, there are two functions for
producing a bibliography statically.
```javascript
// returns BibliographyMeta, with information about how a library consumer should
// lay out the bibliography. There is a similar API in citeproc-js.
let meta = driver.bibliographyMeta();
// This is an array of BibEntry
let bibliography = driver.makeBibliography();
for (let entry of bibliography) {
console.log(entry.id, entry.value);
}
```
### Preview citation clusters

@@ -282,21 +399,27 @@

// Re-hydrate the entire document
driver.resetReferences(allReferences);
// Re-hydrate the entire document based on the reference library and your
// document's clusters
driver.resetReferences(myDocument.allReferences);
driver.initClusters(allNotes.map(fn => fn.cluster));
driver.setClusterOrder(allNotes.map(fn => { id: note.cluster.id, note: note.number }));
driver.setClusterOrder(allNotes.map(fn => { id: fn.cluster.id, note: fn.number }));
// Build every cluster, only after the driver knows about all of them
allNotes.forEach(fn => {
fn.renderedHtml = driver.builtCluster(fn.cluster.id);
});
// Render every cluster and bibliography item.
// It then drains the update queue, leaving the diff empty for the next edit.
// see the FullRender typescript type
let render = driver.fullRender();
let bibliography = driver.makeBibliography();
// Write out the rendered clusters into the doc
for (let fn of allNotes) {
fn.renderedHtml = render.allClusters[fn.cluster.id];
}
// Drain the update queue, so the driver knows you're up to date and won't send
// you a whole-document diff
driver.drain();
// Write out the bibliography entries as well
let allBibKeys = render.bibEntries.map(entry => entry.id);
for (let bibEntry of render.bibEntries) {
myDocument.bibliographyMap[entry.id] = entry.value;
}
// Update the UI
updateUserInterface(allNotes, bibliography);
// Update your (example) UI
updateUserInterface(allNotes, myDocument, whatever);
```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc