-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from cormacrelf/wasm-packaging
Publish WASM builds to NPM
- Loading branch information
Showing
17 changed files
with
5,234 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pkg-scratch | ||
pkg | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,11 +5,14 @@ | |
# Copyright © 2018 Corporation for Digital Scholarship | ||
|
||
[package] | ||
name = "citeproc-wasm" | ||
# package name on NPM = @citeproc-rs/ + this field = @citeproc-rs/wasm | ||
name = "wasm" | ||
version = "0.0.1" | ||
authors = ["Cormac Relf <[email protected]>"] | ||
license = "MPL-2.0" | ||
edition = "2018" | ||
repository = "https://github.com/cormacrelf/citeproc-rs" | ||
description = "citeproc-rs, compiled to WebAssembly" | ||
|
||
[lib] | ||
crate-type = ["cdylib", "rlib"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,7 @@ | ||
# `citeproc-wasm` | ||
# `@citeproc-rs/wasm` | ||
|
||
This is a build of `citeproc` that is suitable for use in Node.js, a browser or | ||
a Firefox/Chromium-based application like Zotero. It consists of a WebAssembly | ||
(WASM) binary, and a fairly lightweight JavaScript wrapper for that binary. | ||
|
||
The wrapper consists of: | ||
|
||
* A JS class to wrap `citeproc::Driver`. The core processing code is | ||
synchronous, but it will generally be sufficiently fast to run in any | ||
interactive context. | ||
* A JS interface for library consumers to asynchronously fetch locales and | ||
style modules at specific points in Driver's lifecycle. The fetching must | ||
happen and complete before the processing actually begins, because processing | ||
cannot be paused to wait for the JS library consumer to fetch something. So | ||
the processor will analyse which locales and modules will be needed, and | ||
request all of them at once. | ||
* Style, locale and style-module inputs are all XML strings. | ||
* The library does its own parsing, and validates it at the same time. Any | ||
validation errors are reported, with line/column positions, the text at that | ||
location, a descriptive and useful message (only in English at the moment) | ||
and sometimes even a hint for how to fix it, for common errors. | ||
* Input libraries are only CSL-JSON, serialized as a string. The other input | ||
formats that `citeproc` may recognise will be disabled, to save bundle size. | ||
* A TypeScript definition file auto-generated from the Rust types and | ||
interfaces. | ||
|
||
The library is intended to replace `citeproc-js`, but the interface will be | ||
different. | ||
|
||
* All fetching is via Promises, but if you have a string already you can just | ||
`return Promise.resolve(string)`. | ||
|
||
* Not all features are supported (at least for now). | ||
* The `citeproc-js` abbreviations API currently requires a huge | ||
implementation by library consumers in order to get the behaviour | ||
envisioned by the spec. Some of this functionality needs to be made more | ||
consistent by having the processor take responsibility for it. (Like | ||
tokenizing/slugifying strings and requesting My, My_Abbreviated, | ||
My_Abbreviated_Name in order, etc. Maybe feed all your abbreviations to the | ||
processor and allow it to build its own | ||
[trie](https://en.wikipedia.org/wiki/Trie) for much faster lookup.) | ||
* Some of it doesn't make much sense, like requiring users to import Juris-M | ||
abbreviation lists into each document rather than linking abbreviations to | ||
styles or jurisdictions or the Courts that each item in those huge lists | ||
refers to. | ||
|
||
* You cannot deserialize your own XML. Any tree modifications you want to do | ||
should be implemented as transforms on the Style AST within `citeproc`, | ||
which, it should be noted, is dramatically different from the XML such that | ||
it is not possible to represent invalid CSL. There isn't any API for such | ||
transforms at present, but it could be done. It's possible but unlikely that | ||
such an API could be bridged to JavaScript. | ||
|
||
Drop-in API compatibility will not be a goal, and given that, the whole | ||
interface may as well be improved. | ||
|
||
README for newer version of the API forthcoming. |
Oops, something went wrong.