@cratis/screenplay-language 4.248.0 → 4.249.1

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"../../_virtual/_virtual/_rolldown/runtime.js";import{eventDeclarations as e}from"../Syntax/EventDeclarations.js";import{dependencySourcesOf as t}from"../Syntax/DependencySources.js";import{expandSpecificationExamples as n}from"../Parsing/SpecificationCommandExamples.js";import{authoredOrderKey as r,authoredOrderOf as i}from"../Files/AuthoredOrder.js";import{dependencyKinds as a}from"./DependencyKind.js";import{InvalidDependencyQuery as o}from"./InvalidDependencyQuery.js";import{sliceReferences as s}from"./SliceReferences.js";import{stronglyConnectedGroups as c}from"./StronglyConnectedGroups.js";const l=[`usesFactsFrom`,`reactsTo`,`decidesFrom`],ordinal=(e,t)=>e<t?-1:+(e>t),declarationKey=(e,t)=>JSON.stringify([e,t.toLowerCase()]),nodeOf=(e,t,n,r)=>({kind:e,address:t,scope:n,rank:r,key:`${e}:${t}`}),compareNodes=(e,t)=>e.rank-t.rank||ordinal(e.key,t.key),distinctNodes=e=>[...new Map([...e].map(e=>[e.key,e])).values()].sort(compareNodes),compareEvidence=(e,t)=>e.consumer.rank-t.consumer.rank||e.location.line-t.location.line||e.location.column-t.location.column||a.indexOf(e.kind)-a.indexOf(t.kind)||e.producer.rank-t.producer.rank||ordinal(e.location.path??``,t.location.path??``)||ordinal(e.role,t.role)||ordinal(e.name,t.name);function variants(e){return e.flatMap(e=>e.kind===`ProjectionVariantSyntax`?[e,...variants(e.blocks)]:e.kind===`ChildrenSyntax`||e.kind===`NestedSyntax`?variants(e.blocks):[])}var u=class DependencyGraph{orderSource;edges;unresolved;excludedReferences;unusedImports;modelNodes=[];slices=[];children=/* @__PURE__ */ new Map;byKey=/* @__PURE__ */ new Map;parents=/* @__PURE__ */ new Map;root=nodeOf(`application`,``,[],-1);static for(e,t=i(e)){return new DependencyGraph(e,t)}get nodes(){return this.modelNodes}constructor(i,o){i=n(i),this.orderSource=o.size>0?`authored`:`syntax`,this.children.set(this.root.key,[]);let ordered=(e,t)=>e.map((e,n)=>({syntax:e,index:n,rank:o.get(r([...t.scope,e.name]))??2**53-1})).sort((e,t)=>e.rank-t.rank||e.index-t.index).map(e=>e.syntax),feature=(e,t)=>{let n=this.add(`feature`,e.name,t);for(let t of ordered(e.slices,n))this.slices.push({node:this.add(`slice`,t.name,n),syntax:t});for(let t of ordered(e.features,n))feature(t,n)};for(let e of ordered(i.modules,this.root)){let t=this.add(`module`,e.name,this.root);for(let n of ordered(e.features,t))feature(n,t)}let c=/* @__PURE__ */ new Map,l=/* @__PURE__ */ new Map,declare=(e,t,n,r)=>{let i=declarationKey(t,n);e.has(i)||e.set(i,[]);let a=e.get(i);a.includes(r)||a.push(r);let o=declarationKey(t,[...r.scope,n].join(`.`));e.has(o)||e.set(o,[]);let s=e.get(o);s.includes(r)||s.push(r)};for(let{node:n,syntax:r}of this.slices){for(let t of e(r))declare(c,`Event`,t.name,n);for(let e of r.commands)declare(c,`Command`,e.name,n);for(let e of r.reactions)declare(c,`Reaction`,e.name,n);for(let e of r.queries)declare(c,`Query`,e.name,n);for(let e of r.screens)declare(c,`Screen`,e.name,n);for(let e of r.readModels)declare(c,`ReadModel`,e.name,n);for(let e of r.projections){let t=variants(e.blocks);t.length===0&&declare(l,`ReadModel`,e.readModel??e.name,n);for(let e of t)declare(l,`ReadModel`,e.name,n)}for(let e of t(r).reducers??[])declare(l,`ReadModel`,e.readModel,n)}let u=new Set((i.declaredTriggers??[]).map(e=>e.name.toLowerCase())),d=new Set([...i.concepts,...i.types].map(e=>e.name.toLowerCase())),f=new Set((i.policies??[]).map(e=>e.name.toLowerCase())),p=i.imports.filter(e=>e.qualifiedName.includes(`.`)).slice().sort((e,t)=>ordinal(e.location.path??``,t.location.path??``)||e.location.line-t.location.line||e.location.column-t.location.column||ordinal(e.qualifiedName,t.qualifiedName)),m=/* @__PURE__ */ new Map,h=[],g=[],_=/* @__PURE__ */ new Set,v=0;for(let{node:e,syntax:t}of this.slices){let n=s(t);v+=n.shared.filter(e=>(e.kind===`type`?d:f).has(e.name.toLowerCase())).length;for(let t of n.references){let n=declarationKey(t.targetKind,t.name),r=(t.targetKind===`ReadModel`&&l.has(n)?l:c).get(n);if(r!==void 0&&r.length>0){let n=r[0];n!==e&&h.push({consumer:e,producer:n,kind:t.kind,role:t.role,name:t.name,ambiguous:r.length>1,alternatives:r.slice(1),location:t.location,testOnly:t.kind===`verifiedWith`});continue}let i=t.targetKind===`Event`?p.filter(e=>e.qualifiedName.slice(e.qualifiedName.lastIndexOf(`.`)+1).toLowerCase()===t.name.toLowerCase()):[];if(i.length>0){let n=[];for(let e of i){_.add(e.qualifiedName);let t=e.qualifiedName.slice(0,e.qualifiedName.lastIndexOf(`.`)),r=`context:${t}`;if(!m.has(r)){let e=nodeOf(`context`,r,[t],this.modelNodes.length);this.modelNodes.push(e),m.set(r,e)}let i=m.get(r);n.includes(i)||n.push(i)}h.push({consumer:e,producer:n[0],kind:`outsideTheModel`,role:t.role,name:t.name,ambiguous:n.length>1,alternatives:n.slice(1),location:t.location,testOnly:t.kind===`verifiedWith`})}else t.role===`trigger`&&u.has(t.name.toLowerCase())?v++:g.push({consumer:e,kind:t.kind,role:t.role,name:t.name,location:t.location})}}let y=/* @__PURE__ */ new Map;for(let e of h.sort(compareEvidence)){let t=JSON.stringify([e.consumer.key,e.producer.key,e.kind]);y.has(t)||y.set(t,[]),y.get(t).push(e)}this.edges=[...y.values()].map(e=>({consumer:e[0].consumer,producer:e[0].producer,kind:e[0].kind,evidence:e})),this.unresolved=g.sort((e,t)=>e.consumer.rank-t.consumer.rank||e.location.line-t.location.line||e.location.column-t.location.column||a.indexOf(e.kind)-a.indexOf(t.kind)||ordinal(e.location.path??``,t.location.path??``)||ordinal(e.name,t.name)),this.excludedReferences=v,this.unusedImports=[...new Set(p.filter(e=>!_.has(e.qualifiedName)).map(e=>e.qualifiedName))]}implied(e,t,n,r=!1,i=3){if(![`slice`,`feature`,`module`].includes(e))throw new o(`Unsupported source level '${e}'.`);if(![`slice`,`feature`,`module`,`context`].includes(t))throw new o(`Unsupported target level '${t}'.`);if(i<0)throw new o(`Evidence limit must not be negative.`);let s=/* @__PURE__ */ new Map;for(let i of this.evidence(n,r))for(let n of this.at(i.consumer,e))for(let e of this.at(i.producer,t).filter(e=>this.disjoint(n,e))){let t=JSON.stringify([n.key,e.key]);s.has(t)||s.set(t,{source:n,target:e,evidence:[]}),s.get(t).evidence.push(i)}return[...s.values()].sort((e,t)=>e.source.rank-t.source.rank||e.target.rank-t.target.rank||ordinal(e.source.key,t.source.key)||ordinal(e.target.key,t.target.key)).map(e=>{let t=e.evidence.sort(compareEvidence),n={};for(let e of a){let r=t.filter(t=>t.kind===e).length;r>0&&(n[e]=r)}return{source:e.source,target:e.target,sliceEdges:new Set(t.map(e=>JSON.stringify([e.consumer.key,e.producer.key]))).size,references:t.length,byKind:n,consumers:distinctNodes(t.map(e=>e.consumer)),producers:distinctNodes(t.map(e=>e.producer)),evidence:t.slice(0,i),evidenceCount:t.length,evidenceTruncated:t.length>i}})}cycles(e,t){if(![`slice`,`feature`,`module`].includes(e))throw new o(`Unsupported cycle level '${e}'.`);let n=this.implied(e,e,selectedOrderingKinds(t)),r=distinctNodes(n.flatMap(e=>[e.source,e.target]));return groupsOf(adjacency(r,n),r,null)}siblingGroups(e){let t=this.siblingEdges(e);return this.containers().flatMap(e=>{let n=this.children.get(e.key);return groupsOf(adjacency(n,t.filter(t=>t.container===e)),n,e)})}suggestedOrder(e){let t=this.siblingEdges(e),n=[];for(let e of this.containers()){let r=this.children.get(e.key),i=t.filter(t=>t.container===e),a=new Map(r.map(e=>[e.key,e])),o=c(adjacency(r,i)).map(e=>e.map(e=>a.get(e)).sort(compareNodes)).sort((e,t)=>e[0].rank-t[0].rank),s=new Map(o.flatMap((e,t)=>e.map(e=>[e.key,t]))),l=new Map(r.map(e=>[e.key,/* @__PURE__ */ new Set]));for(let e of i)s.get(e.source.key)!==s.get(e.target.key)&&l.get(e.source.key).add(e.target.key);for(let e of o)for(let t=1;t<e.length;t++)l.get(e[t].key).add(e[t-1].key);let u=new Set(r.map(e=>e.key)),d=[];for(;u.size>0;){let e=[...u].filter(e=>l.get(e).size===0).sort((e,t)=>compareNodes(a.get(e),a.get(t)))[0];d.push(a.get(e)),u.delete(e);for(let t of u)l.get(t).delete(e)}n.push({container:e,children:d,changed:r.some((e,t)=>e!==d[t])})}let r=new Map(n.map(e=>[e.container.key,e.children])),i=[],walk=e=>{if(e.kind===`slice`)i.push(e);else for(let t of[...r.get(e.key)].sort((e,t)=>Number(e.kind!==`slice`)-Number(t.kind!==`slice`)))walk(t)};return walk(this.root),{containers:n,slices:i}}traverse(e,t,n,r=!1){if(t!==`incoming`&&t!==`outgoing`)throw new o(`Unsupported dependency direction '${t}'.`);let i=this.evidence(n,r).map(e=>t===`incoming`?{source:e.producer,target:e.consumer}:{source:e.consumer,target:e.producer}),a=/* @__PURE__ */ new Set([e]),s=[e],c=[];for(let e=0;e<s.length;e++)for(let t of i.filter(t=>t.source.address===s[e]).sort((e,t)=>e.target.rank-t.target.rank))a.has(t.target.address)||(a.add(t.target.address),c.push(t.target),s.push(t.target.address));return distinctNodes(c)}add(e,t,n){let r=[...n.scope,t],i=r.join(`.`),a=`${e}:${i}`,o=this.byKey.get(a);if(o!==void 0)return o;let s=nodeOf(e,i,r,this.modelNodes.length);return this.modelNodes.push(s),this.byKey.set(a,s),this.parents.set(a,n),this.children.get(n.key).push(s),e!==`slice`&&this.children.set(a,[]),s}ancestors(e){let t=[];for(let n=this.parents.get(e.key);n!==void 0;n=this.parents.get(n.key))t.push(n);return t}disjoint(e,t){return e.key!==t.key&&!this.ancestors(e).includes(t)&&!this.ancestors(t).includes(e)}at(e,t){return[e,...this.ancestors(e)].filter(e=>e.kind===t)}containers(){return[this.root,...this.modelNodes.filter(e=>e.kind===`module`||e.kind===`feature`)]}evidence(e,t){let n=selectedKinds(e);return this.edges.flatMap(e=>e.evidence).filter(e=>n.has(e.kind)&&(t||!e.testOnly))}path(e){return[...this.ancestors(e).reverse(),e].filter(e=>e!==this.root)}siblingEdges(e){let t=[];for(let n of this.evidence(selectedOrderingKinds(e),!1)){let e=this.path(n.consumer),r=this.path(n.producer),i=0;for(;i<e.length&&i<r.length&&e[i].key===r[i].key;)i++;i!==e.length&&i!==r.length&&t.push({container:i===0?this.root:e[i-1],source:e[i],target:r[i]})}return t}};function selectedKinds(e){let t=new Set(e??a);if([...t].some(e=>!a.includes(e)))throw new o(`Unsupported dependency kind.`);return t}function selectedOrderingKinds(e){return[...selectedKinds(e??l)].filter(e=>l.includes(e))}function adjacency(e,t){let n=new Map(e.map(e=>[e.key,/* @__PURE__ */ new Set]));for(let e of t)n.get(e.source.key).add(e.target.key);return n}function groupsOf(e,t,n){let r=new Map(t.map(e=>[e.key,e]));return c(e).filter(e=>e.length>1).map(e=>({container:n,members:distinctNodes(e.map(e=>r.get(e)))})).sort((e,t)=>e.members[0].rank-t.members[0].rank)}export{u as DependencyGraph};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{eventDeclarations as e}from"../Syntax/EventDeclarations.js";import{dependencySourcesOf as t}from"../Syntax/DependencySources.js";import{expandSpecificationExamples as n}from"../Parsing/SpecificationCommandExamples.js";import{authoredOrderKey as r,authoredOrderOf as i}from"../Files/AuthoredOrder.js";import{dependencyKinds as a}from"./DependencyKind.js";import{InvalidDependencyQuery as o}from"./InvalidDependencyQuery.js";import{sliceReferences as s}from"./SliceReferences.js";import{stronglyConnectedGroups as c}from"./StronglyConnectedGroups.js";const l=[`usesFactsFrom`,`reactsTo`,`decidesFrom`],ordinal=(e,t)=>e<t?-1:+(e>t),declarationKey=(e,t)=>JSON.stringify([e,t.toLowerCase()]),nodeOf=(e,t,n,r)=>({kind:e,address:t,scope:n,rank:r,key:`${e}:${t}`}),compareNodes=(e,t)=>e.rank-t.rank||ordinal(e.key,t.key),distinctNodes=e=>[...new Map([...e].map(e=>[e.key,e])).values()].sort(compareNodes),compareEvidence=(e,t)=>e.consumer.rank-t.consumer.rank||e.location.line-t.location.line||e.location.column-t.location.column||a.indexOf(e.kind)-a.indexOf(t.kind)||e.producer.rank-t.producer.rank||ordinal(e.location.path??``,t.location.path??``)||ordinal(e.role,t.role)||ordinal(e.name,t.name);function variants(e){return e.flatMap(e=>e.kind===`ProjectionVariantSyntax`?[e,...variants(e.blocks)]:e.kind===`ChildrenSyntax`||e.kind===`NestedSyntax`?variants(e.blocks):[])}var u=class DependencyGraph{orderSource;edges;unresolved;excludedReferences;unusedImports;modelNodes=[];slices=[];children=/* @__PURE__ */ new Map;byKey=/* @__PURE__ */ new Map;parents=/* @__PURE__ */ new Map;root=nodeOf(`application`,``,[],-1);static for(e,t=i(e)){return new DependencyGraph(e,t)}get nodes(){return this.modelNodes}constructor(i,o){i=n(i),this.orderSource=o.size>0?`authored`:`syntax`,this.children.set(this.root.key,[]);let ordered=(e,t)=>e.map((e,n)=>({syntax:e,index:n,rank:o.get(r([...t.scope,e.name]))??2**53-1})).sort((e,t)=>e.rank-t.rank||e.index-t.index).map(e=>e.syntax),feature=(e,t)=>{let n=this.add(`feature`,e.name,t);for(let t of ordered(e.slices,n))this.slices.push({node:this.add(`slice`,t.name,n),syntax:t});for(let t of ordered(e.features,n))feature(t,n)};for(let e of ordered(i.modules,this.root)){let t=this.add(`module`,e.name,this.root);for(let n of ordered(e.features,t))feature(n,t)}let c=this.projectionEventTargets(),l=/* @__PURE__ */ new Map,u=/* @__PURE__ */ new Map,declare=(e,t,n,r)=>{let i=declarationKey(t,n);e.has(i)||e.set(i,[]);let a=e.get(i);a.includes(r)||a.push(r);let o=declarationKey(t,[...r.scope,n].join(`.`));e.has(o)||e.set(o,[]);let s=e.get(o);s.includes(r)||s.push(r)};for(let{node:n,syntax:r}of this.slices){for(let t of e(r))declare(l,`Event`,t.name,n);for(let e of r.commands)declare(l,`Command`,e.name,n);for(let e of r.reactions)declare(l,`Reaction`,e.name,n);for(let e of r.queries)declare(l,`Query`,e.name,n);for(let e of r.screens)declare(l,`Screen`,e.name,n);for(let e of r.readModels)declare(l,`ReadModel`,e.name,n);for(let e of this.projectionReadModels(r,n,c))declare(u,`ReadModel`,e,n);for(let e of t(r).reducers??[])declare(u,`ReadModel`,e.readModel,n)}let d=new Set((i.declaredTriggers??[]).map(e=>e.name.toLowerCase())),f=new Set([...i.concepts,...i.types].map(e=>e.name.toLowerCase())),p=new Set((i.policies??[]).map(e=>e.name.toLowerCase())),m=i.imports.filter(e=>e.qualifiedName.includes(`.`)).slice().sort((e,t)=>ordinal(e.location.path??``,t.location.path??``)||e.location.line-t.location.line||e.location.column-t.location.column||ordinal(e.qualifiedName,t.qualifiedName)),h=/* @__PURE__ */ new Map,g=[],_=[],v=/* @__PURE__ */ new Set,y=0;for(let{node:e,syntax:t}of this.slices){let n=s(t);y+=n.shared.filter(e=>(e.kind===`type`?f:p).has(e.name.toLowerCase())).length;for(let t of n.references){let n=declarationKey(t.targetKind,t.name),r=(t.targetKind===`ReadModel`&&u.has(n)?u:l).get(n);if(r!==void 0&&r.length>0){let n=r[0];n!==e&&g.push({consumer:e,producer:n,kind:t.kind,role:t.role,name:t.name,ambiguous:r.length>1,alternatives:r.slice(1),location:t.location,testOnly:t.kind===`verifiedWith`});continue}let i=t.targetKind===`Event`?m.filter(e=>e.qualifiedName.slice(e.qualifiedName.lastIndexOf(`.`)+1).toLowerCase()===t.name.toLowerCase()):[];if(i.length>0){let n=[];for(let e of i){v.add(e.qualifiedName);let t=e.qualifiedName.slice(0,e.qualifiedName.lastIndexOf(`.`)),r=`context:${t}`;if(!h.has(r)){let e=nodeOf(`context`,r,[t],this.modelNodes.length);this.modelNodes.push(e),h.set(r,e)}let i=h.get(r);n.includes(i)||n.push(i)}g.push({consumer:e,producer:n[0],kind:`outsideTheModel`,role:t.role,name:t.name,ambiguous:n.length>1,alternatives:n.slice(1),location:t.location,testOnly:t.kind===`verifiedWith`})}else t.role===`trigger`&&d.has(t.name.toLowerCase())?y++:_.push({consumer:e,kind:t.kind,role:t.role,name:t.name,location:t.location})}}let b=/* @__PURE__ */ new Map;for(let e of g.sort(compareEvidence)){let t=JSON.stringify([e.consumer.key,e.producer.key,e.kind]);b.has(t)||b.set(t,[]),b.get(t).push(e)}this.edges=[...b.values()].map(e=>({consumer:e[0].consumer,producer:e[0].producer,kind:e[0].kind,evidence:e})),this.unresolved=_.sort((e,t)=>e.consumer.rank-t.consumer.rank||e.location.line-t.location.line||e.location.column-t.location.column||a.indexOf(e.kind)-a.indexOf(t.kind)||ordinal(e.location.path??``,t.location.path??``)||ordinal(e.name,t.name)),this.excludedReferences=y,this.unusedImports=[...new Set(m.filter(e=>!v.has(e.qualifiedName)).map(e=>e.qualifiedName))]}implied(e,t,n,r=!1,i=3){if(![`slice`,`feature`,`module`].includes(e))throw new o(`Unsupported source level '${e}'.`);if(![`slice`,`feature`,`module`,`context`].includes(t))throw new o(`Unsupported target level '${t}'.`);if(i<0)throw new o(`Evidence limit must not be negative.`);let s=/* @__PURE__ */ new Map;for(let i of this.evidence(n,r))for(let n of this.at(i.consumer,e))for(let e of this.at(i.producer,t).filter(e=>this.disjoint(n,e))){let t=JSON.stringify([n.key,e.key]);s.has(t)||s.set(t,{source:n,target:e,evidence:[]}),s.get(t).evidence.push(i)}return[...s.values()].sort((e,t)=>e.source.rank-t.source.rank||e.target.rank-t.target.rank||ordinal(e.source.key,t.source.key)||ordinal(e.target.key,t.target.key)).map(e=>{let t=e.evidence.sort(compareEvidence),n={};for(let e of a){let r=t.filter(t=>t.kind===e).length;r>0&&(n[e]=r)}return{source:e.source,target:e.target,sliceEdges:new Set(t.map(e=>JSON.stringify([e.consumer.key,e.producer.key]))).size,references:t.length,byKind:n,consumers:distinctNodes(t.map(e=>e.consumer)),producers:distinctNodes(t.map(e=>e.producer)),evidence:t.slice(0,i),evidenceCount:t.length,evidenceTruncated:t.length>i}})}cycles(e,t){if(![`slice`,`feature`,`module`].includes(e))throw new o(`Unsupported cycle level '${e}'.`);let n=this.implied(e,e,selectedOrderingKinds(t)),r=distinctNodes(n.flatMap(e=>[e.source,e.target]));return groupsOf(adjacency(r,n),r,null)}siblingGroups(e){let t=this.siblingEdges(e);return this.containers().flatMap(e=>{let n=this.children.get(e.key);return groupsOf(adjacency(n,t.filter(t=>t.container===e)),n,e)})}suggestedOrder(e){let t=this.siblingEdges(e),n=[];for(let e of this.containers()){let r=this.children.get(e.key),i=t.filter(t=>t.container===e),a=new Map(r.map(e=>[e.key,e])),o=c(adjacency(r,i)).map(e=>e.map(e=>a.get(e)).sort(compareNodes)).sort((e,t)=>e[0].rank-t[0].rank),s=new Map(o.flatMap((e,t)=>e.map(e=>[e.key,t]))),l=new Map(r.map(e=>[e.key,/* @__PURE__ */ new Set]));for(let e of i)s.get(e.source.key)!==s.get(e.target.key)&&l.get(e.source.key).add(e.target.key);for(let e of o)for(let t=1;t<e.length;t++)l.get(e[t].key).add(e[t-1].key);let u=new Set(r.map(e=>e.key)),d=[];for(;u.size>0;){let e=[...u].filter(e=>l.get(e).size===0).sort((e,t)=>compareNodes(a.get(e),a.get(t)))[0];d.push(a.get(e)),u.delete(e);for(let t of u)l.get(t).delete(e)}n.push({container:e,children:d,changed:r.some((e,t)=>e!==d[t])})}let r=new Map(n.map(e=>[e.container.key,e.children])),i=[],walk=e=>{if(e.kind===`slice`)i.push(e);else for(let t of[...r.get(e.key)].sort((e,t)=>Number(e.kind!==`slice`)-Number(t.kind!==`slice`)))walk(t)};return walk(this.root),{containers:n,slices:i}}traverse(e,t,n,r=!1){if(t!==`incoming`&&t!==`outgoing`)throw new o(`Unsupported dependency direction '${t}'.`);let i=this.evidence(n,r).map(e=>t===`incoming`?{source:e.producer,target:e.consumer}:{source:e.consumer,target:e.producer}),a=/* @__PURE__ */ new Set([e]),s=[e],c=[];for(let e=0;e<s.length;e++)for(let t of i.filter(t=>t.source.address===s[e]).sort((e,t)=>e.target.rank-t.target.rank))a.has(t.target.address)||(a.add(t.target.address),c.push(t.target),s.push(t.target.address));return distinctNodes(c)}isBareProjectionTarget(e){return e.length!==0&&!e.includes(`.`)}*projectionReadModels(e,t,n){for(let r of e.projections){let e=variants(r.blocks);e.length>0?yield*e.map(e=>e.name):yield*this.projectionReadModel(r,t,n)}}projectionReadModel(e,t,n){return n.get(e.readModel??``)===t?[]:[e.readModel??e.name]}projectionEventTargets(){let t=/* @__PURE__ */ new Map,n=new Set(this.slices.flatMap(({syntax:e})=>e.readModels.map(e=>e.name.toLowerCase())));for(let{node:n,syntax:r}of this.slices)for(let i of e(r)){let e=i.name.toLowerCase();t.has(e)||t.set(e,[]),t.get(e).push({node:n,name:i.name})}let r=[...t.values()].filter(e=>e.length===1).map(([e])=>e).filter(e=>this.isBareProjectionTarget(e.name)).filter(e=>!n.has(e.name.toLowerCase()));return new Map(r.map(e=>[e.name,e.node]))}add(e,t,n){let r=[...n.scope,t],i=r.join(`.`),a=`${e}:${i}`,o=this.byKey.get(a);if(o!==void 0)return o;let s=nodeOf(e,i,r,this.modelNodes.length);return this.modelNodes.push(s),this.byKey.set(a,s),this.parents.set(a,n),this.children.get(n.key).push(s),e!==`slice`&&this.children.set(a,[]),s}ancestors(e){let t=[];for(let n=this.parents.get(e.key);n!==void 0;n=this.parents.get(n.key))t.push(n);return t}disjoint(e,t){return e.key!==t.key&&!this.ancestors(e).includes(t)&&!this.ancestors(t).includes(e)}at(e,t){return[e,...this.ancestors(e)].filter(e=>e.kind===t)}containers(){return[this.root,...this.modelNodes.filter(e=>e.kind===`module`||e.kind===`feature`)]}evidence(e,t){let n=selectedKinds(e);return this.edges.flatMap(e=>e.evidence).filter(e=>n.has(e.kind)&&(t||!e.testOnly))}path(e){return[...this.ancestors(e).reverse(),e].filter(e=>e!==this.root)}siblingEdges(e){let t=[];for(let n of this.evidence(selectedOrderingKinds(e),!1)){let e=this.path(n.consumer),r=this.path(n.producer),i=0;for(;i<e.length&&i<r.length&&e[i].key===r[i].key;)i++;i!==e.length&&i!==r.length&&t.push({container:i===0?this.root:e[i-1],source:e[i],target:r[i]})}return t}};function selectedKinds(e){let t=new Set(e??a);if([...t].some(e=>!a.includes(e)))throw new o(`Unsupported dependency kind.`);return t}function selectedOrderingKinds(e){return[...selectedKinds(e??l)].filter(e=>l.includes(e))}function adjacency(e,t){let n=new Map(e.map(e=>[e.key,/* @__PURE__ */ new Set]));for(let e of t)n.get(e.source.key).add(e.target.key);return n}function groupsOf(e,t,n){let r=new Map(t.map(e=>[e.key,e]));return c(e).filter(e=>e.length>1).map(e=>({container:n,members:distinctNodes(e.map(e=>r.get(e)))})).sort((e,t)=>e.members[0].rank-t.members[0].rank)}export{u as DependencyGraph};
2
2
  //# sourceMappingURL=DependencyGraph.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DependencyGraph.js","names":["orderingKinds","left","right","kind","name","address","nodes","node","dependencyKinds","blocks","block","DependencyGraph","authoredOrderOf","application","ranks","expandSpecificationExamples","items","authoredOrderKey","parent","syntax","item","slice","child","module","declarations","builders","key","inventory","owners","qualified","scopedOwners","event","eventDeclarations","command","reaction","query","screen","readModel","projection","found","variant","reducer","dependencySourcesOf","foundations","trigger","sharedTypes","type","sharedPolicies","policy","imports","imported","contexts","evidence","unresolved","usedImports","excluded","collected","sliceReferences","reference","candidates","producer","matches","contract","contextName","context","edgeGroups","group","from","InvalidDependencyQuery","to","evidenceLimit","groups","kinds","includeTestOnly","source","target","byKind","count","level","edges","edge","children","container","suggestions","local","byKey","stronglyConnectedGroups","membership","index","dependencies","remaining","ordered","ready","orders","slices","direction","links","visited","queue","link","scope","existing","ancestors","selected","consumer","common","graph"],"sources":["../../../../../../Compiler/Dependencies/DependencyGraph.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { authoredOrderKey, authoredOrderOf } from '../Files/AuthoredOrder';\nimport { expandSpecificationExamples } from '../Parsing/SpecificationCommandExamples';\nimport { dependencySourcesOf } from '../Syntax/DependencySources';\nimport { eventDeclarations } from '../Syntax/EventDeclarations';\nimport { ProjectionBlockSyntax, ProjectionVariantSyntax } from '../Syntax/Projections';\nimport { ApplicationSyntax, FeatureSyntax, SliceSyntax } from '../Syntax/Structure';\nimport type { DependencyKind, DependencyNode, DependencyLevel, DependencyEvidence, DependencyEdge, UnresolvedDependency, ImpliedDependency, DependencyGroup, DependencyOrder, DependencyContainerOrder } from './index';\nimport { dependencyKinds } from './DependencyKind';\nimport { InvalidDependencyQuery } from './InvalidDependencyQuery';\nimport { SiblingEdge } from './SiblingEdge';\nimport { sliceReferences } from './SliceReferences';\nimport { stronglyConnectedGroups } from './StronglyConnectedGroups';\n\nconst orderingKinds: readonly string[] = ['usesFactsFrom', 'reactsTo', 'decidesFrom'];\nconst ordinal = (left: string, right: string): number => left < right ? -1 : left > right ? 1 : 0;\nconst declarationKey = (kind: string, name: string): string => JSON.stringify([kind, name.toLowerCase()]);\nconst nodeOf = (kind: DependencyLevel, address: string, scope: readonly string[], rank: number): DependencyNode => ({ kind, address, scope, rank, key: `${kind}:${address}` });\nconst compareNodes = (left: DependencyNode, right: DependencyNode): number => left.rank - right.rank || ordinal(left.key, right.key);\nconst distinctNodes = (nodes: Iterable<DependencyNode>): DependencyNode[] => [...new Map([...nodes].map(node => [node.key, node])).values()].sort(compareNodes);\nconst compareEvidence = (left: DependencyEvidence, right: DependencyEvidence): number => left.consumer.rank - right.consumer.rank || left.location.line - right.location.line || left.location.column - right.location.column || dependencyKinds.indexOf(left.kind) - dependencyKinds.indexOf(right.kind) || left.producer.rank - right.producer.rank || ordinal(left.location.path ?? '', right.location.path ?? '') || ordinal(left.role, right.role) || ordinal(left.name, right.name);\n\nfunction variants(blocks: readonly ProjectionBlockSyntax[]): ProjectionVariantSyntax[] {\n return blocks.flatMap(block => block.kind === 'ProjectionVariantSyntax' ? [block, ...variants(block.blocks)] : block.kind === 'ChildrenSyntax' || block.kind === 'NestedSyntax' ? variants(block.blocks) : []);\n}\n\n/** Presentation dependencies inferred from explicit syntax, independently of executable binding and identity. */\nexport class DependencyGraph {\n readonly orderSource: 'authored' | 'syntax';\n readonly edges: readonly DependencyEdge[];\n readonly unresolved: readonly UnresolvedDependency[];\n readonly excludedReferences: number;\n readonly unusedImports: readonly string[];\n private readonly modelNodes: DependencyNode[] = [];\n private readonly slices: { node: DependencyNode; syntax: SliceSyntax }[] = [];\n private readonly children = new Map<string, DependencyNode[]>();\n private readonly byKey = new Map<string, DependencyNode>();\n private readonly parents = new Map<string, DependencyNode>();\n private readonly root = nodeOf('application', '', [], -1);\n\n static for(application: ApplicationSyntax, ranks: ReadonlyMap<string, number> = authoredOrderOf(application)): DependencyGraph {\n return new DependencyGraph(application, ranks);\n }\n\n get nodes(): readonly DependencyNode[] { return this.modelNodes; }\n\n private constructor(application: ApplicationSyntax, ranks: ReadonlyMap<string, number>) {\n application = expandSpecificationExamples(application);\n this.orderSource = ranks.size > 0 ? 'authored' : 'syntax';\n this.children.set(this.root.key, []);\n const ordered = <T extends { name: string }>(items: readonly T[], parent: DependencyNode): T[] => items\n .map((syntax, index) => ({ syntax, index, rank: ranks.get(authoredOrderKey([...parent.scope, syntax.name])) ?? Number.MAX_SAFE_INTEGER }))\n .sort((left, right) => left.rank - right.rank || left.index - right.index).map(item => item.syntax);\n const feature = (syntax: FeatureSyntax, parent: DependencyNode) => {\n const node = this.add('feature', syntax.name, parent);\n for (const slice of ordered(syntax.slices, node)) this.slices.push({ node: this.add('slice', slice.name, node), syntax: slice });\n for (const child of ordered(syntax.features, node)) feature(child, node);\n };\n for (const module of ordered(application.modules, this.root)) {\n const node = this.add('module', module.name, this.root);\n for (const child of ordered(module.features, node)) feature(child, node);\n }\n const declarations = new Map<string, DependencyNode[]>();\n const builders = new Map<string, DependencyNode[]>();\n const declare = (inventory: Map<string, DependencyNode[]>, kind: string, name: string, node: DependencyNode) => {\n const key = declarationKey(kind, name);\n if (!inventory.has(key)) inventory.set(key, []);\n const owners = inventory.get(key)!;\n if (!owners.includes(node)) owners.push(node);\n const qualified = declarationKey(kind, [...node.scope, name].join('.'));\n if (!inventory.has(qualified)) inventory.set(qualified, []);\n const scopedOwners = inventory.get(qualified)!;\n if (!scopedOwners.includes(node)) scopedOwners.push(node);\n };\n for (const { node, syntax } of this.slices) {\n for (const event of eventDeclarations(syntax)) declare(declarations, 'Event', event.name, node);\n for (const command of syntax.commands) declare(declarations, 'Command', command.name, node);\n for (const reaction of syntax.reactions) declare(declarations, 'Reaction', reaction.name, node);\n for (const query of syntax.queries) declare(declarations, 'Query', query.name, node);\n for (const screen of syntax.screens) declare(declarations, 'Screen', screen.name, node);\n for (const readModel of syntax.readModels) declare(declarations, 'ReadModel', readModel.name, node);\n for (const projection of syntax.projections) {\n const found = variants(projection.blocks);\n if (found.length === 0) declare(builders, 'ReadModel', projection.readModel ?? projection.name, node);\n for (const variant of found) declare(builders, 'ReadModel', variant.name, node);\n }\n for (const reducer of dependencySourcesOf(syntax).reducers ?? []) declare(builders, 'ReadModel', reducer.readModel, node);\n }\n const foundations = new Set((application.declaredTriggers ?? []).map(trigger => trigger.name.toLowerCase()));\n const sharedTypes = new Set([...application.concepts, ...application.types].map(type => type.name.toLowerCase()));\n const sharedPolicies = new Set((application.policies ?? []).map(policy => policy.name.toLowerCase()));\n const imports = application.imports.filter(imported => imported.qualifiedName.includes('.')).slice().sort((left, right) => ordinal(left.location.path ?? '', right.location.path ?? '') || left.location.line - right.location.line || left.location.column - right.location.column || ordinal(left.qualifiedName, right.qualifiedName));\n const contexts = new Map<string, DependencyNode>();\n const evidence: DependencyEvidence[] = [];\n const unresolved: UnresolvedDependency[] = [];\n const usedImports = new Set<string>();\n let excluded = 0;\n for (const { node, syntax } of this.slices) {\n const collected = sliceReferences(syntax);\n excluded += collected.shared.filter(reference => (reference.kind === 'type' ? sharedTypes : sharedPolicies).has(reference.name.toLowerCase())).length;\n for (const reference of collected.references) {\n const key = declarationKey(reference.targetKind, reference.name);\n const inventory = reference.targetKind === 'ReadModel' && builders.has(key) ? builders : declarations;\n const candidates = inventory.get(key);\n if (candidates !== undefined && candidates.length > 0) {\n const producer = candidates[0];\n if (producer !== node) evidence.push({ consumer: node, producer, kind: reference.kind, role: reference.role, name: reference.name, ambiguous: candidates.length > 1, alternatives: candidates.slice(1), location: reference.location, testOnly: reference.kind === 'verifiedWith' });\n continue;\n }\n const imported = reference.targetKind === 'Event' ? imports.filter(imported => imported.qualifiedName.slice(imported.qualifiedName.lastIndexOf('.') + 1).toLowerCase() === reference.name.toLowerCase()) : [];\n if (imported.length > 0) {\n const matches: DependencyNode[] = [];\n for (const contract of imported) {\n usedImports.add(contract.qualifiedName);\n const contextName = contract.qualifiedName.slice(0, contract.qualifiedName.lastIndexOf('.'));\n const address = `context:${contextName}`;\n if (!contexts.has(address)) {\n const context = nodeOf('context', address, [contextName], this.modelNodes.length);\n this.modelNodes.push(context);\n contexts.set(address, context);\n }\n const context = contexts.get(address)!;\n if (!matches.includes(context)) matches.push(context);\n }\n evidence.push({ consumer: node, producer: matches[0], kind: 'outsideTheModel', role: reference.role, name: reference.name, ambiguous: matches.length > 1, alternatives: matches.slice(1), location: reference.location, testOnly: reference.kind === 'verifiedWith' });\n continue;\n }\n if (reference.role === 'trigger' && foundations.has(reference.name.toLowerCase())) {\n excluded++;\n continue;\n }\n unresolved.push({ consumer: node, kind: reference.kind, role: reference.role, name: reference.name, location: reference.location });\n }\n }\n const edgeGroups = new Map<string, DependencyEvidence[]>();\n for (const item of evidence.sort(compareEvidence)) {\n const key = JSON.stringify([item.consumer.key, item.producer.key, item.kind]);\n if (!edgeGroups.has(key)) edgeGroups.set(key, []);\n edgeGroups.get(key)!.push(item);\n }\n this.edges = [...edgeGroups.values()].map(group => ({ consumer: group[0].consumer, producer: group[0].producer, kind: group[0].kind, evidence: group }));\n this.unresolved = unresolved.sort((left, right) => left.consumer.rank - right.consumer.rank || left.location.line - right.location.line || left.location.column - right.location.column || dependencyKinds.indexOf(left.kind) - dependencyKinds.indexOf(right.kind) || ordinal(left.location.path ?? '', right.location.path ?? '') || ordinal(left.name, right.name));\n this.excludedReferences = excluded;\n this.unusedImports = [...new Set(imports.filter(imported => !usedImports.has(imported.qualifiedName)).map(imported => imported.qualifiedName))];\n }\n\n /** Aggregate any level pair, excluding equal and overlapping containers. Counts include capped evidence. */\n implied(from: string, to: string, kinds?: Iterable<string>, includeTestOnly = false, evidenceLimit = 3): ImpliedDependency[] {\n if (!['slice', 'feature', 'module'].includes(from)) throw new InvalidDependencyQuery(`Unsupported source level '${from}'.`);\n if (!['slice', 'feature', 'module', 'context'].includes(to)) throw new InvalidDependencyQuery(`Unsupported target level '${to}'.`);\n if (evidenceLimit < 0) throw new InvalidDependencyQuery('Evidence limit must not be negative.');\n const groups = new Map<string, { source: DependencyNode; target: DependencyNode; evidence: DependencyEvidence[] }>();\n for (const item of this.evidence(kinds, includeTestOnly)) {\n for (const source of this.at(item.consumer, from)) {\n for (const target of this.at(item.producer, to).filter(target => this.disjoint(source, target))) {\n const key = JSON.stringify([source.key, target.key]);\n if (!groups.has(key)) groups.set(key, { source, target, evidence: [] });\n groups.get(key)!.evidence.push(item);\n }\n }\n }\n return [...groups.values()].sort((left, right) => left.source.rank - right.source.rank || left.target.rank - right.target.rank || ordinal(left.source.key, right.source.key) || ordinal(left.target.key, right.target.key)).map(group => {\n const evidence = group.evidence.sort(compareEvidence);\n const byKind: Partial<Record<DependencyKind, number>> = {};\n for (const kind of dependencyKinds) {\n const count = evidence.filter(item => item.kind === kind).length;\n if (count > 0) byKind[kind] = count;\n }\n return { source: group.source, target: group.target, sliceEdges: new Set(evidence.map(item => JSON.stringify([item.consumer.key, item.producer.key]))).size, references: evidence.length, byKind, consumers: distinctNodes(evidence.map(item => item.consumer)), producers: distinctNodes(evidence.map(item => item.producer)), evidence: evidence.slice(0, evidenceLimit), evidenceCount: evidence.length, evidenceTruncated: evidence.length > evidenceLimit };\n });\n }\n\n /** Mutual dependencies at a single level; only story-ordering kinds can constrain cycles. */\n cycles(level: string, kinds?: Iterable<string>): DependencyGroup[] {\n if (!['slice', 'feature', 'module'].includes(level)) throw new InvalidDependencyQuery(`Unsupported cycle level '${level}'.`);\n const edges = this.implied(level, level, selectedOrderingKinds(kinds));\n const nodes = distinctNodes(edges.flatMap(edge => [edge.source, edge.target]));\n return groupsOf(adjacency(nodes, edges), nodes, null);\n }\n\n siblingGroups(kinds?: Iterable<string>): DependencyGroup[] {\n const edges = this.siblingEdges(kinds);\n return this.containers().flatMap(container => {\n const children = this.children.get(container.key)!;\n return groupsOf(adjacency(children, edges.filter(edge => edge.container === container)), children, container);\n });\n }\n\n /** Producers first via Kahn, preserving authored rank ties and cycle members' relative order. Never applied. */\n suggestedOrder(kinds?: Iterable<string>): DependencyOrder {\n const edges = this.siblingEdges(kinds);\n const suggestions: DependencyContainerOrder[] = [];\n for (const container of this.containers()) {\n const children = this.children.get(container.key)!;\n const local = edges.filter(edge => edge.container === container);\n const byKey = new Map(children.map(node => [node.key, node]));\n const groups = stronglyConnectedGroups(adjacency(children, local)).map(group => group.map(key => byKey.get(key)!).sort(compareNodes)).sort((left, right) => left[0].rank - right[0].rank);\n const membership = new Map(groups.flatMap((group, index) => group.map(node => [node.key, index] as const)));\n const dependencies = new Map(children.map(node => [node.key, new Set<string>()]));\n for (const edge of local) if (membership.get(edge.source.key) !== membership.get(edge.target.key)) dependencies.get(edge.source.key)!.add(edge.target.key);\n // Remove cycle-internal edges, not unrelated children. A cycle need not become contiguous.\n for (const group of groups) for (let index = 1; index < group.length; index++) dependencies.get(group[index].key)!.add(group[index - 1].key);\n const remaining = new Set(children.map(node => node.key));\n const ordered: DependencyNode[] = [];\n while (remaining.size > 0) {\n const ready = [...remaining].filter(key => dependencies.get(key)!.size === 0).sort((left, right) => compareNodes(byKey.get(left)!, byKey.get(right)!))[0];\n ordered.push(byKey.get(ready)!);\n remaining.delete(ready);\n for (const key of remaining) dependencies.get(key)!.delete(ready);\n }\n suggestions.push({ container, children: ordered, changed: children.some((node, index) => node !== ordered[index]) });\n }\n const orders = new Map(suggestions.map(item => [item.container.key, item.children]));\n const slices: DependencyNode[] = [];\n const walk = (node: DependencyNode) => {\n if (node.kind === 'slice') slices.push(node);\n else for (const child of [...orders.get(node.key)!].sort((left, right) => Number(left.kind !== 'slice') - Number(right.kind !== 'slice'))) walk(child);\n };\n walk(this.root);\n return { containers: suggestions, slices };\n }\n\n traverse(address: string, direction: string, kinds?: Iterable<string>, includeTestOnly = false): DependencyNode[] {\n if (direction !== 'incoming' && direction !== 'outgoing') throw new InvalidDependencyQuery(`Unsupported dependency direction '${direction}'.`);\n const links = this.evidence(kinds, includeTestOnly).map(item => direction === 'incoming' ? { source: item.producer, target: item.consumer } : { source: item.consumer, target: item.producer });\n const visited = new Set([address]);\n const queue = [address];\n const nodes: DependencyNode[] = [];\n for (let index = 0; index < queue.length; index++) {\n for (const link of links.filter(link => link.source.address === queue[index]).sort((left, right) => left.target.rank - right.target.rank)) {\n if (visited.has(link.target.address)) continue;\n visited.add(link.target.address);\n nodes.push(link.target);\n queue.push(link.target.address);\n }\n }\n return distinctNodes(nodes);\n }\n\n private add(kind: DependencyLevel, name: string, parent: DependencyNode): DependencyNode {\n const scope = [...parent.scope, name];\n const address = scope.join('.');\n const key = `${kind}:${address}`;\n const existing = this.byKey.get(key);\n if (existing !== undefined) return existing;\n const node = nodeOf(kind, address, scope, this.modelNodes.length);\n this.modelNodes.push(node);\n this.byKey.set(key, node);\n this.parents.set(key, parent);\n this.children.get(parent.key)!.push(node);\n if (kind !== 'slice') this.children.set(key, []);\n return node;\n }\n private ancestors(node: DependencyNode): DependencyNode[] {\n const ancestors: DependencyNode[] = [];\n for (let parent = this.parents.get(node.key); parent !== undefined; parent = this.parents.get(parent.key)) ancestors.push(parent);\n return ancestors;\n }\n private disjoint(left: DependencyNode, right: DependencyNode): boolean {\n return left.key !== right.key && !this.ancestors(left).includes(right) && !this.ancestors(right).includes(left);\n }\n private at(node: DependencyNode, level: string): DependencyNode[] { return [node, ...this.ancestors(node)].filter(node => node.kind === level); }\n private containers(): DependencyNode[] { return [this.root, ...this.modelNodes.filter(node => node.kind === 'module' || node.kind === 'feature')]; }\n private evidence(kinds: Iterable<string> | undefined, includeTestOnly: boolean): DependencyEvidence[] {\n const selected = selectedKinds(kinds);\n return this.edges.flatMap(edge => edge.evidence).filter(item => selected.has(item.kind) && (includeTestOnly || !item.testOnly));\n }\n private path(node: DependencyNode): DependencyNode[] { return [...this.ancestors(node).reverse(), node].filter(node => node !== this.root); }\n private siblingEdges(kinds?: Iterable<string>): SiblingEdge[] {\n const edges: SiblingEdge[] = [];\n for (const item of this.evidence(selectedOrderingKinds(kinds), false)) {\n const consumer = this.path(item.consumer);\n const producer = this.path(item.producer);\n let common = 0;\n while (common < consumer.length && common < producer.length && consumer[common].key === producer[common].key) common++;\n if (common === consumer.length || common === producer.length) continue;\n edges.push({ container: common === 0 ? this.root : consumer[common - 1], source: consumer[common], target: producer[common] });\n }\n return edges;\n }\n}\n\nfunction selectedKinds(kinds?: Iterable<string>): Set<string> {\n const selected = new Set(kinds ?? dependencyKinds);\n if ([...selected].some(kind => !(dependencyKinds as readonly string[]).includes(kind))) throw new InvalidDependencyQuery('Unsupported dependency kind.');\n return selected;\n}\nfunction selectedOrderingKinds(kinds?: Iterable<string>): string[] { return [...selectedKinds(kinds ?? orderingKinds)].filter(kind => orderingKinds.includes(kind)); }\nfunction adjacency(nodes: readonly DependencyNode[], edges: readonly { source: DependencyNode; target: DependencyNode }[]): Map<string, Set<string>> {\n const graph = new Map(nodes.map(node => [node.key, new Set<string>()]));\n for (const edge of edges) graph.get(edge.source.key)!.add(edge.target.key);\n return graph;\n}\nfunction groupsOf(graph: ReadonlyMap<string, ReadonlySet<string>>, nodes: readonly DependencyNode[], container: DependencyNode | null): DependencyGroup[] {\n const byKey = new Map(nodes.map(node => [node.key, node]));\n return stronglyConnectedGroups(graph).filter(group => group.length > 1).map(group => ({ container, members: distinctNodes(group.map(key => byKey.get(key)!)) })).sort((left, right) => left.members[0].rank - right.members[0].rank);\n}\n"],"mappings":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AcA,EAAM,IAAI,GAAOmB,EAAM,IAAI3D,CAAG,CAAE,CAAC,CAAE,EAAE,CAAC,CAAC,MAAM,EAAM,IAAUzB,EAAK,QAAQ,EAAE,CAAC,KAAOC,EAAM,QAAQ,EAAE,CAAC,IAAI,CACvO"}
1
+ {"version":3,"file":"DependencyGraph.js","names":["orderingKinds","left","right","kind","name","address","nodes","node","dependencyKinds","blocks","block","DependencyGraph","authoredOrderOf","application","ranks","expandSpecificationExamples","items","authoredOrderKey","parent","syntax","item","slice","child","module","eventTargets","declarations","builders","key","inventory","owners","qualified","scopedOwners","event","eventDeclarations","command","reaction","query","screen","readModel","reducer","dependencySourcesOf","foundations","trigger","sharedTypes","type","sharedPolicies","policy","imports","imported","contexts","evidence","unresolved","usedImports","excluded","collected","sliceReferences","reference","candidates","producer","matches","contract","contextName","context","edgeGroups","group","from","InvalidDependencyQuery","to","evidenceLimit","groups","kinds","includeTestOnly","source","target","byKind","count","level","edges","edge","children","container","suggestions","local","byKey","stronglyConnectedGroups","membership","index","dependencies","remaining","ordered","ready","orders","slices","direction","links","visited","queue","link","projection","found","variant","events","readModels","value","targets","scope","existing","ancestors","selected","consumer","common","graph"],"sources":["../../../../../../Compiler/Dependencies/DependencyGraph.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { authoredOrderKey, authoredOrderOf } from '../Files/AuthoredOrder';\nimport { expandSpecificationExamples } from '../Parsing/SpecificationCommandExamples';\nimport { dependencySourcesOf } from '../Syntax/DependencySources';\nimport { eventDeclarations } from '../Syntax/EventDeclarations';\nimport { ProjectionBlockSyntax, ProjectionSyntax, ProjectionVariantSyntax } from '../Syntax/Projections';\nimport { ApplicationSyntax, FeatureSyntax, SliceSyntax } from '../Syntax/Structure';\nimport type { DependencyKind, DependencyNode, DependencyLevel, DependencyEvidence, DependencyEdge, UnresolvedDependency, ImpliedDependency, DependencyGroup, DependencyOrder, DependencyContainerOrder } from './index';\nimport { dependencyKinds } from './DependencyKind';\nimport { InvalidDependencyQuery } from './InvalidDependencyQuery';\nimport { SiblingEdge } from './SiblingEdge';\nimport { sliceReferences } from './SliceReferences';\nimport { stronglyConnectedGroups } from './StronglyConnectedGroups';\n\nconst orderingKinds: readonly string[] = ['usesFactsFrom', 'reactsTo', 'decidesFrom'];\nconst ordinal = (left: string, right: string): number => left < right ? -1 : left > right ? 1 : 0;\nconst declarationKey = (kind: string, name: string): string => JSON.stringify([kind, name.toLowerCase()]);\nconst nodeOf = (kind: DependencyLevel, address: string, scope: readonly string[], rank: number): DependencyNode => ({ kind, address, scope, rank, key: `${kind}:${address}` });\nconst compareNodes = (left: DependencyNode, right: DependencyNode): number => left.rank - right.rank || ordinal(left.key, right.key);\nconst distinctNodes = (nodes: Iterable<DependencyNode>): DependencyNode[] => [...new Map([...nodes].map(node => [node.key, node])).values()].sort(compareNodes);\nconst compareEvidence = (left: DependencyEvidence, right: DependencyEvidence): number => left.consumer.rank - right.consumer.rank || left.location.line - right.location.line || left.location.column - right.location.column || dependencyKinds.indexOf(left.kind) - dependencyKinds.indexOf(right.kind) || left.producer.rank - right.producer.rank || ordinal(left.location.path ?? '', right.location.path ?? '') || ordinal(left.role, right.role) || ordinal(left.name, right.name);\n\nfunction variants(blocks: readonly ProjectionBlockSyntax[]): ProjectionVariantSyntax[] {\n return blocks.flatMap(block => block.kind === 'ProjectionVariantSyntax' ? [block, ...variants(block.blocks)] : block.kind === 'ChildrenSyntax' || block.kind === 'NestedSyntax' ? variants(block.blocks) : []);\n}\n\n/** Presentation dependencies inferred from explicit syntax, independently of executable binding and identity. */\nexport class DependencyGraph {\n readonly orderSource: 'authored' | 'syntax';\n readonly edges: readonly DependencyEdge[];\n readonly unresolved: readonly UnresolvedDependency[];\n readonly excludedReferences: number;\n readonly unusedImports: readonly string[];\n private readonly modelNodes: DependencyNode[] = [];\n private readonly slices: { node: DependencyNode; syntax: SliceSyntax }[] = [];\n private readonly children = new Map<string, DependencyNode[]>();\n private readonly byKey = new Map<string, DependencyNode>();\n private readonly parents = new Map<string, DependencyNode>();\n private readonly root = nodeOf('application', '', [], -1);\n\n static for(application: ApplicationSyntax, ranks: ReadonlyMap<string, number> = authoredOrderOf(application)): DependencyGraph {\n return new DependencyGraph(application, ranks);\n }\n\n get nodes(): readonly DependencyNode[] { return this.modelNodes; }\n\n private constructor(application: ApplicationSyntax, ranks: ReadonlyMap<string, number>) {\n application = expandSpecificationExamples(application);\n this.orderSource = ranks.size > 0 ? 'authored' : 'syntax';\n this.children.set(this.root.key, []);\n const ordered = <T extends { name: string }>(items: readonly T[], parent: DependencyNode): T[] => items\n .map((syntax, index) => ({ syntax, index, rank: ranks.get(authoredOrderKey([...parent.scope, syntax.name])) ?? Number.MAX_SAFE_INTEGER }))\n .sort((left, right) => left.rank - right.rank || left.index - right.index).map(item => item.syntax);\n const feature = (syntax: FeatureSyntax, parent: DependencyNode) => {\n const node = this.add('feature', syntax.name, parent);\n for (const slice of ordered(syntax.slices, node)) this.slices.push({ node: this.add('slice', slice.name, node), syntax: slice });\n for (const child of ordered(syntax.features, node)) feature(child, node);\n };\n for (const module of ordered(application.modules, this.root)) {\n const node = this.add('module', module.name, this.root);\n for (const child of ordered(module.features, node)) feature(child, node);\n }\n const eventTargets = this.projectionEventTargets();\n const declarations = new Map<string, DependencyNode[]>();\n const builders = new Map<string, DependencyNode[]>();\n const declare = (inventory: Map<string, DependencyNode[]>, kind: string, name: string, node: DependencyNode) => {\n const key = declarationKey(kind, name);\n if (!inventory.has(key)) inventory.set(key, []);\n const owners = inventory.get(key)!;\n if (!owners.includes(node)) owners.push(node);\n const qualified = declarationKey(kind, [...node.scope, name].join('.'));\n if (!inventory.has(qualified)) inventory.set(qualified, []);\n const scopedOwners = inventory.get(qualified)!;\n if (!scopedOwners.includes(node)) scopedOwners.push(node);\n };\n for (const { node, syntax } of this.slices) {\n for (const event of eventDeclarations(syntax)) declare(declarations, 'Event', event.name, node);\n for (const command of syntax.commands) declare(declarations, 'Command', command.name, node);\n for (const reaction of syntax.reactions) declare(declarations, 'Reaction', reaction.name, node);\n for (const query of syntax.queries) declare(declarations, 'Query', query.name, node);\n for (const screen of syntax.screens) declare(declarations, 'Screen', screen.name, node);\n for (const readModel of syntax.readModels) declare(declarations, 'ReadModel', readModel.name, node);\n for (const name of this.projectionReadModels(syntax, node, eventTargets)) declare(builders, 'ReadModel', name, node);\n for (const reducer of dependencySourcesOf(syntax).reducers ?? []) declare(builders, 'ReadModel', reducer.readModel, node);\n }\n const foundations = new Set((application.declaredTriggers ?? []).map(trigger => trigger.name.toLowerCase()));\n const sharedTypes = new Set([...application.concepts, ...application.types].map(type => type.name.toLowerCase()));\n const sharedPolicies = new Set((application.policies ?? []).map(policy => policy.name.toLowerCase()));\n const imports = application.imports.filter(imported => imported.qualifiedName.includes('.')).slice().sort((left, right) => ordinal(left.location.path ?? '', right.location.path ?? '') || left.location.line - right.location.line || left.location.column - right.location.column || ordinal(left.qualifiedName, right.qualifiedName));\n const contexts = new Map<string, DependencyNode>();\n const evidence: DependencyEvidence[] = [];\n const unresolved: UnresolvedDependency[] = [];\n const usedImports = new Set<string>();\n let excluded = 0;\n for (const { node, syntax } of this.slices) {\n const collected = sliceReferences(syntax);\n excluded += collected.shared.filter(reference => (reference.kind === 'type' ? sharedTypes : sharedPolicies).has(reference.name.toLowerCase())).length;\n for (const reference of collected.references) {\n const key = declarationKey(reference.targetKind, reference.name);\n const inventory = reference.targetKind === 'ReadModel' && builders.has(key) ? builders : declarations;\n const candidates = inventory.get(key);\n if (candidates !== undefined && candidates.length > 0) {\n const producer = candidates[0];\n if (producer !== node) evidence.push({ consumer: node, producer, kind: reference.kind, role: reference.role, name: reference.name, ambiguous: candidates.length > 1, alternatives: candidates.slice(1), location: reference.location, testOnly: reference.kind === 'verifiedWith' });\n continue;\n }\n const imported = reference.targetKind === 'Event' ? imports.filter(imported => imported.qualifiedName.slice(imported.qualifiedName.lastIndexOf('.') + 1).toLowerCase() === reference.name.toLowerCase()) : [];\n if (imported.length > 0) {\n const matches: DependencyNode[] = [];\n for (const contract of imported) {\n usedImports.add(contract.qualifiedName);\n const contextName = contract.qualifiedName.slice(0, contract.qualifiedName.lastIndexOf('.'));\n const address = `context:${contextName}`;\n if (!contexts.has(address)) {\n const context = nodeOf('context', address, [contextName], this.modelNodes.length);\n this.modelNodes.push(context);\n contexts.set(address, context);\n }\n const context = contexts.get(address)!;\n if (!matches.includes(context)) matches.push(context);\n }\n evidence.push({ consumer: node, producer: matches[0], kind: 'outsideTheModel', role: reference.role, name: reference.name, ambiguous: matches.length > 1, alternatives: matches.slice(1), location: reference.location, testOnly: reference.kind === 'verifiedWith' });\n continue;\n }\n if (reference.role === 'trigger' && foundations.has(reference.name.toLowerCase())) {\n excluded++;\n continue;\n }\n unresolved.push({ consumer: node, kind: reference.kind, role: reference.role, name: reference.name, location: reference.location });\n }\n }\n const edgeGroups = new Map<string, DependencyEvidence[]>();\n for (const item of evidence.sort(compareEvidence)) {\n const key = JSON.stringify([item.consumer.key, item.producer.key, item.kind]);\n if (!edgeGroups.has(key)) edgeGroups.set(key, []);\n edgeGroups.get(key)!.push(item);\n }\n this.edges = [...edgeGroups.values()].map(group => ({ consumer: group[0].consumer, producer: group[0].producer, kind: group[0].kind, evidence: group }));\n this.unresolved = unresolved.sort((left, right) => left.consumer.rank - right.consumer.rank || left.location.line - right.location.line || left.location.column - right.location.column || dependencyKinds.indexOf(left.kind) - dependencyKinds.indexOf(right.kind) || ordinal(left.location.path ?? '', right.location.path ?? '') || ordinal(left.name, right.name));\n this.excludedReferences = excluded;\n this.unusedImports = [...new Set(imports.filter(imported => !usedImports.has(imported.qualifiedName)).map(imported => imported.qualifiedName))];\n }\n\n /** Aggregate any level pair, excluding equal and overlapping containers. Counts include capped evidence. */\n implied(from: string, to: string, kinds?: Iterable<string>, includeTestOnly = false, evidenceLimit = 3): ImpliedDependency[] {\n if (!['slice', 'feature', 'module'].includes(from)) throw new InvalidDependencyQuery(`Unsupported source level '${from}'.`);\n if (!['slice', 'feature', 'module', 'context'].includes(to)) throw new InvalidDependencyQuery(`Unsupported target level '${to}'.`);\n if (evidenceLimit < 0) throw new InvalidDependencyQuery('Evidence limit must not be negative.');\n const groups = new Map<string, { source: DependencyNode; target: DependencyNode; evidence: DependencyEvidence[] }>();\n for (const item of this.evidence(kinds, includeTestOnly)) {\n for (const source of this.at(item.consumer, from)) {\n for (const target of this.at(item.producer, to).filter(target => this.disjoint(source, target))) {\n const key = JSON.stringify([source.key, target.key]);\n if (!groups.has(key)) groups.set(key, { source, target, evidence: [] });\n groups.get(key)!.evidence.push(item);\n }\n }\n }\n return [...groups.values()].sort((left, right) => left.source.rank - right.source.rank || left.target.rank - right.target.rank || ordinal(left.source.key, right.source.key) || ordinal(left.target.key, right.target.key)).map(group => {\n const evidence = group.evidence.sort(compareEvidence);\n const byKind: Partial<Record<DependencyKind, number>> = {};\n for (const kind of dependencyKinds) {\n const count = evidence.filter(item => item.kind === kind).length;\n if (count > 0) byKind[kind] = count;\n }\n return { source: group.source, target: group.target, sliceEdges: new Set(evidence.map(item => JSON.stringify([item.consumer.key, item.producer.key]))).size, references: evidence.length, byKind, consumers: distinctNodes(evidence.map(item => item.consumer)), producers: distinctNodes(evidence.map(item => item.producer)), evidence: evidence.slice(0, evidenceLimit), evidenceCount: evidence.length, evidenceTruncated: evidence.length > evidenceLimit };\n });\n }\n\n /** Mutual dependencies at a single level; only story-ordering kinds can constrain cycles. */\n cycles(level: string, kinds?: Iterable<string>): DependencyGroup[] {\n if (!['slice', 'feature', 'module'].includes(level)) throw new InvalidDependencyQuery(`Unsupported cycle level '${level}'.`);\n const edges = this.implied(level, level, selectedOrderingKinds(kinds));\n const nodes = distinctNodes(edges.flatMap(edge => [edge.source, edge.target]));\n return groupsOf(adjacency(nodes, edges), nodes, null);\n }\n\n siblingGroups(kinds?: Iterable<string>): DependencyGroup[] {\n const edges = this.siblingEdges(kinds);\n return this.containers().flatMap(container => {\n const children = this.children.get(container.key)!;\n return groupsOf(adjacency(children, edges.filter(edge => edge.container === container)), children, container);\n });\n }\n\n /** Producers first via Kahn, preserving authored rank ties and cycle members' relative order. Never applied. */\n suggestedOrder(kinds?: Iterable<string>): DependencyOrder {\n const edges = this.siblingEdges(kinds);\n const suggestions: DependencyContainerOrder[] = [];\n for (const container of this.containers()) {\n const children = this.children.get(container.key)!;\n const local = edges.filter(edge => edge.container === container);\n const byKey = new Map(children.map(node => [node.key, node]));\n const groups = stronglyConnectedGroups(adjacency(children, local)).map(group => group.map(key => byKey.get(key)!).sort(compareNodes)).sort((left, right) => left[0].rank - right[0].rank);\n const membership = new Map(groups.flatMap((group, index) => group.map(node => [node.key, index] as const)));\n const dependencies = new Map(children.map(node => [node.key, new Set<string>()]));\n for (const edge of local) if (membership.get(edge.source.key) !== membership.get(edge.target.key)) dependencies.get(edge.source.key)!.add(edge.target.key);\n // Remove cycle-internal edges, not unrelated children. A cycle need not become contiguous.\n for (const group of groups) for (let index = 1; index < group.length; index++) dependencies.get(group[index].key)!.add(group[index - 1].key);\n const remaining = new Set(children.map(node => node.key));\n const ordered: DependencyNode[] = [];\n while (remaining.size > 0) {\n const ready = [...remaining].filter(key => dependencies.get(key)!.size === 0).sort((left, right) => compareNodes(byKey.get(left)!, byKey.get(right)!))[0];\n ordered.push(byKey.get(ready)!);\n remaining.delete(ready);\n for (const key of remaining) dependencies.get(key)!.delete(ready);\n }\n suggestions.push({ container, children: ordered, changed: children.some((node, index) => node !== ordered[index]) });\n }\n const orders = new Map(suggestions.map(item => [item.container.key, item.children]));\n const slices: DependencyNode[] = [];\n const walk = (node: DependencyNode) => {\n if (node.kind === 'slice') slices.push(node);\n else for (const child of [...orders.get(node.key)!].sort((left, right) => Number(left.kind !== 'slice') - Number(right.kind !== 'slice'))) walk(child);\n };\n walk(this.root);\n return { containers: suggestions, slices };\n }\n\n traverse(address: string, direction: string, kinds?: Iterable<string>, includeTestOnly = false): DependencyNode[] {\n if (direction !== 'incoming' && direction !== 'outgoing') throw new InvalidDependencyQuery(`Unsupported dependency direction '${direction}'.`);\n const links = this.evidence(kinds, includeTestOnly).map(item => direction === 'incoming' ? { source: item.producer, target: item.consumer } : { source: item.consumer, target: item.producer });\n const visited = new Set([address]);\n const queue = [address];\n const nodes: DependencyNode[] = [];\n for (let index = 0; index < queue.length; index++) {\n for (const link of links.filter(link => link.source.address === queue[index]).sort((left, right) => left.target.rank - right.target.rank)) {\n if (visited.has(link.target.address)) continue;\n visited.add(link.target.address);\n nodes.push(link.target);\n queue.push(link.target.address);\n }\n }\n return distinctNodes(nodes);\n }\n\n private isBareProjectionTarget(name: string): boolean {\n if (name.length === 0) return false;\n return !name.includes('.');\n }\n private *projectionReadModels(syntax: SliceSyntax, node: DependencyNode, eventTargets: ReadonlyMap<string, DependencyNode>): Iterable<string> {\n for (const projection of syntax.projections) {\n const found = variants(projection.blocks);\n if (found.length > 0) {\n yield* found.map(variant => variant.name);\n continue;\n }\n yield* this.projectionReadModel(projection, node, eventTargets);\n }\n }\n private projectionReadModel(projection: ProjectionSyntax, node: DependencyNode, eventTargets: ReadonlyMap<string, DependencyNode>): string[] {\n if (eventTargets.get(projection.readModel ?? '') === node) return [];\n return [projection.readModel ?? projection.name];\n }\n private projectionEventTargets(): Map<string, DependencyNode> {\n // Count physical declarations before registering builders, including case-only and generation collisions.\n const events = new Map<string, { node: DependencyNode; name: string }[]>();\n const readModels = new Set(this.slices.flatMap(({ syntax }) => syntax.readModels.map(value => value.name.toLowerCase())));\n for (const { node, syntax } of this.slices) {\n for (const event of eventDeclarations(syntax)) {\n const key = event.name.toLowerCase();\n if (!events.has(key)) events.set(key, []);\n events.get(key)!.push({ node, name: event.name });\n }\n }\n const targets = [...events.values()].filter(group => group.length === 1).map(([target]) => target)\n .filter(target => this.isBareProjectionTarget(target.name))\n .filter(target => !readModels.has(target.name.toLowerCase()));\n return new Map(targets.map(target => [target.name, target.node]));\n }\n private add(kind: DependencyLevel, name: string, parent: DependencyNode): DependencyNode {\n const scope = [...parent.scope, name];\n const address = scope.join('.');\n const key = `${kind}:${address}`;\n const existing = this.byKey.get(key);\n if (existing !== undefined) return existing;\n const node = nodeOf(kind, address, scope, this.modelNodes.length);\n this.modelNodes.push(node);\n this.byKey.set(key, node);\n this.parents.set(key, parent);\n this.children.get(parent.key)!.push(node);\n if (kind !== 'slice') this.children.set(key, []);\n return node;\n }\n private ancestors(node: DependencyNode): DependencyNode[] {\n const ancestors: DependencyNode[] = [];\n for (let parent = this.parents.get(node.key); parent !== undefined; parent = this.parents.get(parent.key)) ancestors.push(parent);\n return ancestors;\n }\n private disjoint(left: DependencyNode, right: DependencyNode): boolean {\n return left.key !== right.key && !this.ancestors(left).includes(right) && !this.ancestors(right).includes(left);\n }\n private at(node: DependencyNode, level: string): DependencyNode[] { return [node, ...this.ancestors(node)].filter(node => node.kind === level); }\n private containers(): DependencyNode[] { return [this.root, ...this.modelNodes.filter(node => node.kind === 'module' || node.kind === 'feature')]; }\n private evidence(kinds: Iterable<string> | undefined, includeTestOnly: boolean): DependencyEvidence[] {\n const selected = selectedKinds(kinds);\n return this.edges.flatMap(edge => edge.evidence).filter(item => selected.has(item.kind) && (includeTestOnly || !item.testOnly));\n }\n private path(node: DependencyNode): DependencyNode[] { return [...this.ancestors(node).reverse(), node].filter(node => node !== this.root); }\n private siblingEdges(kinds?: Iterable<string>): SiblingEdge[] {\n const edges: SiblingEdge[] = [];\n for (const item of this.evidence(selectedOrderingKinds(kinds), false)) {\n const consumer = this.path(item.consumer);\n const producer = this.path(item.producer);\n let common = 0;\n while (common < consumer.length && common < producer.length && consumer[common].key === producer[common].key) common++;\n if (common === consumer.length || common === producer.length) continue;\n edges.push({ container: common === 0 ? this.root : consumer[common - 1], source: consumer[common], target: producer[common] });\n }\n return edges;\n }\n}\n\nfunction selectedKinds(kinds?: Iterable<string>): Set<string> {\n const selected = new Set(kinds ?? dependencyKinds);\n if ([...selected].some(kind => !(dependencyKinds as readonly string[]).includes(kind))) throw new InvalidDependencyQuery('Unsupported dependency kind.');\n return selected;\n}\nfunction selectedOrderingKinds(kinds?: Iterable<string>): string[] { return [...selectedKinds(kinds ?? orderingKinds)].filter(kind => orderingKinds.includes(kind)); }\nfunction adjacency(nodes: readonly DependencyNode[], edges: readonly { source: DependencyNode; target: DependencyNode }[]): Map<string, Set<string>> {\n const graph = new Map(nodes.map(node => [node.key, new Set<string>()]));\n for (const edge of edges) graph.get(edge.source.key)!.add(edge.target.key);\n return graph;\n}\nfunction groupsOf(graph: ReadonlyMap<string, ReadonlySet<string>>, nodes: readonly DependencyNode[], container: DependencyNode | null): DependencyGroup[] {\n const byKey = new Map(nodes.map(node => [node.key, node]));\n return stronglyConnectedGroups(graph).filter(group => group.length > 1).map(group => ({ container, members: distinctNodes(group.map(key => byKey.get(key)!)) })).sort((left, right) => left.members[0].rank - right.members[0].rank);\n}\n"],"mappings":"imBAgBA,MAAMA,EAAmC,CAAC,gBAAiB,WAAY,aAAa,EAC9E,SAAW,EAAc,IAA0BC,EAAOC,EAAQ,GAAK,IAAOA,GAC9E,gBAAkB,EAAc,IAAyB,KAAK,UAAU,CAACC,EAAMC,EAAK,YAAY,CAAC,CAAC,EAClG,QAAU,EAAuB,EAAiB,EAA0B,KAAkC,CAAE,OAAM,UAAS,QAAO,OAAM,IAAK,GAAGD,EAAK,GAAGE,GAAU,GACtK,cAAgB,EAAsB,IAAkCJ,EAAK,KAAOC,EAAM,MAAQ,QAAQD,EAAK,IAAKC,EAAM,GAAG,EAC7H,cAAiB,GAAsD,CAAC,GAAG,IAAI,IAAI,CAAC,GAAGI,CAAK,CAAC,CAAC,IAAI,GAAQ,CAACC,EAAK,IAAKA,CAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,YAAY,EACxJ,iBAAmB,EAA0B,IAAsCN,EAAK,SAAS,KAAOC,EAAM,SAAS,MAAQD,EAAK,SAAS,KAAOC,EAAM,SAAS,MAAQD,EAAK,SAAS,OAASC,EAAM,SAAS,QAAUM,EAAgB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,EAAgG,CACjJ,IAAM4G,EAAQ,IAAI,IAAIzG,EAAM,IAAI,GAAQ,CAACC,EAAK,oBAAK,IAAI,GAAa,CAAC,CAAC,EACtE,IAAK,IAAMuE,KAAQD,EAAOkC,EAAM,IAAIjC,EAAK,OAAO,GAAG,CAAC,CAAE,IAAIA,EAAK,OAAO,GAAG,EACzE,OAAOiC,CACX,CACA,SAAS,SAAS,EAAiD,EAAkC,EAAqD,CACtJ,IAAM5B,EAAQ,IAAI,IAAI7E,EAAM,IAAI,GAAQ,CAACC,EAAK,IAAKA,CAAI,CAAC,CAAC,EACzD,OAAO6E,EAAwB2B,CAAK,CAAC,CAAC,OAAO,GAAS/C,EAAM,OAAS,CAAC,CAAC,CAAC,IAAI,IAAU,CAAE,YAAW,QAAS,cAAcA,EAAM,IAAI,GAAOmB,EAAM,IAAIxD,CAAG,CAAE,CAAC,CAAE,EAAE,CAAC,CAAC,MAAM,EAAM,IAAU1B,EAAK,QAAQ,EAAE,CAAC,KAAOC,EAAM,QAAQ,EAAE,CAAC,IAAI,CACvO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/screenplay-language",
3
- "version": "4.248.0",
3
+ "version": "4.249.1",
4
4
  "description": "Monaco language service for the Cratis Screenplay DSL — syntax highlighting, IntelliSense, hover and diagnostics for .play files",
5
5
  "keywords": [
6
6
  "cratis",