yeptris 0.6.58 → 0.6.60
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/README.md +98 -20
- package/dist/yeptris.mjs +1 -1
- package/dist/yeptris.wasm +0 -0
- package/package.json +1 -1
- package/src/index.d.ts +224 -7
- package/src/index.js +729 -63
- package/src/yeptris_wasm.c +381 -5
package/README.md
CHANGED
|
@@ -21,25 +21,103 @@ const yaml = await dump({ name: "yeptris", langs: ["c", "rust"] });
|
|
|
21
21
|
// the engine's canonical, byte-stable YAML
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
24
|
+
## API
|
|
25
|
+
|
|
26
|
+
| Function | What it answers |
|
|
27
|
+
| --- | --- |
|
|
28
|
+
| `load(yaml, options?)` | The document as a JavaScript value (malformed input throws `YamlError` with line/column). A multi-document stream answers with the FIRST document. With a validation gate armed (below) it validates BEFORE loading. |
|
|
29
|
+
| `loadAll(yaml, options?)` | Every document of a multi-document stream, in stream order (`js-yaml` parity; an empty stream answers `[]`). An armed gate validates the whole stream first. |
|
|
30
|
+
| `loadJSON(yaml)` | The engine's canonical JSON string. |
|
|
31
|
+
| `dump(json, options?)` | JSON text (or any JSON-serializable value) to canonical YAML; JSON is a subset of YAML 1.2 flow, so the one parse engine takes it. Options (js-yaml parity names over the engine's `yeptris_emit_options`): `lineWidth` folds flow collections past that column (default 80, `-1` disables folding), `canonical` rides the engine's fixed form. `indent`/`flowLevel` have no engine option and are rejected, never silently ignored. |
|
|
32
|
+
| `events(yaml, options?)` | Every event of the stream as an array of plain objects, in stream order: the engine's recorder bulk drain (one wasm crossing per stream). The normalized event vocabulary is shared with the ruby/py/rs faces and documented as data in [`test/fixtures/events.json`](test/fixtures/events.json). |
|
|
33
|
+
| `validate(input, options?)` | The WHOLE validation report: every diagnostic, in engine order (`[]` when valid). |
|
|
34
|
+
| `isValid(input, options?)` | `true` when `validate` answers no diagnostics. |
|
|
35
|
+
| `compileSchema(jsonSchema)` | A compiled `Schema` handle — parse the schema ONCE, validate many streams. |
|
|
36
|
+
| `version()` | The libyeptris version string. |
|
|
37
|
+
| `wasmModule()` | The cached wasm module instance (diagnostics: heap/memory inspection, the engine's raw exports). |
|
|
38
|
+
| `init()` | Initializes the wasm module (idempotent) — what unlocks the `*Sync` forms. |
|
|
39
|
+
|
|
40
|
+
### Sync postures
|
|
41
|
+
|
|
42
|
+
The wasm executes synchronously; every async form is async only
|
|
43
|
+
because the FIRST call may initialize the module. After one
|
|
44
|
+
`await init()` (or any async call) the same bodies run synchronously:
|
|
45
|
+
`loadSync`, `loadAllSync`, `loadJSONSync`, `dumpSync`, `eventsSync`,
|
|
46
|
+
`validateSync`, `isValidSync`, `compileSchemaSync`, `versionSync` —
|
|
47
|
+
same arguments, same answers, no `Promise`. Each `*Sync` form refuses
|
|
48
|
+
to run uninitialized (the lazy import is an async door) and names the
|
|
49
|
+
way out in the error; the `Schema` handle's own methods
|
|
50
|
+
(`validate`/`isValid`) are synchronous by construction — a handle only
|
|
51
|
+
exists once the module is initialized.
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
await init(); // once, up front
|
|
55
|
+
const doc = loadSync(yaml); // synchronous from here on
|
|
56
|
+
const diags = validateSync(yaml, { schema: "core" });
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Validation
|
|
60
|
+
|
|
61
|
+
```js
|
|
62
|
+
import { validate, isValid, compileSchema, load } from "yeptris";
|
|
63
|
+
|
|
64
|
+
const diags = await validate("a: 1\na: 2\n");
|
|
65
|
+
// [{ code: 4, keyword: "duplicateKey", path: [], pointer: "",
|
|
66
|
+
// message: 'duplicate mapping key ("a")', line: 2, col: 1, offset: 5 }]
|
|
67
|
+
|
|
68
|
+
await isValid("a: 1\n"); // true
|
|
69
|
+
|
|
70
|
+
const schema = await compileSchema({ type: "object", required: ["name"] });
|
|
71
|
+
schema.validate("age: 1\n"); // [{ keyword: "required", pointer: "/name", ... }]
|
|
72
|
+
schema.isValid('name: "x"\n'); // true
|
|
73
|
+
schema.free(); // once, when done — reuse afterwards throws
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Every diagnostic is a plain object — never a raw pointer:
|
|
77
|
+
`code` (the engine's `YeptrisDiagCode`), `keyword` (the spec-spelled
|
|
78
|
+
keyword: the violated JSON Schema keyword for the 2020-12 walk, the
|
|
79
|
+
violated YAML rule for the family walk), `path` (the JSON-pointer
|
|
80
|
+
instance path split into `~0`/`~1`-unescaped segments, `[]` at the
|
|
81
|
+
root), `pointer` (its raw string form), `message` (the engine's
|
|
82
|
+
bounded detail), `line`/`col` (the offending node's 1-based mark,
|
|
83
|
+
`0` = unknown: scalars whose bytes the DOM owns have no input
|
|
84
|
+
position — the path still identifies them), and `offset`. Results are
|
|
85
|
+
WHOLE REPORTS: one call enumerates every miss, never first-fail.
|
|
86
|
+
A multi-document stream's paths name their document — `"/1/a"` is `a`
|
|
87
|
+
of document 1 (0-based); single-document streams keep bare pointers.
|
|
88
|
+
|
|
89
|
+
### Schema selection (the js-yaml `load(str, { schema })` analog)
|
|
90
|
+
|
|
91
|
+
| js-yaml | yeptris | What runs |
|
|
92
|
+
| --- | --- | --- |
|
|
93
|
+
| `schema: DEFAULT_SCHEMA` | `schema: "core"` (the default) | The YAML 1.2 CORE family walk: explicit-tag consistency (spec 10.3 resolution) and mapping-key uniqueness by canonical form (`0o13` and `0xB` are one key). |
|
|
94
|
+
| `schema: JSON_SCHEMA` | `schema: "json"` | The spec 10.2 JSON family walk: every plain scalar must match a JSON production, mapping keys must be strings. |
|
|
95
|
+
| — | `jsonSchema: object \| string` | JSON Schema draft 2020-12 (the engine's keyword subset; unknown keywords are ignored, per 2020-12). |
|
|
96
|
+
| — | `schema: compiledSchema` | The compiled economy: `compileSchema()` parses the schema once, the handle validates many streams. |
|
|
97
|
+
|
|
98
|
+
The doors are alternatives — passing `schema` AND `jsonSchema` throws
|
|
99
|
+
`TypeError` (pick the door you meant; nothing is silently dropped),
|
|
100
|
+
as is any unknown or mistyped option. A `$ref` that resolves nowhere
|
|
101
|
+
is a diagnostic, not an exception; a stream that does not parse
|
|
102
|
+
throws `YamlError` (a parse failure, not a validation report).
|
|
103
|
+
|
|
104
|
+
### Gating a load
|
|
105
|
+
|
|
106
|
+
`load`/`loadAll` accept the same options and validate BEFORE loading
|
|
107
|
+
(the ruby/py face law):
|
|
108
|
+
|
|
109
|
+
```js
|
|
110
|
+
await load("a: 1\na: 2\n", { schema: "core" });
|
|
111
|
+
// throws ValidationError (the input PARSED — not a YamlError);
|
|
112
|
+
// e.diagnostics carries the whole report
|
|
113
|
+
|
|
114
|
+
await load("a: 1\na: 2\n", { schema: "core", collect: true });
|
|
115
|
+
// { document: { a: 2 }, diagnostics: [ ... ] } — the load and the
|
|
116
|
+
// whole report answer together (collect requires an armed gate)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
`loadAll` validates the whole stream before the parse and raises the
|
|
120
|
+
same `ValidationError` (collect rides `load` only).
|
|
43
121
|
|
|
44
122
|
The same model as [teptris-wasm](https://github.com/leptris/teptris-wasm):
|
|
45
123
|
a contained C bridge (`src/yeptris_wasm.c`) over the engine's
|
|
@@ -53,7 +131,7 @@ sibling engine checkout, surfaced as an ES module.
|
|
|
53
131
|
node --test test/test.mjs
|
|
54
132
|
```
|
|
55
133
|
|
|
56
|
-
CI builds the engine
|
|
134
|
+
CI builds the engine ref and runs the same on every push and PR.
|
|
57
135
|
|
|
58
136
|
## Releasing
|
|
59
137
|
|
package/dist/yeptris.mjs
CHANGED
|
@@ -5,7 +5,7 @@ var Module = (() => {
|
|
|
5
5
|
return (
|
|
6
6
|
async function(moduleArg = {}) {
|
|
7
7
|
|
|
8
|
-
var Module=moduleArg;var readyPromiseResolve,readyPromiseReject;Module["ready"]=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject});var moduleOverrides=Object.assign({},Module);var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof importScripts=="function";var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary;if(ENVIRONMENT_IS_NODE){const{createRequire:createRequire}=await import("module");var require=createRequire(import.meta.url);var fs=require("fs");var nodePath=require("path");if(ENVIRONMENT_IS_WORKER){scriptDirectory=nodePath.dirname(scriptDirectory)+"/"}else{scriptDirectory=require("url").fileURLToPath(new URL("./",import.meta.url))}read_=(filename,binary)=>{filename=isFileURI(filename)?new URL(filename):nodePath.normalize(filename);return fs.readFileSync(filename,binary?undefined:"utf8")};readBinary=filename=>{var ret=read_(filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}return ret};readAsync=(filename,onload,onerror,binary=true)=>{filename=isFileURI(filename)?new URL(filename):nodePath.normalize(filename);fs.readFile(filename,binary?undefined:"utf8",(err,data)=>{if(err)onerror(err);else onload(binary?data.buffer:data)})};if(!Module["thisProgram"]&&process.argv.length>1){thisProgram=process.argv[1].replace(/\\/g,"/")}arguments_=process.argv.slice(2);quit_=(status,toThrow)=>{process.exitCode=status;throw toThrow};Module["inspect"]=()=>"[Emscripten Module object]"}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptDir){scriptDirectory=_scriptDir}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=(url,onload,onerror)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.error.bind(console);Object.assign(Module,moduleOverrides);moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];if(typeof WebAssembly!="object"){abort("no native wasm support detected")}var wasmMemory;var ABORT=false;var EXITSTATUS;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAP64,HEAPU64,HEAPF64;function updateMemoryViews(){var b=wasmMemory.buffer;Module["HEAP8"]=HEAP8=new Int8Array(b);Module["HEAP16"]=HEAP16=new Int16Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);Module["HEAPU16"]=HEAPU16=new Uint16Array(b);Module["HEAP32"]=HEAP32=new Int32Array(b);Module["HEAPU32"]=HEAPU32=new Uint32Array(b);Module["HEAPF32"]=HEAPF32=new Float32Array(b);Module["HEAPF64"]=HEAPF64=new Float64Array(b);Module["HEAP64"]=HEAP64=new BigInt64Array(b);Module["HEAPU64"]=HEAPU64=new BigUint64Array(b)}var __ATPRERUN__=[];var __ATINIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnInit(cb){__ATINIT__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}what="Aborted("+what+")";err(what);ABORT=true;EXITSTATUS=1;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject(e);throw e}var dataURIPrefix="data:application/octet-stream;base64,";var isDataURI=filename=>filename.startsWith(dataURIPrefix);var isFileURI=filename=>filename.startsWith("file://");var wasmBinaryFile;if(Module["locateFile"]){wasmBinaryFile="yeptris.wasm";if(!isDataURI(wasmBinaryFile)){wasmBinaryFile=locateFile(wasmBinaryFile)}}else{wasmBinaryFile=new URL("yeptris.wasm",import.meta.url).href}function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}function getBinaryPromise(binaryFile){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)){if(typeof fetch=="function"){return fetch(binaryFile,{credentials:"same-origin"}).then(response=>{if(!response["ok"]){throw"failed to load wasm binary file at '"+binaryFile+"'"}return response["arrayBuffer"]()}).catch(()=>getBinarySync(binaryFile))}}return Promise.resolve().then(()=>getBinarySync(binaryFile))}function instantiateArrayBuffer(binaryFile,imports,receiver){return getBinaryPromise(binaryFile).then(binary=>WebAssembly.instantiate(binary,imports)).then(instance=>instance).then(receiver,reason=>{err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)})}function instantiateAsync(binary,binaryFile,imports,callback){if(!binary&&typeof WebAssembly.instantiateStreaming=="function"&&!isDataURI(binaryFile)&&!ENVIRONMENT_IS_NODE&&typeof fetch=="function"){return fetch(binaryFile,{credentials:"same-origin"}).then(response=>{var result=WebAssembly.instantiateStreaming(response,imports);return result.then(callback,function(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation");return instantiateArrayBuffer(binaryFile,imports,callback)})})}return instantiateArrayBuffer(binaryFile,imports,callback)}function createWasm(){var info={"a":wasmImports};function receiveInstance(instance,module){wasmExports=instance.exports;wasmMemory=wasmExports["g"];updateMemoryViews();addOnInit(wasmExports["h"]);removeRunDependency("wasm-instantiate");return wasmExports}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){receiveInstance(result["instance"])}if(Module["instantiateWasm"]){try{return Module["instantiateWasm"](info,receiveInstance)}catch(e){err(`Module.instantiateWasm callback failed with error: ${e}`);readyPromiseReject(e)}}instantiateAsync(wasmBinary,wasmBinaryFile,info,receiveInstantiationResult).catch(readyPromiseReject);return{}}var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var noExitRuntime=Module["noExitRuntime"]||true;var getHeapMax=()=>2147483648;var growMemory=size=>{var b=wasmMemory.buffer;var pages=(size-b.byteLength+65535)/65536;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}var alignUp=(x,multiple)=>x+(multiple-x%multiple)%multiple;for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignUp(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false};var ENV={};var getExecutableName=()=>thisProgram||"./this.program";var getEnvStrings=()=>{if(!getEnvStrings.strings){var lang=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8";var env={"USER":"web_user","LOGNAME":"web_user","PATH":"/","PWD":"/","HOME":"/home/web_user","LANG":lang,"_":getExecutableName()};for(var x in ENV){if(ENV[x]===undefined)delete env[x];else env[x]=ENV[x]}var strings=[];for(var x in env){strings.push(`${x}=${env[x]}`)}getEnvStrings.strings=strings}return getEnvStrings.strings};var stringToAscii=(str,buffer)=>{for(var i=0;i<str.length;++i){HEAP8[buffer++>>0]=str.charCodeAt(i)}HEAP8[buffer>>0]=0};var UTF8Decoder=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):undefined;var UTF8ArrayToString=(heapOrArray,idx,maxBytesToRead)=>{var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx<endPtr){var u0=heapOrArray[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}return str};var UTF8ToString=(ptr,maxBytesToRead)=>ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):"";var SYSCALLS={varargs:undefined,get(){var ret=HEAP32[+SYSCALLS.varargs>>2];SYSCALLS.varargs+=4;return ret},getp(){return SYSCALLS.get()},getStr(ptr){var ret=UTF8ToString(ptr);return ret}};var _environ_get=(__environ,environ_buf)=>{var bufSize=0;getEnvStrings().forEach((string,i)=>{var ptr=environ_buf+bufSize;HEAPU32[__environ+i*4>>2]=ptr;stringToAscii(string,ptr);bufSize+=string.length+1});return 0};var _environ_sizes_get=(penviron_count,penviron_buf_size)=>{var strings=getEnvStrings();HEAPU32[penviron_count>>2]=strings.length;var bufSize=0;strings.forEach(string=>bufSize+=string.length+1);HEAPU32[penviron_buf_size>>2]=bufSize;return 0};var _fd_close=fd=>52;var MAX_INT53=9007199254740992;var MIN_INT53=-9007199254740992;var bigintToI53Checked=num=>num<MIN_INT53||num>MAX_INT53?NaN:Number(num);function _fd_seek(fd,offset,whence,newOffset){offset=bigintToI53Checked(offset);return 70}var printCharBuffers=[null,[],[]];var printChar=(stream,curr)=>{var buffer=printCharBuffers[stream];if(curr===0||curr===10){(stream===1?out:err)(UTF8ArrayToString(buffer,0));buffer.length=0}else{buffer.push(curr)}};var _fd_write=(fd,iov,iovcnt,pnum)=>{var num=0;for(var i=0;i<iovcnt;i++){var ptr=HEAPU32[iov>>2];var len=HEAPU32[iov+4>>2];iov+=8;for(var j=0;j<len;j++){printChar(fd,HEAPU8[ptr+j])}num+=len}HEAPU32[pnum>>2]=num;return 0};var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.charCodeAt(i);if(u>=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);var lengthBytesUTF8=str=>{var len=0;for(var i=0;i<str.length;++i){var c=str.charCodeAt(i);if(c<=127){len++}else if(c<=2047){len+=2}else if(c>=55296&&c<=57343){len+=4;++i}else{len+=3}}return len};var wasmImports={b:_emscripten_resize_heap,e:_environ_get,f:_environ_sizes_get,d:_fd_close,c:_fd_seek,a:_fd_write};var wasmExports=createWasm();var ___wasm_call_ctors=()=>(___wasm_call_ctors=wasmExports["h"])();var _yeptris_wasm_load=Module["_yeptris_wasm_load"]=(a0,a1)=>(_yeptris_wasm_load=Module["_yeptris_wasm_load"]=wasmExports["i"])(a0,a1);var _malloc=Module["_malloc"]=a0=>(_malloc=Module["_malloc"]=wasmExports["j"])(a0);var _yeptris_wasm_load_all=Module["_yeptris_wasm_load_all"]=(a0,a1)=>(_yeptris_wasm_load_all=Module["_yeptris_wasm_load_all"]=wasmExports["k"])(a0,a1);var _yeptris_wasm_dump=Module["_yeptris_wasm_dump"]=(a0,a1)=>(_yeptris_wasm_dump=Module["_yeptris_wasm_dump"]=wasmExports["l"])(a0,a1);var _yeptris_wasm_last_error=Module["_yeptris_wasm_last_error"]=()=>(_yeptris_wasm_last_error=Module["_yeptris_wasm_last_error"]=wasmExports["m"])();var _yeptris_wasm_last_error_line=Module["_yeptris_wasm_last_error_line"]=()=>(_yeptris_wasm_last_error_line=Module["_yeptris_wasm_last_error_line"]=wasmExports["n"])();var _yeptris_wasm_last_error_column=Module["_yeptris_wasm_last_error_column"]=()=>(_yeptris_wasm_last_error_column=Module["_yeptris_wasm_last_error_column"]=wasmExports["o"])();var _yeptris_wasm_out=Module["_yeptris_wasm_out"]=()=>(_yeptris_wasm_out=Module["_yeptris_wasm_out"]=wasmExports["p"])();var _yeptris_wasm_out_len=Module["_yeptris_wasm_out_len"]=()=>(_yeptris_wasm_out_len=Module["_yeptris_wasm_out_len"]=wasmExports["q"])();var _yeptris_wasm_out_free=Module["_yeptris_wasm_out_free"]=()=>(_yeptris_wasm_out_free=Module["_yeptris_wasm_out_free"]=wasmExports["r"])();var _yeptris_wasm_free=Module["_yeptris_wasm_free"]=a0=>(_yeptris_wasm_free=Module["_yeptris_wasm_free"]=wasmExports["s"])(a0);var _yeptris_wasm_version=Module["_yeptris_wasm_version"]=()=>(_yeptris_wasm_version=Module["_yeptris_wasm_version"]=wasmExports["t"])();var _yeptris_wasm_events=Module["_yeptris_wasm_events"]=(a0,a1)=>(_yeptris_wasm_events=Module["_yeptris_wasm_events"]=wasmExports["u"])(a0,a1);var _yeptris_wasm_event_records=Module["_yeptris_wasm_event_records"]=()=>(_yeptris_wasm_event_records=Module["_yeptris_wasm_event_records"]=wasmExports["v"])();var _yeptris_wasm_event_count=Module["_yeptris_wasm_event_count"]=()=>(_yeptris_wasm_event_count=Module["_yeptris_wasm_event_count"]=wasmExports["w"])();var _yeptris_wasm_event_arena=Module["_yeptris_wasm_event_arena"]=()=>(_yeptris_wasm_event_arena=Module["_yeptris_wasm_event_arena"]=wasmExports["x"])();var _yeptris_wasm_event_arena_len=Module["_yeptris_wasm_event_arena_len"]=()=>(_yeptris_wasm_event_arena_len=Module["_yeptris_wasm_event_arena_len"]=wasmExports["y"])();var _yeptris_wasm_events_free=Module["_yeptris_wasm_events_free"]=()=>(_yeptris_wasm_events_free=Module["_yeptris_wasm_events_free"]=wasmExports["z"])();var ___errno_location=()=>(___errno_location=wasmExports["__errno_location"])();Module["UTF8ToString"]=UTF8ToString;Module["stringToUTF8"]=stringToUTF8;Module["lengthBytesUTF8"]=lengthBytesUTF8;var calledRun;dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function run(){if(runDependencies>0){return}preRun();if(runDependencies>0){return}function doRun(){if(calledRun)return;calledRun=true;Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve(Module);if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else{doRun()}}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}run();
|
|
8
|
+
var Module=moduleArg;var readyPromiseResolve,readyPromiseReject;Module["ready"]=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject});var moduleOverrides=Object.assign({},Module);var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof importScripts=="function";var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary;if(ENVIRONMENT_IS_NODE){const{createRequire:createRequire}=await import("module");var require=createRequire(import.meta.url);var fs=require("fs");var nodePath=require("path");if(ENVIRONMENT_IS_WORKER){scriptDirectory=nodePath.dirname(scriptDirectory)+"/"}else{scriptDirectory=require("url").fileURLToPath(new URL("./",import.meta.url))}read_=(filename,binary)=>{filename=isFileURI(filename)?new URL(filename):nodePath.normalize(filename);return fs.readFileSync(filename,binary?undefined:"utf8")};readBinary=filename=>{var ret=read_(filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}return ret};readAsync=(filename,onload,onerror,binary=true)=>{filename=isFileURI(filename)?new URL(filename):nodePath.normalize(filename);fs.readFile(filename,binary?undefined:"utf8",(err,data)=>{if(err)onerror(err);else onload(binary?data.buffer:data)})};if(!Module["thisProgram"]&&process.argv.length>1){thisProgram=process.argv[1].replace(/\\/g,"/")}arguments_=process.argv.slice(2);quit_=(status,toThrow)=>{process.exitCode=status;throw toThrow};Module["inspect"]=()=>"[Emscripten Module object]"}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptDir){scriptDirectory=_scriptDir}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=(url,onload,onerror)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.error.bind(console);Object.assign(Module,moduleOverrides);moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];if(typeof WebAssembly!="object"){abort("no native wasm support detected")}var wasmMemory;var ABORT=false;var EXITSTATUS;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAP64,HEAPU64,HEAPF64;function updateMemoryViews(){var b=wasmMemory.buffer;Module["HEAP8"]=HEAP8=new Int8Array(b);Module["HEAP16"]=HEAP16=new Int16Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);Module["HEAPU16"]=HEAPU16=new Uint16Array(b);Module["HEAP32"]=HEAP32=new Int32Array(b);Module["HEAPU32"]=HEAPU32=new Uint32Array(b);Module["HEAPF32"]=HEAPF32=new Float32Array(b);Module["HEAPF64"]=HEAPF64=new Float64Array(b);Module["HEAP64"]=HEAP64=new BigInt64Array(b);Module["HEAPU64"]=HEAPU64=new BigUint64Array(b)}var __ATPRERUN__=[];var __ATINIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnInit(cb){__ATINIT__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}what="Aborted("+what+")";err(what);ABORT=true;EXITSTATUS=1;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject(e);throw e}var dataURIPrefix="data:application/octet-stream;base64,";var isDataURI=filename=>filename.startsWith(dataURIPrefix);var isFileURI=filename=>filename.startsWith("file://");var wasmBinaryFile;if(Module["locateFile"]){wasmBinaryFile="yeptris.wasm";if(!isDataURI(wasmBinaryFile)){wasmBinaryFile=locateFile(wasmBinaryFile)}}else{wasmBinaryFile=new URL("yeptris.wasm",import.meta.url).href}function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}function getBinaryPromise(binaryFile){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)){if(typeof fetch=="function"){return fetch(binaryFile,{credentials:"same-origin"}).then(response=>{if(!response["ok"]){throw"failed to load wasm binary file at '"+binaryFile+"'"}return response["arrayBuffer"]()}).catch(()=>getBinarySync(binaryFile))}}return Promise.resolve().then(()=>getBinarySync(binaryFile))}function instantiateArrayBuffer(binaryFile,imports,receiver){return getBinaryPromise(binaryFile).then(binary=>WebAssembly.instantiate(binary,imports)).then(instance=>instance).then(receiver,reason=>{err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)})}function instantiateAsync(binary,binaryFile,imports,callback){if(!binary&&typeof WebAssembly.instantiateStreaming=="function"&&!isDataURI(binaryFile)&&!ENVIRONMENT_IS_NODE&&typeof fetch=="function"){return fetch(binaryFile,{credentials:"same-origin"}).then(response=>{var result=WebAssembly.instantiateStreaming(response,imports);return result.then(callback,function(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation");return instantiateArrayBuffer(binaryFile,imports,callback)})})}return instantiateArrayBuffer(binaryFile,imports,callback)}function createWasm(){var info={"a":wasmImports};function receiveInstance(instance,module){wasmExports=instance.exports;wasmMemory=wasmExports["g"];updateMemoryViews();addOnInit(wasmExports["h"]);removeRunDependency("wasm-instantiate");return wasmExports}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){receiveInstance(result["instance"])}if(Module["instantiateWasm"]){try{return Module["instantiateWasm"](info,receiveInstance)}catch(e){err(`Module.instantiateWasm callback failed with error: ${e}`);readyPromiseReject(e)}}instantiateAsync(wasmBinary,wasmBinaryFile,info,receiveInstantiationResult).catch(readyPromiseReject);return{}}var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var noExitRuntime=Module["noExitRuntime"]||true;var getHeapMax=()=>2147483648;var growMemory=size=>{var b=wasmMemory.buffer;var pages=(size-b.byteLength+65535)/65536;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}var alignUp=(x,multiple)=>x+(multiple-x%multiple)%multiple;for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignUp(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false};var ENV={};var getExecutableName=()=>thisProgram||"./this.program";var getEnvStrings=()=>{if(!getEnvStrings.strings){var lang=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8";var env={"USER":"web_user","LOGNAME":"web_user","PATH":"/","PWD":"/","HOME":"/home/web_user","LANG":lang,"_":getExecutableName()};for(var x in ENV){if(ENV[x]===undefined)delete env[x];else env[x]=ENV[x]}var strings=[];for(var x in env){strings.push(`${x}=${env[x]}`)}getEnvStrings.strings=strings}return getEnvStrings.strings};var stringToAscii=(str,buffer)=>{for(var i=0;i<str.length;++i){HEAP8[buffer++>>0]=str.charCodeAt(i)}HEAP8[buffer>>0]=0};var UTF8Decoder=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):undefined;var UTF8ArrayToString=(heapOrArray,idx,maxBytesToRead)=>{var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx<endPtr){var u0=heapOrArray[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}return str};var UTF8ToString=(ptr,maxBytesToRead)=>ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):"";var SYSCALLS={varargs:undefined,get(){var ret=HEAP32[+SYSCALLS.varargs>>2];SYSCALLS.varargs+=4;return ret},getp(){return SYSCALLS.get()},getStr(ptr){var ret=UTF8ToString(ptr);return ret}};var _environ_get=(__environ,environ_buf)=>{var bufSize=0;getEnvStrings().forEach((string,i)=>{var ptr=environ_buf+bufSize;HEAPU32[__environ+i*4>>2]=ptr;stringToAscii(string,ptr);bufSize+=string.length+1});return 0};var _environ_sizes_get=(penviron_count,penviron_buf_size)=>{var strings=getEnvStrings();HEAPU32[penviron_count>>2]=strings.length;var bufSize=0;strings.forEach(string=>bufSize+=string.length+1);HEAPU32[penviron_buf_size>>2]=bufSize;return 0};var _fd_close=fd=>52;var MAX_INT53=9007199254740992;var MIN_INT53=-9007199254740992;var bigintToI53Checked=num=>num<MIN_INT53||num>MAX_INT53?NaN:Number(num);function _fd_seek(fd,offset,whence,newOffset){offset=bigintToI53Checked(offset);return 70}var printCharBuffers=[null,[],[]];var printChar=(stream,curr)=>{var buffer=printCharBuffers[stream];if(curr===0||curr===10){(stream===1?out:err)(UTF8ArrayToString(buffer,0));buffer.length=0}else{buffer.push(curr)}};var _fd_write=(fd,iov,iovcnt,pnum)=>{var num=0;for(var i=0;i<iovcnt;i++){var ptr=HEAPU32[iov>>2];var len=HEAPU32[iov+4>>2];iov+=8;for(var j=0;j<len;j++){printChar(fd,HEAPU8[ptr+j])}num+=len}HEAPU32[pnum>>2]=num;return 0};var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.charCodeAt(i);if(u>=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);var lengthBytesUTF8=str=>{var len=0;for(var i=0;i<str.length;++i){var c=str.charCodeAt(i);if(c<=127){len++}else if(c<=2047){len+=2}else if(c>=55296&&c<=57343){len+=4;++i}else{len+=3}}return len};var wasmImports={b:_emscripten_resize_heap,e:_environ_get,f:_environ_sizes_get,d:_fd_close,c:_fd_seek,a:_fd_write};var wasmExports=createWasm();var ___wasm_call_ctors=()=>(___wasm_call_ctors=wasmExports["h"])();var _yeptris_wasm_load=Module["_yeptris_wasm_load"]=(a0,a1)=>(_yeptris_wasm_load=Module["_yeptris_wasm_load"]=wasmExports["i"])(a0,a1);var _malloc=Module["_malloc"]=a0=>(_malloc=Module["_malloc"]=wasmExports["j"])(a0);var _yeptris_wasm_load_all=Module["_yeptris_wasm_load_all"]=(a0,a1)=>(_yeptris_wasm_load_all=Module["_yeptris_wasm_load_all"]=wasmExports["k"])(a0,a1);var _yeptris_wasm_dump_ex=Module["_yeptris_wasm_dump_ex"]=(a0,a1,a2,a3)=>(_yeptris_wasm_dump_ex=Module["_yeptris_wasm_dump_ex"]=wasmExports["l"])(a0,a1,a2,a3);var _yeptris_wasm_dump=Module["_yeptris_wasm_dump"]=(a0,a1)=>(_yeptris_wasm_dump=Module["_yeptris_wasm_dump"]=wasmExports["m"])(a0,a1);var _yeptris_wasm_last_error=Module["_yeptris_wasm_last_error"]=()=>(_yeptris_wasm_last_error=Module["_yeptris_wasm_last_error"]=wasmExports["n"])();var _yeptris_wasm_last_error_line=Module["_yeptris_wasm_last_error_line"]=()=>(_yeptris_wasm_last_error_line=Module["_yeptris_wasm_last_error_line"]=wasmExports["o"])();var _yeptris_wasm_last_error_column=Module["_yeptris_wasm_last_error_column"]=()=>(_yeptris_wasm_last_error_column=Module["_yeptris_wasm_last_error_column"]=wasmExports["p"])();var _yeptris_wasm_out=Module["_yeptris_wasm_out"]=()=>(_yeptris_wasm_out=Module["_yeptris_wasm_out"]=wasmExports["q"])();var _yeptris_wasm_out_len=Module["_yeptris_wasm_out_len"]=()=>(_yeptris_wasm_out_len=Module["_yeptris_wasm_out_len"]=wasmExports["r"])();var _yeptris_wasm_out_free=Module["_yeptris_wasm_out_free"]=()=>(_yeptris_wasm_out_free=Module["_yeptris_wasm_out_free"]=wasmExports["s"])();var _yeptris_wasm_free=Module["_yeptris_wasm_free"]=a0=>(_yeptris_wasm_free=Module["_yeptris_wasm_free"]=wasmExports["t"])(a0);var _yeptris_wasm_version=Module["_yeptris_wasm_version"]=()=>(_yeptris_wasm_version=Module["_yeptris_wasm_version"]=wasmExports["u"])();var _yeptris_wasm_events=Module["_yeptris_wasm_events"]=(a0,a1)=>(_yeptris_wasm_events=Module["_yeptris_wasm_events"]=wasmExports["v"])(a0,a1);var _yeptris_wasm_event_records=Module["_yeptris_wasm_event_records"]=()=>(_yeptris_wasm_event_records=Module["_yeptris_wasm_event_records"]=wasmExports["w"])();var _yeptris_wasm_event_count=Module["_yeptris_wasm_event_count"]=()=>(_yeptris_wasm_event_count=Module["_yeptris_wasm_event_count"]=wasmExports["x"])();var _yeptris_wasm_event_arena=Module["_yeptris_wasm_event_arena"]=()=>(_yeptris_wasm_event_arena=Module["_yeptris_wasm_event_arena"]=wasmExports["y"])();var _yeptris_wasm_event_arena_len=Module["_yeptris_wasm_event_arena_len"]=()=>(_yeptris_wasm_event_arena_len=Module["_yeptris_wasm_event_arena_len"]=wasmExports["z"])();var _yeptris_wasm_events_free=Module["_yeptris_wasm_events_free"]=()=>(_yeptris_wasm_events_free=Module["_yeptris_wasm_events_free"]=wasmExports["A"])();var _yeptris_wasm_each_open=Module["_yeptris_wasm_each_open"]=(a0,a1)=>(_yeptris_wasm_each_open=Module["_yeptris_wasm_each_open"]=wasmExports["B"])(a0,a1);var _yeptris_wasm_each_next=Module["_yeptris_wasm_each_next"]=()=>(_yeptris_wasm_each_next=Module["_yeptris_wasm_each_next"]=wasmExports["C"])();var _yeptris_wasm_each_frame=Module["_yeptris_wasm_each_frame"]=()=>(_yeptris_wasm_each_frame=Module["_yeptris_wasm_each_frame"]=wasmExports["D"])();var _yeptris_wasm_each_index=Module["_yeptris_wasm_each_index"]=()=>(_yeptris_wasm_each_index=Module["_yeptris_wasm_each_index"]=wasmExports["E"])();var _yeptris_wasm_each_close=Module["_yeptris_wasm_each_close"]=()=>(_yeptris_wasm_each_close=Module["_yeptris_wasm_each_close"]=wasmExports["F"])();var _yeptris_wasm_validate=Module["_yeptris_wasm_validate"]=(a0,a1,a2)=>(_yeptris_wasm_validate=Module["_yeptris_wasm_validate"]=wasmExports["G"])(a0,a1,a2);var _yeptris_wasm_json_schema_validate=Module["_yeptris_wasm_json_schema_validate"]=(a0,a1,a2,a3)=>(_yeptris_wasm_json_schema_validate=Module["_yeptris_wasm_json_schema_validate"]=wasmExports["H"])(a0,a1,a2,a3);var _yeptris_wasm_schema_compile=Module["_yeptris_wasm_schema_compile"]=(a0,a1)=>(_yeptris_wasm_schema_compile=Module["_yeptris_wasm_schema_compile"]=wasmExports["I"])(a0,a1);var _yeptris_wasm_schema_validate=Module["_yeptris_wasm_schema_validate"]=(a0,a1,a2)=>(_yeptris_wasm_schema_validate=Module["_yeptris_wasm_schema_validate"]=wasmExports["J"])(a0,a1,a2);var _yeptris_wasm_schema_free=Module["_yeptris_wasm_schema_free"]=a0=>(_yeptris_wasm_schema_free=Module["_yeptris_wasm_schema_free"]=wasmExports["K"])(a0);var ___errno_location=()=>(___errno_location=wasmExports["__errno_location"])();Module["UTF8ToString"]=UTF8ToString;Module["stringToUTF8"]=stringToUTF8;Module["lengthBytesUTF8"]=lengthBytesUTF8;var calledRun;dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function run(){if(runDependencies>0){return}preRun();if(runDependencies>0){return}function doRun(){if(calledRun)return;calledRun=true;Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve(Module);if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else{doRun()}}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}run();
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
return moduleArg.ready
|
package/dist/yeptris.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -4,19 +4,129 @@ export declare class YamlError extends Error {
|
|
|
4
4
|
column: number;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
+
/** Raised by load/loadAll when the input PARSES but the armed schema
|
|
8
|
+
* walk produced diagnostics (validate BEFORE loading). Carries the
|
|
9
|
+
* whole report as `diagnostics` — never first-fail. Not a YamlError:
|
|
10
|
+
* the input is well-formed. */
|
|
11
|
+
export declare class ValidationError extends Error {
|
|
12
|
+
diagnostics: Diagnostic[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** One structured validation miss. `path` is the JSON-pointer
|
|
16
|
+
* instance path split into ~0/~1-unescaped segments ([] at the
|
|
17
|
+
* document root); `pointer` is its raw string form; `message` is the
|
|
18
|
+
* engine's bounded detail; `line`/`col` are the offending node's
|
|
19
|
+
* 1-based mark (0 = unknown: scalars whose bytes the DOM owns have no
|
|
20
|
+
* input position — the path still identifies them). */
|
|
21
|
+
export interface Diagnostic {
|
|
22
|
+
/** The engine's YeptrisDiagCode (validate.h, ABI-pinned,
|
|
23
|
+
* appending-only). */
|
|
24
|
+
code: number;
|
|
25
|
+
/** The spec-spelled keyword: the violated JSON Schema keyword for
|
|
26
|
+
* the 2020-12 walk ("type", "minimum", "required", "$ref", ...), the
|
|
27
|
+
* violated YAML rule for the family walk ("tag", "keyType",
|
|
28
|
+
* "jsonType", "duplicateKey"). */
|
|
29
|
+
keyword: string;
|
|
30
|
+
/** The instance path as segments, ~0/~1 unescaped; [] at the root. */
|
|
31
|
+
path: string[];
|
|
32
|
+
/** The raw JSON-pointer form of `path` ("" at the root). */
|
|
33
|
+
pointer: string;
|
|
34
|
+
/** The engine's bounded explanation ("3 is less than the minimum
|
|
35
|
+
* 10"). */
|
|
36
|
+
message: string;
|
|
37
|
+
/** 1-based line of the offending node (0 = unknown). */
|
|
38
|
+
line: number;
|
|
39
|
+
/** 1-based column of the offending node (0 = unknown). */
|
|
40
|
+
col: number;
|
|
41
|
+
/** The offending node's byte offset in the input. */
|
|
42
|
+
offset: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Options that arm a validation gate. The doors are alternatives —
|
|
46
|
+
* passing schema AND jsonSchema throws TypeError. */
|
|
47
|
+
export interface ValidateOptions {
|
|
48
|
+
/** The schema-FAMILY walk: "core" (default) — explicit-tag
|
|
49
|
+
* consistency + canonical-form key uniqueness (spec 3.2.1.3);
|
|
50
|
+
* "json" — the spec 10.2 JSON productions (every plain scalar a
|
|
51
|
+
* JSON type, string mapping keys). A compiled Schema (from
|
|
52
|
+
* compileSchema()) selects the compiled door instead. */
|
|
53
|
+
schema?: "core" | "json" | Schema;
|
|
54
|
+
/** The JSON Schema draft 2020-12 walk: the schema document itself
|
|
55
|
+
* (object — serialized for the wire — or string). The engine's
|
|
56
|
+
* keyword subset applies; unknown keywords are ignored, per
|
|
57
|
+
* 2020-12. */
|
|
58
|
+
jsonSchema?: object | string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** load's collect posture: the document plus the whole report
|
|
62
|
+
* (requires an armed gate — schema: or jsonSchema:). */
|
|
63
|
+
export interface LoadCollectResult {
|
|
64
|
+
document: unknown;
|
|
65
|
+
diagnostics: Diagnostic[];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** A COMPILED JSON Schema: the schema parses once (its DOM and
|
|
69
|
+
* pattern programs retained behind one opaque handle) and validates
|
|
70
|
+
* many instance streams. Build with compileSchema(); after free()
|
|
71
|
+
* reuse throws, double-free is a no-op. */
|
|
72
|
+
export declare class Schema {
|
|
73
|
+
private constructor();
|
|
74
|
+
/** Every diagnostic across every document of `input` ([] when
|
|
75
|
+
* valid). Synchronous — the handle only exists once the module is
|
|
76
|
+
* initialized. Throws after free(). */
|
|
77
|
+
validate(input: string): Diagnostic[];
|
|
78
|
+
/** True when validate() answers no diagnostics. */
|
|
79
|
+
isValid(input: string): boolean;
|
|
80
|
+
/** True once free() ran. */
|
|
81
|
+
get freed(): boolean;
|
|
82
|
+
/** Frees the handle and everything it owns in one call. Idempotent;
|
|
83
|
+
* afterwards the handle is dead (reuse throws, never crashes). */
|
|
84
|
+
free(): void;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Compile a JSON Schema document (object or string; JSON is YAML
|
|
88
|
+
* flow, so a YAML-shaped mapping schema compiles too) into a reusable
|
|
89
|
+
* Schema handle — parse ONCE, validate many. Throws TypeError for
|
|
90
|
+
* empty/absent schema bytes and YamlError (with the engine's message)
|
|
91
|
+
* for bytes that do not parse. */
|
|
92
|
+
export declare function compileSchema(jsonSchema: object | string): Promise<Schema>;
|
|
93
|
+
|
|
94
|
+
/** Validate a YAML stream, answering the WHOLE report: every
|
|
95
|
+
* diagnostic, in engine order ([] when valid). Without options the
|
|
96
|
+
* core-family walk runs. Throws YamlError when the stream does not
|
|
97
|
+
* parse. */
|
|
98
|
+
export declare function validate(
|
|
99
|
+
input: string,
|
|
100
|
+
options?: ValidateOptions,
|
|
101
|
+
): Promise<Diagnostic[]>;
|
|
102
|
+
|
|
103
|
+
/** True when validate() answers no diagnostics. */
|
|
104
|
+
export declare function isValid(
|
|
105
|
+
input: string,
|
|
106
|
+
options?: ValidateOptions,
|
|
107
|
+
): Promise<boolean>;
|
|
108
|
+
|
|
7
109
|
/** Parse YAML text and return the document as a JavaScript value
|
|
8
110
|
* (the engine's canonical JSON, JSON.parse'd). Throws YamlError with
|
|
9
111
|
* line/column on malformed input. A multi-document stream answers
|
|
10
|
-
* with the FIRST document; every document comes from loadAll.
|
|
11
|
-
|
|
112
|
+
* with the FIRST document; every document comes from loadAll.
|
|
113
|
+
* options arms a validation gate (validate BEFORE loading): with
|
|
114
|
+
* diagnostics the load raises ValidationError; with `collect: true`
|
|
115
|
+
* it answers a LoadCollectResult instead. */
|
|
116
|
+
export declare function load(
|
|
117
|
+
yaml: string,
|
|
118
|
+
options?: ValidateOptions & { collect?: boolean },
|
|
119
|
+
): Promise<unknown>;
|
|
12
120
|
|
|
13
121
|
/** Parse a multi-document YAML stream and return EVERY document as a
|
|
14
122
|
* JavaScript value, in stream order. An empty or comment-only stream
|
|
15
|
-
* answers []. options
|
|
16
|
-
*
|
|
123
|
+
* answers []. options arms a whole-stream validation gate that runs
|
|
124
|
+
* BEFORE the parse and raises ValidationError carrying the whole
|
|
125
|
+
* report (collect rides load() only). Throws YamlError with
|
|
126
|
+
* line/column on malformed input. */
|
|
17
127
|
export declare function loadAll(
|
|
18
128
|
yaml: string,
|
|
19
|
-
options?:
|
|
129
|
+
options?: ValidateOptions,
|
|
20
130
|
): Promise<unknown[]>;
|
|
21
131
|
|
|
22
132
|
/** Parse YAML text and return the engine's canonical JSON string. */
|
|
@@ -69,12 +179,119 @@ export declare function events(
|
|
|
69
179
|
options?: Record<string, unknown>,
|
|
70
180
|
): Promise<YamlEvent[]>;
|
|
71
181
|
|
|
182
|
+
/** One step of the tolerant stream walk (eachDocument): a valid
|
|
183
|
+
* document or a failed one, in stream order. The two shapes are
|
|
184
|
+
* exclusive — `document` is present (and `error` undefined) exactly
|
|
185
|
+
* when the frame parsed. */
|
|
186
|
+
export type EachDocumentResult =
|
|
187
|
+
| { document: unknown; index: number; error: undefined }
|
|
188
|
+
| { document: undefined; index: number; error: YamlError };
|
|
189
|
+
|
|
190
|
+
/** Walk a multi-document stream one document at a time, TOLERANTLY
|
|
191
|
+
* (the engine's stream iterator): an async generator of
|
|
192
|
+
* EachDocumentResult in stream order. A parse-class failure carries
|
|
193
|
+
* the failed document's OWN line/column and its 0-based stream index,
|
|
194
|
+
* and the walk CONTINUES at the next `---` line-start marker — the
|
|
195
|
+
* valid documents after a bad one are kept (loadAll would fail the
|
|
196
|
+
* whole stream instead). The stream-fatal classes (memory/encoding)
|
|
197
|
+
* yield their item and end the walk; an unrecoverable tail ends it.
|
|
198
|
+
* Lazy: nothing parses until iteration starts. Documents materialize
|
|
199
|
+
* through load's serialize door (the engine's default, schema 1.2
|
|
200
|
+
* core). */
|
|
201
|
+
export declare function eachDocument(
|
|
202
|
+
yaml: string,
|
|
203
|
+
): AsyncGenerator<EachDocumentResult, void, undefined>;
|
|
204
|
+
|
|
205
|
+
/** Options for dump (js-yaml parity names over emit.h's
|
|
206
|
+
* yeptris_emit_options). `indent` and `flowLevel` have no engine
|
|
207
|
+
* option — the block indent is fixed at 2 and there is no flow-level
|
|
208
|
+
* override — so they are not in the surface rather than silently
|
|
209
|
+
* ignored. */
|
|
210
|
+
export interface DumpOptions {
|
|
211
|
+
/** Fold flow collections once the current line exceeds this column
|
|
212
|
+
* (the engine's best_width; the emitter wraps after a value).
|
|
213
|
+
* Default: the engine default (80). -1 disables folding. */
|
|
214
|
+
lineWidth?: number;
|
|
215
|
+
/** The engine's fixed form: flow collections, quoted strings, typed
|
|
216
|
+
* words, shortest floats — a parse of the output re-serializes
|
|
217
|
+
* byte-identically. Default: false (the recorded-style fidelity
|
|
218
|
+
* mode). */
|
|
219
|
+
canonical?: boolean;
|
|
220
|
+
}
|
|
221
|
+
|
|
72
222
|
/** Convert JSON text (or any JSON-serializable value) to the engine's
|
|
73
|
-
*
|
|
74
|
-
|
|
223
|
+
* byte-stable YAML. Throws TypeError on an unsupported or mistyped
|
|
224
|
+
* option. */
|
|
225
|
+
export declare function dump(
|
|
226
|
+
json: string | unknown,
|
|
227
|
+
options?: DumpOptions,
|
|
228
|
+
): Promise<string>;
|
|
75
229
|
|
|
76
230
|
/** The libyeptris version string. */
|
|
77
231
|
export declare function version(): Promise<string>;
|
|
78
232
|
|
|
79
233
|
/** The wasm module instance the package caches (diagnostics). */
|
|
80
234
|
export declare function wasmModule(): Promise<Record<string, unknown>>;
|
|
235
|
+
|
|
236
|
+
// ---- the Sync postures (usable once the module is initialized) ---------
|
|
237
|
+
//
|
|
238
|
+
// The wasm executes synchronously; the async forms are async only
|
|
239
|
+
// because the FIRST call may initialize the module. After one
|
|
240
|
+
// `await init()` (or any async call) the same bodies run
|
|
241
|
+
// synchronously. Each Sync form throws unless the module is
|
|
242
|
+
// initialized — the lazy import is an async door.
|
|
243
|
+
|
|
244
|
+
/** Initialize the wasm module (idempotent). Unlocks the Sync forms. */
|
|
245
|
+
export declare function init(): Promise<void>;
|
|
246
|
+
|
|
247
|
+
/** load's Sync twin. Throws unless the module is initialized. */
|
|
248
|
+
export declare function loadSync(
|
|
249
|
+
yaml: string,
|
|
250
|
+
options?: ValidateOptions & { collect?: boolean },
|
|
251
|
+
): unknown;
|
|
252
|
+
|
|
253
|
+
/** loadAll's Sync twin. Throws unless the module is initialized. */
|
|
254
|
+
export declare function loadAllSync(
|
|
255
|
+
yaml: string,
|
|
256
|
+
options?: ValidateOptions,
|
|
257
|
+
): unknown[];
|
|
258
|
+
|
|
259
|
+
/** loadJSON's Sync twin. Throws unless the module is initialized. */
|
|
260
|
+
export declare function loadJSONSync(yaml: string): string;
|
|
261
|
+
|
|
262
|
+
/** events' Sync twin. Throws unless the module is initialized. */
|
|
263
|
+
export declare function eventsSync(
|
|
264
|
+
yaml: string,
|
|
265
|
+
options?: Record<string, unknown>,
|
|
266
|
+
): YamlEvent[];
|
|
267
|
+
|
|
268
|
+
/** dump's Sync twin. Throws unless the module is initialized. */
|
|
269
|
+
export declare function dumpSync(
|
|
270
|
+
json: string | unknown,
|
|
271
|
+
options?: DumpOptions,
|
|
272
|
+
): string;
|
|
273
|
+
|
|
274
|
+
/** validate's Sync twin. Throws unless the module is initialized. */
|
|
275
|
+
export declare function validateSync(
|
|
276
|
+
input: string,
|
|
277
|
+
options?: ValidateOptions,
|
|
278
|
+
): Diagnostic[];
|
|
279
|
+
|
|
280
|
+
/** isValid's Sync twin. Throws unless the module is initialized. */
|
|
281
|
+
export declare function isValidSync(
|
|
282
|
+
input: string,
|
|
283
|
+
options?: ValidateOptions,
|
|
284
|
+
): boolean;
|
|
285
|
+
|
|
286
|
+
/** compileSchema's Sync twin. Throws unless the module is initialized. */
|
|
287
|
+
export declare function compileSchemaSync(jsonSchema: object | string): Schema;
|
|
288
|
+
|
|
289
|
+
/** eachDocument's Sync twin: a sync generator over an initialized
|
|
290
|
+
* module (await init() first). Throws unless the module is
|
|
291
|
+
* initialized. */
|
|
292
|
+
export declare function eachDocumentSync(
|
|
293
|
+
yaml: string,
|
|
294
|
+
): Generator<EachDocumentResult, void, undefined>;
|
|
295
|
+
|
|
296
|
+
/** version's Sync twin. Throws unless the module is initialized. */
|
|
297
|
+
export declare function versionSync(): string;
|