@note3/utils 0.1.16 → 0.1.18

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.
@@ -1,2 +1,2 @@
1
- import{v as i,x as s}from"./chunk-WVHDYKM7.min.js";function A(t){return typeof t=="string"?t:JSON.stringify(t)}function u(t,n,p,e){let o=A(t),r=e??i({content:o,parentID:n,after:p,ts:s()},7);return{en:r,applogs:[{en:r,at:"block/content",vl:o}]}}function I(t,n,p,e){let o=e??i({blockID:t,childOf:n,after:p,ts:s()},7);return{en:o,applogs:[{en:o,at:"relation/block",vl:t},{en:o,at:"relation/childOf",vl:n},{en:o,at:"relation/after",vl:p}]}}function g(t,n,p){let e=[],{en:o,applogs:r}=u(t.content,n,p);if(e.push(...r),n){let{applogs:a}=I(o,n,p??null);e.push(...a)}let l=null;if(t.children)for(let a of t.children){let c=g(a,o,l);e.push(...c.applogs),l=c.blockID}return{blockID:o,applogs:e}}function ct(t,n){let p=[],e=[],o=null;for(let r of t){let l=g(r,n,o);p.push(...l.applogs),e.push(l.blockID),o=l.blockID}return{rootIDs:e,applogs:p}}function At(t){return g(t)}export{u as a,I as b,g as c,ct as d,At as e};
2
- //# sourceMappingURL=chunk-WIPAJIX5.min.js.map
1
+ import{v as i,x as s}from"./chunk-KUB6PLBB.min.js";function A(t){return typeof t=="string"?t:JSON.stringify(t)}function u(t,n,p,e){let o=A(t),r=e??i({content:o,parentID:n,after:p,ts:s()},7);return{en:r,applogs:[{en:r,at:"block/content",vl:o}]}}function I(t,n,p,e){let o=e??i({blockID:t,childOf:n,after:p,ts:s()},7);return{en:o,applogs:[{en:o,at:"relation/block",vl:t},{en:o,at:"relation/childOf",vl:n},{en:o,at:"relation/after",vl:p}]}}function g(t,n,p){let e=[],{en:o,applogs:r}=u(t.content,n,p);if(e.push(...r),n){let{applogs:a}=I(o,n,p??null);e.push(...a)}let l=null;if(t.children)for(let a of t.children){let c=g(a,o,l);e.push(...c.applogs),l=c.blockID}return{blockID:o,applogs:e}}function At(t,n){let p=[],e=[],o=null;for(let r of t){let l=g(r,n,o);p.push(...l.applogs),e.push(l.blockID),o=l.blockID}return{rootIDs:e,applogs:p}}function ut(t){return g(t)}export{u as a,I as b,g as c,At as d,ut as e};
2
+ //# sourceMappingURL=chunk-U5CYBCGY.min.js.map
@@ -1,2 +1,2 @@
1
- import{A as Z,B as C,a as M,b as _,c as q,d as E,e as J,f as A,g as H,h as T,i as B,j as W,k as j,l as u,m as F,n as $,o as k,p as h,q as V,r as f,s as Q,t as X,u as Y,w as G,y as x,z as w}from"./chunk-WVHDYKM7.min.js";var{WARN:ue,LOG:we,DEBUG:de,VERBOSE:U,ERROR:Oe}=W.setup(W.INFO),pe=f("queryDivergencesByPrev",function(e){de(`queryDivergencesByPrev<${e.nameAndSizeUntracked}>`),e.filters.includes("lastWriteWins")&&ue("queryDivergencesByPrev on thread lastWriteWins",e);let t=h(()=>{let s=new Map,i=new Set;U("all applogs:",e.applogs);for(let n of e.applogs){let a;n.pv&&(a=n.pv&&s.get(n.pv.toString()),i.delete(n.pv.toString())),U("traversing log",{log:n,prevLogs:a,leafs:Array.from(i)}),s.set(n.cid,a?[...a,n]:[n]),i.add(n.cid)}return Array.from(i).map(n=>{let a=new C(u({caller:"DivergenceLeaf",thread:e,pattern:`leaf: ${n}`}),s.get(n),e.filters,!0);return{log:a.latestLog,thread:a}})},{name:u({caller:"queryDivergencesByPrev",thread:e})});return U.isDisabled||A(()=>U("[queryDivergencesByPrev] result:",T(t))),t},{equals:M.structural});var ee=class{constructor(r,e,t=null){this.logsOfThisNode=r,this.variables=e,this.prevNode=t,B(this,{threadOfTrail:q})}get record(){return this.variables}get threadOfTrail(){return this.prevNode?x([this.logsOfThisNode,this.prevNode.threadOfTrail]):this.logsOfThisNode}get trailLogs(){return this.threadOfTrail.applogs}},P=class{constructor(r){this.nodes=r,B(this,{threadOfAllTrails:q,size:q,isEmpty:q})}get size(){return this.records.length}get isEmpty(){return this.records.length===0}get untrackedSize(){return E(()=>this.records.length)}get records(){return h(()=>this.nodes.map(({variables:r})=>r),{name:"QueryResult.records"})}get leafNodeThread(){return x(h(()=>this.nodes.map(({logsOfThisNode:r})=>r),{name:"QueryResult.leafNodeThread"}))}get leafNodeLogSet(){return h(()=>this.nodes.map(({logsOfThisNode:r})=>r.applogs),{name:"QueryResult.leafNodeLogSet"})}get leafNodeLogs(){return h(()=>this.nodes.flatMap(({logsOfThisNode:r})=>r.applogs),{name:"QueryResult.leafNodeLogs"})}get threadOfAllTrails(){return x(h(()=>this.nodes.map(r=>r.threadOfTrail),{name:"QueryResult.threadOfAllTrails"}))}get thread(){return this.threadOfAllTrails}get allApplogs(){return this.threadOfAllTrails.applogs}},{WARN:Te,LOG:I,DEBUG:N,VERBOSE:o,ERROR:O}=W.setup(W.INFO,{prefix:"[q]"}),L=null,ce=f("lastWriteWins",function(e,{inverseToOnlyReturnFirstLogs:t,tolerateAlreadyFiltered:s}={}){if(o(`lastWriteWins${t?".inversed":""} < ${e.nameAndSizeUntracked} > initializing`),e.filters.includes("lastWriteWins")){if(s)return N("[lastWriteWins] already filtered, but tolerateAlreadyFiltered=true, so returning"),e;throw O("thread already filtered lastWriteWins:",e.filters,{name:e.name})}let i,n=Z(e,function(l,y){let p=Q(l),c,v=[],m=p?null:[];p?(i=new Map,c=l.init):c=l.added;let b;for(let g=t?0:c.length-1;t?g<c.length:g>=0;t?g++:g--){let d=c[g],z=d.en+"|"+d.at;if(b&&(t?b>d.ts:b<d.ts))throw O("lastWriteWins.mapper logs not sorted:",b,t?">":"<",d.ts,{log:d,i:g,newLogs:c,inverseToOnlyReturnFirstLogs:t});b=d.ts;let S=i.get(z);(!S||(t?S.ts>d.ts:S.ts<d.ts))&&(S&&!p&&m.push(S),v.push(d),i.set(z,d))}return Y(v),o.isDisabled||o(`lastWriteWins${t?".inversed":""}<${e.nameAndSizeUntracked}> mapped event`,p?{...Object.fromEntries(Object.entries(l).map(([g,d])=>[g,d?.length])),toAdd:v.length,toRemove:m}:{...l,toAdd:v,toRemove:m}),p?{init:v}:{added:v,removed:m}},{name:`lastWriteWins${t?".inversed":""}`,extraFilterName:"lastWriteWins"});return o.isDisabled||A(()=>{o(`lastWriteWins<${e.nameAndSizeUntracked}> filtered down to`,n.applogs.length)}),n},{equals:$,argsDebugName:r=>u({caller:"lastWriteWins",thread:r})}),fe=f("withoutDeleted",function(e){if(o.isEnabled&&o(`withoutDeleted<${e.nameAndSizeUntracked}>`),e.filters.includes("withoutDeleted"))throw O("thread already filtered withoutDeleted:",e.filters,{name:e.name});let t=w(e,{at:["isDeleted","relation/isDeleted","block/isDeleted"],vl:!0},{name:"isDeleted"});o.isEnabled&&o(`withoutDeleted<${e.nameAndSizeUntracked}> deletionLogs:`,E(function(){return[...t.applogs]}));let s=u({caller:"allDeletedEntities",thread:e}),i=V(function(){return t.map(a=>a.en)},{name:s});return o.isEnabled&&A(()=>{o(`withoutDeleted<${e.nameAndSizeUntracked}> deleted:`,[...i])}),w(e,{"!en":i},{name:"withoutDeleted",extraFilterName:"withoutDeleted"})},{equals:$}),D=f("query",function r(e,t,s={},i={}){le();let n=K(e);N(`query<${n.nameAndSizeUntracked}>:`,t);let a=Array.isArray(t)?t:[t],l;if(a.length===1)l=null;else{let c=a.slice(0,-1);l=r(n,c,s,i)}let y=a[a.length-1],p=te(n,l,y,i);return o.isDisabled||A(()=>o("query result:",T(p))),p},{equals:k,argsDebugName:(r,e,t)=>u({caller:"query",thread:r,args:t?{pattern:e,startVars:t}:e})}),te=f("queryStep",function(e,t,s,i={}){if(N(`queryStep<${e.nameAndSizeUntracked}> with`,t?.untrackedSize??"all","nodes, pattern:",s),!Object.entries(s).length)throw new Error("Pattern is empty");function n(l){let[y,p]=G(s,l?.variables??{});o("[queryStep.doQuery] patternWithoutVars: ",y);let c=w(e,y),v=R(p),m=h(function(){let g=c.map(d=>({log:d,vars:v(d)}));return o.isEnabled&&o("[queryStep.doQuery] step node:",l?.variables," =>",g,"from:",E(()=>c.applogs)),g.map(({log:d,vars:z})=>{let S=Object.assign({},l?.variables,z);return new ee(X.fromArray([d],u({caller:"QueryNode",thread:c,pattern:`${j(S)}@${j(y)}`})),S,l)})},{name:u({caller:"doQuery.mapNodes",thread:c,pattern:s})});return o.isEnabled&&A(()=>o("[queryStep.doQuery] resultNodes:",[...m])),i.debug&&I("[queryStep] step result:",E(()=>m.map(({variables:b,logsOfThisNode:g})=>({variables:b,thread:g})))),m}let a=h(function(){return N(`[queryStep] Running with ${t?.nodes?.length} input nodes:`),t?[...t.nodes.flatMap(n)]:[...n(null)]},{name:u({caller:"queryStep",thread:e,pattern:s})});return o.isEnabled&&A(()=>o("[queryStep] observableResultNodes:",[...a])),new P(a)},{equals:k,argsDebugName:(r,e,t)=>u({caller:"queryStep",thread:r,pattern:t})}),ge=f("queryNot",function(e,t,s,i={}){let n=t.nodes;N(`queryNot<${e.nameAndSizeUntracked}> from: ${n.length} nodes`);let a=Array.isArray(s)?s:[s];for(let l of a){if(!Object.entries(s).length)throw new Error("Pattern is empty");n=n.filter(function({variables:p}){let[c,v]=G(l,p??{});o("[queryNot] patternWithoutVars: ",c);let m=w(e,c);return o("[queryNot] step node:",p," =>",m.size,"applogs"),o.isDisabled||o("[queryNot] step node:",p," => empty?",E(()=>m.applogs)),i.debug&&I("[queryNot] node result:",p,"=>",m.applogs),m.isEmpty})}return new P(n)},{equals:k,argsDebugName:(r,e,t)=>u({caller:"queryNot",thread:r,pattern:t})}),ye=f("filterAndMap",function(e,t,s){N(`filterAndMap<${e.nameAndSizeUntracked}>`,t);let i=w(e,t);o.isEnabled&&(o("[filterAndMap] filtered:",i.untrackedSize),A(()=>o("[filterAndMap] filtered:",i.applogs)));let n=u({thread:e,pattern:t,caller:"filterAndMap"}),a=h(()=>se(i,s),{name:n});return o.isDisabled||A(()=>o("[filterAndMap] mapped:",a)),a},{equals:M.structural,argsDebugName:(r,e)=>u({caller:"filterAndMap",thread:r,pattern:e})}),me=f("queryAndMap",function(e,t,s,i={}){let n=K(e);N(`queryAndMap<${n.nameAndSizeUntracked}>`,{patternOrPatterns:t,variables:i,map:s});let a=u({thread:n,caller:"queryAndMap"}),l=D(n,t);o("[queryAndMap] filtered count:",l.untrackedSize);let y=h(()=>ie(l,s),{name:a});return o.isDisabled||A(()=>o("[queryAndMap] result:",T(y))),y},{equals:M.structural,argsDebugName:(r,e)=>u({caller:"queryAndMap",thread:r,pattern:e})}),he=f("queryEntity",function(e,t,s,i){N(`queryEntity<${e.nameAndSizeUntracked}>`,s,t);let n=w(e,{en:s,at:ae(t,i)});return o("queryEntity applogs:",n.applogs),q(()=>n.isEmpty?null:Object.fromEntries(n.map(({at:a,vl:l})=>[a.slice(t.length+1),l])))},{equals:F,argsDebugName:(r,e,t)=>u({caller:"queryEntity",thread:r,args:{name:e,entityID:t}})}),ve=f("agentsOfThread",function(e){N(`agentsOfThread<${e.nameAndSizeUntracked}>`);let t=_.map(),s=J(n=>{for(let a of Q(n)?n.init:n.added){let l=t.get(a.ag)??0;t.set(a.ag,l+1)}for(let a of!Q(n)&&n.removed||[]){let l=t.get(a.ag);if(!l||l<1)throw O("[agentsOfThread] number is now negative",{log:a,event:n,mapped:t,prev:l});t.set(a.ag,l-1)}I(`agentsOfThread<${e.nameAndSizeUntracked}> processed event`,{event:n,mapped:t})});s({init:e.applogs});let i=e.subscribe(s);return H(t,i),t}),re=f("entityOverlap",function(e,t){return I(`entityOverlap<${e.nameAndSizeUntracked}, ${t.nameAndSizeUntracked}>`),q(()=>{let s=new Set(e.map(n=>n.en)),i=new Set(t.map(n=>n.en));return[...s].filter(n=>i.has(n))})});var Ae=f("entityOverlapCount",function(e,t){return q(()=>re(e,t).get().length)}),ne=f("querySingle",function(e,t,s={}){let i=D(e,t,s);return q(()=>{if(i.isEmpty)return null;if(i.size>1)throw O("[querySingle] got",i.size,"results:",i);let n=i.nodes[0].logsOfThisNode;if(n.size!=1)throw O("[querySingle] single result, but got",n.size,"logs:",n.applogs);return n.applogs[0]})},{equals:M.structural,argsDebugName:(r,e)=>u({caller:"querySingle",thread:r,pattern:e})}),be=f("querySingleAndMap",function(e,t,s,i={}){let n=ne(e,t,i);return q(()=>{let a=n.get();if(a)return typeof s=="string"?a[s]:R(s)(a)})},{equals:M.structural,argsDebugName:(r,e)=>u({caller:"querySingleAndMap",thread:r,pattern:e})}),se=function(e,t){return typeof t=="function"?e.map(t):typeof t=="string"?e.map(s=>s[t]):e.map(R(t))},ie=function(e,t){return typeof t=="function"?e.records.map(t):typeof t=="string"?e.nodes.map(s=>{if(!Object.hasOwn(s.record,t)){if(s.logsOfThisNode.size!==1)throw O(`not sure what to map (it's not a var and a result node log count of ${s.logsOfThisNode.size})`);return s.logsOfThisNode.firstLog[t]}return s.record[t]}):e.nodes.map(s=>R(t)(e))};function R(r){return e=>Object.entries(r).reduce((t,[s,i])=>(t[i]=e[s],t),{})}function ae(r,e){return e.map(t=>oe(r,t))}function oe(r,e){return`${r}/${e}`}function K(r,e){return Array.isArray(r)?C.fromArray(r,e||`threadFromArray[${r.length}]`,!0):r}function le(){if(L!=null&&performance.now()>=L)throw new qe(L)}var qe=class extends Error{constructor(r){super(r)}};function Ne(r,e,t,s){let i=function(a,l,y){if(y.includes(a))throw new Error(`[mapAndRecurseKids.loop] Circular reference detected: ${a}`);if(y.length>42)throw new Error("[mapAndRecurseKids.maxDepth] Maximum recursion depth (42) exceeded");let p=t({blockID:a,relID:l}),v=D(r,[{en:"?kidRelID",at:"relation/childOf",vl:a},{en:"?kidRelID",at:"relation/block",vl:"?kidID"}]).records.map(function({kidID:b,kidRelID:g}){return i(b,g,[...y,a])});return s(p,v)};return i(e,null,[])}function tt(r,e){let t=[];return Ne(r,e,({blockID:s,relID:i})=>{let n=D(r,[{en:s}]);if(t.push(...n.threadOfAllTrails.applogs),i){let a=D(r,[{en:i}]);t.push(...a.threadOfAllTrails.applogs)}},(s,i)=>{}),t}export{Ne as a,tt as b};
2
- //# sourceMappingURL=chunk-UCWJ4E2C.min.js.map
1
+ import{A as Z,B as C,a as M,b as _,c as q,d as E,e as J,f as A,g as H,h as T,i as B,j as W,k as j,l as u,m as F,n as $,o as k,p as h,q as V,r as f,s as Q,t as X,u as Y,w as G,y as x,z as w}from"./chunk-KUB6PLBB.min.js";var{WARN:ue,LOG:we,DEBUG:de,VERBOSE:U,ERROR:Oe}=W.setup(W.INFO),pe=f("queryDivergencesByPrev",function(e){de(`queryDivergencesByPrev<${e.nameAndSizeUntracked}>`),e.filters.includes("lastWriteWins")&&ue("queryDivergencesByPrev on thread lastWriteWins",e);let t=h(()=>{let s=new Map,i=new Set;U("all applogs:",e.applogs);for(let n of e.applogs){let a;n.pv&&(a=n.pv&&s.get(n.pv.toString()),i.delete(n.pv.toString())),U("traversing log",{log:n,prevLogs:a,leafs:Array.from(i)}),s.set(n.cid,a?[...a,n]:[n]),i.add(n.cid)}return Array.from(i).map(n=>{let a=new C(u({caller:"DivergenceLeaf",thread:e,pattern:`leaf: ${n}`}),s.get(n),e.filters,!0);return{log:a.latestLog,thread:a}})},{name:u({caller:"queryDivergencesByPrev",thread:e})});return U.isDisabled||A(()=>U("[queryDivergencesByPrev] result:",T(t))),t},{equals:M.structural});var ee=class{constructor(r,e,t=null){this.logsOfThisNode=r,this.variables=e,this.prevNode=t,B(this,{threadOfTrail:q})}get record(){return this.variables}get threadOfTrail(){return this.prevNode?x([this.logsOfThisNode,this.prevNode.threadOfTrail]):this.logsOfThisNode}get trailLogs(){return this.threadOfTrail.applogs}},P=class{constructor(r){this.nodes=r,B(this,{threadOfAllTrails:q,size:q,isEmpty:q})}get size(){return this.records.length}get isEmpty(){return this.records.length===0}get untrackedSize(){return E(()=>this.records.length)}get records(){return h(()=>this.nodes.map(({variables:r})=>r),{name:"QueryResult.records"})}get leafNodeThread(){return x(h(()=>this.nodes.map(({logsOfThisNode:r})=>r),{name:"QueryResult.leafNodeThread"}))}get leafNodeLogSet(){return h(()=>this.nodes.map(({logsOfThisNode:r})=>r.applogs),{name:"QueryResult.leafNodeLogSet"})}get leafNodeLogs(){return h(()=>this.nodes.flatMap(({logsOfThisNode:r})=>r.applogs),{name:"QueryResult.leafNodeLogs"})}get threadOfAllTrails(){return x(h(()=>this.nodes.map(r=>r.threadOfTrail),{name:"QueryResult.threadOfAllTrails"}))}get thread(){return this.threadOfAllTrails}get allApplogs(){return this.threadOfAllTrails.applogs}},{WARN:Te,LOG:I,DEBUG:N,VERBOSE:o,ERROR:O}=W.setup(W.INFO,{prefix:"[q]"}),L=null,ce=f("lastWriteWins",function(e,{inverseToOnlyReturnFirstLogs:t,tolerateAlreadyFiltered:s}={}){if(o(`lastWriteWins${t?".inversed":""} < ${e.nameAndSizeUntracked} > initializing`),e.filters.includes("lastWriteWins")){if(s)return N("[lastWriteWins] already filtered, but tolerateAlreadyFiltered=true, so returning"),e;throw O("thread already filtered lastWriteWins:",e.filters,{name:e.name})}let i,n=Z(e,function(l,y){let p=Q(l),c,v=[],m=p?null:[];p?(i=new Map,c=l.init):c=l.added;let b;for(let g=t?0:c.length-1;t?g<c.length:g>=0;t?g++:g--){let d=c[g],z=d.en+"|"+d.at;if(b&&(t?b>d.ts:b<d.ts))throw O("lastWriteWins.mapper logs not sorted:",b,t?">":"<",d.ts,{log:d,i:g,newLogs:c,inverseToOnlyReturnFirstLogs:t});b=d.ts;let S=i.get(z);(!S||(t?S.ts>d.ts:S.ts<d.ts))&&(S&&!p&&m.push(S),v.push(d),i.set(z,d))}return Y(v),o.isDisabled||o(`lastWriteWins${t?".inversed":""}<${e.nameAndSizeUntracked}> mapped event`,p?{...Object.fromEntries(Object.entries(l).map(([g,d])=>[g,d?.length])),toAdd:v.length,toRemove:m}:{...l,toAdd:v,toRemove:m}),p?{init:v}:{added:v,removed:m}},{name:`lastWriteWins${t?".inversed":""}`,extraFilterName:"lastWriteWins"});return o.isDisabled||A(()=>{o(`lastWriteWins<${e.nameAndSizeUntracked}> filtered down to`,n.applogs.length)}),n},{equals:$,argsDebugName:r=>u({caller:"lastWriteWins",thread:r})}),fe=f("withoutDeleted",function(e){if(o.isEnabled&&o(`withoutDeleted<${e.nameAndSizeUntracked}>`),e.filters.includes("withoutDeleted"))throw O("thread already filtered withoutDeleted:",e.filters,{name:e.name});let t=w(e,{at:["isDeleted","relation/isDeleted","block/isDeleted"],vl:!0},{name:"isDeleted"});o.isEnabled&&o(`withoutDeleted<${e.nameAndSizeUntracked}> deletionLogs:`,E(function(){return[...t.applogs]}));let s=u({caller:"allDeletedEntities",thread:e}),i=V(function(){return t.map(a=>a.en)},{name:s});return o.isEnabled&&A(()=>{o(`withoutDeleted<${e.nameAndSizeUntracked}> deleted:`,[...i])}),w(e,{"!en":i},{name:"withoutDeleted",extraFilterName:"withoutDeleted"})},{equals:$}),D=f("query",function r(e,t,s={},i={}){le();let n=K(e);N(`query<${n.nameAndSizeUntracked}>:`,t);let a=Array.isArray(t)?t:[t],l;if(a.length===1)l=null;else{let c=a.slice(0,-1);l=r(n,c,s,i)}let y=a[a.length-1],p=te(n,l,y,i);return o.isDisabled||A(()=>o("query result:",T(p))),p},{equals:k,argsDebugName:(r,e,t)=>u({caller:"query",thread:r,args:t?{pattern:e,startVars:t}:e})}),te=f("queryStep",function(e,t,s,i={}){if(N(`queryStep<${e.nameAndSizeUntracked}> with`,t?.untrackedSize??"all","nodes, pattern:",s),!Object.entries(s).length)throw new Error("Pattern is empty");function n(l){let[y,p]=G(s,l?.variables??{});o("[queryStep.doQuery] patternWithoutVars: ",y);let c=w(e,y),v=R(p),m=h(function(){let g=c.map(d=>({log:d,vars:v(d)}));return o.isEnabled&&o("[queryStep.doQuery] step node:",l?.variables," =>",g,"from:",E(()=>c.applogs)),g.map(({log:d,vars:z})=>{let S=Object.assign({},l?.variables,z);return new ee(X.fromArray([d],u({caller:"QueryNode",thread:c,pattern:`${j(S)}@${j(y)}`})),S,l)})},{name:u({caller:"doQuery.mapNodes",thread:c,pattern:s})});return o.isEnabled&&A(()=>o("[queryStep.doQuery] resultNodes:",[...m])),i.debug&&I("[queryStep] step result:",E(()=>m.map(({variables:b,logsOfThisNode:g})=>({variables:b,thread:g})))),m}let a=h(function(){return N(`[queryStep] Running with ${t?.nodes?.length} input nodes:`),t?[...t.nodes.flatMap(n)]:[...n(null)]},{name:u({caller:"queryStep",thread:e,pattern:s})});return o.isEnabled&&A(()=>o("[queryStep] observableResultNodes:",[...a])),new P(a)},{equals:k,argsDebugName:(r,e,t)=>u({caller:"queryStep",thread:r,pattern:t})}),ge=f("queryNot",function(e,t,s,i={}){let n=t.nodes;N(`queryNot<${e.nameAndSizeUntracked}> from: ${n.length} nodes`);let a=Array.isArray(s)?s:[s];for(let l of a){if(!Object.entries(s).length)throw new Error("Pattern is empty");n=n.filter(function({variables:p}){let[c,v]=G(l,p??{});o("[queryNot] patternWithoutVars: ",c);let m=w(e,c);return o("[queryNot] step node:",p," =>",m.size,"applogs"),o.isDisabled||o("[queryNot] step node:",p," => empty?",E(()=>m.applogs)),i.debug&&I("[queryNot] node result:",p,"=>",m.applogs),m.isEmpty})}return new P(n)},{equals:k,argsDebugName:(r,e,t)=>u({caller:"queryNot",thread:r,pattern:t})}),ye=f("filterAndMap",function(e,t,s){N(`filterAndMap<${e.nameAndSizeUntracked}>`,t);let i=w(e,t);o.isEnabled&&(o("[filterAndMap] filtered:",i.untrackedSize),A(()=>o("[filterAndMap] filtered:",i.applogs)));let n=u({thread:e,pattern:t,caller:"filterAndMap"}),a=h(()=>se(i,s),{name:n});return o.isDisabled||A(()=>o("[filterAndMap] mapped:",a)),a},{equals:M.structural,argsDebugName:(r,e)=>u({caller:"filterAndMap",thread:r,pattern:e})}),me=f("queryAndMap",function(e,t,s,i={}){let n=K(e);N(`queryAndMap<${n.nameAndSizeUntracked}>`,{patternOrPatterns:t,variables:i,map:s});let a=u({thread:n,caller:"queryAndMap"}),l=D(n,t);o("[queryAndMap] filtered count:",l.untrackedSize);let y=h(()=>ie(l,s),{name:a});return o.isDisabled||A(()=>o("[queryAndMap] result:",T(y))),y},{equals:M.structural,argsDebugName:(r,e)=>u({caller:"queryAndMap",thread:r,pattern:e})}),he=f("queryEntity",function(e,t,s,i){N(`queryEntity<${e.nameAndSizeUntracked}>`,s,t);let n=w(e,{en:s,at:ae(t,i)});return o("queryEntity applogs:",n.applogs),q(()=>n.isEmpty?null:Object.fromEntries(n.map(({at:a,vl:l})=>[a.slice(t.length+1),l])))},{equals:F,argsDebugName:(r,e,t)=>u({caller:"queryEntity",thread:r,args:{name:e,entityID:t}})}),ve=f("agentsOfThread",function(e){N(`agentsOfThread<${e.nameAndSizeUntracked}>`);let t=_.map(),s=J(n=>{for(let a of Q(n)?n.init:n.added){let l=t.get(a.ag)??0;t.set(a.ag,l+1)}for(let a of!Q(n)&&n.removed||[]){let l=t.get(a.ag);if(!l||l<1)throw O("[agentsOfThread] number is now negative",{log:a,event:n,mapped:t,prev:l});t.set(a.ag,l-1)}I(`agentsOfThread<${e.nameAndSizeUntracked}> processed event`,{event:n,mapped:t})});s({init:e.applogs});let i=e.subscribe(s);return H(t,i),t}),re=f("entityOverlap",function(e,t){return I(`entityOverlap<${e.nameAndSizeUntracked}, ${t.nameAndSizeUntracked}>`),q(()=>{let s=new Set(e.map(n=>n.en)),i=new Set(t.map(n=>n.en));return[...s].filter(n=>i.has(n))})});var Ae=f("entityOverlapCount",function(e,t){return q(()=>re(e,t).get().length)}),ne=f("querySingle",function(e,t,s={}){let i=D(e,t,s);return q(()=>{if(i.isEmpty)return null;if(i.size>1)throw O("[querySingle] got",i.size,"results:",i);let n=i.nodes[0].logsOfThisNode;if(n.size!=1)throw O("[querySingle] single result, but got",n.size,"logs:",n.applogs);return n.applogs[0]})},{equals:M.structural,argsDebugName:(r,e)=>u({caller:"querySingle",thread:r,pattern:e})}),be=f("querySingleAndMap",function(e,t,s,i={}){let n=ne(e,t,i);return q(()=>{let a=n.get();if(a)return typeof s=="string"?a[s]:R(s)(a)})},{equals:M.structural,argsDebugName:(r,e)=>u({caller:"querySingleAndMap",thread:r,pattern:e})}),se=function(e,t){return typeof t=="function"?e.map(t):typeof t=="string"?e.map(s=>s[t]):e.map(R(t))},ie=function(e,t){return typeof t=="function"?e.records.map(t):typeof t=="string"?e.nodes.map(s=>{if(!Object.hasOwn(s.record,t)){if(s.logsOfThisNode.size!==1)throw O(`not sure what to map (it's not a var and a result node log count of ${s.logsOfThisNode.size})`);return s.logsOfThisNode.firstLog[t]}return s.record[t]}):e.nodes.map(s=>R(t)(e))};function R(r){return e=>Object.entries(r).reduce((t,[s,i])=>(t[i]=e[s],t),{})}function ae(r,e){return e.map(t=>oe(r,t))}function oe(r,e){return`${r}/${e}`}function K(r,e){return Array.isArray(r)?C.fromArray(r,e||`threadFromArray[${r.length}]`,!0):r}function le(){if(L!=null&&performance.now()>=L)throw new qe(L)}var qe=class extends Error{constructor(r){super(r)}};function Ne(r,e,t,s){let i=function(a,l,y){if(y.includes(a))throw new Error(`[mapAndRecurseKids.loop] Circular reference detected: ${a}`);if(y.length>42)throw new Error("[mapAndRecurseKids.maxDepth] Maximum recursion depth (42) exceeded");let p=t({blockID:a,relID:l}),v=D(r,[{en:"?kidRelID",at:"relation/childOf",vl:a},{en:"?kidRelID",at:"relation/block",vl:"?kidID"}]).records.map(function({kidID:b,kidRelID:g}){return i(b,g,[...y,a])});return s(p,v)};return i(e,null,[])}function tt(r,e){let t=[];return Ne(r,e,({blockID:s,relID:i})=>{let n=D(r,[{en:s}]);if(t.push(...n.threadOfAllTrails.applogs),i){let a=D(r,[{en:i}]);t.push(...a.threadOfAllTrails.applogs)}},(s,i)=>{}),t}export{Ne as a,tt as b};
2
+ //# sourceMappingURL=chunk-WZKDDQT2.min.js.map
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export * from './map';
4
4
  export * from './note3-regex-constants';
5
5
  export * from './note3-utils-nodeps';
6
6
  export * from './queries';
7
+ export * from './tag-matching';
7
8
  export * from './tree-builder';
8
9
  export * from './types';
9
10
  export * from './relation-ordering';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,WAAW,CAAA;AACzB,cAAc,OAAO,CAAA;AACrB,cAAc,yBAAyB,CAAA;AACvC,cAAc,sBAAsB,CAAA;AACpC,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA;AACvB,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,WAAW,CAAA;AACzB,cAAc,OAAO,CAAA;AACrB,cAAc,yBAAyB,CAAA;AACvC,cAAc,sBAAsB,CAAA;AACpC,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA;AACvB,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA"}
package/dist/index.min.js CHANGED
@@ -1,2 +1,2 @@
1
- import{a as Q,b as R,c as S,d as T,e as U}from"./chunk-WIPAJIX5.min.js";import"./chunk-KHOUPFOL.min.js";import{a as V,b as W,c as X,d as Y,e as Z,f as _,g as $,h as oo,i as ro,j as eo,k as fo,l as mo,m as po,n as to}from"./chunk-4ARVEMAY.min.js";import{a as o,b as r}from"./chunk-UCWJ4E2C.min.js";import"./chunk-WVHDYKM7.min.js";import{a as e,b as f,c as m,d as p,e as t}from"./chunk-O72M27NE.min.js";import"./chunk-5TTMWYXD.min.js";import{a as x}from"./chunk-IFY2JCCQ.min.js";import{a as J,b as K,c as L,d as M,e as N,f as O,g as P}from"./chunk-XL6QVLYO.min.js";import{a as I}from"./chunk-KY36PVHK.min.js";import{a as w,b as y,c as z,d as A,e as B,f as C,g as D,h as E,i as F,j as G,k as H}from"./chunk-LDNVHZO7.min.js";import{a,b,c,d,e as g,f as h,g as i,h as j,i as k,j as l,k as n,l as q,m as s,n as u,o as v}from"./chunk-POX3PUJK.min.js";import"./chunk-MXMMU6NF.min.js";export{$ as CANONICAL_NOTE3_ORIGINS,k as RE_ANY_TAG_ONLY,v as RE_ANY_TAG_WITHCONTEXT,j as RE_AT_TAG_ONLY,u as RE_AT_TAG_WITHCONTEXT,h as RE_HASH_TAG_ONLY,q as RE_HASH_TAG_WITHCONTEXT,i as RE_PLUS_TAG_ONLY,s as RE_PLUS_TAG_WITHCONTEXT,g as RE_TAG_BODY,c as RE_TAG_BODY_CHAR,d as RE_TAG_BODY_REQUIRED_CHAR,n as RE_TAG_CONTEXT_POST,l as RE_TAG_CONTEXT_PRE,x as SetMap,b as TAG_MIN_LENGTH,a as TIPTAP_EMPTY,m as asyncIterableToArray,p as blobToAsyncIterable,r as collectSubtreeApplogs,H as contentVlToPlaintext,Q as createBlockApplogs,R as createRelationApplogs,S as createSingleNodeApplogs,U as createSingleTree,T as createTreeApplogs,Z as deleteHashFragment,G as getAllTagsInText,J as getChildIDs,L as getChildRelations,N as getContent,O as getContentText,W as getHashFragment,oo as getKnownNote3Origins,K as getParentIDs,M as getParentRelations,P as getRootIDs,_ as hasHashFragment,X as hashFragmentsToString,e as lazyVal,fo as makeNote3Url,o as mapAndRecurseKids,I as orderRelations,y as parseBlockContentValue,V as parseHashFragments,D as plainContentMatchAnyTag,C as plainContentMatchAtTag,A as plainContentMatchHashTag,B as plainContentMatchPlusTag,E as plainContentMatchTagGeneric,w as plaintextStringToTiptap,f as racePromises,F as rawContentMatchTag,t as recurseWithLoopProtection,po as replaceSearchParamsInUrl,to as replaceUriParts,mo as searchParamsFromHash,Y as setHashFragment,z as tiptapToPlaintext,eo as tryParseNote3URL,ro as tryParseURL};
1
+ import{a as Q,b as R}from"./chunk-EI3JEXCC.min.js";import{a as S,b as T,c as U,d as V,e as W}from"./chunk-U5CYBCGY.min.js";import"./chunk-KHOUPFOL.min.js";import{a as X,b as Y,c as Z,d as _,e as $,f as oo,g as ro,h as eo,i as fo,j as mo,k as po,l as to,m as xo,n as ao}from"./chunk-4ARVEMAY.min.js";import{a as o,b as r}from"./chunk-WZKDDQT2.min.js";import"./chunk-KUB6PLBB.min.js";import{a as e,b as f,c as m,d as p,e as t}from"./chunk-O72M27NE.min.js";import"./chunk-5TTMWYXD.min.js";import{a as x}from"./chunk-IFY2JCCQ.min.js";import{a as J,b as K,c as L,d as M,e as N,f as O,g as P}from"./chunk-XL6QVLYO.min.js";import{a as I}from"./chunk-KY36PVHK.min.js";import{a as w,b as y,c as z,d as A,e as B,f as C,g as D,h as E,i as F,j as G,k as H}from"./chunk-LDNVHZO7.min.js";import{a,b,c,d,e as g,f as h,g as i,h as j,i as k,j as l,k as n,l as q,m as s,n as u,o as v}from"./chunk-POX3PUJK.min.js";import"./chunk-MXMMU6NF.min.js";export{ro as CANONICAL_NOTE3_ORIGINS,k as RE_ANY_TAG_ONLY,v as RE_ANY_TAG_WITHCONTEXT,j as RE_AT_TAG_ONLY,u as RE_AT_TAG_WITHCONTEXT,h as RE_HASH_TAG_ONLY,q as RE_HASH_TAG_WITHCONTEXT,i as RE_PLUS_TAG_ONLY,s as RE_PLUS_TAG_WITHCONTEXT,g as RE_TAG_BODY,c as RE_TAG_BODY_CHAR,d as RE_TAG_BODY_REQUIRED_CHAR,n as RE_TAG_CONTEXT_POST,l as RE_TAG_CONTEXT_PRE,x as SetMap,b as TAG_MIN_LENGTH,a as TIPTAP_EMPTY,m as asyncIterableToArray,p as blobToAsyncIterable,r as collectSubtreeApplogs,H as contentVlToPlaintext,S as createBlockApplogs,T as createRelationApplogs,U as createSingleNodeApplogs,W as createSingleTree,V as createTreeApplogs,$ as deleteHashFragment,G as getAllTagsInText,J as getChildIDs,L as getChildRelations,N as getContent,O as getContentText,Y as getHashFragment,eo as getKnownNote3Origins,K as getParentIDs,M as getParentRelations,Q as getRegexForTagInContext,P as getRootIDs,oo as hasHashFragment,Z as hashFragmentsToString,e as lazyVal,po as makeNote3Url,o as mapAndRecurseKids,I as orderRelations,y as parseBlockContentValue,X as parseHashFragments,D as plainContentMatchAnyTag,C as plainContentMatchAtTag,A as plainContentMatchHashTag,B as plainContentMatchPlusTag,R as plainContentMatchSpecificTag,E as plainContentMatchTagGeneric,w as plaintextStringToTiptap,f as racePromises,F as rawContentMatchTag,t as recurseWithLoopProtection,xo as replaceSearchParamsInUrl,ao as replaceUriParts,to as searchParamsFromHash,_ as setHashFragment,z as tiptapToPlaintext,mo as tryParseNote3URL,fo as tryParseURL};
2
2
  //# sourceMappingURL=index.min.js.map
@@ -0,0 +1,3 @@
1
+ export declare function getRegexForTagInContext(tag: string, flags?: string): RegExp;
2
+ export declare function plainContentMatchSpecificTag(content: string, tag: string): boolean;
3
+ //# sourceMappingURL=tag-matching.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tag-matching.d.ts","sourceRoot":"","sources":["../src/tag-matching.ts"],"names":[],"mappings":"AAIA,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,SAAK,GAAG,MAAM,CAEvE;AAED,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,WAKxE"}
@@ -0,0 +1,2 @@
1
+ import{a,b}from"./chunk-EI3JEXCC.min.js";import"./chunk-LDNVHZO7.min.js";import"./chunk-POX3PUJK.min.js";import"./chunk-MXMMU6NF.min.js";export{a as getRegexForTagInContext,b as plainContentMatchSpecificTag};
2
+ //# sourceMappingURL=tag-matching.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,2 +1,2 @@
1
- import{a,b,c,d,e}from"./chunk-WIPAJIX5.min.js";import"./chunk-WVHDYKM7.min.js";import"./chunk-MXMMU6NF.min.js";export{a as createBlockApplogs,b as createRelationApplogs,c as createSingleNodeApplogs,e as createSingleTree,d as createTreeApplogs};
1
+ import{a,b,c,d,e}from"./chunk-U5CYBCGY.min.js";import"./chunk-KUB6PLBB.min.js";import"./chunk-MXMMU6NF.min.js";export{a as createBlockApplogs,b as createRelationApplogs,c as createSingleNodeApplogs,e as createSingleTree,d as createTreeApplogs};
2
2
  //# sourceMappingURL=tree-builder.min.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@note3/utils",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./dist/index.min.js",
@@ -30,8 +30,9 @@
30
30
  "besonders-logger": "1.0.2",
31
31
  "comlink": "^4.4.2",
32
32
  "core-js": "^3.45.1",
33
+ "escape-string-regexp": "^5.0.0",
33
34
  "vite-plugin-comlink": "^5.3.0",
34
- "@wovin/core": "^0.1.16"
35
+ "@wovin/core": "^0.1.18"
35
36
  },
36
37
  "devDependencies": {
37
38
  "concurrently": "^8.2.2",