@kanonak-protocol/sdk 3.28.5 → 3.28.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-JSYM5RWI.js +62 -0
- package/dist/index.js +1 -1
- package/dist/look/LookRenderer.d.ts +47 -0
- package/dist/transformations/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-QYWXCEHO.js +0 -50
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import{a as F}from"./chunk-NIGFQYVA.js";import{a as C}from"./chunk-QIIQ4G2Q.js";import{c as S,d,g as K,h as Q,i as X,j as g,k as w,l as m}from"./chunk-W6T7MOKY.js";function ee(u){let e=u.replace(/\r\n/g,`
|
|
2
|
+
`).split(`
|
|
3
|
+
`),t=[],n=0;for(;n<e.length;){let s=e[n];if(s.trim()===""){n++;continue}let o=/^(\s*)```(\S*)\s*$/.exec(s);if(o){let c=o[2],i=[];for(n++;n<e.length&&!/^(\s*)```\s*$/.test(e[n]);)i.push(e[n]),n++;n++;let l=ne(i.join(`
|
|
4
|
+
`)),p=c?` class="language-${te(c)}"`:"";t.push(`<pre><code${p}>${l}</code></pre>`);continue}let r=/^(#{1,6})\s+(.*)$/.exec(s);if(r){let c=r[1].length,i=E(r[2].trim());t.push(`<h${c}>${i}</h${c}>`),n++;continue}if(s.includes("|")&&n+1<e.length&&Z(e[n+1])){let c=B(s),i=ge(e[n+1]);n+=2;let l=[];for(;n<e.length&&e[n].trim()!==""&&e[n].includes("|");)l.push(B(e[n])),n++;t.push(ke(c,i,l));continue}if(/^\s*[-*]\s+/.test(s)){let c=[];for(;n<e.length&&/^\s*[-*]\s+/.test(e[n]);){let i=[e[n].replace(/^\s*[-*]\s+/,"")];for(n++;n<e.length&&e[n].trim()!==""&&!/^\s*[-*]\s+/.test(e[n])&&!/^\s*\d+\.\s+/.test(e[n]);)i.push(e[n]),n++;n<e.length&&e[n].trim()===""&&n++,c.push(`<li>${E(i.join(" ").trim())}</li>`)}t.push(`<ul>
|
|
5
|
+
${c.join(`
|
|
6
|
+
`)}
|
|
7
|
+
</ul>`);continue}if(/^\s*\d+\.\s+/.test(s)){let c=[];for(;n<e.length&&/^\s*\d+\.\s+/.test(e[n]);){let i=[e[n].replace(/^\s*\d+\.\s+/,"")];for(n++;n<e.length&&e[n].trim()!==""&&!/^\s*\d+\.\s+/.test(e[n])&&!/^\s*[-*]\s+/.test(e[n]);)i.push(e[n]),n++;n<e.length&&e[n].trim()===""&&n++,c.push(`<li>${E(i.join(" ").trim())}</li>`)}t.push(`<ol>
|
|
8
|
+
${c.join(`
|
|
9
|
+
`)}
|
|
10
|
+
</ol>`);continue}let a=[s];for(n++;n<e.length&&e[n].trim()!==""&&!/^(#{1,6})\s+/.test(e[n])&&!/^(\s*)```/.test(e[n])&&!/^\s*[-*]\s+/.test(e[n])&&!/^\s*\d+\.\s+/.test(e[n])&&!(e[n].includes("|")&&n+1<e.length&&Z(e[n+1]));)a.push(e[n]),n++;t.push(`<p>${E(a.join(" "))}</p>`)}return t.join(`
|
|
11
|
+
`)}function Z(u){return u.includes("-")?/^[\s|:-]+$/.test(u):!1}function B(u){let e=u.trim();return e.startsWith("|")&&(e=e.slice(1)),e.endsWith("|")&&(e=e.slice(0,-1)),e.split("|").map(t=>t.trim())}function ge(u){return B(u).map(e=>{let t=e.startsWith(":"),n=e.endsWith(":");return t&&n?"center":n?"right":t?"left":null})}function ke(u,e,t){let n=r=>{let a=e[r];return a?` style="text-align:${a}"`:""},s=u.map((r,a)=>`<th${n(a)}>${E(r)}</th>`).join(""),o=t.map(r=>`<tr>${r.map((c,i)=>`<td${n(i)}>${E(c)}</td>`).join("")}</tr>`).join(`
|
|
12
|
+
`);return`<table>
|
|
13
|
+
<thead><tr>${s}</tr></thead>
|
|
14
|
+
<tbody>
|
|
15
|
+
${o}
|
|
16
|
+
</tbody>
|
|
17
|
+
</table>`}function E(u){let e=ne(u);return e=e.replace(/`([^`\n]+)`/g,(t,n)=>`<code>${n}</code>`),e=e.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(t,n,s)=>`<a href="${te(s)}">${n}</a>`),e=e.replace(/\*\*([^*\n]+)\*\*/g,(t,n)=>`<strong>${n}</strong>`),e=e.replace(/(^|[^*])\*([^*\n]+)\*(?!\*)/g,(t,n,s)=>`${n}<em>${s}</em>`),e=e.replace(/(^|[\s(])_([^_\n]+)_(?=[\s).,;:!?]|$)/g,(t,n,s)=>`${n}<em>${s}</em>`),e}function ne(u){return u.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function te(u){return u.replace(/"/g,""").replace(/&/g,"&")}var G={publisher:"kanonak.org",package_:"derivation",name:"look"},M={publisher:"kanonak.org",package_:"derivation",name:"tokens"},$={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},y={publisher:"kanonak.org",package_:"core-rdf",name:"label"},se={publisher:"kanonak.org",package_:"core-rdf",name:"comment"},he={publisher:"kanonak.org",package_:"look",name:"Hero"},me={publisher:"kanonak.org",package_:"look",name:"PropertyList"},be={publisher:"kanonak.org",package_:"look",name:"BadgeRow"},je={publisher:"kanonak.org",package_:"look",name:"ChipRow"},_e={publisher:"kanonak.org",package_:"look",name:"ReferenceList"},re={publisher:"kanonak.org",package_:"look",name:"Markdown"},N={publisher:"kanonak.org",package_:"look",name:"NavGroup"},H={publisher:"kanonak.org",package_:"look",name:"NavLink"},oe={publisher:"kanonak.org",package_:"look",name:"target"},Re={publisher:"kanonak.org",package_:"look",name:"ResourceGrid"};var Ke={publisher:"kanonak.org",package_:"look",name:"semanticSvg"},ve={publisher:"kanonak.org",package_:"look",name:"tierChip"},Se={publisher:"kanonak.org",package_:"look",name:"tierIcon"},$e={publisher:"kanonak.org",package_:"look",name:"tierCard"},ye={publisher:"kanonak.org",package_:"look",name:"tierFull"};var D={publisher:"kanonak.org",package_:"look",name:"bands"},Le={publisher:"kanonak.org",package_:"look",name:"title"},Ue={publisher:"kanonak.org",package_:"look",name:"eyebrow"},Ie={publisher:"kanonak.org",package_:"look",name:"subtitle"},ae={publisher:"kanonak.org",package_:"look",name:"badges"},L={publisher:"kanonak.org",package_:"look",name:"source"},Oe={publisher:"kanonak.org",package_:"look",name:"chips"},W={publisher:"kanonak.org",package_:"look",name:"entries"},we={publisher:"kanonak.org",package_:"look",name:"urlForm"},J=class{constructor(e){this.catalog=e}catalog;findCascadedLook(e){let t=Y(e);if(t)return{declaration:t,sourceClass:{publisher:T(e),package_:(e.namespace||"").split("/")[1]?.split("@")[0]??"",name:e.name}};let n=new Set,s=v(e);for(;s.length>0;){let o=s.shift(),r=I(o.subject);if(n.has(r))continue;n.add(r);let a=b(this.catalog,o.subject);if(!a)continue;let c=Y(a);if(c)return{declaration:c,sourceClass:{publisher:o.subject.publisher,package_:o.subject.package_,name:o.subject.name}};for(let i of V(a))s.push(i)}if(!n.has(I($))){let o=b(this.catalog,$);if(o){let r=Y(o);if(r)return{declaration:r,sourceClass:{...$}}}}}findCascadedTokens(e){let t=new Map;for(let[o,r]of q(e))t.has(o)||t.set(o,r);let n=new Set,s=v(e);for(;s.length>0;){let o=s.shift(),r=I(o.subject);if(n.has(r))continue;n.add(r);let a=x(this.catalog,o.subject);if(a.length!==0)for(let c of a){for(let[i,l]of q(c))t.has(i)||t.set(i,l);for(let i of V(c))s.push(i)}}if(!n.has(I($))){let o=x(this.catalog,$);for(let r of o)for(let[a,c]of q(r))t.has(a)||t.set(a,c)}return t}renderSvg(e){let t=k(e,y)??e.name,n=(t.trim().charAt(0)||"?").toUpperCase(),s=`${e.namespace??""}/${e.name}`,o={label:t,firstLetter:n,uri:s},r=this.collectCascadedSvgTiers(e),a=O=>this.applyPlaceholders(O,e,o),c=a(r.tierChip??""),i=a(r.tierIcon??""),l=a(r.tierCard??""),p=a(r.tierFull??""),A=[...this.findCascadedTokens(e)].map(([O,P])=>`--kan-${O}: ${P};`).join(" ");return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400" width="400" height="400" style="${z(A)}">
|
|
18
|
+
<style>
|
|
19
|
+
.tier-chip,.tier-icon,.tier-card{display:none}
|
|
20
|
+
.tier-full{display:block}
|
|
21
|
+
@media (max-width:400px){.tier-full{display:none}.tier-card{display:block}}
|
|
22
|
+
@media (max-width:160px){.tier-card{display:none}.tier-icon{display:block}}
|
|
23
|
+
@media (max-width:60px){.tier-icon{display:none}.tier-chip{display:block}}
|
|
24
|
+
</style>
|
|
25
|
+
<g class="tier-chip">${c}</g>
|
|
26
|
+
<g class="tier-icon">${i}</g>
|
|
27
|
+
<g class="tier-card">${l}</g>
|
|
28
|
+
<g class="tier-full">${p}</g>
|
|
29
|
+
</svg>`}applyPlaceholders(e,t,n){return e.replace(/\{\{([^}]+)\}\}/g,(s,o)=>{let r=o.trim();if(n[r]!==void 0)return z(n[r]);let a=this.resolvePath(t,r);return a===void 0?`{{${r}}}`:z(a)})}resolvePath(e,t){let n=t.split("/").map(a=>a.trim()).filter(a=>a.length>0);if(n.length===0)return;let s=e;for(let a=0;a<n.length-1;a++){if(!s)return;let c=le(n[a]),i=fe(s,c);if(!i)return;if(i instanceof g&&i.object instanceof d){let l=b(this.catalog,i.object.subject);if(!l)return;s=l}else if(i instanceof w)s=i.object;else return}if(!s)return;let o=le(n[n.length-1]),r=fe(s,o);if(r){if(r instanceof K||r instanceof Q||r instanceof X)return String(r.object);if(r instanceof g&&r.object instanceof d){let a=r.object,c=b(this.catalog,a.subject);return c?k(c,y)??a.subject.name:a.subject.name}}}collectCascadedSvgTiers(e){let t={},n=r=>{let a=U(r,Ke);if(!(a instanceof w))return;let c=a.object,i=k(c,ve),l=k(c,Se),p=k(c,$e),h=k(c,ye);t.tierChip===void 0&&i!==void 0&&(t.tierChip=i),t.tierIcon===void 0&&l!==void 0&&(t.tierIcon=l),t.tierCard===void 0&&p!==void 0&&(t.tierCard=p),t.tierFull===void 0&&h!==void 0&&(t.tierFull=h)};n(e);let s=new Set,o=v(e);for(;o.length>0;){let r=o.shift(),a=I(r.subject);if(s.has(a))continue;s.add(a);let c=x(this.catalog,r.subject);for(let i of c){n(i);for(let l of V(i))o.push(l)}}if(!s.has(I($)))for(let r of x(this.catalog,$))n(r);return t}renderStylesheet(e){let t=this.findCascadedTokens(e),n=[];for(let[r,a]of t)n.push(` --kan-${r}: ${a};`);let s=n.length>0?`:root {
|
|
30
|
+
${n.join(`
|
|
31
|
+
`)}
|
|
32
|
+
}`:":root { /* no tokens resolved */ }",o=this.findBaseStylesheet(T(e))??"";return`${s}
|
|
33
|
+
${o}`}findBaseStylesheet(e){let t="kanonak.org/site/content",n,s;for(let r of this.catalog){if(!(r instanceof S)||r.name!=="base-stylesheet")continue;let a=r.namespace||"";a.startsWith(`${e}/look-styles@`)?n=r:a.startsWith("kanonak.org/look-styles@")&&(s=r)}let o=n??s;if(o)for(let r of o.statement){let a=r.predicate?.subject;if(!a)continue;if(`${a.publisher}/${a.package_}/${a.name}`===t&&r instanceof K)return r.object}}renderHtml(e){let t=this.findCascadedLook(e);if(!t)return`<!-- LookRenderer: no derivation.look found for ${e.namespace}/${e.name} -->`;let n=ie(t.declaration);if(n.length===0)return"<!-- LookRenderer: look declaration has no bands -->";let s=T(e),o=[];for(let r of n)o.push(this.renderBand(r,e,s));return o.join(`
|
|
34
|
+
`)}renderDocument(e){let t=this.renderHtml(e),n=this.readPropertyValueText(e,y)??e.name,s=`${e.name}.css`,o=this.hasSvgDerivation(e)?`<figure class="kan-figure"><img src="${f(e.name)}.svg" alt=""></figure>
|
|
35
|
+
`:"",r=T(e),a=this.renderNavGroup(e,r);return`<!doctype html>
|
|
36
|
+
<html lang="en">
|
|
37
|
+
<head>
|
|
38
|
+
<meta charset="utf-8">
|
|
39
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
40
|
+
<title>${f(n)}</title>
|
|
41
|
+
<link rel="stylesheet" href="${f(s)}">
|
|
42
|
+
</head>
|
|
43
|
+
<body>
|
|
44
|
+
${a}
|
|
45
|
+
<main class="kan-main">
|
|
46
|
+
${o}${t}
|
|
47
|
+
</main>
|
|
48
|
+
</body>
|
|
49
|
+
</html>
|
|
50
|
+
`}hasSvgDerivation(e){let t=new Set,n=v(e);for(;n.length>0;){let s=n.shift(),o=I(s.subject);if(t.has(o))continue;t.add(o);let r=b(this.catalog,s.subject);if(r){for(let a of r.statement)if(a instanceof m&&R(a,"kanonak.org","derivation","derivations")){for(let c of a.object??[])if(c instanceof C)for(let i of c.statement){if(!(i instanceof g)||!R(i,"kanonak.org","derivation","format")||!(i.object instanceof d))continue;let l=i.object.subject;if(l.publisher==="kanonak.org"&&l.package_==="formats"&&l.name==="svg")return!0}}for(let a of V(r))n.push(a)}}return!1}renderBand(e,t,n){let s=ce(e);return s?_(s,he)?this.renderHero(e,t,n):_(s,me)?this.renderPropertyList(e,t,n):_(s,be)?this.renderBadgeRow(e,t,n):_(s,je)?this.renderChipRow(e,t,n):_(s,_e)?this.renderReferenceList(e,t,n):_(s,re)?this.renderMarkdown(e,t):_(s,N)?this.renderNavGroup(t,n):_(s,Re)?this.renderResourceGrid(e,n,t):`<!-- LookRenderer: unsupported band ${s.publisher}/${s.package_}/${s.name} -->`:"<!-- LookRenderer: band has no rdf:type -->"}renderResourceGrid(e,t,n){let s=j(e,L);if(!s)return"<!-- LookRenderer.ResourceGrid: no look.source -->";let o=b(this.catalog,s),r=o?v(o).some(i=>{let l=i.subject.name;return l==="ObjectProperty"||l==="DatatypeProperty"||l==="Property"}):!1,a=[];if(r&&n){let i=this.readPropertyValueReferences(n,s);for(let l of i){let p=b(this.catalog,{publisher:l.subject.publisher,package_:l.subject.package_,name:l.subject.name,...l.subject.version?{version:l.subject.version}:{}});p&&a.push(p)}}else a=this.findInstancesOfClass(s);if(a.length===0)return`<!-- LookRenderer.ResourceGrid: no resources for ${s.publisher}/${s.package_}/${s.name} -->`;let c=[];for(let i of a){let l=k(i,y)??i.name,p=k(i,se),h=i.namespace||"",A=h.split("/")[1]?.split("@")[0]??"",O=h.split("@")[1]??"",P=O?this.parseVersion(O):void 0,pe=F.formatResourceUrl({publisher:T(i),package_:A,name:i.name,...P?{version:P}:{}},"=",{contextPublisher:t}),de=p?`<p class="kan-resource-card-subtitle">${f(p)}</p>`:"";c.push(`<a class="kan-resource-card" href="${f(pe)}"><h3 class="kan-resource-card-title">${f(l)}</h3>${de}</a>`)}return`<section class="kan-resource-grid">
|
|
51
|
+
${c.join(`
|
|
52
|
+
`)}
|
|
53
|
+
</section>`}parseVersion(e){let t=e.split(".").map(Number);if(!(t.length!==3||t.some(n=>Number.isNaN(n))))return{major:t[0],minor:t[1],patch:t[2]}}findInstancesOfClass(e){let t=[];for(let n of this.catalog){if(!(n instanceof S))continue;v(n).map(r=>r.subject).some(r=>r.publisher===e.publisher&&r.package_===e.package_&&r.name===e.name)&&t.push(n)}return t}renderNavGroup(e,t){let n=this.findNavGroupForPublisher(t);if(!n)return"";let s=U(n,W);if(!(s instanceof m))return"";let o=s.object??[];if(o.length===0)return"";let r=[];for(let a of o){if(!(a instanceof d))continue;let c=b(this.catalog,{publisher:a.subject.publisher,package_:a.subject.package_,name:a.subject.name}),{href:i,label:l}=this.resolveNavEntry(a,c,t),p=`/${e.namespace?.split("/")[1]?.split("@")[0]}/${(e.namespace||"").split("@")[1]}/${e.name}`,h=i===p?' aria-current="page"':"";r.push(`<li><a class="kan-nav-link" href="${f(i)}"${h}>${f(l)}</a></li>`)}return`<nav class="kan-site-nav"><ul>
|
|
54
|
+
${r.join(`
|
|
55
|
+
`)}
|
|
56
|
+
</ul></nav>`}resolveNavEntry(e,t,n){if(t&&v(t).map(c=>c.subject).some(c=>c.publisher===H.publisher&&c.package_===H.package_&&c.name===H.name)){let c=k(t,y),i=U(t,oe);if(i instanceof g&&i.object instanceof d){let l=i.object,p=this.readLabelForUri({publisher:l.subject.publisher,package_:l.subject.package_,name:l.subject.name});return{href:this.urlForReference(l,oe,n),label:c??p??l.subject.name}}}let s=F.formatResourceUrl({publisher:e.subject.publisher,package_:e.subject.package_,...e.subject.version?{version:e.subject.version}:{},name:e.subject.name},"*",{contextPublisher:n}),o=t?k(t,y)??e.subject.name:e.subject.name;return{href:s,label:o}}findNavGroupForPublisher(e){for(let t of this.catalog){if(!(t instanceof S)||!(t.namespace||"").startsWith(`${e}/`))continue;if(v(t).map(r=>r.subject).some(r=>r.publisher===N.publisher&&r.package_===N.package_&&r.name===N.name))return t}}renderMarkdown(e,t){let n=j(e,L);if(!n)return"<!-- LookRenderer.Markdown: no look.source -->";let s=this.readPropertyValueText(t,n);return s?`<section class="kan-markdown">
|
|
57
|
+
${ee(s)}
|
|
58
|
+
</section>`:""}renderRawMarkdown(e){let t=this.findCascadedLook(e);if(!t)return;let n=ie(t.declaration),s=[];for(let o of n){let r=ce(o);if(!r||!_(r,re))continue;let a=j(o,L);if(!a)continue;let c=this.readPropertyValueText(e,a);c&&s.push(c)}return s.length>0?s.join(`
|
|
59
|
+
|
|
60
|
+
`):void 0}renderHero(e,t,n){let s=['<header class="kan-hero">'],o=j(e,Ue);if(o){let l=this.readPropertyValueText(t,o);l&&s.push(`<span class="kan-hero-eyebrow">${f(l)}</span>`)}let r=j(e,Le),a="";r&&(a=this.readPropertyValueText(t,r)??""),a||(a=t.name),s.push(`<h1 class="kan-hero-title">${f(a)}</h1>`);let c=j(e,Ie);if(c){let l=this.readPropertyValueText(t,c);l&&s.push(`<p class="kan-hero-subtitle">${f(l)}</p>`)}let i=j(e,ae);if(i){let l=this.readPropertyValueReferences(t,i);if(l.length>0){let p=l.map(h=>this.renderBadge(h,ae,n)).join("");s.push(`<div class="kan-hero-badges">${p}</div>`)}}return s.push("</header>"),s.join(`
|
|
61
|
+
`)}renderPropertyList(e,t,n){let s=j(e,L);if(!s)return"<!-- LookRenderer: PropertyList missing look.source -->";let o=this.readLabelForUri(s)??s.name,r=U(t,s),a=this.gatherValueItems(r),c=a.length>0?a.map(i=>`<li>${this.renderInlineValue(i,L,n)}</li>`).join(""):'<li class="kan-empty">(no values)</li>';return['<section class="kan-property-list">',`<h3 class="kan-property-list-title">${f(o)}</h3>`,`<ul class="kan-property-list-items">${c}</ul>`,"</section>"].join(`
|
|
62
|
+
`)}renderBadgeRow(e,t,n){let s=j(e,L);if(!s)return"<!-- LookRenderer: BadgeRow missing look.source -->";let o=this.readPropertyValueReferences(t,s);return o.length===0?"":`<div class="kan-badge-row">${o.map(a=>this.renderBadge(a,L,n)).join("")}</div>`}renderChipRow(e,t,n){let s=ue(e,Oe);if(s.length===0)return"<!-- LookRenderer: ChipRow has no look.chips -->";let o=[];for(let r of s){let a=U(t,r);if(!a)continue;let c=this.readLabelForUri(r)??r.name,i=this.renderStatementInlineValue(a,r,n);i&&o.push(`<span class="kan-chip"><span class="kan-chip-key">${f(c)}</span> <span class="kan-chip-val">${i}</span></span>`)}return o.length===0?"":`<div class="kan-chip-row">${o.join("")}</div>`}renderReferenceList(e,t,n){let s=ue(e,W);if(s.length===0)return"<!-- LookRenderer: ReferenceList has no look.entries -->";let o=[];for(let r of s){let a=this.readPropertyValueReferences(t,r);if(a.length===0)continue;let c=this.readLabelForUri(r)??r.name,i=a.map(l=>this.renderReferenceLink(l,W,n)).join(", ");o.push(`<dt>${f(c)}</dt><dd>${i}</dd>`)}return o.length===0?"":`<dl class="kan-reference-list">${o.join("")}</dl>`}readPropertyValueText(e,t){let n=U(e,t);if(n){if(n instanceof K)return n.object;if(n instanceof g){let s=n.object;return this.readLabelForUri({publisher:s.subject.publisher,package_:s.subject.package_,name:s.subject.name})??s.subject.name}if(n instanceof m)return(n.object??[]).map(o=>o instanceof d?this.readLabelForUri({publisher:o.subject.publisher,package_:o.subject.package_,name:o.subject.name})??o.subject.name:o instanceof C?o.name??"":String(o)).filter(o=>o).join(", ")}}readPropertyValueReferences(e,t){let n=U(e,t);if(!n)return[];if(n instanceof g)return[n.object];if(n instanceof m){let s=[];for(let o of n.object??[])o instanceof d&&s.push(o);return s}return[]}gatherValueItems(e){return e?e instanceof m?e.object??[]:e instanceof g?[e.object]:e instanceof w?[e.object]:e instanceof K?[e.object]:[]:[]}renderInlineValue(e,t,n){return e instanceof d?this.renderReferenceLink(e,t,n):e instanceof C?f(e.name??"(embedded)"):typeof e=="string"?f(e):typeof e=="number"||typeof e=="boolean"?f(String(e)):""}renderStatementInlineValue(e,t,n){return e instanceof K?f(e.object):e instanceof g?this.renderReferenceLink(e.object,t,n):e instanceof m?(e.object??[]).map(o=>this.renderInlineValue(o,t,n)).filter(o=>o).join(", "):""}renderReferenceLink(e,t,n){let s=this.readLabelForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name})??e.subject.name,o=this.urlForReference(e,t,n);return`<a class="kan-link" href="${f(o)}">${f(s)}</a>`}renderBadge(e,t,n){let s=this.readLabelForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name})??e.subject.name,o=this.readCommentForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name}),r=this.urlForReference(e,t,n),a=o?` title="${f(o)}"`:"";return`<a class="kan-badge" href="${f(r)}"${a}>${f(s)}</a>`}urlForReference(e,t,n){let s=t?this.getUrlFormForProperty(t):"=";return F.formatResourceUrl({publisher:e.subject.publisher,package_:e.subject.package_,...e.subject.version?{version:e.subject.version}:{},name:e.subject.name},s,{contextPublisher:n})}getUrlFormForProperty(e){let t=b(this.catalog,e);if(!t)return"=";let n=k(t,we);return n==="*"||n==="^"||n==="~"||n==="="?n:"="}readLabelForUri(e){let t=b(this.catalog,e);if(t)return k(t,y)}readCommentForUri(e){let t=b(this.catalog,e);if(t)return k(t,se)}};function q(u){let e=new Map;for(let t of u.statement){if(!(t instanceof w)||!R(t,M.publisher,M.package_,M.name))continue;let n=t.object;for(let s of n.statement){if(!(s instanceof K))continue;let o=s.predicate?.subject?.name;if(!o)continue;let r=s.object;e.has(o)||e.set(o,r)}}return e}function Y(u){for(let e of u.statement)if(e instanceof w&&R(e,G.publisher,G.package_,G.name))return e.object}function ie(u){for(let e of u.statement){if(!(e instanceof m)||!R(e,D.publisher,D.package_,D.name))continue;let t=[];for(let n of e.object??[])n instanceof C&&t.push(n);return t}return[]}function ce(u){for(let e of u.statement)if(e instanceof g&&e.predicate?.subject?.name==="type"&&e.object instanceof d){let t=e.object.subject;return{publisher:t.publisher,package_:t.package_,name:t.name}}}function j(u,e){for(let t of u.statement)if(t instanceof g&&R(t,e.publisher,e.package_,e.name)&&t.object instanceof d){let n=t.object.subject;return{publisher:n.publisher,package_:n.package_,name:n.name}}}function ue(u,e){for(let t of u.statement){if(!(t instanceof m)||!R(t,e.publisher,e.package_,e.name))continue;let n=[];for(let s of t.object??[])s instanceof d&&n.push({publisher:s.subject.publisher,package_:s.subject.package_,name:s.subject.name});return n}return[]}function U(u,e){for(let t of u.statement)if(R(t,e.publisher,e.package_,e.name))return t}function k(u,e){for(let t of u.statement)if(t instanceof K&&R(t,e.publisher,e.package_,e.name))return t.object}function v(u){let e=[];for(let t of u.statement)if(t instanceof g){if(t.predicate?.subject?.name!=="type")continue;t.object instanceof d&&e.push(t.object)}else if(t instanceof m){if(t.predicate?.subject?.name!=="type")continue;for(let n of t.object??[])n instanceof d&&e.push(n)}return e}function V(u){let e=[];for(let t of u.statement)if(t instanceof g){if(t.predicate?.subject?.name!=="subClassOf")continue;t.object instanceof d&&e.push(t.object)}else if(t instanceof m){if(t.predicate?.subject?.name!=="subClassOf")continue;for(let n of t.object??[])n instanceof d&&e.push(n)}return e}function x(u,e){let t=[];for(let n of u){if(!(n instanceof S)||n.name!==e.name)continue;(n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`)&&t.push(n)}return t}function b(u,e){let t="version"in e?e.version:void 0;if(t){let n=`${e.publisher}/${e.package_}@${t.major}.${t.minor}.${t.patch}`;for(let s of u)if(s instanceof S&&s.name===e.name&&s.namespace===n)return s}for(let n of u){if(!(n instanceof S)||n.name!==e.name)continue;if((n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`))return n}}function R(u,e,t,n){let s=u.predicate?.subject;return s?s.publisher===e&&s.package_===t&&s.name===n:!1}function _(u,e){return u.publisher===e.publisher&&u.package_===e.package_&&u.name===e.name}function I(u){return`${u.publisher}/${u.package_}/${u.name}`}function T(u){let e=u.namespace||"",t=e.indexOf("/");return t>=0?e.substring(0,t):e}function f(u){return u.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function le(u){let e=u.lastIndexOf(".");return e>=0?u.substring(e+1):u}function fe(u,e){for(let t of u.statement)if(t.predicate?.subject?.name===e)return t}function z(u){return u.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}export{ee as a,J as b};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Ze,b as Qe,c as et,d as tt,e as rt,f as nt,g as ot,h as at,i as it,j as st}from"./chunk-JLFC6WKB.js";import{b as Yt}from"./chunk-
|
|
1
|
+
import{a as Ze,b as Qe,c as et,d as tt,e as rt,f as nt,g as ot,h as at,i as it,j as st}from"./chunk-JLFC6WKB.js";import{b as Yt}from"./chunk-JSYM5RWI.js";import{a as qe,b as Ye,c as Xe,d as b,e as S,f as i}from"./chunk-POFL6NMI.js";import{a as qt}from"./chunk-BQOD26BC.js";import{a as Te,b as je,c as Le,d as Fe,e as Ne}from"./chunk-AZSZXLEH.js";import{a as Be,b as De,c as Oe,d as Ae}from"./chunk-AV4AVTI6.js";import{a as lt,b as dt,c as ut,d as pt}from"./chunk-TWIWVG7W.js";import{a as Je,b as mt,c as ft,d as yt,e as ht}from"./chunk-4TJZIM7A.js";import{a as gt}from"./chunk-NIGFQYVA.js";import{A as Mt,B as zt,C as Gt,D as Wt,E as Jt,a as kt,b as bt,c as St,d as Ct,e as Pt,f as Rt,g as wt,h as xt,i as $t,j as vt,k as Et,l as Kt,m as Bt,n as It,o as Tt,p as jt,q as Lt,r as Ft,s as Nt,t as Dt,u as Ot,v as At,w as Ut,x as Vt,y as Ht,z as _t}from"./chunk-MV2LZFUK.js";import"./chunk-FJ35VIV6.js";import{a as F,b as D,c as Me,e as We}from"./chunk-QIIQ4G2Q.js";import{a as Ue,b as j,c as L,d as N,e as He,f as _e,g as O,h as A,i as U,j as V,k as H,l as _}from"./chunk-W6T7MOKY.js";import{a as Ie}from"./chunk-MYITGTGJ.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 ze,c as Ge}from"./chunk-5ILSX24H.js";import{a as Ve}from"./chunk-FUUTGGJS.js";import{a as ct}from"./chunk-ODIECDN7.js";import{VersionOperator as oo}from"@kanonak-protocol/types/document/models/enums";import{existsSync as fr,readFileSync as yr}from"fs";import{homedir as gr}from"os";import{join as hr}from"path";import{execFile as Xt}from"child_process";import{promisify as Zt}from"util";var C=Zt(Xt),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)}
|
|
@@ -73,6 +73,53 @@ export declare class LookRenderer {
|
|
|
73
73
|
* may resolve different accent colors etc.); the base rules are
|
|
74
74
|
* shared across the universal-look layer.
|
|
75
75
|
*/
|
|
76
|
+
/**
|
|
77
|
+
* Render the instance as a 4-tier responsive SVG.
|
|
78
|
+
*
|
|
79
|
+
* Inside the SVG, four `<g class="tier-X">` groups (tier-chip <60px,
|
|
80
|
+
* tier-icon 60-160, tier-card 160-400, tier-full >=400) wrap the
|
|
81
|
+
* content for each scale. CSS media queries on the SVG's rendered
|
|
82
|
+
* width show exactly one tier — the same file works as a favicon,
|
|
83
|
+
* sidebar tile, ResourceGrid card, or hero figure.
|
|
84
|
+
*
|
|
85
|
+
* v1: defaults only. Reads cascaded `look.title` and `look.subtitle`
|
|
86
|
+
* (or falls back to `rdfs.label` / `rdfs.comment`), and the resource's
|
|
87
|
+
* accent token. tier-chip is the accent circle alone; tier-icon adds
|
|
88
|
+
* the first letter; tier-card adds the full label; tier-full adds
|
|
89
|
+
* the subtitle plus the canonical URI footer.
|
|
90
|
+
*/
|
|
91
|
+
renderSvg(instance: SubjectKanonak): string;
|
|
92
|
+
/**
|
|
93
|
+
* Apply {{...}} placeholders to a slot SVG template.
|
|
94
|
+
*
|
|
95
|
+
* Specials (label, firstLetter, uri) substitute from the pre-computed
|
|
96
|
+
* `specials` map. Anything else is a property path expression: one or
|
|
97
|
+
* more `/`-separated steps; each step reads a property by local name
|
|
98
|
+
* (alias prefix is ignored — `wv.confidence` and `confidence` are
|
|
99
|
+
* equivalent). Mid-path values that are references or embeddeds are
|
|
100
|
+
* followed; the final value is rendered as text (strings/numbers
|
|
101
|
+
* verbatim, references as the target's rdfs.label).
|
|
102
|
+
*
|
|
103
|
+
* Examples — `{{wv.confidence/est.estimateMean}}` reads the embedded
|
|
104
|
+
* value then its number; `{{wv.status/rdfs.label}}` resolves the
|
|
105
|
+
* reference and reads its label.
|
|
106
|
+
*/
|
|
107
|
+
private applyPlaceholders;
|
|
108
|
+
/**
|
|
109
|
+
* Resolve a `/`-separated property path starting from `instance`. Each
|
|
110
|
+
* step matches a statement by predicate local name (alias prefix in
|
|
111
|
+
* the step is ignored for readability — `wv.confidence` and
|
|
112
|
+
* `confidence` both match). Returns the final value as a string, or
|
|
113
|
+
* undefined when the path doesn't resolve.
|
|
114
|
+
*/
|
|
115
|
+
private resolvePath;
|
|
116
|
+
/**
|
|
117
|
+
* Walk the instance's type chain (and rdfs.Resource floor), collecting
|
|
118
|
+
* the per-tier SVG fragment for each tier from the closest declarer.
|
|
119
|
+
* Each tier is filled independently — a class can override tierCard
|
|
120
|
+
* while inheriting tierChip from rdfs.Resource.
|
|
121
|
+
*/
|
|
122
|
+
private collectCascadedSvgTiers;
|
|
76
123
|
renderStylesheet(instance: SubjectKanonak): string;
|
|
77
124
|
/**
|
|
78
125
|
* Find the publisher-appropriate `base-stylesheet` Asset in the catalog
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as E,c as F,d as f,f as M}from"../chunk-2JQMUZWN.js";import{a as X,b as ye}from"../chunk-
|
|
1
|
+
import{b as E,c as F,d as f,f as M}from"../chunk-2JQMUZWN.js";import{a as X,b as ye}from"../chunk-JSYM5RWI.js";import{a as Oe}from"../chunk-BQOD26BC.js";import"../chunk-TWIWVG7W.js";import"../chunk-NIGFQYVA.js";import{a as Ue}from"../chunk-FJ35VIV6.js";import{a as C,c as Re,e as Ce}from"../chunk-QIIQ4G2Q.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{a as Le}from"../chunk-MYITGTGJ.js";import"../chunk-5ILSX24H.js";import"../chunk-FUUTGGJS.js";var gt="kanonak.org",yt="document-ast",m=t=>({publisher:gt,package_:yt,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 Ne(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=kt(e.metadata,n),a=wt(e.children),u=["---",...r,"---","",a].join(`
|
|
2
2
|
`);return n?.trailingNewline&&(u.endsWith(`
|
|
3
3
|
`)||(u+=`
|
|
4
4
|
`)),u}};function kt(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=Ie(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 Ie(t,e){switch(t.kind){case"StringScalar":return ht(t.stringValue,e);case"IntegerScalar":return String(t.integerValue);case"StructuredList":{let n=[];for(let r of t.items){let a=Ie(r,e);a!==void 0&&n.push(a)}return n.join(", ")}case"StructuredMap":return;default:return}}function ht(t,e){return!e||Ne(e,k.ESC_RAW)?t:Ne(e,k.ESC_YAML_SAFE)?bt(t):t}function bt(t){return t.includes(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanonak-protocol/sdk",
|
|
3
|
-
"version": "3.28.
|
|
3
|
+
"version": "3.28.7",
|
|
4
4
|
"description": "Kanonak Protocol SDK - Document repository and parsing implementations for TypeScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"yaml-parser"
|
|
114
114
|
],
|
|
115
115
|
"dependencies": {
|
|
116
|
-
"@kanonak-protocol/types": "^3.28.
|
|
116
|
+
"@kanonak-protocol/types": "^3.28.7",
|
|
117
117
|
"ignore": "^7.0.5",
|
|
118
118
|
"js-yaml": "^4.1.0",
|
|
119
119
|
"yaml": "^2.7.0"
|
package/dist/chunk-QYWXCEHO.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import{a as P}from"./chunk-NIGFQYVA.js";import{a as U}from"./chunk-QIIQ4G2Q.js";import{c as R,d as p,g as K,j as k,k as T,l as g}from"./chunk-W6T7MOKY.js";function z(i){let e=i.replace(/\r\n/g,`
|
|
2
|
-
`).split(`
|
|
3
|
-
`),t=[],n=0;for(;n<e.length;){let s=e[n];if(s.trim()===""){n++;continue}let r=/^(\s*)```(\S*)\s*$/.exec(s);if(r){let u=r[2],c=[];for(n++;n<e.length&&!/^(\s*)```\s*$/.test(e[n]);)c.push(e[n]),n++;n++;let f=J(c.join(`
|
|
4
|
-
`)),d=u?` class="language-${Q(u)}"`:"";t.push(`<pre><code${d}>${f}</code></pre>`);continue}let o=/^(#{1,6})\s+(.*)$/.exec(s);if(o){let u=o[1].length,c=L(o[2].trim());t.push(`<h${u}>${c}</h${u}>`),n++;continue}if(s.includes("|")&&n+1<e.length&&Y(e[n+1])){let u=N(s),c=ue(e[n+1]);n+=2;let f=[];for(;n<e.length&&e[n].trim()!==""&&e[n].includes("|");)f.push(N(e[n])),n++;t.push(fe(u,c,f));continue}if(/^\s*[-*]\s+/.test(s)){let u=[];for(;n<e.length&&/^\s*[-*]\s+/.test(e[n]);){let c=[e[n].replace(/^\s*[-*]\s+/,"")];for(n++;n<e.length&&e[n].trim()!==""&&!/^\s*[-*]\s+/.test(e[n])&&!/^\s*\d+\.\s+/.test(e[n]);)c.push(e[n]),n++;n<e.length&&e[n].trim()===""&&n++,u.push(`<li>${L(c.join(" ").trim())}</li>`)}t.push(`<ul>
|
|
5
|
-
${u.join(`
|
|
6
|
-
`)}
|
|
7
|
-
</ul>`);continue}if(/^\s*\d+\.\s+/.test(s)){let u=[];for(;n<e.length&&/^\s*\d+\.\s+/.test(e[n]);){let c=[e[n].replace(/^\s*\d+\.\s+/,"")];for(n++;n<e.length&&e[n].trim()!==""&&!/^\s*\d+\.\s+/.test(e[n])&&!/^\s*[-*]\s+/.test(e[n]);)c.push(e[n]),n++;n<e.length&&e[n].trim()===""&&n++,u.push(`<li>${L(c.join(" ").trim())}</li>`)}t.push(`<ol>
|
|
8
|
-
${u.join(`
|
|
9
|
-
`)}
|
|
10
|
-
</ol>`);continue}let a=[s];for(n++;n<e.length&&e[n].trim()!==""&&!/^(#{1,6})\s+/.test(e[n])&&!/^(\s*)```/.test(e[n])&&!/^\s*[-*]\s+/.test(e[n])&&!/^\s*\d+\.\s+/.test(e[n])&&!(e[n].includes("|")&&n+1<e.length&&Y(e[n+1]));)a.push(e[n]),n++;t.push(`<p>${L(a.join(" "))}</p>`)}return t.join(`
|
|
11
|
-
`)}function Y(i){return i.includes("-")?/^[\s|:-]+$/.test(i):!1}function N(i){let e=i.trim();return e.startsWith("|")&&(e=e.slice(1)),e.endsWith("|")&&(e=e.slice(0,-1)),e.split("|").map(t=>t.trim())}function ue(i){return N(i).map(e=>{let t=e.startsWith(":"),n=e.endsWith(":");return t&&n?"center":n?"right":t?"left":null})}function fe(i,e,t){let n=o=>{let a=e[o];return a?` style="text-align:${a}"`:""},s=i.map((o,a)=>`<th${n(a)}>${L(o)}</th>`).join(""),r=t.map(o=>`<tr>${o.map((u,c)=>`<td${n(c)}>${L(u)}</td>`).join("")}</tr>`).join(`
|
|
12
|
-
`);return`<table>
|
|
13
|
-
<thead><tr>${s}</tr></thead>
|
|
14
|
-
<tbody>
|
|
15
|
-
${r}
|
|
16
|
-
</tbody>
|
|
17
|
-
</table>`}function L(i){let e=J(i);return e=e.replace(/`([^`\n]+)`/g,(t,n)=>`<code>${n}</code>`),e=e.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(t,n,s)=>`<a href="${Q(s)}">${n}</a>`),e=e.replace(/\*\*([^*\n]+)\*\*/g,(t,n)=>`<strong>${n}</strong>`),e=e.replace(/(^|[^*])\*([^*\n]+)\*(?!\*)/g,(t,n,s)=>`${n}<em>${s}</em>`),e=e.replace(/(^|[\s(])_([^_\n]+)_(?=[\s).,;:!?]|$)/g,(t,n,s)=>`${n}<em>${s}</em>`),e}function J(i){return i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Q(i){return i.replace(/"/g,""").replace(/&/g,"&")}var C={publisher:"kanonak.org",package_:"derivation",name:"look"},V={publisher:"kanonak.org",package_:"derivation",name:"tokens"},O={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},I={publisher:"kanonak.org",package_:"core-rdf",name:"label"},X={publisher:"kanonak.org",package_:"core-rdf",name:"comment"},le={publisher:"kanonak.org",package_:"look",name:"Hero"},pe={publisher:"kanonak.org",package_:"look",name:"PropertyList"},de={publisher:"kanonak.org",package_:"look",name:"BadgeRow"},ke={publisher:"kanonak.org",package_:"look",name:"ChipRow"},ge={publisher:"kanonak.org",package_:"look",name:"ReferenceList"},Z={publisher:"kanonak.org",package_:"look",name:"Markdown"},F={publisher:"kanonak.org",package_:"look",name:"NavGroup"},B={publisher:"kanonak.org",package_:"look",name:"NavLink"},ee={publisher:"kanonak.org",package_:"look",name:"target"},he={publisher:"kanonak.org",package_:"look",name:"ResourceGrid"};var A={publisher:"kanonak.org",package_:"look",name:"bands"},me={publisher:"kanonak.org",package_:"look",name:"title"},be={publisher:"kanonak.org",package_:"look",name:"eyebrow"},je={publisher:"kanonak.org",package_:"look",name:"subtitle"},ne={publisher:"kanonak.org",package_:"look",name:"badges"},v={publisher:"kanonak.org",package_:"look",name:"source"},_e={publisher:"kanonak.org",package_:"look",name:"chips"},G={publisher:"kanonak.org",package_:"look",name:"entries"},Re={publisher:"kanonak.org",package_:"look",name:"urlForm"},x=class{constructor(e){this.catalog=e}catalog;findCascadedLook(e){let t=M(e);if(t)return{declaration:t,sourceClass:{publisher:w(e),package_:(e.namespace||"").split("/")[1]?.split("@")[0]??"",name:e.name}};let n=new Set,s=S(e);for(;s.length>0;){let r=s.shift(),o=E(r.subject);if(n.has(o))continue;n.add(o);let a=m(this.catalog,r.subject);if(!a)continue;let u=M(a);if(u)return{declaration:u,sourceClass:{publisher:r.subject.publisher,package_:r.subject.package_,name:r.subject.name}};for(let c of D(a))s.push(c)}if(!n.has(E(O))){let r=m(this.catalog,O);if(r){let o=M(r);if(o)return{declaration:o,sourceClass:{...O}}}}}findCascadedTokens(e){let t=new Map;for(let[r,o]of H(e))t.has(r)||t.set(r,o);let n=new Set,s=S(e);for(;s.length>0;){let r=s.shift(),o=E(r.subject);if(n.has(o))continue;n.add(o);let a=oe(this.catalog,r.subject);if(a.length!==0)for(let u of a){for(let[c,f]of H(u))t.has(c)||t.set(c,f);for(let c of D(u))s.push(c)}}if(!n.has(E(O))){let r=oe(this.catalog,O);for(let o of r)for(let[a,u]of H(o))t.has(a)||t.set(a,u)}return t}renderStylesheet(e){let t=this.findCascadedTokens(e),n=[];for(let[o,a]of t)n.push(` --kan-${o}: ${a};`);let s=n.length>0?`:root {
|
|
18
|
-
${n.join(`
|
|
19
|
-
`)}
|
|
20
|
-
}`:":root { /* no tokens resolved */ }",r=this.findBaseStylesheet(w(e))??"";return`${s}
|
|
21
|
-
${r}`}findBaseStylesheet(e){let t="kanonak.org/site/content",n,s;for(let o of this.catalog){if(!(o instanceof R)||o.name!=="base-stylesheet")continue;let a=o.namespace||"";a.startsWith(`${e}/look-styles@`)?n=o:a.startsWith("kanonak.org/look-styles@")&&(s=o)}let r=n??s;if(r)for(let o of r.statement){let a=o.predicate?.subject;if(!a)continue;if(`${a.publisher}/${a.package_}/${a.name}`===t&&o instanceof K)return o.object}}renderHtml(e){let t=this.findCascadedLook(e);if(!t)return`<!-- LookRenderer: no derivation.look found for ${e.namespace}/${e.name} -->`;let n=te(t.declaration);if(n.length===0)return"<!-- LookRenderer: look declaration has no bands -->";let s=w(e),r=[];for(let o of n)r.push(this.renderBand(o,e,s));return r.join(`
|
|
22
|
-
`)}renderDocument(e){let t=this.renderHtml(e),n=this.readPropertyValueText(e,I)??e.name,s=`${e.name}.css`,r=this.hasSvgDerivation(e)?`<figure class="kan-figure"><img src="${l(e.name)}.svg" alt=""></figure>
|
|
23
|
-
`:"",o=w(e),a=this.renderNavGroup(e,o);return`<!doctype html>
|
|
24
|
-
<html lang="en">
|
|
25
|
-
<head>
|
|
26
|
-
<meta charset="utf-8">
|
|
27
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
28
|
-
<title>${l(n)}</title>
|
|
29
|
-
<link rel="stylesheet" href="${l(s)}">
|
|
30
|
-
</head>
|
|
31
|
-
<body>
|
|
32
|
-
${a}
|
|
33
|
-
<main class="kan-main">
|
|
34
|
-
${r}${t}
|
|
35
|
-
</main>
|
|
36
|
-
</body>
|
|
37
|
-
</html>
|
|
38
|
-
`}hasSvgDerivation(e){let t=new Set,n=S(e);for(;n.length>0;){let s=n.shift(),r=E(s.subject);if(t.has(r))continue;t.add(r);let o=m(this.catalog,s.subject);if(o){for(let a of o.statement)if(a instanceof g&&j(a,"kanonak.org","derivation","derivations")){for(let u of a.object??[])if(u instanceof U)for(let c of u.statement){if(!(c instanceof k)||!j(c,"kanonak.org","derivation","format")||!(c.object instanceof p))continue;let f=c.object.subject;if(f.publisher==="kanonak.org"&&f.package_==="formats"&&f.name==="svg")return!0}}for(let a of D(o))n.push(a)}}return!1}renderBand(e,t,n){let s=se(e);return s?b(s,le)?this.renderHero(e,t,n):b(s,pe)?this.renderPropertyList(e,t,n):b(s,de)?this.renderBadgeRow(e,t,n):b(s,ke)?this.renderChipRow(e,t,n):b(s,ge)?this.renderReferenceList(e,t,n):b(s,Z)?this.renderMarkdown(e,t):b(s,F)?this.renderNavGroup(t,n):b(s,he)?this.renderResourceGrid(e,n,t):`<!-- LookRenderer: unsupported band ${s.publisher}/${s.package_}/${s.name} -->`:"<!-- LookRenderer: band has no rdf:type -->"}renderResourceGrid(e,t,n){let s=h(e,v);if(!s)return"<!-- LookRenderer.ResourceGrid: no look.source -->";let r=m(this.catalog,s),o=r?S(r).some(c=>{let f=c.subject.name;return f==="ObjectProperty"||f==="DatatypeProperty"||f==="Property"}):!1,a=[];if(o&&n){let c=this.readPropertyValueReferences(n,s);for(let f of c){let d=m(this.catalog,{publisher:f.subject.publisher,package_:f.subject.package_,name:f.subject.name,...f.subject.version?{version:f.subject.version}:{}});d&&a.push(d)}}else a=this.findInstancesOfClass(s);if(a.length===0)return`<!-- LookRenderer.ResourceGrid: no resources for ${s.publisher}/${s.package_}/${s.name} -->`;let u=[];for(let c of a){let f=$(c,I)??c.name,d=$(c,X),_=c.namespace||"",ae=_.split("/")[1]?.split("@")[0]??"",W=_.split("@")[1]??"",q=W?this.parseVersion(W):void 0,ie=P.formatResourceUrl({publisher:w(c),package_:ae,name:c.name,...q?{version:q}:{}},"=",{contextPublisher:t}),ce=d?`<p class="kan-resource-card-subtitle">${l(d)}</p>`:"";u.push(`<a class="kan-resource-card" href="${l(ie)}"><h3 class="kan-resource-card-title">${l(f)}</h3>${ce}</a>`)}return`<section class="kan-resource-grid">
|
|
39
|
-
${u.join(`
|
|
40
|
-
`)}
|
|
41
|
-
</section>`}parseVersion(e){let t=e.split(".").map(Number);if(!(t.length!==3||t.some(n=>Number.isNaN(n))))return{major:t[0],minor:t[1],patch:t[2]}}findInstancesOfClass(e){let t=[];for(let n of this.catalog){if(!(n instanceof R))continue;S(n).map(o=>o.subject).some(o=>o.publisher===e.publisher&&o.package_===e.package_&&o.name===e.name)&&t.push(n)}return t}renderNavGroup(e,t){let n=this.findNavGroupForPublisher(t);if(!n)return"";let s=y(n,G);if(!(s instanceof g))return"";let r=s.object??[];if(r.length===0)return"";let o=[];for(let a of r){if(!(a instanceof p))continue;let u=m(this.catalog,{publisher:a.subject.publisher,package_:a.subject.package_,name:a.subject.name}),{href:c,label:f}=this.resolveNavEntry(a,u,t),d=`/${e.namespace?.split("/")[1]?.split("@")[0]}/${(e.namespace||"").split("@")[1]}/${e.name}`,_=c===d?' aria-current="page"':"";o.push(`<li><a class="kan-nav-link" href="${l(c)}"${_}>${l(f)}</a></li>`)}return`<nav class="kan-site-nav"><ul>
|
|
42
|
-
${o.join(`
|
|
43
|
-
`)}
|
|
44
|
-
</ul></nav>`}resolveNavEntry(e,t,n){if(t&&S(t).map(u=>u.subject).some(u=>u.publisher===B.publisher&&u.package_===B.package_&&u.name===B.name)){let u=$(t,I),c=y(t,ee);if(c instanceof k&&c.object instanceof p){let f=c.object,d=this.readLabelForUri({publisher:f.subject.publisher,package_:f.subject.package_,name:f.subject.name});return{href:this.urlForReference(f,ee,n),label:u??d??f.subject.name}}}let s=P.formatResourceUrl({publisher:e.subject.publisher,package_:e.subject.package_,...e.subject.version?{version:e.subject.version}:{},name:e.subject.name},"*",{contextPublisher:n}),r=t?$(t,I)??e.subject.name:e.subject.name;return{href:s,label:r}}findNavGroupForPublisher(e){for(let t of this.catalog){if(!(t instanceof R)||!(t.namespace||"").startsWith(`${e}/`))continue;if(S(t).map(o=>o.subject).some(o=>o.publisher===F.publisher&&o.package_===F.package_&&o.name===F.name))return t}}renderMarkdown(e,t){let n=h(e,v);if(!n)return"<!-- LookRenderer.Markdown: no look.source -->";let s=this.readPropertyValueText(t,n);return s?`<section class="kan-markdown">
|
|
45
|
-
${z(s)}
|
|
46
|
-
</section>`:""}renderRawMarkdown(e){let t=this.findCascadedLook(e);if(!t)return;let n=te(t.declaration),s=[];for(let r of n){let o=se(r);if(!o||!b(o,Z))continue;let a=h(r,v);if(!a)continue;let u=this.readPropertyValueText(e,a);u&&s.push(u)}return s.length>0?s.join(`
|
|
47
|
-
|
|
48
|
-
`):void 0}renderHero(e,t,n){let s=['<header class="kan-hero">'],r=h(e,be);if(r){let f=this.readPropertyValueText(t,r);f&&s.push(`<span class="kan-hero-eyebrow">${l(f)}</span>`)}let o=h(e,me),a="";o&&(a=this.readPropertyValueText(t,o)??""),a||(a=t.name),s.push(`<h1 class="kan-hero-title">${l(a)}</h1>`);let u=h(e,je);if(u){let f=this.readPropertyValueText(t,u);f&&s.push(`<p class="kan-hero-subtitle">${l(f)}</p>`)}let c=h(e,ne);if(c){let f=this.readPropertyValueReferences(t,c);if(f.length>0){let d=f.map(_=>this.renderBadge(_,ne,n)).join("");s.push(`<div class="kan-hero-badges">${d}</div>`)}}return s.push("</header>"),s.join(`
|
|
49
|
-
`)}renderPropertyList(e,t,n){let s=h(e,v);if(!s)return"<!-- LookRenderer: PropertyList missing look.source -->";let r=this.readLabelForUri(s)??s.name,o=y(t,s),a=this.gatherValueItems(o),u=a.length>0?a.map(c=>`<li>${this.renderInlineValue(c,v,n)}</li>`).join(""):'<li class="kan-empty">(no values)</li>';return['<section class="kan-property-list">',`<h3 class="kan-property-list-title">${l(r)}</h3>`,`<ul class="kan-property-list-items">${u}</ul>`,"</section>"].join(`
|
|
50
|
-
`)}renderBadgeRow(e,t,n){let s=h(e,v);if(!s)return"<!-- LookRenderer: BadgeRow missing look.source -->";let r=this.readPropertyValueReferences(t,s);return r.length===0?"":`<div class="kan-badge-row">${r.map(a=>this.renderBadge(a,v,n)).join("")}</div>`}renderChipRow(e,t,n){let s=re(e,_e);if(s.length===0)return"<!-- LookRenderer: ChipRow has no look.chips -->";let r=[];for(let o of s){let a=y(t,o);if(!a)continue;let u=this.readLabelForUri(o)??o.name,c=this.renderStatementInlineValue(a,o,n);c&&r.push(`<span class="kan-chip"><span class="kan-chip-key">${l(u)}</span> <span class="kan-chip-val">${c}</span></span>`)}return r.length===0?"":`<div class="kan-chip-row">${r.join("")}</div>`}renderReferenceList(e,t,n){let s=re(e,G);if(s.length===0)return"<!-- LookRenderer: ReferenceList has no look.entries -->";let r=[];for(let o of s){let a=this.readPropertyValueReferences(t,o);if(a.length===0)continue;let u=this.readLabelForUri(o)??o.name,c=a.map(f=>this.renderReferenceLink(f,G,n)).join(", ");r.push(`<dt>${l(u)}</dt><dd>${c}</dd>`)}return r.length===0?"":`<dl class="kan-reference-list">${r.join("")}</dl>`}readPropertyValueText(e,t){let n=y(e,t);if(n){if(n instanceof K)return n.object;if(n instanceof k){let s=n.object;return this.readLabelForUri({publisher:s.subject.publisher,package_:s.subject.package_,name:s.subject.name})??s.subject.name}if(n instanceof g)return(n.object??[]).map(r=>r instanceof p?this.readLabelForUri({publisher:r.subject.publisher,package_:r.subject.package_,name:r.subject.name})??r.subject.name:r instanceof U?r.name??"":String(r)).filter(r=>r).join(", ")}}readPropertyValueReferences(e,t){let n=y(e,t);if(!n)return[];if(n instanceof k)return[n.object];if(n instanceof g){let s=[];for(let r of n.object??[])r instanceof p&&s.push(r);return s}return[]}gatherValueItems(e){return e?e instanceof g?e.object??[]:e instanceof k?[e.object]:e instanceof T?[e.object]:e instanceof K?[e.object]:[]:[]}renderInlineValue(e,t,n){return e instanceof p?this.renderReferenceLink(e,t,n):e instanceof U?l(e.name??"(embedded)"):typeof e=="string"?l(e):typeof e=="number"||typeof e=="boolean"?l(String(e)):""}renderStatementInlineValue(e,t,n){return e instanceof K?l(e.object):e instanceof k?this.renderReferenceLink(e.object,t,n):e instanceof g?(e.object??[]).map(r=>this.renderInlineValue(r,t,n)).filter(r=>r).join(", "):""}renderReferenceLink(e,t,n){let s=this.readLabelForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name})??e.subject.name,r=this.urlForReference(e,t,n);return`<a class="kan-link" href="${l(r)}">${l(s)}</a>`}renderBadge(e,t,n){let s=this.readLabelForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name})??e.subject.name,r=this.readCommentForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name}),o=this.urlForReference(e,t,n),a=r?` title="${l(r)}"`:"";return`<a class="kan-badge" href="${l(o)}"${a}>${l(s)}</a>`}urlForReference(e,t,n){let s=t?this.getUrlFormForProperty(t):"=";return P.formatResourceUrl({publisher:e.subject.publisher,package_:e.subject.package_,...e.subject.version?{version:e.subject.version}:{},name:e.subject.name},s,{contextPublisher:n})}getUrlFormForProperty(e){let t=m(this.catalog,e);if(!t)return"=";let n=$(t,Re);return n==="*"||n==="^"||n==="~"||n==="="?n:"="}readLabelForUri(e){let t=m(this.catalog,e);if(t)return $(t,I)}readCommentForUri(e){let t=m(this.catalog,e);if(t)return $(t,X)}};function H(i){let e=new Map;for(let t of i.statement){if(!(t instanceof T)||!j(t,V.publisher,V.package_,V.name))continue;let n=t.object;for(let s of n.statement){if(!(s instanceof K))continue;let r=s.predicate?.subject?.name;if(!r)continue;let o=s.object;e.has(r)||e.set(r,o)}}return e}function M(i){for(let e of i.statement)if(e instanceof T&&j(e,C.publisher,C.package_,C.name))return e.object}function te(i){for(let e of i.statement){if(!(e instanceof g)||!j(e,A.publisher,A.package_,A.name))continue;let t=[];for(let n of e.object??[])n instanceof U&&t.push(n);return t}return[]}function se(i){for(let e of i.statement)if(e instanceof k&&e.predicate?.subject?.name==="type"&&e.object instanceof p){let t=e.object.subject;return{publisher:t.publisher,package_:t.package_,name:t.name}}}function h(i,e){for(let t of i.statement)if(t instanceof k&&j(t,e.publisher,e.package_,e.name)&&t.object instanceof p){let n=t.object.subject;return{publisher:n.publisher,package_:n.package_,name:n.name}}}function re(i,e){for(let t of i.statement){if(!(t instanceof g)||!j(t,e.publisher,e.package_,e.name))continue;let n=[];for(let s of t.object??[])s instanceof p&&n.push({publisher:s.subject.publisher,package_:s.subject.package_,name:s.subject.name});return n}return[]}function y(i,e){for(let t of i.statement)if(j(t,e.publisher,e.package_,e.name))return t}function $(i,e){for(let t of i.statement)if(t instanceof K&&j(t,e.publisher,e.package_,e.name))return t.object}function S(i){let e=[];for(let t of i.statement)if(t instanceof k){if(t.predicate?.subject?.name!=="type")continue;t.object instanceof p&&e.push(t.object)}else if(t instanceof g){if(t.predicate?.subject?.name!=="type")continue;for(let n of t.object??[])n instanceof p&&e.push(n)}return e}function D(i){let e=[];for(let t of i.statement)if(t instanceof k){if(t.predicate?.subject?.name!=="subClassOf")continue;t.object instanceof p&&e.push(t.object)}else if(t instanceof g){if(t.predicate?.subject?.name!=="subClassOf")continue;for(let n of t.object??[])n instanceof p&&e.push(n)}return e}function oe(i,e){let t=[];for(let n of i){if(!(n instanceof R)||n.name!==e.name)continue;(n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`)&&t.push(n)}return t}function m(i,e){let t="version"in e?e.version:void 0;if(t){let n=`${e.publisher}/${e.package_}@${t.major}.${t.minor}.${t.patch}`;for(let s of i)if(s instanceof R&&s.name===e.name&&s.namespace===n)return s}for(let n of i){if(!(n instanceof R)||n.name!==e.name)continue;if((n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`))return n}}function j(i,e,t,n){let s=i.predicate?.subject;return s?s.publisher===e&&s.package_===t&&s.name===n:!1}function b(i,e){return i.publisher===e.publisher&&i.package_===e.package_&&i.name===e.name}function E(i){return`${i.publisher}/${i.package_}/${i.name}`}function w(i){let e=i.namespace||"",t=e.indexOf("/");return t>=0?e.substring(0,t):e}function l(i){return i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}export{z as a,x as b};
|