toilscript 0.1.33 → 0.1.34
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/dist/cli.generated.d.ts +59 -9
- package/dist/cli.js +44 -1
- package/dist/cli.js.map +2 -2
- package/dist/importmap.json +2 -2
- package/dist/toilscript.generated.d.ts +51 -1
- package/dist/toilscript.js +74 -74
- package/dist/toilscript.js.map +4 -4
- package/dist/web.js +3 -3
- package/package.json +1 -1
- package/std/assembly/bindings/toildb.ts +16 -0
- package/std/assembly/toildb.ts +27 -0
- package/std/assembly/toilscript.d.ts +6 -4
package/dist/cli.generated.d.ts
CHANGED
|
@@ -2861,6 +2861,51 @@ declare module "types:toilscript/src/resolver" {
|
|
|
2861
2861
|
reportMode?: ReportMode): TypeNode | null;
|
|
2862
2862
|
}
|
|
2863
2863
|
}
|
|
2864
|
+
declare module "types:toilscript/src/dbcatalog" {
|
|
2865
|
+
import { Program } from "types:toilscript/src/program";
|
|
2866
|
+
import { Source } from "types:toilscript/src/ast";
|
|
2867
|
+
import { ClassDeclaration } from "types:toilscript/src/ast";
|
|
2868
|
+
/** FNV-1a 32-bit hash, matching `dataTypeId` in the parser. */
|
|
2869
|
+
export function fnv1a(name: string): number;
|
|
2870
|
+
/** One field of a `@data` value type, in declaration order. */
|
|
2871
|
+
export class FieldLayout {
|
|
2872
|
+
name: string;
|
|
2873
|
+
typeName: string;
|
|
2874
|
+
isArray: boolean;
|
|
2875
|
+
}
|
|
2876
|
+
/**
|
|
2877
|
+
* `schema_version`: a hash over the ORDERED field layout (name, type, is_array),
|
|
2878
|
+
* NOT the value-type name. Adding, removing, retyping, or REORDERING a field
|
|
2879
|
+
* changes it - so the runtime can tell a compatible (append-only) change from a
|
|
2880
|
+
* breaking one, instead of silently misreading old rows. (Flat, like toildb's
|
|
2881
|
+
* `SchemaDescriptor::layout_hash`: a change to a NESTED `@data` type's own fields
|
|
2882
|
+
* does not bump the parent - that lands with recursive layouts later.)
|
|
2883
|
+
*/
|
|
2884
|
+
export function layoutHash(fields: FieldLayout[]): number;
|
|
2885
|
+
/** Extract the encoded field layout of a `@data` class, in declaration order,
|
|
2886
|
+
* mirroring `injectDataCodec` (skip static; `Array<T>` -> element + array flag;
|
|
2887
|
+
* else scalar/string/`Uint8Array`/nested-`@data` by its type name). */
|
|
2888
|
+
export function dataFields(cls: ClassDeclaration): FieldLayout[];
|
|
2889
|
+
/** A `@migrate` free function `fn(old: OldType): NewType`. `oldVersion` is the
|
|
2890
|
+
* layout hash of `OldType` - i.e. the `schema_version` the old rows were written
|
|
2891
|
+
* under - so a read can dispatch on it and run the transform (lazy migration). */
|
|
2892
|
+
export class DataMigration {
|
|
2893
|
+
oldType: string;
|
|
2894
|
+
newType: string;
|
|
2895
|
+
fnName: string;
|
|
2896
|
+
oldVersion: number;
|
|
2897
|
+
}
|
|
2898
|
+
/** Every `@migrate` function across the (non-library) sources. `layouts` maps a
|
|
2899
|
+
* `@data` class name to its field layout, for the old-version hash. A migration
|
|
2900
|
+
* whose param/return is not a single named type, or whose old type has no
|
|
2901
|
+
* layout, is skipped. */
|
|
2902
|
+
export function collectMigrations(sources: Source[], layouts: Map<string, FieldLayout[]>): DataMigration[];
|
|
2903
|
+
/**
|
|
2904
|
+
* Build the `toildb.catalog` section bytes, or `null` if the program declares
|
|
2905
|
+
* no `@database`.
|
|
2906
|
+
*/
|
|
2907
|
+
export function buildToilDbCatalog(program: Program): Uint8Array | null;
|
|
2908
|
+
}
|
|
2864
2909
|
declare module "types:toilscript/src/parser" {
|
|
2865
2910
|
/**
|
|
2866
2911
|
* @fileoverview A TypeScript parser for the ToilScript subset.
|
|
@@ -2902,6 +2947,15 @@ declare module "types:toilscript/src/parser" {
|
|
|
2902
2947
|
ratelimitRouteCounter: number;
|
|
2903
2948
|
/** An array of parsed sources. */
|
|
2904
2949
|
sources: Source[];
|
|
2950
|
+
/** A `@data` value type's generated field reads (the `decodeFrom` body, `__o.`
|
|
2951
|
+
* form) keyed by class name, captured so `finish()` can regenerate `decodeInto`
|
|
2952
|
+
* with a `@migrate` version-dispatch prefix. */
|
|
2953
|
+
toildbCodecReads: Map<string, string>;
|
|
2954
|
+
/** A `@data` value type's declaration, keyed by class name (to find/replace its
|
|
2955
|
+
* `decodeInto` member when weaving migrations). */
|
|
2956
|
+
toildbCodecClasses: Map<string, ClassDeclaration>;
|
|
2957
|
+
/** Guards `weaveDataMigrations` so it runs exactly once (before element creation). */
|
|
2958
|
+
toildbWoven: boolean;
|
|
2905
2959
|
/** Current overridden module name. */
|
|
2906
2960
|
currentModuleName: string | null;
|
|
2907
2961
|
/** Compiler options. */
|
|
@@ -2924,6 +2978,9 @@ declare module "types:toilscript/src/parser" {
|
|
|
2924
2978
|
getDependee(dependent: string): string | null;
|
|
2925
2979
|
/** Finishes parsing. */
|
|
2926
2980
|
finish(): void;
|
|
2981
|
+
weaveDataMigrations(): void;
|
|
2982
|
+
/** Replace `newType`'s generated `decodeInto` with a version-dispatching one. */
|
|
2983
|
+
private weaveDecodeInto;
|
|
2927
2984
|
private checkToilDbKinds;
|
|
2928
2985
|
/** Map every `@database` class (incl. inside namespaces) to its
|
|
2929
2986
|
* collection-name -> handle-family-name. */
|
|
@@ -6456,7 +6513,8 @@ declare module "types:toilscript/src/ast" {
|
|
|
6456
6513
|
Action = 34,
|
|
6457
6514
|
Job = 35,
|
|
6458
6515
|
Derive = 36,
|
|
6459
|
-
|
|
6516
|
+
Migrate = 37,
|
|
6517
|
+
Admin = 38
|
|
6460
6518
|
}
|
|
6461
6519
|
export namespace DecoratorKind {
|
|
6462
6520
|
/** Returns the kind of the specified decorator name node. Defaults to {@link DecoratorKind.CUSTOM}. */
|
|
@@ -8604,14 +8662,6 @@ declare module "types:toilscript/src/builtins" {
|
|
|
8604
8662
|
/** Compiles runtime type information for use by stdlib. */
|
|
8605
8663
|
export function compileRTTI(compiler: Compiler): void;
|
|
8606
8664
|
}
|
|
8607
|
-
declare module "types:toilscript/src/dbcatalog" {
|
|
8608
|
-
import { Program } from "types:toilscript/src/program";
|
|
8609
|
-
/**
|
|
8610
|
-
* Build the `toildb.catalog` section bytes, or `null` if the program declares
|
|
8611
|
-
* no `@database`.
|
|
8612
|
-
*/
|
|
8613
|
-
export function buildToilDbCatalog(program: Program): Uint8Array | null;
|
|
8614
|
-
}
|
|
8615
8665
|
declare module "types:toilscript/src/passes/pass" {
|
|
8616
8666
|
/**
|
|
8617
8667
|
* @fileoverview Infrastructure for custom Binaryen passes.
|
package/dist/cli.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* SPDX-License-Identifier: Apache-2.0
|
|
6
6
|
*/
|
|
7
7
|
var se=Object.defineProperty;var Ne=Object.getOwnPropertyDescriptor;var Ue=Object.getOwnPropertyNames;var Me=Object.prototype.hasOwnProperty;var fn=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(r){throw n=[r],r}};var nn=(e,t)=>{for(var n in t)se(e,n,{get:t[n],enumerable:!0})},oe=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ue(t))!Me.call(e,s)&&s!==n&&se(e,s,{get:()=>t[s],enumerable:!(r=Ne(t,s))||r.enumerable});return e},Dn=(e,t,n)=>(oe(e,t,"default"),n&&oe(n,t,"default"));var le={};nn(le,{promises:()=>Pe});var Pe,ue=fn(()=>{"use strict";Pe={}});var fe={};nn(fe,{createRequire:()=>Ve});function Ve(){return function(t){throw new Error(`Cannot find module: '${t}'`)}}var ce=fn(()=>{"use strict"});var On={};nn(On,{argv:()=>He,cwd:()=>In,exit:()=>Ke,hrtime:()=>qe,platform:()=>Ge,umask:()=>je});function In(){return"."}function je(){return 0}function Ke(e=0){throw Error(`exit ${e}`)}function qe(e){var t=Xe.call(de),n=Math.floor(t*.001),r=Math.floor(t*1e6-n*1e9);return e&&(n-=e[0],r-=e[1],r<0&&(n--,r+=1e9)),[n,r]}var Ge,He,de,Xe,Ln=fn(()=>{"use strict";Ge="linux";He=[];de=globalThis.performance||{},Xe=de.now||function(){return new Date().getTime()}});var Rn={};nn(Rn,{basename:()=>Qe,delimiter:()=>it,dirname:()=>$e,extname:()=>nt,format:()=>et,isAbsolute:()=>Ye,join:()=>Je,normalize:()=>he,parse:()=>tt,relative:()=>Ze,resolve:()=>cn,sep:()=>kn,win32:()=>rt});function V(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function pe(e,t){for(var n="",r=0,s=-1,a=0,u,f=0;f<=e.length;++f){if(f<e.length)u=e.charCodeAt(f);else{if(u===47)break;u=47}if(u===47){if(!(s===f-1||a===1))if(s!==f-1&&a===2){if(n.length<2||r!==2||n.charCodeAt(n.length-1)!==46||n.charCodeAt(n.length-2)!==46){if(n.length>2){var h=n.lastIndexOf("/");if(h!==n.length-1){h===-1?(n="",r=0):(n=n.slice(0,h),r=n.length-1-n.lastIndexOf("/")),s=f,a=0;continue}}else if(n.length===2||n.length===1){n="",r=0,s=f,a=0;continue}}t&&(n.length>0?n+="/..":n="..",r=2)}else n.length>0?n+="/"+e.slice(s+1,f):n=e.slice(s+1,f),r=f-s-1;s=f,a=0}else u===46&&a!==-1?++a:a=-1}return n}function We(e,t){var n=t.dir||t.root,r=t.base||(t.name||"")+(t.ext||"");return n?n===t.root?n+r:n+e+r:r}function cn(){for(var e="",t=!1,n,r=arguments.length-1;r>=-1&&!t;r--){var s;r>=0?s=arguments[r]:(n===void 0&&(n=In()),s=n),V(s),s.length!==0&&(e=s+"/"+e,t=s.charCodeAt(0)===47)}return e=pe(e,!t),t?e.length>0?"/"+e:"/":e.length>0?e:"."}function he(e){if(V(e),e.length===0)return".";var t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47;return e=pe(e,!t),e.length===0&&!t&&(e="."),e.length>0&&n&&(e+="/"),t?"/"+e:e}function Ye(e){return V(e),e.length>0&&e.charCodeAt(0)===47}function Je(){if(arguments.length===0)return".";for(var e,t=0;t<arguments.length;++t){var n=arguments[t];V(n),n.length>0&&(e===void 0?e=n:e+="/"+n)}return e===void 0?".":he(e)}function Ze(e,t){if(V(e),V(t),e===t||(e=cn(e),t=cn(t),e===t))return"";if(e===".")return t;for(var n=1;n<e.length&&e.charCodeAt(n)===47;++n);for(var r=e.length,s=r-n,a=1;a<t.length&&t.charCodeAt(a)===47;++a);for(var u=t.length,f=u-a,h=s<f?s:f,b=-1,d=0;d<=h;++d){if(d===h){if(f>h){if(t.charCodeAt(a+d)===47)return t.slice(a+d+1);if(d===0)return t.slice(a+d)}else s>h&&(e.charCodeAt(n+d)===47?b=d:d===0&&(b=0));break}var g=e.charCodeAt(n+d),y=t.charCodeAt(a+d);if(g!==y)break;g===47&&(b=d)}var m="";for(d=n+b+1;d<=r;++d)(d===r||e.charCodeAt(d)===47)&&(m.length===0?m+="..":m+="/..");return m.length>0?m+t.slice(a+b):(a+=b,t.charCodeAt(a)===47&&++a,t.slice(a))}function $e(e){if(V(e),e.length===0)return".";for(var t=e.charCodeAt(0),n=t===47,r=-1,s=!0,a=e.length-1;a>=1;--a)if(t=e.charCodeAt(a),t===47){if(!s){r=a;break}}else s=!1;return r===-1?n?"/":".":n&&r===1?"//":e.slice(0,r)}function Qe(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');V(e);var n=0,r=-1,s=!0,a;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var u=t.length-1,f=-1;for(a=e.length-1;a>=0;--a){var h=e.charCodeAt(a);if(h===47){if(!s){n=a+1;break}}else f===-1&&(s=!1,f=a+1),u>=0&&(h===t.charCodeAt(u)?--u===-1&&(r=a):(u=-1,r=f))}return n===r?r=f:r===-1&&(r=e.length),e.slice(n,r)}else{for(a=e.length-1;a>=0;--a)if(e.charCodeAt(a)===47){if(!s){n=a+1;break}}else r===-1&&(s=!1,r=a+1);return r===-1?"":e.slice(n,r)}}function nt(e){V(e);for(var t=-1,n=0,r=-1,s=!0,a=0,u=e.length-1;u>=0;--u){var f=e.charCodeAt(u);if(f===47){if(!s){n=u+1;break}continue}r===-1&&(s=!1,r=u+1),f===46?t===-1?t=u:a!==1&&(a=1):t!==-1&&(a=-1)}return t===-1||r===-1||a===0||a===1&&t===r-1&&t===n+1?"":e.slice(t,r)}function et(e){if(e===null||typeof e!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return We("/",e)}function tt(e){V(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;var n=e.charCodeAt(0),r=n===47,s;r?(t.root="/",s=1):s=0;for(var a=-1,u=0,f=-1,h=!0,b=e.length-1,d=0;b>=s;--b){if(n=e.charCodeAt(b),n===47){if(!h){u=b+1;break}continue}f===-1&&(h=!1,f=b+1),n===46?a===-1?a=b:d!==1&&(d=1):a!==-1&&(d=-1)}return a===-1||f===-1||d===0||d===1&&a===f-1&&a===u+1?f!==-1&&(u===0&&r?t.base=t.name=e.slice(1,f):t.base=t.name=e.slice(u,f)):(u===0&&r?(t.name=e.slice(1,a),t.base=e.slice(1,f)):(t.name=e.slice(u,a),t.base=e.slice(u,f)),t.ext=e.slice(a,f)),u>0?t.dir=e.slice(0,u-1):r&&(t.dir="/"),t}var kn,it,rt,Nn=fn(()=>{"use strict";Ln();kn="/",it=":",rt=null});var xe={};nn(xe,{pathToFileURL:()=>ot});function at(e){return e.replace(/%/g,"%25").replace(/\\/g,"%5C").replace(/\n/g,"%0A").replace(/\r/g,"%0D").replace(/\t/g,"%09")}function ot(e){let t=cn(e);e.charCodeAt(e.length-1)===47&&t[t.length-1]!==kn&&(t+="/");let n=new URL("file://");return n.pathname=at(t),n}var ge=fn(()=>{"use strict";Nn()});var Wn={};nn(Wn,{Stats:()=>Cn,checkDiagnostics:()=>gn,compileString:()=>wt,configToArguments:()=>qn,createMemoryStream:()=>Kn,default:()=>Wn,defaultOptimizeLevel:()=>Se,defaultShrinkLevel:()=>we,definitionFiles:()=>St,libraryFiles:()=>H,libraryPrefix:()=>P,main:()=>Be,options:()=>zt,tscOptions:()=>Bt,version:()=>Hn});var st=Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]",j,sn,F,M,dn;st?(j=await import("fs"),sn=await import("module"),F=await import("path"),M=globalThis.process,dn=await import("url")):(j=await Promise.resolve().then(()=>(ue(),le)),sn=await Promise.resolve().then(()=>(ce(),fe)),F=await Promise.resolve().then(()=>(Nn(),Rn)),M=await Promise.resolve().then(()=>(Ln(),On)),dn=await Promise.resolve().then(()=>(ge(),xe)));var An=typeof process<"u"&&process||{},lt=An.env&&"CI"in An.env,ut="\x1B[90m",ft="\x1B[91m",ct="\x1B[92m",dt="\x1B[93m",pt="\x1B[94m",ht="\x1B[95m",xt="\x1B[96m",gt="\x1B[97m",W="\x1B[0m",en=class{constructor(t){this.stream=t,this.enabled=!!(this.stream&&this.stream.isTTY||lt)}gray(t){return this.enabled?ut+t+W:t}red(t){return this.enabled?ft+t+W:t}green(t){return this.enabled?ct+t+W:t}yellow(t){return this.enabled?dt+t+W:t}blue(t){return this.enabled?pt+t+W:t}magenta(t){return this.enabled?ht+t+W:t}cyan(t){return this.enabled?xt+t+W:t}white(t){return this.enabled?gt+t+W:t}},_n=new en(An.stdout),Ot=new en(An.stderr);function mt(e){for(var t=0,n=0,r=e.length;n<r;++n){let s=e.charCodeAt(n);s<128?t+=1:s<2048?t+=2:(s&64512)===55296&&n+1<r&&(e.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3}return t}function bt(e,t,n){var r=n-t;if(r<1)return"";for(var s=null,a=[],u=0,f;t<n;)f=e[t++],f<128?a[u++]=f:f>191&&f<224?a[u++]=(f&31)<<6|e[t++]&63:f>239&&f<365?(f=((f&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,a[u++]=55296+(f>>10),a[u++]=56320+(f&1023)):a[u++]=(f&15)<<12|(e[t++]&63)<<6|e[t++]&63,u>=8192&&((s||(s=[])).push(String.fromCharCode(...a)),u=0);return s?(u&&s.push(String.fromCharCode(...a.slice(0,u))),s.join("")):String.fromCharCode(...a.slice(0,u))}function yt(e,t,n){for(var r=n,s=0,a=e.length;s<a;++s){let u=e.charCodeAt(s),f;u<128?t[n++]=u:u<2048?(t[n++]=u>>6|192,t[n++]=u&63|128):(u&64512)===55296&&s+1<a&&((f=e.charCodeAt(s+1))&64512)===56320?(u=65536+((u&1023)<<10)+(f&1023),++s,t[n++]=u>>18|240,t[n++]=u>>12&63|128,t[n++]=u>>6&63|128,t[n++]=u&63|128):(t[n++]=u>>12|224,t[n++]=u>>6&63|128,t[n++]=u&63|128)}return n-r}var Tn={length:mt,read:bt,write:yt};var me=sn.createRequire(import.meta.url);function ye(e,t,n=!0){var r={},s=[],a=[],u=[],f={};Object.keys(t).forEach(d=>{if(!d.startsWith(" ")){var g=t[d];g.alias!=null&&(typeof g.alias=="string"?f[g.alias]=d:Array.isArray(g.alias)&&g.alias.forEach(y=>f[y]=d)),n&&g.default!=null&&(r[d]=g.default)}});for(var h=0,b=(e=e.slice()).length;h<b;++h){let d=e[h];if(d=="--"){++h;break}let g=/^(?:(-\w)(?:=(.*))?|(--\w{2,})(?:=(.*))?)$/.exec(d),y,m;if(g)t[d]?y=t[m=d]:g[1]!=null?(y=t[m=f[g[1].substring(1)]],y&&g[2]!=null&&(e[h--]=g[2])):g[3]!=null&&(y=t[m=g[3].substring(2)],y&&g[4]!=null&&(e[h--]=g[4]));else if(d.charCodeAt(0)==45)y=t[m=d];else{a.push(d);continue}if(y)if(y.value)Object.keys(y.value).forEach(i=>r[i]=y.value[i]);else if(y.type==null||y.type==="b")r[m]=!0;else if(h+1<e.length&&e[h+1].charCodeAt(0)!=45)switch(y.type){case"i":r[m]=parseInt(e[++h],10);break;case"I":r[m]=(r[m]||[]).concat(parseInt(e[++h],10));break;case"f":r[m]=parseFloat(e[++h]);break;case"F":r[m]=(r[m]||[]).concat(parseFloat(e[++h]));break;case"s":r[m]=String(e[++h]);break;case"S":r[m]=(r[m]||[]).concat(e[++h].split(","));break;default:s.push(d),--h}else switch(y.type){case"i":case"f":r[m]=y.default||0;break;case"s":r[m]=y.default||"";break;case"I":case"F":case"S":r[m]=y.default||[];break;default:s.push(d)}else s.push(d)}for(;h<b;)u.push(e[h++]);return n&&Mn(t,r),{options:r,unknown:s,arguments:a,trailing:u}}function ve(e,t){t||(t={});var n=t.indent||2,r=t.padding||24,s=t.eol||`
|
|
8
|
-
`,a={},u=[];Object.keys(e).forEach(b=>{var d=e[b];if(d.description!=null){for(var g="";g.length<n;)g+=" ";for(g+="--"+b,d.alias&&(g+=", -"+d.alias);g.length<r;)g+=" ";var y;!t.noCategories&&d.category?(y=a[d.category])||(a[d.category]=y=[]):y=u,Array.isArray(d.description)?y.push(g+d.description[0]+d.description.slice(1).map(m=>{for(let i=0;i<r;++i)m=" "+m;return s+m}).join("")):y.push(g+d.description)}});var f=[],h=!1;return Object.keys(a).forEach(b=>{h=!0,f.push(s+" "+_n.gray(b)+s),f.push(a[b].join(s))}),h&&u.length&&f.push(s+" "+_n.gray("Other")+s),f.push(u.join(s)),f.join(s)}function be(e,t){if(e!=null)switch(t){case void 0:case"b":return!!e;case"i":return Math.trunc(e)||0;case"f":return Number(e)||0;case"s":return e===!0?"":e===!1?null:String(e);case"I":return Array.isArray(e)||(e=[e]),e.map(n=>Math.trunc(n)||0);case"F":return Array.isArray(e)||(e=[e]),e.map(n=>Number(n)||0);case"S":return Array.isArray(e)||(e=[e]),e.map(String)}}function Un(e,t,n,r){let s={};for(let[a,{type:u,mutuallyExclusive:f,isPath:h,useNodeResolution:b,cliOnly:d}]of Object.entries(e)){let g=be(t[a],u),y=be(n[a],u);if(g==null){if(y!=null){if(d)continue;if(Array.isArray(y)){let m;h&&(y=y.map(i=>tn(i,r,b))),f!=null&&(m=t[f])?s[a]=y.filter(i=>!m.includes(i)):s[a]=y.slice()}else h&&(y=tn(y,r,b)),s[a]=y}}else if(y==null)Array.isArray(g)?s[a]=g.slice():s[a]=g;else if(Array.isArray(g)){if(d){s[a]=g.slice();continue}let m;h&&(y=y.map(i=>tn(i,r,b))),f!=null&&(m=t[f])?s[a]=[...g,...y.filter(i=>!g.includes(i)&&!m.includes(i))]:s[a]=[...g,...y.filter(i=>!g.includes(i))]}else s[a]=g}return s}function vt(e){let t=F.parse(e);return t.root||(t.root="./"),F.format(t)}function tn(e,t,n=!1){return F.isAbsolute(e)?e:n&&!e.startsWith(".")&&me.resolve?me.resolve(e,{paths:[t]}):vt(F.join(t,e))}function Mn(e,t){for(let[n,{default:r}]of Object.entries(e))t[n]==null&&r!=null&&(t[n]=r)}var Fe="0.1.33",Y={version:{category:"General",description:"Prints just the compiler's version and exits.",type:"b",alias:"v"},help:{category:"General",description:"Prints this message and exits.",type:"b",alias:"h"},config:{category:"General",description:"Configuration file to apply. CLI arguments take precedence.",type:"s",cliOnly:!0},target:{category:"General",description:"Configuration file target to use. Defaults to 'release'.",type:"s",cliOnly:!0},optimize:{category:"Optimization",description:["Optimizes the module. Typical shorthands are:",""," Default optimizations -O"," Make a release build -O --noAssert"," Make a debug build --debug"," Optimize for speed -Ospeed"," Optimize for size -Osize",""],type:"b",alias:"O"},optimizeLevel:{category:"Optimization",description:"How much to focus on optimizing code. [0-3]",type:"i"},shrinkLevel:{category:"Optimization",description:"How much to focus on shrinking code size. [0-2, s=1, z=2]",type:"i"},converge:{category:"Optimization",description:"Re-optimizes until no further improvements can be made.",type:"b",default:!1},noAssert:{category:"Optimization",description:"Replaces assertions with just their value without trapping.",type:"b",default:!1},outFile:{category:"Output",description:"Specifies the WebAssembly output file (.wasm).",type:"s",alias:"o",isPath:!0},textFile:{category:"Output",description:"Specifies the WebAssembly text output file (.wat).",type:"s",alias:"t",isPath:!0},rpcModule:{category:"Output",description:"Emits a .ts module: the @data codec + the typed client-callable Server surface.",type:"s",isPath:!0},rpcRuntime:{category:"Output",description:"Import specifier for the DataWriter/DataReader codec in the emitted RPC module.",type:"s",default:"toiljs/io"},bindings:{category:"Output",description:["Specifies the bindings to generate (.js + .d.ts).",""," esm JavaScript bindings & typings for ESM integration."," raw Like esm, but exports just the instantiate function."," Useful where modules are meant to be instantiated"," multiple times or non-ESM imports must be provided."],type:"S",alias:"b"},sourceMap:{category:"Debugging",description:["Enables source map generation. Optionally takes the URL","used to reference the source map from the binary file."],type:"s"},uncheckedBehavior:{category:"Debugging",description:["Changes the behavior of unchecked() expressions.","Using this option can potentially cause breakage.",""," default The default behavior: unchecked operations are"," only used inside of unchecked()."," never Unchecked operations are never used, even when"," inside of unchecked()."," always Unchecked operations are always used if possible,"," whether or not unchecked() is used."],type:"s",default:"default"},debug:{category:"Debugging",description:"Enables debug information in emitted binaries.",type:"b",default:!1},importMemory:{category:"Features",description:"Imports the memory from 'env.memory'.",type:"b",default:!1},noExportMemory:{category:"Features",description:"Does not export the memory as 'memory'.",type:"b",default:!1},initialMemory:{category:"Features",description:"Sets the initial memory size in pages.",type:"i",default:0},maximumMemory:{category:"Features",description:"Sets the maximum memory size in pages.",type:"i",default:0},sharedMemory:{category:"Features",description:"Declare memory as shared. Requires maximumMemory.",type:"b",default:!1},zeroFilledMemory:{category:"Features",description:"Assume imported memory is zeroed. Requires importMemory.",type:"b",default:!1},importTable:{category:"Features",description:"Imports the function table from 'env.table'.",type:"b",default:!1},exportTable:{category:"Features",description:"Exports the function table as 'table'.",type:"b",default:!1},exportStart:{category:"Features",description:["Exports the start function using the specified name instead","of calling it implicitly. Useful to obtain the exported memory","before executing any code accessing it."],type:"s"},runtime:{category:"Features",description:["Specifies the runtime variant to include in the program.",""," incremental TLSF + incremental GC (default)"," minimal TLSF + lightweight GC invoked externally"," stub Minimal runtime stub (never frees)"," ... Path to a custom runtime implementation",""],type:"s",default:"incremental"},exportRuntime:{category:"Features",description:["Always exports the runtime helpers (__new, __collect, __pin etc.).","Automatically determined when generation of --bindings is enabled."],type:"b",default:!1},stackSize:{category:"Features",description:["Overrides the stack size. Only relevant for incremental GC","or when using a custom runtime that requires stack space.","Defaults to 0 without and to 32768 with incremental GC."],default:0,type:"i"},enable:{category:"Features",description:["Enables WebAssembly features being disabled by default.",""," threads Threading and atomic operations."," simd SIMD types and operations."," reference-types Reference types and operations."," gc Garbage collection (WIP)."," stringref String reference types."," relaxed-simd Relaxed SIMD operations.",""],TODO_doesNothingYet:[" exception-handling Exception handling."," tail-calls Tail call operations."," multi-value Multi value types."," memory64 Memory64 operations."," extended-const Extended const expressions."],type:"S",mutuallyExclusive:"disable"},disable:{category:"Features",description:["Disables WebAssembly features being enabled by default.",""," mutable-globals Mutable global imports and exports."," sign-extension Sign-extension operations"," nontrapping-f2i Non-trapping float to integer ops."," bulk-memory Bulk memory operations.",""],type:"S",mutuallyExclusive:"enable"},use:{category:"Features",description:["Aliases a global object under another name, e.g., to switch","the default 'Math' implementation used: --use Math=JSMath","Can also be used to introduce an integer constant."],type:"S",alias:"u"},lowMemoryLimit:{category:"Features",description:"Enforces very low (<64k) memory constraints.",default:0,type:"i"},memoryBase:{category:"Linking",description:"Sets the start offset of emitted memory segments.",type:"i",default:0},tableBase:{category:"Linking",description:"Sets the start offset of emitted table elements.",type:"i",default:0},transform:{category:"API",description:"Specifies the path to a custom transform to load.",type:"S",isPath:!0,useNodeResolution:!0},trapMode:{category:"Binaryen",description:["Sets the trap mode to use.",""," allow Allow trapping operations. This is the default."," clamp Replace trapping operations with clamping semantics."," js Replace trapping operations with JS semantics.",""],type:"s",default:"allow"},runPasses:{category:"Binaryen",description:["Specifies additional Binaryen passes to run after other","optimizations, if any. See: Binaryen/src/passes/pass.cpp"],type:"s"},noValidate:{category:"Binaryen",description:"Skips validating the module using Binaryen.",type:"b",default:!1},baseDir:{description:"Specifies the base directory of input and output files.",type:"s",default:"."},noColors:{description:"Disables terminal colors.",type:"b",default:!1},noUnsafe:{description:["Disallows the use of unsafe features in user code.","Does not affect library files and external modules."],type:"b",default:!1},disableWarning:{description:["Disables warnings matching the given diagnostic code.","If no diagnostic code is given, all warnings are disabled."],type:"I"},noEmit:{description:"Performs compilation as usual but does not emit code.",type:"b",default:!1},showConfig:{description:"Print computed compiler options and exit.",type:"b",default:!1},stats:{description:"Prints statistics on I/O and compile times.",type:"b",default:!1},pedantic:{description:"Make yourself sad for no good reason.",type:"b",default:!1},lib:{description:["Adds one or multiple paths to custom library components and","uses exports of all top-level files at this path as globals."],type:"S",isPath:!0},path:{description:["Adds one or multiple paths to package resolution, similar","to node_modules. Prefers an 'ascMain' entry in a package's","package.json and falls back to an inner 'assembly/' folder."],type:"S",isPath:!0},wasm:{description:"Uses the specified Wasm binary of the compiler.",type:"s"}," ...":{description:"Specifies node.js options (CLI only). See: node --help"},"-Os":{value:{optimizeLevel:0,shrinkLevel:1}},"-Oz":{value:{optimizeLevel:0,shrinkLevel:2}},"-O0":{value:{optimizeLevel:0,shrinkLevel:0}},"-O1":{value:{optimizeLevel:1,shrinkLevel:0}},"-O2":{value:{optimizeLevel:2,shrinkLevel:0}},"-O3":{value:{optimizeLevel:3,shrinkLevel:0}},"-O0s":{value:{optimizeLevel:0,shrinkLevel:1}},"-O1s":{value:{optimizeLevel:1,shrinkLevel:1}},"-O2s":{value:{optimizeLevel:2,shrinkLevel:1}},"-O3s":{value:{optimizeLevel:3,shrinkLevel:1}},"-O0z":{value:{optimizeLevel:0,shrinkLevel:2}},"-O1z":{value:{optimizeLevel:1,shrinkLevel:2}},"-O2z":{value:{optimizeLevel:2,shrinkLevel:2}},"-O3z":{value:{optimizeLevel:3,shrinkLevel:2}},"-Ospeed":{value:{optimizeLevel:3,shrinkLevel:0}},"-Osize":{value:{optimizeLevel:0,shrinkLevel:2,converge:!0}},"--measure":{value:{stats:!0}}},Ee="~lib/",Ae={array:`/// <reference path="./rt/index.d.ts" />
|
|
8
|
+
`,a={},u=[];Object.keys(e).forEach(b=>{var d=e[b];if(d.description!=null){for(var g="";g.length<n;)g+=" ";for(g+="--"+b,d.alias&&(g+=", -"+d.alias);g.length<r;)g+=" ";var y;!t.noCategories&&d.category?(y=a[d.category])||(a[d.category]=y=[]):y=u,Array.isArray(d.description)?y.push(g+d.description[0]+d.description.slice(1).map(m=>{for(let i=0;i<r;++i)m=" "+m;return s+m}).join("")):y.push(g+d.description)}});var f=[],h=!1;return Object.keys(a).forEach(b=>{h=!0,f.push(s+" "+_n.gray(b)+s),f.push(a[b].join(s))}),h&&u.length&&f.push(s+" "+_n.gray("Other")+s),f.push(u.join(s)),f.join(s)}function be(e,t){if(e!=null)switch(t){case void 0:case"b":return!!e;case"i":return Math.trunc(e)||0;case"f":return Number(e)||0;case"s":return e===!0?"":e===!1?null:String(e);case"I":return Array.isArray(e)||(e=[e]),e.map(n=>Math.trunc(n)||0);case"F":return Array.isArray(e)||(e=[e]),e.map(n=>Number(n)||0);case"S":return Array.isArray(e)||(e=[e]),e.map(String)}}function Un(e,t,n,r){let s={};for(let[a,{type:u,mutuallyExclusive:f,isPath:h,useNodeResolution:b,cliOnly:d}]of Object.entries(e)){let g=be(t[a],u),y=be(n[a],u);if(g==null){if(y!=null){if(d)continue;if(Array.isArray(y)){let m;h&&(y=y.map(i=>tn(i,r,b))),f!=null&&(m=t[f])?s[a]=y.filter(i=>!m.includes(i)):s[a]=y.slice()}else h&&(y=tn(y,r,b)),s[a]=y}}else if(y==null)Array.isArray(g)?s[a]=g.slice():s[a]=g;else if(Array.isArray(g)){if(d){s[a]=g.slice();continue}let m;h&&(y=y.map(i=>tn(i,r,b))),f!=null&&(m=t[f])?s[a]=[...g,...y.filter(i=>!g.includes(i)&&!m.includes(i))]:s[a]=[...g,...y.filter(i=>!g.includes(i))]}else s[a]=g}return s}function vt(e){let t=F.parse(e);return t.root||(t.root="./"),F.format(t)}function tn(e,t,n=!1){return F.isAbsolute(e)?e:n&&!e.startsWith(".")&&me.resolve?me.resolve(e,{paths:[t]}):vt(F.join(t,e))}function Mn(e,t){for(let[n,{default:r}]of Object.entries(e))t[n]==null&&r!=null&&(t[n]=r)}var Fe="0.1.34",Y={version:{category:"General",description:"Prints just the compiler's version and exits.",type:"b",alias:"v"},help:{category:"General",description:"Prints this message and exits.",type:"b",alias:"h"},config:{category:"General",description:"Configuration file to apply. CLI arguments take precedence.",type:"s",cliOnly:!0},target:{category:"General",description:"Configuration file target to use. Defaults to 'release'.",type:"s",cliOnly:!0},optimize:{category:"Optimization",description:["Optimizes the module. Typical shorthands are:",""," Default optimizations -O"," Make a release build -O --noAssert"," Make a debug build --debug"," Optimize for speed -Ospeed"," Optimize for size -Osize",""],type:"b",alias:"O"},optimizeLevel:{category:"Optimization",description:"How much to focus on optimizing code. [0-3]",type:"i"},shrinkLevel:{category:"Optimization",description:"How much to focus on shrinking code size. [0-2, s=1, z=2]",type:"i"},converge:{category:"Optimization",description:"Re-optimizes until no further improvements can be made.",type:"b",default:!1},noAssert:{category:"Optimization",description:"Replaces assertions with just their value without trapping.",type:"b",default:!1},outFile:{category:"Output",description:"Specifies the WebAssembly output file (.wasm).",type:"s",alias:"o",isPath:!0},textFile:{category:"Output",description:"Specifies the WebAssembly text output file (.wat).",type:"s",alias:"t",isPath:!0},rpcModule:{category:"Output",description:"Emits a .ts module: the @data codec + the typed client-callable Server surface.",type:"s",isPath:!0},rpcRuntime:{category:"Output",description:"Import specifier for the DataWriter/DataReader codec in the emitted RPC module.",type:"s",default:"toiljs/io"},bindings:{category:"Output",description:["Specifies the bindings to generate (.js + .d.ts).",""," esm JavaScript bindings & typings for ESM integration."," raw Like esm, but exports just the instantiate function."," Useful where modules are meant to be instantiated"," multiple times or non-ESM imports must be provided."],type:"S",alias:"b"},sourceMap:{category:"Debugging",description:["Enables source map generation. Optionally takes the URL","used to reference the source map from the binary file."],type:"s"},uncheckedBehavior:{category:"Debugging",description:["Changes the behavior of unchecked() expressions.","Using this option can potentially cause breakage.",""," default The default behavior: unchecked operations are"," only used inside of unchecked()."," never Unchecked operations are never used, even when"," inside of unchecked()."," always Unchecked operations are always used if possible,"," whether or not unchecked() is used."],type:"s",default:"default"},debug:{category:"Debugging",description:"Enables debug information in emitted binaries.",type:"b",default:!1},importMemory:{category:"Features",description:"Imports the memory from 'env.memory'.",type:"b",default:!1},noExportMemory:{category:"Features",description:"Does not export the memory as 'memory'.",type:"b",default:!1},initialMemory:{category:"Features",description:"Sets the initial memory size in pages.",type:"i",default:0},maximumMemory:{category:"Features",description:"Sets the maximum memory size in pages.",type:"i",default:0},sharedMemory:{category:"Features",description:"Declare memory as shared. Requires maximumMemory.",type:"b",default:!1},zeroFilledMemory:{category:"Features",description:"Assume imported memory is zeroed. Requires importMemory.",type:"b",default:!1},importTable:{category:"Features",description:"Imports the function table from 'env.table'.",type:"b",default:!1},exportTable:{category:"Features",description:"Exports the function table as 'table'.",type:"b",default:!1},exportStart:{category:"Features",description:["Exports the start function using the specified name instead","of calling it implicitly. Useful to obtain the exported memory","before executing any code accessing it."],type:"s"},runtime:{category:"Features",description:["Specifies the runtime variant to include in the program.",""," incremental TLSF + incremental GC (default)"," minimal TLSF + lightweight GC invoked externally"," stub Minimal runtime stub (never frees)"," ... Path to a custom runtime implementation",""],type:"s",default:"incremental"},exportRuntime:{category:"Features",description:["Always exports the runtime helpers (__new, __collect, __pin etc.).","Automatically determined when generation of --bindings is enabled."],type:"b",default:!1},stackSize:{category:"Features",description:["Overrides the stack size. Only relevant for incremental GC","or when using a custom runtime that requires stack space.","Defaults to 0 without and to 32768 with incremental GC."],default:0,type:"i"},enable:{category:"Features",description:["Enables WebAssembly features being disabled by default.",""," threads Threading and atomic operations."," simd SIMD types and operations."," reference-types Reference types and operations."," gc Garbage collection (WIP)."," stringref String reference types."," relaxed-simd Relaxed SIMD operations.",""],TODO_doesNothingYet:[" exception-handling Exception handling."," tail-calls Tail call operations."," multi-value Multi value types."," memory64 Memory64 operations."," extended-const Extended const expressions."],type:"S",mutuallyExclusive:"disable"},disable:{category:"Features",description:["Disables WebAssembly features being enabled by default.",""," mutable-globals Mutable global imports and exports."," sign-extension Sign-extension operations"," nontrapping-f2i Non-trapping float to integer ops."," bulk-memory Bulk memory operations.",""],type:"S",mutuallyExclusive:"enable"},use:{category:"Features",description:["Aliases a global object under another name, e.g., to switch","the default 'Math' implementation used: --use Math=JSMath","Can also be used to introduce an integer constant."],type:"S",alias:"u"},lowMemoryLimit:{category:"Features",description:"Enforces very low (<64k) memory constraints.",default:0,type:"i"},memoryBase:{category:"Linking",description:"Sets the start offset of emitted memory segments.",type:"i",default:0},tableBase:{category:"Linking",description:"Sets the start offset of emitted table elements.",type:"i",default:0},transform:{category:"API",description:"Specifies the path to a custom transform to load.",type:"S",isPath:!0,useNodeResolution:!0},trapMode:{category:"Binaryen",description:["Sets the trap mode to use.",""," allow Allow trapping operations. This is the default."," clamp Replace trapping operations with clamping semantics."," js Replace trapping operations with JS semantics.",""],type:"s",default:"allow"},runPasses:{category:"Binaryen",description:["Specifies additional Binaryen passes to run after other","optimizations, if any. See: Binaryen/src/passes/pass.cpp"],type:"s"},noValidate:{category:"Binaryen",description:"Skips validating the module using Binaryen.",type:"b",default:!1},baseDir:{description:"Specifies the base directory of input and output files.",type:"s",default:"."},noColors:{description:"Disables terminal colors.",type:"b",default:!1},noUnsafe:{description:["Disallows the use of unsafe features in user code.","Does not affect library files and external modules."],type:"b",default:!1},disableWarning:{description:["Disables warnings matching the given diagnostic code.","If no diagnostic code is given, all warnings are disabled."],type:"I"},noEmit:{description:"Performs compilation as usual but does not emit code.",type:"b",default:!1},showConfig:{description:"Print computed compiler options and exit.",type:"b",default:!1},stats:{description:"Prints statistics on I/O and compile times.",type:"b",default:!1},pedantic:{description:"Make yourself sad for no good reason.",type:"b",default:!1},lib:{description:["Adds one or multiple paths to custom library components and","uses exports of all top-level files at this path as globals."],type:"S",isPath:!0},path:{description:["Adds one or multiple paths to package resolution, similar","to node_modules. Prefers an 'ascMain' entry in a package's","package.json and falls back to an inner 'assembly/' folder."],type:"S",isPath:!0},wasm:{description:"Uses the specified Wasm binary of the compiler.",type:"s"}," ...":{description:"Specifies node.js options (CLI only). See: node --help"},"-Os":{value:{optimizeLevel:0,shrinkLevel:1}},"-Oz":{value:{optimizeLevel:0,shrinkLevel:2}},"-O0":{value:{optimizeLevel:0,shrinkLevel:0}},"-O1":{value:{optimizeLevel:1,shrinkLevel:0}},"-O2":{value:{optimizeLevel:2,shrinkLevel:0}},"-O3":{value:{optimizeLevel:3,shrinkLevel:0}},"-O0s":{value:{optimizeLevel:0,shrinkLevel:1}},"-O1s":{value:{optimizeLevel:1,shrinkLevel:1}},"-O2s":{value:{optimizeLevel:2,shrinkLevel:1}},"-O3s":{value:{optimizeLevel:3,shrinkLevel:1}},"-O0z":{value:{optimizeLevel:0,shrinkLevel:2}},"-O1z":{value:{optimizeLevel:1,shrinkLevel:2}},"-O2z":{value:{optimizeLevel:2,shrinkLevel:2}},"-O3z":{value:{optimizeLevel:3,shrinkLevel:2}},"-Ospeed":{value:{optimizeLevel:3,shrinkLevel:0}},"-Osize":{value:{optimizeLevel:0,shrinkLevel:2,converge:!0}},"--measure":{value:{stats:!0}}},Ee="~lib/",Ae={array:`/// <reference path="./rt/index.d.ts" />
|
|
9
9
|
|
|
10
10
|
import { BLOCK_MAXSIZE } from "./rt/common";
|
|
11
11
|
import { Runtime } from "shared/runtime";
|
|
@@ -4811,6 +4811,22 @@ export namespace toildbHost {
|
|
|
4811
4811
|
// @ts-ignore: decorator
|
|
4812
4812
|
@external("env", "data.take_result")
|
|
4813
4813
|
export declare function takeResult(outPtr: usize, outLen: i32): i32;
|
|
4814
|
+
|
|
4815
|
+
// The schema version the LAST value-returning read's row was written under, so
|
|
4816
|
+
// the generated decoder can default fields added since / reject an unknown
|
|
4817
|
+
// layout. A u32 version rides in the non-negative range; -1 means the last op
|
|
4818
|
+
// returned no value (or the host does not track a version). Does not drain the
|
|
4819
|
+
// result stash, so it may be read before or after \`takeResult\`.
|
|
4820
|
+
// @ts-ignore: decorator
|
|
4821
|
+
@external("env", "data.result_schema_version")
|
|
4822
|
+
export declare function resultSchemaVersion(): i64;
|
|
4823
|
+
|
|
4824
|
+
// 1 if the current call's kind may issue a record write, else 0. The generated
|
|
4825
|
+
// reader uses it to skip the rewrite-on-read convergence write in a read-only
|
|
4826
|
+
// \`@query\` (where it would be rejected) rather than attempt a doomed write.
|
|
4827
|
+
// @ts-ignore: decorator
|
|
4828
|
+
@external("env", "data.write_allowed")
|
|
4829
|
+
export declare function writeAllowed(): i32;
|
|
4814
4830
|
}
|
|
4815
4831
|
`,"bindings/webcrypto":`// Host-import declarations for the Web Crypto surface. The production edge
|
|
4816
4832
|
// (toil-backend \`src/wasm/host/import_functions/crypto\`) and the toiljs dev
|
|
@@ -18708,6 +18724,24 @@ export function __toildbResolve(name: string): u32 {
|
|
|
18708
18724
|
return load<u32>(out.dataStart);
|
|
18709
18725
|
}
|
|
18710
18726
|
|
|
18727
|
+
/// The schema version of the last value-returning read's row (or -1). The
|
|
18728
|
+
/// generated \`decodeInto\` of a \`@migrate\`-d value type calls this to dispatch an
|
|
18729
|
+
/// old-layout row through its transform. Global so generated user-code reaches it
|
|
18730
|
+
/// (like \`__toildbResolve\`).
|
|
18731
|
+
export function __toildbReadVersion(): i64 {
|
|
18732
|
+
return toildbHost.resultSchemaVersion();
|
|
18733
|
+
}
|
|
18734
|
+
|
|
18735
|
+
/// Set true by a woven \`decodeInto\` when it migrates an old-layout row, so the
|
|
18736
|
+
/// reading handle can converge the row (rewrite-on-read). The handle resets it
|
|
18737
|
+
/// before each decode and reads it after; the dispatch marks it AFTER the
|
|
18738
|
+
/// transform runs, so a transform that itself reads (resetting the flag) does not
|
|
18739
|
+
/// clear the outer migration.
|
|
18740
|
+
let __toildbMigratedFlag: bool = false;
|
|
18741
|
+
export function __toildbResetMigrated(): void { __toildbMigratedFlag = false; }
|
|
18742
|
+
export function __toildbMarkMigrated(): void { __toildbMigratedFlag = true; }
|
|
18743
|
+
export function __toildbWasMigrated(): bool { return __toildbMigratedFlag; }
|
|
18744
|
+
|
|
18711
18745
|
/// Pull the last stashed variable-length result of \`len\` bytes into a buffer.
|
|
18712
18746
|
function __toildbTake(len: i32): Uint8Array {
|
|
18713
18747
|
const buf = new Uint8Array(len);
|
|
@@ -18744,8 +18778,17 @@ export class Documents<K, V> {
|
|
|
18744
18778
|
const kb = key.encode();
|
|
18745
18779
|
const status = toildbHost.get(this.__handle, kb.dataStart, kb.byteLength);
|
|
18746
18780
|
if (status < 0) return null;
|
|
18781
|
+
__toildbResetMigrated();
|
|
18747
18782
|
const v = instantiate<V>();
|
|
18748
18783
|
v.decodeInto(__toildbTake(status));
|
|
18784
|
+
// Rewrite-on-read convergence: if this row was lazily migrated from an older
|
|
18785
|
+
// layout AND the current call may write, persist the migrated value so it
|
|
18786
|
+
// stops being re-migrated. Best-effort: a read-only kind skips it, and a
|
|
18787
|
+
// failed patch is ignored (the in-memory value is already correct).
|
|
18788
|
+
if (__toildbWasMigrated() && toildbHost.writeAllowed() == 1) {
|
|
18789
|
+
const nb = v.encode();
|
|
18790
|
+
toildbHost.patch(this.__handle, kb.dataStart, kb.byteLength, nb.dataStart, nb.byteLength, 0);
|
|
18791
|
+
}
|
|
18749
18792
|
return v;
|
|
18750
18793
|
}
|
|
18751
18794
|
|