@kanonak-protocol/sdk 3.58.0 → 3.60.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/browser.js +1 -1
  2. package/dist/chunk-2ACBWC7K.js +1 -0
  3. package/dist/{chunk-CYDDQF6S.js → chunk-7JZUJ2K4.js} +1 -1
  4. package/dist/chunk-CA2EATJR.js +1 -0
  5. package/dist/{chunk-IIODYDKS.js → chunk-IUCHSPLQ.js} +1 -1
  6. package/dist/{chunk-ESYVKB25.js → chunk-JYUZT2JU.js} +1 -1
  7. package/dist/{chunk-WDQONH3P.js → chunk-KSTGTV35.js} +1 -1
  8. package/dist/{chunk-BSJ6PEKE.js → chunk-OIVACCMQ.js} +9 -9
  9. package/dist/chunk-ORFSMEMM.js +1 -0
  10. package/dist/{chunk-DC774EQL.js → chunk-PEUTCG3B.js} +1 -1
  11. package/dist/{chunk-VJT6YUWK.js → chunk-Q6QTQWR2.js} +1 -1
  12. package/dist/{chunk-SD5QKNBC.js → chunk-QHJ6EY3Y.js} +1 -1
  13. package/dist/chunk-RSIZQAFL.js +2 -0
  14. package/dist/chunk-SC5M74NM.js +1 -0
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.js +20 -20
  17. package/dist/parsing/KanonakParser.d.ts +10 -1
  18. package/dist/parsing/index.js +1 -1
  19. package/dist/reasoning/index.js +1 -1
  20. package/dist/repositories/PublisherConfig.d.ts +11 -0
  21. package/dist/repositories/browser.js +1 -1
  22. package/dist/repositories/index.js +1 -1
  23. package/dist/resolution/VersionUtils.d.ts +12 -0
  24. package/dist/resolution/assertPackageIdentity.d.ts +10 -0
  25. package/dist/resolution/index.d.ts +2 -1
  26. package/dist/resolution/index.js +1 -1
  27. package/dist/search/index.js +1 -1
  28. package/dist/server/assembleModel.d.ts +21 -0
  29. package/dist/server/index.d.ts +4 -0
  30. package/dist/server/index.js +2 -2
  31. package/dist/server/loadResourceModel.d.ts +26 -0
  32. package/dist/server/renderStack.d.ts +42 -0
  33. package/dist/transformations/index.js +1 -1
  34. package/dist/validation/index.js +1 -1
  35. package/package.json +2 -2
  36. package/dist/chunk-6SGRDFL5.js +0 -2
  37. package/dist/chunk-7CUTGGH3.js +0 -1
  38. package/dist/chunk-FQHALFRR.js +0 -1
  39. package/dist/chunk-MYPKSBTP.js +0 -1
@@ -1 +1 @@
1
- import{c as _}from"./chunk-VJT6YUWK.js";import{a as j,b as x}from"./chunk-H2LEQLVD.js";import{d as l,e as u,f as b,g as $,h as s,j as h}from"./chunk-64TVBQFR.js";import{c as S,d as O,g as I,h as T,i as g,j as v,k as L,l as q}from"./chunk-W6T7MOKY.js";var d=class{all=new Set;byPIdx=new Map;bySPIdx=new Map;byPOIdx=new Map;tripleList=[];add(e){let t=b(e);return this.all.has(t)?!1:(this.all.add(t),this.tripleList.push(e),P(this.byPIdx,e.p,e),P(this.bySPIdx,`${e.s}|${e.p}`,e),e.o.kind==="uri"&&P(this.byPOIdx,`${e.p}|${e.o.key}`,e),!0)}has(e){return this.all.has(b(e))}size(){return this.tripleList.length}snapshot(){return this.tripleList.slice()}byPredicate(e){let t=this.byPIdx.get(e);return t?t.slice():[]}bySubjectPredicate(e,t){let r=this.bySPIdx.get(`${e}|${t}`);return r?r.slice():[]}byPredicateObject(e,t){let r=this.byPOIdx.get(`${e}|${t}`);return r?r.slice():[]}subjectsWithPredicateObject(e,t){let r=this.byPOIdx.get(`${e}|${t}`);if(!r)return[];let n=new Set;for(let a of r)n.add(a.s);return Array.from(n)}uriObjectsOf(e,t){let r=this.bySPIdx.get(`${e}|${t}`);if(!r)return[];let n=new Set;for(let a of r)a.o.kind==="uri"&&n.add(a.o.key);return Array.from(n)}hasUri(e,t,r){return this.all.has(`${e}|${t}|u:${r}`)}hasTriple(e,t,r){return this.all.has(`${e}|${t}|${$(r)}`)}};function P(o,e,t){let r=o.get(e);r?r.push(t):o.set(e,[t])}var w={name:"rdfs2",apply(o,e){let t=!1;for(let r of o.byPredicate(e.domain)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;for(let i of o.byPredicate(n))o.add(s(i.s,e.type,a))&&(t=!0)}return t}},C={name:"rdfs3",apply(o,e){let t=!1;for(let r of o.byPredicate(e.range)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;for(let i of o.byPredicate(n))i.o.kind==="uri"&&o.add(s(i.o.key,e.type,a))&&(t=!0)}return t}},A={name:"rdfs5",apply(o,e){let t=!1;for(let r of o.byPredicate(e.subPropertyOf)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;for(let i of o.bySubjectPredicate(a,e.subPropertyOf))i.o.kind==="uri"&&o.add(s(n,e.subPropertyOf,i.o.key))&&(t=!0)}return t}},V={name:"rdfs7",apply(o,e){let t=!1;for(let r of o.byPredicate(e.subPropertyOf)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.byPredicate(n)){let f={s:i.s,p:a,o:i.o};o.add(f)&&(t=!0)}}return t}},W={name:"rdfs9",apply(o,e){let t=!1;for(let r of o.byPredicate(e.subClassOf)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.byPredicateObject(e.type,n))o.add(s(i.s,e.type,a))&&(t=!0)}return t}},F={name:"rdfs11",apply(o,e){let t=!1;for(let r of o.byPredicate(e.subClassOf)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;for(let i of o.bySubjectPredicate(a,e.subClassOf))i.o.kind==="uri"&&o.add(s(n,e.subClassOf,i.o.key))&&(t=!0)}return t}},k=[w,C,A,V,W,F];var N={name:"prp-trp",apply(o,e){let t=!1,r=o.subjectsWithPredicateObject(e.type,e.transitiveProperty);for(let n of r){let a=o.byPredicate(n);for(let i of a){if(i.o.kind!=="uri")continue;let f=i.o.key;for(let c of o.bySubjectPredicate(f,n))c.o.kind==="uri"&&i.s!==c.o.key&&o.add(s(i.s,n,c.o.key))&&(t=!0)}}return t}},D={name:"prp-symp",apply(o,e){let t=!1,r=o.subjectsWithPredicateObject(e.type,e.symmetricProperty);for(let n of r)for(let a of o.byPredicate(n))a.o.kind==="uri"&&o.add(s(a.o.key,n,a.s))&&(t=!0);return t}},z={name:"prp-inv1",apply(o,e){let t=!1;for(let r of o.byPredicate(e.inverseOf)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;for(let i of o.byPredicate(n))i.o.kind==="uri"&&o.add(s(i.o.key,a,i.s))&&(t=!0)}return t}},B={name:"prp-inv2",apply(o,e){let t=!1;for(let r of o.byPredicate(e.inverseOf)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;for(let i of o.byPredicate(a))i.o.kind==="uri"&&o.add(s(i.o.key,n,i.s))&&(t=!0)}return t}},M={name:"prp-eqp1",apply(o,e){let t=!1;for(let r of o.byPredicate(e.equivalentProperty)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.byPredicate(n))o.add({s:i.s,p:a,o:i.o})&&(t=!0)}return t}},G={name:"prp-eqp2",apply(o,e){let t=!1;for(let r of o.byPredicate(e.equivalentProperty)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.byPredicate(a))o.add({s:i.s,p:n,o:i.o})&&(t=!0)}return t}},H={name:"cax-eqc1",apply(o,e){let t=!1;for(let r of o.byPredicate(e.equivalentClass)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.byPredicateObject(e.type,n))o.add(s(i.s,e.type,a))&&(t=!0)}return t}},J={name:"cax-eqc2",apply(o,e){let t=!1;for(let r of o.byPredicate(e.equivalentClass)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.byPredicateObject(e.type,a))o.add(s(i.s,e.type,n))&&(t=!0)}return t}},Q={name:"eq-rep-s",apply(o,e){let t=!1;for(let r of o.byPredicate(e.sameAs)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a){for(let i of o.snapshot())i.s===n&&o.add({s:a,p:i.p,o:i.o})&&(t=!0);for(let i of o.snapshot())i.s===a&&o.add({s:n,p:i.p,o:i.o})&&(t=!0)}}return t}},X={name:"eq-rep-o",apply(o,e){let t=!1;for(let r of o.byPredicate(e.sameAs)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.snapshot())i.o.kind==="uri"&&(i.o.key===n?o.add(s(i.s,i.p,a))&&(t=!0):i.o.key===a&&o.add(s(i.s,i.p,n))&&(t=!0))}return t}},K=[N,D,z,B,M,G,H,J,Q,X];var y=class{constructor(e,t){this.store=e;this.vocabulary=t}store;vocabulary;getInstancesOfClass(e){let t=p(e);return this.store.subjectsWithPredicateObject(this.vocabulary.type,t)}getSubclasses(e){let t=p(e);return this.store.subjectsWithPredicateObject(this.vocabulary.subClassOf,t).filter(n=>n!==t)}getSuperclasses(e){let t=p(e);return this.store.uriObjectsOf(t,this.vocabulary.subClassOf).filter(r=>r!==t)}getTypesOfIndividual(e){return this.store.uriObjectsOf(p(e),this.vocabulary.type)}isInstanceOf(e,t){return this.store.hasUri(p(e),this.vocabulary.type,p(t))}triples(){return this.store.snapshot()}size(){return this.store.size()}};function p(o){return typeof o=="string"?o:u(o.publisher,o.package_,o.name)}var R=class{vocabulary;profile;maxIterations;constructor(e={}){this.vocabulary=e.vocabulary??new h,this.profile=e.profile??"owl-rl-classification",this.maxIterations=e.maxIterations??100}async reason(e){let t=new d,n=await new _().parseKanonaks(e),a=new U;for(let c of n)if(c instanceof S){let m=Y(c);if(!m)continue;for(let E of c.statement)this.emitStatement(m,E,t,a)}let i=[...k];this.profile==="owl-rl-classification"&&i.push(...K);let f=0;for(;f<this.maxIterations;){let c=!1;for(let m of i)m.apply(t,this.vocabulary)&&(c=!0);if(!c)break;f++}return new y(t,this.vocabulary)}emitStatement(e,t,r,n){let a=Z(t);if(a){if(t instanceof I){r.add({s:e,p:a,o:{kind:"literal",lexical:t.object,datatype:"string"}});return}if(t instanceof T){r.add({s:e,p:a,o:{kind:"literal",lexical:String(t.object),datatype:"number"}});return}if(t instanceof g){r.add({s:e,p:a,o:{kind:"literal",lexical:String(t.object),datatype:"boolean"}});return}if(t instanceof v){let i=l(t.object.subject);r.add(s(e,a,i));return}if(t instanceof L){let i=n.next();r.add({s:e,p:a,o:{kind:"blank",id:i}}),this.emitEmbedded(i,t.object,r,n);return}if(t instanceof q){for(let i of t.object??[])this.emitListItem(e,a,i,r,n);return}}}emitListItem(e,t,r,n,a){if(r instanceof O)n.add(s(e,t,l(r.subject)));else if(r instanceof j){let i=a.next();n.add({s:e,p:t,o:{kind:"blank",id:i}}),this.emitEmbedded(i,r,n,a)}else if(r instanceof x){let i=typeof r.value=="number"?"number":typeof r.value=="boolean"?"boolean":"string";n.add({s:e,p:t,o:{kind:"literal",lexical:String(r.value),datatype:i}})}}emitEmbedded(e,t,r,n){let a=`_:${e}`;for(let i of t.statement)this.emitStatement(a,i,r,n)}},U=class{counter=0;next(){return`b${this.counter++}`}};function Y(o){let e=o.namespace??"",t=e.indexOf("@"),r=t===-1?e:e.substring(0,t),n=r.indexOf("/");if(n===-1)return null;let a=r.substring(0,n),i=r.substring(n+1);return!a||!i||!o.name?null:u(a,i,o.name)}function Z(o){let e=o.predicate;return e?.subject?l(e.subject):null}export{d as a,k as b,K as c,y as d,R as e};
1
+ import{c as _}from"./chunk-Q6QTQWR2.js";import{a as j,b as x}from"./chunk-H2LEQLVD.js";import{d as l,e as u,f as b,g as $,h as s,j as h}from"./chunk-64TVBQFR.js";import{c as S,d as O,g as I,h as T,i as g,j as v,k as L,l as q}from"./chunk-W6T7MOKY.js";var d=class{all=new Set;byPIdx=new Map;bySPIdx=new Map;byPOIdx=new Map;tripleList=[];add(e){let t=b(e);return this.all.has(t)?!1:(this.all.add(t),this.tripleList.push(e),P(this.byPIdx,e.p,e),P(this.bySPIdx,`${e.s}|${e.p}`,e),e.o.kind==="uri"&&P(this.byPOIdx,`${e.p}|${e.o.key}`,e),!0)}has(e){return this.all.has(b(e))}size(){return this.tripleList.length}snapshot(){return this.tripleList.slice()}byPredicate(e){let t=this.byPIdx.get(e);return t?t.slice():[]}bySubjectPredicate(e,t){let r=this.bySPIdx.get(`${e}|${t}`);return r?r.slice():[]}byPredicateObject(e,t){let r=this.byPOIdx.get(`${e}|${t}`);return r?r.slice():[]}subjectsWithPredicateObject(e,t){let r=this.byPOIdx.get(`${e}|${t}`);if(!r)return[];let n=new Set;for(let a of r)n.add(a.s);return Array.from(n)}uriObjectsOf(e,t){let r=this.bySPIdx.get(`${e}|${t}`);if(!r)return[];let n=new Set;for(let a of r)a.o.kind==="uri"&&n.add(a.o.key);return Array.from(n)}hasUri(e,t,r){return this.all.has(`${e}|${t}|u:${r}`)}hasTriple(e,t,r){return this.all.has(`${e}|${t}|${$(r)}`)}};function P(o,e,t){let r=o.get(e);r?r.push(t):o.set(e,[t])}var w={name:"rdfs2",apply(o,e){let t=!1;for(let r of o.byPredicate(e.domain)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;for(let i of o.byPredicate(n))o.add(s(i.s,e.type,a))&&(t=!0)}return t}},C={name:"rdfs3",apply(o,e){let t=!1;for(let r of o.byPredicate(e.range)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;for(let i of o.byPredicate(n))i.o.kind==="uri"&&o.add(s(i.o.key,e.type,a))&&(t=!0)}return t}},A={name:"rdfs5",apply(o,e){let t=!1;for(let r of o.byPredicate(e.subPropertyOf)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;for(let i of o.bySubjectPredicate(a,e.subPropertyOf))i.o.kind==="uri"&&o.add(s(n,e.subPropertyOf,i.o.key))&&(t=!0)}return t}},V={name:"rdfs7",apply(o,e){let t=!1;for(let r of o.byPredicate(e.subPropertyOf)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.byPredicate(n)){let f={s:i.s,p:a,o:i.o};o.add(f)&&(t=!0)}}return t}},W={name:"rdfs9",apply(o,e){let t=!1;for(let r of o.byPredicate(e.subClassOf)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.byPredicateObject(e.type,n))o.add(s(i.s,e.type,a))&&(t=!0)}return t}},F={name:"rdfs11",apply(o,e){let t=!1;for(let r of o.byPredicate(e.subClassOf)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;for(let i of o.bySubjectPredicate(a,e.subClassOf))i.o.kind==="uri"&&o.add(s(n,e.subClassOf,i.o.key))&&(t=!0)}return t}},k=[w,C,A,V,W,F];var N={name:"prp-trp",apply(o,e){let t=!1,r=o.subjectsWithPredicateObject(e.type,e.transitiveProperty);for(let n of r){let a=o.byPredicate(n);for(let i of a){if(i.o.kind!=="uri")continue;let f=i.o.key;for(let c of o.bySubjectPredicate(f,n))c.o.kind==="uri"&&i.s!==c.o.key&&o.add(s(i.s,n,c.o.key))&&(t=!0)}}return t}},D={name:"prp-symp",apply(o,e){let t=!1,r=o.subjectsWithPredicateObject(e.type,e.symmetricProperty);for(let n of r)for(let a of o.byPredicate(n))a.o.kind==="uri"&&o.add(s(a.o.key,n,a.s))&&(t=!0);return t}},z={name:"prp-inv1",apply(o,e){let t=!1;for(let r of o.byPredicate(e.inverseOf)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;for(let i of o.byPredicate(n))i.o.kind==="uri"&&o.add(s(i.o.key,a,i.s))&&(t=!0)}return t}},B={name:"prp-inv2",apply(o,e){let t=!1;for(let r of o.byPredicate(e.inverseOf)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;for(let i of o.byPredicate(a))i.o.kind==="uri"&&o.add(s(i.o.key,n,i.s))&&(t=!0)}return t}},M={name:"prp-eqp1",apply(o,e){let t=!1;for(let r of o.byPredicate(e.equivalentProperty)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.byPredicate(n))o.add({s:i.s,p:a,o:i.o})&&(t=!0)}return t}},G={name:"prp-eqp2",apply(o,e){let t=!1;for(let r of o.byPredicate(e.equivalentProperty)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.byPredicate(a))o.add({s:i.s,p:n,o:i.o})&&(t=!0)}return t}},H={name:"cax-eqc1",apply(o,e){let t=!1;for(let r of o.byPredicate(e.equivalentClass)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.byPredicateObject(e.type,n))o.add(s(i.s,e.type,a))&&(t=!0)}return t}},J={name:"cax-eqc2",apply(o,e){let t=!1;for(let r of o.byPredicate(e.equivalentClass)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.byPredicateObject(e.type,a))o.add(s(i.s,e.type,n))&&(t=!0)}return t}},Q={name:"eq-rep-s",apply(o,e){let t=!1;for(let r of o.byPredicate(e.sameAs)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a){for(let i of o.snapshot())i.s===n&&o.add({s:a,p:i.p,o:i.o})&&(t=!0);for(let i of o.snapshot())i.s===a&&o.add({s:n,p:i.p,o:i.o})&&(t=!0)}}return t}},X={name:"eq-rep-o",apply(o,e){let t=!1;for(let r of o.byPredicate(e.sameAs)){if(r.o.kind!=="uri")continue;let n=r.s,a=r.o.key;if(n!==a)for(let i of o.snapshot())i.o.kind==="uri"&&(i.o.key===n?o.add(s(i.s,i.p,a))&&(t=!0):i.o.key===a&&o.add(s(i.s,i.p,n))&&(t=!0))}return t}},K=[N,D,z,B,M,G,H,J,Q,X];var y=class{constructor(e,t){this.store=e;this.vocabulary=t}store;vocabulary;getInstancesOfClass(e){let t=p(e);return this.store.subjectsWithPredicateObject(this.vocabulary.type,t)}getSubclasses(e){let t=p(e);return this.store.subjectsWithPredicateObject(this.vocabulary.subClassOf,t).filter(n=>n!==t)}getSuperclasses(e){let t=p(e);return this.store.uriObjectsOf(t,this.vocabulary.subClassOf).filter(r=>r!==t)}getTypesOfIndividual(e){return this.store.uriObjectsOf(p(e),this.vocabulary.type)}isInstanceOf(e,t){return this.store.hasUri(p(e),this.vocabulary.type,p(t))}triples(){return this.store.snapshot()}size(){return this.store.size()}};function p(o){return typeof o=="string"?o:u(o.publisher,o.package_,o.name)}var R=class{vocabulary;profile;maxIterations;constructor(e={}){this.vocabulary=e.vocabulary??new h,this.profile=e.profile??"owl-rl-classification",this.maxIterations=e.maxIterations??100}async reason(e){let t=new d,n=await new _().parseKanonaks(e),a=new U;for(let c of n)if(c instanceof S){let m=Y(c);if(!m)continue;for(let E of c.statement)this.emitStatement(m,E,t,a)}let i=[...k];this.profile==="owl-rl-classification"&&i.push(...K);let f=0;for(;f<this.maxIterations;){let c=!1;for(let m of i)m.apply(t,this.vocabulary)&&(c=!0);if(!c)break;f++}return new y(t,this.vocabulary)}emitStatement(e,t,r,n){let a=Z(t);if(a){if(t instanceof I){r.add({s:e,p:a,o:{kind:"literal",lexical:t.object,datatype:"string"}});return}if(t instanceof T){r.add({s:e,p:a,o:{kind:"literal",lexical:String(t.object),datatype:"number"}});return}if(t instanceof g){r.add({s:e,p:a,o:{kind:"literal",lexical:String(t.object),datatype:"boolean"}});return}if(t instanceof v){let i=l(t.object.subject);r.add(s(e,a,i));return}if(t instanceof L){let i=n.next();r.add({s:e,p:a,o:{kind:"blank",id:i}}),this.emitEmbedded(i,t.object,r,n);return}if(t instanceof q){for(let i of t.object??[])this.emitListItem(e,a,i,r,n);return}}}emitListItem(e,t,r,n,a){if(r instanceof O)n.add(s(e,t,l(r.subject)));else if(r instanceof j){let i=a.next();n.add({s:e,p:t,o:{kind:"blank",id:i}}),this.emitEmbedded(i,r,n,a)}else if(r instanceof x){let i=typeof r.value=="number"?"number":typeof r.value=="boolean"?"boolean":"string";n.add({s:e,p:t,o:{kind:"literal",lexical:String(r.value),datatype:i}})}}emitEmbedded(e,t,r,n){let a=`_:${e}`;for(let i of t.statement)this.emitStatement(a,i,r,n)}},U=class{counter=0;next(){return`b${this.counter++}`}};function Y(o){let e=o.namespace??"",t=e.indexOf("@"),r=t===-1?e:e.substring(0,t),n=r.indexOf("/");if(n===-1)return null;let a=r.substring(0,n),i=r.substring(n+1);return!a||!i||!o.name?null:u(a,i,o.name)}function Z(o){let e=o.predicate;return e?.subject?l(e.subject):null}export{d as a,k as b,K as c,y as d,R as e};
@@ -0,0 +1,2 @@
1
+ import{a as y}from"./chunk-SC5M74NM.js";import{a as C}from"./chunk-ORFSMEMM.js";import{c as d,d as k,h as v,i as P}from"./chunk-2ACBWC7K.js";import{VersionOperator as u}from"@kanonak-protocol/types/document/models/enums";var x=class{documents=new Map;documentContents=new Map;parser;constructor(t){this.parser=t}async getAllDocumentsAsync(){return Array.from(this.documents.values())}async getDocumentAsync(t){return this.documents.get(t)??null}async getDocumentsByNamespaceAsync(t,e){let r=[];for(let n of this.documents.values())n.metadata?.namespace_?.publisher===t&&n.metadata?.namespace_?.package_===e&&r.push(n);return r}async getHighestCompatibleVersionAsync(t,e){let r=[];for(let s of this.documents.values())s.metadata?.namespace_?.publisher===t&&s.metadata?.namespace_?.package_===e.packageName&&s.metadata?.namespace_?.version!==void 0&&r.push(s);if(r.length===0)return null;let n=r.filter(s=>{let a=s.metadata.namespace_.version;if(!a)return!1;switch(e.versionOperator){case u.Exact:return k(a,e.version);case u.Compatible:return v(a,e.version);case u.Major:return P(a,e.version);case u.Any:return d(a,e.minVersion)>=0;default:return!1}});return n.length===0?null:(n.sort((s,a)=>{let o=s.metadata.namespace_.version,c=a.metadata.namespace_.version;return!o&&!c?0:o?c?d(c,o):-1:1}),n[0])}async saveDocumentAsync(t,e){this.documents.set(e,t);let r=this.parser.save(t);this.documentContents.set(e,r)}async deleteDocumentAsync(t){this.documents.delete(t),this.documentContents.delete(t)}async clearNamespaceAsync(t,e){let r=[];for(let[n,s]of this.documents.entries())s.metadata?.namespace_?.publisher===t&&s.metadata?.namespace_?.package_===e&&r.push(n);for(let n of r)this.documents.delete(n),this.documentContents.delete(n)}async getAllDocumentReferencesAsync(){let t=[];for(let e of this.documents.values())e.metadata?.namespace_&&t.push({identifier:e.metadata.namespace_.toString(),uri:`kanonak://${e.metadata.namespace_}`,hasParseError:!1});return t}async getDocumentContentAsync(t){let e=this.documentContents.get(t);if(e!==void 0)return e;let r=this.documents.get(t);return r!==void 0?this.parser.save(r):null}async getDocumentUriAsync(t){let e=this.documents.get(t);return e?e.metadata?.namespace_?`kanonak://${e.metadata.namespace_}`:`kanonak://${t}`:null}};var D="https://{publisher}/index.txt",F="https://{publisher}/{package}/{version}.kan.yml",w={version:1};function K(i){return{version:1,index:D.replaceAll("{publisher}",i),package:F.replaceAll("{publisher}",i),auth:"none"}}var g=class{cache=new Map;getConfig(t){let e=this.cache.get(t);return e||(e=this.fetchConfig(t),this.cache.set(t,e),e.catch(()=>{this.cache.get(t)===e&&this.cache.delete(t)})),e}async fetchConfig(t){let e=`https://${t}/.well-known/kanonak.json`,r;try{r=await fetch(e)}catch{return w}if(r.status===404)return w;if(!r.ok)throw new Error(`Failed to fetch publisher config: ${e} (${r.status} ${r.statusText})`);let n=await r.json();if(typeof n.version!="number")throw new Error(`Invalid publisher config at ${e}: missing or invalid "version" field`);let s={version:n.version};return typeof n.index=="string"&&(s.index=n.index),typeof n.package=="string"&&(s.package=n.package),(n.auth==="none"||n.auth==="oauth"||n.auth==="bearer")&&(s.auth=n.auth),Array.isArray(n.render)&&n.render.every(a=>typeof a=="string")&&(s.render=n.render),s}resolveIndexUrl(t,e){let r=e.index??D;return A(r,{publisher:t})}resolvePackageUrl(t,e,r,n){let s=n.package??F;return A(s,{publisher:t,package:e,version:r})}};function A(i,t){let e=i;for(let[n,s]of Object.entries(t))e=e.replaceAll(`{${n}}`,s);let r=e.match(/\{[a-z]+\}/);if(r)throw new Error(`Unresolved variable ${r[0]} in URL template: ${i}`);return e}import{VersionOperator as l}from"@kanonak-protocol/types/document/models/enums";var m=class i{indexCache=new Map;configResolver;fetchFn;constructor(t){this.configResolver=t?.configResolver??new g,this.fetchFn=t?.fetchFn}async resolveVersion(t,e){let r=await this.getPackageVersions(t,e.packageName);if(r.length===0)return null;let n=r.filter(s=>this.isVersionCompatible(s,e.version,e.versionOperator));return n.length===0?null:(n.sort((s,a)=>this.compareVersionStrings(a,s)),n[0])}async getHighestVersion(t,e){let r=await this.getPackageVersions(t,e);return r.length===0?null:[...r].sort((s,a)=>this.compareVersionStrings(a,s))[0]}async listLatestPackages(t){let e=await this.getIndex(t),r=[];for(let[n,s]of e){if(s.length===0)continue;let a=[...s].sort((o,c)=>this.compareVersionStrings(c,o));r.push({packageName:n,version:a[0]})}return r.sort((n,s)=>n.packageName.localeCompare(s.packageName)),r}async getPackageUrl(t,e,r){let n=await this.configResolver.getConfig(t);return this.configResolver.resolvePackageUrl(t,e,r,n)}async getPackageVersions(t,e){return(await this.getIndex(t)).get(e)??[]}getIndex(t){let e=this.indexCache.get(t);return e||(e=this.fetchIndex(t),this.indexCache.set(t,e),e.catch(()=>{this.indexCache.get(t)===e&&this.indexCache.delete(t)})),e}async fetchIndex(t){let e=await this.configResolver.getConfig(t),r=this.configResolver.resolveIndexUrl(t,e),n=this.fetchFn?await this.fetchFn(r,t):await fetch(r);if(!n.ok)throw new Error(`Failed to fetch publisher index: ${r} (${n.status} ${n.statusText})`);let s=await n.text();return i.parseIndex(s)}static parseIndex(t){let e=new Map;for(let r of t.split(`
2
+ `)){let n=r.trim();if(!n||n.startsWith("#"))continue;let s=n.indexOf("/");if(s===-1)continue;let a=n.substring(0,s),o=n.substring(s+1);if(!a||!o)continue;let c=e.get(a);c?c.push(o):e.set(a,[o])}return e}isVersionCompatible(t,e,r){let n=i.parseVersion(t);if(!n)return!1;switch(r){case l.Any:return!0;case l.Exact:return n.major===e.major&&n.minor===e.minor&&n.patch===e.patch;case l.Compatible:return n.major===e.major&&n.minor===e.minor&&n.patch>=e.patch;case l.Major:return n.major!==e.major?!1:n.minor>e.minor?!0:n.minor===e.minor?n.patch>=e.patch:!1;default:return!1}}static parseVersion(t){let e=t.split(".");if(e.length<2)return null;let r=parseInt(e[0],10),n=parseInt(e[1],10),s=e.length>=3?parseInt(e[2],10):0;return isNaN(r)||isNaN(n)||isNaN(s)?null:{major:r,minor:n,patch:s}}compareVersionStrings(t,e){let r=i.parseVersion(t),n=i.parseVersion(e);return!r&&!n?0:r?n?r.major!==n.major?r.major-n.major:r.minor!==n.minor?r.minor-n.minor:r.patch-n.patch:1:-1}};var b=class{parser=new C;publisherIndex;documents=new Map;contentCache=new Map;fetchFn;onFetch;getFromCache;constructor(t){this.onFetch=t?.onFetch,this.getFromCache=t?.getFromCache,this.fetchFn=t?.fetchFn,this.publisherIndex=t?.fetchFn?new m({fetchFn:t.fetchFn}):new m}async getHighestCompatibleVersionAsync(t,e){let r=await this.publisherIndex.resolveVersion(t,e);if(!r)return null;let n=`${t}/${e.packageName}@${r}`,s=this.documents.get(n);if(s)return s;if(this.getFromCache){let p=this.getFromCache(t,e.packageName,r);if(p){let f=this.parser.parse(p);return y(f,t,e.packageName,r),this.documents.set(n,f),this.contentCache.set(n,p),f}}let a=await this.publisherIndex.getPackageUrl(t,e.packageName,r),o=this.fetchFn?await this.fetchFn(a,t):await fetch(a);if(!o.ok)throw new Error(`Failed to fetch Kanonak package: ${a} (${o.status} ${o.statusText})`);let c=await o.text(),h=this.parser.parse(c);return y(h,t,e.packageName,r),this.onFetch&&this.onFetch(t,e.packageName,r,c),this.documents.set(n,h),this.contentCache.set(n,c),h}async getAllDocumentsAsync(){return Array.from(this.documents.values())}async getDocumentAsync(t){return this.documents.get(t)??null}async getDocumentsByNamespaceAsync(t,e){return Array.from(this.documents.values()).filter(r=>{let n=r.metadata.namespace_;return n&&n.publisher===t&&n.package_===e})}async saveDocumentAsync(t,e){throw new Error("HttpKanonakDocumentRepository is read-only")}async deleteDocumentAsync(t){throw new Error("HttpKanonakDocumentRepository is read-only")}async clearNamespaceAsync(t,e){throw new Error("HttpKanonakDocumentRepository is read-only")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(t){return this.contentCache.get(t)??null}async getDocumentUriAsync(t){let e=t.match(/^(.+?)\/(.+?)@(.+)$/);if(!e)return null;let[,r,n,s]=e;return this.publisherIndex.getPackageUrl(r,n,s)}};export{x as a,K as b,g as c,m as d,b as e};
@@ -0,0 +1 @@
1
+ function i(s,n,o,a){let e=s.metadata?.namespace_,t=e?.version,c=t?`${t.major}.${t.minor}.${t.patch}`:void 0;if(!e||e.publisher!==n||e.package_!==o||c!==a){let r=e?`${e.publisher}/${e.package_}@${c??"?"}`:"(no namespace declared)";throw new Error(`Package identity mismatch: requested ${n}/${o}@${a} but the fetched document declares ${r}. Refusing to use it.`)}}export{i as a};
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@ export { GitIgnoreFilter } from './filtering/index.js';
8
8
  export type { IGitIgnoreFilter } from './filtering/index.js';
9
9
  export { KanonakParser, KanonakObjectParser, PropertyMetadata, KanonakDocumentPositions, parseWithPositions, findMarkdownLinkAt, } from './parsing/index.js';
10
10
  export type { IKanonakObjectParser, SourcePosition, ImportPackageEntry, ParsedDocumentWithPositions, } from './parsing/index.js';
11
- export { ResourceResolver, KanonakUri, KanonakUriBuilder, parseKanonakAddress, formatKanonakAddress, KanonakUrlResolver, TypeResolver, ResourceTypeClassifier, findInstancesByType, compareVersions, versionsEqual, formatVersion, parseVersionString, createVersion, isCompatibleVersion, isMajorCompatible, pickHighestDocument, propertiesInScope, resolvePropertyStep, contextTypesOf, subjectUri, } from './resolution/index.js';
11
+ export { ResourceResolver, KanonakUri, KanonakUriBuilder, parseKanonakAddress, formatKanonakAddress, KanonakUrlResolver, TypeResolver, ResourceTypeClassifier, findInstancesByType, compareVersions, versionsEqual, formatVersion, parseVersionString, createVersion, isCompatibleVersion, isMajorCompatible, pickHighestDocument, versionOperatorFromChar, versionOperatorToChar, propertiesInScope, resolvePropertyStep, contextTypesOf, subjectUri, assertPackageIdentity, } from './resolution/index.js';
12
12
  export type { ResourceResolutionResult, ILogger, InstanceSearchResult, DocumentVersionPick, PropertyDescriptor, PropertyKind, StepResolution, KanonakAddress, UrlAddress, PublisherUrlAddress, PackageUrlAddress, ResourceUrlAddress, VersionSpec, UrlForm, } from './resolution/index.js';
13
13
  export { Kanonak, DefinedKanonak, SubjectKanonak, EmbeddedKanonak, ReferenceKanonak, LiteralKanonak } from './kanonaks/index.js';
14
14
  export type { IStatement } from './statements/index.js';
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
- import{a as ct,b as lt,c as dt,d as ut,e as pt}from"./chunk-SD5QKNBC.js";import{a as or,c as ar}from"./chunk-ESYVKB25.js";import{a as at,b as it,c as st,d as b,e as S,f as i}from"./chunk-WDQONH3P.js";import{a as nr}from"./chunk-IIODYDKS.js";import"./chunk-3NEUHF7E.js";import{a as Te,b as je,c as Le,d as Fe,e as De,f as Ue,g as Ve,h as He}from"./chunk-MYPKSBTP.js";import{a as Ie,c as Ne,d as Oe,e as Ae}from"./chunk-6SGRDFL5.js";import{a as ft,b as yt,c as gt,d as ht}from"./chunk-CYDDQF6S.js";import{a as kt,b as $t}from"./chunk-DC774EQL.js";import{a as Ct}from"./chunk-NIGFQYVA.js";import{A as Qt,B as er,C as tr,E as rr,a as vt,b as Et,c as Kt,d as It,e as Bt,f as Tt,g as jt,h as Lt,i as Ft,j as Dt,k as Nt,l as Ot,m as At,n as Ut,o as Vt,p as Ht,q as Mt,r as _t,s as zt,t as Gt,u as Wt,v as Jt,w as qt,x as Yt,y as Xt,z as Zt}from"./chunk-BSJ6PEKE.js";import{a as tt,b as rt,c as nt}from"./chunk-VJT6YUWK.js";import{a as F,b as N,c as We}from"./chunk-H2LEQLVD.js";import{a as Be}from"./chunk-7CUTGGH3.js";import{a as ot,b as bt,c as St,d as Pt,e as Rt,f as wt,g as xt}from"./chunk-N224PFBI.js";import"./chunk-Q4DKP5DO.js";import{a as Pe,b as Re,c as we,d as xe,e as $e,f as ve,g as Ee,h as Ke}from"./chunk-FQHALFRR.js";import{b as Je,c as qe,d as Ye,e as Xe,f as Ze,h as Qe,j as et}from"./chunk-64TVBQFR.js";import{a as Me,b as j,c as L,d as D,e as ze,f as Ge,g as O,h as A,i as U,j as V,k as H,l as M}from"./chunk-W6T7MOKY.js";import{a as _e}from"./chunk-FUUTGGJS.js";import{a as mt}from"./chunk-ODIECDN7.js";import{VersionOperator as yo}from"@kanonak-protocol/types/document/models/enums";import{existsSync as Rr,readFileSync as wr}from"fs";import{homedir as xr}from"os";import{join as $r}from"path";import{execFile as ir}from"child_process";import{promisify as sr}from"util";var C=sr(ir),P="kanonak",R="/usr/bin/security",p=class{async get(e){let r=i(e);try{let{stdout:n}=await C(R,["find-generic-password","-s",P,"-a",r,"-w"],{timeout:1e4});try{return JSON.parse(n.trim())}catch{throw new Error(`Stored credential for '${r}' is corrupted (not valid JSON).
1
+ import{a as ut,b as pt,c as mt,d as ft,e as yt}from"./chunk-QHJ6EY3Y.js";import{a as sr,c as cr}from"./chunk-JYUZT2JU.js";import{a as ct,b as lt,c as dt,d as b,e as S,f as i}from"./chunk-KSTGTV35.js";import{a as ir}from"./chunk-IUCHSPLQ.js";import"./chunk-3NEUHF7E.js";import{a as Le,b as Fe,c as De,d as Ne,e as Oe,f as Me,g as _e,h as ze}from"./chunk-CA2EATJR.js";import{a as Te,c as Ae,d as Ue,e as He}from"./chunk-RSIZQAFL.js";import{a as ht,b as kt,c as bt,d as St}from"./chunk-7JZUJ2K4.js";import{a as Ct,b as Kt}from"./chunk-PEUTCG3B.js";import{a as wt}from"./chunk-NIGFQYVA.js";import{a as Ve}from"./chunk-SC5M74NM.js";import{A as rr,B as nr,C as or,E as ar,a as It,b as Bt,c as Tt,d as jt,e as Lt,f as Ft,g as Dt,h as Nt,i as Ot,j as At,k as Ut,l as Vt,m as Ht,n as Mt,o as _t,p as zt,q as Gt,r as Wt,s as Jt,t as qt,u as Yt,v as Xt,w as Zt,x as Qt,y as er,z as tr}from"./chunk-OIVACCMQ.js";import{a as ot,b as at,c as it}from"./chunk-Q6QTQWR2.js";import{a as F,b as N,c as Ye}from"./chunk-H2LEQLVD.js";import{a as je}from"./chunk-ORFSMEMM.js";import{a as st,b as Pt,c as Rt,d as xt,e as vt,f as $t,g as Et}from"./chunk-N224PFBI.js";import"./chunk-Q4DKP5DO.js";import{b as Xe,c as Ze,d as Qe,e as et,f as tt,h as rt,j as nt}from"./chunk-64TVBQFR.js";import{a as Ge,b as j,c as L,d as D,e as Je,f as qe,g as O,h as A,i as U,j as V,k as H,l as M}from"./chunk-W6T7MOKY.js";import{a as We}from"./chunk-FUUTGGJS.js";import{a as Pe,b as Re,c as we,d as xe,e as ve,f as $e,g as Ee,h as Ke,i as Ie,j as Be}from"./chunk-2ACBWC7K.js";import{a as gt}from"./chunk-ODIECDN7.js";import{VersionOperator as ko}from"@kanonak-protocol/types/document/models/enums";import{existsSync as vr,readFileSync as $r}from"fs";import{homedir as Er}from"os";import{join as Kr}from"path";import{execFile as lr}from"child_process";import{promisify as dr}from"util";var C=dr(lr),P="kanonak",R="/usr/bin/security",p=class{async get(e){let r=i(e);try{let{stdout:n}=await C(R,["find-generic-password","-s",P,"-a",r,"-w"],{timeout:1e4});try{return JSON.parse(n.trim())}catch{throw new Error(`Stored credential for '${r}' is corrupted (not valid JSON).
2
2
  Run 'kanonak logout ${r}' then 'kanonak login ${r}' to fix.`)}}catch(n){if(X(n,44))return null;throw new Error(`macOS Keychain read failed for '${r}': ${w(n)}
3
3
  The Keychain may be locked or inaccessible.
4
4
  Try unlocking it via Keychain Access.app or running 'security unlock-keychain'.`)}}async store(e,r){let n=i(e),o=JSON.stringify(r);try{await C(R,["add-generic-password","-s",P,"-a",n,"-U","-w",o],{timeout:1e4})}catch(a){throw new Error(`macOS Keychain write failed for '${n}': ${w(a)}
5
5
  Ensure the Keychain is unlocked and the CLI has write permission.
6
6
  On managed devices, your IT policy may block credential storage.`)}}async remove(e){let r=i(e);try{await C(R,["delete-generic-password","-s",P,"-a",r],{timeout:1e4})}catch(n){if(X(n,44))return;console.warn(` Warning: macOS Keychain delete failed for '${r}': ${w(n)}
7
7
  The credential may not have been fully removed.`)}}async list(){try{let{stdout:e}=await C(R,["dump-keychain"],{timeout:1e4}),r=[],n=!1;for(let o of e.split(`
8
- `))if(o.includes(`"svce"<blob>="${P}"`)&&(n=!0),n&&o.includes('"acct"<blob>=')){let a=o.match(/"acct"<blob>="([^"]+)"/);a&&r.push(a[1]),n=!1}return r}catch(e){return console.warn(` Warning: Could not enumerate Keychain entries: ${w(e)}`),[]}}};function X(t,e){return typeof t=="object"&&t!==null&&"code"in t&&t.code===e}function w(t){return t instanceof Error?t.message:String(t)}import{execFile as cr}from"child_process";import{promisify as lr}from"util";var dr=lr(cr),x="kanonak:",m=class{async get(e){let r=x+i(e),n=`
9
- ${v}
8
+ `))if(o.includes(`"svce"<blob>="${P}"`)&&(n=!0),n&&o.includes('"acct"<blob>=')){let a=o.match(/"acct"<blob>="([^"]+)"/);a&&r.push(a[1]),n=!1}return r}catch(e){return console.warn(` Warning: Could not enumerate Keychain entries: ${w(e)}`),[]}}};function X(t,e){return typeof t=="object"&&t!==null&&"code"in t&&t.code===e}function w(t){return t instanceof Error?t.message:String(t)}import{execFile as ur}from"child_process";import{promisify as pr}from"util";var mr=pr(ur),x="kanonak:",m=class{async get(e){let r=x+i(e),n=`
9
+ ${$}
10
10
  $target = [Console]::In.ReadLine()
11
11
  $ptr = [IntPtr]::Zero
12
12
  $result = [CredMan]::CredRead($target, 1, 0, [ref]$ptr)
@@ -18,8 +18,8 @@ try {
18
18
  [System.Text.Encoding]::Unicode.GetString($bytes)
19
19
  } finally {
20
20
  [CredMan]::CredFree($ptr)
21
- }`;try{let{stdout:o}=await $(n,r),a=o.trim();return a?JSON.parse(a):null}catch{return null}}async store(e,r){let n=x+i(e),o=JSON.stringify(r),a=`
22
- ${v}
21
+ }`;try{let{stdout:o}=await v(n,r),a=o.trim();return a?JSON.parse(a):null}catch{return null}}async store(e,r){let n=x+i(e),o=JSON.stringify(r),a=`
22
+ ${$}
23
23
  $target = [Console]::In.ReadLine()
24
24
  $json = [Console]::In.ReadLine()
25
25
  $bytes = [System.Text.Encoding]::Unicode.GetBytes($json)
@@ -35,13 +35,13 @@ try {
35
35
  if (-not $result) { throw "CredWrite failed" }
36
36
  } finally {
37
37
  [System.Runtime.InteropServices.Marshal]::FreeHGlobal($cred.CredentialBlob)
38
- }`;try{await $(a,`${n}
38
+ }`;try{await v(a,`${n}
39
39
  ${o}`)}catch(s){throw new Error(`Windows Credential Manager write failed: ${String(s)}`)}}async remove(e){let r=x+i(e),n=`
40
- ${v}
40
+ ${$}
41
41
  $target = [Console]::In.ReadLine()
42
- [CredMan]::CredDelete($target, 1, 0) | Out-Null`;try{await $(n,r)}catch{}}async list(){let e=`
43
- ${v}
44
- ${ur}
42
+ [CredMan]::CredDelete($target, 1, 0) | Out-Null`;try{await v(n,r)}catch{}}async list(){let e=`
43
+ ${$}
44
+ ${fr}
45
45
  $prefix = [Console]::In.ReadLine()
46
46
  $count = 0
47
47
  $pCreds = [IntPtr]::Zero
@@ -55,8 +55,8 @@ if ([CredMan]::CredEnumerate($null, 0, [ref]$count, [ref]$pCreds)) {
55
55
  }
56
56
  }
57
57
  [CredMan]::CredFree($pCreds)
58
- }`;try{let{stdout:r}=await $(e,x);return r.trim().split(`
59
- `).map(n=>n.trim()).filter(Boolean)}catch{return[]}}};async function $(t,e){for(let r of["pwsh","powershell"])try{return await dr(r,["-NoProfile","-NonInteractive","-Command",t],{timeout:15e3,...e!==void 0&&{input:e}})}catch(n){if(r==="powershell")throw n}throw new Error("Neither pwsh nor powershell found")}var v=`
58
+ }`;try{let{stdout:r}=await v(e,x);return r.trim().split(`
59
+ `).map(n=>n.trim()).filter(Boolean)}catch{return[]}}};async function v(t,e){for(let r of["pwsh","powershell"])try{return await mr(r,["-NoProfile","-NonInteractive","-Command",t],{timeout:15e3,...e!==void 0&&{input:e}})}catch(n){if(r==="powershell")throw n}throw new Error("Neither pwsh nor powershell found")}var $=`
60
60
  Add-Type -TypeDefinition @"
61
61
  using System;
62
62
  using System.Runtime.InteropServices;
@@ -87,13 +87,13 @@ public class CredMan {
87
87
  [DllImport("Advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
88
88
  public static extern bool CredEnumerate(string filter, int flags, out int count, out IntPtr credentials);
89
89
  }
90
- "@`,ur="";import{execFile as pr,spawn as mr}from"child_process";import{promisify as fr}from"util";var K=fr(pr),E="kanonak",f=class{async get(e){let r=i(e);try{let{stdout:n}=await K("secret-tool",["lookup","service",E,"publisher",r],{timeout:1e4}),o=n.trim();return o?JSON.parse(o):null}catch{return null}}async store(e,r){let n=i(e),o=JSON.stringify(r);await new Promise((a,s)=>{let c=mr("secret-tool",["store","--label",`Kanonak: ${n}`,"service",E,"publisher",n],{stdio:["pipe","ignore","ignore"],timeout:1e4});c.stdin.write(o),c.stdin.end(),c.on("close",l=>{l===0?a():s(new Error(`secret-tool store exited with code ${l}`))}),c.on("error",s)})}async remove(e){let r=i(e);try{await K("secret-tool",["clear","service",E,"publisher",r],{timeout:1e4})}catch{}}async list(){try{let{stdout:e}=await K("secret-tool",["search","service",E],{timeout:1e4}),r=[];for(let n of e.split(`
91
- `)){let o=n.match(/attribute\.publisher\s*=\s*(.+)/);o&&r.push(o[1].trim())}return r}catch{return[]}}};async function _(){try{return await K("sh",["-c","command -v secret-tool"],{timeout:5e3}),!0}catch{return!1}}import{existsSync as Z,mkdirSync as Q,readFileSync as ee,writeFileSync as te}from"fs";import{createCipheriv as yr,createDecipheriv as gr,randomBytes as re}from"crypto";import{homedir as hr}from"os";import{join as W,dirname as ne}from"path";var ae=W(hr(),".config","kanonak"),y=W(ae,"keyring.key"),I=W(ae,"credentials.enc"),oe="aes-256-gcm",z=32,u=12,G=16,g=class{async get(e){let r=this.loadStore(),n=i(e);return r[n]??null}async store(e,r){let n=this.loadStore(),o=i(e);n[o]=r,this.saveStore(n)}async remove(e){let r=this.loadStore(),n=i(e);delete r[n],this.saveStore(r)}async list(){let e=this.loadStore();return Object.keys(e)}loadStore(){if(!Z(I))return{};try{let e=this.getOrCreateKey(),r=ee(I);if(r.length<u+G)return{};let n=r.subarray(0,u),o=r.subarray(u,u+G),a=r.subarray(u+G),s=gr(oe,e,n);s.setAuthTag(o);let c=Buffer.concat([s.update(a),s.final()]);return JSON.parse(c.toString("utf-8"))}catch{return{}}}saveStore(e){let r=this.getOrCreateKey(),n=re(u),o=yr(oe,r,n),a=Buffer.from(JSON.stringify(e),"utf-8"),s=Buffer.concat([o.update(a),o.final()]),c=o.getAuthTag(),l=Buffer.concat([n,c,s]);Q(ne(I),{recursive:!0}),te(I,l,{mode:384})}getOrCreateKey(){if(Z(y)){let r=ee(y);if(r.length!==z)throw new Error(`Credential keyring key is corrupted (expected ${z} bytes, got ${r.length}). Delete ${y} and re-authenticate.`);return r}let e=re(z);return Q(ne(y),{recursive:!0}),te(y,e,{mode:384}),e}};import{execFile as kr}from"child_process";import{promisify as br}from"util";var Sr=br(kr),ie=3e4,h=class{constructor(e){this.helperPath=e}helperPath;async get(e){let r=i(e);try{let o=(await this.runHelper("get",{publisher:r})).trim();return o?JSON.parse(o):null}catch(n){throw new Error(`Credential helper '${this.helperPath}' failed to read credential for '${r}': ${B(n)}
90
+ "@`,fr="";import{execFile as yr,spawn as gr}from"child_process";import{promisify as hr}from"util";var K=hr(yr),E="kanonak",f=class{async get(e){let r=i(e);try{let{stdout:n}=await K("secret-tool",["lookup","service",E,"publisher",r],{timeout:1e4}),o=n.trim();return o?JSON.parse(o):null}catch{return null}}async store(e,r){let n=i(e),o=JSON.stringify(r);await new Promise((a,s)=>{let c=gr("secret-tool",["store","--label",`Kanonak: ${n}`,"service",E,"publisher",n],{stdio:["pipe","ignore","ignore"],timeout:1e4});c.stdin.write(o),c.stdin.end(),c.on("close",l=>{l===0?a():s(new Error(`secret-tool store exited with code ${l}`))}),c.on("error",s)})}async remove(e){let r=i(e);try{await K("secret-tool",["clear","service",E,"publisher",r],{timeout:1e4})}catch{}}async list(){try{let{stdout:e}=await K("secret-tool",["search","service",E],{timeout:1e4}),r=[];for(let n of e.split(`
91
+ `)){let o=n.match(/attribute\.publisher\s*=\s*(.+)/);o&&r.push(o[1].trim())}return r}catch{return[]}}};async function _(){try{return await K("sh",["-c","command -v secret-tool"],{timeout:5e3}),!0}catch{return!1}}import{existsSync as Z,mkdirSync as Q,readFileSync as ee,writeFileSync as te}from"fs";import{createCipheriv as kr,createDecipheriv as br,randomBytes as re}from"crypto";import{homedir as Sr}from"os";import{join as W,dirname as ne}from"path";var ae=W(Sr(),".config","kanonak"),y=W(ae,"keyring.key"),I=W(ae,"credentials.enc"),oe="aes-256-gcm",z=32,u=12,G=16,g=class{async get(e){let r=this.loadStore(),n=i(e);return r[n]??null}async store(e,r){let n=this.loadStore(),o=i(e);n[o]=r,this.saveStore(n)}async remove(e){let r=this.loadStore(),n=i(e);delete r[n],this.saveStore(r)}async list(){let e=this.loadStore();return Object.keys(e)}loadStore(){if(!Z(I))return{};try{let e=this.getOrCreateKey(),r=ee(I);if(r.length<u+G)return{};let n=r.subarray(0,u),o=r.subarray(u,u+G),a=r.subarray(u+G),s=br(oe,e,n);s.setAuthTag(o);let c=Buffer.concat([s.update(a),s.final()]);return JSON.parse(c.toString("utf-8"))}catch{return{}}}saveStore(e){let r=this.getOrCreateKey(),n=re(u),o=kr(oe,r,n),a=Buffer.from(JSON.stringify(e),"utf-8"),s=Buffer.concat([o.update(a),o.final()]),c=o.getAuthTag(),l=Buffer.concat([n,c,s]);Q(ne(I),{recursive:!0}),te(I,l,{mode:384})}getOrCreateKey(){if(Z(y)){let r=ee(y);if(r.length!==z)throw new Error(`Credential keyring key is corrupted (expected ${z} bytes, got ${r.length}). Delete ${y} and re-authenticate.`);return r}let e=re(z);return Q(ne(y),{recursive:!0}),te(y,e,{mode:384}),e}};import{execFile as Cr}from"child_process";import{promisify as Pr}from"util";var Rr=Pr(Cr),ie=3e4,h=class{constructor(e){this.helperPath=e}helperPath;async get(e){let r=i(e);try{let o=(await this.runHelper("get",{publisher:r})).trim();return o?JSON.parse(o):null}catch(n){throw new Error(`Credential helper '${this.helperPath}' failed to read credential for '${r}': ${B(n)}
92
92
  Verify the helper binary exists, is executable, and implements the Kanonak credential helper protocol.
93
93
  Check the 'credentialHelper' path in ~/.kanonak/config.json.`)}}async store(e,r){let n=i(e);try{await this.runHelper("store",{publisher:n,credential:r})}catch(o){throw new Error(`Credential helper '${this.helperPath}' failed to store credential for '${n}': ${B(o)}
94
- Verify the helper binary supports the 'store' action.`)}}async remove(e){let r=i(e);try{await this.runHelper("erase",{publisher:r})}catch(n){console.warn(` Warning: Credential helper '${this.helperPath}' failed to erase credential for '${r}': ${B(n)}`)}}async list(){try{let e=await this.runHelper("list",void 0);return JSON.parse(e.trim())}catch(e){return console.warn(` Warning: Credential helper '${this.helperPath}' failed to list credentials: ${B(e)}`),[]}}async runHelper(e,r){try{let{stdout:n}=await Sr(this.helperPath,[e],{...r&&{input:JSON.stringify(r)},timeout:ie});return n}catch(n){throw Cr(n)?new Error(`Credential helper not found at '${this.helperPath}'.
95
- Check the 'credentialHelper' path in ~/.kanonak/config.json.`):Pr(n)?new Error(`Credential helper '${this.helperPath}' timed out after ${ie/1e3}s on '${e}'.
96
- The helper may be waiting for authentication to an external vault.`):n}}};function B(t){return t instanceof Error?t.message:String(t)}function Cr(t){return t instanceof Error&&"code"in t&&t.code==="ENOENT"}function Pr(t){return t instanceof Error&&"killed"in t&&t.killed}var J=$r(xr(),".kanonak","config.json"),T=class{backend=null;backendReady=null;async getBackend(){if(this.backend)return this.backend;if(this.backendReady)return this.backendReady;this.backendReady=this.resolveBackend();try{return this.backend=await this.backendReady,this.backend}catch(e){throw this.backendReady=null,e}}async getToken(e){let r=vr(e);if(r)return r;let o=await(await this.getBackend()).get(e);return!o||!S(o)?null:o.accessToken??null}async getCredential(e){return(await this.getBackend()).get(e)}async store(e,r){return(await this.getBackend()).store(e,r)}async remove(e){return(await this.getBackend()).remove(e)}async list(){return(await this.getBackend()).list()}async resolveBackend(){let e=Er();return e.credentialHelper?new h(e.credentialHelper):process.platform==="darwin"?new p:process.platform==="win32"?new m:await _()?new f:new g}};function vr(t){let r="KANONAK_TOKEN_"+i(t).replace(/[.\-]/g,"_").toUpperCase();return process.env[r]??null}function Er(){if(!Rr(J))return{};try{return JSON.parse(wr(J,"utf-8"))}catch(t){let e=t instanceof Error?t.message:String(t);return console.warn(` Warning: Failed to parse ${J}: ${e}
97
- Using default credential backend. Fix the JSON syntax or delete the file.`),{}}}import{createHash as Kr,createPrivateKey as Ir,generateKeyPairSync as Br,randomUUID as Tr,sign as jr}from"crypto";function ce(){let{publicKey:t,privateKey:e}=Br("ec",{namedCurve:"P-256"});return{publicKey:t.export({format:"jwk"}),privateKey:e.export({format:"jwk"})}}function k(t,e,r,n,o,a){let s={alg:"ES256",typ:"dpop+jwt",jwk:{kty:e.kty,crv:e.crv,x:e.x,y:e.y}},c={jti:Tr(),htm:r.toUpperCase(),htu:n,iat:Math.floor(Date.now()/1e3)};return o&&(c.ath=Kr("sha256").update(o).digest("base64url")),a&&(c.nonce=a),Lr(s,c,t)}function le(t){return!t||t.length===0?!1:t.some(e=>e.toUpperCase()==="ES256")}function Lr(t,e,r){let n=se(JSON.stringify(t)),o=se(JSON.stringify(e)),a=`${n}.${o}`,s=Ir({key:r,format:"jwk"}),l=jr("SHA256",Buffer.from(a),{key:s,dsaEncoding:"ieee-p1363"}).toString("base64url");return`${a}.${l}`}function se(t){return Buffer.from(t,"utf-8").toString("base64url")}function de(t){let e=new Map;return async(r,n,o="GET")=>{if(!t)return fetch(r,{method:o});let a=await t.getCredential(n);if(!a?.accessToken)return fetch(r,{method:o});b(a)&&console.warn(` Warning: Access token for '${n}' is expired. Run 'kanonak login ${n}' to re-authenticate.`);let s={};if(a.dpopKeyPair){let l=e.get(n);try{let d=k(a.dpopKeyPair.privateKey,a.dpopKeyPair.publicKey,o,r,a.accessToken,l);s.Authorization=`DPoP ${a.accessToken}`,s.DPoP=d}catch(d){let Ce=d instanceof Error?d.message:String(d);console.error(` Error: Failed to create DPoP proof for '${n}': ${Ce}
98
- The stored key pair may be corrupted. Run 'kanonak login ${n}' to re-authenticate.`),s.Authorization=`Bearer ${a.accessToken}`}}else s.Authorization=`Bearer ${a.accessToken}`;let c=await fetch(r,{method:o,headers:s});if(c.status===401&&a.dpopKeyPair){let l=c.headers.get("DPoP-Nonce");if(l){e.set(n,l);try{let d=k(a.dpopKeyPair.privateKey,a.dpopKeyPair.publicKey,o,r,a.accessToken,l);s.DPoP=d,c=await fetch(r,{method:o,headers:s})}catch{}}}return c}}import{readFileSync as Fr,writeFileSync as Dr,existsSync as Nr}from"fs";import{createHash as Or}from"crypto";import ue from"js-yaml";var pe="kanonak.lock",Ar=`# This file is generated by Kanonak CLI. Do not edit manually.
99
- `;function me(t=pe){if(!Nr(t))return null;let e=Fr(t,"utf-8"),r=ue.load(e);return!r||typeof r!="object"||r.version!=="1"?null:{version:"1",lastUpdated:r.lastUpdated??new Date().toISOString(),packages:r.packages??{}}}function fe(t,e=pe){t.lastUpdated=new Date().toISOString();let r={};for(let o of Object.keys(t.packages).sort())r[o]=t.packages[o];t.packages=r;let n=ue.dump(t,{lineWidth:-1,sortKeys:!1,quotingType:'"'});Dr(e,Ar+n,"utf-8")}function ye(t){return`sha256:${Or("sha256").update(t).digest("hex")}`}import{createHash as Ur}from"crypto";function q(t){let e=[];for(let n of t)n instanceof L&&e.push(Vr(n));return e.sort((n,o)=>n.uri<o.uri?-1:n.uri>o.uri?1:0),JSON.stringify({subjects:e})}function ge(t){let e=q(t);return`sha256:${Ur("sha256").update(e,"utf8").digest("hex")}`}function Vr(t){let e=Wr(t),r=Y(t.statement);return{uri:e,statements:r}}function Y(t){let e=[];for(let r of t){let n=Hr(r);n&&e.push(n)}return e.sort((r,n)=>r.predicate<n.predicate?-1:r.predicate>n.predicate?1:0),e}function Hr(t){let e=Gr(t);if(!e)return;let r=Mr(t);if(r)return zr(e,r)}function Mr(t){if(t instanceof O)return{type:"string",value:t.object};if(t instanceof A)return{type:"number",value:Se(t.object)};if(t instanceof U)return{type:"boolean",value:t.object};if(t instanceof V)return{type:"ref",value:ke(t.object)};if(t instanceof H){let e=t.object;return he(e)}if(t instanceof M)return{type:"list",items:t.object.map(_r)}}function he(t){let e=Y(t.statement);return t.name&&t.name.length>0?{type:"embedded",name:t.name,statements:e}:{type:"embedded",statements:e}}function _r(t){if(t instanceof D)return{type:"ref",value:ke(t)};if(t instanceof F)return he(t);if(t instanceof N){let e=t.value;if(typeof e=="string")return{type:"string",value:e};if(typeof e=="number")return{type:"number",value:Se(e)};if(typeof e=="boolean")return{type:"boolean",value:e}}if(t instanceof j)return{type:"embedded",statements:Y(t.statement)};throw new Error(`canonicalForm: list item of unrecognized kind (${t.constructor?.name??typeof t}); add canonicalization support before hashing data that contains it`)}function zr(t,e){switch(e.type){case"string":return{predicate:t,type:"string",value:e.value};case"number":return{predicate:t,type:"number",value:e.value};case"boolean":return{predicate:t,type:"boolean",value:e.value};case"ref":return{predicate:t,type:"ref",value:e.value};case"embedded":return e.name!==void 0?{predicate:t,type:"embedded",name:e.name,statements:e.statements}:{predicate:t,type:"embedded",statements:e.statements};case"list":return{predicate:t,type:"list",items:e.items}}}function Gr(t){let e=t.predicate;if(e)return be(e.subject)}function Wr(t){let e=t.namespace??"",r=t.name??"";return`${e}/${r}`}function ke(t){return be(t.subject)}function be(t){let e=t.version;return e&&typeof e.major=="number"?`${t.publisher}/${t.package_}@${e.major}.${e.minor}.${e.patch}/${t.name}`:`${t.publisher}/${t.package_}/${t.name}`}function Se(t){if(Number.isNaN(t))throw new Error("canonicalForm: NaN cannot be canonicalized");if(!Number.isFinite(t))throw new Error("canonicalForm: \xB1Infinity cannot be canonicalized");return Object.is(t,-0)?"0":String(t)}export{Jt as AmbiguousReferenceRule,U as BooleanStatement,er as ClassDefinitionRule,At as ClassHierarchyCycleRule,Le as CompositeKanonakDocumentRepository,T as CredentialStore,j as DefinedKanonak,Gt as DefinitionPropertyReferenceRule,je as DocumentLocation,it as EdgeType,F as EmbeddedKanonak,Dt as EmbeddedKanonakTypeRule,H as EmbeddedStatement,Te as FileSystemKanonakDocumentRepository,mt as GitIgnoreFilter,st as GraphBuilder,Ae as HttpKanonakDocumentRepository,Nt as ImportExistenceRule,Ie as InMemoryKanonakDocumentRepository,zt as InstancePropertyReferenceRule,Me as Kanonak,yt as KanonakDocumentPositions,nt as KanonakObjectParser,rr as KanonakObjectValidator,Be as KanonakParser,_e as KanonakUri,kt as KanonakUriBuilder,Ct as KanonakUrlResolver,et as KanonakVocabulary,M as ListStatement,N as LiteralKanonak,Ue as LocalFirstRepository,ar as LookRenderer,tr as MarkdownLinkRule,We as MarkdownStatement,_t as NamespaceImportCycleRule,Tt as NamespacePrefixRule,at as NodeType,A as NumberStatement,dt as OWL_RL_CLASSIFICATION_RULES,Yt as ObjectPropertyImportRule,Xt as ObjectPropertyValueValidationRule,Kt as OntologyValidationError,vt as OntologyValidationResult,Zt as PropertyDomainRule,Ut as PropertyHierarchyCycleRule,ft as PropertyMetadata,qt as PropertyRangeReferenceRule,Vt as PropertyRangeRequiredRule,Lt as PropertyTypeSpecificityRule,Qt as PropertyValueTypeRule,Ne as PublisherConfigResolver,Oe as PublisherIndex,lt as RDFS_RULES,pt as Reasoner,ut as ReasoningResult,D as ReferenceKanonak,V as ReferenceStatement,De as RepositoryFactory,jt as ResourceNamingRule,Je as ResourceResolver,ot as ResourceTypeClassifier,Ge as ScalarStatement,ze as Statement,O as StringStatement,Ht as SubClassOfReferenceRule,Mt as SubPropertyOfReferenceRule,L as SubjectKanonak,Ft as SubjectKanonakTypeRequiredRule,ct as TripleStore,qe as TypeResolver,Ot as UnresolvedReferenceRule,Bt as ValidationCache,It as ValidationContext,Et as ValidationSeverity,yo as VersionOperator,Wt as XsdImportRule,He as buildLocalFirstRepository,q as canonicalForm,ge as canonicalHash,Ve as collectKanonakFiles,Pe as compareVersions,ye as computeIntegrity,xt as contextTypesOf,de as createAuthenticatedFetch,k as createDPoPProof,xe as createVersion,rt as extractMarkdownLinks,nr as findDerivation,$t as findInstancesByType,tt as findMalformedReferences,ht as findMarkdownLinkAt,St as formatKanonakAddress,we as formatVersion,ce as generateDPoPKeyPair,Fe as getGlobalCachePath,S as hasValidToken,ve as isCompatibleVersion,b as isExpired,Ee as isMajorCompatible,me as loadLockFile,Xe as makeUriKey,i as normalizeHost,bt as parseKanonakAddress,$e as parseVersionString,gt as parseWithPositions,Ke as pickHighestDocument,Rt as propertiesInScope,or as resolveDisplayValue,wt as resolvePropertyStep,fe as saveLockFile,le as serverSupportsDPoP,Pt as subjectUri,Ze as tripleKey,Ye as uriKey,Qe as uriTriple,Re as versionsEqual};
94
+ Verify the helper binary supports the 'store' action.`)}}async remove(e){let r=i(e);try{await this.runHelper("erase",{publisher:r})}catch(n){console.warn(` Warning: Credential helper '${this.helperPath}' failed to erase credential for '${r}': ${B(n)}`)}}async list(){try{let e=await this.runHelper("list",void 0);return JSON.parse(e.trim())}catch(e){return console.warn(` Warning: Credential helper '${this.helperPath}' failed to list credentials: ${B(e)}`),[]}}async runHelper(e,r){try{let{stdout:n}=await Rr(this.helperPath,[e],{...r&&{input:JSON.stringify(r)},timeout:ie});return n}catch(n){throw wr(n)?new Error(`Credential helper not found at '${this.helperPath}'.
95
+ Check the 'credentialHelper' path in ~/.kanonak/config.json.`):xr(n)?new Error(`Credential helper '${this.helperPath}' timed out after ${ie/1e3}s on '${e}'.
96
+ The helper may be waiting for authentication to an external vault.`):n}}};function B(t){return t instanceof Error?t.message:String(t)}function wr(t){return t instanceof Error&&"code"in t&&t.code==="ENOENT"}function xr(t){return t instanceof Error&&"killed"in t&&t.killed}var J=Kr(Er(),".kanonak","config.json"),T=class{backend=null;backendReady=null;async getBackend(){if(this.backend)return this.backend;if(this.backendReady)return this.backendReady;this.backendReady=this.resolveBackend();try{return this.backend=await this.backendReady,this.backend}catch(e){throw this.backendReady=null,e}}async getToken(e){let r=Ir(e);if(r)return r;let o=await(await this.getBackend()).get(e);return!o||!S(o)?null:o.accessToken??null}async getCredential(e){return(await this.getBackend()).get(e)}async store(e,r){return(await this.getBackend()).store(e,r)}async remove(e){return(await this.getBackend()).remove(e)}async list(){return(await this.getBackend()).list()}async resolveBackend(){let e=Br();return e.credentialHelper?new h(e.credentialHelper):process.platform==="darwin"?new p:process.platform==="win32"?new m:await _()?new f:new g}};function Ir(t){let r="KANONAK_TOKEN_"+i(t).replace(/[.\-]/g,"_").toUpperCase();return process.env[r]??null}function Br(){if(!vr(J))return{};try{return JSON.parse($r(J,"utf-8"))}catch(t){let e=t instanceof Error?t.message:String(t);return console.warn(` Warning: Failed to parse ${J}: ${e}
97
+ Using default credential backend. Fix the JSON syntax or delete the file.`),{}}}import{createHash as Tr,createPrivateKey as jr,generateKeyPairSync as Lr,randomUUID as Fr,sign as Dr}from"crypto";function ce(){let{publicKey:t,privateKey:e}=Lr("ec",{namedCurve:"P-256"});return{publicKey:t.export({format:"jwk"}),privateKey:e.export({format:"jwk"})}}function k(t,e,r,n,o,a){let s={alg:"ES256",typ:"dpop+jwt",jwk:{kty:e.kty,crv:e.crv,x:e.x,y:e.y}},c={jti:Fr(),htm:r.toUpperCase(),htu:n,iat:Math.floor(Date.now()/1e3)};return o&&(c.ath=Tr("sha256").update(o).digest("base64url")),a&&(c.nonce=a),Nr(s,c,t)}function le(t){return!t||t.length===0?!1:t.some(e=>e.toUpperCase()==="ES256")}function Nr(t,e,r){let n=se(JSON.stringify(t)),o=se(JSON.stringify(e)),a=`${n}.${o}`,s=jr({key:r,format:"jwk"}),l=Dr("SHA256",Buffer.from(a),{key:s,dsaEncoding:"ieee-p1363"}).toString("base64url");return`${a}.${l}`}function se(t){return Buffer.from(t,"utf-8").toString("base64url")}function de(t){let e=new Map;return async(r,n,o="GET")=>{if(!t)return fetch(r,{method:o});let a=await t.getCredential(n);if(!a?.accessToken)return fetch(r,{method:o});b(a)&&console.warn(` Warning: Access token for '${n}' is expired. Run 'kanonak login ${n}' to re-authenticate.`);let s={};if(a.dpopKeyPair){let l=e.get(n);try{let d=k(a.dpopKeyPair.privateKey,a.dpopKeyPair.publicKey,o,r,a.accessToken,l);s.Authorization=`DPoP ${a.accessToken}`,s.DPoP=d}catch(d){let Ce=d instanceof Error?d.message:String(d);console.error(` Error: Failed to create DPoP proof for '${n}': ${Ce}
98
+ The stored key pair may be corrupted. Run 'kanonak login ${n}' to re-authenticate.`),s.Authorization=`Bearer ${a.accessToken}`}}else s.Authorization=`Bearer ${a.accessToken}`;let c=await fetch(r,{method:o,headers:s});if(c.status===401&&a.dpopKeyPair){let l=c.headers.get("DPoP-Nonce");if(l){e.set(n,l);try{let d=k(a.dpopKeyPair.privateKey,a.dpopKeyPair.publicKey,o,r,a.accessToken,l);s.DPoP=d,c=await fetch(r,{method:o,headers:s})}catch{}}}return c}}import{readFileSync as Or,writeFileSync as Ar,existsSync as Ur}from"fs";import{createHash as Vr}from"crypto";import ue from"js-yaml";var pe="kanonak.lock",Hr=`# This file is generated by Kanonak CLI. Do not edit manually.
99
+ `;function me(t=pe){if(!Ur(t))return null;let e=Or(t,"utf-8"),r=ue.load(e);return!r||typeof r!="object"||r.version!=="1"?null:{version:"1",lastUpdated:r.lastUpdated??new Date().toISOString(),packages:r.packages??{}}}function fe(t,e=pe){t.lastUpdated=new Date().toISOString();let r={};for(let o of Object.keys(t.packages).sort())r[o]=t.packages[o];t.packages=r;let n=ue.dump(t,{lineWidth:-1,sortKeys:!1,quotingType:'"'});Ar(e,Hr+n,"utf-8")}function ye(t){return`sha256:${Vr("sha256").update(t).digest("hex")}`}import{createHash as Mr}from"crypto";function q(t){let e=[];for(let n of t)n instanceof L&&e.push(_r(n));return e.sort((n,o)=>n.uri<o.uri?-1:n.uri>o.uri?1:0),JSON.stringify({subjects:e})}function ge(t){let e=q(t);return`sha256:${Mr("sha256").update(e,"utf8").digest("hex")}`}function _r(t){let e=Yr(t),r=Y(t.statement);return{uri:e,statements:r}}function Y(t){let e=[];for(let r of t){let n=zr(r);n&&e.push(n)}return e.sort((r,n)=>r.predicate<n.predicate?-1:r.predicate>n.predicate?1:0),e}function zr(t){let e=qr(t);if(!e)return;let r=Gr(t);if(r)return Jr(e,r)}function Gr(t){if(t instanceof O)return{type:"string",value:t.object};if(t instanceof A)return{type:"number",value:Se(t.object)};if(t instanceof U)return{type:"boolean",value:t.object};if(t instanceof V)return{type:"ref",value:ke(t.object)};if(t instanceof H){let e=t.object;return he(e)}if(t instanceof M)return{type:"list",items:t.object.map(Wr)}}function he(t){let e=Y(t.statement);return t.name&&t.name.length>0?{type:"embedded",name:t.name,statements:e}:{type:"embedded",statements:e}}function Wr(t){if(t instanceof D)return{type:"ref",value:ke(t)};if(t instanceof F)return he(t);if(t instanceof N){let e=t.value;if(typeof e=="string")return{type:"string",value:e};if(typeof e=="number")return{type:"number",value:Se(e)};if(typeof e=="boolean")return{type:"boolean",value:e}}if(t instanceof j)return{type:"embedded",statements:Y(t.statement)};throw new Error(`canonicalForm: list item of unrecognized kind (${t.constructor?.name??typeof t}); add canonicalization support before hashing data that contains it`)}function Jr(t,e){switch(e.type){case"string":return{predicate:t,type:"string",value:e.value};case"number":return{predicate:t,type:"number",value:e.value};case"boolean":return{predicate:t,type:"boolean",value:e.value};case"ref":return{predicate:t,type:"ref",value:e.value};case"embedded":return e.name!==void 0?{predicate:t,type:"embedded",name:e.name,statements:e.statements}:{predicate:t,type:"embedded",statements:e.statements};case"list":return{predicate:t,type:"list",items:e.items}}}function qr(t){let e=t.predicate;if(e)return be(e.subject)}function Yr(t){let e=t.namespace??"",r=t.name??"";return`${e}/${r}`}function ke(t){return be(t.subject)}function be(t){let e=t.version;return e&&typeof e.major=="number"?`${t.publisher}/${t.package_}@${e.major}.${e.minor}.${e.patch}/${t.name}`:`${t.publisher}/${t.package_}/${t.name}`}function Se(t){if(Number.isNaN(t))throw new Error("canonicalForm: NaN cannot be canonicalized");if(!Number.isFinite(t))throw new Error("canonicalForm: \xB1Infinity cannot be canonicalized");return Object.is(t,-0)?"0":String(t)}export{Xt as AmbiguousReferenceRule,U as BooleanStatement,nr as ClassDefinitionRule,Ht as ClassHierarchyCycleRule,De as CompositeKanonakDocumentRepository,T as CredentialStore,j as DefinedKanonak,qt as DefinitionPropertyReferenceRule,Fe as DocumentLocation,lt as EdgeType,F as EmbeddedKanonak,At as EmbeddedKanonakTypeRule,H as EmbeddedStatement,Le as FileSystemKanonakDocumentRepository,gt as GitIgnoreFilter,dt as GraphBuilder,He as HttpKanonakDocumentRepository,Ut as ImportExistenceRule,Te as InMemoryKanonakDocumentRepository,Jt as InstancePropertyReferenceRule,Ge as Kanonak,kt as KanonakDocumentPositions,it as KanonakObjectParser,ar as KanonakObjectValidator,je as KanonakParser,We as KanonakUri,Ct as KanonakUriBuilder,wt as KanonakUrlResolver,nt as KanonakVocabulary,M as ListStatement,N as LiteralKanonak,Me as LocalFirstRepository,cr as LookRenderer,or as MarkdownLinkRule,Ye as MarkdownStatement,Wt as NamespaceImportCycleRule,Ft as NamespacePrefixRule,ct as NodeType,A as NumberStatement,mt as OWL_RL_CLASSIFICATION_RULES,Qt as ObjectPropertyImportRule,er as ObjectPropertyValueValidationRule,Tt as OntologyValidationError,It as OntologyValidationResult,tr as PropertyDomainRule,Mt as PropertyHierarchyCycleRule,ht as PropertyMetadata,Zt as PropertyRangeReferenceRule,_t as PropertyRangeRequiredRule,Nt as PropertyTypeSpecificityRule,rr as PropertyValueTypeRule,Ae as PublisherConfigResolver,Ue as PublisherIndex,pt as RDFS_RULES,yt as Reasoner,ft as ReasoningResult,D as ReferenceKanonak,V as ReferenceStatement,Oe as RepositoryFactory,Dt as ResourceNamingRule,Xe as ResourceResolver,st as ResourceTypeClassifier,qe as ScalarStatement,Je as Statement,O as StringStatement,zt as SubClassOfReferenceRule,Gt as SubPropertyOfReferenceRule,L as SubjectKanonak,Ot as SubjectKanonakTypeRequiredRule,ut as TripleStore,Ze as TypeResolver,Vt as UnresolvedReferenceRule,Lt as ValidationCache,jt as ValidationContext,Bt as ValidationSeverity,ko as VersionOperator,Yt as XsdImportRule,Ve as assertPackageIdentity,ze as buildLocalFirstRepository,q as canonicalForm,ge as canonicalHash,_e as collectKanonakFiles,we as compareVersions,ye as computeIntegrity,Et as contextTypesOf,de as createAuthenticatedFetch,k as createDPoPProof,$e as createVersion,at as extractMarkdownLinks,ir as findDerivation,Kt as findInstancesByType,ot as findMalformedReferences,St as findMarkdownLinkAt,Rt as formatKanonakAddress,ve as formatVersion,ce as generateDPoPKeyPair,Ne as getGlobalCachePath,S as hasValidToken,Ke as isCompatibleVersion,b as isExpired,Ie as isMajorCompatible,me as loadLockFile,et as makeUriKey,i as normalizeHost,Pt as parseKanonakAddress,Ee as parseVersionString,bt as parseWithPositions,Be as pickHighestDocument,vt as propertiesInScope,sr as resolveDisplayValue,$t as resolvePropertyStep,fe as saveLockFile,le as serverSupportsDPoP,xt as subjectUri,tt as tripleKey,Qe as uriKey,rt as uriTriple,Pe as versionOperatorFromChar,Re as versionOperatorToChar,xe as versionsEqual};
@@ -1,4 +1,4 @@
1
- import type { KanonakDocument, ParseResult } from '@kanonak-protocol/types/document/models/types';
1
+ import type { KanonakDocument, Import, ParseResult } from '@kanonak-protocol/types/document/models/types';
2
2
  import type { IKanonakParser } from '@kanonak-protocol/types/document/parsing';
3
3
  export declare class KanonakParser implements IKanonakParser {
4
4
  parse(yamlText: string): KanonakDocument;
@@ -14,6 +14,15 @@ export declare class KanonakParser implements IKanonakParser {
14
14
  private parseImportsV3;
15
15
  private parseImportsLegacy;
16
16
  private parseImportFromEmbeddedObject;
17
+ /**
18
+ * Build a single {@link Import} from its parts — the canonical way to
19
+ * construct one OUTSIDE parsing a document (e.g. to request a seed package
20
+ * by address in request-driven rendering). Delegates to the same logic that
21
+ * parses an authored import, so the operator, version, and the computed
22
+ * `minVersion`/`maxVersion` are identical to a parsed import. `operator` is
23
+ * the character form (`= ~ ^ *`); `version` is a `major.minor.patch` string.
24
+ */
25
+ buildImport(packageName: string, operator: string, version: string, publisher?: string): Import;
17
26
  private parseImport;
18
27
  private parseVersionOperator;
19
28
  private calculateMaxVersion;
@@ -1 +1 @@
1
- import{a as c,b as d,c as e,d as f}from"../chunk-CYDDQF6S.js";import{c as b}from"../chunk-VJT6YUWK.js";import"../chunk-H2LEQLVD.js";import{a}from"../chunk-7CUTGGH3.js";import"../chunk-64TVBQFR.js";import"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";export{d as KanonakDocumentPositions,b as KanonakObjectParser,a as KanonakParser,c as PropertyMetadata,f as findMarkdownLinkAt,e as parseWithPositions};
1
+ import{a as c,b as d,c as e,d as f}from"../chunk-7JZUJ2K4.js";import{c as b}from"../chunk-Q6QTQWR2.js";import"../chunk-H2LEQLVD.js";import{a}from"../chunk-ORFSMEMM.js";import"../chunk-64TVBQFR.js";import"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import"../chunk-2ACBWC7K.js";export{d as KanonakDocumentPositions,b as KanonakObjectParser,a as KanonakParser,c as PropertyMetadata,f as findMarkdownLinkAt,e as parseWithPositions};
@@ -1 +1 @@
1
- import{a as g,b as h,c as i,d as j,e as k}from"../chunk-SD5QKNBC.js";import"../chunk-VJT6YUWK.js";import"../chunk-H2LEQLVD.js";import"../chunk-7CUTGGH3.js";import{d as a,e as b,f as c,h as d,i as e,j as f}from"../chunk-64TVBQFR.js";import"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";export{f as KanonakVocabulary,i as OWL_RL_CLASSIFICATION_RULES,h as RDFS_RULES,k as Reasoner,j as ReasoningResult,g as TripleStore,e as canonicalizeBuiltinUri,b as makeUriKey,c as tripleKey,a as uriKey,d as uriTriple};
1
+ import{a as g,b as h,c as i,d as j,e as k}from"../chunk-QHJ6EY3Y.js";import"../chunk-Q6QTQWR2.js";import"../chunk-H2LEQLVD.js";import"../chunk-ORFSMEMM.js";import{d as a,e as b,f as c,h as d,i as e,j as f}from"../chunk-64TVBQFR.js";import"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import"../chunk-2ACBWC7K.js";export{f as KanonakVocabulary,i as OWL_RL_CLASSIFICATION_RULES,h as RDFS_RULES,k as Reasoner,j as ReasoningResult,g as TripleStore,e as canonicalizeBuiltinUri,b as makeUriKey,c as tripleKey,a as uriKey,d as uriTriple};
@@ -3,6 +3,17 @@ export interface PublisherConfig {
3
3
  index?: string;
4
4
  package?: string;
5
5
  auth?: 'none' | 'oauth' | 'bearer';
6
+ /**
7
+ * Optional render contract: the look-stack packages — each a
8
+ * `publisher/package[@version]` address — a consumer must include in the
9
+ * render closure to STYLE this publisher's resources. ABSENT means "use the
10
+ * universal kanonak.org render base" (see `resolveRenderContract`). The look
11
+ * stack is discovered ambiently by the renderer, not via import edges, so
12
+ * declaring it here is how a publisher makes that dependency EXPLICIT — and
13
+ * how it overrides the universal base with its own look. Each entry is parsed
14
+ * through `parseKanonakAddress`, not string-matched.
15
+ */
16
+ render?: string[];
6
17
  }
7
18
  /**
8
19
  * The explicit, self-describing config a publisher advertises at
@@ -1 +1 @@
1
- import{a as o,c as e,d as r,e as n}from"../chunk-6SGRDFL5.js";import"../chunk-7CUTGGH3.js";import"../chunk-FQHALFRR.js";export{n as HttpKanonakDocumentRepository,o as InMemoryKanonakDocumentRepository,e as PublisherConfigResolver,r as PublisherIndex};
1
+ import{a as o,c as e,d as r,e as n}from"../chunk-RSIZQAFL.js";import"../chunk-SC5M74NM.js";import"../chunk-ORFSMEMM.js";import"../chunk-2ACBWC7K.js";export{n as HttpKanonakDocumentRepository,o as InMemoryKanonakDocumentRepository,e as PublisherConfigResolver,r as PublisherIndex};
@@ -1 +1 @@
1
- import{a as b,b as c,c as d,d as e,e as f,f as k,g as l,h as m}from"../chunk-MYPKSBTP.js";import{a,b as g,c as h,d as i,e as j}from"../chunk-6SGRDFL5.js";import"../chunk-7CUTGGH3.js";import"../chunk-FQHALFRR.js";export{d as CompositeKanonakDocumentRepository,c as DocumentLocation,b as FileSystemKanonakDocumentRepository,j as HttpKanonakDocumentRepository,a as InMemoryKanonakDocumentRepository,k as LocalFirstRepository,h as PublisherConfigResolver,i as PublisherIndex,f as RepositoryFactory,m as buildLocalFirstRepository,l as collectKanonakFiles,g as defaultPublisherConfig,e as getGlobalCachePath};
1
+ import{a as b,b as c,c as d,d as e,e as f,f as k,g as l,h as m}from"../chunk-CA2EATJR.js";import{a,b as g,c as h,d as i,e as j}from"../chunk-RSIZQAFL.js";import"../chunk-SC5M74NM.js";import"../chunk-ORFSMEMM.js";import"../chunk-2ACBWC7K.js";export{d as CompositeKanonakDocumentRepository,c as DocumentLocation,b as FileSystemKanonakDocumentRepository,j as HttpKanonakDocumentRepository,a as InMemoryKanonakDocumentRepository,k as LocalFirstRepository,h as PublisherConfigResolver,i as PublisherIndex,f as RepositoryFactory,m as buildLocalFirstRepository,l as collectKanonakFiles,g as defaultPublisherConfig,e as getGlobalCachePath};
@@ -1,4 +1,16 @@
1
1
  import type { Version, KanonakDocument } from '@kanonak-protocol/types/document/models/types';
2
+ import { VersionOperator } from '@kanonak-protocol/types/document/models/enums';
3
+ /**
4
+ * The canonical mapping between an import's operator character (`= ~ ^ *`) and
5
+ * its {@link VersionOperator}. This is the ONE source of truth for that
6
+ * correspondence: the parser uses it to read operators and to serialize them
7
+ * back, so no code switches on raw enum numbers or indexes a positional array
8
+ * (the historical source of an enum-name/value mismatch). An unknown character
9
+ * falls back to `Compatible` (`~`), the parser's long-standing default.
10
+ */
11
+ export declare function versionOperatorFromChar(op: string): VersionOperator;
12
+ /** The inverse of {@link versionOperatorFromChar}: operator → its character. */
13
+ export declare function versionOperatorToChar(op: VersionOperator): string;
2
14
  export declare function compareVersions(a: Version, b: Version): number;
3
15
  export declare function versionsEqual(a: Version, b: Version): boolean;
4
16
  export declare function formatVersion(v: Version): string;
@@ -0,0 +1,10 @@
1
+ import type { KanonakDocument } from '@kanonak-protocol/types/document/models';
2
+ /**
3
+ * Verify that a fetched/cached document actually declares the package identity
4
+ * it was requested under — "what you got is what you asked for." A publisher's
5
+ * `package` URL serving the wrong file, a misconfigured CDN, or a tampered
6
+ * source could otherwise be cached/locked under the requested identity with
7
+ * mismatched content (namespace confusion). Throws (fail visibly) on any
8
+ * publisher / package / version mismatch; never silently accepts.
9
+ */
10
+ export declare function assertPackageIdentity(doc: KanonakDocument, publisher: string, packageName: string, version: string): void;
@@ -1,5 +1,6 @@
1
1
  export { ResourceResolver } from './ResourceResolver.js';
2
2
  export type { ILogger } from './ResourceResolver.js';
3
+ export { assertPackageIdentity } from './assertPackageIdentity.js';
3
4
  export { KanonakUri } from './KanonakUri.js';
4
5
  export { KanonakUriBuilder } from './KanonakUriBuilder.js';
5
6
  export { parseKanonakAddress, formatKanonakAddress, } from './KanonakAddress.js';
@@ -13,5 +14,5 @@ export type { PropertyDescriptor, PropertyKind, StepResolution } from './TypeDir
13
14
  export { ResourceTypeClassifier } from './ResourceTypeClassifier.js';
14
15
  export { findInstancesByType } from './InstanceSearch.js';
15
16
  export type { InstanceSearchResult } from './InstanceSearch.js';
16
- export { compareVersions, versionsEqual, formatVersion, parseVersionString, createVersion, isCompatibleVersion, isMajorCompatible, pickHighestDocument, } from './VersionUtils.js';
17
+ export { compareVersions, versionsEqual, formatVersion, parseVersionString, createVersion, isCompatibleVersion, isMajorCompatible, pickHighestDocument, versionOperatorFromChar, versionOperatorToChar, } from './VersionUtils.js';
17
18
  export type { DocumentVersionPick } from './VersionUtils.js';
@@ -1 +1 @@
1
- import{a as m,b as u}from"../chunk-DC774EQL.js";import{a as p}from"../chunk-NIGFQYVA.js";import{a as l,b as n,c as o,d as q,e as r,f as s,g as t}from"../chunk-N224PFBI.js";import"../chunk-Q4DKP5DO.js";import{a,b,c,d,e,f,g,h}from"../chunk-FQHALFRR.js";import{b as j,c as k}from"../chunk-64TVBQFR.js";import"../chunk-W6T7MOKY.js";import{a as i}from"../chunk-FUUTGGJS.js";export{i as KanonakUri,m as KanonakUriBuilder,p as KanonakUrlResolver,j as ResourceResolver,l as ResourceTypeClassifier,k as TypeResolver,a as compareVersions,t as contextTypesOf,d as createVersion,u as findInstancesByType,o as formatKanonakAddress,c as formatVersion,f as isCompatibleVersion,g as isMajorCompatible,n as parseKanonakAddress,e as parseVersionString,h as pickHighestDocument,r as propertiesInScope,s as resolvePropertyStep,q as subjectUri,b as versionsEqual};
1
+ import{a as p,b as x}from"../chunk-PEUTCG3B.js";import{a as s}from"../chunk-NIGFQYVA.js";import{a as k}from"../chunk-SC5M74NM.js";import{a as o,b as q,c as r,d as t,e as u,f as v,g as w}from"../chunk-N224PFBI.js";import"../chunk-Q4DKP5DO.js";import{b as m,c as n}from"../chunk-64TVBQFR.js";import"../chunk-W6T7MOKY.js";import{a as l}from"../chunk-FUUTGGJS.js";import{a,b,c,d,e,f,g,h,i,j}from"../chunk-2ACBWC7K.js";export{l as KanonakUri,p as KanonakUriBuilder,s as KanonakUrlResolver,m as ResourceResolver,o as ResourceTypeClassifier,n as TypeResolver,k as assertPackageIdentity,c as compareVersions,w as contextTypesOf,f as createVersion,x as findInstancesByType,r as formatKanonakAddress,e as formatVersion,h as isCompatibleVersion,i as isMajorCompatible,q as parseKanonakAddress,g as parseVersionString,j as pickHighestDocument,u as propertiesInScope,v as resolvePropertyStep,t as subjectUri,a as versionOperatorFromChar,b as versionOperatorToChar,d as versionsEqual};
@@ -1,4 +1,4 @@
1
- import{a as p}from"../chunk-ESYVKB25.js";import"../chunk-3NEUHF7E.js";import"../chunk-DC774EQL.js";import"../chunk-NIGFQYVA.js";import"../chunk-H2LEQLVD.js";import{d as m,g as x}from"../chunk-N224PFBI.js";import{a as d,f as S}from"../chunk-Q4DKP5DO.js";import{a as v}from"../chunk-FQHALFRR.js";import"../chunk-64TVBQFR.js";import{c as j}from"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import{homedir as P}from"os";import{join as k}from"path";import{existsSync as B,mkdirSync as C,readFileSync as D,writeFileSync as O}from"fs";import{createHash as z}from"crypto";var f="Xenova/all-MiniLM-L6-v2",w="q8",b=32,g=null;async function K(){return g||(g=(async()=>{let t;try{t=await import("@huggingface/transformers")}catch(i){throw new Error(`Semantic search requires the embedding runtime, which is an optional dependency.
1
+ import{a as p}from"../chunk-JYUZT2JU.js";import"../chunk-3NEUHF7E.js";import"../chunk-PEUTCG3B.js";import"../chunk-NIGFQYVA.js";import"../chunk-SC5M74NM.js";import"../chunk-H2LEQLVD.js";import{d as m,g as x}from"../chunk-N224PFBI.js";import{a as d,f as S}from"../chunk-Q4DKP5DO.js";import"../chunk-64TVBQFR.js";import{c as j}from"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import{c as v}from"../chunk-2ACBWC7K.js";import{homedir as P}from"os";import{join as k}from"path";import{existsSync as B,mkdirSync as C,readFileSync as D,writeFileSync as O}from"fs";import{createHash as z}from"crypto";var f="Xenova/all-MiniLM-L6-v2",w="q8",b=32,g=null;async function K(){return g||(g=(async()=>{let t;try{t=await import("@huggingface/transformers")}catch(i){throw new Error(`Semantic search requires the embedding runtime, which is an optional dependency.
2
2
  Install it with:
3
3
  npm install @huggingface/transformers
4
4
  (underlying import error: ${i.message})`)}let{pipeline:r,env:n}=t;n.cacheDir=k(P(),".kanonak","models");let e=await r("feature-extraction",f,{dtype:w});return async i=>(await e(i,{pooling:"mean",normalize:!0})).tolist()})()),g}function H(t,r){let n=0;for(let e=0;e<t.length;e++)n+=t[e]*r[e];return n}function U(t,r){return r?t.version?r.version?v(t.version,r.version)>0:!0:!1:!0}function F(t,r){let n=p(t,r),e=[n.label],i=x(r);if(i.length>0){let s=S(t,i[0]),c=s?p(t,s).label:i[0].name;c&&e.push(`\u2014 a ${c}.`)}return n.summary&&e.push(n.summary),e.join(" ")}function M(t){let r=new Map;for(let n of t){if(!(n instanceof j))continue;let e=m(n);if(!e)continue;let i=d(e),s=r.get(i);(!s||U(e,m(s)))&&r.set(i,n)}return[...r.values()].sort((n,e)=>{let i=m(n)?d(m(n)):n.name,s=m(e)?d(m(e)):e.name;return i.localeCompare(s)})}var y=class{entries=[];get size(){return this.entries.length}async build(r,n={}){let e=M(r);if(n.include&&(e=e.filter(n.include)),e.length===0)return this.entries=[],{size:0,cached:!1};let i=e.map(o=>F(r,o)),s=n.cacheDir,c;if(s){let o=z("sha256").update(f+"|"+w+`
@@ -0,0 +1,21 @@
1
+ import type { Kanonak } from '../kanonaks/index.js';
2
+ import type { LookRenderer } from '../look/index.js';
3
+ import type { ServerModel } from './types.js';
4
+ /**
5
+ * Build the route-facing indexes for a {@link ServerModel} from an already-built
6
+ * catalog + `LookRenderer`, scoped to the served publisher's `localNamespaces`.
7
+ *
8
+ * This is the half of model-building that is identical whether the seed came
9
+ * from a workspace scan (`loadServerModel`) or an address fetched over HTTP
10
+ * (`loadResourceModel`): given the catalog, the renderer, which namespaces the
11
+ * served publisher owns, and their raw sources, it produces `bySubject` /
12
+ * `pkgVersions` / `pkgSelfByVer`. Pure — no I/O.
13
+ */
14
+ export declare function assembleServerModel(params: {
15
+ publisher: string;
16
+ availablePublishers: string[];
17
+ catalog: Kanonak[];
18
+ lookRenderer: LookRenderer;
19
+ localNamespaces: Set<string>;
20
+ rawByNsKey: Map<string, string>;
21
+ }): ServerModel;
@@ -1,4 +1,8 @@
1
1
  export { loadServerModel } from './loadServerModel.js';
2
+ export { loadResourceModel } from './loadResourceModel.js';
3
+ export type { LoadResourceModelOptions } from './loadResourceModel.js';
2
4
  export { route } from './route.js';
3
5
  export { deriveImportClosure, ClosureScopedRepository } from './closure.js';
6
+ export { UNIVERSAL_RENDER_BASE, resolveRenderContract, renderRefKey, } from './renderStack.js';
7
+ export type { RenderPackageRef } from './renderStack.js';
4
8
  export type { ServerModel, RouteResponse, LoadServerModelOptions, PackageVersion, } from './types.js';
@@ -1,3 +1,3 @@
1
- import{c as z}from"../chunk-ESYVKB25.js";import"../chunk-3NEUHF7E.js";import{a as W,d as _,f as U,g as G}from"../chunk-MYPKSBTP.js";import{a as L,b as B,d as H,e as T}from"../chunk-6SGRDFL5.js";import{a as J}from"../chunk-NIGFQYVA.js";import{c as q}from"../chunk-VJT6YUWK.js";import"../chunk-H2LEQLVD.js";import{a as O}from"../chunk-7CUTGGH3.js";import"../chunk-Q4DKP5DO.js";import{a as P,e as E}from"../chunk-FQHALFRR.js";import"../chunk-64TVBQFR.js";import{c as Y}from"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import{readFileSync as ne,existsSync as te,readdirSync as re,writeFileSync as oe,mkdirSync as se}from"fs";import{join as C}from"path";function Q(o){let e=o.metadata?.namespace_;return e?`${e.publisher}/${e.package_}`:void 0}async function V(o,e){let t=new Set,r=[...o];for(;r.length>0;){let s=r.shift(),d=Q(s);if(!d||t.has(d))continue;t.add(d);let m=s.metadata?.imports;if(m)for(let[u,w]of Object.entries(m))for(let b of w)try{let i=await e.getHighestCompatibleVersionAsync(u,b);i&&r.push(i)}catch{}}return t}var $=class{constructor(e,t){this.inner=e;this.scope=t}inner;scope;async getAllDocumentsAsync(){return(await this.inner.getAllDocumentsAsync()).filter(t=>{let r=Q(t);return r!==void 0&&this.scope.has(r)})}getDocumentAsync(e){return this.inner.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,t){return this.inner.getDocumentsByNamespaceAsync(e,t)}getHighestCompatibleVersionAsync(e,t){return this.inner.getHighestCompatibleVersionAsync(e,t)}saveDocumentAsync(e,t){return this.inner.saveDocumentAsync(e,t)}deleteDocumentAsync(e){return this.inner.deleteDocumentAsync(e)}clearNamespaceAsync(e,t){return this.inner.clearNamespaceAsync(e,t)}getAllDocumentReferencesAsync(){return this.inner.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.inner.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.inner.getDocumentUriAsync(e)}};var X=["core-kanonak","site","link","look-tokens","look-styles","look","universal-look"];async function ie(o,e={}){let t=new O,r=new L(t),s=[],d=[];for(let n of G(o)){let p;try{p=ne(n,"utf-8")}catch{continue}let a;try{a=t.parse(p).metadata?.namespace_}catch{continue}if(!a?.version)continue;let k=a.version;d.push({publisher:a.publisher,package_:a.package_,verStr:`${k.major}.${k.minor}.${k.patch}`,version:k,source:p})}d.sort((n,p)=>P(p.version,n.version));for(let n of d)await r.saveDocumentAsync(t.parse(n.source),`${n.publisher}/${n.package_}@${n.verStr}`),s.push({publisher:n.publisher,package_:n.package_,verStr:n.verStr,source:n.source});let m=[...new Set(s.map(n=>n.publisher))].sort(),u=e.publisher;if(u){if(!m.includes(u))throw new Error(`Publisher "${u}" not found in workspace. Available: ${m.join(", ")||"(none)"}`)}else if(m.length===1)u=m[0];else throw m.length===0?new Error(`No Kanonak packages found under ${o}`):new Error(`Workspace has multiple publishers (${m.join(", ")}). Pass --publisher <domain> to choose which one to serve.`);let w=new Set,b=new Map;for(let n of s)n.publisher===u&&(w.add(`${n.publisher}/${n.package_}@${n.verStr}`),b.set(`${n.package_}@${n.verStr}`,n.source));let i=new W(_(),!0,t),c=e.repository??new U(r,i,new T(e.httpCache?{getFromCache:e.httpCache.getFromCache,onFetch:e.httpCache.onFetch}:void 0));if(!e.repository){let n=_(),p=h=>C(n,h),a=h=>{let v=p(h);return te(v)?new Set(re(v).filter(K=>K.endsWith(".kan.yml")).map(K=>K.split("@")[0])):new Set},k=h=>s.some(v=>v.publisher==="kanonak.org"&&v.package_===h),R=new H,x=a("kanonak.org");for(let h of X)if(!(x.has(h)||k(h)))try{let v=await R.getHighestVersion("kanonak.org",h);if(!v)continue;let K=await R.getPackageUrl("kanonak.org",h,v),I=await fetch(K);if(!I.ok)continue;let ee=await I.text(),F=C(n,"kanonak.org");se(F,{recursive:!0}),oe(C(F,`${h}@${v}.kan.yml`),ee,"utf-8")}catch{}}let l=c;if(!e.repository){let n=(await r.getAllDocumentsAsync()).filter(a=>a.metadata.namespace_?.publisher===u),p=await V(n,c);for(let a of X)p.add(`kanonak.org/${a}`);l=new $(c,p)}let y=await new q(t).parseKanonaks(l),D=new z(y),j=new Map,A=new Map,N=new Map,M=new Set;for(let n of y){if(!(n instanceof Y))continue;let p=n.namespace||"";if(!w.has(p))continue;j.set(`${p}/${n.name}`,n);let a=p.split("/")[1]??"",[k,R]=a.split("@");if(!k||!R)continue;let x=E(R);x&&(M.has(a)||(M.add(a),A.has(k)||A.set(k,[]),A.get(k).push({verStr:R,version:x})),n.name===k&&N.set(a,n))}for(let n of A.values())n.sort((p,a)=>P(a.version,p.version));return{publisher:u,availablePublishers:m,catalog:y,lookRenderer:D,localNamespaces:w,rawByNsKey:b,bySubject:j,pkgVersions:A,pkgSelfByVer:N}}var g={".html":"text/html; charset=utf-8",".css":"text/css; charset=utf-8",".svg":"image/svg+xml",".md":"text/markdown; charset=utf-8",".kan.yml":"application/yaml; charset=utf-8",".txt":"text/plain; charset=utf-8",".json":"application/json; charset=utf-8"},f=(o,e,t,r)=>({status:o,headers:{"Content-Type":e,...r||{}},body:t}),S=o=>f(404,g[".html"],`<!doctype html><meta charset=utf-8><title>404</title><h1>404</h1><p>Not found: ${o}</p>`),ce=o=>({status:301,headers:{Location:o},body:""});function Z(o,e,t){let r=o.pkgVersions.get(e);if(!r||r.length===0)return null;switch(t.kind){case"any":return r[0].verStr;case"major-pin":return r.find(s=>s.version.major===t.major)?.verStr??null;case"minor-pin":return r.find(s=>s.version.major===t.major&&s.version.minor===t.minor)?.verStr??null;case"exact":return r.find(s=>s.version.major===t.major&&s.version.minor===t.minor&&s.version.patch===t.patch)?.verStr??null;default:return null}}function ae(o,e,t=""){let{lookRenderer:r,publisher:s}=o;if(e==="/.well-known/kanonak.json")return f(200,g[".json"],JSON.stringify(B(s),null,2));if(e==="/index.txt"){let c=[...o.localNamespaces].map(l=>l.split("/")[1].replace("@","/")).sort();return f(200,g[".txt"],c.join(`
1
+ import{c as L}from"../chunk-JYUZT2JU.js";import"../chunk-3NEUHF7E.js";import{a as T,d as x,f as q,g as J}from"../chunk-CA2EATJR.js";import{a as W,b as G,c as Y,d as V,e as N}from"../chunk-RSIZQAFL.js";import"../chunk-PEUTCG3B.js";import{a as Q}from"../chunk-NIGFQYVA.js";import"../chunk-SC5M74NM.js";import{c as F}from"../chunk-Q6QTQWR2.js";import"../chunk-H2LEQLVD.js";import{a as M}from"../chunk-ORFSMEMM.js";import{b as I}from"../chunk-N224PFBI.js";import"../chunk-Q4DKP5DO.js";import"../chunk-64TVBQFR.js";import{c as z}from"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import{c as C,g as U}from"../chunk-2ACBWC7K.js";import{readFileSync as te,existsSync as oe,readdirSync as se,writeFileSync as ae,mkdirSync as ie}from"fs";import{join as O}from"path";function X(s){let e=s.metadata?.namespace_;return e?`${e.publisher}/${e.package_}`:void 0}async function A(s,e){let n=new Set,r=[...s];for(;r.length>0;){let o=r.shift(),g=X(o);if(!g||n.has(g))continue;n.add(g);let d=o.metadata?.imports;if(d)for(let[l,v]of Object.entries(d))for(let h of v)try{let p=await e.getHighestCompatibleVersionAsync(l,h);p&&r.push(p)}catch{}}return n}var K=class{constructor(e,n){this.inner=e;this.scope=n}inner;scope;async getAllDocumentsAsync(){return(await this.inner.getAllDocumentsAsync()).filter(n=>{let r=X(n);return r!==void 0&&this.scope.has(r)})}getDocumentAsync(e){return this.inner.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,n){return this.inner.getDocumentsByNamespaceAsync(e,n)}getHighestCompatibleVersionAsync(e,n){return this.inner.getHighestCompatibleVersionAsync(e,n)}saveDocumentAsync(e,n){return this.inner.saveDocumentAsync(e,n)}deleteDocumentAsync(e){return this.inner.deleteDocumentAsync(e)}clearNamespaceAsync(e,n){return this.inner.clearNamespaceAsync(e,n)}getAllDocumentReferencesAsync(){return this.inner.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.inner.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.inner.getDocumentUriAsync(e)}};var Z=[{publisher:"kanonak.org",package_:"core-kanonak"},{publisher:"kanonak.org",package_:"site"},{publisher:"kanonak.org",package_:"link"},{publisher:"kanonak.org",package_:"look-tokens"},{publisher:"kanonak.org",package_:"look-styles"},{publisher:"kanonak.org",package_:"look"},{publisher:"kanonak.org",package_:"universal-look"}];function j(s){let e=s?.render;if(e&&e.length>0){let n=[];for(let r of e)try{let o=I(r);o.kind==="package"?n.push({publisher:o.publisher,package_:o.package_}):o.kind==="resource"&&n.push({publisher:o.uri.publisher,package_:o.uri.package_})}catch{}if(n.length>0)return n}return Z}function B(s){return`${s.publisher}/${s.package_}`}function E(s){let{publisher:e,availablePublishers:n,catalog:r,lookRenderer:o,localNamespaces:g,rawByNsKey:d}=s,l=new Map,v=new Map,h=new Map,p=new Set;for(let c of r){if(!(c instanceof z))continue;let u=c.namespace||"";if(!g.has(u))continue;l.set(`${u}/${c.name}`,c);let f=u.split("/")[1]??"",[y,D]=f.split("@");if(!y||!D)continue;let a=U(D);a&&(p.has(f)||(p.add(f),v.has(y)||v.set(y,[]),v.get(y).push({verStr:D,version:a})),c.name===y&&h.set(f,c))}for(let c of v.values())c.sort((u,f)=>C(f.version,u.version));return{publisher:e,availablePublishers:n,catalog:r,lookRenderer:o,localNamespaces:g,rawByNsKey:d,bySubject:l,pkgVersions:v,pkgSelfByVer:h}}async function ce(s,e={}){let n=new M,r=new W(n),o=[],g=[];for(let a of J(s)){let w;try{w=te(a,"utf-8")}catch{continue}let b;try{b=n.parse(w).metadata?.namespace_}catch{continue}if(!b?.version)continue;let _=b.version;g.push({publisher:b.publisher,package_:b.package_,verStr:`${_.major}.${_.minor}.${_.patch}`,version:_,source:w})}g.sort((a,w)=>C(w.version,a.version));for(let a of g)await r.saveDocumentAsync(n.parse(a.source),`${a.publisher}/${a.package_}@${a.verStr}`),o.push({publisher:a.publisher,package_:a.package_,verStr:a.verStr,source:a.source});let d=[...new Set(o.map(a=>a.publisher))].sort(),l=e.publisher;if(l){if(!d.includes(l))throw new Error(`Publisher "${l}" not found in workspace. Available: ${d.join(", ")||"(none)"}`)}else if(d.length===1)l=d[0];else throw d.length===0?new Error(`No Kanonak packages found under ${s}`):new Error(`Workspace has multiple publishers (${d.join(", ")}). Pass --publisher <domain> to choose which one to serve.`);let v=new Set,h=new Map;for(let a of o)a.publisher===l&&(v.add(`${a.publisher}/${a.package_}@${a.verStr}`),h.set(`${a.package_}@${a.verStr}`,a.source));let p=new T(x(),!0,n),c=e.repository??new q(r,p,new N(e.httpCache?{getFromCache:e.httpCache.getFromCache,onFetch:e.httpCache.onFetch}:void 0)),u=j(void 0);if(!e.repository){let a=x(),w=t=>{let m=O(a,t);return oe(m)?new Set(se(m).filter(k=>k.endsWith(".kan.yml")).map(k=>k.split("@")[0])):new Set},b=(t,m)=>o.some(k=>k.publisher===t&&k.package_===m),_=new V,i=new Map;for(let t of u)if(i.has(t.publisher)||i.set(t.publisher,w(t.publisher)),!(i.get(t.publisher).has(t.package_)||b(t.publisher,t.package_)))try{let m=await _.getHighestVersion(t.publisher,t.package_);if(!m)continue;let k=await _.getPackageUrl(t.publisher,t.package_,m),$=await fetch(k);if(!$.ok)continue;let ne=await $.text(),H=O(a,t.publisher);ie(H,{recursive:!0}),ae(O(H,`${t.package_}@${m}.kan.yml`),ne,"utf-8")}catch{}}let f=c;if(!e.repository){let a=(await r.getAllDocumentsAsync()).filter(b=>b.metadata.namespace_?.publisher===l),w=await A(a,c);for(let b of u)w.add(B(b));f=new K(c,w)}let y=await new F(n).parseKanonaks(f),D=new L(y);return E({publisher:l,availablePublishers:d,catalog:y,lookRenderer:D,localNamespaces:v,rawByNsKey:h})}import{existsSync as le,readFileSync as pe,writeFileSync as ue,mkdirSync as me}from"fs";import{join as ee}from"path";async function ge(s,e={}){let n=new M,r=I(s),o=r.kind==="resource"?r.uri.publisher:r.publisher,g=e.cacheRoot??x(),d=(i,t,m)=>ee(g,i,`${t}@${m}.kan.yml`),l=new N({getFromCache:(i,t,m)=>{let k=d(i,t,m);return le(k)?pe(k,"utf-8"):null},onFetch:(i,t,m,k)=>{let $=ee(g,i);me($,{recursive:!0}),ue(d(i,t,m),k,"utf-8")},...e.fetchFn?{fetchFn:e.fetchFn}:{}}),v=new V(e.fetchFn?{fetchFn:e.fetchFn}:void 0),h;if(r.kind==="resource"){let i=r.uri.version;h=[i?{package_:r.uri.package_,version:`${i.major}.${i.minor}.${i.patch}`}:{package_:r.uri.package_}]}else if(r.kind==="package"){let i=r.version;h=[i?{package_:r.package_,version:`${i.major}.${i.minor}.${i.patch}`}:{package_:r.package_}]}else h=(await v.listLatestPackages(o)).map(t=>({package_:t.packageName}));let p=async(i,t,m)=>{try{let k=m?n.buildImport(t,"=",m,i):n.buildImport(t,"*","0.0.0",i);return await l.getHighestCompatibleVersionAsync(i,k)}catch{return null}},c=[];for(let i of h){let t=await p(o,i.package_,i.version);t&&c.push(t)}if(c.length===0)throw new Error(`Could not fetch any package for address "${s}" from publisher "${o}".`);let u=await new Y().getConfig(o).catch(()=>{}),f=[];for(let i of j(u)){let t=await p(i.publisher,i.package_,void 0);t&&f.push(t)}let y=await A([...c,...f],l),D=new K(l,y),a=await new F(n).parseKanonaks(D),w=new L(a),b=new Set,_=new Map;for(let i of await l.getAllDocumentsAsync()){let t=i.metadata.namespace_;if(!t||t.publisher!==o)continue;let m=`${t.version.major}.${t.version.minor}.${t.version.patch}`,k=`${t.publisher}/${t.package_}@${m}`;b.add(k);let $=await l.getDocumentContentAsync(k);$!==null&&_.set(`${t.package_}@${m}`,$)}return E({publisher:o,availablePublishers:[o],catalog:a,lookRenderer:w,localNamespaces:b,rawByNsKey:_})}var S={".html":"text/html; charset=utf-8",".css":"text/css; charset=utf-8",".svg":"image/svg+xml",".md":"text/markdown; charset=utf-8",".kan.yml":"application/yaml; charset=utf-8",".txt":"text/plain; charset=utf-8",".json":"application/json; charset=utf-8"},R=(s,e,n,r)=>({status:s,headers:{"Content-Type":e,...r||{}},body:n}),P=s=>R(404,S[".html"],`<!doctype html><meta charset=utf-8><title>404</title><h1>404</h1><p>Not found: ${s}</p>`),de=s=>({status:301,headers:{Location:s},body:""});function re(s,e,n){let r=s.pkgVersions.get(e);if(!r||r.length===0)return null;switch(n.kind){case"any":return r[0].verStr;case"major-pin":return r.find(o=>o.version.major===n.major)?.verStr??null;case"minor-pin":return r.find(o=>o.version.major===n.major&&o.version.minor===n.minor)?.verStr??null;case"exact":return r.find(o=>o.version.major===n.major&&o.version.minor===n.minor&&o.version.patch===n.patch)?.verStr??null;default:return null}}function fe(s,e,n=""){let{lookRenderer:r,publisher:o}=s;if(e==="/.well-known/kanonak.json")return R(200,S[".json"],JSON.stringify(G(o),null,2));if(e==="/index.txt"){let c=[...s.localNamespaces].map(u=>u.split("/")[1].replace("@","/")).sort();return R(200,S[".txt"],c.join(`
2
2
  `)+`
3
- `)}if(e==="/"||e==="/index.html"||e==="/index.css"){let c=r.publisherSubject(s);return e==="/index.css"?f(200,g[".css"],r.renderStylesheet(c)):f(200,g[".html"],r.renderDocument(c,{rootIndex:!0}))}let d=".html",m=!1,u=e;for(let c of[".kan.yml",".css",".svg",".md",".html"])if(e.endsWith(c)){d=c,m=!0,u=e.slice(0,-c.length);break}let w=!m&&/application\/yaml|text\/yaml/i.test(t),b=u.endsWith("/");b&&u!=="/"&&(u=u.slice(0,-1));let i=J.parse(u,s);if(!i)return S(e);if(i.kind==="package"){let c=Z(o,i.package_,i.versionSpec);if(!c)return S(e);if(d===".kan.yml"||w){let D=o.rawByNsKey.get(`${i.package_}@${c}`);return D!==void 0?f(200,g[".kan.yml"],D):S(e)}let l=o.pkgSelfByVer.get(`${i.package_}@${c}`);if(!l)return S(e);if(d===".css")return f(200,g[".css"],r.renderStylesheet(l));if(!b)return ce(u+"/");let y=i.versionSpec.kind==="any";if(y&&!r.hasDeclaredView(l)){let D=(o.pkgVersions.get(i.package_)||[]).map(j=>j.verStr);return f(200,g[".html"],r.renderPackageVersionList(i.package_,D,l))}return f(200,g[".html"],r.renderDocument(l,y?{bareOverview:!0}:void 0))}if(i.kind==="resource"){let c=Z(o,i.package_,i.versionSpec);if(!c)return S(e);let l=o.bySubject.get(`${s}/${i.package_}@${c}/${i.name}`);if(!l)return S(e);switch(d){case".css":return f(200,g[".css"],r.renderStylesheet(l));case".svg":return f(200,g[".svg"],r.renderSvg(l));case".md":{let y=r.renderRawMarkdown(l);return y===void 0?S(e):f(200,g[".md"],y)}default:return f(200,g[".html"],r.renderDocument(l))}}return S(e)}export{$ as ClosureScopedRepository,V as deriveImportClosure,ie as loadServerModel,ae as route};
3
+ `)}if(e==="/"||e==="/index.html"||e==="/index.css"){let c=r.publisherSubject(o);return e==="/index.css"?R(200,S[".css"],r.renderStylesheet(c)):R(200,S[".html"],r.renderDocument(c,{rootIndex:!0}))}let g=".html",d=!1,l=e;for(let c of[".kan.yml",".css",".svg",".md",".html"])if(e.endsWith(c)){g=c,d=!0,l=e.slice(0,-c.length);break}let v=!d&&/application\/yaml|text\/yaml/i.test(n),h=l.endsWith("/");h&&l!=="/"&&(l=l.slice(0,-1));let p=Q.parse(l,o);if(!p)return P(e);if(p.kind==="package"){let c=re(s,p.package_,p.versionSpec);if(!c)return P(e);if(g===".kan.yml"||v){let y=s.rawByNsKey.get(`${p.package_}@${c}`);return y!==void 0?R(200,S[".kan.yml"],y):P(e)}let u=s.pkgSelfByVer.get(`${p.package_}@${c}`);if(!u)return P(e);if(g===".css")return R(200,S[".css"],r.renderStylesheet(u));if(!h)return de(l+"/");let f=p.versionSpec.kind==="any";if(f&&!r.hasDeclaredView(u)){let y=(s.pkgVersions.get(p.package_)||[]).map(D=>D.verStr);return R(200,S[".html"],r.renderPackageVersionList(p.package_,y,u))}return R(200,S[".html"],r.renderDocument(u,f?{bareOverview:!0}:void 0))}if(p.kind==="resource"){let c=re(s,p.package_,p.versionSpec);if(!c)return P(e);let u=s.bySubject.get(`${o}/${p.package_}@${c}/${p.name}`);if(!u)return P(e);switch(g){case".css":return R(200,S[".css"],r.renderStylesheet(u));case".svg":return R(200,S[".svg"],r.renderSvg(u));case".md":{let f=r.renderRawMarkdown(u);return f===void 0?P(e):R(200,S[".md"],f)}default:return R(200,S[".html"],r.renderDocument(u))}}return P(e)}export{K as ClosureScopedRepository,Z as UNIVERSAL_RENDER_BASE,A as deriveImportClosure,ge as loadResourceModel,ce as loadServerModel,B as renderRefKey,j as resolveRenderContract,fe as route};
@@ -0,0 +1,26 @@
1
+ import type { AuthenticatedFetchFn } from '../auth/index.js';
2
+ import type { ServerModel } from './types.js';
3
+ export interface LoadResourceModelOptions {
4
+ /** Authenticated fetch used for every HTTP request (config, index, package). */
5
+ fetchFn?: AuthenticatedFetchFn;
6
+ /** Override the global cache directory (the untrusted download accelerator). */
7
+ cacheRoot?: string;
8
+ }
9
+ /**
10
+ * Build a {@link ServerModel} seeded from a single Kanonak ADDRESS, fetching
11
+ * the resource's import closure over HTTP — the request-driven counterpart of
12
+ * `loadServerModel` (which seeds from a workspace on disk). A render is a pure
13
+ * function of `(the resource + its closure)`, and the address carries both: its
14
+ * first segment is the publisher, and the package's `imports:` give the
15
+ * transitive closure. So no `--publisher` flag and no workspace are needed.
16
+ *
17
+ * The pipeline reuses every #42 primitive: the HTTP repo fetches each package
18
+ * from its OWN publisher's config-driven endpoints (the closure may span
19
+ * publishers), verifying identity (`assertPackageIdentity`, inside the repo)
20
+ * before the global cache — an untrusted accelerator — keeps a raw copy;
21
+ * `deriveImportClosure` + `ClosureScopedRepository` scope the catalog so a
22
+ * polluted cache can't leak in; the look stack comes from the publisher's
23
+ * render contract (its `.well-known` override, else the universal kanonak.org
24
+ * base). The result is the same `ServerModel` shape `route` already consumes.
25
+ */
26
+ export declare function loadResourceModel(address: string, options?: LoadResourceModelOptions): Promise<ServerModel>;
@@ -0,0 +1,42 @@
1
+ import type { PublisherConfig } from '../repositories/index.js';
2
+ /** A render-stack package by canonical (publisher, package). */
3
+ export interface RenderPackageRef {
4
+ readonly publisher: string;
5
+ readonly package_: string;
6
+ }
7
+ /**
8
+ * The universal render base: the kanonak.org "look stack" the `LookRenderer`
9
+ * needs (the base stylesheet, the `--kan-*` design tokens, the `rdfs.Resource`
10
+ * look floor) but which NO document imports — the renderer discovers it
11
+ * ambiently by scanning the catalog. Every render closure includes this set so
12
+ * ANY publisher's pages render styled, exactly as a browser fetches a page's
13
+ * linked stylesheet. kanonak.org is the trust anchor for the base look
14
+ * contract, and it now publishes the whole stack over HTTP, so a request-driven
15
+ * render can fetch a fully-styled closure from the real origin.
16
+ *
17
+ * A publisher MAY override this by declaring its own `render` list in
18
+ * `.well-known/kanonak.json` (see {@link resolveRenderContract}) — the hybrid
19
+ * that keeps zero-config styling for normal publishers while making the stack
20
+ * explicit and overridable. This constant is the universal DEFAULT of that
21
+ * contract, not a hidden hardcode: it replaces the former implicit
22
+ * `WELL_KNOWN_RENDER_PACKAGES` list.
23
+ */
24
+ export declare const UNIVERSAL_RENDER_BASE: readonly RenderPackageRef[];
25
+ /**
26
+ * Resolve the render contract for a publisher from its fetched config. Returns
27
+ * the publisher's declared `render` list when present (each entry parsed
28
+ * through {@link parseKanonakAddress}, never string-sliced), else the
29
+ * {@link UNIVERSAL_RENDER_BASE}. This is the ONE place the "which look packages
30
+ * does a render need" decision is made — both the workspace builder
31
+ * (`loadServerModel`) and the request-driven builder (`loadResourceModel`)
32
+ * route through it.
33
+ *
34
+ * Render entries are package-level; a `@version` is accepted but the closure is
35
+ * version-agnostic (it resolves the highest compatible), so the version only
36
+ * documents intent for now. Publisher- or resource-kind entries are ignored
37
+ * (the render stack is packages). A malformed entry is skipped, never thrown —
38
+ * a bad render line must not break rendering.
39
+ */
40
+ export declare function resolveRenderContract(config: PublisherConfig | undefined): readonly RenderPackageRef[];
41
+ /** The closure-set key (`publisher/package`) for a render-stack ref. */
42
+ export declare function renderRefKey(ref: RenderPackageRef): string;
@@ -1,4 +1,4 @@
1
- import{b as X,c as ye}from"../chunk-ESYVKB25.js";import{a as Ne}from"../chunk-IIODYDKS.js";import"../chunk-3NEUHF7E.js";import"../chunk-CYDDQF6S.js";import"../chunk-NIGFQYVA.js";import{c as Ue}from"../chunk-VJT6YUWK.js";import{a as C,c as Ce}from"../chunk-H2LEQLVD.js";import{a as Re}from"../chunk-7CUTGGH3.js";import{b as E,c as F,d as f,f as M,l as Oe}from"../chunk-Q4DKP5DO.js";import{e as Le}from"../chunk-FQHALFRR.js";import"../chunk-64TVBQFR.js";import{b as K,c as w,d as b,g as L,h as U,i as O,j,k as T,l as S}from"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";var yt="kanonak.org",kt="document-ast",m=t=>({publisher:yt,package_:kt,name:t}),k={Document:m("Document"),Block:m("Block"),Inline:m("Inline"),StructuredValue:m("StructuredValue"),Heading:m("Heading"),Paragraph:m("Paragraph"),RawBlock:m("RawBlock"),Text:m("Text"),StructuredMap:m("StructuredMap"),StructuredEntry:m("StructuredEntry"),StructuredList:m("StructuredList"),StringScalar:m("StringScalar"),IntegerScalar:m("IntegerScalar"),EscapeHint:m("EscapeHint"),MediaType:m("MediaType"),metadata:m("metadata"),children:m("children"),level:m("level"),inlines:m("inlines"),text:m("text"),entries:m("entries"),key:m("key"),value:m("value"),escapeHint:m("escapeHint"),items:m("items"),stringValue:m("stringValue"),integerValue:m("integerValue"),rawContent:m("rawContent"),mediaType:m("mediaType"),mimeType:m("mimeType"),ESC_RAW:m("esc-raw"),ESC_YAML_SAFE:m("esc-yaml-safe"),ESC_TOML_STRING:m("esc-toml-string"),ESC_TOML_MULTILINE:m("esc-toml-multiline"),ESC_JSON:m("esc-json"),ESC_DYNAMODB_BOOL:m("esc-dynamodb-bool"),ESC_DYNAMODB_NUMBER:m("esc-dynamodb-number"),ESC_DYNAMODB_NULL:m("esc-dynamodb-null"),TEXT_PLAIN:m("text-plain"),TEXT_MARKDOWN:m("text-markdown"),TEXT_HTML:m("text-html"),TEXT_CSS:m("text-css"),APPLICATION_JSON:m("application-json"),TEXT_YAML:m("text-yaml"),IMAGE_SVG_XML:m("image-svg-xml"),ResourceLink:m("ResourceLink"),target:m("target"),linkLabel:m("linkLabel"),PropertyList:m("PropertyList"),propertyEntries:m("propertyEntries"),PropertyEntry:m("PropertyEntry"),propertyKey:m("propertyKey"),propertyValue:m("propertyValue"),Table:m("Table"),tableColumnLabels:m("tableColumnLabels"),tableRows:m("tableRows"),TableRow:m("TableRow"),tableCells:m("tableCells")};function Ie(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var Y=class{backendUri="kanonak.org/transformations/markdown-with-frontmatter";render(e,n){let r=ht(e.metadata,n),a=St(e.children),u=["---",...r,"---","",a].join(`
1
+ import{b as X,c as ye}from"../chunk-JYUZT2JU.js";import{a as Ne}from"../chunk-IUCHSPLQ.js";import"../chunk-3NEUHF7E.js";import"../chunk-7JZUJ2K4.js";import"../chunk-NIGFQYVA.js";import{c as Ue}from"../chunk-Q6QTQWR2.js";import{a as C,c as Ce}from"../chunk-H2LEQLVD.js";import{a as Re}from"../chunk-ORFSMEMM.js";import{b as E,c as F,d as f,f as M,l as Oe}from"../chunk-Q4DKP5DO.js";import"../chunk-64TVBQFR.js";import{b as K,c as w,d as b,g as L,h as U,i as O,j,k as T,l as S}from"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import{g as Le}from"../chunk-2ACBWC7K.js";var yt="kanonak.org",kt="document-ast",m=t=>({publisher:yt,package_:kt,name:t}),k={Document:m("Document"),Block:m("Block"),Inline:m("Inline"),StructuredValue:m("StructuredValue"),Heading:m("Heading"),Paragraph:m("Paragraph"),RawBlock:m("RawBlock"),Text:m("Text"),StructuredMap:m("StructuredMap"),StructuredEntry:m("StructuredEntry"),StructuredList:m("StructuredList"),StringScalar:m("StringScalar"),IntegerScalar:m("IntegerScalar"),EscapeHint:m("EscapeHint"),MediaType:m("MediaType"),metadata:m("metadata"),children:m("children"),level:m("level"),inlines:m("inlines"),text:m("text"),entries:m("entries"),key:m("key"),value:m("value"),escapeHint:m("escapeHint"),items:m("items"),stringValue:m("stringValue"),integerValue:m("integerValue"),rawContent:m("rawContent"),mediaType:m("mediaType"),mimeType:m("mimeType"),ESC_RAW:m("esc-raw"),ESC_YAML_SAFE:m("esc-yaml-safe"),ESC_TOML_STRING:m("esc-toml-string"),ESC_TOML_MULTILINE:m("esc-toml-multiline"),ESC_JSON:m("esc-json"),ESC_DYNAMODB_BOOL:m("esc-dynamodb-bool"),ESC_DYNAMODB_NUMBER:m("esc-dynamodb-number"),ESC_DYNAMODB_NULL:m("esc-dynamodb-null"),TEXT_PLAIN:m("text-plain"),TEXT_MARKDOWN:m("text-markdown"),TEXT_HTML:m("text-html"),TEXT_CSS:m("text-css"),APPLICATION_JSON:m("application-json"),TEXT_YAML:m("text-yaml"),IMAGE_SVG_XML:m("image-svg-xml"),ResourceLink:m("ResourceLink"),target:m("target"),linkLabel:m("linkLabel"),PropertyList:m("PropertyList"),propertyEntries:m("propertyEntries"),PropertyEntry:m("PropertyEntry"),propertyKey:m("propertyKey"),propertyValue:m("propertyValue"),Table:m("Table"),tableColumnLabels:m("tableColumnLabels"),tableRows:m("tableRows"),TableRow:m("TableRow"),tableCells:m("tableCells")};function Ie(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var Y=class{backendUri="kanonak.org/transformations/markdown-with-frontmatter";render(e,n){let r=ht(e.metadata,n),a=St(e.children),u=["---",...r,"---","",a].join(`
2
2
  `);return n?.trailingNewline&&(u.endsWith(`
3
3
  `)||(u+=`
4
4
  `)),u}};function ht(t,e){if(!t)return[];let n=new Map;for(let c of t.entries)n.set(ue(c.key),c);let r=new Map;if(e?.metadataRenames)for(let[c,l]of e.metadataRenames)r.set(ue(c),l);let i=(e?.metadataKeys??t.entries.map(c=>c.key)).map(ue),u=[];for(let c of i){let l=n.get(c);if(!l)continue;let p=r.get(c),y=ue(p??c),h=Me(l.value,l.escapeHint);h!==void 0&&u.push(`${y}: ${h}`)}return u}function ue(t){let e=t.lastIndexOf(".");return e===-1?t:t.substring(e+1)||t}function Me(t,e){switch(t.kind){case"StringScalar":return bt(t.stringValue,e);case"IntegerScalar":return String(t.integerValue);case"StructuredList":{let n=[];for(let r of t.items){let a=Me(r,e);a!==void 0&&n.push(a)}return n.join(", ")}case"StructuredMap":return;default:return}}function bt(t,e){return!e||Ie(e,k.ESC_RAW)?t:Ie(e,k.ESC_YAML_SAFE)?wt(t):t}function wt(t){return t.includes(`