yeptris 0.6.77 → 0.6.79
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 +7 -4
- package/dist/yeptris.mjs +1 -1
- package/dist/yeptris.wasm +0 -0
- package/package.json +1 -1
- package/src/index.d.ts +124 -0
- package/src/index.js +540 -0
- package/src/yeptris_wasm.c +248 -0
package/README.md
CHANGED
|
@@ -33,6 +33,8 @@ const yaml = await dump({ name: "yeptris", langs: ["c", "rust"] });
|
|
|
33
33
|
| `validate(input, options?)` | The WHOLE validation report: every diagnostic, in engine order (`[]` when valid). |
|
|
34
34
|
| `isValid(input, options?)` | `true` when `validate` answers no diagnostics. |
|
|
35
35
|
| `compileSchema(jsonSchema)` | A compiled `Schema` handle — parse the schema ONCE, validate many streams. |
|
|
36
|
+
| `compilePlan(spec)` | A compiled `Plan` handle (plan.h, the rs face's shape) — the query spec parses ONCE, `plan.walk(yaml)` applies it to a document in one C pass and answers typed columns: `rows`, `kind(col)` (`int`/`float`/`str`/`bool`), `ints`/`floats`/`strs` (copies; bools read through `ints` as 0/1) and `nulls` (the null/missing markers). |
|
|
37
|
+
| `parseJsonTape(json)` | A `JsonTape` (tape.h) — the columnar record stream of one strict JSON parse: one record per token, no DOM. `columns()` copies the `kinds`/`offs`/`lens` triple (spans are offsets into YOUR source string), `convert([from, to])` materializes the number records as dense `{ ints, floats }`. The pinned record vocabulary is exported as `TAPE_KINDS`. |
|
|
36
38
|
| `version()` | The libyeptris version string. |
|
|
37
39
|
| `wasmModule()` | The cached wasm module instance (diagnostics: heap/memory inspection, the engine's raw exports). |
|
|
38
40
|
| `init()` | Initializes the wasm module (idempotent) — what unlocks the `*Sync` forms. |
|
|
@@ -43,12 +45,13 @@ The wasm executes synchronously; every async form is async only
|
|
|
43
45
|
because the FIRST call may initialize the module. After one
|
|
44
46
|
`await init()` (or any async call) the same bodies run synchronously:
|
|
45
47
|
`loadSync`, `loadAllSync`, `loadJSONSync`, `dumpSync`, `eventsSync`,
|
|
46
|
-
`validateSync`, `isValidSync`, `compileSchemaSync`, `
|
|
48
|
+
`validateSync`, `isValidSync`, `compileSchemaSync`, `compilePlanSync`,
|
|
49
|
+
`parseJsonTapeSync`, `versionSync` —
|
|
47
50
|
same arguments, same answers, no `Promise`. Each `*Sync` form refuses
|
|
48
51
|
to run uninitialized (the lazy import is an async door) and names the
|
|
49
|
-
way out in the error; the `Schema`
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
way out in the error; the `Schema`/`Plan`/`JsonTape` handles' own
|
|
53
|
+
methods are synchronous by construction — a handle only exists once
|
|
54
|
+
the module is initialized.
|
|
52
55
|
|
|
53
56
|
```js
|
|
54
57
|
await init(); // once, up front
|
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_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_open_ex=Module["_yeptris_wasm_each_open_ex"]=(a0,a1,a2,a3)=>(_yeptris_wasm_each_open_ex=Module["_yeptris_wasm_each_open_ex"]=wasmExports["C"])(a0,a1,a2,a3);var _yeptris_wasm_each_next=Module["_yeptris_wasm_each_next"]=()=>(_yeptris_wasm_each_next=Module["_yeptris_wasm_each_next"]=wasmExports["D"])();var _yeptris_wasm_each_frame=Module["_yeptris_wasm_each_frame"]=()=>(_yeptris_wasm_each_frame=Module["_yeptris_wasm_each_frame"]=wasmExports["E"])();var _yeptris_wasm_each_index=Module["_yeptris_wasm_each_index"]=()=>(_yeptris_wasm_each_index=Module["_yeptris_wasm_each_index"]=wasmExports["F"])();var _yeptris_wasm_each_close=Module["_yeptris_wasm_each_close"]=()=>(_yeptris_wasm_each_close=Module["_yeptris_wasm_each_close"]=wasmExports["G"])();var _yeptris_wasm_validate=Module["_yeptris_wasm_validate"]=(a0,a1,a2)=>(_yeptris_wasm_validate=Module["_yeptris_wasm_validate"]=wasmExports["H"])(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["I"])(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["J"])(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["K"])(a0,a1,a2);var _yeptris_wasm_schema_free=Module["_yeptris_wasm_schema_free"]=a0=>(_yeptris_wasm_schema_free=Module["_yeptris_wasm_schema_free"]=wasmExports["L"])(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_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_open_ex=Module["_yeptris_wasm_each_open_ex"]=(a0,a1,a2,a3)=>(_yeptris_wasm_each_open_ex=Module["_yeptris_wasm_each_open_ex"]=wasmExports["C"])(a0,a1,a2,a3);var _yeptris_wasm_each_next=Module["_yeptris_wasm_each_next"]=()=>(_yeptris_wasm_each_next=Module["_yeptris_wasm_each_next"]=wasmExports["D"])();var _yeptris_wasm_each_frame=Module["_yeptris_wasm_each_frame"]=()=>(_yeptris_wasm_each_frame=Module["_yeptris_wasm_each_frame"]=wasmExports["E"])();var _yeptris_wasm_each_index=Module["_yeptris_wasm_each_index"]=()=>(_yeptris_wasm_each_index=Module["_yeptris_wasm_each_index"]=wasmExports["F"])();var _yeptris_wasm_each_close=Module["_yeptris_wasm_each_close"]=()=>(_yeptris_wasm_each_close=Module["_yeptris_wasm_each_close"]=wasmExports["G"])();var _yeptris_wasm_validate=Module["_yeptris_wasm_validate"]=(a0,a1,a2)=>(_yeptris_wasm_validate=Module["_yeptris_wasm_validate"]=wasmExports["H"])(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["I"])(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["J"])(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["K"])(a0,a1,a2);var _yeptris_wasm_schema_free=Module["_yeptris_wasm_schema_free"]=a0=>(_yeptris_wasm_schema_free=Module["_yeptris_wasm_schema_free"]=wasmExports["L"])(a0);var _yeptris_wasm_plan_compile=Module["_yeptris_wasm_plan_compile"]=(a0,a1)=>(_yeptris_wasm_plan_compile=Module["_yeptris_wasm_plan_compile"]=wasmExports["M"])(a0,a1);var _yeptris_wasm_plan_column_count=Module["_yeptris_wasm_plan_column_count"]=a0=>(_yeptris_wasm_plan_column_count=Module["_yeptris_wasm_plan_column_count"]=wasmExports["N"])(a0);var _yeptris_wasm_plan_free=Module["_yeptris_wasm_plan_free"]=a0=>(_yeptris_wasm_plan_free=Module["_yeptris_wasm_plan_free"]=wasmExports["O"])(a0);var _yeptris_wasm_plan_walk=Module["_yeptris_wasm_plan_walk"]=(a0,a1,a2)=>(_yeptris_wasm_plan_walk=Module["_yeptris_wasm_plan_walk"]=wasmExports["P"])(a0,a1,a2);var _yeptris_wasm_plan_seq=Module["_yeptris_wasm_plan_seq"]=()=>(_yeptris_wasm_plan_seq=Module["_yeptris_wasm_plan_seq"]=wasmExports["Q"])();var _yeptris_wasm_plan_rows=Module["_yeptris_wasm_plan_rows"]=()=>(_yeptris_wasm_plan_rows=Module["_yeptris_wasm_plan_rows"]=wasmExports["R"])();var _yeptris_wasm_plan_kind=Module["_yeptris_wasm_plan_kind"]=a0=>(_yeptris_wasm_plan_kind=Module["_yeptris_wasm_plan_kind"]=wasmExports["S"])(a0);var _yeptris_wasm_plan_ints=Module["_yeptris_wasm_plan_ints"]=a0=>(_yeptris_wasm_plan_ints=Module["_yeptris_wasm_plan_ints"]=wasmExports["T"])(a0);var _yeptris_wasm_plan_floats=Module["_yeptris_wasm_plan_floats"]=a0=>(_yeptris_wasm_plan_floats=Module["_yeptris_wasm_plan_floats"]=wasmExports["U"])(a0);var _yeptris_wasm_plan_strs=Module["_yeptris_wasm_plan_strs"]=a0=>(_yeptris_wasm_plan_strs=Module["_yeptris_wasm_plan_strs"]=wasmExports["V"])(a0);var _yeptris_wasm_plan_nulls=Module["_yeptris_wasm_plan_nulls"]=a0=>(_yeptris_wasm_plan_nulls=Module["_yeptris_wasm_plan_nulls"]=wasmExports["W"])(a0);var _yeptris_wasm_plan_walk_free=Module["_yeptris_wasm_plan_walk_free"]=()=>(_yeptris_wasm_plan_walk_free=Module["_yeptris_wasm_plan_walk_free"]=wasmExports["X"])();var _yeptris_wasm_tape_parse=Module["_yeptris_wasm_tape_parse"]=(a0,a1)=>(_yeptris_wasm_tape_parse=Module["_yeptris_wasm_tape_parse"]=wasmExports["Y"])(a0,a1);var _yeptris_wasm_tape_seq=Module["_yeptris_wasm_tape_seq"]=()=>(_yeptris_wasm_tape_seq=Module["_yeptris_wasm_tape_seq"]=wasmExports["Z"])();var _yeptris_wasm_tape_count=Module["_yeptris_wasm_tape_count"]=()=>(_yeptris_wasm_tape_count=Module["_yeptris_wasm_tape_count"]=wasmExports["_"])();var _yeptris_wasm_tape_columns=Module["_yeptris_wasm_tape_columns"]=()=>(_yeptris_wasm_tape_columns=Module["_yeptris_wasm_tape_columns"]=wasmExports["$"])();var _yeptris_wasm_tape_kinds=Module["_yeptris_wasm_tape_kinds"]=()=>(_yeptris_wasm_tape_kinds=Module["_yeptris_wasm_tape_kinds"]=wasmExports["aa"])();var _yeptris_wasm_tape_offs=Module["_yeptris_wasm_tape_offs"]=()=>(_yeptris_wasm_tape_offs=Module["_yeptris_wasm_tape_offs"]=wasmExports["ba"])();var _yeptris_wasm_tape_lens=Module["_yeptris_wasm_tape_lens"]=()=>(_yeptris_wasm_tape_lens=Module["_yeptris_wasm_tape_lens"]=wasmExports["ca"])();var _yeptris_wasm_tape_convert=Module["_yeptris_wasm_tape_convert"]=(a0,a1,a2,a3)=>(_yeptris_wasm_tape_convert=Module["_yeptris_wasm_tape_convert"]=wasmExports["da"])(a0,a1,a2,a3);var _yeptris_wasm_tape_free=Module["_yeptris_wasm_tape_free"]=()=>(_yeptris_wasm_tape_free=Module["_yeptris_wasm_tape_free"]=wasmExports["ea"])();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
|
@@ -91,6 +91,124 @@ export declare class Schema {
|
|
|
91
91
|
* for bytes that do not parse. */
|
|
92
92
|
export declare function compileSchema(jsonSchema: object | string): Promise<Schema>;
|
|
93
93
|
|
|
94
|
+
// ---- the plan face (plan.h; the compiled columnar walk) ----------------
|
|
95
|
+
|
|
96
|
+
/** The columnar result of one plan walk. Produced by Plan.walk(); the
|
|
97
|
+
* accessors COPY their answers out of the retained walk state — free()
|
|
98
|
+
* releases it. After free() reuse throws; a STALE result (a newer
|
|
99
|
+
* walk() replaced the retained state) throws too — never a silent
|
|
100
|
+
* wrong answer. */
|
|
101
|
+
export declare class PlanResult {
|
|
102
|
+
private constructor();
|
|
103
|
+
/** The number of rows (one per row of the rows container). */
|
|
104
|
+
get rows(): number;
|
|
105
|
+
/** The leaf kind of column `col`: "int" | "float" | "str" | "bool". */
|
|
106
|
+
kind(col: number): string;
|
|
107
|
+
/** INT column values as JS numbers. BOOL columns read through here
|
|
108
|
+
* too, as 0/1 (the engine's columnar contract). Exact within
|
|
109
|
+
* +/-2^53; the engine's int64 beyond that rounds, per JS number. */
|
|
110
|
+
ints(col: number): number[];
|
|
111
|
+
/** FLOAT column values as JS numbers (the f64 lane, copied). */
|
|
112
|
+
floats(col: number): number[];
|
|
113
|
+
/** STR column values as JS strings (decoded out of the walk's
|
|
114
|
+
* (ptr,len) views). */
|
|
115
|
+
strs(col: number): string[];
|
|
116
|
+
/** The column's null markers: 1 = the row's leaf was null or
|
|
117
|
+
* missing. A Uint8Array copy of `rows` entries. */
|
|
118
|
+
nulls(col: number): Uint8Array;
|
|
119
|
+
/** True once free() ran. */
|
|
120
|
+
get freed(): boolean;
|
|
121
|
+
/** Releases the retained walk (result + document + input copy).
|
|
122
|
+
* Idempotent. A stale result only dies locally — the retained
|
|
123
|
+
* state belongs to the walk that replaced it. */
|
|
124
|
+
free(): void;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** A COMPILED plan (plan.h): the query spec parses once and walks
|
|
128
|
+
* many documents. Build with compilePlan(); after free() reuse
|
|
129
|
+
* throws. */
|
|
130
|
+
export declare class Plan {
|
|
131
|
+
private constructor();
|
|
132
|
+
/** The number of leaf columns the spec declared. */
|
|
133
|
+
get columnCount(): number;
|
|
134
|
+
/** Apply the plan to a YAML document (the DOM leg): typed columns,
|
|
135
|
+
* one C pass. Synchronous — the handle only exists once the module
|
|
136
|
+
* is initialized. Throws YamlError when the document does not
|
|
137
|
+
* parse or its shape disagrees with the plan. */
|
|
138
|
+
walk(yaml: string): PlanResult;
|
|
139
|
+
/** True once free() ran. */
|
|
140
|
+
get freed(): boolean;
|
|
141
|
+
/** Frees the handle. Idempotent; afterwards reuse throws. */
|
|
142
|
+
free(): void;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Compile a plan from a strict-JSON spec document (object or string;
|
|
146
|
+
* the shape plan.h spells: kind "seq"|"map", path string|string[],
|
|
147
|
+
* children of { name, kind: "int"|"float"|"str"|"bool" }). Throws
|
|
148
|
+
* TypeError for empty/absent spec bytes and YamlError for bytes that
|
|
149
|
+
* do not parse or name no engine kind. */
|
|
150
|
+
export declare function compilePlan(spec: object | string): Promise<Plan>;
|
|
151
|
+
|
|
152
|
+
// ---- the tape face (tape.h; the columnar JSON parse) -------------------
|
|
153
|
+
|
|
154
|
+
/** The tape record kinds (tape.h's YEP_T_*, ABI-pinned). `kinds` in
|
|
155
|
+
* JsonTape.columns() answers these raw bytes. */
|
|
156
|
+
export const TAPE_KINDS: Readonly<{
|
|
157
|
+
doc: 0;
|
|
158
|
+
null: 1;
|
|
159
|
+
true: 2;
|
|
160
|
+
false: 3;
|
|
161
|
+
int: 4;
|
|
162
|
+
float: 5;
|
|
163
|
+
str: 6;
|
|
164
|
+
"seq-open": 7;
|
|
165
|
+
"map-open": 8;
|
|
166
|
+
close: 9;
|
|
167
|
+
num: 10;
|
|
168
|
+
}>;
|
|
169
|
+
|
|
170
|
+
/** One column materialization: three parallel arrays, one entry per
|
|
171
|
+
* record. `kinds` answers TAPE_KINDS bytes; `offs`/`lens` are span
|
|
172
|
+
* starts and lengths into the SOURCE for str/int/float records and
|
|
173
|
+
* container links (matching open/close) for open/close records. */
|
|
174
|
+
export interface TapeColumns {
|
|
175
|
+
kinds: Uint8Array;
|
|
176
|
+
offs: Uint32Array;
|
|
177
|
+
lens: Uint32Array;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** A parsed JSON tape (tape.h): the record stream of one strict
|
|
181
|
+
* parse. Build with parseJsonTape(); after free() reuse throws; a
|
|
182
|
+
* newer parseJsonTape() makes older tape objects stale — they refuse
|
|
183
|
+
* instead of answering the newer records. */
|
|
184
|
+
export declare class JsonTape {
|
|
185
|
+
private constructor();
|
|
186
|
+
/** The number of records (one per token, the document boundary
|
|
187
|
+
* record included). */
|
|
188
|
+
get count(): number;
|
|
189
|
+
/** The three parallel columns, materialized and copied out of the
|
|
190
|
+
* heap. */
|
|
191
|
+
columns(): TapeColumns;
|
|
192
|
+
/** Convert the number records in `[from, to)` (record indices;
|
|
193
|
+
* defaults convert every number record): DENSE answers in tape
|
|
194
|
+
* order — the INT records' converted values and the FLOAT records'
|
|
195
|
+
* (a lenient route's `num` record converts as a float). Exact
|
|
196
|
+
* within +/-2^53. */
|
|
197
|
+
convert(from?: number, to?: number): { ints: number[]; floats: number[] };
|
|
198
|
+
/** True once free() ran. */
|
|
199
|
+
get freed(): boolean;
|
|
200
|
+
/** Releases the retained tape and its input copy. Idempotent;
|
|
201
|
+
* afterwards reuse throws. */
|
|
202
|
+
free(): void;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** Parse strict JSON into the columnar tape (tape.h): one record per
|
|
206
|
+
* token, no DOM — the simdjson-class materialization. Scalar roots
|
|
207
|
+
* ride (a single record after the boundary). Throws YamlError with
|
|
208
|
+
* line/column on malformed input (the strict route validates the
|
|
209
|
+
* number grammar at parse). */
|
|
210
|
+
export declare function parseJsonTape(json: string): Promise<JsonTape>;
|
|
211
|
+
|
|
94
212
|
/** Validate a YAML stream, answering the WHOLE report: every
|
|
95
213
|
* diagnostic, in engine order ([] when valid). Without options the
|
|
96
214
|
* core-family walk runs. Throws YamlError when the stream does not
|
|
@@ -306,6 +424,12 @@ export declare function isValidSync(
|
|
|
306
424
|
/** compileSchema's Sync twin. Throws unless the module is initialized. */
|
|
307
425
|
export declare function compileSchemaSync(jsonSchema: object | string): Schema;
|
|
308
426
|
|
|
427
|
+
/** compilePlan's Sync twin. Throws unless the module is initialized. */
|
|
428
|
+
export declare function compilePlanSync(spec: object | string): Plan;
|
|
429
|
+
|
|
430
|
+
/** parseJsonTape's Sync twin. Throws unless the module is initialized. */
|
|
431
|
+
export declare function parseJsonTapeSync(json: string): JsonTape;
|
|
432
|
+
|
|
309
433
|
/** eachDocument's Sync twin: a sync generator over an initialized
|
|
310
434
|
* module (await init() first). Throws unless the module is
|
|
311
435
|
* initialized. Takes the same options door as eachDocument. */
|
package/src/index.js
CHANGED
|
@@ -106,6 +106,27 @@ async function mod() {
|
|
|
106
106
|
"_yeptris_wasm_schema_compile",
|
|
107
107
|
"_yeptris_wasm_schema_validate",
|
|
108
108
|
"_yeptris_wasm_schema_free",
|
|
109
|
+
"_yeptris_wasm_plan_compile",
|
|
110
|
+
"_yeptris_wasm_plan_column_count",
|
|
111
|
+
"_yeptris_wasm_plan_free",
|
|
112
|
+
"_yeptris_wasm_plan_walk",
|
|
113
|
+
"_yeptris_wasm_plan_seq",
|
|
114
|
+
"_yeptris_wasm_plan_rows",
|
|
115
|
+
"_yeptris_wasm_plan_kind",
|
|
116
|
+
"_yeptris_wasm_plan_ints",
|
|
117
|
+
"_yeptris_wasm_plan_floats",
|
|
118
|
+
"_yeptris_wasm_plan_strs",
|
|
119
|
+
"_yeptris_wasm_plan_nulls",
|
|
120
|
+
"_yeptris_wasm_plan_walk_free",
|
|
121
|
+
"_yeptris_wasm_tape_parse",
|
|
122
|
+
"_yeptris_wasm_tape_seq",
|
|
123
|
+
"_yeptris_wasm_tape_count",
|
|
124
|
+
"_yeptris_wasm_tape_columns",
|
|
125
|
+
"_yeptris_wasm_tape_kinds",
|
|
126
|
+
"_yeptris_wasm_tape_offs",
|
|
127
|
+
"_yeptris_wasm_tape_lens",
|
|
128
|
+
"_yeptris_wasm_tape_convert",
|
|
129
|
+
"_yeptris_wasm_tape_free",
|
|
109
130
|
"_yeptris_wasm_out",
|
|
110
131
|
"_yeptris_wasm_out_len",
|
|
111
132
|
"_yeptris_wasm_out_free",
|
|
@@ -894,6 +915,515 @@ function eventsCore(mod, yaml, options) {
|
|
|
894
915
|
}
|
|
895
916
|
}
|
|
896
917
|
|
|
918
|
+
// ---- the plan face (plan.h; the compiled columnar walk) ----------------
|
|
919
|
+
//
|
|
920
|
+
// The query surface, the rs face's shape (yeptris-rs 0.6.78, `pub mod
|
|
921
|
+
// plan`): a plan compiles ONCE from a strict-JSON spec
|
|
922
|
+
//
|
|
923
|
+
// {"kind":"seq","path":"items","children":[
|
|
924
|
+
// {"name":"id","kind":"int"}, {"name":"ok","kind":"bool"}, ...]}
|
|
925
|
+
//
|
|
926
|
+
// (kind: "seq" | "map" — the rows container's shape at the root; path:
|
|
927
|
+
// the root mapping's key holding the rows, a string or an ARRAY of
|
|
928
|
+
// strings for a segmented path walked mapping by mapping; leaf kinds:
|
|
929
|
+
// int, float, str, bool) and applies to a parsed document in ONE C
|
|
930
|
+
// pass, answering typed columns. Across the wasm boundary the walk is
|
|
931
|
+
// RETAINED state, the events-face lifecycle: the result BORROWS the
|
|
932
|
+
// document (its string columns are (ptr,len) views into the
|
|
933
|
+
// document's regions) and the document borrows its input — walk()
|
|
934
|
+
// retains all three until the host has copied its answers out, then
|
|
935
|
+
// free() releases them (a newer walk releases an undrained one
|
|
936
|
+
// defensively). Every accessor COPIES from the heap; nothing
|
|
937
|
+
// engine-owned survives free().
|
|
938
|
+
|
|
939
|
+
// YEP_PLAN_* (plan.h) -> the leaf-kind name.
|
|
940
|
+
const PLAN_KINDS = {
|
|
941
|
+
0: "int",
|
|
942
|
+
1: "float",
|
|
943
|
+
2: "str",
|
|
944
|
+
3: "bool",
|
|
945
|
+
};
|
|
946
|
+
|
|
947
|
+
/** The columnar result of one plan walk. Produced by Plan.walk(); a
|
|
948
|
+
* shim-retained answer the accessors copy from — free() releases the
|
|
949
|
+
* engine state. After free() reuse throws; so does a STALE result
|
|
950
|
+
* (a newer walk() replaced the retained state) — never a silent wrong
|
|
951
|
+
* answer. */
|
|
952
|
+
export class PlanResult {
|
|
953
|
+
/** @private — produced by Plan.walk() only */
|
|
954
|
+
constructor() {
|
|
955
|
+
throw new TypeError(
|
|
956
|
+
"yeptris: walk results come from plan.walk(), not new PlanResult()");
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
static _take(mod, seq) {
|
|
960
|
+
const r = Object.create(PlanResult.prototype);
|
|
961
|
+
r._mod = mod;
|
|
962
|
+
r._seq = seq; // the shim's retained-walk generation this answer is
|
|
963
|
+
r._freed = false;
|
|
964
|
+
return r;
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
/** True once free() ran. */
|
|
968
|
+
get freed() {
|
|
969
|
+
return this._freed;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
_requireLive(who) {
|
|
973
|
+
if (this._freed) {
|
|
974
|
+
throw new Error(
|
|
975
|
+
`yeptris: the walk result is freed — ${who} after free() is ` +
|
|
976
|
+
"refused (walk again for a fresh result)");
|
|
977
|
+
}
|
|
978
|
+
if (this._mod._yeptris_wasm_plan_seq() !== this._seq) {
|
|
979
|
+
throw new Error(
|
|
980
|
+
"yeptris: stale walk result — a newer walk() replaced the " +
|
|
981
|
+
"retained state; read this result's columns before walking again");
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
/** The number of rows (one per row of the rows container). */
|
|
986
|
+
get rows() {
|
|
987
|
+
this._requireLive("rows");
|
|
988
|
+
return this._mod._yeptris_wasm_plan_rows();
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
/** The leaf kind of column `col`: "int" | "float" | "str" | "bool". */
|
|
992
|
+
kind(col) {
|
|
993
|
+
this._requireLive("kind");
|
|
994
|
+
const k = this._mod._yeptris_wasm_plan_kind(col);
|
|
995
|
+
return PLAN_KINDS[k] ?? `unknown-${k}`;
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
/** INT column values as JS numbers. BOOL columns read through here
|
|
999
|
+
* too, as 0/1 — the engine's columnar contract (the rs face's
|
|
1000
|
+
* `ints()`). Exact within +/-2^53 (the load()'s JSON round-trip
|
|
1001
|
+
* law); the engine's int64 wider than that rounds, per JS number. */
|
|
1002
|
+
ints(col) {
|
|
1003
|
+
this._requireLive("ints");
|
|
1004
|
+
const k = this._mod._yeptris_wasm_plan_kind(col);
|
|
1005
|
+
if (k !== 0 && k !== 3) {
|
|
1006
|
+
throw new TypeError(
|
|
1007
|
+
`yeptris: ints() reads int and bool columns — column ${col} is ` +
|
|
1008
|
+
`${PLAN_KINDS[k] ?? `unknown-${k}`}`);
|
|
1009
|
+
}
|
|
1010
|
+
const rows = this._mod._yeptris_wasm_plan_rows();
|
|
1011
|
+
const p = this._mod._yeptris_wasm_plan_ints(col);
|
|
1012
|
+
if (!p || rows === 0) {
|
|
1013
|
+
return [];
|
|
1014
|
+
}
|
|
1015
|
+
// views fetched AFTER the calls (the memory may have grown); the
|
|
1016
|
+
// int64 lane composes from the u32 pair — wasm64 views are not a
|
|
1017
|
+
// given across the emcc eras this surface builds on
|
|
1018
|
+
const u32 = this._mod.HEAPU32;
|
|
1019
|
+
const base = p >> 2;
|
|
1020
|
+
const out = new Array(rows);
|
|
1021
|
+
for (let i = 0; i < rows; i++) {
|
|
1022
|
+
const hi = u32[base + i * 2 + 1];
|
|
1023
|
+
let v = hi * 4294967296 + u32[base + i * 2];
|
|
1024
|
+
if (hi >= 2147483648) {
|
|
1025
|
+
v -= 18446744073709551616;
|
|
1026
|
+
}
|
|
1027
|
+
out[i] = v;
|
|
1028
|
+
}
|
|
1029
|
+
return out;
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
/** FLOAT column values as JS numbers (the f64 lane, copied). */
|
|
1033
|
+
floats(col) {
|
|
1034
|
+
this._requireLive("floats");
|
|
1035
|
+
const k = this._mod._yeptris_wasm_plan_kind(col);
|
|
1036
|
+
if (k !== 1) {
|
|
1037
|
+
throw new TypeError(
|
|
1038
|
+
`yeptris: floats() reads float columns — column ${col} is ` +
|
|
1039
|
+
`${PLAN_KINDS[k] ?? `unknown-${k}`}`);
|
|
1040
|
+
}
|
|
1041
|
+
const rows = this._mod._yeptris_wasm_plan_rows();
|
|
1042
|
+
const p = this._mod._yeptris_wasm_plan_floats(col);
|
|
1043
|
+
if (!p || rows === 0) {
|
|
1044
|
+
return [];
|
|
1045
|
+
}
|
|
1046
|
+
const f64 = this._mod.HEAPF64;
|
|
1047
|
+
const base = p >> 3;
|
|
1048
|
+
return Array.from(f64.subarray(base, base + rows));
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
/** STR column values as JS strings (the DOM leg's (ptr,len) views,
|
|
1052
|
+
* decoded and copied out of the heap). */
|
|
1053
|
+
strs(col) {
|
|
1054
|
+
this._requireLive("strs");
|
|
1055
|
+
const k = this._mod._yeptris_wasm_plan_kind(col);
|
|
1056
|
+
if (k !== 2) {
|
|
1057
|
+
throw new TypeError(
|
|
1058
|
+
`yeptris: strs() reads str columns — column ${col} is ` +
|
|
1059
|
+
`${PLAN_KINDS[k] ?? `unknown-${k}`}`);
|
|
1060
|
+
}
|
|
1061
|
+
const rows = this._mod._yeptris_wasm_plan_rows();
|
|
1062
|
+
const p = this._mod._yeptris_wasm_plan_strs(col);
|
|
1063
|
+
if (!p || rows === 0) {
|
|
1064
|
+
return [];
|
|
1065
|
+
}
|
|
1066
|
+
// records of yeptris_plan_str { const char* p; size_t len; } —
|
|
1067
|
+
// 8 bytes on wasm32: one u32 pair per row
|
|
1068
|
+
const u8 = this._mod.HEAPU8;
|
|
1069
|
+
const u32 = this._mod.HEAPU32;
|
|
1070
|
+
const base = p >> 2;
|
|
1071
|
+
const out = new Array(rows);
|
|
1072
|
+
for (let i = 0; i < rows; i++) {
|
|
1073
|
+
const sp = u32[base + i * 2];
|
|
1074
|
+
const sl = u32[base + i * 2 + 1];
|
|
1075
|
+
out[i] = sl !== 0 ? decodeArena(u8, sp, sl) : "";
|
|
1076
|
+
}
|
|
1077
|
+
return out;
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
/** The column's null markers: 1 = the row's leaf was null or
|
|
1081
|
+
* missing. A Uint8Array copy of `rows` entries. */
|
|
1082
|
+
nulls(col) {
|
|
1083
|
+
this._requireLive("nulls");
|
|
1084
|
+
const rows = this._mod._yeptris_wasm_plan_rows();
|
|
1085
|
+
const p = this._mod._yeptris_wasm_plan_nulls(col);
|
|
1086
|
+
if (!p || rows === 0) {
|
|
1087
|
+
return new Uint8Array(0);
|
|
1088
|
+
}
|
|
1089
|
+
// slice COPIES: a subarray would view the heap that free() releases
|
|
1090
|
+
return this._mod.HEAPU8.slice(p, p + rows);
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
/** Releases the retained walk (result + document + input copy).
|
|
1094
|
+
* Idempotent. A STALE result only dies locally — the retained state
|
|
1095
|
+
* belongs to the walk that replaced it. */
|
|
1096
|
+
free() {
|
|
1097
|
+
if (this._freed) return;
|
|
1098
|
+
this._freed = true;
|
|
1099
|
+
if (this._mod._yeptris_wasm_plan_seq() === this._seq) {
|
|
1100
|
+
this._mod._yeptris_wasm_plan_walk_free();
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
/** A COMPILED plan (plan.h): the query spec parses once — its columns
|
|
1106
|
+
* and segmented path retained behind one opaque handle — and walks
|
|
1107
|
+
* MANY documents. Build with compilePlan(); direct construction is
|
|
1108
|
+
* refused. After free() the handle is dead: reuse throws. */
|
|
1109
|
+
export class Plan {
|
|
1110
|
+
/** @private — produced by compilePlan() only */
|
|
1111
|
+
constructor() {
|
|
1112
|
+
throw new TypeError(
|
|
1113
|
+
"yeptris: build plans with compilePlan(), not new Plan()");
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
static _take(mod, handle) {
|
|
1117
|
+
const s = Object.create(Plan.prototype);
|
|
1118
|
+
s._mod = mod; // the module the handle lives in (compile ran => initialized)
|
|
1119
|
+
s._handle = handle;
|
|
1120
|
+
s._freed = false;
|
|
1121
|
+
return s;
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
/** True once free() ran. */
|
|
1125
|
+
get freed() {
|
|
1126
|
+
return this._freed;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
_requireAlive(who) {
|
|
1130
|
+
if (this._freed) {
|
|
1131
|
+
throw new Error(
|
|
1132
|
+
`yeptris: the plan handle is freed — ${who} on a freed plan is ` +
|
|
1133
|
+
"refused (compile a fresh one with compilePlan())");
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
/** The number of leaf columns the spec declared. */
|
|
1138
|
+
get columnCount() {
|
|
1139
|
+
this._requireAlive("columnCount");
|
|
1140
|
+
return this._mod._yeptris_wasm_plan_column_count(this._handle);
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
/** Apply the plan to a YAML document (the DOM leg): typed columns,
|
|
1144
|
+
* one C pass, no per-node host dispatch. Synchronous — the handle
|
|
1145
|
+
* only exists once the module is initialized. Throws YamlError when
|
|
1146
|
+
* the document does not parse or its shape disagrees with the plan
|
|
1147
|
+
* (the rows container the path names is not there). */
|
|
1148
|
+
walk(yaml) {
|
|
1149
|
+
this._requireAlive("walk");
|
|
1150
|
+
return planWalkCore(this._mod, this, yaml);
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
/** Frees the handle. Idempotent; afterwards reuse throws. */
|
|
1154
|
+
free() {
|
|
1155
|
+
if (this._freed) return;
|
|
1156
|
+
this._freed = true;
|
|
1157
|
+
this._mod._yeptris_wasm_plan_free(this._handle);
|
|
1158
|
+
this._handle = 0;
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
function planWalkCore(mod, plan, yaml) {
|
|
1163
|
+
const [ptr, len] = cstr(mod, yaml);
|
|
1164
|
+
try {
|
|
1165
|
+
const st = mod._yeptris_wasm_plan_walk(plan._handle, ptr, len);
|
|
1166
|
+
if (st !== 0) {
|
|
1167
|
+
throw new YamlError(
|
|
1168
|
+
mod.UTF8ToString(mod._yeptris_wasm_last_error()),
|
|
1169
|
+
mod._yeptris_wasm_last_error_line(),
|
|
1170
|
+
mod._yeptris_wasm_last_error_column());
|
|
1171
|
+
}
|
|
1172
|
+
return PlanResult._take(mod, mod._yeptris_wasm_plan_seq());
|
|
1173
|
+
} finally {
|
|
1174
|
+
freeCstr(mod, ptr);
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
function compilePlanCore(mod, spec) {
|
|
1179
|
+
if (spec === undefined || spec === null) {
|
|
1180
|
+
throw new TypeError("yeptris: plan spec bytes are required");
|
|
1181
|
+
}
|
|
1182
|
+
const bytes = typeof spec === "string" ? spec : JSON.stringify(spec);
|
|
1183
|
+
if (bytes.length === 0) {
|
|
1184
|
+
throw new TypeError("yeptris: plan spec holds no document");
|
|
1185
|
+
}
|
|
1186
|
+
const [ptr, len] = cstr(mod, bytes);
|
|
1187
|
+
let handle;
|
|
1188
|
+
try {
|
|
1189
|
+
handle = mod._yeptris_wasm_plan_compile(ptr, len);
|
|
1190
|
+
} finally {
|
|
1191
|
+
freeCstr(mod, ptr);
|
|
1192
|
+
}
|
|
1193
|
+
if (handle === 0) {
|
|
1194
|
+
throw failFrom(mod); // the engine's why rides last_error
|
|
1195
|
+
}
|
|
1196
|
+
return Plan._take(mod, handle);
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
/** Compile a plan from a strict-JSON spec document (object or string;
|
|
1200
|
+
* the shape plan.h spells: kind "seq"|"map", path string|string[],
|
|
1201
|
+
* children of { name, kind: int|float|str|bool }). Throws TypeError
|
|
1202
|
+
* for empty/absent spec bytes and YamlError (with the engine's
|
|
1203
|
+
* message) for bytes that do not parse or name no engine kind. */
|
|
1204
|
+
export async function compilePlan(spec) {
|
|
1205
|
+
const m = await mod();
|
|
1206
|
+
return compilePlanCore(m, spec);
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
// ---- the tape face (tape.h; the columnar JSON parse) -------------------
|
|
1210
|
+
//
|
|
1211
|
+
// The simdjson-class materialization: one fused strict walk appends
|
|
1212
|
+
// ONE record per token — no DOM nodes, no links, no views. Records
|
|
1213
|
+
// are three parallel columns (kind byte, off, len); bools encode in
|
|
1214
|
+
// the kind, container links ride the off column (matching
|
|
1215
|
+
// open/close), numbers record spans only, and strings stay zero-copy
|
|
1216
|
+
// spans into the caller's buffer — which is why the tape is RETAINED
|
|
1217
|
+
// state across the wasm boundary (the events-face lifecycle again):
|
|
1218
|
+
// parse() copies the input and retains tape + copy, the accessors
|
|
1219
|
+
// copy their answers out, free() releases both. The record kinds are
|
|
1220
|
+
// ABI-pinned (tape.h, appending-only) and exported below as data.
|
|
1221
|
+
|
|
1222
|
+
/** The tape record kinds (tape.h's YEP_T_*, ABI-pinned). `kinds` in
|
|
1223
|
+
* columns() answers these raw bytes; the names spell the vocabulary. */
|
|
1224
|
+
export const TAPE_KINDS = Object.freeze({
|
|
1225
|
+
doc: 0, // document boundary (records start after it)
|
|
1226
|
+
null: 1,
|
|
1227
|
+
true: 2, // the kind IS the value
|
|
1228
|
+
false: 3,
|
|
1229
|
+
int: 4, // off/len: signed digit span; convert materializes
|
|
1230
|
+
float: 5, // off/len: float text span
|
|
1231
|
+
str: 6, // off/len: raw span into the source (escapes untouched)
|
|
1232
|
+
"seq-open": 7, // off: index of the matching close
|
|
1233
|
+
"map-open": 8, // off: index of the matching close
|
|
1234
|
+
close: 9, // off: index of the matching open
|
|
1235
|
+
num: 10, // lenient route only: a number span the grammar has NOT
|
|
1236
|
+
// validated at parse — convert is the authority
|
|
1237
|
+
});
|
|
1238
|
+
|
|
1239
|
+
/** A parsed JSON tape (tape.h): the record stream of one strict
|
|
1240
|
+
* parse, retained behind the module. Build with parseJsonTape();
|
|
1241
|
+
* direct construction is refused. After free() reuse throws; a newer
|
|
1242
|
+
* parse() makes older tape objects stale — they refuse instead of
|
|
1243
|
+
* answering the newer records. */
|
|
1244
|
+
export class JsonTape {
|
|
1245
|
+
/** @private — produced by parseJsonTape() only */
|
|
1246
|
+
constructor() {
|
|
1247
|
+
throw new TypeError(
|
|
1248
|
+
"yeptris: build tapes with parseJsonTape(), not new JsonTape()");
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
static _take(mod, seq) {
|
|
1252
|
+
const t = Object.create(JsonTape.prototype);
|
|
1253
|
+
t._mod = mod;
|
|
1254
|
+
t._seq = seq; // the shim's retained-tape generation this answer is
|
|
1255
|
+
t._freed = false;
|
|
1256
|
+
return t;
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
/** True once free() ran. */
|
|
1260
|
+
get freed() {
|
|
1261
|
+
return this._freed;
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
_requireLive(who) {
|
|
1265
|
+
if (this._freed) {
|
|
1266
|
+
throw new Error(
|
|
1267
|
+
`yeptris: the tape is freed — ${who} after free() is refused ` +
|
|
1268
|
+
"(parse again for a fresh tape)");
|
|
1269
|
+
}
|
|
1270
|
+
if (this._mod._yeptris_wasm_tape_seq() !== this._seq) {
|
|
1271
|
+
throw new Error(
|
|
1272
|
+
"yeptris: stale tape — a newer parseJsonTape() replaced the " +
|
|
1273
|
+
"retained state; read this tape's records before parsing again");
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
/** The number of records (one per token, the document boundary
|
|
1278
|
+
* record included). */
|
|
1279
|
+
get count() {
|
|
1280
|
+
this._requireLive("count");
|
|
1281
|
+
return this._mod._yeptris_wasm_tape_count();
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
/** The three parallel columns, materialized (the shim runs
|
|
1285
|
+
* yeptris_tape_columns first — a no-op when already materialized)
|
|
1286
|
+
* and COPIED out of the heap: `{ kinds: Uint8Array, offs:
|
|
1287
|
+
* Uint32Array, lens: Uint32Array }`, one entry per record. `kinds`
|
|
1288
|
+
* answers TAPE_KINDS bytes; `offs`/`lens` are span starts and
|
|
1289
|
+
* lengths into the SOURCE for str/int/float records and container
|
|
1290
|
+
* links for open/close records. */
|
|
1291
|
+
columns() {
|
|
1292
|
+
this._requireLive("columns");
|
|
1293
|
+
const st = this._mod._yeptris_wasm_tape_columns();
|
|
1294
|
+
if (st !== 0) {
|
|
1295
|
+
throw new Error(
|
|
1296
|
+
`yeptris: tape column materialization failed (status ${st})`);
|
|
1297
|
+
}
|
|
1298
|
+
const count = this._mod._yeptris_wasm_tape_count();
|
|
1299
|
+
// heap views fetched AFTER the calls (the memory may have grown);
|
|
1300
|
+
// slice COPIES — the tape frees under these
|
|
1301
|
+
const u8 = this._mod.HEAPU8;
|
|
1302
|
+
const u32 = this._mod.HEAPU32;
|
|
1303
|
+
const kinds = this._mod._yeptris_wasm_tape_kinds();
|
|
1304
|
+
const offs = this._mod._yeptris_wasm_tape_offs();
|
|
1305
|
+
const lens = this._mod._yeptris_wasm_tape_lens();
|
|
1306
|
+
return {
|
|
1307
|
+
kinds: kinds !== 0 ? u8.slice(kinds, kinds + count) : new Uint8Array(0),
|
|
1308
|
+
offs: offs !== 0
|
|
1309
|
+
? u32.slice(offs >> 2, (offs >> 2) + count)
|
|
1310
|
+
: new Uint32Array(0),
|
|
1311
|
+
lens: lens !== 0
|
|
1312
|
+
? u32.slice(lens >> 2, (lens >> 2) + count)
|
|
1313
|
+
: new Uint32Array(0),
|
|
1314
|
+
};
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
/** Convert the number records in `[from, to)` (record indices; the
|
|
1318
|
+
* defaults convert every number record): answers
|
|
1319
|
+
* `{ ints: number[], floats: number[] }` — DENSE, in tape order:
|
|
1320
|
+
* the INT records' converted values and the FLOAT records' (a
|
|
1321
|
+
* lenient route's `num` record converts as a float — convert is the
|
|
1322
|
+
* grammar's authority there). Exact within +/-2^53 (the load()'s
|
|
1323
|
+
* JSON round-trip law). */
|
|
1324
|
+
convert(from = 0, to) {
|
|
1325
|
+
this._requireLive("convert");
|
|
1326
|
+
const count = this._mod._yeptris_wasm_tape_count();
|
|
1327
|
+
const end = to === undefined || to === null ? count : to;
|
|
1328
|
+
const reqIndex = (v, who) => {
|
|
1329
|
+
if (typeof v !== "number" || !Number.isInteger(v) || v < 0) {
|
|
1330
|
+
throw new TypeError(
|
|
1331
|
+
`yeptris: convert ${who} must be a non-negative integer ` +
|
|
1332
|
+
"(a record index)");
|
|
1333
|
+
}
|
|
1334
|
+
};
|
|
1335
|
+
reqIndex(from, "from");
|
|
1336
|
+
if (to !== undefined && to !== null) {
|
|
1337
|
+
reqIndex(to, "to");
|
|
1338
|
+
}
|
|
1339
|
+
if (from > end) {
|
|
1340
|
+
throw new TypeError("yeptris: convert from exceeds to");
|
|
1341
|
+
}
|
|
1342
|
+
if (end > count) {
|
|
1343
|
+
throw new TypeError(
|
|
1344
|
+
`yeptris: convert to ${end} exceeds the tape's ${count} records`);
|
|
1345
|
+
}
|
|
1346
|
+
const cols = this.columns(); // the kinds view drives the dense answer
|
|
1347
|
+
const bufN = count > 0 ? count : 1;
|
|
1348
|
+
const ivals = this._mod._malloc(bufN * 8);
|
|
1349
|
+
const dvals = this._mod._malloc(bufN * 8);
|
|
1350
|
+
try {
|
|
1351
|
+
// record-index-parallel slots, zeroed: the engine writes only
|
|
1352
|
+
// the number records' slots, the untouched ones read 0
|
|
1353
|
+
new Uint8Array(this._mod.HEAPU8.buffer, ivals, bufN * 8).fill(0);
|
|
1354
|
+
new Uint8Array(this._mod.HEAPU8.buffer, dvals, bufN * 8).fill(0);
|
|
1355
|
+
const n = this._mod._yeptris_wasm_tape_convert(from, end, ivals, dvals);
|
|
1356
|
+
if (n === -1) {
|
|
1357
|
+
throw new Error(
|
|
1358
|
+
"yeptris: a number span refused to convert (not a tape this " +
|
|
1359
|
+
"library produced)");
|
|
1360
|
+
}
|
|
1361
|
+
// views fetched AFTER the call: the mallocs may have grown the
|
|
1362
|
+
// memory, and the exported views re-bind on growth
|
|
1363
|
+
const u32 = this._mod.HEAPU32;
|
|
1364
|
+
const f64 = this._mod.HEAPF64;
|
|
1365
|
+
const ibase = ivals >> 2;
|
|
1366
|
+
const dbase = dvals >> 3;
|
|
1367
|
+
const ints = [];
|
|
1368
|
+
const floats = [];
|
|
1369
|
+
for (let i = from; i < end; i++) {
|
|
1370
|
+
const kind = cols.kinds[i];
|
|
1371
|
+
if (kind === TAPE_KINDS.int) {
|
|
1372
|
+
const hi = u32[ibase + i * 2 + 1];
|
|
1373
|
+
let v = hi * 4294967296 + u32[ibase + i * 2];
|
|
1374
|
+
if (hi >= 2147483648) {
|
|
1375
|
+
v -= 18446744073709551616;
|
|
1376
|
+
}
|
|
1377
|
+
ints.push(v);
|
|
1378
|
+
} else if (kind === TAPE_KINDS.float || kind === TAPE_KINDS.num) {
|
|
1379
|
+
floats.push(f64[dbase + i]);
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
return { ints, floats };
|
|
1383
|
+
} finally {
|
|
1384
|
+
this._mod._yeptris_wasm_free(ivals);
|
|
1385
|
+
this._mod._yeptris_wasm_free(dvals);
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
/** Releases the retained tape and its input copy. Idempotent;
|
|
1390
|
+
* afterwards reuse throws. */
|
|
1391
|
+
free() {
|
|
1392
|
+
if (this._freed) return;
|
|
1393
|
+
this._freed = true;
|
|
1394
|
+
this._mod._yeptris_wasm_tape_free();
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
function parseJsonTapeCore(mod, json) {
|
|
1399
|
+
const [ptr, len] = cstr(mod, json);
|
|
1400
|
+
try {
|
|
1401
|
+
const st = mod._yeptris_wasm_tape_parse(ptr, len);
|
|
1402
|
+
if (st !== 0) {
|
|
1403
|
+
throw new YamlError(
|
|
1404
|
+
mod.UTF8ToString(mod._yeptris_wasm_last_error()),
|
|
1405
|
+
mod._yeptris_wasm_last_error_line(),
|
|
1406
|
+
mod._yeptris_wasm_last_error_column());
|
|
1407
|
+
}
|
|
1408
|
+
return JsonTape._take(mod, mod._yeptris_wasm_tape_seq());
|
|
1409
|
+
} finally {
|
|
1410
|
+
freeCstr(mod, ptr);
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
/** Parse strict JSON into the columnar tape (tape.h): one record per
|
|
1415
|
+
* token, no DOM — the simdjson-class materialization. Scalar roots
|
|
1416
|
+
* ride (a single record after the boundary). Throws YamlError with
|
|
1417
|
+
* line/column on malformed input — the strict route validates the
|
|
1418
|
+
* number grammar at parse, so a malformed span never reaches the
|
|
1419
|
+
* tape (the lenient route's deferred numbers are an engine door this
|
|
1420
|
+
* face does not open; convert remains the authority for `num`
|
|
1421
|
+
* records). */
|
|
1422
|
+
export async function parseJsonTape(json) {
|
|
1423
|
+
const m = await mod();
|
|
1424
|
+
return parseJsonTapeCore(m, json);
|
|
1425
|
+
}
|
|
1426
|
+
|
|
897
1427
|
/** Parse YAML text and return the document as a JavaScript value
|
|
898
1428
|
* (the engine's canonical JSON, JSON.parse'd). Throws YamlError with
|
|
899
1429
|
* line/column on malformed input. A multi-document stream answers
|
|
@@ -1039,6 +1569,16 @@ export function compileSchemaSync(jsonSchema) {
|
|
|
1039
1569
|
return compileSchemaCore(requireMod("compileSchemaSync"), jsonSchema);
|
|
1040
1570
|
}
|
|
1041
1571
|
|
|
1572
|
+
/** compilePlan's Sync twin. Throws unless the module is initialized. */
|
|
1573
|
+
export function compilePlanSync(spec) {
|
|
1574
|
+
return compilePlanCore(requireMod("compilePlanSync"), spec);
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
/** parseJsonTape's Sync twin. Throws unless the module is initialized. */
|
|
1578
|
+
export function parseJsonTapeSync(json) {
|
|
1579
|
+
return parseJsonTapeCore(requireMod("parseJsonTapeSync"), json);
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1042
1582
|
/** version's Sync twin. Throws unless the module is initialized. */
|
|
1043
1583
|
export function versionSync() {
|
|
1044
1584
|
const m = requireMod("versionSync");
|
package/src/yeptris_wasm.c
CHANGED
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
#include "yeptris/events.h"
|
|
17
17
|
#include "yeptris/json.h"
|
|
18
18
|
#include "yeptris/parse.h"
|
|
19
|
+
#include "yeptris/plan.h"
|
|
20
|
+
#include "yeptris/tape.h"
|
|
19
21
|
#include "yeptris/validate.h"
|
|
20
22
|
#include "yeptris/version.h"
|
|
21
23
|
|
|
@@ -875,3 +877,249 @@ int yeptris_wasm_schema_validate(yeptris_schema *s, const char *data, size_t len
|
|
|
875
877
|
|
|
876
878
|
EMSCRIPTEN_KEEPALIVE
|
|
877
879
|
void yeptris_wasm_schema_free(yeptris_schema *s) { yeptris_schema_free(s); }
|
|
880
|
+
|
|
881
|
+
/* ---- the plan face (plan.h) --------------------------------------------
|
|
882
|
+
*
|
|
883
|
+
* The compiled columnar walk: a plan compiles once from a strict-JSON
|
|
884
|
+
* spec (kind seq/map, a path — string or segmented string array — and
|
|
885
|
+
* typed leaf children) and applies to a parsed document in ONE C pass,
|
|
886
|
+
* answering typed columns. yeptris-rs 0.6.78 `pub mod plan` is the
|
|
887
|
+
* reference wrapper shape.
|
|
888
|
+
*
|
|
889
|
+
* Across the wasm boundary the walk is RETAINED state, same lifecycle
|
|
890
|
+
* as the events drain: the result BORROWS the document (its string
|
|
891
|
+
* columns are (ptr,len) views into the document's regions) and the
|
|
892
|
+
* document borrows its input — so walk() retains the input copy, the
|
|
893
|
+
* document and the result in globals, the host reads its answers out
|
|
894
|
+
* through the accessor exports (every column accessor hands back a raw
|
|
895
|
+
* heap pointer the host copies from), and plan_walk_free releases all
|
|
896
|
+
* three. A new walk releases a previous undrained one defensively.
|
|
897
|
+
*
|
|
898
|
+
* The result pointer itself is never handed to the host — the retained
|
|
899
|
+
* globals are the single source, and a monotonically rising seq guard
|
|
900
|
+
* lets the host refuse a stale result object instead of silently
|
|
901
|
+
* answering the newer walk's data (the module-guard law: a stale read
|
|
902
|
+
* refuses loudly, never lies). */
|
|
903
|
+
|
|
904
|
+
static YeptrisDocument g_pw_doc;
|
|
905
|
+
static char *g_pw_buf;
|
|
906
|
+
static yeptris_plan_result *g_pw_res;
|
|
907
|
+
static unsigned g_pw_seq;
|
|
908
|
+
|
|
909
|
+
static void yeptris_wasm_plan_walk_release(void) {
|
|
910
|
+
/* the result borrows the document, the document the buffer — this
|
|
911
|
+
* order, always */
|
|
912
|
+
yeptris_plan_result_free(g_pw_res);
|
|
913
|
+
g_pw_res = NULL;
|
|
914
|
+
yeptris_document_free(g_pw_doc);
|
|
915
|
+
g_pw_doc = NULL;
|
|
916
|
+
free(g_pw_buf);
|
|
917
|
+
g_pw_buf = NULL;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
/* The plan handle crosses as an opaque wasm32 pointer the host stores
|
|
921
|
+
* verbatim (the compiled-schema pattern): 0 = compile failed, with the
|
|
922
|
+
* why on the error channel. A spec that PARSES but is then rejected
|
|
923
|
+
* (an unknown kind value, a malformed child) sets no engine message —
|
|
924
|
+
* the channel would answer a stale why from an earlier call. Compare
|
|
925
|
+
* the channel across the call: unchanged means the engine said
|
|
926
|
+
* nothing, and the generic reason stands instead of a lie. */
|
|
927
|
+
EMSCRIPTEN_KEEPALIVE
|
|
928
|
+
yeptris_plan *yeptris_wasm_plan_compile(const char *spec, size_t len) {
|
|
929
|
+
char prev[256];
|
|
930
|
+
const char *b = yeptris_last_error(NULL, NULL);
|
|
931
|
+
snprintf(prev, sizeof prev, "%s", b ? b : "");
|
|
932
|
+
YeptrisStatus st = YEPTRIS_OK;
|
|
933
|
+
yeptris_plan *plan = yeptris_plan_compile(spec, len, &st);
|
|
934
|
+
if (plan != NULL) {
|
|
935
|
+
return plan;
|
|
936
|
+
}
|
|
937
|
+
const char *after = yeptris_last_error(NULL, NULL);
|
|
938
|
+
if (after != NULL && after[0] != '\0' && strcmp(after, prev) != 0) {
|
|
939
|
+
capture_error(); /* the engine's why + position (spec JSON refused) */
|
|
940
|
+
} else {
|
|
941
|
+
capture_plain(st == YEPTRIS_ERROR_ARG ? "the plan spec is not a valid plan document"
|
|
942
|
+
: "the plan spec failed to parse");
|
|
943
|
+
}
|
|
944
|
+
return NULL;
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
EMSCRIPTEN_KEEPALIVE
|
|
948
|
+
int yeptris_wasm_plan_column_count(const yeptris_plan *plan) {
|
|
949
|
+
return plan != NULL ? (int)yeptris_plan_column_count(plan) : 0;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
EMSCRIPTEN_KEEPALIVE
|
|
953
|
+
void yeptris_wasm_plan_free(yeptris_plan *plan) { yeptris_plan_free(plan); }
|
|
954
|
+
|
|
955
|
+
EMSCRIPTEN_KEEPALIVE
|
|
956
|
+
int yeptris_wasm_plan_walk(const yeptris_plan *plan, const char *data, size_t len) {
|
|
957
|
+
yeptris_wasm_plan_walk_release(); /* defensive: an undrained walk */
|
|
958
|
+
g_pw_buf = (char *)malloc(len > 0 ? len : 1);
|
|
959
|
+
if (g_pw_buf == NULL) {
|
|
960
|
+
capture_plain("plan walk allocation failed");
|
|
961
|
+
return YEPTRIS_ERROR_MEMORY;
|
|
962
|
+
}
|
|
963
|
+
if (len > 0) {
|
|
964
|
+
memcpy(g_pw_buf, data, len);
|
|
965
|
+
}
|
|
966
|
+
YeptrisStatus st = YEPTRIS_OK;
|
|
967
|
+
g_pw_doc = yeptris_parse(g_pw_buf, len, &st);
|
|
968
|
+
if (g_pw_doc == NULL) {
|
|
969
|
+
capture_error(); /* the YAML itself refused: the engine's why */
|
|
970
|
+
free(g_pw_buf);
|
|
971
|
+
g_pw_buf = NULL;
|
|
972
|
+
return (int)st;
|
|
973
|
+
}
|
|
974
|
+
g_pw_res = yeptris_document_plan_walk(g_pw_doc, plan, &st);
|
|
975
|
+
if (g_pw_res == NULL) {
|
|
976
|
+
/* the shape-disagreement class (PARSE) carries no engine
|
|
977
|
+
* message; everything else is memory/arg — say so directly,
|
|
978
|
+
* never a stale channel text */
|
|
979
|
+
capture_plain(st == YEPTRIS_ERROR_PARSE ? "the document shape disagrees with the plan"
|
|
980
|
+
: "the plan walk failed");
|
|
981
|
+
yeptris_document_free(g_pw_doc);
|
|
982
|
+
g_pw_doc = NULL;
|
|
983
|
+
free(g_pw_buf);
|
|
984
|
+
g_pw_buf = NULL;
|
|
985
|
+
return (int)st;
|
|
986
|
+
}
|
|
987
|
+
g_pw_seq++;
|
|
988
|
+
return YEPTRIS_OK;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
EMSCRIPTEN_KEEPALIVE
|
|
992
|
+
unsigned yeptris_wasm_plan_seq(void) { return g_pw_seq; }
|
|
993
|
+
|
|
994
|
+
EMSCRIPTEN_KEEPALIVE
|
|
995
|
+
int yeptris_wasm_plan_rows(void) {
|
|
996
|
+
return g_pw_res != NULL ? (int)yeptris_plan_result_rows(g_pw_res) : 0;
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
EMSCRIPTEN_KEEPALIVE
|
|
1000
|
+
int yeptris_wasm_plan_kind(size_t col) {
|
|
1001
|
+
return g_pw_res != NULL ? yeptris_plan_result_kind(g_pw_res, col) : -1;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
EMSCRIPTEN_KEEPALIVE
|
|
1005
|
+
const int64_t *yeptris_wasm_plan_ints(size_t col) {
|
|
1006
|
+
return g_pw_res != NULL ? yeptris_plan_result_ints(g_pw_res, col) : NULL;
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
EMSCRIPTEN_KEEPALIVE
|
|
1010
|
+
const double *yeptris_wasm_plan_floats(size_t col) {
|
|
1011
|
+
return g_pw_res != NULL ? yeptris_plan_result_floats(g_pw_res, col) : NULL;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
EMSCRIPTEN_KEEPALIVE
|
|
1015
|
+
const yeptris_plan_str *yeptris_wasm_plan_strs(size_t col) {
|
|
1016
|
+
return g_pw_res != NULL ? yeptris_plan_result_strs(g_pw_res, col) : NULL;
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
EMSCRIPTEN_KEEPALIVE
|
|
1020
|
+
const uint8_t *yeptris_wasm_plan_nulls(size_t col) {
|
|
1021
|
+
return g_pw_res != NULL ? yeptris_plan_result_nulls(g_pw_res, col) : NULL;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
EMSCRIPTEN_KEEPALIVE
|
|
1025
|
+
void yeptris_wasm_plan_walk_free(void) { yeptris_wasm_plan_walk_release(); }
|
|
1026
|
+
|
|
1027
|
+
/* ---- the tape face (tape.h) --------------------------------------------
|
|
1028
|
+
*
|
|
1029
|
+
* The compact JSON tape: one fused strict walk appends ONE record per
|
|
1030
|
+
* token — no DOM, no links, no views. Records are three parallel
|
|
1031
|
+
* columns (kind byte, off, len); numbers record spans only (the
|
|
1032
|
+
* grammar is validated at parse on the strict route; convert is the
|
|
1033
|
+
* authority for the lenient route's deferred records). Strings stay
|
|
1034
|
+
* zero-copy spans into the caller's buffer — so the shim retains a
|
|
1035
|
+
* COPY of the input for the tape's lifetime, same law as the walk:
|
|
1036
|
+
* parse (feed, copy, construct), the accessor reads, then an explicit
|
|
1037
|
+
* free. A new parse releases a previous undrained tape defensively.
|
|
1038
|
+
*
|
|
1039
|
+
* The engine hands the tape back through a caller-provided struct
|
|
1040
|
+
* (parse memsets it), so the retained state is one static struct plus
|
|
1041
|
+
* the buffer copy — and the seq guard idiom carries over: the host
|
|
1042
|
+
* refuses a stale tape object instead of silently answering the newer
|
|
1043
|
+
* parse's records. yeptris_tape_columns runs before every pointer
|
|
1044
|
+
* hand-out (the compat columns materialize lazily on the interleaved
|
|
1045
|
+
* route; a no-op when already materialized). */
|
|
1046
|
+
|
|
1047
|
+
static yeptris_json_tape g_tp;
|
|
1048
|
+
static char *g_tp_buf;
|
|
1049
|
+
static unsigned g_tp_seq;
|
|
1050
|
+
static int g_tp_live;
|
|
1051
|
+
|
|
1052
|
+
EMSCRIPTEN_KEEPALIVE
|
|
1053
|
+
int yeptris_wasm_tape_parse(const char *data, size_t len) {
|
|
1054
|
+
if (g_tp_live) { /* defensive: the previous tape was not freed */
|
|
1055
|
+
yeptris_tape_free(&g_tp);
|
|
1056
|
+
g_tp_live = 0;
|
|
1057
|
+
}
|
|
1058
|
+
free(g_tp_buf);
|
|
1059
|
+
g_tp_buf = (char *)malloc(len > 0 ? len : 1);
|
|
1060
|
+
if (g_tp_buf == NULL) {
|
|
1061
|
+
g_tp_buf = NULL;
|
|
1062
|
+
capture_plain("tape allocation failed");
|
|
1063
|
+
return YEPTRIS_ERROR_MEMORY;
|
|
1064
|
+
}
|
|
1065
|
+
if (len > 0) {
|
|
1066
|
+
memcpy(g_tp_buf, data, len);
|
|
1067
|
+
}
|
|
1068
|
+
YeptrisStatus st = yeptris_parse_json_tape(g_tp_buf, len, &g_tp);
|
|
1069
|
+
if (st != YEPTRIS_OK) {
|
|
1070
|
+
capture_error();
|
|
1071
|
+
free(g_tp_buf);
|
|
1072
|
+
g_tp_buf = NULL;
|
|
1073
|
+
return (int)st;
|
|
1074
|
+
}
|
|
1075
|
+
g_tp_live = 1;
|
|
1076
|
+
g_tp_seq++;
|
|
1077
|
+
return YEPTRIS_OK;
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
EMSCRIPTEN_KEEPALIVE
|
|
1081
|
+
unsigned yeptris_wasm_tape_seq(void) { return g_tp_seq; }
|
|
1082
|
+
|
|
1083
|
+
EMSCRIPTEN_KEEPALIVE
|
|
1084
|
+
int yeptris_wasm_tape_count(void) { return g_tp_live ? (int)g_tp.count : 0; }
|
|
1085
|
+
|
|
1086
|
+
EMSCRIPTEN_KEEPALIVE
|
|
1087
|
+
int yeptris_wasm_tape_columns(void) {
|
|
1088
|
+
if (!g_tp_live) {
|
|
1089
|
+
return YEPTRIS_ERROR_ARG;
|
|
1090
|
+
}
|
|
1091
|
+
return yeptris_tape_columns(&g_tp) == 0 ? YEPTRIS_OK : YEPTRIS_ERROR_MEMORY;
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
EMSCRIPTEN_KEEPALIVE
|
|
1095
|
+
const uint8_t *yeptris_wasm_tape_kinds(void) { return g_tp_live ? g_tp.kinds : NULL; }
|
|
1096
|
+
|
|
1097
|
+
EMSCRIPTEN_KEEPALIVE
|
|
1098
|
+
const uint32_t *yeptris_wasm_tape_offs(void) { return g_tp_live ? g_tp.offs : NULL; }
|
|
1099
|
+
|
|
1100
|
+
EMSCRIPTEN_KEEPALIVE
|
|
1101
|
+
const uint32_t *yeptris_wasm_tape_lens(void) { return g_tp_live ? g_tp.lens : NULL; }
|
|
1102
|
+
|
|
1103
|
+
/* Converts the number records in [from, to): ivals/dvals are the
|
|
1104
|
+
* HOST's malloc'd record-index-parallel buffers (the JS door zeroes
|
|
1105
|
+
* them and reads only the number records' slots). A span that refuses
|
|
1106
|
+
* to re-scan as a number answers SIZE_MAX — impossible for a tape
|
|
1107
|
+
* this library produced — and crosses as -1. */
|
|
1108
|
+
EMSCRIPTEN_KEEPALIVE
|
|
1109
|
+
int yeptris_wasm_tape_convert(size_t from, size_t to, int64_t *ivals, double *dvals) {
|
|
1110
|
+
if (!g_tp_live) {
|
|
1111
|
+
return -1;
|
|
1112
|
+
}
|
|
1113
|
+
size_t n = yeptris_tape_convert(&g_tp, from, to, ivals, dvals);
|
|
1114
|
+
return n == (size_t)-1 ? -1 : (int)n;
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
EMSCRIPTEN_KEEPALIVE
|
|
1118
|
+
void yeptris_wasm_tape_free(void) {
|
|
1119
|
+
if (g_tp_live) {
|
|
1120
|
+
yeptris_tape_free(&g_tp);
|
|
1121
|
+
g_tp_live = 0;
|
|
1122
|
+
}
|
|
1123
|
+
free(g_tp_buf);
|
|
1124
|
+
g_tp_buf = NULL;
|
|
1125
|
+
}
|