yeptris 0.6.56 → 0.6.58

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 CHANGED
@@ -7,9 +7,9 @@ Part of the yeptris program: *the best (multiple dimensions)
7
7
  YAML/JSON parser/builder ever* — conformance, performance,
8
8
  safety/hardening, API surfaces, transport correctness, and trust,
9
9
  held simultaneously, in C, Ruby, Rust, and JS. This binding is the
10
- thinnest surface (the WASM module); the recorder bulk-drain and
11
- iterparse are planned next (the engine's PLAN.md, "The best-ever
12
- program").
10
+ thinnest surface (the WASM module); the recorder bulk-drain rides the
11
+ `events()` face, iterparse is planned next (the engine's PLAN.md, "The
12
+ best-ever program").
13
13
 
14
14
  ```js
15
15
  import { load, dump } from "yeptris";
@@ -22,7 +22,20 @@ const yaml = await dump({ name: "yeptris", langs: ["c", "rust"] });
22
22
  ```
23
23
 
24
24
  - `load(yaml)` — parse to a JavaScript value (malformed input throws
25
- `YamlError` with line/column).
25
+ `YamlError` with line/column). A multi-document stream answers with
26
+ the FIRST document.
27
+ - `loadAll(yaml, options?)` — parse a multi-document stream to an
28
+ array of every document, in stream order (`js-yaml` parity; an
29
+ empty stream answers `[]`).
30
+ - `events(yaml, options?)` — every event of the stream as an array of
31
+ plain objects, in stream order: the engine's recorder bulk drain
32
+ (one wasm crossing per stream — the fixed 44-byte event records and
33
+ the string arena are read straight from the heap, no per-event
34
+ marshalling). Document boundaries ride the same stream: the
35
+ `document-start`/`-end` events are the `loadAll` boundaries. The
36
+ normalized event vocabulary is shared with the ruby/py/rs faces and
37
+ documented as data in
38
+ [`test/fixtures/events.json`](test/fixtures/events.json).
26
39
  - `loadJSON(yaml)` — the engine's canonical JSON string.
27
40
  - `dump(json)` — JSON text (or any JSON-serializable value) to
28
41
  canonical YAML; JSON is a subset of YAML 1.2 flow, so the one parse
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 _yeptris_wasm_dump=Module["_yeptris_wasm_dump"]=(a0,a1)=>(_yeptris_wasm_dump=Module["_yeptris_wasm_dump"]=wasmExports["j"])(a0,a1);var _yeptris_wasm_last_error=Module["_yeptris_wasm_last_error"]=()=>(_yeptris_wasm_last_error=Module["_yeptris_wasm_last_error"]=wasmExports["k"])();var _yeptris_wasm_last_error_line=Module["_yeptris_wasm_last_error_line"]=()=>(_yeptris_wasm_last_error_line=Module["_yeptris_wasm_last_error_line"]=wasmExports["l"])();var _yeptris_wasm_last_error_column=Module["_yeptris_wasm_last_error_column"]=()=>(_yeptris_wasm_last_error_column=Module["_yeptris_wasm_last_error_column"]=wasmExports["m"])();var _yeptris_wasm_out=Module["_yeptris_wasm_out"]=()=>(_yeptris_wasm_out=Module["_yeptris_wasm_out"]=wasmExports["n"])();var _yeptris_wasm_out_len=Module["_yeptris_wasm_out_len"]=()=>(_yeptris_wasm_out_len=Module["_yeptris_wasm_out_len"]=wasmExports["o"])();var _yeptris_wasm_out_free=Module["_yeptris_wasm_out_free"]=()=>(_yeptris_wasm_out_free=Module["_yeptris_wasm_out_free"]=wasmExports["p"])();var _yeptris_wasm_free=Module["_yeptris_wasm_free"]=a0=>(_yeptris_wasm_free=Module["_yeptris_wasm_free"]=wasmExports["q"])(a0);var _yeptris_wasm_version=Module["_yeptris_wasm_version"]=()=>(_yeptris_wasm_version=Module["_yeptris_wasm_version"]=wasmExports["r"])();var _malloc=Module["_malloc"]=a0=>(_malloc=Module["_malloc"]=wasmExports["t"])(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();
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();
9
9
 
10
10
 
11
11
  return moduleArg.ready
package/dist/yeptris.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yeptris",
3
- "version": "0.6.56",
3
+ "version": "0.6.58",
4
4
  "description": "YAML for JavaScript at libyeptris speed (WebAssembly, no fallback)",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/index.d.ts CHANGED
@@ -6,12 +6,69 @@ export declare class YamlError extends Error {
6
6
 
7
7
  /** Parse YAML text and return the document as a JavaScript value
8
8
  * (the engine's canonical JSON, JSON.parse'd). Throws YamlError with
9
- * line/column on malformed input. */
9
+ * line/column on malformed input. A multi-document stream answers
10
+ * with the FIRST document; every document comes from loadAll. */
10
11
  export declare function load(yaml: string): Promise<unknown>;
11
12
 
13
+ /** Parse a multi-document YAML stream and return EVERY document as a
14
+ * JavaScript value, in stream order. An empty or comment-only stream
15
+ * answers []. options is reserved (no options today). Throws
16
+ * YamlError with line/column on malformed input. */
17
+ export declare function loadAll(
18
+ yaml: string,
19
+ options?: Record<string, unknown>,
20
+ ): Promise<unknown[]>;
21
+
12
22
  /** Parse YAML text and return the engine's canonical JSON string. */
13
23
  export declare function loadJSON(yaml: string): Promise<string>;
14
24
 
25
+ /** One normalized parse event (the recorder's bulk drain). Absent
26
+ * properties are omitted, never null. */
27
+ export interface YamlEvent {
28
+ /** stream-start | stream-end | document-start | document-end |
29
+ * sequence-start | sequence-end | mapping-start | mapping-end |
30
+ * scalar | alias */
31
+ type: string;
32
+ /** 1-based start mark (0 = the event carries no position, the empty
33
+ * document's null scalar) */
34
+ line: number;
35
+ column: number;
36
+ /** libyaml end_mark semantics: 1-based, column one past the end */
37
+ endLine: number;
38
+ endColumn: number;
39
+ /** scalar content; the alias NAME for type "alias" */
40
+ value?: string;
41
+ /** the node's &anchor, present when written */
42
+ anchor?: string;
43
+ /** the node's tag: the resolved core URI (!!str) or the local form
44
+ * (!custom), present when written */
45
+ tag?: string;
46
+ /** scalars: plain | single | double | literal | folded (absent when
47
+ * the parser recorded no style — the empty document's null scalar) */
48
+ style?: string;
49
+ /** scalars: the resolved kind (str|int|float|bool|null|timestamp|
50
+ * seq|map|binary|merge|value|custom) — the typing SSOT, so hosts
51
+ * never re-scan */
52
+ tagId?: string;
53
+ /** scalars: plain style (the resolver's implicit-typing trigger) */
54
+ implicit?: boolean;
55
+ /** collection starts: flow context */
56
+ flow?: boolean;
57
+ /** document start/end: a --- / ... marker was seen */
58
+ explicit?: boolean;
59
+ }
60
+
61
+ /** Parse YAML text and return EVERY event of the stream, in stream
62
+ * order (the recorder's bulk drain: one wasm crossing per stream, no
63
+ * per-event marshalling). Document boundaries ride the same stream —
64
+ * the document-start/-end events are the loadAll boundaries. options
65
+ * is accepted for call-site symmetry and reserved. Throws YamlError
66
+ * on malformed input. */
67
+ export declare function events(
68
+ yaml: string,
69
+ options?: Record<string, unknown>,
70
+ ): Promise<YamlEvent[]>;
71
+
15
72
  /** Convert JSON text (or any JSON-serializable value) to the engine's
16
73
  * canonical, byte-stable YAML. */
17
74
  export declare function dump(json: string | unknown): Promise<string>;
package/src/index.js CHANGED
@@ -60,7 +60,14 @@ async function mod() {
60
60
  // parse at all).
61
61
  for (const fn of [
62
62
  "_yeptris_wasm_load",
63
+ "_yeptris_wasm_load_all",
63
64
  "_yeptris_wasm_dump",
65
+ "_yeptris_wasm_events",
66
+ "_yeptris_wasm_event_records",
67
+ "_yeptris_wasm_event_count",
68
+ "_yeptris_wasm_event_arena",
69
+ "_yeptris_wasm_event_arena_len",
70
+ "_yeptris_wasm_events_free",
64
71
  "_yeptris_wasm_out",
65
72
  "_yeptris_wasm_out_len",
66
73
  "_yeptris_wasm_out_free",
@@ -81,18 +88,192 @@ async function mod() {
81
88
 
82
89
  /** Parse YAML text and return the document as a JavaScript value
83
90
  * (the engine's canonical JSON, JSON.parse'd). Throws YamlError with
84
- * line/column on malformed input. */
91
+ * line/column on malformed input. A multi-document stream answers
92
+ * with the FIRST document (the engine's json contract); every
93
+ * document of a stream comes from loadAll. */
85
94
  export async function load(yaml) {
86
95
  const m = await mod();
87
96
  return JSON.parse(run(m, m._yeptris_wasm_load, yaml));
88
97
  }
89
98
 
99
+ /** Parse a multi-document YAML stream and return EVERY document as a
100
+ * JavaScript value, in stream order (js-yaml's loadAll shape). An
101
+ * empty or comment-only stream answers []; an empty document
102
+ * ("---\n---") answers null at its position. options is accepted for
103
+ * call-site symmetry and reserved (load takes none today). Throws
104
+ * YamlError with line/column on malformed input. */
105
+ export async function loadAll(yaml, options) {
106
+ const m = await mod();
107
+ return JSON.parse(run(m, m._yeptris_wasm_load_all, yaml));
108
+ }
109
+
90
110
  /** Parse YAML text and return the engine's canonical JSON string. */
91
111
  export async function loadJSON(yaml) {
92
112
  const m = await mod();
93
113
  return run(m, m._yeptris_wasm_load, yaml);
94
114
  }
95
115
 
116
+ // ---- the event face (the recorder's bulk drain) -------------------------
117
+ //
118
+ // The engine ships three event models over the one parse: push (a
119
+ // callback per event), pull (a StAX cursor) and the recorder (fixed
120
+ // 44-byte records plus one copied string arena). Across the wasm
121
+ // boundary the recorder wins: the whole stream drains as TWO spans
122
+ // read straight from the heap — O(1) crossings, no per-event callback
123
+ // marshalling. The record layout is ABI-pinned (events.h, 44B) and
124
+ // this decoder is the JS mirror of the ctypes/FFI readers the
125
+ // ruby/py/rs faces use over the same bytes.
126
+
127
+ // YeptrisEventType (events.h, ABI-pinned order).
128
+ const EV_KINDS = {
129
+ 1: "stream-start",
130
+ 2: "stream-end",
131
+ 3: "document-start",
132
+ 4: "document-end",
133
+ 5: "sequence-start",
134
+ 6: "sequence-end",
135
+ 7: "mapping-start",
136
+ 8: "mapping-end",
137
+ 9: "scalar",
138
+ 10: "alias",
139
+ };
140
+
141
+ // YeptrisScalarStyle (dom.h). 0 = ANY ("no recorded style" — the empty
142
+ // document's null scalar) and spells as an ABSENT style, not a lie.
143
+ const EV_STYLES = {
144
+ 1: "plain",
145
+ 2: "single",
146
+ 3: "double",
147
+ 4: "literal",
148
+ 5: "folded",
149
+ };
150
+
151
+ // YeptrisTagId (resolve.h) — the resolver's typing verdict, spelled as
152
+ // the kind name (the same vocabulary ruby/py/rs consume).
153
+ const EV_TAG_IDS = {
154
+ 0: "str",
155
+ 1: "int",
156
+ 2: "float",
157
+ 3: "bool",
158
+ 4: "null",
159
+ 5: "timestamp",
160
+ 6: "seq",
161
+ 7: "map",
162
+ 8: "binary",
163
+ 9: "merge",
164
+ 10: "value",
165
+ 11: "custom",
166
+ };
167
+
168
+ // YEPTRIS_EF_* flag bits (events.h).
169
+ const EF_FLOW = 1; // collection in flow style
170
+ const EF_EXPLICIT = 2; // document with a --- / ... marker
171
+ const EF_IMPLICIT = 4; // plain (unquoted, un-block) scalar style
172
+
173
+ const EV_RECORD_SIZE = 44; // sizeof(YeptrisEventRecord), ABI-pinned
174
+
175
+ let utf8Decoder = null;
176
+
177
+ function decodeArena(u8, off, len) {
178
+ if (utf8Decoder === null) {
179
+ utf8Decoder = new TextDecoder("utf-8");
180
+ }
181
+ return utf8Decoder.decode(u8.subarray(off, off + len));
182
+ }
183
+
184
+ /** Parse YAML text and return EVERY event of the stream as an array
185
+ * of plain objects, in stream order (leptris/yeptris#886). One event
186
+ * is:
187
+ *
188
+ * { type: "stream-start" | "stream-end" | "document-start" |
189
+ * "document-end" | "sequence-start" | "sequence-end" |
190
+ * "mapping-start" | "mapping-end" | "scalar" | "alias",
191
+ * line, column, // 1-based start mark (0 = no position)
192
+ * endLine, endColumn, // libyaml end_mark: col one past the end
193
+ * value?, // scalar content; the alias NAME for alias
194
+ * anchor?, tag?, // node properties, present when written
195
+ * style?, // scalars: plain|single|double|literal|folded
196
+ * tagId?, // scalars: the resolved kind (str|int|...)
197
+ * implicit?, // scalars: plain style (the typing trigger)
198
+ * flow?, // collection starts: flow context
199
+ * explicit? } // document start/end: --- / ... marker seen
200
+ *
201
+ * Absent properties are omitted, never null. The faces of
202
+ * ruby/py/rs consume the same normalized vocabulary (see
203
+ * test/fixtures/events.json, whose header documents it as data).
204
+ * options is accepted for call-site symmetry and reserved. Throws
205
+ * YamlError on malformed input (position from the recorder's status;
206
+ * its message is the generic "parse failed" — the recorder carries
207
+ * status + position, not the error text). */
208
+ export async function events(yaml, options) {
209
+ const m = await mod();
210
+ const [ptr, len] = cstr(m, yaml);
211
+ try {
212
+ const st = m._yeptris_wasm_events(ptr, len);
213
+ if (st !== 0) {
214
+ throw new YamlError(
215
+ m.UTF8ToString(m._yeptris_wasm_last_error()),
216
+ m._yeptris_wasm_last_error_line(),
217
+ m._yeptris_wasm_last_error_column());
218
+ }
219
+ const n = m._yeptris_wasm_event_count();
220
+ const recs = m._yeptris_wasm_event_records();
221
+ const arena = m._yeptris_wasm_event_arena();
222
+ // Heap views fetched AFTER the call: the feed may have grown the
223
+ // memory, and the exported views are re-bound on growth.
224
+ const u8 = m.HEAPU8;
225
+ const u32 = m.HEAPU32;
226
+ const out = new Array(n);
227
+ for (let i = 0; i < n; i++) {
228
+ const base = recs + i * EV_RECORD_SIZE;
229
+ const p = base >> 2;
230
+ const type = u8[base];
231
+ const flags = u8[base + 2];
232
+ const ev = {
233
+ type: EV_KINDS[type],
234
+ line: u32[p + 1],
235
+ column: u32[p + 2],
236
+ endLine: u32[p + 3],
237
+ endColumn: u32[p + 4],
238
+ };
239
+ const valueLen = u32[p + 6];
240
+ if (valueLen !== 0) {
241
+ ev.value = decodeArena(u8, arena + u32[p + 5], valueLen);
242
+ }
243
+ const anchorLen = u32[p + 8];
244
+ if (anchorLen !== 0) {
245
+ ev.anchor = decodeArena(u8, arena + u32[p + 7], anchorLen);
246
+ }
247
+ const tagLen = u32[p + 10];
248
+ if (tagLen !== 0) {
249
+ ev.tag = decodeArena(u8, arena + u32[p + 9], tagLen);
250
+ }
251
+ if (type === 9) { // scalar
252
+ const style = u8[base + 1];
253
+ if (style !== 0) {
254
+ ev.style = EV_STYLES[style];
255
+ }
256
+ if ((flags & EF_IMPLICIT) !== 0) {
257
+ ev.implicit = true;
258
+ }
259
+ ev.tagId = EV_TAG_IDS[u8[base + 3]];
260
+ }
261
+ if ((flags & EF_FLOW) !== 0) {
262
+ ev.flow = true;
263
+ }
264
+ if ((type === 3 || type === 4) && (flags & EF_EXPLICIT) !== 0) {
265
+ ev.explicit = true;
266
+ }
267
+ out[i] = ev;
268
+ }
269
+ return out;
270
+ } finally {
271
+ // the drain is decoded: release the recorder (nothing retained
272
+ // past this call — the answer left the heap as JS objects)
273
+ m._yeptris_wasm_events_free();
274
+ }
275
+ }
276
+
96
277
  /** Convert JSON text (or any JSON-serializable value) to the engine's
97
278
  * canonical, byte-stable YAML. JSON is a subset of YAML 1.2 flow, so
98
279
  * the one parse engine takes it. */
@@ -5,6 +5,7 @@
5
5
  * never holds a heap pointer past the call — the C buffer-lifetime
6
6
  * contract stays internal. */
7
7
  #include <emscripten/emscripten.h>
8
+ #include <stdint.h>
8
9
  #include <stdio.h>
9
10
  #include <stdlib.h>
10
11
  #include <string.h>
@@ -12,6 +13,7 @@
12
13
  #include "yeptris/dom.h"
13
14
  #include "yeptris/emit.h"
14
15
  #include "yeptris/error.h"
16
+ #include "yeptris/events.h"
15
17
  #include "yeptris/json.h"
16
18
  #include "yeptris/parse.h"
17
19
  #include "yeptris/version.h"
@@ -32,7 +34,244 @@ static void capture_error(void) {
32
34
  last_error_column = (int)col;
33
35
  }
34
36
 
35
- /* YAML in -> canonical JSON out (yeptris_serialize_json). */
37
+ static void capture_plain(const char *msg) {
38
+ snprintf(last_error, sizeof last_error, "%s", msg);
39
+ last_error_line = 0;
40
+ last_error_column = 0;
41
+ }
42
+
43
+ static void publish_out(char *out, size_t out_len) {
44
+ g_out = out;
45
+ g_out_len = out_len;
46
+ }
47
+
48
+ /* ---- multi-document streams -------------------------------------------
49
+ *
50
+ * yeptris_parse returns the WHOLE stream as one document set (the DOM
51
+ * forest: yeptris_document_count / yeptris_document_root). The JSON
52
+ * emitter answers for exactly one document (yep_emit_run's dcount==1
53
+ * guard), so per-document JSON is produced by re-typing the forest
54
+ * into a fresh document through the public build API:
55
+ *
56
+ * - scalars copy value + style; plain re-resolves through the same
57
+ * schema resolver exactly like parse, quoted/block forces string
58
+ * — the JSON typing is identical by construction;
59
+ * - explicit tags ride BUILD_TAG;
60
+ * - aliases project to null and anchors drop — which IS the JSON
61
+ * projection law (emit_alias_ex writes null, JSON spells no
62
+ * anchors).
63
+ *
64
+ * The one extra nesting level the wrapper sequence adds is why the
65
+ * recursion cap is the parser's cap + 1. */
66
+
67
+ #define YW_MAX_DEPTH 1001 /* parser default max_depth (1000) + wrapper */
68
+
69
+ typedef struct {
70
+ YeptrisBuildEntry *entries;
71
+ size_t n, cap;
72
+ char *blob;
73
+ size_t blen, bcap;
74
+ int failed; /* 0 ok, else the YeptrisStatus */
75
+ int depth;
76
+ } yw_rec;
77
+
78
+ static int yw_push_entry(yw_rec *r, uint8_t op, uint8_t style, size_t off, uint32_t len) {
79
+ if (r->n == r->cap) {
80
+ size_t ncap = r->cap ? r->cap * 2 : 64;
81
+ YeptrisBuildEntry *ne = (YeptrisBuildEntry *)realloc(r->entries, ncap * sizeof *ne);
82
+ if (ne == NULL) {
83
+ r->failed = YEPTRIS_ERROR_MEMORY;
84
+ return -1;
85
+ }
86
+ r->entries = ne;
87
+ r->cap = ncap;
88
+ }
89
+ YeptrisBuildEntry *e = &r->entries[r->n++];
90
+ e->op = op;
91
+ e->style = style;
92
+ e->reserved = 0;
93
+ e->off = (uint32_t)off;
94
+ e->len = len;
95
+ return 0;
96
+ }
97
+
98
+ static long yw_push_blob(yw_rec *r, const char *p, size_t len) {
99
+ if (r->blen + len > UINT32_MAX) { /* blob offsets are 32-bit */
100
+ r->failed = YEPTRIS_ERROR_MEMORY;
101
+ return -1;
102
+ }
103
+ if (r->blen + len > r->bcap) {
104
+ size_t ncap = r->bcap ? r->bcap : 4096;
105
+ while (ncap < r->blen + len) {
106
+ ncap *= 2;
107
+ }
108
+ char *nb = (char *)realloc(r->blob, ncap);
109
+ if (nb == NULL) {
110
+ r->failed = YEPTRIS_ERROR_MEMORY;
111
+ return -1;
112
+ }
113
+ r->blob = nb;
114
+ r->bcap = ncap;
115
+ }
116
+ if (len > 0) {
117
+ memcpy(r->blob + r->blen, p, len);
118
+ }
119
+ long off = (long)r->blen;
120
+ r->blen += len;
121
+ return off;
122
+ }
123
+
124
+ static int yw_tag_entry(yw_rec *r, YeptrisNode node) {
125
+ size_t tl = 0;
126
+ const char *t = yeptris_node_tag(node, &tl);
127
+ if (t == NULL || tl == 0) {
128
+ return 0;
129
+ }
130
+ long off = yw_push_blob(r, t, tl);
131
+ if (off < 0) {
132
+ return -1;
133
+ }
134
+ return yw_push_entry(r, YEPTRIS_BUILD_TAG, 0, (size_t)off, (uint32_t)tl);
135
+ }
136
+
137
+ /* Records one subtree into the build entry/blob buffers. */
138
+ static int yw_flatten(yw_rec *r, YeptrisNode node) {
139
+ if (r->failed != 0) {
140
+ return -1;
141
+ }
142
+ if (++r->depth > YW_MAX_DEPTH) {
143
+ r->failed = YEPTRIS_ERROR_DEPTH;
144
+ return -1;
145
+ }
146
+ switch (yeptris_node_kind(node)) {
147
+ case YEPTRIS_NODE_ALIAS: {
148
+ /* the JSON projection law: aliases dereference to null */
149
+ long off = yw_push_blob(r, "null", 4);
150
+ if (off < 0 ||
151
+ yw_push_entry(r, YEPTRIS_BUILD_SCALAR, YEPTRIS_STYLE_PLAIN, (size_t)off, 4) != 0) {
152
+ return -1;
153
+ }
154
+ break;
155
+ }
156
+ case YEPTRIS_NODE_SCALAR: {
157
+ size_t vl = 0;
158
+ const char *v = yeptris_node_value(node, &vl);
159
+ /* a parsed empty document root carries STYLE_ANY (no recorded
160
+ * style); the build API only types PLAIN scalars, and ANY
161
+ * means "no recorded style" — i.e. plain — so normalize */
162
+ uint8_t sty = (uint8_t)yeptris_node_style(node);
163
+ if (sty == YEPTRIS_STYLE_ANY) {
164
+ sty = YEPTRIS_STYLE_PLAIN;
165
+ }
166
+ long off = yw_push_blob(r, v ? v : "", vl);
167
+ if (off < 0 || yw_push_entry(r, YEPTRIS_BUILD_SCALAR, sty, (size_t)off, (uint32_t)vl) != 0) {
168
+ return -1;
169
+ }
170
+ if (yw_tag_entry(r, node) != 0) {
171
+ return -1;
172
+ }
173
+ break;
174
+ }
175
+ default: { /* sequence or mapping */
176
+ uint8_t op = yeptris_node_kind(node) == YEPTRIS_NODE_MAPPING ? YEPTRIS_BUILD_MAP
177
+ : YEPTRIS_BUILD_SEQ;
178
+ if (yw_push_entry(r, op, 0, 0, 0) != 0 || yw_tag_entry(r, node) != 0) {
179
+ return -1;
180
+ }
181
+ size_t n = yeptris_node_children(node, NULL, 0);
182
+ if (n > 0) {
183
+ YeptrisNode *kids = (YeptrisNode *)malloc(n * sizeof *kids);
184
+ if (kids == NULL) {
185
+ r->failed = YEPTRIS_ERROR_MEMORY;
186
+ return -1;
187
+ }
188
+ size_t got = yeptris_node_children(node, kids, n);
189
+ for (size_t i = 0; i < got; i++) {
190
+ if (yw_flatten(r, kids[i]) != 0) {
191
+ free(kids);
192
+ return -1;
193
+ }
194
+ }
195
+ free(kids);
196
+ }
197
+ if (yw_push_entry(r, YEPTRIS_BUILD_END, 0, 0, 0) != 0) {
198
+ return -1;
199
+ }
200
+ break;
201
+ }
202
+ }
203
+ r->depth--;
204
+ return 0;
205
+ }
206
+
207
+ static void yw_rec_free(yw_rec *r) {
208
+ free(r->entries);
209
+ free(r->blob);
210
+ r->entries = NULL;
211
+ r->blob = NULL;
212
+ }
213
+
214
+ /* Builds a fresh document from the recorder and serializes it as JSON
215
+ * (engine-owned output buffer). r is freed either way. */
216
+ static char *yw_serialize_rebuilt(yw_rec *r, size_t *out_len) {
217
+ if (r->failed != 0) {
218
+ yw_rec_free(r);
219
+ return NULL;
220
+ }
221
+ YeptrisDocument b = yeptris_document_new();
222
+ if (b == NULL) {
223
+ yw_rec_free(r);
224
+ return NULL;
225
+ }
226
+ YeptrisStatus bst = yeptris_document_build(b, r->entries, r->n, r->blob, r->blen);
227
+ yw_rec_free(r);
228
+ if (bst != YEPTRIS_OK) {
229
+ return NULL;
230
+ }
231
+ char *out = yeptris_serialize_json(b, out_len);
232
+ yeptris_document_free(b);
233
+ return out;
234
+ }
235
+
236
+ /* Builds the stream answer: a JSON array of every document. count==0
237
+ * builds the empty wrapper ("[]"); every other stream wraps its
238
+ * documents in one sequence, which serialize_json spells as the
239
+ * array. */
240
+ static int yeptris_wasm_load_all_answer(YeptrisDocument doc, size_t count) {
241
+ yw_rec r;
242
+ memset(&r, 0, sizeof r);
243
+ if (yw_push_entry(&r, YEPTRIS_BUILD_SEQ, 0, 0, 0) != 0) {
244
+ capture_plain("document rebuild failed");
245
+ return YEPTRIS_ERROR_MEMORY;
246
+ }
247
+ for (size_t i = 0; i < count; i++) {
248
+ YeptrisNode root = yeptris_document_root(doc, i);
249
+ if (root == NULL || yw_flatten(&r, root) != 0) {
250
+ capture_plain(r.failed == YEPTRIS_ERROR_DEPTH ? "document nesting exceeds the rebuild depth cap"
251
+ : "document rebuild failed");
252
+ yw_rec_free(&r);
253
+ return r.failed != 0 ? r.failed : YEPTRIS_ERROR_MEMORY;
254
+ }
255
+ }
256
+ if (yw_push_entry(&r, YEPTRIS_BUILD_END, 0, 0, 0) != 0) {
257
+ capture_plain("document rebuild failed");
258
+ return YEPTRIS_ERROR_MEMORY;
259
+ }
260
+ size_t out_len = 0;
261
+ char *out = yw_serialize_rebuilt(&r, &out_len);
262
+ if (out == NULL) {
263
+ capture_plain("serialization failed");
264
+ return YEPTRIS_ERROR_MEMORY;
265
+ }
266
+ publish_out(out, out_len);
267
+ return YEPTRIS_OK;
268
+ }
269
+
270
+ /* YAML in -> canonical JSON out (yeptris_serialize_json). A
271
+ * multi-document stream answers with the FIRST document — the json.h
272
+ * contract; the emitter only writes dcount==1 forests directly, so
273
+ * bigger streams re-type document 0 through the build API. An empty
274
+ * stream (no documents) keeps the engine's answer: an empty output. */
36
275
  EMSCRIPTEN_KEEPALIVE
37
276
  int yeptris_wasm_load(const char *data, size_t len) {
38
277
  YeptrisStatus st = YEPTRIS_OK;
@@ -42,19 +281,59 @@ int yeptris_wasm_load(const char *data, size_t len) {
42
281
  return (int)st;
43
282
  }
44
283
  size_t out_len = 0;
45
- char *out = yeptris_serialize_json(doc, &out_len);
46
- yeptris_document_free(doc);
284
+ char *out = NULL;
285
+ if (yeptris_document_count(doc) <= 1) {
286
+ out = yeptris_serialize_json(doc, &out_len);
287
+ yeptris_document_free(doc);
288
+ } else {
289
+ yw_rec r;
290
+ memset(&r, 0, sizeof r);
291
+ int rc = 0;
292
+ YeptrisNode root = yeptris_document_root(doc, 0);
293
+ if (root == NULL || yw_flatten(&r, root) != 0) {
294
+ rc = r.failed != 0 ? r.failed : YEPTRIS_ERROR_MEMORY;
295
+ } else {
296
+ out = yw_serialize_rebuilt(&r, &out_len);
297
+ rc = out == NULL ? YEPTRIS_ERROR_MEMORY : YEPTRIS_OK;
298
+ }
299
+ yeptris_document_free(doc);
300
+ if (rc != YEPTRIS_OK) {
301
+ capture_plain(rc == YEPTRIS_ERROR_DEPTH
302
+ ? "document nesting exceeds the rebuild depth cap"
303
+ : "document rebuild failed");
304
+ return rc;
305
+ }
306
+ }
47
307
  if (out == NULL) {
48
308
  snprintf(last_error, sizeof last_error, "serialization failed");
49
309
  last_error_line = 0;
50
310
  last_error_column = 0;
51
311
  return YEPTRIS_ERROR_MEMORY;
52
312
  }
53
- g_out = out;
54
- g_out_len = out_len;
313
+ publish_out(out, out_len);
55
314
  return YEPTRIS_OK;
56
315
  }
57
316
 
317
+ /* YAML in -> a JSON array of every document in the stream (the
318
+ * loadAll answer). An empty stream (and a failed-to-parse-with-OK
319
+ * empty input, the engine's "zero documents" shape) answers "[]";
320
+ * parse errors surface exactly like load's. */
321
+ EMSCRIPTEN_KEEPALIVE
322
+ int yeptris_wasm_load_all(const char *data, size_t len) {
323
+ YeptrisStatus st = YEPTRIS_OK;
324
+ YeptrisDocument doc = yeptris_parse(data, len, &st);
325
+ if (doc == NULL) {
326
+ if (st == YEPTRIS_OK) { /* empty/comment-only stream: no docs */
327
+ return yeptris_wasm_load_all_answer(NULL, 0);
328
+ }
329
+ capture_error();
330
+ return (int)st;
331
+ }
332
+ int rc = yeptris_wasm_load_all_answer(doc, yeptris_document_count(doc));
333
+ yeptris_document_free(doc);
334
+ return rc;
335
+ }
336
+
58
337
  /* JSON in -> canonical YAML out (JSON is a subset of YAML 1.2 flow, so
59
338
  * the one parse engine takes it; the emitter's canonical form is
60
339
  * byte-stable across round trips). */
@@ -107,3 +386,82 @@ void yeptris_wasm_free(void *p) { yeptris_free(p); }
107
386
 
108
387
  EMSCRIPTEN_KEEPALIVE
109
388
  const char *yeptris_wasm_version(void) { return yeptris_version(); }
389
+
390
+ /* ---- events (the recorder bulk drain) ----------------------------------
391
+ *
392
+ * The engine ships three event models over the one parse: push (a
393
+ * callback per event), pull (a StAX cursor) and the recorder (fixed
394
+ * 44-byte records plus one copied string arena). Across the wasm
395
+ * boundary the RECORDER is the fit: the whole stream answers as two
396
+ * spans — the record array and the arena — which the host reads
397
+ * straight from the heap in one pass. That is O(1) crossings per
398
+ * stream; push would cross once per event and pull would need a
399
+ * cursor protocol whose strings die at the next call. This mirrors
400
+ * exactly what the ctypes/FFI readers of the ruby/py/rs faces do with
401
+ * the same record layout.
402
+ *
403
+ * Lifecycle is the load pattern: one C call (feed, final), the drain
404
+ * retained in globals until the host has decoded it, then an explicit
405
+ * free. */
406
+ static YeptrisRecorder g_ev_rec;
407
+ static size_t g_ev_count;
408
+ static size_t g_ev_arena_len;
409
+
410
+ EMSCRIPTEN_KEEPALIVE
411
+ int yeptris_wasm_events(const char *data, size_t len) {
412
+ if (g_ev_rec != NULL) { /* defensive: the previous drain was not freed */
413
+ yeptris_recorder_free(g_ev_rec);
414
+ g_ev_rec = NULL;
415
+ }
416
+ g_ev_count = 0;
417
+ g_ev_arena_len = 0;
418
+ YeptrisRecorder rec = yeptris_recorder_new();
419
+ if (rec == NULL) {
420
+ capture_plain("recorder allocation failed");
421
+ return YEPTRIS_ERROR_MEMORY;
422
+ }
423
+ /* One chunk, final: the recorder v1 buffers to the stream end, so
424
+ * a whole-input feed IS the drain (mid-stream feeds arrive with the
425
+ * engine's resumable stepping and keep this shape). */
426
+ YeptrisStatus st = yeptris_recorder_feed(rec, data, len, 1);
427
+ if (st != YEPTRIS_OK) {
428
+ uint32_t line = 0;
429
+ uint32_t col = 0;
430
+ yeptris_recorder_status(rec, &line, &col);
431
+ /* the recorder carries status + 1-based position, no message
432
+ * string (its errors are parse errors by construction) */
433
+ snprintf(last_error, sizeof last_error, "parse failed");
434
+ last_error_line = (int)line;
435
+ last_error_column = (int)col;
436
+ yeptris_recorder_free(rec);
437
+ return (int)st;
438
+ }
439
+ g_ev_rec = rec;
440
+ yeptris_recorder_records(rec, &g_ev_count);
441
+ yeptris_recorder_arena(rec, &g_ev_arena_len);
442
+ return YEPTRIS_OK;
443
+ }
444
+
445
+ EMSCRIPTEN_KEEPALIVE
446
+ const YeptrisEventRecord *yeptris_wasm_event_records(void) {
447
+ return g_ev_rec != NULL ? yeptris_recorder_records(g_ev_rec, NULL) : NULL;
448
+ }
449
+
450
+ EMSCRIPTEN_KEEPALIVE
451
+ int yeptris_wasm_event_count(void) { return (int)g_ev_count; }
452
+
453
+ EMSCRIPTEN_KEEPALIVE
454
+ const char *yeptris_wasm_event_arena(void) {
455
+ return g_ev_rec != NULL ? yeptris_recorder_arena(g_ev_rec, NULL) : NULL;
456
+ }
457
+
458
+ EMSCRIPTEN_KEEPALIVE
459
+ int yeptris_wasm_event_arena_len(void) { return (int)g_ev_arena_len; }
460
+
461
+ EMSCRIPTEN_KEEPALIVE
462
+ void yeptris_wasm_events_free(void) {
463
+ yeptris_recorder_free(g_ev_rec);
464
+ g_ev_rec = NULL;
465
+ g_ev_count = 0;
466
+ g_ev_arena_len = 0;
467
+ }