@lapxo/bound 0.1.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/TARGET.bound +57 -14
- package/assets/wasm/guest.js +4 -0
- package/assets/wasm/manifest.json +27 -0
- package/assets/wasm/runtime.js +6 -0
- package/assets/wasm/runtime.wasm +0 -0
- package/dist/cli/pass.js +3 -3
- package/dist/cli/place.d.ts +2 -0
- package/dist/cli/place.js +7 -4
- package/dist/cli/verb.js +43 -6
- package/dist/engine/index.d.ts +11 -0
- package/dist/engine/index.js +9 -0
- package/dist/engine/object.d.ts +17 -0
- package/dist/engine/object.js +38 -0
- package/dist/fold/closed.d.ts +1 -1
- package/dist/fold/closed.js +22 -5
- package/dist/fold/digests.js +3 -2
- package/dist/fold/object.d.ts +3 -17
- package/dist/fold/object.js +2 -38
- package/dist/fold/resolved.js +1 -1
- package/dist/host/admitted-place.js +4 -1
- package/dist/host/cell-receipts.js +1 -1
- package/dist/host/objects.d.ts +2 -1
- package/dist/host/objects.js +24 -4
- package/dist/host/reading-closures.d.ts +2 -0
- package/dist/host/reading-closures.js +11 -13
- package/dist/host/reference-authenticated.d.ts +28 -0
- package/dist/host/reference-authenticated.js +84 -0
- package/dist/host/reference-native.d.ts +10 -0
- package/dist/host/reference-native.js +50 -0
- package/dist/host/reference-profile.d.ts +23 -0
- package/dist/host/reference-profile.js +62 -0
- package/dist/host/reference.d.ts +6 -0
- package/dist/host/reference.js +24 -0
- package/dist/host/selected-topos.d.ts +1 -1
- package/dist/host/selected-topos.js +9 -1
- package/dist/observe/regions.d.ts +4 -0
- package/dist/observe/regions.js +109 -1
- package/dist/wasm/adapter.d.ts +51 -0
- package/dist/wasm/adapter.js +180 -0
- package/dist/wasm/node-worker.d.ts +1 -0
- package/dist/wasm/node-worker.js +13 -0
- package/dist/wasm/object.d.ts +8 -0
- package/dist/wasm/object.js +76 -0
- package/dist/wasm/worker.d.ts +1 -0
- package/dist/wasm/worker.js +7 -0
- package/docs/contracts/authenticated-reference.publication.json +25 -0
- package/docs/contracts/engine-object-projection.publication.json +25 -0
- package/docs/contracts/engine.md +39 -0
- package/docs/contracts/native-publication.inventory.json +8 -0
- package/docs/contracts/optional-wasm-adapter.publication.json +25 -0
- package/docs/contracts/publication-additions.inventory.json +8 -0
- package/docs/contracts/reference-port.md +33 -0
- package/docs/contracts/reference-port.publication.json +25 -0
- package/licenses/wasm/bound.txt +21 -0
- package/licenses/wasm/fast-text-encoding.txt +201 -0
- package/licenses/wasm/jitl-quickjs-ffi-types.txt +21 -0
- package/licenses/wasm/jitl-quickjs-wasmfile-release-sync.txt +47 -0
- package/licenses/wasm/obligations.txt +21 -0
- package/licenses/wasm/quickjs-emscripten-core.txt +21 -0
- package/licenses/wasm/topos.txt +21 -0
- package/package.json +94 -4
- package/receipts.bound +7672 -613
- package/samples/authenticated-reference/no.json +31 -0
- package/samples/authenticated-reference/yes/editorial-state/TARGET.bound +57 -0
- package/samples/authenticated-reference/yes/editorial-state/inputs/arrival.json +1 -0
- package/samples/authenticated-reference/yes/editorial-state/inputs/coverage.json +1 -0
- package/samples/authenticated-reference/yes/editorial-state/inputs/era.json +1 -0
- package/samples/authenticated-reference/yes/editorial-state/inputs/order.json +1 -0
- package/samples/authenticated-reference/yes/editorial-state/inputs/signature.json +1 -0
- package/samples/authenticated-reference/yes/editorial-state/inputs/transport.arrival.json +1 -0
- package/samples/authenticated-reference/yes/editorial-state/inputs/transport.coverage.json +1 -0
- package/samples/authenticated-reference/yes/editorial-state/inputs/transport.era.json +1 -0
- package/samples/authenticated-reference/yes/editorial-state/inputs/transport.order.json +1 -0
- package/samples/authenticated-reference/yes/editorial-state/inputs/transport.signature.json +1 -0
- package/samples/authenticated-reference/yes/editorial-state/inputs/transport.yes.json +1 -0
- package/samples/authenticated-reference/yes/editorial-state/inputs/yes.json +1 -0
- package/samples/authenticated-reference/yes/weather-reading/TARGET.bound +57 -0
- package/samples/authenticated-reference/yes/weather-reading/inputs/arrival.json +1 -0
- package/samples/authenticated-reference/yes/weather-reading/inputs/coverage.json +1 -0
- package/samples/authenticated-reference/yes/weather-reading/inputs/era.json +1 -0
- package/samples/authenticated-reference/yes/weather-reading/inputs/order.json +1 -0
- package/samples/authenticated-reference/yes/weather-reading/inputs/signature.json +1 -0
- package/samples/authenticated-reference/yes/weather-reading/inputs/transport.arrival.json +1 -0
- package/samples/authenticated-reference/yes/weather-reading/inputs/transport.coverage.json +1 -0
- package/samples/authenticated-reference/yes/weather-reading/inputs/transport.era.json +1 -0
- package/samples/authenticated-reference/yes/weather-reading/inputs/transport.order.json +1 -0
- package/samples/authenticated-reference/yes/weather-reading/inputs/transport.signature.json +1 -0
- package/samples/authenticated-reference/yes/weather-reading/inputs/transport.yes.json +1 -0
- package/samples/authenticated-reference/yes/weather-reading/inputs/yes.json +1 -0
- package/samples/authenticated-reference/yes.json +19 -0
- package/samples/engine-alphabet/TARGET.bound +29 -0
- package/samples/engine-alphabet/inputs/sample.json +323 -0
- package/samples/engine-alphabet/package.json +1 -0
- package/samples/engine-alphabet/reader.js +1457 -0
- package/samples/engine-alphabet/receipts.bound +12 -0
- package/samples/engine-interval/TARGET.bound +29 -0
- package/samples/engine-interval/inputs/sample.json +277 -0
- package/samples/engine-interval/package.json +1 -0
- package/samples/engine-interval/reader.js +1457 -0
- package/samples/engine-interval/receipts.bound +12 -0
- package/samples/no/engine-order/TARGET.bound +29 -0
- package/samples/no/engine-order/inputs/sample.json +277 -0
- package/samples/no/engine-order/package.json +1 -0
- package/samples/no/engine-order/reader.js +1457 -0
- package/samples/reference-port/no/catalog/standing.json +1 -0
- package/samples/reference-port/no/catalog/transport.json +1 -0
- package/samples/reference-port/no/route-notes/standing.json +1 -0
- package/samples/reference-port/no/route-notes/transport.json +1 -0
- package/samples/reference-port/yes/catalog/TARGET.bound +33 -0
- package/samples/reference-port/yes/catalog/standing.json +1 -0
- package/samples/reference-port/yes/catalog/transport.json +1 -0
- package/samples/reference-port/yes/route-notes/TARGET.bound +33 -0
- package/samples/reference-port/yes/route-notes/standing.json +1 -0
- package/samples/reference-port/yes/route-notes/transport.json +1 -0
- package/samples/wasm/editorial-notes/TARGET.bound +65 -0
- package/samples/wasm/editorial-notes/esm.bound +59 -0
- package/samples/wasm/editorial-notes/no-deadline.bound +65 -0
- package/samples/wasm/editorial-notes/no-memory.bound +65 -0
- package/samples/wasm/editorial-notes/no-missing-limit.bound +64 -0
- package/samples/wasm/editorial-notes/receipts.bound +1 -0
- package/samples/wasm/water-level/TARGET.bound +65 -0
- package/samples/wasm/water-level/esm.bound +59 -0
- package/samples/wasm/water-level/no-deadline.bound +65 -0
- package/samples/wasm/water-level/no-memory.bound +65 -0
- package/samples/wasm/water-level/no-missing-limit.bound +64 -0
- package/samples/wasm/water-level/receipts.bound +1 -0
- package/vectors/engine-object.cli.json +548 -0
- package/vectors/native/authenticated-reference-formation.vector.json +53 -0
- package/vectors/native/authenticated-reference.cli.json +157 -0
- package/vectors/native/authenticated-reference.vector.json +440 -0
- package/vectors/reference-port.cli.json +688 -0
- package/vectors/wasm-object.cli.json +452 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var global=globalThis;
|
|
2
|
+
var bt=Object.create;var Re=Object.defineProperty;var xt=Object.getOwnPropertyDescriptor;var kt=Object.getOwnPropertyNames;var Ot=Object.getPrototypeOf,vt=Object.prototype.hasOwnProperty;var Et=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(n){throw t=0,n}};var $t=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of kt(t))!vt.call(e,o)&&o!==n&&Re(e,o,{get:()=>t[o],enumerable:!(r=xt(t,o))||r.enumerable});return e};var Rt=(e,t,n)=>(n=e!=null?bt(Ot(e)):{},$t(t||!e||!e.__esModule?Re(n,"default",{value:e,enumerable:!0}):n,e));var Me=Et(Fe=>{(function(e){"use strict";function t(c,h){var y;return c instanceof Buffer?y=c:y=Buffer.from(c.buffer,c.byteOffset,c.byteLength),y.toString(h)}var n=function(c){return Buffer.from(c)};function r(c){for(var h=0,y=Math.min(256*256,c.length+1),x=new Uint16Array(y),M=[],k=0;;){var g=h<c.length;if(!g||k>=y-1){var E=x.subarray(0,k),v=E;if(M.push(String.fromCharCode.apply(null,v)),!g)return M.join("");c=c.subarray(h),h=0,k=0}var $=c[h++];if(($&128)===0)x[k++]=$;else if(($&224)===192){var P=c[h++]&63;x[k++]=($&31)<<6|P}else if(($&240)===224){var P=c[h++]&63,le=c[h++]&63;x[k++]=($&31)<<12|P<<6|le}else if(($&248)===240){var P=c[h++]&63,le=c[h++]&63,yt=c[h++]&63,B=($&7)<<18|P<<12|le<<6|yt;B>65535&&(B-=65536,x[k++]=B>>>10&1023|55296,B=56320|B&1023),x[k++]=B}}}function o(c){for(var h=0,y=c.length,x=0,M=Math.max(32,y+(y>>>1)+7),k=new Uint8Array(M>>>3<<3);h<y;){var g=c.charCodeAt(h++);if(g>=55296&&g<=56319){if(h<y){var E=c.charCodeAt(h);(E&64512)===56320&&(++h,g=((g&1023)<<10)+(E&1023)+65536)}if(g>=55296&&g<=56319)continue}if(x+4>k.length){M+=8,M*=1+h/c.length*2,M=M>>>3<<3;var v=new Uint8Array(M);v.set(k),k=v}if((g&4294967168)===0){k[x++]=g;continue}else if((g&4294965248)===0)k[x++]=g>>>6&31|192;else if((g&4294901760)===0)k[x++]=g>>>12&15|224,k[x++]=g>>>6&63|128;else if((g&4292870144)===0)k[x++]=g>>>18&7|240,k[x++]=g>>>12&63|128,k[x++]=g>>>6&63|128;else continue;k[x++]=g&63|128}return k.slice?k.slice(0,x):k.subarray(0,x)}var i="Failed to ",l=function(c,h,y){if(c)throw new Error("".concat(i).concat(h,": the '").concat(y,"' option is unsupported."))},s=typeof Buffer=="function"&&Buffer.from,u=s?n:o;function m(){this.encoding="utf-8"}m.prototype.encode=function(c,h){return l(h&&h.stream,"encode","stream"),u(c)};function a(c){var h;try{var y=new Blob([c],{type:"text/plain;charset=UTF-8"});h=URL.createObjectURL(y);var x=new XMLHttpRequest;return x.open("GET",h,!1),x.send(),x.responseText}finally{h&&URL.revokeObjectURL(h)}}var b=!s&&typeof Blob=="function"&&typeof URL=="function"&&typeof URL.createObjectURL=="function",F=["utf-8","utf8","unicode-1-1-utf-8"],p=r;s?p=t:b&&(p=function(c){try{return a(c)}catch{return r(c)}});var w="construct 'TextDecoder'",f="".concat(i," ").concat(w,": the ");function d(c,h){l(h&&h.fatal,w,"fatal"),c=c||"utf-8";var y;if(s?y=Buffer.isEncoding(c):y=F.indexOf(c.toLowerCase())!==-1,!y)throw new RangeError("".concat(f," encoding label provided ('").concat(c,"') is invalid."));this.encoding=c,this.fatal=!1,this.ignoreBOM=!1}d.prototype.decode=function(c,h){l(h&&h.stream,"decode","stream");var y;return c instanceof Uint8Array?y=c:c.buffer instanceof ArrayBuffer?y=new Uint8Array(c.buffer):y=new Uint8Array(c),p(y,this.encoding)},e.TextEncoder=e.TextEncoder||m,e.TextDecoder=e.TextDecoder||d})(typeof window<"u"?window:typeof global<"u"?global:Fe)});var qr=Rt(Me());function Se(e,t="/"){let n=e.split(new RegExp(`[${t.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")}]`)).filter(r=>r!=="");for(;n[n.length-1]==="*"||n[n.length-1]==="**";)n.pop();return n}var A=class e extends Error{code;detail;constructor(t,n,r={}){super(n),this.name="UnitError",this.code=t,this.detail=Object.freeze({...r}),Object.setPrototypeOf(this,e.prototype)}};function q(e,t=0,n=[],r=[]){return{at:Se(e),epoch:t,seen:n,restsOn:r}}function N(e){if(e.widens!==void 0&&e.reach==="travels")throw new A("widening-travels","obligations: REFUSE\xB7widening-travels a widening stands where it was witnessed and never travels to what rests there",{pole:e.pole});return e.takes===void 0?e:{...e,sign:-1}}function j(e){let t=new Set(e.flatMap(n=>n.takes===void 0?[]:[n.takes]));return e.filter(n=>n.takes===void 0&&(n.id===void 0||!t.has(n.id)))}function z(e,t=new Map){let n=e.at.join("/"),r=[],o=new Set,i=[...e.restsOn];for(let l=0;l<i.length;l+=1){let s=i[l];if(s===n)throw new A("rest-cycle",`obligations: REFUSE\xB7rest ${n} rests on itself: an order of rest with a cycle has no fold to reach`,{at:n});o.has(s)||(o.add(s),r.push(s),i.push(...t.get(s)?.restsOn??[]))}return r}function Y(e,t,n=new Map){let r=z(t,n),o=r.flatMap(a=>j(n.get(a)?.marks??[]).filter(b=>b.reach==="travels"&&b.widens===void 0)),i=[...j(t.marks??[]),...o].sort((a,b)=>(a.at??0)-(b.at??0)),l=e.top,s=e.top;for(let a of i)a.pole==="floor"?l=e.meet(l,a.span):s=a.widens===void 0?e.meet(s,a.span):e.join(s,a.span);let u=j(t.seen),m=u.reduce((a,b)=>e.meet(a,b.span),e.top);return{floor:e.meet(l,m),ceiling:e.meet(s,m),origins:u,rest:r,required:l,signed:s}}function ce(e,t,n=new Map){let{floor:r,ceiling:o,origins:i,required:l,signed:s}=Y(e,t,n);return e.inhabited(e.meet(l,s))?new Set(i.map(u=>u.origin)).size<2?"REQUIRED":e.inhabited(i.reduce((u,m)=>e.meet(u,m.span),e.top))?e.inhabited(e.meet(r,o))?"FREE":"FORBIDDEN":"CONFLICT":"CONFLICT"}function fe(e,t,n,r,o){if(r==="")throw new A("join-unwitnessed","obligations: REFUSE\xB7join a widening lands only with a witness or the signatures of whoever rests on the old bound");return{...t,marks:[...t.marks??[],N({pole:"ceiling",reach:"local",span:e.meet(e.top,n),widens:r,...o===void 0?{}:{at:o}})]}}function ue(e,t,n=t.takes===void 0?1:-1){let r=n===1?void 0:t.takes??t.id;if(n===1&&t.takes!==void 0)throw new A("sign-mismatch","obligations: REFUSE\xB7observe a claim that takes another back is observed at \u22121, never at +1");if(n===-1&&r===void 0)throw new A("withdrawal-unnamed","obligations: REFUSE\xB7observe a withdrawal names the claim it takes back, never a value that looks like it");let o=r===void 0?t:{origin:t.origin,span:t.span,sign:-1,takes:r,...t.at===void 0?{}:{at:t.at}};return{...e,epoch:Math.max(e.epoch,t.at??e.epoch),seen:[...e.seen,o]}}function de(e,t,n,r,o={}){let i=t.get(n)??q(n);return new Map([...t,[n,{...i,marks:[...i.marks??[],N({pole:"floor",reach:"travels",span:e.meet(e.top,r),...o})]}]])}function pe(e,t,n,r,o={}){let i=t.get(n)??q(n);return new Map([...t,[n,{...i,marks:[...i.marks??[],N({pole:"ceiling",reach:"travels",span:e.meet(e.top,r),...o})]}]])}function J(e){let t=[],n="";for(let r=0;r<e.length;r++){let o=e[r];if(o==="\\"){let i=e[r+1];if(i!=="|"&&i!=="\\")return null;n+=i,r+=1}else o==="|"?(t.push(n),n=""):n+=o}return t.push(n),t}var G="*",Ae=e=>{if(!/^-?\d+(\.\d+)?$/.test(e))return null;let t=Number(e);return isFinite(t)?t:null};var Ft={interval:e=>{let t=e.indexOf("..");if(t<0)return null;let n=e.slice(0,t),r=e.slice(t+2),o=n===G?null:Ae(n),i=r===G?null:Ae(r);return n!==G&&o===null||r!==G&&i===null?null:{kind:"interval",lo:o,hi:i}},alphabet:e=>{let t=J(e);return t===null?null:{kind:"enumerated",values:t}},ladder:e=>{let t=J(e);return t===null||t.length!==2?null:{kind:"band",floor:t[0]??"",ceiling:t[1]??""}}};var un=Object.keys(Ft);var je=new TextEncoder;function Ie(e,t){let n=je.encode(e),r=je.encode(t);for(let o=0;o<n.length&&o<r.length;o++)if(n[o]!==r[o])return n[o]-r[o];return n.length-r.length}var[X,me,he,hn,gn,wn,yn,Z]=["not:","none","|","=","/","@","*","\\"],Ne=(e,t)=>{throw new Error(`REFUSE\xB7wire ${e}: ${t}`)};function ge(e){if(typeof e!="string"){let o=e.members.map(i=>i.split(Z).join(Z+Z).split(he).join(Z+he)).join(he);return e.polarity==="forbid"?X+o:o.startsWith(X)||o===me?Ne("alphabet","a permitted alphabet neither begins with not: nor is the one word none"):o||me}let t=e.startsWith(X),n=t?e.slice(X.length):e,r=!t&&n===me?[]:J(n)??Ne("alphabet","a backslash escapes only a pipe or itself");return{polarity:t?"forbid":"permit",members:r.filter(o=>o!=="")}}function Mt(e){return e!==""&&!/[\s\\|]/.test(e)&&e.split("/").every(t=>t!==""&&t!=="."&&t!==".."&&t!=="*"&&t!=="**")}function we(e){try{let t=ge(e);if(t.polarity!=="permit"||t.members.some(r=>!Mt(r)))return;let n=[...new Set(t.members)].sort(Ie);return ge({polarity:"permit",members:n})!==e?void 0:n}catch{return}}function Ce(e,t){let n=new Map,r=new Map(e.filter(l=>l.record==="cell").map(l=>[l.fields.scope,l])),o=new Map([...r].map(([l,s])=>[l,t.resolve(s)])),i=new Map(e.map(l=>[l.fields.id,l]));for(let l of[...e].sort((s,u)=>Number(s.fields.epoch)-Number(u.fields.epoch))){let s=l.fields,u=s.scope,m=Number(s.epoch);if(l.record==="cell"){n=new Map([...n,[u,q(u,m,[],we(s.restsOn))]]);continue}let a=o.get(u),b=a.form.lattice(a.params),F=n.get(u);if(l.record==="claim"){let p=s.sign==="-1"?i.get(s.takes).fields:s,w=ue(F,{id:s.id,at:m,origin:p.origin,span:a.form.parse(a.params,p.value),...s.takes?{takes:s.takes}:{}},s.sign==="-1"?-1:1),f=[...w.seen];f[f.length-1]={...f.at(-1),id:s.id},n=new Map([...n,[u,{...w,seen:f}]])}else if(s.sign==="-1"){let p=i.get(s.takes).fields;n=new Map([...n,[u,{...F,marks:[...F.marks??[],N({id:s.id,at:m,takes:s.takes,pole:p.pole,reach:"local",span:a.form.parse(a.params,p.value)})]}]])}else if(s.widens!==void 0){let p=fe(b,F,a.form.parse(a.params,s.value),s.widens,m),w=[...p.marks??[]];w[w.length-1]={...w.at(-1),id:s.id},n=new Map([...n,[u,{...p,marks:w}]])}else{let p=a.form.parse(a.params,s.value);n=s.pole==="floor"?de(b,n,u,p,{id:s.id,at:m}):pe(b,n,u,p,{id:s.id,at:m})}}return[...n].map(([l,s])=>{let u=o.get(l),m=u.form.lattice(u.params);return{cell:l,state:ce(m,s,n),parts:Y(m,s,n),rest:z(s,n),ownMarks:j(s.marks??[]).map(a=>a.id),ownClaims:j(s.seen).map(a=>({id:a.id,origin:a.origin})),marks:j(s.marks??[]),claims:j(s.seen)}})}var I=class e extends Error{code;detail;constructor(t,n,r={}){super(n),this.name="UnitError",this.code=t,this.detail=Object.freeze({...r}),Object.setPrototypeOf(this,e.prototype)}};function Te(e,t,n){let r=e.length;for(let f=0;f<r;f++)if(e.indexOf(e[f])!==f)throw new I("DUPLICATE_LEVEL",`the level \`${e[f]}\` is declared twice`,{level:e[f]});let o=new Map(e.map((f,d)=>[f,d])),i=(f,d)=>t[f][d]===d,l=e.every((f,d)=>e.every((c,h)=>t[d][h]===d||t[d][h]===h)),s=!0;for(let f=0;f<r&&s;f++)for(let d=0;d<r&&s;d++)for(let c=0;c<r;c++)if(n[f][t[d][c]]!==t[n[f][d]][n[f][c]]){s=!1;break}let u=[...e.keys()],m=u.find(f=>u.every(d=>i(f,d)))??0,a=u.find(f=>u.every(d=>i(d,f)))??r-1,b=u.filter(f=>f!==m&&u.filter(d=>d!==f&&i(d,f)).reduce((d,c)=>t[d][c],m)!==f),F=u.filter(f=>f!==a&&u.filter(d=>d!==f&&i(f,d)).reduce((d,c)=>n[d][c],a)!==f),p=new Set,w=[];for(let f of[...b,...F])p.has(f)||(p.add(f),w.push(f));return{levels:e,isLadder:l,isSimple:s,bottomIx:m,topIx:a,bottom:e[m],top:e[a],leq:i,higher:(f,d)=>t[f][d],lower:(f,d)=>n[f][d],rank(f){let d=o.get(f);if(d===void 0)throw new I("UNKNOWN_LEVEL",`no level \`${f}\` in this scale`,{level:f,levels:e});return d},stateOf(f,d){return i(f,d)?f!==m?"REQUIRED":d!==a?"FORBIDDEN":"FREE":"CONFLICT"},joins:()=>b.slice(),limits:()=>F.slice(),debits:()=>w.slice(),intervalHeight(f,d){if(!i(f,d))return null;let c=u.filter(g=>i(f,g)&&i(g,d)),h=g=>c.filter(E=>E!==g&&i(g,E)&&!c.some(v=>v!==g&&v!==E&&i(g,v)&&i(v,E))),y=new Map([[f,0]]),x=new Map([[f,0]]),M=[...c].sort((g,E)=>c.filter(v=>i(v,g)).length-c.filter(v=>i(v,E)).length);for(let g of M){let E=y.get(g),v=x.get(g);if(!(E===void 0||v===void 0))for(let $ of h(g))y.set($,Math.max(y.get($)??E+1,E+1)),x.set($,Math.min(x.get($)??v+1,v+1))}let k=y.get(d);return k!==void 0&&k===x.get(d)?k:null}}}function ye(e){if(!Array.isArray(e)||e.length===0)throw new I("EMPTY_CHAIN","a chain needs at least one level");let t=e.length,n=r=>[...Array(t)].map((o,i)=>[...Array(t)].map((l,s)=>r(i,s)));return Te(e,n(Math.max),n(Math.min))}function qe(e,t){if(!Array.isArray(e)||e.length===0)throw new I("EMPTY_CHAIN","an order needs at least one level");let n=e.length,r=(i,l,s)=>{let u=[...Array(n).keys()].filter(a=>s?t[i][a]&&t[l][a]:t[a][i]&&t[a][l]),m=u.filter(a=>u.every(b=>s?t[a][b]:t[b][a]));if(m.length!==1)throw new I("MALFORMED",`\`${e[i]}\` and \`${e[l]}\` have ${m.length} ${s?"lowest common":"highest common"} bounds, so this is not a usable scale`,{levels:[e[i],e[l]]});return m[0]},o=i=>[...Array(n)].map((l,s)=>[...Array(n)].map((u,m)=>r(s,m,i)));return Te(e,o(!0),o(!1))}function St(e,t){return{subject:e,floor:t.floor,ceiling:t.ceiling}}var be=(e,t)=>St(t,{floor:e.bottom,ceiling:e.top});function Ue(e,t){return e.stateOf(e.rank(t.floor),e.rank(t.ceiling))}function At(e,t,n,r,o){let i=n.floor,l=n.ceiling;for(let s of t)i=r(i,e.rank(s.floor)),l=o(l,e.rank(s.ceiling));return{subject:t[0].subject,floor:e.levels[i],ceiling:e.levels[l]}}function Be(e,t){return t.length===0?be(e,""):At(e,t,{floor:e.bottomIx,ceiling:e.topIx},(n,r)=>e.higher(n,r),(n,r)=>e.lower(n,r))}function De(e,t,n){let[r,o]=[e.rank(t.floor),e.rank(t.ceiling)],[i,l]=[e.rank(n.floor),e.rank(n.ceiling)];return e.leq(i,r)&&e.leq(o,l)}var Le=32;function We(e){return e<=0?0:Math.ceil(e/Le)}var S=class e{words;width;constructor(t,n){this.width=t,this.words=n??new Uint32Array(We(t))}static fromTokens(t,n){let r=new e(t.length);return t.forEach((o,i)=>{n.has(o)&&r.set(i)}),r}set(t){if(t<0||t>=this.width)throw new I("MALFORMED",`bit ${t} is outside a mask of width ${this.width}`,{bit:t,width:this.width});this.words[t>>5]|=1<<(t&31)}has(t){return t<0||t>=this.width?!1:(this.words[t>>5]&1<<(t&31))!==0}and(t){let n=Math.max(this.width,t.width),r=new e(n),o=Math.min(this.words.length,t.words.length);for(let i=0;i<o;i++)r.words[i]=this.words[i]&t.words[i];return r}or(t){let n=Math.max(this.width,t.width),r=new e(n);for(let o=0;o<r.words.length;o++)r.words[o]=(this.words[o]??0)|(t.words[o]??0);return r}difference(t){let n=Math.max(this.width,t.width),r=new e(n);for(let i=0;i<r.words.length;i++)r.words[i]=(this.words[i]??0)&~(t.words[i]??0);let o=n%32;return o!==0&&r.words.length>0&&(r.words[r.words.length-1]&=(1<<o)-1),r}subsetOf(t){let n=Math.max(this.words.length,t.words.length);for(let r=0;r<n;r++){let o=this.words[r]??0,i=t.words[r]??0;if((o&~i)!==0)return!1}return!0}size(){let t=0;for(let n=0;n<this.width;n++)this.has(n)&&t++;return t}members(t){return t.filter((n,r)=>this.has(r))}static filled(t){let n=new e(t);if(t<=0)return n;n.words.fill(4294967295);let r=t%32;return r!==0&&(n.words[n.words.length-1]=(1<<r)-1),n}};function xe(e){let t=n=>Ue(e,n)!=="CONFLICT";return{top:be(e,""),bottom:{subject:"",floor:e.levels[e.topIx]??"",ceiling:e.levels[e.bottomIx]??""},leq:(n,r)=>De(e,n,r),meet:(n,r)=>Be(e,[n,r]),join:(n,r)=>t(n)?t(r)?{subject:n.subject||r.subject,floor:e.levels[e.lower(e.rank(n.floor),e.rank(r.floor))]??n.floor,ceiling:e.levels[e.higher(e.rank(n.ceiling),e.rank(r.ceiling))]??n.ceiling}:n:r,show:n=>`[${n.floor}, ${n.ceiling}]`,inhabited:t}}function _e(e){return{bottom:new S(e.length),top:S.filled(e.length),leq:(t,n)=>t.subsetOf(n),meet:(t,n)=>t.and(n),join:(t,n)=>t.or(n),show:t=>t.members(e).join(","),inhabited:t=>t.size()>0}}function K(e,t){let n=Math.min(e,t),r=Math.max(e,t);return{bottom:{lo:r,hi:n},top:{lo:n,hi:r},leq(o,i){return o.lo>o.hi?!0:i.lo>i.hi?!1:i.lo<=o.lo&&o.hi<=i.hi},meet(o,i){return{lo:Math.max(o.lo,i.lo),hi:Math.min(o.hi,i.hi)}},join(o,i){return o.lo>o.hi?i:i.lo>i.hi?o:{lo:Math.min(o.lo,i.lo),hi:Math.max(o.hi,i.hi)}},show(o){return o.lo>o.hi?"empty":`${o.lo}..${o.hi}`},inhabited(o){return o.lo<=o.hi}}}function ee(e){let t={lattice:e.lattice,parse:e.parse,emit:e.emit,count:e.count,show:e.show,points:e.points},n=Object.entries(t).find(([,r])=>typeof r!="function");if(n)throw new Error(`form \`${e.id}\` declared no ${n[0]}`);return e}var R=e=>e!==null&&typeof e=="object"?e:{};function C(e){return Array.isArray(e)?e.map(String):[]}var ke=e=>{let t=e>>>0;return()=>{t=t+1831565813>>>0;let n=Math.imul(t^t>>>15,t|1);return n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}},Pe=(e,t)=>t[Math.floor(e()*t.length)];function jt(e,t){if(e.length===0)return{kind:"refused",why:"a ladder with no levels cannot be counted"};let n=ye(e),r=n.rank(t.floor),o=n.rank(t.ceiling);return n.leq(r,o)?{kind:"finite",n:e.filter((l,s)=>n.leq(r,s)&&n.leq(s,o)).length}:{kind:"finite",n:0}}var ze={parse(e,t){let n=this.lattice(e),r=R(t);return{subject:String(r.subject??""),floor:String(r.floor??n.top.floor),ceiling:String(r.ceiling??n.top.ceiling)}},emit(e,t){return{subject:t.subject,floor:t.floor,ceiling:t.ceiling}},count(e,t){return jt(C(R(t).levels),e)},points(e,t,n){let r=this.lattice(e),o=C(R(e).levels),i=ke(t),l=(s,u)=>({subject:"",floor:s,ceiling:u});return Array.from({length:n},()=>{let[s,u]=[Pe(i,o),Pe(i,o)];return[l(s,u),l(u,s)].find(m=>r.inhabited(m))??l(s,s)})}},Ke=ee({id:"ladder",lattice(e){let t=C(R(e).levels);if(t.length===0)throw new Error("ladder needs levels");return xe(ye(t))},...ze,show(e){return e.floor===e.ceiling?e.floor:`${e.floor}..${e.ceiling}`}}),D=ee({id:"alphabet",lattice(e){return _e(C(R(e).tokens))},parse(e,t){let n=C(R(e).tokens),r=R(t),o=r.want!==void 0?C(r.want):n;return S.fromTokens(n,new Set(o))},emit(e,t){return{want:t.members(C(R(e).tokens))}},count(e){return{kind:"finite",n:e.size()}},show(e){return`${e.size()}`},points(e,t,n){let r=C(R(e).tokens),o=ke(t);return Array.from({length:n},()=>S.fromTokens(r,new Set(r.filter(()=>o()<.5))))}}),L=ee({id:"continuous",lattice(e){let t=R(e);return K(Number(t.lo??0),Number(t.hi??1))},parse(e,t){let n=this.lattice(e),r=R(t);return{lo:r.lo===void 0?n.top.lo:Number(r.lo),hi:r.hi===void 0?n.top.hi:Number(r.hi)}},emit(e,t){return{lo:t.lo,hi:t.hi}},count(){return{kind:"refused",why:"a continuous band has no count; prefer not to exist over inventing one"}},show(e){return e.lo>e.hi?"empty":`${e.lo}..${e.hi}`},points(e,t,n){let r=R(e),o=Number(r.lo??0),i=Number(r.hi??1),l=ke(t),s=()=>o+Math.round(l()*(i-o));return Array.from({length:n},()=>({lo:s(),hi:s()}))}}),He=ee({id:"lattice",lattice(e){let t=R(e),n=C(t.levels),r=t.leq;if(n.length&&r)return xe(qe(n,r));throw new Error("lattice needs levels+leq")},...ze,show(e){return`${e.floor}..${e.ceiling}`}}),Qe=[Ke,D,L,He],It=[...Qe];function W(e){let t=[],n="";for(let r=0;r<e.length;r++){let o=e[r];if(o==="\\"){let i=e[r+1];if(i!=="|"&&i!=="\\")return null;n+=i,r+=1}else o==="|"?(t.push(n),n=""):n+=o}return t.push(n),t}var te="*",Ve=e=>{if(!/^-?\d+(\.\d+)?$/.test(e))return null;let t=Number(e);return isFinite(t)?t:null};function Ye(e){if(!isFinite(e))throw new Error(`REFUSE\xB7wire decimal: \`${e}\` is not a finite number`);let t=/^(-?)(\d)(?:\.(\d+))?e([+-])(\d+)$/.exec(String(e));if(t===null)return String(e);let[,n="",r="",o="",i="",l="0"]=t;return i==="+"?`${n}${r}${o}${"0".repeat(Number(l)-o.length)}`:`${n}0.${"0".repeat(Number(l)-1)}${r}${o}`}var Ge={interval:e=>{let t=e.indexOf("..");if(t<0)return null;let n=e.slice(0,t),r=e.slice(t+2),o=n===te?null:Ve(n),i=r===te?null:Ve(r);return n!==te&&o===null||r!==te&&i===null?null:{kind:"interval",lo:o,hi:i}},alphabet:e=>{let t=W(e);return t===null?null:{kind:"enumerated",values:t}},ladder:e=>{let t=W(e);return t===null||t.length!==2?null:{kind:"band",floor:t[0]??"",ceiling:t[1]??""}}};function ne(e,t,n){let r=Array.isArray(n)?n.find(o=>o.form===e):void 0;return r?r.parse(t):Ge[e]?.(t)??null}var Je=Object.keys(Ge),Xe=["within","copies","derives"];var[re,Oe,ve,Xn,Zn,er,tr,oe]=["not:","none","|","=","/","@","*","\\"],Ze=(e,t)=>{throw new Error(`REFUSE\xB7wire ${e}: ${t}`)};function U(e){if(typeof e!="string"){let o=e.members.map(i=>i.split(oe).join(oe+oe).split(ve).join(oe+ve)).join(ve);return e.polarity==="forbid"?re+o:o.startsWith(re)||o===Oe?Ze("alphabet","a permitted alphabet neither begins with not: nor is the one word none"):o||Oe}let t=e.startsWith(re),n=t?e.slice(re.length):e,r=!t&&n===Oe?[]:W(n)??Ze("alphabet","a backslash escapes only a pipe or itself");return{polarity:t?"forbid":"permit",members:r.filter(o=>o!=="")}}var _=e=>({kind:"fact",value:e}),T=e=>({kind:"abstain",why:e}),O=(e,t)=>({kind:"refuse",why:e,...t===void 0?{}:{named:t}});var Ee="bound-lock/1",tt=/[ ="\n\\]/;function Nt(e){return tt.test(e)?`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n")}"`:e}function Ct(e){if(!e.startsWith('"'))return tt.test(e)?null:e;if(e.length<2||!e.endsWith('"'))return null;let t=e.slice(1,-1),n="";for(let r=0;r<t.length;r++){let o=t[r];if(o!=="\\"){if(o==='"')return null;n+=o;continue}let i=t[r+1];if(i==='"')n+='"';else if(i==="\\")n+="\\";else if(i==="n")n+=`
|
|
3
|
+
`;else return null;r+=1}return n}var et=new TextEncoder;function H(e,t){let n=et.encode(e),r=et.encode(t);for(let o=0;o<n.length&&o<r.length;o++)if(n[o]!==r[o])return n[o]-r[o];return n.length-r.length}var nt=e=>e.form==="interval"&&e.value!==void 0&&e.value!=="withdraw"&&ne("interval",e.value)===null;function rt(e,t="1"){if(nt(e))throw new Error(`REFUSE\xB7wire canonical: \`${e.value}\` is no interval the wire writes: two ends, each decimal or *`);let r=Object.keys(e).sort(H).map(o=>`${o}=${Nt(e[o])}`);return[`${Ee.split("/")[0]}/${t}`,...r].join(" ")}var Tt="-";function ot(e,t={}){if(e.includes(`
|
|
4
|
+
`))return O("a line is one line \u2014 a newline in a value must be escaped as `\\n`");let n=e.indexOf(" "),r=n===-1?e:e.slice(0,n),[o,i]=r.split("/");if(o!==Ee.split("/")[0]||!i)return O(`no \`bound-lock/<v>\` envelope \u2014 found \`${r.slice(0,24)}\``);if(i!==Ee.split("/")[1])return T(`\`bound-lock/${i}\` is a version this reader does not know`);let l={},s=new Set;for(let u of qt(n===-1?"":e.slice(n+1))){if(u===null)return O("a quoted value is not closed");let m=u.indexOf("=");if(m<=0)return O(`\`${u.slice(0,24)}\` is not \`key=value\``);let a=u.slice(0,m);if(s.has(a))return O(`\`${a}\` appears twice \u2014 one line, one value per key`);s.add(a);let b=Ct(u.slice(m+1));if(b===null)return O(`\`${a}\` has an escaping this format does not define`);b!==Tt&&(l[a]=b)}return nt(l)?O(`\`${l.value}\` is no interval the wire reads: two ends, each decimal or *`):_({version:i,fields:l,...t.preserveKeys?{keys:[...s]}:{}})}function*qt(e){let t=0;for(;t<e.length;){for(;e[t]===" ";)t+=1;if(t>=e.length)return;let n=t,r=!1;for(;n<e.length&&(r||e[n]!==" ");)e[n]==="\\"&&r?n+=1:e[n]==='"'&&(r=!r),n+=1;if(r){yield null;return}yield e.slice(t,n),t=n}}function it(e){return e!==""&&!/[\s\\|]/.test(e)&&e.split("/").every(t=>t!==""&&t!=="."&&t!==".."&&t!=="*"&&t!=="**")}function Ut(e){try{let t=U(e);if(t.polarity!=="permit"||t.members.some(r=>!it(r)))return;let n=[...new Set(t.members)].sort(H);return U({polarity:"permit",members:n})!==e?void 0:n}catch{return}}var Bt=["type","scope","id","epoch","by","sig"];function st(e,t,n,r,o){let i=(a,b)=>O(a,b);if(t.includes("at"))return i("object records carry no at: order is epoch and a local join witness is widens","at");let l=e.type;if(!n.types.has(l??"")||!["cell","claim","mark"].includes(l??""))return i("an object record names a declared type: cell, claim or mark","type");if(!/^(0|[1-9][0-9]*)$/.test(e.epoch??"")||!Number.isSafeInteger(Number(e.epoch)))return i("an object record carries an exactly supported logical epoch","epoch");if(Number(e.epoch)<n.activation)return i(`an object epoch precedes typed-wire activation ${n.activation}`,"epoch");let s;if(l==="cell")s="cell";else if(e.sign==="-1")s=`${l}/negative`;else{if(e.sign!=="+1")return i("a claim or mark names sign=+1 or sign=-1","sign");if(l==="claim")s="claim/positive";else if(e.pole==="floor"&&e.reach==="travels"&&e.widens===void 0)s="mark/floor-travelling";else if(e.pole==="ceiling"&&e.reach==="travels"&&e.widens===void 0)s="mark/travelling";else if(e.pole==="ceiling"&&e.reach==="local")s="mark/local";else return i("a positive mark is ceiling/travels, ceiling/local with widens, or floor/travels without widens","pole")}let u=n.required.get(s),m=n.allowed.get(s);if(!u||!m||n.common.size===0||n.configuration.size===0||[...n.common].some(a=>!u.has(a)||!m.has(a))||[...u].some(a=>!m.has(a)))return i(`typed wire has no complete required/allowed contract for ${s}`,"type");for(let a of Bt)if(e[a]===void 0||e[a]==="")return i(`an object record has no ${a}`,a);for(let a of t)if(!r.has(a)||!m.has(a))return i(`\`${a}=\` is not allowed on ${s}`,a);for(let a of u)if(!m.has(a)||e[a]===void 0||e[a]==="")return i(`a ${s} record has no declared required \`${a}\``,a);if(!it(e.scope))return i("scope is a canonical cell coordinate","scope");if(l==="cell"){if(!o.has(e.form))return i("the cell names no admitted form","form");if(Ut(e.restsOn)===void 0)return i("cell restsOn is none or a canonical alphabet of coordinates","restsOn")}return _({record:l,fields:{...e}})}function at(e){let t=e.lastIndexOf(":");return t<=0||t===e.length-1?null:{algorithm:e.slice(0,t),raw:e.slice(t+1)}}var lt="withdraw";function se(e,t){let n=e.indexOf(":");return n>0&&t.digests.has(e.slice(0,n))&&/^[0-9a-f]+$/i.test(e.slice(n+1))}function Dt(e){if(e.startsWith("/")||/[\s\\]/.test(e))return!1;let t=e.split("/").filter(n=>n!=="");return t.length>0&&t.every((n,r)=>n!=="."&&n!==".."&&(!n.includes("*")||r===t.length-1))}var ct={region:e=>e.split("|").filter(Boolean).every(Dt),class:(e,t)=>{let n=e.indexOf(":");if(n<=0||!t.classes.has(e.slice(0,n)))return!1;let r=e.slice(n+1);return!/^[a-z0-9-]+:[0-9a-f]{16,}$/i.test(r)||se(r,t)},signature:(e,t)=>{let n=at(e);if(n===null||!t.signatures.has(n.algorithm))return!1;let r=n.algorithm.slice(n.algorithm.lastIndexOf(":")+1);return se(n.algorithm,t)||n.algorithm.includes(":")&&(t.lists.get("era")?.has(r)??!1)},count:e=>/^\d+$/.test(e)};function ie(e,t){return O(t,e)}function ft(e,t,n){let r=ot(e,{preserveKeys:!0});if(r.kind!=="fact")return r.kind==="abstain"?T(r.why):O(r.why,r.named);let o=r.value.fields,i=r.value.keys;if(i.includes("type")){if(!t?.object)return O("typed object grammar is not admitted at this epoch","type");if(!t.object.configuration.size||!t.object.reserved.size||[...t.object.reserved].some(w=>t.object.configuration.has(w)))return O("typed wire has no closed configuration/object field contract","type");let p=st(o,i,t.object,t.fields,t.forms);return p.kind!=="fact"?p:ct.signature(o.sig,t)?p.value.record==="cell"&&!se(o.topos,t)?O("cell topos is not an admitted digest","topos"):p.value.record==="cell"&&(o.restsOn??"").split("|").some(w=>se(w,t))?O("cell restsOn names coordinates, not byte digests","restsOn"):p:O("object signature grammar is not admitted","sig")}if(t){if(t.object){if(!t.object.configuration.size||!t.object.reserved.size||[...t.object.reserved].some(w=>t.object.configuration.has(w)))return O("typed wire has no closed configuration/object field contract","type");let p=i.find(w=>t.object.reserved.has(w)||!t.object.configuration.has(w));if(p)return O(`\`${p}=\` is an object-only field: untyped configuration cannot carry it`,p)}for(let p of Object.keys(o))if(!t.fields.has(p))return ie(p,`\`${p}=\` is not a field of the wire at epoch ${t.epoch}`);for(let p of t.required)if(o[p]===void 0)return ie(p,`a claim with no \`${p}\``);for(let[p,w]of t.formOf){let f=o[p];if(f===void 0)continue;let d=t.lists.get(w),c=ct[w]??(d?h=>d.has(h):void 0);if(!c)return T(`\`${p}\` takes the form ${w}, which this reader does not know`);if(!c(f,t))return ie(p,`\`${p}=${f}\` is not a ${w} of the wire at epoch ${t.epoch}`)}if(o.role!==void 0&&!t.roles.has(o.role))return T(`\`role=${o.role}\` is a role this wire does not name`);if(!t.forms.has(o.form??""))return T(`\`form=${o.form}\` is a form this wire does not name`)}let l=Array.isArray(n)?n:void 0,s=o.value===lt?{kind:"enumerated",values:[lt]}:ne(o.form??"",o.value??"",l);if(s===null)return Je.includes(o.form??"")||(l?.some(w=>w.form===o.form)??!1)?ie("value",`\`${o.value}\` is not a ${o.form}`):T(`\`form=${o.form}\` is a form this reader does not know`);let u=o.role==="writes"?"writes":o.role==="demands"?"demands":"reads",m={};for(let[p,w]of Object.entries(o))["scope","measure","form","value","by","at","role","unit","multiplicity","epoch","ref","to","ref_by"].includes(p)||(m[p]=w);let a=o.ref,b=o.to===void 0?null:W(o.to),F=a&&b&&Xe.includes(a)?{rel:a,to:b,by:o.ref_by==="declared"?"declared":"inferred"}:null;return _({scope:o.scope??"",measure:o.measure??"",bound:s,role:u,by:o.by??"",at:o.at??"",...o.unit!==void 0?{unit:o.unit}:{},...o.multiplicity==="one"||o.multiplicity==="many"||o.multiplicity==="unknown"?{multiplicity:o.multiplicity}:{},...o.epoch!==void 0?{epoch:o.epoch}:{},...F?{reference:F}:{},extra:m})}var yr=K(-1/0,1/0),br=K(1,1/0);var ut=e=>e!==null&&typeof e=="object"?e:{};function Q(e,t){throw new Error(`REFUSE\xB7form ${e}: ${t}`)}function $e(e,t,n){let r=ut(t)[n];return(typeof r!="number"||!isFinite(r))&&Q(e,`takes ${n} as a number, and a value it is not given is not invented`),r}function dt(e,t,n){let r=ut(t)[n];return(!Array.isArray(r)||!r.length||r.some(o=>typeof o!="string"))&&Q(e,`takes ${n} as a list of words`),r}var pt=e=>U({polarity:"permit",members:[...new Set(e)].sort(H)});function mt(e,t,n){if(n==="empty")return{lo:t.hi,hi:t.lo};let r=o=>(i=>i.kind==="fact"&&i.value.bound.kind==="interval"?{lo:i.value.bound.lo??t.lo,hi:i.value.bound.hi??t.hi}:void 0)(ft(rt({form:"interval",value:o}),null));return r(n)??r(`${n}..${n}`)??Q(e,`\`${n}\` is not a band: lo..hi or one end, each a number or *`)}var ht=e=>(t=>e.lo>e.hi?"empty":`${t(e.lo)}..${t(e.hi)}`)(t=>isFinite(t)?Ye(t):"*");var V=e=>({tokens:dt("alphabet",e,"tokens")}),gt={id:"alphabet",lattice:e=>D.lattice(V(e)),parse(e,t){let{tokens:n}=V(e),r=U(t),o=r.members.find(i=>!n.includes(i));return o!==void 0&&Q("alphabet",`\`${o}\` is not one of its tokens`),S.fromTokens(n,new Set(r.polarity==="forbid"?n.filter(i=>!r.members.includes(i)):r.members))},emit:(e,t)=>pt(t.members(V(e).tokens)),show:(e,t)=>D.lattice(V(e)).show(t),points:(e,t,n)=>D.points(V(e),t,n)};var ae=e=>({lo:$e("interval",e,"lo"),hi:$e("interval",e,"hi")}),wt={id:"interval",lattice:e=>L.lattice(ae(e)),parse:(e,t)=>mt("interval",ae(e),t),emit:(e,t)=>ht(t),show:(e,t)=>L.lattice(ae(e)).show(t),points:(e,t,n)=>L.points(ae(e),t,n)};export{gt as alphabetOfForm,wt as intervalForm,Ce as objectFold};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"profile": "bound-wasm-assets-proposed@1",
|
|
3
|
+
"runtime": "sha256:78daa39ad957affb2423846cf0e6754c4ed9e729829db84e58b25b3b241336e7",
|
|
4
|
+
"wasm": "sha256:105c3bed22d457e43e3d1c3c1c6959fda62a8fe06f0fc8a985303c3a2be72232",
|
|
5
|
+
"modules": {
|
|
6
|
+
"/bound/guest.js": "sha256:4a8cef02c4027ca2bd35aa2810f3c56ddd9884e8f245ede48d01f020f70e00f3"
|
|
7
|
+
},
|
|
8
|
+
"byteLengths": {
|
|
9
|
+
"runtime": 51308,
|
|
10
|
+
"wasm": 503134,
|
|
11
|
+
"modules": {
|
|
12
|
+
"/bound/guest.js": 29909
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"forms": {
|
|
16
|
+
"sha256:13ee36d217833cb78bc180a62303e3335f4f1020d120914d1ef7d674ae38f67e": {
|
|
17
|
+
"form": "interval",
|
|
18
|
+
"export": "intervalForm",
|
|
19
|
+
"contextArtifact": "sha256:04942f6938e4e4ca1ff25257347df3d124d3f9dd554c3fe8b85e8eb31338b891"
|
|
20
|
+
},
|
|
21
|
+
"sha256:7ca38123f88692b8c38cb7673fc1885d3324bd1b8558113173b4add055b06d28": {
|
|
22
|
+
"form": "alphabet",
|
|
23
|
+
"export": "alphabetOfForm",
|
|
24
|
+
"contextArtifact": "sha256:04942f6938e4e4ca1ff25257347df3d124d3f9dd554c3fe8b85e8eb31338b891"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
var _t=Object.defineProperty;var se=(e,r,t)=>()=>{if(t)throw t[0];try{return e&&(r=e(e=0)),r}catch(i){throw t=[i],i}};var yt=(e,r)=>{for(var t in r)_t(e,t,{get:r[t],enumerable:!0})};var L,oe,z,J,D,W=se(()=>{L={JS_EVAL_TYPE_GLOBAL:0,JS_EVAL_TYPE_MODULE:1,JS_EVAL_TYPE_DIRECT:2,JS_EVAL_TYPE_INDIRECT:3,JS_EVAL_TYPE_MASK:3,JS_EVAL_FLAG_STRICT:8,JS_EVAL_FLAG_STRIP:16,JS_EVAL_FLAG_COMPILE_ONLY:32,JS_EVAL_FLAG_BACKTRACE_BARRIER:64},oe={BaseObjects:1,Date:2,Eval:4,StringNormalize:8,RegExp:16,RegExpCompiler:32,JSON:64,Proxy:128,MapSet:256,TypedArrays:512,Promise:1024,BigInt:2048,BigFloat:4096,BigDecimal:8192,OperatorOverloading:16384,BignumExt:32768},z={Pending:0,Fulfilled:1,Rejected:2},J={JS_GPN_STRING_MASK:1,JS_GPN_SYMBOL_MASK:2,JS_GPN_PRIVATE_MASK:4,JS_GPN_ENUM_ONLY:16,JS_GPN_SET_ENUM:32,QTS_GPN_NUMBER_MASK:64,QTS_STANDARD_COMPLIANT_NUMBER:128},D={IsStrictlyEqual:0,IsSameValue:1,IsSameValueZero:2}});function V(...e){ce&&console.log("quickjs-emscripten:",...e)}function*Ke(e){return yield e}function xt(e){return Ke(fe(e))}function Ce(e,r){return(...t)=>{let i=r.call(e,de,...t);return fe(i)}}function Pt(e,r){let t=r.call(e,de);return fe(t)}function fe(e){function r(t){return t.done?t.value:t.value instanceof Promise?t.value.then(i=>r(e.next(i)),i=>r(e.throw(i))):r(e.next(t.value))}return r(e.next())}function ue(e,r){let t;try{e.dispose()}catch(i){t=i}if(r&&t)throw Object.assign(r,{message:`${r.message}
|
|
2
|
+
Then, failed to dispose scope: ${t.message}`,disposeError:t}),r;if(r||t)throw r||t}function Mt(e){let r=e?Array.from(e):[];function t(){return r.forEach(u=>u.alive?u.dispose():void 0)}function i(){return r.some(u=>u.alive)}return Object.defineProperty(r,he,{configurable:!0,enumerable:!1,value:t}),Object.defineProperty(r,"dispose",{configurable:!0,enumerable:!1,value:t}),Object.defineProperty(r,"alive",{configurable:!0,enumerable:!1,get:i}),r}function Y(e){return!!(e&&(typeof e=="object"||typeof e=="function")&&"alive"in e&&typeof e.alive=="boolean"&&"dispose"in e&&typeof e.dispose=="function")}function kt(e){if(!e)return 0;let r=0;for(let[t,i]of Object.entries(e)){if(!(t in oe))throw new We(t);i&&(r|=oe[t])}return r}function It(e){if(typeof e=="number")return e;if(e===void 0)return 0;let{type:r,strict:t,strip:i,compileOnly:u,backtraceBarrier:a}=e,l=0;return r==="global"&&(l|=L.JS_EVAL_TYPE_GLOBAL),r==="module"&&(l|=L.JS_EVAL_TYPE_MODULE),t&&(l|=L.JS_EVAL_FLAG_STRICT),i&&(l|=L.JS_EVAL_FLAG_STRIP),u&&(l|=L.JS_EVAL_FLAG_COMPILE_ONLY),a&&(l|=L.JS_EVAL_FLAG_BACKTRACE_BARRIER),l}function Lt(e){if(typeof e=="number")return e;if(e===void 0)return 0;let{strings:r,symbols:t,quickjsPrivate:i,onlyEnumerable:u,numbers:a,numbersAsStrings:l}=e,m=0;return r&&(m|=J.JS_GPN_STRING_MASK),t&&(m|=J.JS_GPN_SYMBOL_MASK),i&&(m|=J.JS_GPN_PRIVATE_MASK),u&&(m|=J.JS_GPN_ENUM_ONLY),a&&(m|=J.QTS_GPN_NUMBER_MASK),l&&(m|=J.QTS_STANDARD_COMPLIANT_NUMBER),m}function Jt(...e){let r=[];for(let t of e)t!==void 0&&(r=r.concat(t));return r}function ae(e){return e>>8}function we(e,r){r.interruptHandler&&e.setInterruptHandler(r.interruptHandler),r.maxStackSizeBytes!==void 0&&e.setMaxStackSize(r.maxStackSizeBytes),r.memoryLimitBytes!==void 0&&e.setMemoryLimit(r.memoryLimitBytes)}function _e(e,r){r.moduleLoader&&e.setModuleLoader(r.moduleLoader),r.shouldInterrupt&&e.setInterruptHandler(r.shouldInterrupt),r.memoryLimitBytes!==void 0&&e.setMemoryLimit(r.memoryLimitBytes),r.maxStackSizeBytes!==void 0&&e.setMaxStackSize(r.maxStackSizeBytes)}var vt,gt,ce,bt,le,Be,me,Ue,je,ze,Tt,Qt,We,$e,qe,Ye,R,de,M,he,He,y,N,Oe,x,pe,At,Et,H,Rt,et,zt,Nt,Ge,De,q,Ft,Ve,Ct,Ht,Ot,Gt,Se,tt,rt=se(()=>{W();W();vt=Object.defineProperty,gt=(e,r)=>{for(var t in r)vt(e,t,{get:r[t],enumerable:!0})},ce=!1;bt={};gt(bt,{QuickJSAsyncifyError:()=>je,QuickJSAsyncifySuspended:()=>ze,QuickJSEmptyGetOwnPropertyNames:()=>qe,QuickJSEmscriptenModuleError:()=>Qt,QuickJSHostRefInvalid:()=>R,QuickJSHostRefRangeExceeded:()=>Ye,QuickJSMemoryLeakDetected:()=>Tt,QuickJSNotImplemented:()=>Ue,QuickJSPromisePending:()=>$e,QuickJSUnknownIntrinsic:()=>We,QuickJSUnwrapError:()=>le,QuickJSUseAfterFree:()=>me,QuickJSWrongOwner:()=>Be});le=class extends Error{constructor(e,r){let t=typeof e=="object"&&e&&"message"in e?String(e.message):String(e);super(t),this.cause=e,this.context=r,this.name="QuickJSUnwrapError"}},Be=class extends Error{constructor(){super(...arguments),this.name="QuickJSWrongOwner"}},me=class extends Error{constructor(){super(...arguments),this.name="QuickJSUseAfterFree"}},Ue=class extends Error{constructor(){super(...arguments),this.name="QuickJSNotImplemented"}},je=class extends Error{constructor(){super(...arguments),this.name="QuickJSAsyncifyError"}},ze=class extends Error{constructor(){super(...arguments),this.name="QuickJSAsyncifySuspended"}},Tt=class extends Error{constructor(){super(...arguments),this.name="QuickJSMemoryLeakDetected"}},Qt=class extends Error{constructor(){super(...arguments),this.name="QuickJSEmscriptenModuleError"}},We=class extends TypeError{constructor(){super(...arguments),this.name="QuickJSUnknownIntrinsic"}},$e=class extends Error{constructor(){super(...arguments),this.name="QuickJSPromisePending"}},qe=class extends Error{constructor(){super(...arguments),this.name="QuickJSEmptyGetOwnPropertyNames"}},Ye=class extends Error{constructor(){super(...arguments),this.name="QuickJSHostRefRangeExceeded"}},R=class extends Error{constructor(){super(...arguments),this.name="QuickJSHostRefInvalid"}};de=Ke;de.of=xt;M=class{[Symbol.dispose](){return this.dispose()}},he=Symbol.dispose??Symbol.for("Symbol.dispose"),He=M.prototype;He[he]||(He[he]=function(){return this.dispose()});y=class Ze extends M{constructor(r,t,i,u){super(),this._value=r,this.copier=t,this.disposer=i,this._owner=u,this._alive=!0,this._constructorStack=ce?new Error("Lifetime constructed").stack:void 0}get alive(){return this._alive}get value(){return this.assertAlive(),this._value}get owner(){return this._owner}get dupable(){return!!this.copier}dup(){if(this.assertAlive(),!this.copier)throw new Error("Non-dupable lifetime");return new Ze(this.copier(this._value),this.copier,this.disposer,this._owner)}consume(r){this.assertAlive();let t=r(this);return this.dispose(),t}map(r){return this.assertAlive(),r(this)}tap(r){return r(this),this}dispose(){this.assertAlive(),this.disposer&&this.disposer(this._value),this._alive=!1}assertAlive(){if(!this.alive)throw this._constructorStack?new me(`Lifetime not alive
|
|
3
|
+
${this._constructorStack}
|
|
4
|
+
Lifetime used`):new me("Lifetime not alive")}},N=class extends y{constructor(e,r){super(e,void 0,void 0,r)}get dupable(){return!0}dup(){return this}dispose(){}},Oe=class extends y{constructor(e,r,t,i){super(e,r,t,i)}dispose(){this._alive=!1}};x=class $ extends M{constructor(){super(...arguments),this._disposables=new y(new Set),this.manage=r=>(this._disposables.value.add(r),r)}static withScope(r){let t=new $,i;try{return r(t)}catch(u){throw i=u,u}finally{ue(t,i)}}static withScopeMaybeAsync(r,t){return Pt(void 0,function*(i){let u=new $,a;try{return yield*i.of(t.call(r,i,u))}catch(l){throw a=l,l}finally{ue(u,a)}})}static async withScopeAsync(r){let t=new $,i;try{return await r(t)}catch(u){throw i=u,u}finally{ue(t,i)}}get alive(){return this._disposables.alive}dispose(){let r=Array.from(this._disposables.value.values()).reverse();for(let t of r)t.alive&&t.dispose();this._disposables.dispose()}};pe=class Xe extends M{static success(r){return new At(r)}static fail(r,t){return new Et(r,t)}static is(r){return r instanceof Xe}},At=class extends pe{constructor(e){super(),this.value=e}get alive(){return Y(this.value)?this.value.alive:!0}dispose(){Y(this.value)&&this.value.dispose()}unwrap(){return this.value}unwrapOr(e){return this.value}},Et=class extends pe{constructor(e,r){super(),this.error=e,this.onUnwrap=r}get alive(){return Y(this.error)?this.error.alive:!0}dispose(){Y(this.error)&&this.error.dispose()}unwrap(){throw this.onUnwrap(this),this.error}unwrapOr(e){return e}},H=pe,Rt=class extends M{constructor(e){super(),this.resolve=r=>{this.resolveHandle.alive&&(this.context.unwrapResult(this.context.callFunction(this.resolveHandle,this.context.undefined,r||this.context.undefined)).dispose(),this.disposeResolvers(),this.onSettled())},this.reject=r=>{this.rejectHandle.alive&&(this.context.unwrapResult(this.context.callFunction(this.rejectHandle,this.context.undefined,r||this.context.undefined)).dispose(),this.disposeResolvers(),this.onSettled())},this.dispose=()=>{this.handle.alive&&this.handle.dispose(),this.disposeResolvers()},this.context=e.context,this.owner=e.context.runtime,this.handle=e.promiseHandle,this.settled=new Promise(r=>{this.onSettled=r}),this.resolveHandle=e.resolveHandle,this.rejectHandle=e.rejectHandle}get alive(){return this.handle.alive||this.resolveHandle.alive||this.rejectHandle.alive}disposeResolvers(){this.resolveHandle.alive&&this.resolveHandle.dispose(),this.rejectHandle.alive&&this.rejectHandle.dispose()}},et=class{constructor(e){this.module=e}toPointerArray(e){let r=new Int32Array(e.map(u=>u.value)),t=r.length*r.BYTES_PER_ELEMENT,i=this.module._malloc(t);return new Uint8Array(this.module.HEAPU8.buffer,i,t).set(new Uint8Array(r.buffer)),new y(i,void 0,u=>this.module._free(u))}newTypedArray(e,r){let t=new e(new Array(r).fill(0)),i=t.length*t.BYTES_PER_ELEMENT,u=this.module._malloc(i),a=new e(this.module.HEAPU8.buffer,u,r);return a.set(t),new y({typedArray:a,ptr:u},void 0,l=>this.module._free(l.ptr))}newMutablePointerArray(e){return this.newTypedArray(Int32Array,e)}newHeapCharPointer(e){let r=this.module.lengthBytesUTF8(e),t=r+1,i=this.module._malloc(t);return this.module.stringToUTF8(e,i,t),new y({ptr:i,strlen:r},void 0,u=>this.module._free(u.ptr))}newHeapBufferPointer(e){let r=e.byteLength,t=this.module._malloc(r);return this.module.HEAPU8.set(e,t),new y({pointer:t,numBytes:r},void 0,i=>this.module._free(i.pointer))}consumeHeapCharPointer(e){let r=this.module.UTF8ToString(e);return this.module._free(e),r}},zt=Object.freeze({BaseObjects:!0,Date:!0,Eval:!0,StringNormalize:!0,RegExp:!0,JSON:!0,Proxy:!0,MapSet:!0,TypedArrays:!0,Promise:!0});Nt=class extends M{constructor(e,r){super(),this.handle=e,this.context=r,this._isDone=!1,this.owner=r.runtime}[Symbol.iterator](){return this}next(e){if(!this.alive||this._isDone)return{done:!0,value:void 0};let r=this._next??(this._next=this.context.getProp(this.handle,"next"));return this.callIteratorMethod(r,e)}return(e){if(!this.alive)return{done:!0,value:void 0};let r=this.context.getProp(this.handle,"return");if(r===this.context.undefined&&e===void 0)return this.dispose(),{done:!0,value:void 0};let t=this.callIteratorMethod(r,e);return r.dispose(),this.dispose(),t}throw(e){if(!this.alive)return{done:!0,value:void 0};let r=e instanceof y?e:this.context.newError(e),t=this.context.getProp(this.handle,"throw"),i=this.callIteratorMethod(t,e);return r.alive&&r.dispose(),t.dispose(),this.dispose(),i}get alive(){return this.handle.alive}dispose(){this._isDone=!0,this.handle.dispose(),this._next?.dispose()}callIteratorMethod(e,r){let t=r?this.context.callFunction(e,this.handle,r):this.context.callFunction(e,this.handle);if(t.error)return this.dispose(),{value:t};let i=this.context.getProp(t.value,"done").consume(a=>this.context.dump(a)),u=this.context.getProp(t.value,"value");return t.value.dispose(),i&&this.dispose(),{value:H.success(u),done:i}}},Ge=-2147483648,De=2147483647,q=0;Ft=class{constructor(){this.nextId=Ge,this.freelist=[],this.groups=new Map}put(e){let r=this.allocateId(),t=ae(r),i=this.groups.get(t);return i||(i=new Map,this.groups.set(t,i)),i.set(r,e),r}get(e){if(e===q)throw new R("no host reference id defined");let r=ae(e),t=this.groups.get(r);if(!t)throw new R(`host reference id ${e} is not defined`);let i=t.get(e);if(!i)throw new R(`host reference id ${e} is not defined`);return i}delete(e){if(e===q)throw new R("no host reference id defined");let r=ae(e),t=this.groups.get(r);if(!t)throw new R(`host reference id ${e} is not defined`);t.delete(e),t.size===0&&this.groups.delete(r),this.freelist.push(e)}allocateId(){if(this.freelist.length>0)return this.freelist.shift();if(this.nextId===q&&this.nextId++,this.nextId>De)throw new Ye(`HostRefMap: too many host refs created without disposing. Max simultaneous host refs: ${De-Ge}`);return this.nextId++}},Ve=class extends M{constructor(e,r,t){if(t===q)throw new R("cannot create HostRef with undefined id");super(),this.runtime=e,this.handle=r,this.id=t}get alive(){return this.handle.alive}dispose(){this.handle.dispose()}get value(){return this.runtime.hostRefs.get(this.id)}},Ct=class extends et{constructor(e){super(e.module),this.scope=new x,this.copyJSValue=r=>this.ffi.QTS_DupValuePointer(this.ctx.value,r),this.freeJSValue=r=>{this.ffi.QTS_FreeValuePointer(this.ctx.value,r)},e.ownedLifetimes?.forEach(r=>this.scope.manage(r)),this.owner=e.owner,this.module=e.module,this.ffi=e.ffi,this.rt=e.rt,this.ctx=this.scope.manage(e.ctx)}get alive(){return this.scope.alive}dispose(){return this.scope.dispose()}[Symbol.dispose](){return this.dispose()}manage(e){return this.scope.manage(e)}consumeJSCharPointer(e){let r=this.module.UTF8ToString(e);return this.ffi.QTS_FreeCString(this.ctx.value,e),r}heapValueHandle(e,r){let t=r?i=>{r(),this.freeJSValue(i)}:this.freeJSValue;return new y(e,this.copyJSValue,t,this.owner)}staticHeapValueHandle(e){return this.manage(this.heapValueHandle(e)),new N(e,this.owner)}},Ht=class extends M{constructor(e){super(),this._undefined=void 0,this._null=void 0,this._false=void 0,this._true=void 0,this._global=void 0,this._BigInt=void 0,this._Symbol=void 0,this._SymbolIterator=void 0,this._SymbolAsyncIterator=void 0,this.cToHostCallbacks={callFunction:(r,t,i,u,a)=>{if(r!==this.ctx.value)throw new Error("QuickJSContext instance received C -> JS call with mismatched ctx");let l=this.getFunction(a);return x.withScopeMaybeAsync(this,function*(m,c){let T=c.manage(new Oe(t,this.memory.copyJSValue,this.memory.freeJSValue,this.runtime)),Q=new Array(i);for(let S=0;S<i;S++){let g=this.ffi.QTS_ArgvGetJSValueConstPointer(u,S);Q[S]=c.manage(new Oe(g,this.memory.copyJSValue,this.memory.freeJSValue,this.runtime))}try{let S=yield*m(l.apply(T,Q));if(S){if("error"in S&&S.error)throw this.runtime.debugLog("throw error",S.error),S.error;let g=c.manage(S instanceof y?S:S.value);return this.ffi.QTS_DupValuePointer(this.ctx.value,g.value)}return 0}catch(S){return this.errorToHandle(S).consume(g=>this.ffi.QTS_Throw(this.ctx.value,g.value))}})}},this.runtime=e.runtime,this.module=e.module,this.ffi=e.ffi,this.rt=e.rt,this.ctx=e.ctx,this.memory=new Ct({...e,owner:this.runtime}),e.callbacks.setContextCallbacks(this.ctx.value,this.cToHostCallbacks),this.dump=this.dump.bind(this),this.getString=this.getString.bind(this),this.getNumber=this.getNumber.bind(this),this.resolvePromise=this.resolvePromise.bind(this),this.uint32Out=this.memory.manage(this.memory.newTypedArray(Uint32Array,1))}get alive(){return this.memory.alive}dispose(){this.memory.dispose()}get undefined(){if(this._undefined)return this._undefined;let e=this.ffi.QTS_GetUndefined();return this._undefined=new N(e)}get null(){if(this._null)return this._null;let e=this.ffi.QTS_GetNull();return this._null=new N(e)}get true(){if(this._true)return this._true;let e=this.ffi.QTS_GetTrue();return this._true=new N(e)}get false(){if(this._false)return this._false;let e=this.ffi.QTS_GetFalse();return this._false=new N(e)}get global(){if(this._global)return this._global;let e=this.ffi.QTS_GetGlobalObject(this.ctx.value);return this._global=this.memory.staticHeapValueHandle(e),this._global}newNumber(e){return this.memory.heapValueHandle(this.ffi.QTS_NewFloat64(this.ctx.value,e))}newString(e){let r=this.memory.newHeapCharPointer(e).consume(t=>this.ffi.QTS_NewString(this.ctx.value,t.value.ptr));return this.memory.heapValueHandle(r)}newUniqueSymbol(e){let r=(typeof e=="symbol"?e.description:e)??"",t=this.memory.newHeapCharPointer(r).consume(i=>this.ffi.QTS_NewSymbol(this.ctx.value,i.value.ptr,0));return this.memory.heapValueHandle(t)}newSymbolFor(e){let r=(typeof e=="symbol"?e.description:e)??"",t=this.memory.newHeapCharPointer(r).consume(i=>this.ffi.QTS_NewSymbol(this.ctx.value,i.value.ptr,1));return this.memory.heapValueHandle(t)}getWellKnownSymbol(e){return this._Symbol??(this._Symbol=this.memory.manage(this.getProp(this.global,"Symbol"))),this.getProp(this._Symbol,e)}newBigInt(e){if(!this._BigInt){let i=this.getProp(this.global,"BigInt");this.memory.manage(i),this._BigInt=new N(i.value,this.runtime)}let r=this._BigInt,t=String(e);return this.newString(t).consume(i=>this.unwrapResult(this.callFunction(r,this.undefined,i)))}newObject(e){e&&this.runtime.assertOwned(e);let r=e?this.ffi.QTS_NewObjectProto(this.ctx.value,e.value):this.ffi.QTS_NewObject(this.ctx.value);return this.memory.heapValueHandle(r)}newArray(){let e=this.ffi.QTS_NewArray(this.ctx.value);return this.memory.heapValueHandle(e)}newArrayBuffer(e){let r=new Uint8Array(e),t=this.memory.newHeapBufferPointer(r),i=this.ffi.QTS_NewArrayBuffer(this.ctx.value,t.value.pointer,r.length);return this.memory.heapValueHandle(i)}newPromise(e){let r=x.withScope(t=>{let i=t.manage(this.memory.newMutablePointerArray(2)),u=this.ffi.QTS_NewPromiseCapability(this.ctx.value,i.value.ptr),a=this.memory.heapValueHandle(u),[l,m]=Array.from(i.value.typedArray).map(c=>this.memory.heapValueHandle(c));return new Rt({context:this,promiseHandle:a,resolveHandle:l,rejectHandle:m})});return e&&typeof e=="function"&&(e=new Promise(e)),e&&Promise.resolve(e).then(r.resolve,t=>t instanceof y?r.reject(t):this.newError(t).consume(r.reject)),r}newFunction(e,r){let t=typeof e=="function"?e:r;if(!t)throw new TypeError("Expected a function");return this.newFunctionWithOptions({name:typeof e=="string"?e:void 0,length:t.length,isConstructor:!1,fn:t})}newConstructorFunction(e,r){let t=typeof e=="function"?e:r;if(!t)throw new TypeError("Expected a function");return this.newFunctionWithOptions({name:typeof e=="string"?e:void 0,length:t.length,isConstructor:!0,fn:t})}newFunctionWithOptions(e){let{name:r,length:t,isConstructor:i,fn:u}=e,a=this.runtime.hostRefs.put(u);try{return this.memory.heapValueHandle(this.ffi.QTS_NewFunction(this.ctx.value,r??"",t,i,a))}catch(l){throw this.runtime.hostRefs.delete(a),l}}newError(e){let r=this.memory.heapValueHandle(this.ffi.QTS_NewError(this.ctx.value));return e&&typeof e=="object"?(e.name!==void 0&&this.newString(e.name).consume(t=>this.setProp(r,"name",t)),e.message!==void 0&&this.newString(e.message).consume(t=>this.setProp(r,"message",t))):typeof e=="string"?this.newString(e).consume(t=>this.setProp(r,"message",t)):e!==void 0&&this.newString(String(e)).consume(t=>this.setProp(r,"message",t)),r}newHostRef(e){let r=this.runtime.hostRefs.put(e);try{let t=this.memory.heapValueHandle(this.ffi.QTS_NewHostRef(this.ctx.value,r));return new Ve(this.runtime,t,r)}catch(t){throw this.runtime.hostRefs.delete(r),t}}toHostRef(e){let r=this.ffi.QTS_GetHostRefId(e.value);if(r!==0)return this.runtime.hostRefs.get(r),new Ve(this.runtime,e.dup(),r)}unwrapHostRef(e){let r=this.ffi.QTS_GetHostRefId(e.value);if(r===0)throw new R("handle is not a HostRef");return this.runtime.hostRefs.get(r)}typeof(e){return this.runtime.assertOwned(e),this.memory.consumeHeapCharPointer(this.ffi.QTS_Typeof(this.ctx.value,e.value))}getNumber(e){return this.runtime.assertOwned(e),this.ffi.QTS_GetFloat64(this.ctx.value,e.value)}getString(e){return this.runtime.assertOwned(e),this.memory.consumeJSCharPointer(this.ffi.QTS_GetString(this.ctx.value,e.value))}getSymbol(e){this.runtime.assertOwned(e);let r=this.memory.consumeJSCharPointer(this.ffi.QTS_GetSymbolDescriptionOrKey(this.ctx.value,e.value));return this.ffi.QTS_IsGlobalSymbol(this.ctx.value,e.value)?Symbol.for(r):Symbol(r)}getBigInt(e){this.runtime.assertOwned(e);let r=this.getString(e);return BigInt(r)}getArrayBuffer(e){this.runtime.assertOwned(e);let r=this.ffi.QTS_GetArrayBufferLength(this.ctx.value,e.value),t=this.ffi.QTS_GetArrayBuffer(this.ctx.value,e.value);if(!t)throw new Error("Couldn't allocate memory to get ArrayBuffer");return new y(this.module.HEAPU8.subarray(t,t+r),void 0,()=>this.module._free(t))}getPromiseState(e){this.runtime.assertOwned(e);let r=this.ffi.QTS_PromiseState(this.ctx.value,e.value);if(r<0)return{type:"fulfilled",value:e,notAPromise:!0};if(r===z.Pending)return{type:"pending",get error(){return new $e("Cannot unwrap a pending promise")}};let t=this.ffi.QTS_PromiseResult(this.ctx.value,e.value),i=this.memory.heapValueHandle(t);if(r===z.Fulfilled)return{type:"fulfilled",value:i};if(r===z.Rejected)return{type:"rejected",error:i};throw i.dispose(),new Error(`Unknown JSPromiseStateEnum: ${r}`)}resolvePromise(e){this.runtime.assertOwned(e);let r=x.withScope(t=>{let i=t.manage(this.getProp(this.global,"Promise")),u=t.manage(this.getProp(i,"resolve"));return this.callFunction(u,i,e)});return r.error?Promise.resolve(r):new Promise(t=>{x.withScope(i=>{let u=i.manage(this.newFunction("resolve",c=>{t(this.success(c&&c.dup()))})),a=i.manage(this.newFunction("reject",c=>{t(this.fail(c&&c.dup()))})),l=i.manage(r.value),m=i.manage(this.getProp(l,"then"));this.callFunction(m,l,u,a).unwrap().dispose()})})}isEqual(e,r,t=D.IsStrictlyEqual){if(e===r)return!0;this.runtime.assertOwned(e),this.runtime.assertOwned(r);let i=this.ffi.QTS_IsEqual(this.ctx.value,e.value,r.value,t);if(i===-1)throw new Ue("WASM variant does not expose equality");return!!i}eq(e,r){return this.isEqual(e,r,D.IsStrictlyEqual)}sameValue(e,r){return this.isEqual(e,r,D.IsSameValue)}sameValueZero(e,r){return this.isEqual(e,r,D.IsSameValueZero)}getProp(e,r){this.runtime.assertOwned(e);let t;return typeof r=="number"&&r>=0?t=this.ffi.QTS_GetPropNumber(this.ctx.value,e.value,r):t=this.borrowPropertyKey(r).consume(i=>this.ffi.QTS_GetProp(this.ctx.value,e.value,i.value)),this.memory.heapValueHandle(t)}getLength(e){if(this.runtime.assertOwned(e),!(this.ffi.QTS_GetLength(this.ctx.value,this.uint32Out.value.ptr,e.value)<0))return this.uint32Out.value.typedArray[0]}getOwnPropertyNames(e,r={strings:!0,numbersAsStrings:!0}){this.runtime.assertOwned(e),e.value;let t=Lt(r);if(t===0)throw new qe("No options set, will return an empty array");return x.withScope(i=>{let u=i.manage(this.memory.newMutablePointerArray(1)),a=this.ffi.QTS_GetOwnPropertyNames(this.ctx.value,u.value.ptr,this.uint32Out.value.ptr,e.value,t);if(a)return this.fail(this.memory.heapValueHandle(a));let l=this.uint32Out.value.typedArray[0],m=u.value.typedArray[0],c=new Uint32Array(this.module.HEAP8.buffer,m,l),T=Array.from(c).map(Q=>this.memory.heapValueHandle(Q));return this.ffi.QTS_FreeVoidPointer(this.ctx.value,m),this.success(Mt(T))})}getIterator(e){let r=this._SymbolIterator??(this._SymbolIterator=this.memory.manage(this.getWellKnownSymbol("iterator")));return x.withScope(t=>{let i=t.manage(this.getProp(e,r)),u=this.callFunction(i,e);return u.error?u:this.success(new Nt(u.value,this))})}setProp(e,r,t){this.runtime.assertOwned(e),this.borrowPropertyKey(r).consume(i=>this.ffi.QTS_SetProp(this.ctx.value,e.value,i.value,t.value))}defineProp(e,r,t){this.runtime.assertOwned(e),x.withScope(i=>{let u=i.manage(this.borrowPropertyKey(r)),a=t.value||this.undefined,l=!!t.configurable,m=!!t.enumerable,c=!!t.value,T=t.get?i.manage(this.newFunction(t.get.name,t.get)):this.undefined,Q=t.set?i.manage(this.newFunction(t.set.name,t.set)):this.undefined;this.ffi.QTS_DefineProp(this.ctx.value,e.value,u.value,a.value,T.value,Q.value,l,m,c)})}callFunction(e,r,...t){this.runtime.assertOwned(e);let i,u=t[0];u===void 0||Array.isArray(u)?i=u??[]:i=t;let a=this.memory.toPointerArray(i).consume(m=>this.ffi.QTS_Call(this.ctx.value,e.value,r.value,i.length,m.value)),l=this.ffi.QTS_ResolveException(this.ctx.value,a);return l?(this.ffi.QTS_FreeValuePointer(this.ctx.value,a),this.fail(this.memory.heapValueHandle(l))):this.success(this.memory.heapValueHandle(a))}callMethod(e,r,t=[]){return this.getProp(e,r).consume(i=>this.callFunction(i,e,t))}evalCode(e,r="eval.js",t){let i=t===void 0?1:0,u=It(t),a=this.memory.newHeapCharPointer(e).consume(m=>this.ffi.QTS_Eval(this.ctx.value,m.value.ptr,m.value.strlen,r,i,u)),l=this.ffi.QTS_ResolveException(this.ctx.value,a);return l?(this.ffi.QTS_FreeValuePointer(this.ctx.value,a),this.fail(this.memory.heapValueHandle(l))):this.success(this.memory.heapValueHandle(a))}throw(e){return this.errorToHandle(e).consume(r=>this.ffi.QTS_Throw(this.ctx.value,r.value))}borrowPropertyKey(e){return typeof e=="number"?this.newNumber(e):typeof e=="string"?this.newString(e):new N(e.value,this.runtime)}getMemory(e){if(e===this.rt.value)return this.memory;throw new Error("Private API. Cannot get memory from a different runtime")}dump(e){this.runtime.assertOwned(e);let r=this.typeof(e);if(r==="string")return this.getString(e);if(r==="number")return this.getNumber(e);if(r==="bigint")return this.getBigInt(e);if(r==="undefined")return;if(r==="symbol")return this.getSymbol(e);let t=this.getPromiseState(e);if(t.type==="fulfilled"&&!t.notAPromise)return e.dispose(),{type:t.type,value:t.value.consume(this.dump)};if(t.type==="pending")return e.dispose(),{type:t.type};if(t.type==="rejected")return e.dispose(),{type:t.type,error:t.error.consume(this.dump)};let i=this.memory.consumeJSCharPointer(this.ffi.QTS_Dump(this.ctx.value,e.value));try{return JSON.parse(i)}catch{return i}}unwrapResult(e){if(e.error){let r="context"in e.error?e.error.context:this,t=e.error.consume(i=>this.dump(i));if(t&&typeof t=="object"&&typeof t.message=="string"){let{message:i,name:u,stack:a,...l}=t,m=new le(t,r);typeof u=="string"&&(m.name=t.name),m.message=i;let c=m.stack;throw typeof a=="string"&&(m.stack=`${u}: ${i}
|
|
5
|
+
${t.stack}Host: ${c}`),Object.assign(m,l),m}throw new le(t)}return e.value}[Symbol.for("nodejs.util.inspect.custom")](){return this.alive?`${this.constructor.name} { ctx: ${this.ctx.value} rt: ${this.rt.value} }`:`${this.constructor.name} { disposed }`}getFunction(e){let r=this.runtime.hostRefs.get(e);if(typeof r!="function")throw new Error(`Host reference ${e} is not a function`);return r}errorToHandle(e){return e instanceof y?e:this.newError(e)}encodeBinaryJSON(e){let r=this.ffi.QTS_bjson_encode(this.ctx.value,e.value);return this.memory.heapValueHandle(r)}decodeBinaryJSON(e){let r=this.ffi.QTS_bjson_decode(this.ctx.value,e.value);return this.memory.heapValueHandle(r)}success(e){return H.success(e)}fail(e){return H.fail(e,r=>this.unwrapResult(r))}},Ot=class extends M{constructor(e){super(),this.scope=new x,this.contextMap=new Map,this.hostRefs=new Ft,this._debugMode=!1,this.cToHostCallbacks={freeHostRef:(r,t)=>{if(r!==this.rt.value)throw new Error("Runtime pointer mismatch");this.hostRefs.delete(t)},shouldInterrupt:r=>{if(r!==this.rt.value)throw new Error("QuickJSContext instance received C -> JS interrupt with mismatched rt");let t=this.interruptHandler;if(!t)throw new Error("QuickJSContext had no interrupt handler");return t(this)?1:0},loadModuleSource:Ce(this,function*(r,t,i,u){let a=this.moduleLoader;if(!a)throw new Error("Runtime has no module loader");if(t!==this.rt.value)throw new Error("Runtime pointer mismatch");let l=this.contextMap.get(i)??this.newContext({contextPointer:i});try{let m=yield*r(a(u,l));if(typeof m=="object"&&"error"in m&&m.error)throw this.debugLog("cToHostLoadModule: loader returned error",m.error),m.error;let c=typeof m=="string"?m:"value"in m?m.value:m;return this.memory.newHeapCharPointer(c).value.ptr}catch(m){return this.debugLog("cToHostLoadModule: caught error",m),l.throw(m),0}}),normalizeModule:Ce(this,function*(r,t,i,u,a){let l=this.moduleNormalizer;if(!l)throw new Error("Runtime has no module normalizer");if(t!==this.rt.value)throw new Error("Runtime pointer mismatch");let m=this.contextMap.get(i)??this.newContext({contextPointer:i});try{let c=yield*r(l(u,a,m));if(typeof c=="object"&&"error"in c&&c.error)throw this.debugLog("cToHostNormalizeModule: normalizer returned error",c.error),c.error;let T=typeof c=="string"?c:c.value;return m.getMemory(this.rt.value).newHeapCharPointer(T).value.ptr}catch(c){return this.debugLog("normalizeModule: caught error",c),m.throw(c),0}})},e.ownedLifetimes?.forEach(r=>this.scope.manage(r)),this.module=e.module,this.memory=new et(this.module),this.ffi=e.ffi,this.rt=e.rt,this.callbacks=e.callbacks,this.scope.manage(this.rt),this.callbacks.setRuntimeCallbacks(this.rt.value,this.cToHostCallbacks),this.executePendingJobs=this.executePendingJobs.bind(this),ce&&this.setDebugMode(!0)}get alive(){return this.scope.alive}dispose(){return this.scope.dispose()}newContext(e={}){let r=kt(e.intrinsics),t=new y(e.contextPointer||this.ffi.QTS_NewContext(this.rt.value,r),void 0,u=>{this.contextMap.delete(u),this.callbacks.deleteContext(u),this.ffi.QTS_FreeContext(u)}),i=new Ht({module:this.module,ctx:t,ffi:this.ffi,rt:this.rt,ownedLifetimes:e.ownedLifetimes,runtime:this,callbacks:this.callbacks});return this.contextMap.set(t.value,i),i}setModuleLoader(e,r){this.moduleLoader=e,this.moduleNormalizer=r,this.ffi.QTS_RuntimeEnableModuleLoader(this.rt.value,this.moduleNormalizer?1:0)}removeModuleLoader(){this.moduleLoader=void 0,this.ffi.QTS_RuntimeDisableModuleLoader(this.rt.value)}hasPendingJob(){return!!this.ffi.QTS_IsJobPending(this.rt.value)}setInterruptHandler(e){let r=this.interruptHandler;this.interruptHandler=e,r||this.ffi.QTS_RuntimeEnableInterruptHandler(this.rt.value)}removeInterruptHandler(){this.interruptHandler&&(this.ffi.QTS_RuntimeDisableInterruptHandler(this.rt.value),this.interruptHandler=void 0)}executePendingJobs(e=-1){let r=this.memory.newMutablePointerArray(1),t=this.ffi.QTS_ExecutePendingJob(this.rt.value,e??-1,r.value.ptr),i=r.value.typedArray[0];if(r.dispose(),i===0)return this.ffi.QTS_FreeValuePointerRuntime(this.rt.value,t),H.success(0);let u=this.contextMap.get(i)??this.newContext({contextPointer:i}),a=u.getMemory(this.rt.value).heapValueHandle(t);if(u.typeof(a)==="number"){let l=u.getNumber(a);return a.dispose(),H.success(l)}else{let l=Object.assign(a,{context:u});return H.fail(l,m=>u.unwrapResult(m))}}setMemoryLimit(e){if(e<0&&e!==-1)throw new Error("Cannot set memory limit to negative number. To unset, pass -1");this.ffi.QTS_RuntimeSetMemoryLimit(this.rt.value,e)}computeMemoryUsage(){let e=this.getSystemContext().getMemory(this.rt.value);return e.heapValueHandle(this.ffi.QTS_RuntimeComputeMemoryUsage(this.rt.value,e.ctx.value))}dumpMemoryUsage(){return this.memory.consumeHeapCharPointer(this.ffi.QTS_RuntimeDumpMemoryUsage(this.rt.value))}setMaxStackSize(e){if(e<0)throw new Error("Cannot set memory limit to negative number. To unset, pass 0.");this.ffi.QTS_RuntimeSetMaxStackSize(this.rt.value,e)}assertOwned(e){if(e.owner&&e.owner.rt!==this.rt)throw new Be(`Handle is not owned by this runtime: ${e.owner.rt.value} != ${this.rt.value}`)}setDebugMode(e){this._debugMode=e,this.ffi.DEBUG&&this.rt.alive&&this.ffi.QTS_SetDebugLogEnabled(this.rt.value,e?1:0)}isDebugMode(){return this._debugMode}debugLog(...e){this._debugMode&&console.log("quickjs-emscripten:",...e)}[Symbol.for("nodejs.util.inspect.custom")](){return this.alive?`${this.constructor.name} { rt: ${this.rt.value} }`:`${this.constructor.name} { disposed }`}getSystemContext(){return this.context||(this.context=this.scope.manage(this.newContext())),this.context}},Gt=class{constructor(e){this.freeHostRef=e.freeHostRef,this.callFunction=e.callFunction,this.shouldInterrupt=e.shouldInterrupt,this.loadModuleSource=e.loadModuleSource,this.normalizeModule=e.normalizeModule}},Se=class{constructor(e){this.contextCallbacks=new Map,this.runtimeCallbacks=new Map,this.suspendedCount=0,this.cToHostCallbacks=new Gt({freeHostRef:(r,t,i)=>{let u=this.runtimeCallbacks.get(t);if(!u)throw new Error(`QuickJSRuntime(rt = ${t}) not found when trying to free HostRef(id = ${i})`);u.freeHostRef(t,i)},callFunction:(r,t,i,u,a,l)=>this.handleAsyncify(r,()=>{try{let m=this.contextCallbacks.get(t);if(!m)throw new Error(`QuickJSContext(ctx = ${t}) not found for C function call "${l}"`);return m.callFunction(t,i,u,a,l)}catch(m){return console.error("[C to host error: returning null]",m),0}}),shouldInterrupt:(r,t)=>this.handleAsyncify(r,()=>{try{let i=this.runtimeCallbacks.get(t);if(!i)throw new Error(`QuickJSRuntime(rt = ${t}) not found for C interrupt`);return i.shouldInterrupt(t)}catch(i){return console.error("[C to host interrupt: returning error]",i),1}}),loadModuleSource:(r,t,i,u)=>this.handleAsyncify(r,()=>{try{let a=this.runtimeCallbacks.get(t);if(!a)throw new Error(`QuickJSRuntime(rt = ${t}) not found for C module loader`);let l=a.loadModuleSource;if(!l)throw new Error(`QuickJSRuntime(rt = ${t}) does not support module loading`);return l(t,i,u)}catch(a){return console.error("[C to host module loader error: returning null]",a),0}}),normalizeModule:(r,t,i,u,a)=>this.handleAsyncify(r,()=>{try{let l=this.runtimeCallbacks.get(t);if(!l)throw new Error(`QuickJSRuntime(rt = ${t}) not found for C module loader`);let m=l.normalizeModule;if(!m)throw new Error(`QuickJSRuntime(rt = ${t}) does not support module loading`);return m(t,i,u,a)}catch(l){return console.error("[C to host module loader error: returning null]",l),0}})}),this.module=e,this.module.callbacks=this.cToHostCallbacks}setRuntimeCallbacks(e,r){this.runtimeCallbacks.set(e,r)}deleteRuntime(e){this.runtimeCallbacks.delete(e)}setContextCallbacks(e,r){this.contextCallbacks.set(e,r)}deleteContext(e){this.contextCallbacks.delete(e)}handleAsyncify(e,r){if(e)return e.handleSleep(i=>{try{let u=r();if(!(u instanceof Promise)){V("asyncify.handleSleep: not suspending:",u),i(u);return}if(this.suspended)throw new je(`Already suspended at: ${this.suspended.stack}
|
|
6
|
+
Attempted to suspend at:`);this.suspended=new ze(`(${this.suspendedCount++})`),V("asyncify.handleSleep: suspending:",this.suspended),u.then(a=>{this.suspended=void 0,V("asyncify.handleSleep: resolved:",a),i(a)},a=>{V("asyncify.handleSleep: rejected:",a),console.error("QuickJS: cannot handle error in suspended function",a),this.suspended=void 0})}catch(u){throw V("asyncify.handleSleep: error:",u),this.suspended=void 0,u}});let t=r();if(t instanceof Promise)throw new Error("Promise return value not supported in non-asyncify context.");return t}};tt=class{constructor(e,r){this.module=e,this.ffi=r,this.callbacks=new Se(e)}newRuntime(e={}){let r=new y(this.ffi.QTS_NewRuntime(),void 0,i=>{this.ffi.QTS_FreeRuntime(i),this.callbacks.deleteRuntime(i)}),t=new Ot({module:this.module,callbacks:this.callbacks,ffi:this.ffi,rt:r});return we(t,e),e.moduleLoader&&t.setModuleLoader(e.moduleLoader),t}newContext(e={}){let r=this.newRuntime(),t=r.newContext({...e,ownedLifetimes:Jt(r,e.ownedLifetimes)});return r.context=t,t}evalCode(e,r={}){return x.withScope(t=>{let i=t.manage(this.newContext());_e(i.runtime,r);let u=i.evalCode(e,"eval.js");if(r.memoryLimitBytes!==void 0&&i.runtime.setMemoryLimit(-1),u.error)throw i.dump(t.manage(u.error));return i.dump(t.manage(u.value))})}getWasmMemory(){let e=this.module.quickjsEmscriptenInit?.(()=>{})?.getWasmMemory?.();if(!e)throw new Error("Variant does not support getting WebAssembly.Memory");return e}getFFI(){return this.ffi}}});var it={};yt(it,{QuickJSModuleCallbacks:()=>Se,QuickJSWASMModule:()=>tt,applyBaseRuntimeOptions:()=>we,applyModuleEvalRuntimeOptions:()=>_e});var nt=se(()=>{rt()});W();async function st(e){let r=ye(await e),[t,i,{QuickJSWASMModule:u}]=await Promise.all([r.importModuleLoader().then(ye),r.importFFI(),Promise.resolve().then(()=>(nt(),it)).then(ye)]),a=await t();a.type="sync";let l=new i(a);return new u(a,l)}function ye(e){return e&&"default"in e&&e.default?e.default&&"default"in e.default&&e.default.default?e.default.default:e.default:e}var ot=class{constructor(e){this.module=e,this.DEBUG=!1,this.QTS_Throw=this.module.cwrap("QTS_Throw","number",["number","number"]),this.QTS_NewError=this.module.cwrap("QTS_NewError","number",["number"]),this.QTS_RuntimeSetMemoryLimit=this.module.cwrap("QTS_RuntimeSetMemoryLimit",null,["number","number"]),this.QTS_RuntimeComputeMemoryUsage=this.module.cwrap("QTS_RuntimeComputeMemoryUsage","number",["number","number"]),this.QTS_RuntimeDumpMemoryUsage=this.module.cwrap("QTS_RuntimeDumpMemoryUsage","number",["number"]),this.QTS_RecoverableLeakCheck=this.module.cwrap("QTS_RecoverableLeakCheck","number",[]),this.QTS_BuildIsSanitizeLeak=this.module.cwrap("QTS_BuildIsSanitizeLeak","number",[]),this.QTS_RuntimeSetMaxStackSize=this.module.cwrap("QTS_RuntimeSetMaxStackSize",null,["number","number"]),this.QTS_GetUndefined=this.module.cwrap("QTS_GetUndefined","number",[]),this.QTS_GetNull=this.module.cwrap("QTS_GetNull","number",[]),this.QTS_GetFalse=this.module.cwrap("QTS_GetFalse","number",[]),this.QTS_GetTrue=this.module.cwrap("QTS_GetTrue","number",[]),this.QTS_NewHostRef=this.module.cwrap("QTS_NewHostRef","number",["number","number"]),this.QTS_GetHostRefId=this.module.cwrap("QTS_GetHostRefId","number",["number"]),this.QTS_NewRuntime=this.module.cwrap("QTS_NewRuntime","number",[]),this.QTS_FreeRuntime=this.module.cwrap("QTS_FreeRuntime",null,["number"]),this.QTS_NewContext=this.module.cwrap("QTS_NewContext","number",["number","number"]),this.QTS_FreeContext=this.module.cwrap("QTS_FreeContext",null,["number"]),this.QTS_FreeValuePointer=this.module.cwrap("QTS_FreeValuePointer",null,["number","number"]),this.QTS_FreeValuePointerRuntime=this.module.cwrap("QTS_FreeValuePointerRuntime",null,["number","number"]),this.QTS_FreeVoidPointer=this.module.cwrap("QTS_FreeVoidPointer",null,["number","number"]),this.QTS_FreeCString=this.module.cwrap("QTS_FreeCString",null,["number","number"]),this.QTS_DupValuePointer=this.module.cwrap("QTS_DupValuePointer","number",["number","number"]),this.QTS_NewObject=this.module.cwrap("QTS_NewObject","number",["number"]),this.QTS_NewObjectProto=this.module.cwrap("QTS_NewObjectProto","number",["number","number"]),this.QTS_NewArray=this.module.cwrap("QTS_NewArray","number",["number"]),this.QTS_NewArrayBuffer=this.module.cwrap("QTS_NewArrayBuffer","number",["number","number","number"]),this.QTS_NewFloat64=this.module.cwrap("QTS_NewFloat64","number",["number","number"]),this.QTS_GetFloat64=this.module.cwrap("QTS_GetFloat64","number",["number","number"]),this.QTS_NewString=this.module.cwrap("QTS_NewString","number",["number","number"]),this.QTS_GetString=this.module.cwrap("QTS_GetString","number",["number","number"]),this.QTS_GetArrayBuffer=this.module.cwrap("QTS_GetArrayBuffer","number",["number","number"]),this.QTS_GetArrayBufferLength=this.module.cwrap("QTS_GetArrayBufferLength","number",["number","number"]),this.QTS_NewSymbol=this.module.cwrap("QTS_NewSymbol","number",["number","number","number"]),this.QTS_GetSymbolDescriptionOrKey=this.module.cwrap("QTS_GetSymbolDescriptionOrKey","number",["number","number"]),this.QTS_IsGlobalSymbol=this.module.cwrap("QTS_IsGlobalSymbol","number",["number","number"]),this.QTS_IsJobPending=this.module.cwrap("QTS_IsJobPending","number",["number"]),this.QTS_ExecutePendingJob=this.module.cwrap("QTS_ExecutePendingJob","number",["number","number","number"]),this.QTS_GetProp=this.module.cwrap("QTS_GetProp","number",["number","number","number"]),this.QTS_GetPropNumber=this.module.cwrap("QTS_GetPropNumber","number",["number","number","number"]),this.QTS_SetProp=this.module.cwrap("QTS_SetProp",null,["number","number","number","number"]),this.QTS_DefineProp=this.module.cwrap("QTS_DefineProp",null,["number","number","number","number","number","number","boolean","boolean","boolean"]),this.QTS_GetOwnPropertyNames=this.module.cwrap("QTS_GetOwnPropertyNames","number",["number","number","number","number","number"]),this.QTS_Call=this.module.cwrap("QTS_Call","number",["number","number","number","number","number"]),this.QTS_ResolveException=this.module.cwrap("QTS_ResolveException","number",["number","number"]),this.QTS_Dump=this.module.cwrap("QTS_Dump","number",["number","number"]),this.QTS_Eval=this.module.cwrap("QTS_Eval","number",["number","number","number","string","number","number"]),this.QTS_GetModuleNamespace=this.module.cwrap("QTS_GetModuleNamespace","number",["number","number"]),this.QTS_Typeof=this.module.cwrap("QTS_Typeof","number",["number","number"]),this.QTS_GetLength=this.module.cwrap("QTS_GetLength","number",["number","number","number"]),this.QTS_IsEqual=this.module.cwrap("QTS_IsEqual","number",["number","number","number","number"]),this.QTS_GetGlobalObject=this.module.cwrap("QTS_GetGlobalObject","number",["number"]),this.QTS_NewPromiseCapability=this.module.cwrap("QTS_NewPromiseCapability","number",["number","number"]),this.QTS_PromiseState=this.module.cwrap("QTS_PromiseState","number",["number","number"]),this.QTS_PromiseResult=this.module.cwrap("QTS_PromiseResult","number",["number","number"]),this.QTS_TestStringArg=this.module.cwrap("QTS_TestStringArg",null,["string"]),this.QTS_GetDebugLogEnabled=this.module.cwrap("QTS_GetDebugLogEnabled","number",["number"]),this.QTS_SetDebugLogEnabled=this.module.cwrap("QTS_SetDebugLogEnabled",null,["number","number"]),this.QTS_BuildIsDebug=this.module.cwrap("QTS_BuildIsDebug","number",[]),this.QTS_BuildIsAsyncify=this.module.cwrap("QTS_BuildIsAsyncify","number",[]),this.QTS_NewFunction=this.module.cwrap("QTS_NewFunction","number",["number","string","number","boolean","number"]),this.QTS_ArgvGetJSValueConstPointer=this.module.cwrap("QTS_ArgvGetJSValueConstPointer","number",["number","number"]),this.QTS_RuntimeEnableInterruptHandler=this.module.cwrap("QTS_RuntimeEnableInterruptHandler",null,["number"]),this.QTS_RuntimeDisableInterruptHandler=this.module.cwrap("QTS_RuntimeDisableInterruptHandler",null,["number"]),this.QTS_RuntimeEnableModuleLoader=this.module.cwrap("QTS_RuntimeEnableModuleLoader",null,["number","number"]),this.QTS_RuntimeDisableModuleLoader=this.module.cwrap("QTS_RuntimeDisableModuleLoader",null,["number"]),this.QTS_bjson_encode=this.module.cwrap("QTS_bjson_encode","number",["number","number"]),this.QTS_bjson_decode=this.module.cwrap("QTS_bjson_decode","number",["number","number"])}};async function Dt(e={}){var r,t=e,i=!!globalThis.window,u=!!globalThis.WorkerGlobalScope;function a(n){n={log:n||function(){}};for(let o of a.Pa)o(n);return t.quickJSEmscriptenExtensions=n}a.Pa=[],t.quickjsEmscriptenInit=a,a.Pa.push(n=>{n.getWasmMemory=function(){return k}});var l="./this.program",m=import.meta.url,c="",T,Q;if(i||u){try{c=new URL(".",m).href}catch{}u&&(Q=n=>{var o=new XMLHttpRequest;return o.open("GET",n,!1),o.responseType="arraybuffer",o.send(null),new Uint8Array(o.response)}),T=async n=>{if(n=await fetch(n,{credentials:"same-origin"}),n.ok)return n.arrayBuffer();throw Error(n.status+" : "+n.url)}}var S=console.log.bind(console),g=console.error.bind(console),O,B=!1,K,ve,ge,be,F,b,A,Te=!1;function Qe(){var n=k.buffer;t.HEAP8=be=new Int8Array(n),new Int16Array(n),t.HEAPU8=F=new Uint8Array(n),new Uint16Array(n),b=new Int32Array(n),A=new Uint32Array(n),new Float32Array(n),new Float64Array(n),new BigInt64Array(n),new BigUint64Array(n)}function Z(n){throw t.onAbort?.(n),n="Aborted("+n+")",g(n),B=!0,n=new WebAssembly.RuntimeError(n+". Build with -sASSERTIONS for more info."),ge?.(n),n}var X;async function at(n){if(!O)try{var o=await T(n);return new Uint8Array(o)}catch{}if(n==X&&O)n=new Uint8Array(O);else if(Q)n=Q(n);else throw"both async and sync fetching of the wasm failed";return n}async function lt(n,o){try{var s=await at(n);return await WebAssembly.instantiate(s,o)}catch(h){g(`failed to asynchronously prepare wasm: ${h}`),Z(h)}}async function mt(n){var o=X;if(!O)try{var s=fetch(o,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(s,n)}catch(h){g(`wasm streaming compile failed: ${h}`),g("falling back to ArrayBuffer instantiation")}return lt(o,n)}class xe{name="ExitStatus";constructor(o){this.message=`Program terminated with exit(${o})`,this.status=o}}var Pe=n=>{for(;0<n.length;)n.shift()(t)},Me=[],Ae=[],ht=()=>{var n=t.preRun.shift();Ae.push(n)},U=!0,k,Ee=new TextDecoder,Re=(n,o,s,h)=>{if(s=o+s,h)return s;for(;n[o]&&!(o>=s);)++o;return o},E=(n,o,s)=>n?Ee.decode(F.subarray(n,Re(F,n,o,s))):"",ee=0,ct=[0,31,60,91,121,152,182,213,244,274,305,335],dt=[0,31,59,90,120,151,181,212,243,273,304,334],G={},ke=n=>{if(!(n instanceof xe||n=="unwind"))throw n},Ie=n=>{throw K=n,U||0<ee||(t.onExit?.(n),B=!0),new xe(n)},ft=n=>{if(!B)try{n()}catch(o){ke(o)}finally{if(!(U||0<ee))try{K=n=K,Ie(n)}catch(o){ke(o)}}},I=(n,o,s)=>{var h=F;if(!(0<s))return 0;var d=o;s=o+s-1;for(var f=0;f<n.length;++f){var p=n.codePointAt(f);if(127>=p){if(o>=s)break;h[o++]=p}else if(2047>=p){if(o+1>=s)break;h[o++]=192|p>>6,h[o++]=128|p&63}else if(65535>=p){if(o+2>=s)break;h[o++]=224|p>>12,h[o++]=128|p>>6&63,h[o++]=128|p&63}else{if(o+3>=s)break;h[o++]=240|p>>18,h[o++]=128|p>>12&63,h[o++]=128|p>>6&63,h[o++]=128|p&63,f++}}return h[o]=0,o-d},te={},Le=()=>{if(!re){var n={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:l||"./this.program"},o;for(o in te)te[o]===void 0?delete n[o]:n[o]=te[o];var s=[];for(o in n)s.push(`${o}=${n[o]}`);re=s}return re},re,ie=n=>{for(var o=0,s=0;s<n.length;++s){var h=n.charCodeAt(s);127>=h?o++:2047>=h?o+=2:55296<=h&&57343>=h?(o+=4,++s):o+=3}return o},pt=[null,[],[]],St=(n,o,s,h)=>{var d={string:w=>{var _=0;if(w!=null&&w!==0){_=ie(w)+1;var P=ne(_);I(w,P,_),_=P}return _},array:w=>{var _=ne(w.length);return be.set(w,_),_}};n=t["_"+n];var f=[],p=0;if(h)for(var v=0;v<h.length;v++){var C=d[s[v]];C?(p===0&&(p=Fe()),f[v]=C(h[v])):f[v]=h[v]}return s=n(...f),s=(function(w){return p!==0&&Ne(p),o==="string"?E(w):o==="boolean"?!!w:w})(s)};if(t.wasmMemory?k=t.wasmMemory:k=new WebAssembly.Memory({initial:(t.INITIAL_MEMORY||16777216)/65536,maximum:32768}),Qe(),t.noExitRuntime&&(U=t.noExitRuntime),t.print&&(S=t.print),t.printErr&&(g=t.printErr),t.wasmBinary&&(O=t.wasmBinary),t.thisProgram&&(l=t.thisProgram),t.preInit)for(typeof t.preInit=="function"&&(t.preInit=[t.preInit]);0<t.preInit.length;)t.preInit.shift()();t.cwrap=(n,o,s,h)=>{var d=!s||s.every(f=>f==="number"||f==="boolean");return o!=="string"&&d&&!h?t["_"+n]:(...f)=>St(n,o,s,f)},t.UTF8ToString=E,t.stringToUTF8=(n,o,s)=>I(n,o,s),t.lengthBytesUTF8=ie;var Je,Ne,ne,Fe,wt={b:(n,o,s,h)=>Z(`Assertion failed: ${E(n)}, at: `+[o?E(o):"unknown filename",s,h?E(h):"unknown function"]),q:()=>Z(""),l:()=>{U=!1,ee=0},m:function(n,o){n=-9007199254740992>n||9007199254740992<n?NaN:Number(n),n=new Date(1e3*n),b[o>>2]=n.getSeconds(),b[o+4>>2]=n.getMinutes(),b[o+8>>2]=n.getHours(),b[o+12>>2]=n.getDate(),b[o+16>>2]=n.getMonth(),b[o+20>>2]=n.getFullYear()-1900,b[o+24>>2]=n.getDay();var s=n.getFullYear();b[o+28>>2]=(s%4!==0||s%100===0&&s%400!==0?dt:ct)[n.getMonth()]+n.getDate()-1|0,b[o+36>>2]=-(60*n.getTimezoneOffset()),s=new Date(n.getFullYear(),6,1).getTimezoneOffset();var h=new Date(n.getFullYear(),0,1).getTimezoneOffset();b[o+32>>2]=(s!=h&&n.getTimezoneOffset()==Math.min(h,s))|0},j:(n,o)=>{if(G[n]&&(clearTimeout(G[n].id),delete G[n]),!o)return 0;var s=setTimeout(()=>{delete G[n],ft(()=>Je(n,performance.now()))},o);return G[n]={id:s,Qa:o},0},n:(n,o,s,h)=>{var d=new Date().getFullYear(),f=new Date(d,0,1).getTimezoneOffset();d=new Date(d,6,1).getTimezoneOffset(),A[n>>2]=60*Math.max(f,d),b[o>>2]=+(f!=d),o=p=>{var v=Math.abs(p);return`UTC${0<=p?"-":"+"}${String(Math.floor(v/60)).padStart(2,"0")}${String(v%60).padStart(2,"0")}`},n=o(f),o=o(d),d<f?(I(n,s,17),I(o,h,17)):(I(n,h,17),I(o,s,17))},p:()=>Date.now(),k:n=>{var o=F.length;if(n>>>=0,2147483648<n)return!1;for(var s=1;4>=s;s*=2){var h=o*(1+.2/s);h=Math.min(h,n+100663296);e:{h=(Math.min(2147483648,65536*Math.ceil(Math.max(n,h)/65536))-k.buffer.byteLength+65535)/65536|0;try{k.grow(h),Qe();var d=1;break e}catch{}d=void 0}if(d)return!0}return!1},e:(n,o)=>{var s=0,h=0,d;for(d of Le()){var f=o+s;A[n+h>>2]=f,s+=I(d,f,1/0)+1,h+=4}return 0},f:(n,o)=>{var s=Le();A[n>>2]=s.length,n=0;for(var h of s)n+=ie(h)+1;return A[o>>2]=n,0},d:()=>52,o:function(){return 70},c:(n,o,s,h)=>{for(var d=0,f=0;f<s;f++){var p=A[o>>2],v=A[o+4>>2];o+=8;for(var C=0;C<v;C++){var w=n,_=F[p+C],P=pt[w];_===0||_===10?(w=w===1?S:g,_=Re(P,0),_=Ee.decode(P.buffer?P.subarray(0,_):new Uint8Array(P.slice(0,_))),w(_),P.length=0):P.push(_)}d+=v}return A[h>>2]=d,0},a:k,r:Ie,s:function(n,o,s,h,d){return t.callbacks.callFunction(void 0,n,o,s,h,d)},i:function(n){return t.callbacks.shouldInterrupt(void 0,n)},h:function(n,o,s){return s=E(s),t.callbacks.loadModuleSource(void 0,n,o,s)},g:function(n,o,s,h){return s=E(s),h=E(h),t.callbacks.normalizeModule(void 0,n,o,s,h)},t:function(n,o){t.callbacks.freeHostRef(void 0,n,o)}},j;return j=await(async function(){function n(s){return s=j=s.exports,t._malloc=s.v,t._QTS_Throw=s.w,t._QTS_NewError=s.x,t._QTS_RuntimeSetMemoryLimit=s.y,t._QTS_RuntimeComputeMemoryUsage=s.z,t._QTS_RuntimeDumpMemoryUsage=s.A,t._QTS_RecoverableLeakCheck=s.B,t._QTS_BuildIsSanitizeLeak=s.C,t._QTS_RuntimeSetMaxStackSize=s.D,t._QTS_GetUndefined=s.E,t._QTS_GetNull=s.F,t._QTS_GetFalse=s.G,t._QTS_GetTrue=s.H,t._QTS_NewHostRef=s.I,t._QTS_GetHostRefId=s.J,t._QTS_NewRuntime=s.K,t._QTS_FreeRuntime=s.L,t._free=s.M,t._QTS_NewContext=s.N,t._QTS_FreeContext=s.O,t._QTS_FreeValuePointer=s.P,t._QTS_FreeValuePointerRuntime=s.Q,t._QTS_FreeVoidPointer=s.R,t._QTS_FreeCString=s.S,t._QTS_DupValuePointer=s.T,t._QTS_NewObject=s.U,t._QTS_NewObjectProto=s.V,t._QTS_NewArray=s.W,t._QTS_NewArrayBuffer=s.X,t._QTS_NewFloat64=s.Y,t._QTS_GetFloat64=s.Z,t._QTS_NewString=s._,t._QTS_GetString=s.$,t._QTS_GetArrayBuffer=s.aa,t._QTS_GetArrayBufferLength=s.ba,t._QTS_NewSymbol=s.ca,t._QTS_GetSymbolDescriptionOrKey=s.da,t._QTS_IsGlobalSymbol=s.ea,t._QTS_IsJobPending=s.fa,t._QTS_ExecutePendingJob=s.ga,t._QTS_GetProp=s.ha,t._QTS_GetPropNumber=s.ia,t._QTS_SetProp=s.ja,t._QTS_DefineProp=s.ka,t._QTS_GetOwnPropertyNames=s.la,t._QTS_Call=s.ma,t._QTS_ResolveException=s.na,t._QTS_Dump=s.oa,t._QTS_Eval=s.pa,t._QTS_GetModuleNamespace=s.qa,t._QTS_Typeof=s.ra,t._QTS_GetLength=s.sa,t._QTS_IsEqual=s.ta,t._QTS_GetGlobalObject=s.ua,t._QTS_NewPromiseCapability=s.va,t._QTS_PromiseState=s.wa,t._QTS_PromiseResult=s.xa,t._QTS_TestStringArg=s.ya,t._QTS_GetDebugLogEnabled=s.za,t._QTS_SetDebugLogEnabled=s.Aa,t._QTS_BuildIsDebug=s.Ba,t._QTS_BuildIsAsyncify=s.Ca,t._QTS_NewFunction=s.Da,t._QTS_ArgvGetJSValueConstPointer=s.Ea,t._QTS_RuntimeEnableInterruptHandler=s.Fa,t._QTS_RuntimeDisableInterruptHandler=s.Ga,t._QTS_RuntimeEnableModuleLoader=s.Ha,t._QTS_RuntimeDisableModuleLoader=s.Ia,t._QTS_bjson_encode=s.Ja,t._QTS_bjson_decode=s.Ka,Je=s.La,Ne=s.Ma,ne=s.Na,Fe=s.Oa,j}var o={a:wt};return t.instantiateWasm?new Promise(s=>{t.instantiateWasm(o,(h,d)=>{s(n(h,d))})}):(X??=t.locateFile?t.locateFile?t.locateFile("emscripten-module.wasm",c):c+"emscripten-module.wasm":new URL("emscripten-module.wasm",import.meta.url).href,n((await mt(o)).instance))})(),(function(){function n(){if(t.calledRun=!0,!B){if(Te=!0,j.u(),ve?.(t),t.onRuntimeInitialized?.(),t.postRun)for(typeof t.postRun=="function"&&(t.postRun=[t.postRun]);t.postRun.length;){var o=t.postRun.shift();Me.push(o)}Pe(Me)}}if(t.preRun)for(typeof t.preRun=="function"&&(t.preRun=[t.preRun]);t.preRun.length;)ht();Pe(Ae),t.setStatus?(t.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>t.setStatus(""),1),n()},1)):n()})(),Te?r=t:r=new Promise((n,o)=>{ve=n,ge=o}),r}var ut=Dt;var Ir=e=>st({type:"sync",importFFI:async()=>ot,importModuleLoader:async()=>()=>ut({wasmBinary:e,locateFile:()=>"data:application/wasm;base64,"})});export{Ir as createQuickJS};
|
|
Binary file
|
package/dist/cli/pass.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mkdirSync, rmSync } from 'node:fs';
|
|
2
|
-
import { dirname, join } from 'node:path';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
3
|
import { Worker } from 'node:worker_threads';
|
|
4
4
|
import { ENVELOPE, canonical, parse } from '@lapxo/topos/wire';
|
|
5
5
|
import { foldPlace, standingOf } from "./place.js";
|
|
@@ -57,7 +57,7 @@ async function checked(root, entry, under) {
|
|
|
57
57
|
return 1;
|
|
58
58
|
}
|
|
59
59
|
const standing = emptyLedger(store) ? ownLockOf(root, under?.replace(/\/$/, '') ?? '') : standingOf(root).standing;
|
|
60
|
-
const instrument = sealed === undefined ? instrumentOf(store, entry, standing, root, ownLock()) : instrumentDigest(store, entry, [], ownRoot(), ownLock());
|
|
60
|
+
const instrument = sealed === undefined ? instrumentOf(store, entry, standing, root, ownLock()) : instrumentDigest(store, resolve(root, entry), [], ownRoot(), ownLock());
|
|
61
61
|
if (expectedInstrument !== instrument) {
|
|
62
62
|
process.stderr.write(`${selfName()}: REFUSE·check receipt instrument differs; a fold must close it\n`);
|
|
63
63
|
return 1;
|
|
@@ -90,10 +90,10 @@ export async function pass(root, entry, under, check) {
|
|
|
90
90
|
// Byte seals describe the completed render pass, not its intermediate outputs.
|
|
91
91
|
if (!swept.written.length)
|
|
92
92
|
await closeReceipts(root, storeOf(root));
|
|
93
|
-
const closed = meets(root, storeOf(root), under ?? '') && !swept.written.length;
|
|
94
93
|
// Sealed files do not imply an empty reading. If a retained fold is stale,
|
|
95
94
|
// foldPlace must reload its evidence; a valid retained fold still costs no read.
|
|
96
95
|
const fold = foldPlace(root, entry, under, false, { standing: swept.standingAt.get(under ?? '') ?? standingOf(root, under), ...(swept.settled ? {} : { observed: swept.observed.length ? swept.observed : observedClaims(root, storeOf(root), { wait: false }) }), free: !swept.settled });
|
|
96
|
+
const closed = meets(root, storeOf(root), under ?? '', true, fold.observed) && !swept.written.length;
|
|
97
97
|
for (const line of releasePolicyLines(fold.release))
|
|
98
98
|
process.stdout.write(`${line}\n`);
|
|
99
99
|
if (closed) {
|
package/dist/cli/place.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export interface PlaceFold {
|
|
|
28
28
|
readonly missing: readonly string[];
|
|
29
29
|
readonly history: readonly string[];
|
|
30
30
|
readonly observed: readonly string[];
|
|
31
|
+
readonly receiptHistory?: readonly string[];
|
|
31
32
|
readonly ceilings: {
|
|
32
33
|
readonly read: number;
|
|
33
34
|
readonly total: number;
|
|
@@ -63,6 +64,7 @@ export declare function standingOf(root: string, under?: string, told?: readonly
|
|
|
63
64
|
export declare function coneOf(root: string, entry: string, ceilings: readonly string[], descent?: readonly string[]): {
|
|
64
65
|
readonly standing: readonly string[];
|
|
65
66
|
readonly observed: readonly string[];
|
|
67
|
+
readonly receiptHistory?: readonly string[];
|
|
66
68
|
readonly own: Readonly<Record<string, number>>;
|
|
67
69
|
readonly kept: boolean;
|
|
68
70
|
};
|
package/dist/cli/place.js
CHANGED
|
@@ -20,7 +20,7 @@ import { canonical, LOCK, parse } from '@lapxo/topos/wire';
|
|
|
20
20
|
import { classDefaults, kindsOf, placesIn, spoken } from "../fold/places.js";
|
|
21
21
|
import { isCeiling } from "../fold/configures.js";
|
|
22
22
|
import { observedClaims, placedReadings } from "../fold/observed.js";
|
|
23
|
-
import { capsuleReadingsOver } from "../observe/regions.js";
|
|
23
|
+
import { capsuleReadingsOver, currentReceiptObservations, retiredReceiptHistory } from "../observe/regions.js";
|
|
24
24
|
import { costReadings, ownReadings } from "../fold/own.js";
|
|
25
25
|
import { paidOf } from "../fold/paid.js";
|
|
26
26
|
import { rolesOf } from "../fold/roles.js";
|
|
@@ -175,7 +175,8 @@ export function coneOf(root, entry, ceilings, descent) {
|
|
|
175
175
|
const named = regionsNamed(standing);
|
|
176
176
|
const reach = descent !== undefined && descent.length ? [...descent] : [...new Set(ceilings.map((line) => boundOf(named, line).region))];
|
|
177
177
|
const read = observedClaims(root, store, { wait: false, ...(reach.includes('') ? {} : { reach }) });
|
|
178
|
-
const
|
|
178
|
+
const current = currentReceiptObservations({ root, store, standing, observed: read });
|
|
179
|
+
const observed = [...current, ...capsuleReadingsOver({ root, store, standing, observed: read })];
|
|
179
180
|
const own = {
|
|
180
181
|
...ownReadings({ root, store, entry, roleOf: rolesOf(store), standing, observed, unadmitted: rendered.grey.length + rendered.refused.length, orphans: 0 }),
|
|
181
182
|
...costReadings(store, standing),
|
|
@@ -213,7 +214,8 @@ export function foldPlace(root, entry, under, look = true, given) {
|
|
|
213
214
|
const spent = [];
|
|
214
215
|
const took = timing(spent);
|
|
215
216
|
const read = given?.observed ?? (under ? took('observe', () => observedClaims(root, store, { wait: look })) : reached);
|
|
216
|
-
const
|
|
217
|
+
const current = currentReceiptObservations({ root, store, ...(under ? { under } : {}), standing, observed: read });
|
|
218
|
+
const everywhere = [...current, ...took('capsules', () => capsuleReadingsOver({ root, store, ...(under ? { under } : {}), standing, observed: read }))];
|
|
217
219
|
const points = foldPoints(store, standing, under, folder, self, reached, root, answered, reads);
|
|
218
220
|
const taken = bytesDigest(store, new TextEncoder().encode(points.join('\n'))).replace(/^sha256:/, '');
|
|
219
221
|
const observed = everywhere.filter((line) => !/ measure=observed /.test(line) || inside(fieldOf(line, 'scope')));
|
|
@@ -241,6 +243,7 @@ export function foldPlace(root, entry, under, look = true, given) {
|
|
|
241
243
|
demands, paid, missing,
|
|
242
244
|
history: live.history.filter((line) => fieldOf(line, 'needs').split('|').filter(Boolean).some(inside)),
|
|
243
245
|
observed,
|
|
246
|
+
receiptHistory: retiredReceiptHistory({ root, store, ...(under ? { under } : {}), standing, observed: read }),
|
|
244
247
|
ceilings: {
|
|
245
248
|
read: folded.read.length,
|
|
246
249
|
total: ceilings.length,
|
|
@@ -290,7 +293,7 @@ export function foldPlace(root, entry, under, look = true, given) {
|
|
|
290
293
|
over: listed(again.over.filter((o) => o.side === 'over')),
|
|
291
294
|
},
|
|
292
295
|
};
|
|
293
|
-
if (folder !== undefined &&
|
|
296
|
+
if (folder !== undefined && meets(root, store, under ?? '', true, whole.observed))
|
|
294
297
|
took('keep', () => keepFold(store, taken, whole, points, self));
|
|
295
298
|
process.stderr.write(`SPENT fold ${spent.join(' ms · ')} ms\n`);
|
|
296
299
|
return whole;
|
package/dist/cli/verb.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { printReleaseApproval } from "./release-result.js";
|
|
3
|
+
import { inspectReference } from "../host/reference.js";
|
|
4
|
+
import { authenticatedReferenceSelected, openAuthenticatedReference } from "../host/reference-native.js";
|
|
3
5
|
import { printActResult } from "./act-result.js";
|
|
4
6
|
import { printStandingResult } from "./standing-result.js";
|
|
5
7
|
import { withContentStore } from "../host/content-store.js";
|
|
@@ -10,7 +12,8 @@ import { cellsWithReceipts } from "../host/cell-receipts.js";
|
|
|
10
12
|
import { renderCells } from '@lapxo/topos/cells-view';
|
|
11
13
|
import { releasePolicyLines } from "../fold/release-policy.js";
|
|
12
14
|
import { admittedObjects } from "../host/objects.js";
|
|
13
|
-
import { objectFold } from "../
|
|
15
|
+
import { objectFold } from "../engine/index.js";
|
|
16
|
+
import { foldObjectsWithWasm, usesWasmObject } from "../wasm/object.js";
|
|
14
17
|
import { OBJECT_VIEW } from '@lapxo/topos/wire';
|
|
15
18
|
import { toposStanding } from '@lapxo/topos/standing';
|
|
16
19
|
import { wireAt, parse as parseWire } from '@lapxo/topos/wire';
|
|
@@ -446,6 +449,28 @@ function foldFile(at) {
|
|
|
446
449
|
return EXIT.closed;
|
|
447
450
|
}
|
|
448
451
|
function foldVerb(root, rest) {
|
|
452
|
+
const references = positionalsOf(rest).filter(one => /^#bound(?::|$)/.test(one));
|
|
453
|
+
if (references.length) {
|
|
454
|
+
if (references.length !== 1 || positionalsOf(rest).length !== 1 || rest.some(one => one.startsWith('--')))
|
|
455
|
+
throw Error('REFUSE·reference name one reference without view, check or signing options');
|
|
456
|
+
if (authenticatedReferenceSelected(standingOf(root).standing))
|
|
457
|
+
return openAuthenticatedReference(root, references[0]).then(result => {
|
|
458
|
+
process.stdout.write(`SOURCE ${result.reference.source}\n`);
|
|
459
|
+
for (const line of result.semanticStanding.split('\n').filter(Boolean))
|
|
460
|
+
process.stdout.write(`TOPOS ${line}\n`);
|
|
461
|
+
for (const cell of result.readings)
|
|
462
|
+
process.stdout.write('CELL ' + JSON.stringify(cell) + '\n');
|
|
463
|
+
process.stdout.write(`AUTHENTICATED standing ${result.semanticIdentity} · authority ${result.authorityContextIdentity} · no effects committed\n`);
|
|
464
|
+
return EXIT.closed;
|
|
465
|
+
});
|
|
466
|
+
return inspectReference(references[0], standingOf(root).standing).then(result => {
|
|
467
|
+
process.stdout.write(`SOURCE ${result.reference.source}\n`);
|
|
468
|
+
for (const line of result.lines)
|
|
469
|
+
process.stdout.write(`TOPOS ${line}\n`);
|
|
470
|
+
process.stdout.write(`INSPECT standing sha256:${result.reference.digest} · blob ${result.reference.blob} · no encounters computed · unauthenticated\n`);
|
|
471
|
+
return EXIT.closed;
|
|
472
|
+
});
|
|
473
|
+
}
|
|
449
474
|
const files = positionalsOf(rest).filter((one) => existsSync(resolve(one)) && !lstatSync(resolve(one)).isDirectory() && one.endsWith(EXTENSION));
|
|
450
475
|
const places = positionalsOf(rest).filter((one) => existsSync(resolve(one)) && lstatSync(resolve(one)).isDirectory());
|
|
451
476
|
if (files.length === 1 && !places.length && valueOf(rest, FLAGS.as) === undefined) {
|
|
@@ -501,9 +526,21 @@ async function foldResolved(root, under, argv) {
|
|
|
501
526
|
throw Error('REFUSE·object one history snapshot per fold');
|
|
502
527
|
const history = inputs.length ? claimLinesIn(inputs[0]) : signedOwnerLines(storeOf(root));
|
|
503
528
|
const held = await admittedObjects(root, history, text => process.stdout.write(text + '\n'));
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
529
|
+
let cells;
|
|
530
|
+
if (usesWasmObject(held.configuration)) {
|
|
531
|
+
const cancellation = new AbortController(), interrupt = () => cancellation.abort();
|
|
532
|
+
process.once('SIGINT', interrupt);
|
|
533
|
+
try {
|
|
534
|
+
cells = await foldObjectsWithWasm(root, held.records, held.context, held.configuration, cancellation.signal);
|
|
535
|
+
}
|
|
536
|
+
finally {
|
|
537
|
+
process.removeListener('SIGINT', interrupt);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
else
|
|
541
|
+
cells = objectFold(held.records, held.context);
|
|
542
|
+
for (const cell of cells)
|
|
543
|
+
process.stdout.write('CELL ' + JSON.stringify(cell) + '\n');
|
|
507
544
|
process.stdout.write(`FACT object fold ${cells.length} cells\n`);
|
|
508
545
|
return EXIT.closed;
|
|
509
546
|
}
|
|
@@ -583,9 +620,9 @@ function main(argv) {
|
|
|
583
620
|
const selected = roots[0];
|
|
584
621
|
const root = resolve(selected === undefined ? '.' : rest[selected]);
|
|
585
622
|
const normalized = selected === undefined ? rest : rest.filter((_, index) => index !== selected);
|
|
586
|
-
return withContentStore(storeOf(root), () => verb === 'fold' && selected !== undefined
|
|
623
|
+
return withContentStore(storeOf(root), () => verb === 'fold' && selected !== undefined && !positionalsOf(normalized).some(one => /^#bound(?::|$)/.test(one))
|
|
587
624
|
? foldAt(root, undefined, normalized)
|
|
588
|
-
: run(root, normalized, [verb, ...normalized]));
|
|
625
|
+
: run(root, normalized, [verb, ...normalized]), () => standingOf(root).standing);
|
|
589
626
|
}
|
|
590
627
|
const under = argv[0] ?? '';
|
|
591
628
|
if (under && !under.startsWith('-') && places.includes(under)) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure projection of already admitted typed-object records.
|
|
3
|
+
* Input is the effective history already admitted by the host, preserving cell
|
|
4
|
+
* declarations before uses within each epoch and a deterministic selected context.
|
|
5
|
+
* This API performs no admission,
|
|
6
|
+
* signature verification, storage, transport, clock selection or execution.
|
|
7
|
+
* Object operations delegate to the existing Obligations implementation.
|
|
8
|
+
*/
|
|
9
|
+
export { objectFold } from './object.ts';
|
|
10
|
+
export type { ObjectReading } from './object.ts';
|
|
11
|
+
export type { ObjectRecord, ObjectContext } from '@lapxo/topos/wire';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure projection of already admitted typed-object records.
|
|
3
|
+
* Input is the effective history already admitted by the host, preserving cell
|
|
4
|
+
* declarations before uses within each epoch and a deterministic selected context.
|
|
5
|
+
* This API performs no admission,
|
|
6
|
+
* signature verification, storage, transport, clock selection or execution.
|
|
7
|
+
* Object operations delegate to the existing Obligations implementation.
|
|
8
|
+
*/
|
|
9
|
+
export { objectFold } from "./object.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Mark, Cell } from '@lapxo/obligations/views/field';
|
|
2
|
+
import type { ObjectRecord, ObjectContext } from '@lapxo/topos/wire';
|
|
3
|
+
/** Projection dispatches admitted acts into Obligatory; it defines no meet or propagation. */
|
|
4
|
+
export interface ObjectReading {
|
|
5
|
+
cell: string;
|
|
6
|
+
state: string;
|
|
7
|
+
parts: Cell<unknown>;
|
|
8
|
+
rest: readonly string[];
|
|
9
|
+
ownMarks: readonly (string | undefined)[];
|
|
10
|
+
ownClaims: readonly {
|
|
11
|
+
id: string | undefined;
|
|
12
|
+
origin: string;
|
|
13
|
+
}[];
|
|
14
|
+
marks: readonly Mark<unknown>[];
|
|
15
|
+
claims: readonly unknown[];
|
|
16
|
+
}
|
|
17
|
+
export declare function objectFold(records: readonly ObjectRecord[], context: ObjectContext): readonly ObjectReading[];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { cell, sign, join, require as requireFloor, observe, mark, parts, state, live, restOf } from '@lapxo/obligations/views/field';
|
|
2
|
+
import { restCoordinates } from '@lapxo/topos/wire';
|
|
3
|
+
export function objectFold(records, context) {
|
|
4
|
+
let world = new Map();
|
|
5
|
+
const definitions = new Map(records.filter(r => r.record === 'cell').map(r => [r.fields.scope, r]));
|
|
6
|
+
const codecs = new Map([...definitions].map(([name, c]) => [name, context.resolve(c)]));
|
|
7
|
+
const ids = new Map(records.map(r => [r.fields.id, r]));
|
|
8
|
+
for (const record of [...records].sort((a, b) => Number(a.fields.epoch) - Number(b.fields.epoch))) {
|
|
9
|
+
const f = record.fields, name = f.scope, at = Number(f.epoch);
|
|
10
|
+
if (record.record === 'cell') {
|
|
11
|
+
world = new Map([...world, [name, cell(name, at, [], restCoordinates(f.restsOn))]]);
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
const codec = codecs.get(name), L = codec.form.lattice(codec.params), held = world.get(name);
|
|
15
|
+
if (record.record === 'claim') {
|
|
16
|
+
const target = f.sign === '-1' ? ids.get(f.takes).fields : f;
|
|
17
|
+
const changed = observe(held, { id: f.id, at, origin: target.origin, span: codec.form.parse(codec.params, target.value), ...(f.takes ? { takes: f.takes } : {}) }, f.sign === '-1' ? -1 : 1);
|
|
18
|
+
const seen = [...changed.seen];
|
|
19
|
+
seen[seen.length - 1] = { ...seen.at(-1), id: f.id };
|
|
20
|
+
world = new Map([...world, [name, { ...changed, seen }]]);
|
|
21
|
+
}
|
|
22
|
+
else if (f.sign === '-1') {
|
|
23
|
+
const target = ids.get(f.takes).fields;
|
|
24
|
+
world = new Map([...world, [name, { ...held, marks: [...(held.marks ?? []), mark({ id: f.id, at, takes: f.takes, pole: target.pole, reach: 'local', span: codec.form.parse(codec.params, target.value) })] }]]);
|
|
25
|
+
}
|
|
26
|
+
else if (f.widens !== undefined) {
|
|
27
|
+
const changed = join(L, held, codec.form.parse(codec.params, f.value), f.widens, at);
|
|
28
|
+
const marks = [...(changed.marks ?? [])];
|
|
29
|
+
marks[marks.length - 1] = { ...marks.at(-1), id: f.id };
|
|
30
|
+
world = new Map([...world, [name, { ...changed, marks }]]);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
const span = codec.form.parse(codec.params, f.value);
|
|
34
|
+
world = f.pole === 'floor' ? requireFloor(L, world, name, span, { id: f.id, at }) : sign(L, world, name, span, { id: f.id, at });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return [...world].map(([name, c]) => { const codec = codecs.get(name), L = codec.form.lattice(codec.params); return { cell: name, state: state(L, c, world), parts: parts(L, c, world), rest: restOf(c, world), ownMarks: live(c.marks ?? []).map(m => m.id), ownClaims: live(c.seen).map(s => ({ id: s.id, origin: s.origin })), marks: live(c.marks ?? []), claims: live(c.seen) }; });
|
|
38
|
+
}
|
package/dist/fold/closed.d.ts
CHANGED
|
@@ -12,4 +12,4 @@ export declare function instrumentKeep(store: string, id: string): void;
|
|
|
12
12
|
export declare function receiptPlaces(root: string, store: string): readonly string[];
|
|
13
13
|
export declare function closeReceipts(root: string, store: string, semantic?: ReadonlyMap<string, string>): Promise<readonly string[]>;
|
|
14
14
|
/** One comparison. A place meets its receipt; the root meets when every receipt it names meets. */
|
|
15
|
-
export declare function meets(root: string, store: string, place: string, current?: boolean): boolean;
|
|
15
|
+
export declare function meets(root: string, store: string, place: string, current?: boolean, active?: readonly string[]): boolean;
|
package/dist/fold/closed.js
CHANGED
|
@@ -10,9 +10,10 @@ import { bytesDigest as hashBytes, fullDigest as hashFull } from "../host/digest
|
|
|
10
10
|
import { mountedCoordinatesIn, worldAt } from "./places.js";
|
|
11
11
|
import { ownLockOf } from "./signed.js";
|
|
12
12
|
import { viewsOf } from "./views.js";
|
|
13
|
+
import { keptPlace } from "./kept.js";
|
|
13
14
|
import { storeAt, storeOf } from "../land/ledger.js";
|
|
14
15
|
import { coordinatesUnder, observeFile, observeText } from "../observe/files.js";
|
|
15
|
-
import { carriedFrom } from "./resolved.js";
|
|
16
|
+
import { bytesOnly, carriedFrom } from "./resolved.js";
|
|
16
17
|
import { takenFor } from "../fold/place-inputs.js";
|
|
17
18
|
/** A region is closed when the digest of its bytes is the one its receipt names. Folding a closed region is idle: idleCount is how many were already closed, actSeconds the largest measured act or unpartitioned host work, receiptsSeen how many receipts were read and how long that took. */
|
|
18
19
|
let idle = 0;
|
|
@@ -178,7 +179,7 @@ export async function closeReceipts(root, store, semantic) {
|
|
|
178
179
|
return open;
|
|
179
180
|
}
|
|
180
181
|
/** One comparison. A place meets its receipt; the root meets when every receipt it names meets. */
|
|
181
|
-
export function meets(root, store, place, current = true) {
|
|
182
|
+
export function meets(root, store, place, current = true, active) {
|
|
182
183
|
const name = place.replace(/\/$/, '');
|
|
183
184
|
if (name === '') {
|
|
184
185
|
const at = Date.now();
|
|
@@ -192,12 +193,28 @@ export function meets(root, store, place, current = true) {
|
|
|
192
193
|
return bytes !== undefined && hashBytes(bytes, algorithm) === expected && meets(root, store, `${one}/`, current);
|
|
193
194
|
});
|
|
194
195
|
if (closed && carried) {
|
|
195
|
-
const algorithm = algorithmIn(own.join('\n'));
|
|
196
|
+
const algorithm = algorithmIn(own.join('\n')), hash = (text) => hashFull(text, algorithm);
|
|
196
197
|
const profile = readingProfile((observeText(join(root, LOCK)) ?? '').split('\n').filter(isWire), fieldOf);
|
|
197
|
-
|
|
198
|
+
// History keeps its canonical identity and bytes. It does not become a
|
|
199
|
+
// current execution merely because it shares a public carrier with one.
|
|
200
|
+
const readings = verifiedReadingReceipts(store, carried, hash, undefined, profile);
|
|
198
201
|
if (readings === undefined)
|
|
199
202
|
closed = false;
|
|
200
|
-
else if (readings)
|
|
203
|
+
else if (current && profile && readings) {
|
|
204
|
+
const stamp = instrumentKept(store);
|
|
205
|
+
const snapshot = active ?? (stamp ? keptPlace(store, undefined, stamp)?.observed : undefined);
|
|
206
|
+
if (snapshot === undefined)
|
|
207
|
+
closed = false;
|
|
208
|
+
else {
|
|
209
|
+
const units = snapshot.filter(line => fieldOf(line, 'scope').startsWith('receipts/readings/') && fieldOf(line, 'role') === 'writes');
|
|
210
|
+
const supplied = new Set(carried);
|
|
211
|
+
const present = units.length > 0 && units.every(line => supplied.has(line) || (fieldOf(line, 'measure') === 'observed' && supplied.has(bytesOnly(line))));
|
|
212
|
+
const fresh = present ? verifiedReadingReceipts(store, snapshot, hash, currentReadingEnvironment(store, root, hash, childFlags()), profile) : undefined;
|
|
213
|
+
if (!fresh)
|
|
214
|
+
closed = false;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (closed && readings)
|
|
201
218
|
process.stderr.write(`RECEIPTS ${readings} read · 0 opened · reading closures\n`);
|
|
202
219
|
}
|
|
203
220
|
seen = { count: named.size + (own.length > 0 ? 1 : 0), ms: Date.now() - at };
|
package/dist/fold/digests.js
CHANGED
|
@@ -160,8 +160,9 @@ const importsOf = (store, at, digest) => {
|
|
|
160
160
|
* A fold is a function of its points and the instrument is one of them, so a fold kept by another bound is another
|
|
161
161
|
* origin's fold — readable as history, never as this instrument's own state.
|
|
162
162
|
*/
|
|
163
|
-
export function instrumentOf(store, entry, standing = [], root
|
|
164
|
-
|
|
163
|
+
export function instrumentOf(store, entry, standing = [], root, releases = []) {
|
|
164
|
+
const coordinate = root === undefined ? resolve(entry) : resolve(root, entry);
|
|
165
|
+
return instrumentDigest(store, coordinate, standing, root ?? dirname(coordinate), releases).replace(/^[^:]*:/, '').slice(0, 12);
|
|
165
166
|
}
|
|
166
167
|
export function instrumentDigest(store, entry, standing = [], root = dirname(resolve(entry)), releases = []) {
|
|
167
168
|
const seen = instrumentCoordinates(store, entry, standing, root, releases);
|
package/dist/fold/object.d.ts
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export interface ObjectReading {
|
|
5
|
-
cell: string;
|
|
6
|
-
state: string;
|
|
7
|
-
parts: Cell<unknown>;
|
|
8
|
-
rest: readonly string[];
|
|
9
|
-
ownMarks: readonly (string | undefined)[];
|
|
10
|
-
ownClaims: readonly {
|
|
11
|
-
id: string | undefined;
|
|
12
|
-
origin: string;
|
|
13
|
-
}[];
|
|
14
|
-
marks: readonly Mark<unknown>[];
|
|
15
|
-
claims: readonly unknown[];
|
|
16
|
-
}
|
|
17
|
-
export declare function objectFold(records: readonly ObjectRecord[], context: ObjectContext): readonly ObjectReading[];
|
|
1
|
+
/** Compatibility path; the engine owns the single object projection. */
|
|
2
|
+
export { objectFold } from '../engine/index.ts';
|
|
3
|
+
export type { ObjectReading } from '../engine/index.ts';
|