@oval-vote/oval 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 oval-vote
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,26 @@
1
- # Temporary Holding Version
1
+ # @oval-vote/oval
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Parse, validate, compile, and format [Oval](https://oval.vote) voting guides from JavaScript.
4
+ This is the reference implementation's Rust code compiled to WebAssembly, for Node.
5
+
6
+ ```js
7
+ const oval = require("@oval-vote/oval");
8
+
9
+ const source = fs.readFileSync("guide.oval", "utf8");
10
+
11
+ oval.check(source);
12
+ // [{ code: "V14", severity: "warning", range: { start: 120, end: 124 }, message: "..." }]
13
+
14
+ oval.compile(source);
15
+ // The canonical JSON model described by the specification's guide.schema.json.
16
+ // Throws the diagnostics when the document has errors.
17
+
18
+ oval.format(source);
19
+ // The formatted source. Throws the diagnostics when the document has syntax errors.
20
+ ```
21
+
22
+ Ranges are byte offsets into the UTF-8 source.
23
+
24
+ The language is specified in [oval-vote/oval-spec](https://github.com/oval-vote/oval-spec) and
25
+ implemented in [oval-vote/oval](https://github.com/oval-vote/oval), which also provides the `oval`
26
+ command-line tool.
package/package.json CHANGED
@@ -1,6 +1,30 @@
1
1
  {
2
2
  "name": "@oval-vote/oval",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Parse, validate, compile, and format Oval voting guides",
5
+ "license": "MIT",
6
+ "type": "commonjs",
7
+ "main": "./pkg/oval_wasm.js",
8
+ "types": "./pkg/oval_wasm.d.ts",
9
+ "files": [
10
+ "pkg/oval_wasm.js",
11
+ "pkg/oval_wasm.d.ts",
12
+ "pkg/oval_wasm_bg.wasm",
13
+ "pkg/oval_wasm_bg.wasm.d.ts"
14
+ ],
15
+ "scripts": {
16
+ "build": "wasm-pack build ../../crates/oval-wasm --target nodejs --out-dir ../../packages/oval/pkg --out-name oval_wasm",
17
+ "test": "node --test test/*.test.js"
18
+ },
19
+ "repository": "github:oval-vote/oval",
20
+ "homepage": "https://oval.vote",
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "devDependencies": {
25
+ "wasm-pack": "0.15.1"
26
+ },
27
+ "allowScripts": {
28
+ "wasm-pack@0.15.1": true
29
+ }
30
+ }
@@ -0,0 +1,17 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Parses and validates `source`, returning every diagnostic in source order.
6
+ */
7
+ export function check(source: string): any;
8
+
9
+ /**
10
+ * Compiles `source` to its canonical form, or fails with the diagnostics.
11
+ */
12
+ export function compile(source: string): any;
13
+
14
+ /**
15
+ * Formats `source`, or fails with the diagnostics.
16
+ */
17
+ export function format(source: string): string;
@@ -0,0 +1,197 @@
1
+ /* @ts-self-types="./oval_wasm.d.ts" */
2
+
3
+ /**
4
+ * Parses and validates `source`, returning every diagnostic in source order.
5
+ * @param {string} source
6
+ * @returns {any}
7
+ */
8
+ function check(source) {
9
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
10
+ const len0 = WASM_VECTOR_LEN;
11
+ const ret = wasm.check(ptr0, len0);
12
+ if (ret[2]) {
13
+ throw takeFromExternrefTable0(ret[1]);
14
+ }
15
+ return takeFromExternrefTable0(ret[0]);
16
+ }
17
+ exports.check = check;
18
+
19
+ /**
20
+ * Compiles `source` to its canonical form, or fails with the diagnostics.
21
+ * @param {string} source
22
+ * @returns {any}
23
+ */
24
+ function compile(source) {
25
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
26
+ const len0 = WASM_VECTOR_LEN;
27
+ const ret = wasm.compile(ptr0, len0);
28
+ if (ret[2]) {
29
+ throw takeFromExternrefTable0(ret[1]);
30
+ }
31
+ return takeFromExternrefTable0(ret[0]);
32
+ }
33
+ exports.compile = compile;
34
+
35
+ /**
36
+ * Formats `source`, or fails with the diagnostics.
37
+ * @param {string} source
38
+ * @returns {string}
39
+ */
40
+ function format(source) {
41
+ let deferred3_0;
42
+ let deferred3_1;
43
+ try {
44
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
45
+ const len0 = WASM_VECTOR_LEN;
46
+ const ret = wasm.format(ptr0, len0);
47
+ var ptr2 = ret[0];
48
+ var len2 = ret[1];
49
+ if (ret[3]) {
50
+ ptr2 = 0; len2 = 0;
51
+ throw takeFromExternrefTable0(ret[2]);
52
+ }
53
+ deferred3_0 = ptr2;
54
+ deferred3_1 = len2;
55
+ return getStringFromWasm0(ptr2, len2);
56
+ } finally {
57
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
58
+ }
59
+ }
60
+ exports.format = format;
61
+ function __wbg_get_imports() {
62
+ const import0 = {
63
+ __proto__: null,
64
+ __wbg_Error_208446807d0d1e30: function(arg0, arg1) {
65
+ const ret = Error(getStringFromWasm0(arg0, arg1));
66
+ return ret;
67
+ },
68
+ __wbg___wbindgen_throw_4c88d8bf264fd984: function(arg0, arg1) {
69
+ throw new Error(getStringFromWasm0(arg0, arg1));
70
+ },
71
+ __wbg_new_37eb45aaf5eeb820: function() {
72
+ const ret = new Array();
73
+ return ret;
74
+ },
75
+ __wbg_new_cd4348290afae586: function() {
76
+ const ret = new Object();
77
+ return ret;
78
+ },
79
+ __wbg_set_d2d33b52458e984a: function(arg0, arg1, arg2) {
80
+ arg0[arg1 >>> 0] = arg2;
81
+ },
82
+ __wbg_set_e4b9a833d288759a: function(arg0, arg1, arg2) {
83
+ arg0[arg1] = arg2;
84
+ },
85
+ __wbindgen_generic_0000000000000001: function(arg0) {
86
+ // Cast intrinsic for `F64 -> Externref`.
87
+ const ret = arg0;
88
+ return ret;
89
+ },
90
+ __wbindgen_generic_0000000000000002: function(arg0, arg1) {
91
+ // Cast intrinsic for `Ref(String) -> Externref`.
92
+ const ret = getStringFromWasm0(arg0, arg1);
93
+ return ret;
94
+ },
95
+ __wbindgen_generic_0000000000000003: function(arg0) {
96
+ // Cast intrinsic for `U64 -> Externref`.
97
+ const ret = BigInt.asUintN(64, arg0);
98
+ return ret;
99
+ },
100
+ __wbindgen_init_externref_table: function() {
101
+ const table = wasm.__wbindgen_externrefs;
102
+ table.set(0, undefined);
103
+ table.set(1024, undefined);
104
+ table.set(1025, null);
105
+ table.set(1026, true);
106
+ table.set(1027, false);
107
+ },
108
+ };
109
+ return {
110
+ __proto__: null,
111
+ "./oval_wasm_bg.js": import0,
112
+ };
113
+ }
114
+
115
+ function getStringFromWasm0(ptr, len) {
116
+ ptr = ptr >>> 0;
117
+ return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
118
+ }
119
+
120
+ let cachedUint8ArrayMemory0 = null;
121
+ function getUint8ArrayMemory0() {
122
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
123
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
124
+ }
125
+ return cachedUint8ArrayMemory0;
126
+ }
127
+
128
+ function passStringToWasm0(arg, malloc, realloc) {
129
+ if (realloc === undefined) {
130
+ const buf = cachedTextEncoder.encode(arg);
131
+ const ptr = malloc(buf.length, 1) >>> 0;
132
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
133
+ WASM_VECTOR_LEN = buf.length;
134
+ return ptr;
135
+ }
136
+
137
+ let len = arg.length;
138
+ let ptr = malloc(len, 1) >>> 0;
139
+
140
+ const mem = getUint8ArrayMemory0();
141
+
142
+ let offset = 0;
143
+
144
+ for (; offset < len; offset++) {
145
+ const code = arg.charCodeAt(offset);
146
+ if (code > 0x7F) break;
147
+ mem[ptr + offset] = code;
148
+ }
149
+ if (offset !== len) {
150
+ if (offset !== 0) {
151
+ arg = arg.slice(offset);
152
+ }
153
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
154
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
155
+ const ret = cachedTextEncoder.encodeInto(arg, view);
156
+
157
+ offset += ret.written;
158
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
159
+ }
160
+
161
+ WASM_VECTOR_LEN = offset;
162
+ return ptr;
163
+ }
164
+
165
+ function takeFromExternrefTable0(idx) {
166
+ const value = wasm.__wbindgen_externrefs.get(idx);
167
+ wasm.__externref_table_dealloc(idx);
168
+ return value;
169
+ }
170
+
171
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
172
+ cachedTextDecoder.decode();
173
+ function decodeText(bytes) {
174
+ return cachedTextDecoder.decode(bytes);
175
+ }
176
+
177
+ const cachedTextEncoder = new TextEncoder();
178
+
179
+ if (!('encodeInto' in cachedTextEncoder)) {
180
+ cachedTextEncoder.encodeInto = function (arg, view) {
181
+ const buf = cachedTextEncoder.encode(arg);
182
+ view.set(buf);
183
+ return {
184
+ read: arg.length,
185
+ written: buf.length
186
+ };
187
+ };
188
+ }
189
+
190
+ let WASM_VECTOR_LEN = 0;
191
+
192
+ const wasmPath = `${__dirname}/oval_wasm_bg.wasm`;
193
+ const wasmBytes = require('fs').readFileSync(wasmPath);
194
+ const wasmModule = new WebAssembly.Module(wasmBytes);
195
+ let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
196
+ let wasm = wasmInstance.exports;
197
+ wasm.__wbindgen_start();
Binary file
@@ -0,0 +1,12 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const check: (a: number, b: number) => [number, number, number];
5
+ export const compile: (a: number, b: number) => [number, number, number];
6
+ export const format: (a: number, b: number) => [number, number, number, number];
7
+ export const __wbindgen_externrefs: WebAssembly.Table;
8
+ export const __wbindgen_malloc: (a: number, b: number) => number;
9
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
10
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
11
+ export const __externref_table_dealloc: (a: number) => void;
12
+ export const __wbindgen_start: () => void;