@kanonak-protocol/sdk 3.28.8 → 3.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +1 -1
- package/dist/{chunk-JLFC6WKB.js → chunk-2BQ6SOU6.js} +1 -1
- package/dist/{chunk-BQOD26BC.js → chunk-2VCFHCFN.js} +1 -1
- package/dist/{chunk-QIIQ4G2Q.js → chunk-4YHWMYAZ.js} +1 -1
- package/dist/{chunk-AZSZXLEH.js → chunk-5AH6GIPO.js} +1 -1
- package/dist/chunk-7CUTGGH3.js +1 -0
- package/dist/{chunk-MV2LZFUK.js → chunk-A2JTW3ON.js} +2 -2
- package/dist/chunk-BNSBR6LR.js +66 -0
- package/dist/{chunk-TWIWVG7W.js → chunk-IIP6J4EP.js} +1 -1
- package/dist/{chunk-POFL6NMI.js → chunk-REH5YNFQ.js} +1 -1
- package/dist/{chunk-AV4AVTI6.js → chunk-VQFL5C7Q.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/parsing/index.js +1 -1
- package/dist/reasoning/index.js +1 -1
- package/dist/repositories/browser.js +1 -1
- package/dist/repositories/index.js +1 -1
- package/dist/transformations/index.js +1 -1
- package/dist/validation/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-ITS5BOWM.js +0 -66
- package/dist/chunk-MYITGTGJ.js +0 -1
package/dist/browser.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as ge,b as fe,c as me,d as C,e as E,f as d}from"./chunk-
|
|
1
|
+
import{a as ge,b as fe,c as me,d as C,e as E,f as d}from"./chunk-REH5YNFQ.js";import{a as Ye}from"./chunk-2VCFHCFN.js";import{a as H,b as L,c as W,d as F}from"./chunk-VQFL5C7Q.js";import{a as Pe,b as we,c as he}from"./chunk-IIP6J4EP.js";import{a as ye,b as ke,e as be}from"./chunk-4TJZIM7A.js";import"./chunk-NIGFQYVA.js";import{A as We,B as Fe,C as Ge,D as Xe,E as Qe,a as Ke,b as xe,c as Se,d as Re,f as De,g as Be,h as Ce,i as Ee,j as je,k as ve,l as _e,m as Ae,n as Ie,o as Te,p as Oe,q as Ve,r as $e,s as Ue,t as ze,u as Me,v as Ne,w as Je,x as He,y as qe,z as Le}from"./chunk-A2JTW3ON.js";import"./chunk-FJ35VIV6.js";import{a as Y,c as le,e as pe}from"./chunk-4YHWMYAZ.js";import{a as G,b as X,c as Q,d as ee,e as re,f as te,g as ne,h as oe,i as se,j as ie,k as ae,l as ce}from"./chunk-W6T7MOKY.js";import{a as q}from"./chunk-7CUTGGH3.js";import{a as O,b as V,c as $,d as U,e as z,f as M,g as N,h as J}from"./chunk-FQHALFRR.js";import{b as ue,c as de}from"./chunk-5ILSX24H.js";import{a as Z}from"./chunk-FUUTGGJS.js";var j="kanonak-credentials",u="credentials",Ze=1,f=class{async get(r){let e=d(r),t=await h();return new Promise((o,a)=>{let s=t.transaction(u,"readonly"),i=s.objectStore(u).get(e);i.onsuccess=()=>o(i.result??null),i.onerror=()=>a(new Error(`IndexedDB read failed for '${e}': ${i.error?.message}`)),s.oncomplete=()=>t.close()})}async store(r,e){let t=d(r),o=await h();return new Promise((a,s)=>{let l=o.transaction(u,"readwrite"),c=l.objectStore(u).put(e,t);c.onsuccess=()=>a(),c.onerror=()=>s(new Error(`IndexedDB write failed for '${t}': ${c.error?.message}`)),l.oncomplete=()=>o.close()})}async remove(r){let e=d(r),t=await h();return new Promise((o,a)=>{let s=t.transaction(u,"readwrite"),i=s.objectStore(u).delete(e);i.onsuccess=()=>o(),i.onerror=()=>a(new Error(`IndexedDB delete failed for '${e}': ${i.error?.message}`)),s.oncomplete=()=>t.close()})}async list(){let r=await h();return new Promise((e,t)=>{let o=r.transaction(u,"readonly"),s=o.objectStore(u).getAllKeys();s.onsuccess=()=>e(s.result??[]),s.onerror=()=>t(new Error(`IndexedDB list failed: ${s.error?.message}`)),o.oncomplete=()=>r.close()})}};function h(){return new Promise((n,r)=>{let e=indexedDB.open(j,Ze);e.onupgradeneeded=()=>{let t=e.result;t.objectStoreNames.contains(u)||t.createObjectStore(u)},e.onsuccess=()=>n(e.result),e.onerror=()=>r(new Error(`Failed to open IndexedDB '${j}': ${e.error?.message}
|
|
2
2
|
Credential storage requires IndexedDB support in your browser.`))})}async function _(){let n=await crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),r=await crypto.subtle.exportKey("jwk",n.publicKey);return{signingKey:n.privateKey,publicKeyJwk:r}}async function k(){let n=await crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},!0,["sign"]),r=await crypto.subtle.exportKey("jwk",n.publicKey),e=await crypto.subtle.exportKey("jwk",n.privateKey);return{keys:{signingKey:n.privateKey,publicKeyJwk:r},dpopKeyPair:{publicKey:r,privateKey:e}}}async function b(n){return{signingKey:await crypto.subtle.importKey("jwk",n.privateKey,{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),publicKeyJwk:n.publicKey}}async function K(n,r,e,t,o){let a={alg:"ES256",typ:"dpop+jwt",jwk:{kty:n.publicKeyJwk.kty,crv:n.publicKeyJwk.crv,x:n.publicKeyJwk.x,y:n.publicKeyJwk.y}},s={jti:crypto.randomUUID(),htm:r.toUpperCase(),htu:e,iat:Math.floor(Date.now()/1e3)};return t&&(s.ath=await rr(t)),o&&(s.nonce=o),await er(a,s,n.signingKey)}function x(n){return!n||n.length===0?!1:n.some(r=>r.toUpperCase()==="ES256")}async function er(n,r,e){let t=v(JSON.stringify(n)),o=v(JSON.stringify(r)),a=new TextEncoder().encode(`${t}.${o}`),s=await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},e,a),l=D(s);return`${t}.${o}.${l}`}async function rr(n){let r=new TextEncoder().encode(n),e=await crypto.subtle.digest("SHA-256",r);return D(e)}function v(n){let r=new TextEncoder().encode(n);return D(r.buffer)}function D(n){let r=new Uint8Array(n),e="";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}var tr=300*1e3,S=class{credentialBackend;callbackUrl;constructor(r){this.credentialBackend=new f,this.callbackUrl=r??`${window.location.origin}/browser/callback.html`}async authorize(r){let e=d(r),t=await this.discover(e);if(!t)return{success:!1,error:`No OAuth discovery endpoint found for '${e}'.`};if(!t.authorizationEndpoint||!t.tokenEndpoint)return{success:!1,error:`OAuth metadata incomplete for '${e}'.`};let o=x(t.dpopSigningAlgValuesSupported),a=null,s=null;if(o){let g=await k();a=g.keys,s=g.dpopKeyPair}let l=await this.credentialBackend.get(e),i=l?.clientId??null,c=l?.clientSecret??null;if(!i&&t.registrationEndpoint){let g=await this.registerClient(t.registrationEndpoint);if(!g)return{success:!1,error:`Dynamic client registration failed for '${e}'.`};i=g.clientId,c=g.clientSecret??null}if(!i)return{success:!1,error:`No OAuth client credentials for '${e}'.`};let m=nr(),p=await or(m),R=sr(),I=ir(t.authorizationEndpoint,i,this.callbackUrl,R,p),y=await this.openAuthPopup(I,R);if(!y)return{success:!1,error:"Authorization timed out or was cancelled."};if(y.error)return{success:!1,error:`Authorization failed: ${y.error}`};if(!y.code)return{success:!1,error:"No authorization code received."};if(y.state!==R)return{success:!1,error:"State mismatch \u2014 possible CSRF attack."};let P=await this.exchangeCode(t.tokenEndpoint,i,c,y.code,this.callbackUrl,m,a);if(!P)return{success:!1,error:"Token exchange failed."};let T={clientId:i,clientSecret:c,accessToken:P.accessToken??null,refreshToken:P.refreshToken??null,expiresAt:P.expiresIn?new Date(Date.now()+P.expiresIn*1e3).toISOString():null,tokenEndpoint:t.tokenEndpoint,dpopKeyPair:s};return await this.credentialBackend.store(e,T),{success:!0,host:e}}async getCredentialWithKeys(r){let e=await this.credentialBackend.get(r);if(!e)return null;let t=null;return e.dpopKeyPair&&(t=await b(e.dpopKeyPair)),{credential:e,dpopKeys:t}}async logout(r){let e=d(r);return await this.credentialBackend.remove(e),{success:!0,host:e}}async listAuthenticated(){return this.credentialBackend.list()}async discover(r){for(let e of[`https://${r}/.well-known/oauth-authorization-server`,`https://${r}/.well-known/openid-configuration`])try{let t=await fetch(e);if(!t.ok)continue;let o=await t.json();return{issuer:w(o.issuer),authorizationEndpoint:w(o.authorization_endpoint),tokenEndpoint:w(o.token_endpoint),registrationEndpoint:w(o.registration_endpoint),revocationEndpoint:w(o.revocation_endpoint),dpopSigningAlgValuesSupported:A(o.dpop_signing_alg_values_supported),codeChallengeMethodsSupported:A(o.code_challenge_methods_supported)}}catch{continue}return null}async registerClient(r){try{let e=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:"Kanonak Browser",redirect_uris:[this.callbackUrl],grant_types:["authorization_code","refresh_token"],response_types:["code"],token_endpoint_auth_method:"none"})});if(!e.ok)return null;let t=await e.json(),o=t.client_id;return o?{clientId:o,clientSecret:t.client_secret}:null}catch{return null}}openAuthPopup(r,e){return new Promise(t=>{let o=window.open(r,"kanonak-auth","width=500,height=700,menubar=no,toolbar=no,location=yes,status=no");if(!o){t(null);return}let a=setTimeout(()=>{i(),t(null)},tr),s=c=>{c.origin===window.location.origin&&(!c.data||c.data.type!=="kanonak-auth-callback"||(i(),t({code:c.data.code??void 0,state:c.data.state??void 0,error:c.data.error??void 0})))},l=setInterval(()=>{o.closed&&(i(),t(null))},500),i=()=>{clearTimeout(a),clearInterval(l),window.removeEventListener("message",s);try{o.close()}catch{}};window.addEventListener("message",s)})}async exchangeCode(r,e,t,o,a,s,l){let i=new URLSearchParams({grant_type:"authorization_code",client_id:e,code:o,redirect_uri:a,code_verifier:s});t&&i.set("client_secret",t);let c={"Content-Type":"application/x-www-form-urlencoded"};l&&(c.DPoP=await K(l,"POST",r));try{let m=await fetch(r,{method:"POST",headers:c,body:i.toString()});if(!m.ok)return null;let p=await m.json();return{accessToken:p.access_token,refreshToken:p.refresh_token,expiresIn:typeof p.expires_in=="number"?p.expires_in:void 0}}catch{return null}}};function nr(){let n=new Uint8Array(32);return crypto.getRandomValues(n),B(n.buffer)}async function or(n){let r=new TextEncoder().encode(n),e=await crypto.subtle.digest("SHA-256",r);return B(e)}function sr(){let n=new Uint8Array(16);return crypto.getRandomValues(n),B(n.buffer)}function ir(n,r,e,t,o){let a=new URLSearchParams({client_id:r,response_type:"code",redirect_uri:e,state:t,code_challenge:o,code_challenge_method:"S256"});return`${n}?${a}`}function B(n){let r=new Uint8Array(n),e="";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function w(n){return typeof n=="string"?n:null}function A(n){return Array.isArray(n)?n.filter(r=>typeof r=="string"):null}export{Je as AmbiguousReferenceRule,se as BooleanStatement,f as BrowserCredentialBackend,S as BrowserOAuthFlow,Ge as ClassDefinitionRule,Ie as ClassHierarchyCycleRule,X as DefinedKanonak,Me as DefinitionPropertyReferenceRule,fe as EdgeType,Y as EmbeddedKanonak,je as EmbeddedKanonakTypeRule,ae as EmbeddedStatement,me as GraphBuilder,F as HttpKanonakDocumentRepository,ve as ImportExistenceRule,H as InMemoryKanonakDocumentRepository,ze as InstancePropertyReferenceRule,G as Kanonak,we as KanonakDocumentPositions,pe as KanonakObjectParser,Qe as KanonakObjectValidator,q as KanonakParser,Z as KanonakUri,ke as KanonakUriBuilder,ce as ListStatement,Xe as MarkdownLinkRule,le as MarkdownStatement,Ue as NamespaceImportCycleRule,De as NamespacePrefixRule,ge as NodeType,oe as NumberStatement,qe as ObjectPropertyImportRule,Le as ObjectPropertyValueValidationRule,Se as OntologyValidationError,Ke as OntologyValidationResult,We as PropertyDomainRule,Te as PropertyHierarchyCycleRule,Pe as PropertyMetadata,He as PropertyRangeReferenceRule,Oe as PropertyRangeRequiredRule,Ce as PropertyTypeSpecificityRule,Fe as PropertyValueTypeRule,L as PublisherConfigResolver,W as PublisherIndex,ee as ReferenceKanonak,ie as ReferenceStatement,Be as ResourceNamingRule,ue as ResourceResolver,ye as ResourceTypeClassifier,te as ScalarStatement,re as Statement,ne as StringStatement,Ve as SubClassOfReferenceRule,$e as SubPropertyOfReferenceRule,Q as SubjectKanonak,Ee as SubjectKanonakTypeRequiredRule,Ae as TypeAmbiguityRule,de as TypeResolver,_e as UnresolvedReferenceRule,Re as ValidationContext,xe as ValidationSeverity,Ne as XsdImportRule,x as browserServerSupportsDPoP,O as compareVersions,K as createBrowserDPoPProof,U as createVersion,Ye as findDerivation,be as findInstancesByType,$ as formatVersion,k as generateBrowserDPoPKeyPair,_ as generateBrowserDPoPKeys,E as hasValidToken,b as importDPoPKeys,M as isCompatibleVersion,C as isExpired,N as isMajorCompatible,d as normalizeHost,z as parseVersionString,he as parseWithPositions,J as pickHighestDocument,V as versionsEqual};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as S,b as j,e as w}from"./chunk-
|
|
1
|
+
import{a as S,b as j,e as w}from"./chunk-4YHWMYAZ.js";import{c as x,d as g,g as T,h as I,i as v,j as $,k as q,l as L}from"./chunk-W6T7MOKY.js";function u(t){return`${t.publisher}/${t.package_}/${t.name}`}function c(t,e,r){return`${t}/${e}/${r}`}function k(t){return`${t.s}|${t.p}|${P(t.o)}`}function P(t){switch(t.kind){case"uri":return`u:${t.key}`;case"literal":return`l:${t.datatype}:${t.lexical}`;case"blank":return`b:${t.id}`}}function s(t,e,r){return{s:t,p:e,o:{kind:"uri",key:r}}}var y=class{all=new Set;byPIdx=new Map;bySPIdx=new Map;byPOIdx=new Map;tripleList=[];add(e){let r=k(e);return this.all.has(r)?!1:(this.all.add(r),this.tripleList.push(e),h(this.byPIdx,e.p,e),h(this.bySPIdx,`${e.s}|${e.p}`,e),e.o.kind==="uri"&&h(this.byPOIdx,`${e.p}|${e.o.key}`,e),!0)}has(e){return this.all.has(k(e))}size(){return this.tripleList.length}snapshot(){return this.tripleList.slice()}byPredicate(e){let r=this.byPIdx.get(e);return r?r.slice():[]}bySubjectPredicate(e,r){let o=this.bySPIdx.get(`${e}|${r}`);return o?o.slice():[]}byPredicateObject(e,r){let o=this.byPOIdx.get(`${e}|${r}`);return o?o.slice():[]}subjectsWithPredicateObject(e,r){let o=this.byPOIdx.get(`${e}|${r}`);if(!o)return[];let i=new Set;for(let a of o)i.add(a.s);return Array.from(i)}uriObjectsOf(e,r){let o=this.bySPIdx.get(`${e}|${r}`);if(!o)return[];let i=new Set;for(let a of o)a.o.kind==="uri"&&i.add(a.o.key);return Array.from(i)}hasUri(e,r,o){return this.all.has(`${e}|${r}|u:${o}`)}hasTriple(e,r,o){return this.all.has(`${e}|${r}|${P(o)}`)}};function h(t,e,r){let o=t.get(e);o?o.push(r):t.set(e,[r])}var d=class{type=c("kanonak.org","core-rdf","type");subClassOf=c("kanonak.org","core-rdf","subClassOf");subPropertyOf=c("kanonak.org","core-rdf","subPropertyOf");domain=c("kanonak.org","core-rdf","domain");range=c("kanonak.org","core-rdf","range");equivalentClass=c("kanonak.org","core-owl","equivalentClass");equivalentProperty=c("kanonak.org","core-owl","equivalentProperty");inverseOf=c("kanonak.org","core-owl","inverseOf");sameAs=c("kanonak.org","core-owl","sameAs");transitiveProperty=c("kanonak.org","core-owl","TransitiveProperty");symmetricProperty=c("kanonak.org","core-owl","SymmetricProperty")};var _={name:"rdfs2",apply(t,e){let r=!1;for(let o of t.byPredicate(e.domain)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;for(let n of t.byPredicate(i))t.add(s(n.s,e.type,a))&&(r=!0)}return r}},E={name:"rdfs3",apply(t,e){let r=!1;for(let o of t.byPredicate(e.range)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;for(let n of t.byPredicate(i))n.o.kind==="uri"&&t.add(s(n.o.key,e.type,a))&&(r=!0)}return r}},A={name:"rdfs5",apply(t,e){let r=!1;for(let o of t.byPredicate(e.subPropertyOf)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;for(let n of t.bySubjectPredicate(a,e.subPropertyOf))n.o.kind==="uri"&&t.add(s(i,e.subPropertyOf,n.o.key))&&(r=!0)}return r}},V={name:"rdfs7",apply(t,e){let r=!1;for(let o of t.byPredicate(e.subPropertyOf)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;if(i!==a)for(let n of t.byPredicate(i)){let p={s:n.s,p:a,o:n.o};t.add(p)&&(r=!0)}}return r}},W={name:"rdfs9",apply(t,e){let r=!1;for(let o of t.byPredicate(e.subClassOf)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;if(i!==a)for(let n of t.byPredicateObject(e.type,i))t.add(s(n.s,e.type,a))&&(r=!0)}return r}},F={name:"rdfs11",apply(t,e){let r=!1;for(let o of t.byPredicate(e.subClassOf)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;for(let n of t.bySubjectPredicate(a,e.subClassOf))n.o.kind==="uri"&&t.add(s(i,e.subClassOf,n.o.key))&&(r=!0)}return r}},K=[_,E,A,V,W,F];var N={name:"prp-trp",apply(t,e){let r=!1,o=t.subjectsWithPredicateObject(e.type,e.transitiveProperty);for(let i of o){let a=t.byPredicate(i);for(let n of a){if(n.o.kind!=="uri")continue;let p=n.o.key;for(let l of t.bySubjectPredicate(p,i))l.o.kind==="uri"&&n.s!==l.o.key&&t.add(s(n.s,i,l.o.key))&&(r=!0)}}return r}},D={name:"prp-symp",apply(t,e){let r=!1,o=t.subjectsWithPredicateObject(e.type,e.symmetricProperty);for(let i of o)for(let a of t.byPredicate(i))a.o.kind==="uri"&&t.add(s(a.o.key,i,a.s))&&(r=!0);return r}},M={name:"prp-inv1",apply(t,e){let r=!1;for(let o of t.byPredicate(e.inverseOf)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;for(let n of t.byPredicate(i))n.o.kind==="uri"&&t.add(s(n.o.key,a,n.s))&&(r=!0)}return r}},z={name:"prp-inv2",apply(t,e){let r=!1;for(let o of t.byPredicate(e.inverseOf)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;for(let n of t.byPredicate(a))n.o.kind==="uri"&&t.add(s(n.o.key,i,n.s))&&(r=!0)}return r}},B={name:"prp-eqp1",apply(t,e){let r=!1;for(let o of t.byPredicate(e.equivalentProperty)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;if(i!==a)for(let n of t.byPredicate(i))t.add({s:n.s,p:a,o:n.o})&&(r=!0)}return r}},G={name:"prp-eqp2",apply(t,e){let r=!1;for(let o of t.byPredicate(e.equivalentProperty)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;if(i!==a)for(let n of t.byPredicate(a))t.add({s:n.s,p:i,o:n.o})&&(r=!0)}return r}},H={name:"cax-eqc1",apply(t,e){let r=!1;for(let o of t.byPredicate(e.equivalentClass)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;if(i!==a)for(let n of t.byPredicateObject(e.type,i))t.add(s(n.s,e.type,a))&&(r=!0)}return r}},J={name:"cax-eqc2",apply(t,e){let r=!1;for(let o of t.byPredicate(e.equivalentClass)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;if(i!==a)for(let n of t.byPredicateObject(e.type,a))t.add(s(n.s,e.type,i))&&(r=!0)}return r}},Q={name:"eq-rep-s",apply(t,e){let r=!1;for(let o of t.byPredicate(e.sameAs)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;if(i!==a){for(let n of t.snapshot())n.s===i&&t.add({s:a,p:n.p,o:n.o})&&(r=!0);for(let n of t.snapshot())n.s===a&&t.add({s:i,p:n.p,o:n.o})&&(r=!0)}}return r}},X={name:"eq-rep-o",apply(t,e){let r=!1;for(let o of t.byPredicate(e.sameAs)){if(o.o.kind!=="uri")continue;let i=o.s,a=o.o.key;if(i!==a)for(let n of t.snapshot())n.o.kind==="uri"&&(n.o.key===i?t.add(s(n.s,n.p,a))&&(r=!0):n.o.key===a&&t.add(s(n.s,n.p,i))&&(r=!0))}return r}},U=[N,D,M,z,B,G,H,J,Q,X];var m=class{constructor(e,r){this.store=e;this.vocabulary=r}store;vocabulary;getInstancesOfClass(e){let r=f(e);return this.store.subjectsWithPredicateObject(this.vocabulary.type,r)}getSubclasses(e){let r=f(e);return this.store.subjectsWithPredicateObject(this.vocabulary.subClassOf,r).filter(i=>i!==r)}getSuperclasses(e){let r=f(e);return this.store.uriObjectsOf(r,this.vocabulary.subClassOf).filter(o=>o!==r)}getTypesOfIndividual(e){return this.store.uriObjectsOf(f(e),this.vocabulary.type)}isInstanceOf(e,r){return this.store.hasUri(f(e),this.vocabulary.type,f(r))}triples(){return this.store.snapshot()}size(){return this.store.size()}};function f(t){return typeof t=="string"?t:c(t.publisher,t.package_,t.name)}var R=class{vocabulary;profile;maxIterations;constructor(e={}){this.vocabulary=e.vocabulary??new d,this.profile=e.profile??"owl-rl-classification",this.maxIterations=e.maxIterations??100}async reason(e){let r=new y,i=await new w().parseKanonaks(e),a=new O;for(let l of i)if(l instanceof x){let b=Y(l);if(!b)continue;for(let C of l.statement)this.emitStatement(b,C,r,a)}let n=[...K];this.profile==="owl-rl-classification"&&n.push(...U);let p=0;for(;p<this.maxIterations;){let l=!1;for(let b of n)b.apply(r,this.vocabulary)&&(l=!0);if(!l)break;p++}return new m(r,this.vocabulary)}emitStatement(e,r,o,i){let a=Z(r);if(a){if(r instanceof T){o.add({s:e,p:a,o:{kind:"literal",lexical:r.object,datatype:"string"}});return}if(r instanceof I){o.add({s:e,p:a,o:{kind:"literal",lexical:String(r.object),datatype:"number"}});return}if(r instanceof v){o.add({s:e,p:a,o:{kind:"literal",lexical:String(r.object),datatype:"boolean"}});return}if(r instanceof $){let n=u(r.object.subject);o.add(s(e,a,n));return}if(r instanceof q){let n=i.next();o.add({s:e,p:a,o:{kind:"blank",id:n}}),this.emitEmbedded(n,r.object,o,i);return}if(r instanceof L){for(let n of r.object??[])this.emitListItem(e,a,n,o,i);return}}}emitListItem(e,r,o,i,a){if(o instanceof g)i.add(s(e,r,u(o.subject)));else if(o instanceof S){let n=a.next();i.add({s:e,p:r,o:{kind:"blank",id:n}}),this.emitEmbedded(n,o,i,a)}else if(o instanceof j){let n=typeof o.value=="number"?"number":typeof o.value=="boolean"?"boolean":"string";i.add({s:e,p:r,o:{kind:"literal",lexical:String(o.value),datatype:n}})}}emitEmbedded(e,r,o,i){let a=`_:${e}`;for(let n of r.statement)this.emitStatement(a,n,o,i)}},O=class{counter=0;next(){return`b${this.counter++}`}};function Y(t){let e=t.namespace??"",r=e.indexOf("@"),o=r===-1?e:e.substring(0,r),i=o.indexOf("/");if(i===-1)return null;let a=o.substring(0,i),n=o.substring(i+1);return!a||!n||!t.name?null:c(a,n,t.name)}function Z(t){let e=t.predicate;return e?.subject?u(e.subject):null}export{u as a,c as b,k as c,s as d,y as e,d as f,K as g,U as h,m as i,R as j};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as S}from"./chunk-
|
|
1
|
+
import{a as S}from"./chunk-4YHWMYAZ.js";import{c as v,d as u,g as j,j as p,k as h,l as k}from"./chunk-W6T7MOKY.js";function fe(t,n,e,a){let r=D(t);if(r.length>0){let i=r.find(f=>m(f.format,n)&&m(f.variant,e));return i?{transformation:i.transformation,source:"instance"}:void 0}let o=new Set,s=U(t);for(;s.length>0;){let i=s.shift(),f=y(i.subject);if(o.has(f))continue;o.add(f);let c=R(a,i.subject);if(!c)continue;let K=D(c).find(d=>m(d.format,n)&&m(d.variant,e));if(K)return{transformation:K.transformation,source:{publisher:i.subject.publisher,package_:i.subject.package_,name:i.subject.name}};for(let d of T(c))s.push(d)}let l={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"};if(!o.has(y(l))){let i=R(a,l);if(i){let c=D(i).find(g=>m(g.format,n)&&m(g.variant,e));if(c)return{transformation:c.transformation,source:l}}}}function D(t){let n=[];for(let e of t.statement)if(e instanceof k&&b(e,"kanonak.org","derivation","derivations"))for(let a of e.object??[]){if(!(a instanceof S))continue;let r=E(a);r&&n.push(r)}return n}function E(t){let n,e,a;for(let r of t.statement)r instanceof p?b(r,"kanonak.org","derivation","format")?n=x(r):b(r,"kanonak.org","derivation","variant")&&(e=x(r)):r instanceof h&&b(r,"kanonak.org","derivation","transformation")&&(a=_(r.object));if(!(!n||!a))return e||(e={publisher:"kanonak.org",package_:"derivation",name:"default"}),{format:n,variant:e,transformation:a}}function _(t){let n,e,a,r;for(let o of t.statement){if(!(o instanceof j))continue;let s=o.predicate?.subject?.name;s==="publisher"?n=o.object:s==="package"?e=o.object:s==="version"?a=o.object:s==="name"&&(r=o.object)}if(!(!n||!e||!a||!r))return{publisher:n,package_:e,version:a,name:r}}function U(t){let n=[];for(let e of t.statement)e instanceof p&&e.predicate?.subject?.name==="type"&&e.object instanceof u&&n.push(e.object);return n}function T(t){let n=[];for(let e of t.statement)if(e instanceof p){if(e.predicate?.subject?.name!=="subClassOf")continue;e.object instanceof u&&n.push(e.object)}else if(e instanceof k){if(e.predicate?.subject?.name!=="subClassOf")continue;for(let a of e.object??[])a instanceof u&&n.push(a)}return n}function R(t,n){for(let e of t){if(!(e instanceof v)||e.name!==n.name)continue;if((e.namespace||"").startsWith(`${n.publisher}/${n.package_}@`))return e}}function b(t,n,e,a){let r=t.predicate?.subject;return r?r.publisher===n&&r.package_===e&&r.name===a:!1}function x(t){let n=t.object.subject;return{publisher:n.publisher,package_:n.package_,name:n.name}}function m(t,n){return t.publisher===n.publisher&&t.package_===n.package_&&t.name===n.name}function y(t){return`${t.publisher}/${t.package_}/${t.name}`}export{fe as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as T,b as O,c as K,d as u,g,h as R,i as S,j as D,k as h,l as j}from"./chunk-W6T7MOKY.js";import{a as I}from"./chunk-
|
|
1
|
+
import{a as T,b as O,c as K,d as u,g,h as R,i as S,j as D,k as h,l as j}from"./chunk-W6T7MOKY.js";import{a as I}from"./chunk-7CUTGGH3.js";import{b as v,c as M}from"./chunk-5ILSX24H.js";var k=class extends O{name};var w=class extends T{value};var P=class extends g{links=[]};var L=/\[\[([^\[\]\n]+)\]\]/g,V=/```[\s\S]*?```|`[^`\n]*`/g;function x(d){if(!d||!d.includes("[["))return[];let e=[];for(let n of d.matchAll(V))e.push([n.index,n.index+n[0].length]);let t=n=>e.some(([s,a])=>n>=s&&n<a),i=[];for(let n of d.matchAll(L)){let s=n.index;if(t(s))continue;let a=n[1],r=a.indexOf("|"),o=(r===-1?a:a.slice(0,r)).trim();if(o.length===0)continue;let p=r===-1?"":a.slice(r+1).trim(),c={reference:o,startOffset:s,endOffset:s+n[0].length};p.length>0&&(c.displayText=p),i.push(c)}return i}var A=class{constructor(e){}async parseKanonaks(e){let t=[],i=await e.getAllDocumentsAsync(),n=new v(e),s=new M(n);for(let o of i){let p=o.metadata.namespace_?.toString()??"";for(let[c,m]of Object.entries(o.body)){let f=new K,y=this.resolveCanonicalEntity(c,o,p);f.namespace=y.namespace,f.name=y.name,f.statement=[];let l=await this.parseStatements(m,o,n,s,e);f.statement.push(...l),t.push(f)}}let a=new Map,r=[];for(let o of t)if(o instanceof K){let p=`${o.namespace}/${o.name}`,c=a.get(p);c?c.statement.push(...o.statement):(a.set(p,o),r.push(o))}else r.push(o);return r}resolveCanonicalEntity(e,t,i){if(!e.includes(".")||!t.metadata?.imports)return{namespace:i,name:e};let n=e.indexOf("."),s=e.substring(0,n),a=e.substring(n+1);for(let[r,o]of Object.entries(t.metadata.imports))for(let p of o)if((p.alias??p.packageName)===s){let m=p.version;return{namespace:`${r}/${p.packageName}@${m.major}.${m.minor}.${m.patch}`,name:a}}return{namespace:i,name:e}}async parseStatements(e,t,i,n,s){let a=[];if(typeof e!="object"||e===null||Array.isArray(e))return a;for(let[r,o]of Object.entries(e))try{let p=await this.getPropertyMetadata(r,t,i,s,n);if(!p)continue;let c=await this.parsePropertyValue(r,o,p,t,i,n);c&&a.push(c)}catch(p){console.error(`Error parsing property ${r}:`,p)}return a}async getPropertyMetadata(e,t,i,n,s){let a=await i.resolveEntityAsync(e,t);if(!a)return;let r=a.entity,o=r.type?.toString()??"",p=o.includes(".")?o.substring(o.lastIndexOf(".")+1):o;if(!new Set(["Property","DatatypeProperty","ObjectProperty","AnnotationProperty"]).has(p))return;let m=s.getPropertyTypeClassification(o),f=r.range?.toString(),y;if(m==="ObjectProperty")y="ObjectProperty";else if(m==="DatatypeProperty")y="DatatypeProperty";else{let b=f&&f.includes(".")?f.substring(f.lastIndexOf(".")+1):f??"";(f?s.isKnownXsdDatatypeName(f):!1)||b==="Literal"?y="DatatypeProperty":y="ObjectProperty"}let l;return f&&(l=(await i.resolveEntityAsync(f,t))?.uri),{propertyUri:a.uri.toString(),propertyType:y,range:f,rangeUri:l,isImported:a.isImported,definedInNamespace:a.definedInNamespace}}async parsePropertyValue(e,t,i,n,s,a){let r=i.propertyUri;if(t!=null){if(Array.isArray(t))return this.parseListValue(r,t,i,n,s,a);if(i.propertyType==="DatatypeProperty")return this.parseDatatypeValue(r,t,i,n,s,a);if(i.propertyType==="ObjectProperty")return this.parseObjectValue(r,t,i,n,s,a)}}async parseDatatypeValue(e,t,i,n,s,a){if(t instanceof Date)return g.parse(e,t.toISOString());if(typeof t=="string")return a.isSubstitutableDatatype(i.rangeUri)?await this.parseSubstitutableValue(e,t,n,s):g.parse(e,t);if(typeof t=="number")return R.parse(e,t);if(typeof t=="boolean"){let r=new S;return r.predicate=u.parse(e),r.object=t,r}}async parseSubstitutableValue(e,t,i,n){let s=new P;s.predicate=u.parse(e),s.object=t;for(let a of x(t)){let r=await n.resolveEntityAsync(a.reference,i),o;r&&(o=new u,o.subject=r.uri);let p={reference:a.reference,startOffset:a.startOffset,endOffset:a.endOffset};a.displayText!==void 0&&(p.displayText=a.displayText),o!==void 0&&(p.target=o),s.links.push(p)}return s}async parseObjectValue(e,t,i,n,s,a){if(typeof t=="string"){let r=await this.resolveReference(t,n,s);if(!r)return;let o=new D;return o.predicate=u.parse(e),o.object=r,o}if(typeof t=="object"&&!Array.isArray(t)){let r=new k;if(r.statement=await this.parseStatements(t,n,s,a,{}),r.statement.length>0){let c=new h;return c.predicate=u.parse(e),c.object=r,c}let o=[];for(let[c,m]of Object.entries(t))if(typeof m=="object"&&m!==null&&!Array.isArray(m)){let f=new k;f.name=c,f.statement=await this.parseStatements(m,n,s,a,{}),o.push(f)}else if(typeof m=="string"){let f=await this.resolveReference(m,n,s);f&&o.push(f)}if(o.length>0){let c=new j;return c.predicate=u.parse(e),c.object=o,c}let p=new h;return p.predicate=u.parse(e),p.object=r,p}}async parseListValue(e,t,i,n,s,a){let r=[],o=i.propertyType==="DatatypeProperty";for(let c of t){if(o&&(typeof c=="string"||typeof c=="number"||typeof c=="boolean")){let m=new w;m.value=c,r.push(m);continue}if(o&&c instanceof Date){let m=new w;m.value=c.toISOString(),r.push(m);continue}if(typeof c=="string"){let m=await this.resolveReference(c,n,s);m&&r.push(m)}else if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let m=new k;m.statement=await this.parseStatements(c,n,s,a,{}),r.push(m)}}let p=new j;return p.predicate=u.parse(e),p.object=r,p}async resolveReference(e,t,i){let n=await i.resolveEntityAsync(e,t);if(n){let a=new u;return a.subject=n.uri,a}let s=t.metadata?.namespace_;if(s){let{KanonakUri:a}=await import("./KanonakUri-4VJGV3FN.js"),r=s.version??{major:0,minor:0,patch:0,toString:()=>"0.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};if(e.includes(".")){let p=e.indexOf("."),c=e.substring(0,p),m=e.substring(p+1);if(t.metadata?.imports){for(let[f,y]of Object.entries(t.metadata.imports))for(let l of y)if((l.alias??l.packageName)===c){let b=new u;return b.subject=new a(f,l.packageName,m,l.version),b}}}let o=new u;return o.subject=new a(s.publisher,s.package_,e,r),o}return null}async saveKanonaks(e,t){let i=new Map;for(let n of e)n instanceof K&&n.namespace&&(i.has(n.namespace)||i.set(n.namespace,[]),i.get(n.namespace).push(n));for(let[n,s]of i){let a=await this.convertKanonaksToDocument(n,s),r=`${n.split("@")[0]}.yml`;await t.saveDocumentAsync(a,r)}}async serializeToYaml(e,t){let i=e.filter(a=>a instanceof K&&a.namespace===t);if(i.length===0)throw new Error(`No kanonaks found with namespace '${t}'`);let n=await this.convertKanonaksToDocument(t,i);return new I().save(n)}async convertKanonaksToDocument(e,t){let n={metadata:{namespace_:e,get allImports(){if(!this.imports)return[];let a=[];for(let r of Object.values(this.imports))a.push(...r);return a}},body:{}},s=new Map;for(let a of t){let r={};for(let o of a.statement){let[p,c]=this.convertStatementToProperty(o);p&&c!==null&&c!==void 0&&(r[p]=c),this.collectImportsFromStatement(o,e,s)}n.body[a.name]=r}return n}convertStatementToProperty(e){if(e instanceof g)return[e.predicate.subject.name,e.object];if(e instanceof R)return[e.predicate.subject.name,e.object];if(e instanceof S)return[e.predicate.subject.name,e.object];if(e instanceof D)return[e.predicate.subject.name,e.object.subject.name];if(e instanceof j){let t=this.convertKanonakListToValue(e.object);return[e.predicate.subject.name,t]}else if(e instanceof h){let t=this.convertEmbeddedKanonakToValue(e.object);return[e.predicate.subject.name,t]}return[null,null]}convertKanonakListToValue(e){let t=[];for(let i of e)i instanceof u?t.push(i.subject.name):i instanceof k&&t.push(this.convertEmbeddedKanonakToValue(i));return t}convertEmbeddedKanonakToValue(e){let t={};for(let i of e.statement){let[n,s]=this.convertStatementToProperty(i);n&&s!==null&&s!==void 0&&(t[n]=s)}return t}collectImportsFromStatement(e,t,i){}};export{k as a,w as b,P as c,x as d,A as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as f}from"./chunk-
|
|
1
|
+
import{a as f}from"./chunk-7CUTGGH3.js";import{a as g,b as D,f as P,g as w}from"./chunk-FQHALFRR.js";import*as c from"fs/promises";import*as i from"path";import{pathToFileURL as v}from"url";var l=class{rootPath;recursive;parser;documentCache;filePathsByIdentifier;cacheInitialized=!1;cacheInitPromise=null;parsingErrors=new Map;constructor(t,e=!0,n){if(!t||t.trim().length===0)throw new Error("Root path cannot be null or empty");this.rootPath=i.resolve(t),this.recursive=e,this.parser=n??new f,this.documentCache=new Map,this.filePathsByIdentifier=new Map}async getAllDocumentsAsync(){await this.ensureCacheInitialized();let t=new Set(this.documentCache.values());return Array.from(t)}async getDocumentAsync(t){await this.ensureCacheInitialized();let e=this.documentCache.get(t);if(e)return e;let n=i.join(this.rootPath,t);if(e=this.documentCache.get(n),e)return e;for(let a of[".kan.yml",".yml",".yaml"])if(!t.endsWith(a)){let s=t+a;if(e=this.documentCache.get(s),e)return e;let o=i.join(this.rootPath,s);if(e=this.documentCache.get(o),e)return e}return null}async getDocumentsByNamespaceAsync(t,e){await this.ensureCacheInitialized();let n=new Set(this.documentCache.values());return Array.from(n).filter(a=>a.metadata.namespace_?.publisher===t&&a.metadata.namespace_?.package_===e)}async getHighestCompatibleVersionAsync(t,e){await this.ensureCacheInitialized();let n=new Set(this.documentCache.values()),a=Array.from(n).filter(o=>o.metadata?.namespace_?.publisher===t&&o.metadata?.namespace_?.package_===e.packageName&&o.metadata?.namespace_?.version!==void 0);if(a.length===0)return null;let s=a.filter(o=>{let r=o.metadata.namespace_.version;switch(e.versionOperator){case 0:return D(r,e.version);case 1:return P(r,e.version);case 2:return w(r,e.version);case 3:return g(r,e.minVersion)>=0;default:return!1}});return s.length===0?null:(s.sort((o,r)=>{let m=o.metadata.namespace_.version,u=r.metadata.namespace_.version;return g(u,m)}),s[0])}async saveDocumentAsync(t,e){let n,a=t.metadata.namespace_?.toString();if(a&&a.includes("@")&&a.includes("/")){let m=a.split("/"),u=m[0],I=m[1].replace("@","@")+".kan.yml";n=i.join(this.rootPath,u,I)}else n=i.join(this.rootPath,e),!n.endsWith(".yml")&&!n.endsWith(".yaml")&&!n.endsWith(".kan.yml")&&(n+=".kan.yml");let s=i.dirname(n);await c.mkdir(s,{recursive:!0});let o=this.parser.save(t);await c.writeFile(n,o,"utf8"),a&&this.documentCache.set(a,t),this.documentCache.set(n,t);let r=i.relative(this.rootPath,n);this.documentCache.set(r,t)}async deleteDocumentAsync(t){let e=await this.getDocumentAsync(t);if(!e)return;let n=this.filePathsByIdentifier.get(t);if(!n)return;try{await c.unlink(n)}catch{}let a=e.metadata.namespace_?.toString();a&&this.documentCache.delete(a),this.documentCache.delete(t),this.documentCache.delete(n);let s=i.relative(this.rootPath,n);this.documentCache.delete(s)}async clearNamespaceAsync(t,e){await this.ensureCacheInitialized();let n=[];for(let[s,o]of this.documentCache.entries()){let r=o.metadata.namespace_?.toString()||"";r.includes(t)&&r.includes(e)&&n.push([s,o])}let a=i.join(this.rootPath,t);try{let s=await c.readdir(a);for(let o of s)o.includes(e)&&o.endsWith(".kan.yml")&&await c.unlink(i.join(a,o))}catch{}for(let[s]of n)this.documentCache.delete(s)}async getAllDocumentReferencesAsync(){await this.ensureCacheInitialized();let t=new Set(this.filePathsByIdentifier.values()),e=[];for(let n of t){let a=v(n).toString(),s;for(let[m,u]of this.documentCache.entries())if(this.filePathsByIdentifier.get(m)===n&&u.metadata.namespace_){s=u.metadata.namespace_.toString();break}let o=s??i.relative(this.rootPath,n),r=this.parsingErrors.has(n);e.push({identifier:o,uri:a,hasParseError:r})}return e}async getDocumentContentAsync(t){await this.ensureCacheInitialized();let e=this.filePathsByIdentifier.get(t);if(!e)try{await c.access(t),e=t}catch{let n=i.join(this.rootPath,t);try{await c.access(n),e=n}catch{return null}}try{return await c.readFile(e,"utf8")}catch{return null}}async getDocumentUriAsync(t){await this.ensureCacheInitialized();let e=this.filePathsByIdentifier.get(t);if(!e)try{await c.access(t),e=t}catch{let n=i.join(this.rootPath,t);try{await c.access(n),e=n}catch{return null}}return v(e).toString()}async refreshAsync(){this.documentCache.clear(),this.filePathsByIdentifier.clear(),this.parsingErrors.clear(),this.cacheInitialized=!1,this.cacheInitPromise=null,await this.ensureCacheInitialized()}async ensureCacheInitialized(){if(!this.cacheInitialized){if(this.cacheInitPromise){await this.cacheInitPromise;return}this.cacheInitPromise=this.loadDocuments(),await this.cacheInitPromise,this.cacheInitialized=!0}}async loadDocuments(){try{await c.mkdir(this.rootPath,{recursive:!0})}catch{}let e=(await this.findYamlFiles(this.rootPath,this.recursive)).map(async a=>{try{let s=await c.readFile(a,"utf8"),o=this.parser.parse(s);return{filePath:a,document:o,error:null}}catch(s){return{filePath:a,document:null,error:s instanceof Error?s.message:String(s)}}}),n=await Promise.all(e);for(let{filePath:a,document:s,error:o}of n){let r=i.relative(this.rootPath,a);if(s&&s.metadata.namespace_){let m=s.metadata.namespace_.toString();this.documentCache.set(m,s),this.documentCache.set(a,s),this.documentCache.set(r,s),this.filePathsByIdentifier.set(m,a),this.filePathsByIdentifier.set(a,a),this.filePathsByIdentifier.set(r,a)}else this.filePathsByIdentifier.set(a,a),this.filePathsByIdentifier.set(r,a);o&&this.parsingErrors.set(a,o)}}async findYamlFiles(t,e){let n=[];try{let a=await c.readdir(t,{withFileTypes:!0});for(let s of a){let o=i.join(t,s.name);if(s.isDirectory()&&e){let r=await this.findYamlFiles(o,e);n.push(...r)}else s.isFile()&&s.name.endsWith(".kan.yml")&&n.push(o)}}catch{}return n}};import*as p from"fs";var A=(n=>(n.NotFound="NotFound",n.Workspace="Workspace",n.Cache="Cache",n))(A||{}),y=class{cache;workspace;constructor(t,e,n){let a=n??new f;p.existsSync(t)||p.mkdirSync(t,{recursive:!0}),p.existsSync(e)||p.mkdirSync(e,{recursive:!0}),this.cache=new l(t,!0,a),this.workspace=new l(e,!0,a)}getCache(){return this.cache}getWorkspace(){return this.workspace}async getAllDocumentsAsync(){let t=await this.workspace.getAllDocumentsAsync(),e=await this.cache.getAllDocumentsAsync(),n=new Map;for(let a of e)if(a.metadata.namespace_){let s=a.metadata.namespace_.toString();n.set(s,a)}for(let a of t)if(a.metadata.namespace_){let s=a.metadata.namespace_.toString();n.set(s,a)}return Array.from(n.values())}async getDocumentAsync(t){let e=await this.workspace.getDocumentAsync(t);return e||await this.cache.getDocumentAsync(t)}async getDocumentsByNamespaceAsync(t,e){let n=await this.workspace.getDocumentsByNamespaceAsync(t,e),a=await this.cache.getDocumentsByNamespaceAsync(t,e),s=new Map;for(let o of a)if(o.metadata.namespace_?.version){let r=o.metadata.namespace_.version.toString();s.set(r,o)}for(let o of n)if(o.metadata.namespace_?.version){let r=o.metadata.namespace_.version.toString();s.set(r,o)}return Array.from(s.values())}async getHighestCompatibleVersionAsync(t,e){let n=await this.workspace.getHighestCompatibleVersionAsync(t,e);return n||await this.cache.getHighestCompatibleVersionAsync(t,e)}async saveDocumentAsync(t,e){await this.workspace.saveDocumentAsync(t,e)}async saveToCacheAsync(t,e){await this.cache.saveDocumentAsync(t,e)}async deleteDocumentAsync(t){await this.workspace.deleteDocumentAsync(t)}async clearNamespaceAsync(t,e){await this.workspace.clearNamespaceAsync(t,e)}async getAllDocumentReferencesAsync(){let t=await this.workspace.getAllDocumentReferencesAsync(),e=await this.cache.getAllDocumentReferencesAsync(),n=[];return n.push(...t),n.push(...e),n}async getDocumentContentAsync(t){let e=await this.workspace.getDocumentContentAsync(t);return e||await this.cache.getDocumentContentAsync(t)}async getDocumentUriAsync(t){let e=await this.workspace.getDocumentUriAsync(t);return e||await this.cache.getDocumentUriAsync(t)}async getDocumentLocationAsync(t){return await this.workspace.getDocumentAsync(t)?"Workspace":await this.cache.getDocumentAsync(t)?"Cache":"NotFound"}};import{homedir as K}from"os";import{join as R}from"path";function d(){let h=process.env.KANONAK_PACKAGE_CACHE;return h||R(K(),".kanonak","packages")}var k=class h{static createComposite(t,e,n){let a=t??d(),s=e??".";return new y(a,s,n)}static createFromEnvironment(t){let e=d(),n=process.env.KANONAK_WORKSPACE_PATH??".";return h.createComposite(e,n,t)}};export{l as a,A as b,y as c,d,k as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as h from"js-yaml";var g=class{parse(r){let t=this.parseWithErrors(r);if(!t.isValid){let a=t.errors[0];throw new Error(`YAML parse error at line ${a.line}, column ${a.column}: ${a.message}`)}return t.document}parseWithErrors(r){let t=[],a;try{r=r.replace(/^\uFEFF/,"");let s=h.load(r);if(!s||typeof s!="object")return a={metadata:this.createEmptyMetadata(),body:{},toString:()=>"KanonakDocument(empty)"},{document:a,errors:t,isValid:!0};let e=this.extractMetadata(s),n=this.extractBody(s,e);return a={metadata:e,body:n,toString:function(){return this.metadata.namespace_?`KanonakDocument(${this.metadata.namespace_.publisher}/${this.metadata.namespace_.package_})`:"KanonakDocument(no namespace)"}},{document:a,errors:t,isValid:!0}}catch(s){let e=s,n={message:e.message||"Unknown parse error",line:e.mark?.line??0,column:e.mark?.column??0,errorType:e.name==="YAMLException"?"SyntaxError":"Unknown",toString:()=>`${e.name==="YAMLException"?"SyntaxError":"Unknown"} at line ${e.mark?.line??0}: ${e.message||"Unknown parse error"}`};return t.push(n),{document:void 0,errors:t,isValid:!1}}}save(r){let t={};if(r.metadata.namespace_){let a=r.metadata.namespace_,s={type:"Package",publisher:a.publisher};a.version&&(s.version=`${a.version.major}.${a.version.minor}.${a.version.patch}`),r.metadata.imports&&(s.imports=this.serializeImports(r.metadata.imports)),t[a.package_]=s}return Object.assign(t,r.body),h.dump(t,{indent:2,noRefs:!0,sortKeys:!1})}createEmptyMetadata(){return{get allImports(){return[]}}}addAllImportsGetter(r){let t=r.imports;return Object.defineProperty(r,"allImports",{get:function(){if(!t)return[];let a=[];for(let s of Object.values(t))a.push(...s);return a},enumerable:!0,configurable:!0}),r}createVersion(r,t,a){return{major:r,minor:t,patch:a,toString:()=>`${r}.${t}.${a}`,equals:e=>!e||typeof e!="object"?!1:e.major===r&&e.minor===t&&e.patch===a,getHashCode:()=>r<<20|t<<10|a,compareTo:e=>r!==e.major?r-e.major:t!==e.minor?t-e.minor:a-e.patch}}extractMetadata(r){let t=this.createEmptyMetadata();for(let[a,s]of Object.entries(r))if(s&&typeof s=="object"&&s.type==="Package"){t.type_="Package";let e=a,n=s.publisher,i=s.version?this.parseVersion(s.version):void 0;return n&&e&&(t.namespace_={publisher:n,package_:e,version:i,toString:function(){return`${this.publisher}/${this.package_}@${this.version?.major??1}.${this.version?.minor??0}.${this.version?.patch??0}`},equals:o=>!o||typeof o!="object"?!1:o.publisher===n&&o.package_===e&&(!i||!o.version||i.equals(o.version)),getHashCode:()=>{let o=0;for(let c=0;c<n.length;c++)o=(o<<5)-o+n.charCodeAt(c);for(let c=0;c<e.length;c++)o=(o<<5)-o+e.charCodeAt(c);return o|0}}),s.imports&&Array.isArray(s.imports)&&(t.imports=this.parseImportsV3(s.imports)),this.addAllImportsGetter(t)}if(r.kanonak&&typeof r.kanonak=="object"){let a=r.kanonak;return(a.publisher||a.package||a.version)&&(t.namespace_=this.parseNamespace(a)),a.imports&&typeof a.imports=="object"&&(t.imports=this.parseImportsLegacy(a.imports)),this.addAllImportsGetter(t)}return t}extractBody(r,t){let a={};for(let[s,e]of Object.entries(r))if(!(s==="kanonak"||s==="namespace"||s==="imports"))if(e&&typeof e=="object"&&e.type==="Package"){let n={};for(let[i,o]of Object.entries(e))i==="publisher"||i==="version"||i==="imports"||(n[i]=o);a[s]=n}else a[s]=e;return a}parseNamespace(r){if(typeof r=="string"){let e=r.match(/^([^/]+)\/([^@]+)(?:@(.+))?$/);if(e){let n=e[3]?this.parseVersion(e[3]):this.createVersion(1,0,0);return{publisher:e[1],package_:e[2],version:n,toString:()=>r,equals:i=>!i||typeof i!="object"?!1:i.publisher===e[1]&&i.package_===e[2]&&(!n||!i.version||n.equals(i.version)),getHashCode:()=>{let i=0;for(let o=0;o<e[1].length;o++)i=(i<<5)-i+e[1].charCodeAt(o);for(let o=0;o<e[2].length;o++)i=(i<<5)-i+e[2].charCodeAt(o);return i|0}}}}let t=r.publisher||"",a=r.package||"",s=r.version?this.parseVersion(r.version):this.createVersion(1,0,0);return{publisher:t,package_:a,version:s,toString:function(){return`${this.publisher}/${this.package_}@${this.version?.major??1}.${this.version?.minor??0}.${this.version?.patch??0}`},equals:e=>!e||typeof e!="object"?!1:e.publisher===t&&e.package_===a&&(!s||!e.version||s.equals(e.version)),getHashCode:()=>{let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n);for(let n=0;n<a.length;n++)e=(e<<5)-e+a.charCodeAt(n);return e|0}}}parseVersion(r){if(typeof r=="string"){let t=r.split(".").map(Number);return this.createVersion(t[0]||0,t[1]||0,t[2]||0)}return this.createVersion(r.major||0,r.minor||0,r.patch||0)}parseImportsV3(r){let t={};for(let a of r)if(!(!a||typeof a!="object"))if(a.packages&&Array.isArray(a.packages)){let s=a.publisher;if(!s)throw new Error("PublisherImport requires 'publisher' property");t[s]||(t[s]=[]);for(let e of a.packages){if(!e||typeof e!="object")continue;let n=this.parseImportFromEmbeddedObject(e,s);t[s].push(n)}}else{let s=this.parseImportFromEmbeddedObject(a,a.publisher),e=s.publisher||"";t[e]||(t[e]=[]),t[e].push(s)}return t}parseImportsLegacy(r){let t={};for(let[a,s]of Object.entries(r))Array.isArray(s)&&(t[a]=s.map(e=>this.parseImport(e,a)));return t}parseImportFromEmbeddedObject(r,t){let a=r.package;if(!a)throw new Error("Import requires 'package' property");let s=r.match;if(!s)throw new Error("Import requires 'match' property");let e=r.version;if(!e)throw new Error("Import requires 'version' property");let n=this.parseVersion(e),i=this.parseVersionOperator(s),o=this.calculateMaxVersion(s,n),c=r.alias;return{package_:`${a} ${s} ${n.toString()}`,publisher:t,packageName:a,versionOperator:i,version:n,alias:c,minVersion:n,maxVersion:o,toEmbeddedObject:()=>{let m={package:a,match:s,version:n.toString()};return c&&(m.alias=c),m},toString:()=>c?`${a} ${s} ${n.toString()} as ${c}`:`${a} ${s} ${n.toString()}`}}parseImport(r,t){if(typeof r=="string"){let o=r.match(/^(.+?)\s*([~^=*])\s*(\S+)\s+as\s+(\S+)$/);if(o){let m=o[1].trim(),u=o[2],p=this.parseVersion(o[3].trim()),l=o[4].trim(),d=this.parseVersionOperator(u),y=this.calculateMaxVersion(u,p);return{package_:r,publisher:t,packageName:m,versionOperator:d,version:p,alias:l,minVersion:p,maxVersion:y,toEmbeddedObject:()=>{let f={package:m,match:u,version:p.toString()};return l&&(f.alias=l),f},toString:()=>`${m} ${u} ${p.toString()} as ${l}`}}let c=r.match(/^(.+?)\s*([~^=*])\s*(.+)$/);if(c){let m=c[1].trim(),u=c[2],p=this.parseVersion(c[3].trim()),l=this.parseVersionOperator(u),d=this.calculateMaxVersion(u,p);return{package_:r,publisher:t,packageName:m,versionOperator:l,version:p,alias:void 0,minVersion:p,maxVersion:d,toEmbeddedObject:()=>({package:m,match:u,version:p.toString()}),toString:()=>`${m} ${u} ${p.toString()}`}}}let a=this.parseVersionOperator(r.operator||"~"),s=this.parseVersion(r.version||"1.0.0"),e=r.packageName||r.package||"",n=["=","~","^","*"][a],i=this.calculateMaxVersion(r.operator||"~",s);return{package_:r.package||"",publisher:t,packageName:e,versionOperator:a,version:s,alias:r.alias,minVersion:s,maxVersion:i,toEmbeddedObject:()=>{let o={package:e,match:n,version:s.toString()};return r.alias&&(o.alias=r.alias),o},toString:()=>`${e} ${n} ${s.toString()}`}}parseVersionOperator(r){switch(r){case"=":return 0;case"~":return 1;case"^":return 2;case"*":return 3;default:return 1}}calculateMaxVersion(r,t){switch(r){case"~":return this.createVersion(t.major,t.minor+1,0);case"^":return t.major===0?this.createVersion(0,t.minor+1,0):this.createVersion(t.major+1,0,0);default:return this.createVersion(999,999,999)}}serializeImports(r){let t=[];for(let[a,s]of Object.entries(r)){let e={publisher:a,packages:s.map(n=>{let i=["=","~","^","*"][n.versionOperator],o={package:n.packageName,match:i,version:`${n.version.major}.${n.version.minor}.${n.version.patch}`};return n.alias&&(o.alias=n.alias),o})};t.push(e)}return t}};export{g as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as ye}from"./chunk-FJ35VIV6.js";import{a as se,c as le,e as Z}from"./chunk-QIIQ4G2Q.js";import{c as J,k as ae,l as ce}from"./chunk-W6T7MOKY.js";import{a as ie}from"./chunk-MYITGTGJ.js";import{c as A}from"./chunk-FQHALFRR.js";import{a as P,b as V,c as pe}from"./chunk-5ILSX24H.js";var D=class{isValid=!1;errors=[];warnings=[];get totalIssues(){return this.errors.length+this.warnings.length}};var R=(r=>(r.Warning="Warning",r.Error="Error",r))(R||{});var g=class{ruleType="";severity="Error";lineNumber;column;entityName;propertyName;propertyPath;message="";suggestion;actualValue;expectedValue;toString(){let e="";return this.lineNumber!==void 0&&(e+=`Line ${this.lineNumber}: `),this.entityName&&(e+=`[${this.entityName}] `),e+=this.message,e}};var Q=class d{resolvedDocuments=[];currentEntityPath;withPath(e){let r=new d;return r.resolvedDocuments=this.resolvedDocuments,r.currentEntityPath=e,r}};var te=class{constructor(e){this.underlying=e;this.repository=new re(e)}underlying;repository;kanonaksPromise=null;importClosureCache=new Map;classDeclarationsCache=new Map;propertyNamesCache=new Map;allDocumentsPromise=null;getKanonaks(){return this.kanonaksPromise||(this.kanonaksPromise=new Z().parseKanonaks(this.underlying)),this.kanonaksPromise}async getImportClosure(e){let r=this.importClosureCache.get(e);return r||(r=this.computeImportClosure(e),this.importClosureCache.set(e,r),r)}async getClassDeclarations(e){let r=this.classDeclarationsCache.get(e);return r||(r=this.computeClassDeclarations(e),this.classDeclarationsCache.set(e,r),r)}async getPropertyNames(e){let r=this.propertyNamesCache.get(e);return r||(r=this.computePropertyNames(e),this.propertyNamesCache.set(e,r),r)}getAllDocuments(){return this.allDocumentsPromise||(this.allDocumentsPromise=this.underlying.getAllDocumentsAsync()),this.allDocumentsPromise}async computeImportClosure(e){let r=new Set([e]),t=[e],i=await this.buildDocsByIdIndex();for(;t.length>0;){let a=t.shift(),n=i.get(a);if(n?.metadata.imports)for(let[o,c]of Object.entries(n.metadata.imports))for(let s of c){let l=await this.repository.getHighestCompatibleVersionAsync(o,s);if(!l)continue;let p=ee(l);!p||r.has(p)||(r.add(p),t.push(p))}}return r}async buildDocsByIdIndex(){let e=await this.getAllDocuments(),r=new Map;for(let t of e){let i=ee(t);i&&r.set(i,t)}return r}async computeClassDeclarations(e){let r=await this.findDocById(e),t=new Map;if(!r)return t;for(let[i,a]of Object.entries(r.body)){if(!me(a))continue;let n=a,o=ue(n,"type");if(o==="Class"||o?.endsWith(".Class")){let c=ge(n);t.set(i,c)}}return t}async computePropertyNames(e){let r=await this.findDocById(e),t=new Set;if(!r)return t;for(let[i,a]of Object.entries(r.body)){if(!me(a))continue;let o=ue(a,"type");(o==="ObjectProperty"||o?.endsWith(".ObjectProperty")||o==="DatatypeProperty"||o?.endsWith(".DatatypeProperty")||o==="AnnotationProperty"||o?.endsWith(".AnnotationProperty")||o==="Property"||o?.endsWith(".Property"))&&t.add(i)}return t}async findDocById(e){let r=await this.getAllDocuments();for(let t of r)if(ee(t)===e)return t}};function ee(d){let e=d.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${A(e.version)}`}function me(d){return typeof d=="object"&&d!==null&&!Array.isArray(d)}function ue(d,e){if(e in d)return fe(d[e]);for(let r of Object.keys(d))if(r.endsWith(`.${e}`))return fe(d[r])}function fe(d){return Array.isArray(d)?d.length>0?String(d[0]):void 0:d==null?void 0:String(d)}function ge(d){let e=d.subClassOf;if(e===void 0){for(let r of Object.keys(d))if(r.endsWith(".subClassOf")){e=d[r];break}}return P(e)}var re=class{constructor(e){this.inner=e}inner;highestVersionCache=new Map;byNamespaceCache=new Map;getAllDocumentsAsync(){return this.inner.getAllDocumentsAsync()}getDocumentAsync(e){return this.inner.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,r){let t=`${e}/${r}`,i=this.byNamespaceCache.get(t);return i||(i=this.inner.getDocumentsByNamespaceAsync(e,r),this.byNamespaceCache.set(t,i),i)}getHighestCompatibleVersionAsync(e,r){let t=r.version,i=t?`${t.major}.${t.minor}.${t.patch}`:"",a=`${e}/${r.packageName}@${r.versionOperator}:${i}`,n=this.highestVersionCache.get(a);return n||(n=this.inner.getHighestCompatibleVersionAsync(e,r),this.highestVersionCache.set(a,n),n)}saveDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}deleteDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}clearNamespaceAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}getAllDocumentReferencesAsync(){return this.inner.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.inner.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.inner.getDocumentUriAsync(e)}};var v=class d{static NAMESPACE_PREFIX_PATTERN=/^(rdfs|xsd|owl|rdf|dc|foaf|skos|dct|dcterms|geo|time|prov|schema|og|dbo):/i;ruleName="NamespacePrefix";validate(e){let r=[];for(let[t,i]of Object.entries(e.body))i&&typeof i=="object"&&!Array.isArray(i)&&this.validateEntity(t,i,r);return r}validateEntity(e,r,t){for(let[i,a]of Object.entries(r)){let n=a?.toString()??"";if(n&&d.NAMESPACE_PREFIX_PATTERN.test(n)){let o=this.getSuggestionForPrefixedValue(n),c=e.split(".")[0],s=new g;s.ruleType=this.ruleName,s.severity="Error",s.entityName=c,s.propertyName=e,s.actualValue=i,s.expectedValue=o,s.message=`Invalid namespace prefix '${n}'. Use '${o}' without prefix.`,s.suggestion="Kanonak YAML uses simple type names. Namespace resolution is handled through imports.",t.push(s)}a&&typeof a=="object"&&!Array.isArray(a)&&this.validateEntity(`${e}.${i}`,a,t)}}getSuggestionForPrefixedValue(e){let r=e.toLowerCase();if(r==="rdfs:class"||r==="owl:class")return"Class";if(r==="rdfs:property"||r==="rdf:property")return"DatatypeProperty or ObjectProperty";if(r.startsWith("xsd:"))return e.substring(4);let t=e.indexOf(":");return t>=0?e.substring(t+1):e}};var I=class d{static RESERVED_WORDS=new Set(["kanonak","imports","namespace","type","label","comment","subclassof","domain","range","required","functional"]);static VALID_PROPERTIES=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","required","functional","inverseOf","transitive","symmetric","inverseFunctional"]);static VALID_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_AUGMENTATION_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*\.[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_PROPERTY_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_.]*$/;ruleName="ResourceNaming";validate(e){let r=[],t=e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-");for(let[i,a]of Object.entries(e.body)){let n=d.VALID_AUGMENTATION_PATTERN.test(i);if(!n&&!t&&d.RESERVED_WORDS.has(i.toLowerCase())){let o=new g;o.ruleType=this.ruleName,o.severity="Error",o.entityName=i,o.message=`Entity name '${i}' is a reserved word and cannot be used.`,o.suggestion="Choose a different name that doesn't conflict with Kanonak reserved words.",r.push(o);continue}if(!n&&!d.VALID_NAME_PATTERN.test(i)){let o;/^\d/.test(i)?o="Entity names must start with a letter, not a number.":i.includes(" ")?o="Entity names cannot contain spaces. Use camelCase or underscores instead.":o="Entity names must start with a letter and contain only letters, numbers, and underscores.";let c=new g;c.ruleType=this.ruleName,c.severity="Error",c.entityName=i,c.message=`Invalid entity name '${i}'. ${o}`,c.suggestion=o,r.push(c)}a&&typeof a=="object"&&!Array.isArray(a)&&this.validatePropertyNames(i,a,r)}return r}validatePropertyNames(e,r,t){for(let i of Object.keys(r))if(!d.VALID_PROPERTIES.has(i)&&!d.VALID_PROPERTY_NAME_PATTERN.test(i)){let a=new g;a.ruleType=this.ruleName,a.severity="Warning",a.entityName=e,a.propertyName=i,a.message=`Property name '${i}' in entity '${e}' doesn't follow naming conventions.`,a.suggestion="Property names should start with a letter and contain only letters, numbers, and underscores.",t.push(a)}}};var O=class d{static XSD_TYPES=new Set(["string","integer","int","long","short","byte","decimal","float","double","boolean","bool","datetime","date","time","duration","anyuri","anysimpletype","nonnegativeinteger","positiveinteger","negativeinteger","nonpositiveinteger","unsignedint","unsignedlong","unsignedshort","unsignedbyte","base64binary","hexbinary"]);ruleName="PropertyTypeSpecificity";validate(e){let r=[];if(e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-"))return r;let t=this.isPropertyDefinedAsClass(e);for(let[i,a]of Object.entries(e.body))if(a&&typeof a=="object"&&!Array.isArray(a)){let n=a,o=n.type;if(o){let c=[];if(Array.isArray(o))for(let s of o){let l=s?.toString();l&&l==="Property"&&!t&&c.push(l)}else{let s=o?.toString();s&&s==="Property"&&!t&&c.push(s)}for(let s of c){let l=this.getPropertyValue(n,"range"),p=this.determinePropertyType(l),y=new g;y.ruleType=this.ruleName,y.severity="Error",y.entityName=i,y.propertyName="type",y.actualValue=s,y.expectedValue=p,y.message=`Invalid property type '${s}'. Use '${p}' instead.`,y.suggestion="Properties should specify their type: DatatypeProperty for data values, ObjectProperty for relationships.",r.push(y)}}}return r}determinePropertyType(e){return!e||e.trim().length===0?"DatatypeProperty or ObjectProperty":d.XSD_TYPES.has(e.toLowerCase())?"DatatypeProperty":/^[A-Z]/.test(e)?"ObjectProperty":"DatatypeProperty or ObjectProperty"}getPropertyValue(e,r){let t=e[r];return t?t.toString():null}isPropertyDefinedAsClass(e){let r=e.body.Property;if(r&&typeof r=="object"&&!Array.isArray(r)){let i=r.type;if(i){let a=i.toString();return a==="Class"||a.endsWith(".Class")}}return!1}};var w=class{get ruleName(){return"SubjectKanonakTypeRequired"}validate(e){let r=[];for(let[t,i]of Object.entries(e.body)){if(typeof i!="object"||i===null||Array.isArray(i)||t.includes("."))continue;let a=i,n="type"in a,o=a.type?.toString().trim();if(!n||!o){let c=new g;c.ruleType=this.ruleName,c.severity="Error",c.entityName=t,c.propertyName="type",c.message=`Subject Kanonak '${t}' must have a 'type' property.`,c.suggestion=`Add a type statement like:
|
|
1
|
+
import{a as ye}from"./chunk-FJ35VIV6.js";import{a as se,c as le,e as Z}from"./chunk-4YHWMYAZ.js";import{c as J,k as ae,l as ce}from"./chunk-W6T7MOKY.js";import{a as ie}from"./chunk-7CUTGGH3.js";import{c as A}from"./chunk-FQHALFRR.js";import{a as P,b as V,c as pe}from"./chunk-5ILSX24H.js";var D=class{isValid=!1;errors=[];warnings=[];get totalIssues(){return this.errors.length+this.warnings.length}};var R=(r=>(r.Warning="Warning",r.Error="Error",r))(R||{});var g=class{ruleType="";severity="Error";lineNumber;column;entityName;propertyName;propertyPath;message="";suggestion;actualValue;expectedValue;toString(){let e="";return this.lineNumber!==void 0&&(e+=`Line ${this.lineNumber}: `),this.entityName&&(e+=`[${this.entityName}] `),e+=this.message,e}};var Q=class d{resolvedDocuments=[];currentEntityPath;withPath(e){let r=new d;return r.resolvedDocuments=this.resolvedDocuments,r.currentEntityPath=e,r}};var te=class{constructor(e){this.underlying=e;this.repository=new re(e)}underlying;repository;kanonaksPromise=null;importClosureCache=new Map;classDeclarationsCache=new Map;propertyNamesCache=new Map;allDocumentsPromise=null;getKanonaks(){return this.kanonaksPromise||(this.kanonaksPromise=new Z().parseKanonaks(this.underlying)),this.kanonaksPromise}async getImportClosure(e){let r=this.importClosureCache.get(e);return r||(r=this.computeImportClosure(e),this.importClosureCache.set(e,r),r)}async getClassDeclarations(e){let r=this.classDeclarationsCache.get(e);return r||(r=this.computeClassDeclarations(e),this.classDeclarationsCache.set(e,r),r)}async getPropertyNames(e){let r=this.propertyNamesCache.get(e);return r||(r=this.computePropertyNames(e),this.propertyNamesCache.set(e,r),r)}getAllDocuments(){return this.allDocumentsPromise||(this.allDocumentsPromise=this.underlying.getAllDocumentsAsync()),this.allDocumentsPromise}async computeImportClosure(e){let r=new Set([e]),t=[e],i=await this.buildDocsByIdIndex();for(;t.length>0;){let a=t.shift(),n=i.get(a);if(n?.metadata.imports)for(let[o,c]of Object.entries(n.metadata.imports))for(let s of c){let l=await this.repository.getHighestCompatibleVersionAsync(o,s);if(!l)continue;let p=ee(l);!p||r.has(p)||(r.add(p),t.push(p))}}return r}async buildDocsByIdIndex(){let e=await this.getAllDocuments(),r=new Map;for(let t of e){let i=ee(t);i&&r.set(i,t)}return r}async computeClassDeclarations(e){let r=await this.findDocById(e),t=new Map;if(!r)return t;for(let[i,a]of Object.entries(r.body)){if(!me(a))continue;let n=a,o=ue(n,"type");if(o==="Class"||o?.endsWith(".Class")){let c=ge(n);t.set(i,c)}}return t}async computePropertyNames(e){let r=await this.findDocById(e),t=new Set;if(!r)return t;for(let[i,a]of Object.entries(r.body)){if(!me(a))continue;let o=ue(a,"type");(o==="ObjectProperty"||o?.endsWith(".ObjectProperty")||o==="DatatypeProperty"||o?.endsWith(".DatatypeProperty")||o==="AnnotationProperty"||o?.endsWith(".AnnotationProperty")||o==="Property"||o?.endsWith(".Property"))&&t.add(i)}return t}async findDocById(e){let r=await this.getAllDocuments();for(let t of r)if(ee(t)===e)return t}};function ee(d){let e=d.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${A(e.version)}`}function me(d){return typeof d=="object"&&d!==null&&!Array.isArray(d)}function ue(d,e){if(e in d)return fe(d[e]);for(let r of Object.keys(d))if(r.endsWith(`.${e}`))return fe(d[r])}function fe(d){return Array.isArray(d)?d.length>0?String(d[0]):void 0:d==null?void 0:String(d)}function ge(d){let e=d.subClassOf;if(e===void 0){for(let r of Object.keys(d))if(r.endsWith(".subClassOf")){e=d[r];break}}return P(e)}var re=class{constructor(e){this.inner=e}inner;highestVersionCache=new Map;byNamespaceCache=new Map;getAllDocumentsAsync(){return this.inner.getAllDocumentsAsync()}getDocumentAsync(e){return this.inner.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,r){let t=`${e}/${r}`,i=this.byNamespaceCache.get(t);return i||(i=this.inner.getDocumentsByNamespaceAsync(e,r),this.byNamespaceCache.set(t,i),i)}getHighestCompatibleVersionAsync(e,r){let t=r.version,i=t?`${t.major}.${t.minor}.${t.patch}`:"",a=`${e}/${r.packageName}@${r.versionOperator}:${i}`,n=this.highestVersionCache.get(a);return n||(n=this.inner.getHighestCompatibleVersionAsync(e,r),this.highestVersionCache.set(a,n),n)}saveDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}deleteDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}clearNamespaceAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}getAllDocumentReferencesAsync(){return this.inner.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.inner.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.inner.getDocumentUriAsync(e)}};var v=class d{static NAMESPACE_PREFIX_PATTERN=/^(rdfs|xsd|owl|rdf|dc|foaf|skos|dct|dcterms|geo|time|prov|schema|og|dbo):/i;ruleName="NamespacePrefix";validate(e){let r=[];for(let[t,i]of Object.entries(e.body))i&&typeof i=="object"&&!Array.isArray(i)&&this.validateEntity(t,i,r);return r}validateEntity(e,r,t){for(let[i,a]of Object.entries(r)){let n=a?.toString()??"";if(n&&d.NAMESPACE_PREFIX_PATTERN.test(n)){let o=this.getSuggestionForPrefixedValue(n),c=e.split(".")[0],s=new g;s.ruleType=this.ruleName,s.severity="Error",s.entityName=c,s.propertyName=e,s.actualValue=i,s.expectedValue=o,s.message=`Invalid namespace prefix '${n}'. Use '${o}' without prefix.`,s.suggestion="Kanonak YAML uses simple type names. Namespace resolution is handled through imports.",t.push(s)}a&&typeof a=="object"&&!Array.isArray(a)&&this.validateEntity(`${e}.${i}`,a,t)}}getSuggestionForPrefixedValue(e){let r=e.toLowerCase();if(r==="rdfs:class"||r==="owl:class")return"Class";if(r==="rdfs:property"||r==="rdf:property")return"DatatypeProperty or ObjectProperty";if(r.startsWith("xsd:"))return e.substring(4);let t=e.indexOf(":");return t>=0?e.substring(t+1):e}};var I=class d{static RESERVED_WORDS=new Set(["kanonak","imports","namespace","type","label","comment","subclassof","domain","range","required","functional"]);static VALID_PROPERTIES=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","required","functional","inverseOf","transitive","symmetric","inverseFunctional"]);static VALID_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_AUGMENTATION_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*\.[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_PROPERTY_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_.]*$/;ruleName="ResourceNaming";validate(e){let r=[],t=e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-");for(let[i,a]of Object.entries(e.body)){let n=d.VALID_AUGMENTATION_PATTERN.test(i);if(!n&&!t&&d.RESERVED_WORDS.has(i.toLowerCase())){let o=new g;o.ruleType=this.ruleName,o.severity="Error",o.entityName=i,o.message=`Entity name '${i}' is a reserved word and cannot be used.`,o.suggestion="Choose a different name that doesn't conflict with Kanonak reserved words.",r.push(o);continue}if(!n&&!d.VALID_NAME_PATTERN.test(i)){let o;/^\d/.test(i)?o="Entity names must start with a letter, not a number.":i.includes(" ")?o="Entity names cannot contain spaces. Use camelCase or underscores instead.":o="Entity names must start with a letter and contain only letters, numbers, and underscores.";let c=new g;c.ruleType=this.ruleName,c.severity="Error",c.entityName=i,c.message=`Invalid entity name '${i}'. ${o}`,c.suggestion=o,r.push(c)}a&&typeof a=="object"&&!Array.isArray(a)&&this.validatePropertyNames(i,a,r)}return r}validatePropertyNames(e,r,t){for(let i of Object.keys(r))if(!d.VALID_PROPERTIES.has(i)&&!d.VALID_PROPERTY_NAME_PATTERN.test(i)){let a=new g;a.ruleType=this.ruleName,a.severity="Warning",a.entityName=e,a.propertyName=i,a.message=`Property name '${i}' in entity '${e}' doesn't follow naming conventions.`,a.suggestion="Property names should start with a letter and contain only letters, numbers, and underscores.",t.push(a)}}};var O=class d{static XSD_TYPES=new Set(["string","integer","int","long","short","byte","decimal","float","double","boolean","bool","datetime","date","time","duration","anyuri","anysimpletype","nonnegativeinteger","positiveinteger","negativeinteger","nonpositiveinteger","unsignedint","unsignedlong","unsignedshort","unsignedbyte","base64binary","hexbinary"]);ruleName="PropertyTypeSpecificity";validate(e){let r=[];if(e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-"))return r;let t=this.isPropertyDefinedAsClass(e);for(let[i,a]of Object.entries(e.body))if(a&&typeof a=="object"&&!Array.isArray(a)){let n=a,o=n.type;if(o){let c=[];if(Array.isArray(o))for(let s of o){let l=s?.toString();l&&l==="Property"&&!t&&c.push(l)}else{let s=o?.toString();s&&s==="Property"&&!t&&c.push(s)}for(let s of c){let l=this.getPropertyValue(n,"range"),p=this.determinePropertyType(l),y=new g;y.ruleType=this.ruleName,y.severity="Error",y.entityName=i,y.propertyName="type",y.actualValue=s,y.expectedValue=p,y.message=`Invalid property type '${s}'. Use '${p}' instead.`,y.suggestion="Properties should specify their type: DatatypeProperty for data values, ObjectProperty for relationships.",r.push(y)}}}return r}determinePropertyType(e){return!e||e.trim().length===0?"DatatypeProperty or ObjectProperty":d.XSD_TYPES.has(e.toLowerCase())?"DatatypeProperty":/^[A-Z]/.test(e)?"ObjectProperty":"DatatypeProperty or ObjectProperty"}getPropertyValue(e,r){let t=e[r];return t?t.toString():null}isPropertyDefinedAsClass(e){let r=e.body.Property;if(r&&typeof r=="object"&&!Array.isArray(r)){let i=r.type;if(i){let a=i.toString();return a==="Class"||a.endsWith(".Class")}}return!1}};var w=class{get ruleName(){return"SubjectKanonakTypeRequired"}validate(e){let r=[];for(let[t,i]of Object.entries(e.body)){if(typeof i!="object"||i===null||Array.isArray(i)||t.includes("."))continue;let a=i,n="type"in a,o=a.type?.toString().trim();if(!n||!o){let c=new g;c.ruleType=this.ruleName,c.severity="Error",c.entityName=t,c.propertyName="type",c.message=`Subject Kanonak '${t}' must have a 'type' property.`,c.suggestion=`Add a type statement like:
|
|
2
2
|
type: Scene
|
|
3
3
|
|
|
4
4
|
Only embedded objects can infer type from their parent property's range. Subject Kanonaks (top-level entities) must explicitly declare their type.`,c.expectedValue="A valid class name (Scene, Character, Story, etc.)",r.push(c)}}return r}};var j=class{get ruleName(){return"EmbeddedKanonakType"}async validateAsync(e,r){let t=[],i=new V(r),a=await this.buildPropertyRangeMap(e,i);for(let[n,o]of Object.entries(e.body))typeof o=="object"&&o!==null&&!Array.isArray(o)&&await this.checkEmbeddedTypes(n,o,void 0,a,i,e,t,0);return t}pickRange(e,r,t){if(e.length===0)return;if(e.length===1)return e[0].range;let i=r.indexOf(".");if(i>0){let a=r.substring(0,i),n=e.find(o=>o.declaringAlias===a);if(n)return n.range}if(t){let a=this.localName(t),n=e.find(o=>this.localName(o.domain)===a);if(n)return n.range}return e[0].range}async checkEmbeddedTypes(e,r,t,i,a,n,o,c){if(c>0){let l=r.type;if(l!=null){let p=await this.validateEmbeddedType(e,String(l),t,a,n);p&&o.push(p)}}let s=r.type!==void 0&&r.type!==null?String(r.type):void 0;for(let[l,p]of Object.entries(r)){let y=this.localName(l),m=i.get(y),f=(m!==void 0?this.pickRange(m,l,s):void 0)??t;if(typeof p=="object"&&p!==null)if(Array.isArray(p))for(let b=0;b<p.length;b++){let h=p[b];typeof h=="object"&&h!==null&&!Array.isArray(h)&&await this.checkEmbeddedTypes(`${e}.${l}[${b}]`,h,f,i,a,n,o,c+1)}else await this.checkEmbeddedTypes(`${e}.${l}`,p,f,i,a,n,o,c+1)}}async validateEmbeddedType(e,r,t,i,a){if(r.length===0||!t)return null;let n=this.localName(r),o=this.localName(t);if(o==="Resource"||o==="Class")return null;let c=e.split(".")[0];if(n===o){let l=new g;return l.ruleType=this.ruleName,l.severity="Warning",l.entityName=c,l.propertyName=e,l.actualValue=r,l.expectedValue=t,l.message=`Embedded object at '${e}' declares 'type: ${r}', which equals the parent property's range '${t}'. The declaration is redundant \u2014 the type is already inferred from the property's range.`,l.suggestion=`Remove the 'type: ${r}' line, or keep it if explicitness is preferred over concision.`,l}if(await i.isSubclassOfAsync(r,t,a)||(n!==r||o!==t)&&await i.isSubclassOfAsync(n,o,a))return null;let s=new g;return s.ruleType=this.ruleName,s.severity="Error",s.entityName=c,s.propertyName=e,s.actualValue=r,s.expectedValue=t,s.message=`Embedded object at '${e}' has 'type: ${r}', which is not a subclass of the parent property's range '${t}'.`,s.suggestion=`Either remove the 'type: ${r}' line (so the type is inferred from the property's range '${t}'), or add 'subClassOf: ${t}' to the '${r}' class definition so the relationship holds.`,s}localName(e){let r=e.lastIndexOf(".");return r<0||r===e.length-1?e:e.substring(r+1)}async buildPropertyRangeMap(e,r){let t=new Map,i=await r.buildEntityIndexAsync(e),a=new Map;for(let[n,o]of i){let c=o.entity.type;if(c==null)continue;let s=String(c),l=this.localName(s);if(!(l==="Property"||l==="DatatypeProperty"||l==="ObjectProperty"||l==="AnnotationProperty"))continue;let y=o.entity.range;if(y==null)continue;let m=String(y);if(m.length===0)continue;let u=o.entity.domain,f=u!=null?String(u):"",b=o.uri.toString(),h=a.get(b),k=n.includes(".");(!h||k&&!h.entityName.includes("."))&&a.set(b,{entityName:n,domain:f,range:m})}for(let n of a.values()){let o=this.localName(n.entityName),c=n.entityName.indexOf("."),s=c>0?n.entityName.substring(0,c):void 0,l=t.get(o)??[];l.push({domain:n.domain,range:n.range,declaringAlias:s}),t.set(o,l)}return t}};var N=class{ruleName="ImportExistence";async validateAsync(e,r){let t=[];if(!e.metadata?.imports)return t;let i=await r.getAllDocumentsAsync();for(let[a,n]of Object.entries(e.metadata.imports))for(let o of n)if(!await r.getHighestCompatibleVersionAsync(a,o)){let s=await this.determineImportErrorAsync(r,a,o,i),l=new g;l.ruleType=this.ruleName,l.severity="Error",l.message=s.message,l.suggestion=s.suggestion,l.entityName=`Import: ${a}/${o.packageName}`,l.actualValue=o.toString(),l.expectedValue=s.expectedValue,t.push(l)}return t}async determineImportErrorAsync(e,r,t,i){let a=await e.getDocumentsByNamespaceAsync(r,t.packageName);if(a.length===0){let s=i.filter(m=>m.metadata.namespace_?.publisher===r).map(m=>m.metadata.namespace_.package_).filter((m,u,f)=>f.indexOf(m)===u),l=this.findSimilarPackages(t.packageName,s),p=`Import '${r}/${t.package_}' not found - package does not exist`,y=l.length>0?`Did you mean: ${l.slice(0,3).join(", ")}?`:s.length>0?`Available packages in ${r}: ${s.slice(0,5).join(", ")}`:`No packages found for publisher '${r}'. Verify the publisher name is correct.`;return{message:p,suggestion:y,expectedValue:"Existing package"}}let o=a.filter(s=>s.metadata.namespace_?.version).map(s=>s.metadata.namespace_.version.toString()).sort().join(", "),c=this.getAcceptableVersionRange(t);return{message:`Import '${r}/${t.toString()}' version mismatch - no compatible version found`,suggestion:`Available versions: ${o}. Required: ${c}`,expectedValue:c}}getAcceptableVersionRange(e){switch(e.versionOperator){case 0:return`exactly ${e.version.major}.${e.version.minor}.${e.version.patch}`;case 1:return`${e.version.major}.${e.version.minor}.${e.version.patch} to ${e.version.major}.${e.version.minor}.x`;case 2:return e.version.major===0?`0.${e.version.minor}.x`:`${e.version.major}.x.x`;case 3:return`any version >= ${e.version.major}.${e.version.minor}.${e.version.patch}`;default:return e.toString()}}findSimilarPackages(e,r){if(r.length===0)return[];let t=r.filter(n=>n.toLowerCase().includes(e.toLowerCase())||e.toLowerCase().includes(n.toLowerCase()));if(t.length>0)return t.sort((n,o)=>n.length-o.length);let i=r.map(n=>({package:n,distance:this.levenshteinDistance(e.toLowerCase(),n.toLowerCase())})).sort((n,o)=>n.distance-o.distance),a=Math.max(3,Math.floor(e.length*.4));return i.filter(n=>n.distance<=a).map(n=>n.package)}levenshteinDistance(e,r){if(!e||e.length===0)return r?.length??0;if(!r||r.length===0)return e.length;let t=e.length,i=r.length,a=Array(t+1).fill(null).map(()=>Array(i+1).fill(0));for(let n=0;n<=t;n++)a[n][0]=n;for(let n=0;n<=i;n++)a[0][n]=n;for(let n=1;n<=t;n++)for(let o=1;o<=i;o++){let c=e[n-1]===r[o-1]?0:1;a[n][o]=Math.min(Math.min(a[n-1][o]+1,a[n][o-1]+1),a[n-1][o-1]+c)}return a[t][i]}};var $=class{ruleName="UnresolvedReference";async validateAsync(e,r){let t=[],i=new V(r),a=await i.buildEntityIndexAsync(e),n=new Set;for(let[o,c]of a.entries()){let s=c.entity.type;if(s){let l=s.toString();(l==="ObjectProperty"||l.endsWith(".ObjectProperty"))&&n.add(o)}}for(let[o,c]of Object.entries(e.body)){if(!c||typeof c!="object"||Array.isArray(c))continue;let s=c,l=this.getPropertyValue(s,"type");if(!(!l||l==="Class"||l.endsWith("Property")||l==="AnnotationProperty"))for(let[p,y]of Object.entries(s))p==="type"||p==="label"||p==="comment"||!(n.has(p)||Array.from(n).some(u=>u.endsWith(`.${p}`)))||await this.validateReferenceValue(o,p,y,e,i,t)}return t}async validateReferenceValue(e,r,t,i,a,n){if(t!=null){if(typeof t=="string")await a.resolveEntityAsync(t,i)||n.push(this.createUnresolvedReferenceError(e,r,t));else if(Array.isArray(t))for(let o=0;o<t.length;o++){let c=t[o];typeof c=="string"&&(await a.resolveEntityAsync(c,i)||n.push(this.createUnresolvedReferenceError(e,`${r}[${o}]`,c)))}}}createUnresolvedReferenceError(e,r,t){let i=`The entity '${t}' cannot be found in the current document or any imported namespaces.
|
|
@@ -39,7 +39,7 @@ ${h.slice(1).map(k=>` - ${k}`).join(`
|
|
|
39
39
|
3. Create a different property for '${t}'`,expectedValue:`Property used on ${y} or its subclasses`})}if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let m=c,u=this.getPropertyValue(m,"type");if(u){let f=`${r}.${o}`;this.validateEntityProperties(m,f,u,i,a,n)}else{let f=this.getPropertyValue(p,"range");if(f){let b=`${r}.${o}`;this.validateEntityProperties(m,b,f,i,a,n)}}}else if(Array.isArray(c))for(let m=0;m<c.length;m++){let u=c[m];if(typeof u=="object"&&u!==null&&!Array.isArray(u)){let f=u,b=this.getPropertyValue(f,"type");if(b){let h=`${r}.${o}[${m}]`;this.validateEntityProperties(f,h,b,i,a,n)}else{let h=this.getPropertyValue(p,"range");if(h){let k=`${r}.${o}[${m}]`;this.validateEntityProperties(f,k,h,i,a,n)}}}}}}}isTypeCompatibleWithDomain(e,r,t){if(e===r)return!0;let i=new Set,a=[e];for(;a.length>0;){let n=a.shift();if(i.has(n))continue;i.add(n);let o=t.get(n);if(o)for(let c of o){if(c===r)return!0;a.push(c)}}return!1}getPropertyValue(e,r){if(r in e){let t=e[r];return this.extractFirstValue(t)}for(let t of Object.keys(e))if(t.endsWith(`.${r}`)){let i=e[t];return this.extractFirstValue(i)}}extractFirstValue(e){if(Array.isArray(e)){let r=[];for(let t of e)r.push(t?.toString()??"");return r.length>0?r[0]:void 0}return e?.toString()}};function he(d){let e=d.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${A(e.version)}`}var X=class{get ruleName(){return"PropertyValueType"}async validateAsync(e,r){let t=[],i=new Map;for(let[a,n]of Object.entries(e.body))if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let o=n,c=this.getPropertyValue(o,"type");(c==="DatatypeProperty"||c==="ObjectProperty")&&i.set(a,o)}for(let[a,n]of Object.entries(e.body)){if(typeof n!="object"||n===null||Array.isArray(n))continue;let o=n,c=this.getPropertyValue(o,"type");if(!(!c||c==="Class"||c.endsWith("Property")||c==="AnnotationProperty"))for(let[s,l]of Object.entries(o)){if(s==="type"||s==="label"||s==="comment")continue;let p=s,y=s.lastIndexOf(".");y>0&&y<s.length-1&&(p=s.substring(y+1));let m=i.get(p);if(!m)continue;let u=this.getPropertyValue(m,"type"),f=this.getPropertyValue(m,"range");if(u==="DatatypeProperty"){if(typeof l=="object"&&l!==null&&!Array.isArray(l)||Array.isArray(l))t.push({ruleType:this.ruleName,severity:"Error",entityName:a,propertyName:s,message:`Property '${s}' is a DatatypeProperty with range '${f}' but instance '${a}' has a complex object value`,suggestion:`Either:
|
|
40
40
|
1. Create a class for this data and change '${s}' to an ObjectProperty
|
|
41
41
|
2. Store as a JSON string to keep it as DatatypeProperty
|
|
42
|
-
3. Use separate properties instead of nesting`,expectedValue:`A simple value of type '${f}'`});else if(!this.validateDatatypeValue(f,l)){let b={ruleType:this.ruleName,severity:"Error",entityName:a,propertyName:s,message:`Property '${s}' expects type '${f}' but instance '${a}' has value of type '${this.getValueTypeName(l)}'`,suggestion:`Provide a value of type '${f}'`,toString:()=>""};f&&(b.expectedValue=f),t.push(b)}}else if(u==="ObjectProperty")if(Array.isArray(l))for(let b=0;b<l.length;b++){let h=l[b];typeof h!="string"&&(typeof h!="object"||h===null||Array.isArray(h))&&t.push({ruleType:this.ruleName,severity:"Error",entityName:a,propertyName:`${s}[${b}]`,message:`ObjectProperty '${s}' array item ${b} in instance '${a}' has invalid type '${this.getValueTypeName(h)}'`,suggestion:"Array items must be references (strings) or embedded objects (dictionaries)",expectedValue:"string or object"})}else typeof l!="string"&&(typeof l!="object"||l===null||Array.isArray(l))&&t.push({ruleType:this.ruleName,severity:"Error",entityName:a,propertyName:s,message:`ObjectProperty '${s}' in instance '${a}' has invalid value type '${this.getValueTypeName(l)}'`,suggestion:"Value must be a reference (string), embedded object (dictionary), or array of these",expectedValue:`Reference to ${f} or embedded ${f} object`})}}return t}validateDatatypeValue(e,r){switch(e?.toLowerCase()){case"string":return typeof r=="string";case"integer":case"int":return typeof r=="number"&&Number.isInteger(r);case"decimal":return typeof r=="number";case"boolean":return typeof r=="boolean";case"float":case"double":return typeof r=="number";default:return!0}}getValueTypeName(e){return typeof e=="string"?"string":typeof e=="number"?Number.isInteger(e)?"integer":"decimal":typeof e=="boolean"?"boolean":Array.isArray(e)?"array":typeof e=="object"&&e!==null?"object":e===null?"null":e===void 0?"undefined":typeof e}getPropertyValue(e,r){if(r in e){let t=e[r];if(Array.isArray(t)){let i=[];for(let a of t)i.push(a?.toString()??"");return i.length>0?i[0]:void 0}return t?.toString()}}};var z=class{builtInClasses=new Set(["Resource","Class","Literal","Thing","Nothing","Property","DatatypeProperty","ObjectProperty","AnnotationProperty","FunctionalProperty","InverseFunctionalProperty","TransitiveProperty","SymmetricProperty"]);get ruleName(){return"ClassDefinition"}async validateAsync(e,r){let t=[],i=new Map,a=new Set;for(let[o,c]of Object.entries(e.body))if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let l=c.type;if(l)if(Array.isArray(l))for(let p of l){let y=p?.toString();if(y==="Class"||y&&y.endsWith(".Class")){a.add(o);break}}else{let p=l?.toString();(p==="Class"||p&&p.endsWith(".Class"))&&a.add(o)}}for(let[o,c]of Object.entries(e.body))if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let s=c,l=s.type;if(l)if(Array.isArray(l)){let p=!1;for(let y of l){let m=y?.toString();if(m&&this.isDefinitionType(m)){p=!0;break}}if(!p)for(let y of l){let m=y?.toString();m&&m.trim().length>0&&(i.has(m)||i.set(m,[]),i.get(m).push(o))}}else{let p=l?.toString();p&&p.trim().length>0&&(this.isDefinitionType(p)||(i.has(p)||i.set(p,[]),i.get(p).push(o)))}this.checkNestedTypes(s,o,i,o)}let n=new V(r);for(let[o,c]of i){if(this.builtInClasses.has(o)||a.has(o))continue;let s=await n.resolveEntityAsync(o,e);if(!(s&&this.isClassEntity(s.entity))){let p=Array.from(new Set(c)).sort();for(let y of p)t.push({ruleType:this.ruleName,severity:"Error",message:`Class '${o}' is not defined or imported`,suggestion:`Define '${o}' as a Class in this document, or import a namespace that contains it`,entityName:y,propertyName:"type",actualValue:o,expectedValue:"Defined or imported class"})}}return t}checkNestedTypes(e,r,t,i){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let a=e,n=a.type;if(n){let o=new Set(["Class","DatatypeProperty","ObjectProperty","AnnotationProperty"]);if(Array.isArray(n))for(let c of n){let s=c?.toString();s&&s.trim().length>0&&!o.has(s)&&(t.has(s)||t.set(s,[]),t.get(s).push(i))}else{let c=n?.toString();c&&c.trim().length>0&&!o.has(c)&&(t.has(c)||t.set(c,[]),t.get(c).push(i))}}for(let[o,c]of Object.entries(a))if(o!=="type"){let s=`${i}.${o}`;this.checkNestedTypes(c,r,t,s)}}else if(Array.isArray(e))for(let a=0;a<e.length;a++){let n=`${i}[${a}]`;this.checkNestedTypes(e[a],r,t,n)}}isClassEntity(e){if(!e)return!1;let r=e.type;if(!r)return!1;if(Array.isArray(r))for(let t of r){let i=t?.toString();if(i==="Class"||i&&i.endsWith(".Class"))return!0}else{let t=r?.toString();if(t==="Class"||t&&t.endsWith(".Class"))return!0}return!1}isDefinitionType(e){return!e||e.trim().length===0?!1:new Set(["Class","Property","DatatypeProperty","ObjectProperty","AnnotationProperty"]).has(e)?!0:e.endsWith(".Class")||e.endsWith(".Property")||e.endsWith(".DatatypeProperty")||e.endsWith(".ObjectProperty")||e.endsWith(".AnnotationProperty")}};var Y=class{ruleName="MarkdownLink";async validateAsync(e,r,t){let i=[],a;if(t){let n=await t.getKanonaks(),o=be(e);a=o?n.filter(c=>c instanceof J&&c.namespace===o):[]}else{let n=new ye(e,r);a=await new Z().parseKanonaks(n)}for(let n of a)n instanceof J&&this.checkDefined(n,n.name,i);return i}checkDefined(e,r,t){for(let i of e.statement)if(i instanceof le){let a=i.predicate.subject?.name??"(unknown)";for(let n of i.links)n.target||t.push(this.unresolvedLinkError(r,a,n.reference))}else if(i instanceof ae)this.checkDefined(i.object,r,t);else if(i instanceof ce)for(let a of i.object)a instanceof se&&this.checkDefined(a,r,t)}unresolvedLinkError(e,r,t){let i=new g;return i.ruleType=this.ruleName,i.severity="Warning",i.entityName=e,i.propertyName=r,i.actualValue=t,i.message=`Embedded link [[${t}]] in '${r}' could not be resolved`,i.expectedValue="A reference resolvable through the document's import closure",i.suggestion=`The reference '${t}' inside a markdown value cannot be found in the current document or any imported namespace.
|
|
42
|
+
3. Use separate properties instead of nesting`,expectedValue:`A simple value of type '${f}'`});else if(!this.validateDatatypeValue(f,l)){let b={ruleType:this.ruleName,severity:"Error",entityName:a,propertyName:s,message:`Property '${s}' expects type '${f}' but instance '${a}' has value of type '${this.getValueTypeName(l)}'`,suggestion:`Provide a value of type '${f}'`,toString:()=>""};f&&(b.expectedValue=f),t.push(b)}}else if(u==="ObjectProperty")if(Array.isArray(l))for(let b=0;b<l.length;b++){let h=l[b];typeof h!="string"&&(typeof h!="object"||h===null||Array.isArray(h))&&t.push({ruleType:this.ruleName,severity:"Error",entityName:a,propertyName:`${s}[${b}]`,message:`ObjectProperty '${s}' array item ${b} in instance '${a}' has invalid type '${this.getValueTypeName(h)}'`,suggestion:"Array items must be references (strings) or embedded objects (dictionaries)",expectedValue:"string or object"})}else typeof l!="string"&&(typeof l!="object"||l===null||Array.isArray(l))&&t.push({ruleType:this.ruleName,severity:"Error",entityName:a,propertyName:s,message:`ObjectProperty '${s}' in instance '${a}' has invalid value type '${this.getValueTypeName(l)}'`,suggestion:"Value must be a reference (string), embedded object (dictionary), or array of these",expectedValue:`Reference to ${f} or embedded ${f} object`})}}return t}validateDatatypeValue(e,r){switch(e?.toLowerCase()){case"string":return typeof r=="string";case"integer":case"int":return typeof r=="number"&&Number.isInteger(r);case"decimal":return typeof r=="number";case"boolean":return typeof r=="boolean";case"float":case"double":return typeof r=="number";default:return!0}}getValueTypeName(e){return typeof e=="string"?"string":typeof e=="number"?Number.isInteger(e)?"integer":"decimal":typeof e=="boolean"?"boolean":Array.isArray(e)?"array":typeof e=="object"&&e!==null?"object":e===null?"null":e===void 0?"undefined":typeof e}getPropertyValue(e,r){if(r in e){let t=e[r];if(Array.isArray(t)){let i=[];for(let a of t)i.push(a?.toString()??"");return i.length>0?i[0]:void 0}return t?.toString()}}};var z=class{builtInClasses=new Set(["Resource","Class","Literal","Thing","Nothing","Property","DatatypeProperty","ObjectProperty","AnnotationProperty","FunctionalProperty","InverseFunctionalProperty","TransitiveProperty","SymmetricProperty","Package"]);get ruleName(){return"ClassDefinition"}async validateAsync(e,r){let t=[],i=new Map,a=new Set;for(let[o,c]of Object.entries(e.body))if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let l=c.type;if(l)if(Array.isArray(l))for(let p of l){let y=p?.toString();if(y==="Class"||y&&y.endsWith(".Class")){a.add(o);break}}else{let p=l?.toString();(p==="Class"||p&&p.endsWith(".Class"))&&a.add(o)}}for(let[o,c]of Object.entries(e.body))if(typeof c=="object"&&c!==null&&!Array.isArray(c)){let s=c,l=s.type;if(l)if(Array.isArray(l)){let p=!1;for(let y of l){let m=y?.toString();if(m&&this.isDefinitionType(m)){p=!0;break}}if(!p)for(let y of l){let m=y?.toString();m&&m.trim().length>0&&(i.has(m)||i.set(m,[]),i.get(m).push(o))}}else{let p=l?.toString();p&&p.trim().length>0&&(this.isDefinitionType(p)||(i.has(p)||i.set(p,[]),i.get(p).push(o)))}this.checkNestedTypes(s,o,i,o)}let n=new V(r);for(let[o,c]of i){if(this.builtInClasses.has(o)||a.has(o))continue;let s=await n.resolveEntityAsync(o,e);if(!(s&&this.isClassEntity(s.entity))){let p=Array.from(new Set(c)).sort();for(let y of p)t.push({ruleType:this.ruleName,severity:"Error",message:`Class '${o}' is not defined or imported`,suggestion:`Define '${o}' as a Class in this document, or import a namespace that contains it`,entityName:y,propertyName:"type",actualValue:o,expectedValue:"Defined or imported class"})}}return t}checkNestedTypes(e,r,t,i){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let a=e,n=a.type;if(n){let o=new Set(["Class","DatatypeProperty","ObjectProperty","AnnotationProperty"]);if(Array.isArray(n))for(let c of n){let s=c?.toString();s&&s.trim().length>0&&!o.has(s)&&(t.has(s)||t.set(s,[]),t.get(s).push(i))}else{let c=n?.toString();c&&c.trim().length>0&&!o.has(c)&&(t.has(c)||t.set(c,[]),t.get(c).push(i))}}for(let[o,c]of Object.entries(a))if(o!=="type"){let s=`${i}.${o}`;this.checkNestedTypes(c,r,t,s)}}else if(Array.isArray(e))for(let a=0;a<e.length;a++){let n=`${i}[${a}]`;this.checkNestedTypes(e[a],r,t,n)}}isClassEntity(e){if(!e)return!1;let r=e.type;if(!r)return!1;if(Array.isArray(r))for(let t of r){let i=t?.toString();if(i==="Class"||i&&i.endsWith(".Class"))return!0}else{let t=r?.toString();if(t==="Class"||t&&t.endsWith(".Class"))return!0}return!1}isDefinitionType(e){return!e||e.trim().length===0?!1:new Set(["Class","Property","DatatypeProperty","ObjectProperty","AnnotationProperty"]).has(e)?!0:e.endsWith(".Class")||e.endsWith(".Property")||e.endsWith(".DatatypeProperty")||e.endsWith(".ObjectProperty")||e.endsWith(".AnnotationProperty")}};var Y=class{ruleName="MarkdownLink";async validateAsync(e,r,t){let i=[],a;if(t){let n=await t.getKanonaks(),o=be(e);a=o?n.filter(c=>c instanceof J&&c.namespace===o):[]}else{let n=new ye(e,r);a=await new Z().parseKanonaks(n)}for(let n of a)n instanceof J&&this.checkDefined(n,n.name,i);return i}checkDefined(e,r,t){for(let i of e.statement)if(i instanceof le){let a=i.predicate.subject?.name??"(unknown)";for(let n of i.links)n.target||t.push(this.unresolvedLinkError(r,a,n.reference))}else if(i instanceof ae)this.checkDefined(i.object,r,t);else if(i instanceof ce)for(let a of i.object)a instanceof se&&this.checkDefined(a,r,t)}unresolvedLinkError(e,r,t){let i=new g;return i.ruleType=this.ruleName,i.severity="Warning",i.entityName=e,i.propertyName=r,i.actualValue=t,i.message=`Embedded link [[${t}]] in '${r}' could not be resolved`,i.expectedValue="A reference resolvable through the document's import closure",i.suggestion=`The reference '${t}' inside a markdown value cannot be found in the current document or any imported namespace.
|
|
43
43
|
|
|
44
44
|
Possible solutions:
|
|
45
45
|
\u2022 Import the package that defines '${t}' so the link can resolve
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import{a as N}from"./chunk-NIGFQYVA.js";import{a as P}from"./chunk-4YHWMYAZ.js";import{c as L,d,g as K,h as Q,i as X,j as m,k as C,l as j}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 r=e[n];if(r.trim()===""){n++;continue}let a=/^(\s*)```(\S*)\s*$/.exec(r);if(a){let i=a[2],c=[];for(n++;n<e.length&&!/^(\s*)```\s*$/.test(e[n]);)c.push(e[n]),n++;n++;let l=ne(c.join(`
|
|
4
|
+
`)),p=i?` class="language-${te(i)}"`:"";t.push(`<pre><code${p}>${l}</code></pre>`);continue}let s=/^(#{1,6})\s+(.*)$/.exec(r);if(s){let i=s[1].length,c=T(s[2].trim());t.push(`<h${i}>${c}</h${i}>`),n++;continue}if(r.includes("|")&&n+1<e.length&&Z(e[n+1])){let i=A(r),c=ge(e[n+1]);n+=2;let l=[];for(;n<e.length&&e[n].trim()!==""&&e[n].includes("|");)l.push(A(e[n])),n++;t.push(ke(i,c,l));continue}if(/^\s*[-*]\s+/.test(r)){let i=[];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++,i.push(`<li>${T(c.join(" ").trim())}</li>`)}t.push(`<ul>
|
|
5
|
+
${i.join(`
|
|
6
|
+
`)}
|
|
7
|
+
</ul>`);continue}if(/^\s*\d+\.\s+/.test(r)){let i=[];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++,i.push(`<li>${T(c.join(" ").trim())}</li>`)}t.push(`<ol>
|
|
8
|
+
${i.join(`
|
|
9
|
+
`)}
|
|
10
|
+
</ol>`);continue}let o=[r];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]));)o.push(e[n]),n++;t.push(`<p>${T(o.join(" "))}</p>`)}return t.join(`
|
|
11
|
+
`)}function Z(u){return u.includes("-")?/^[\s|:-]+$/.test(u):!1}function A(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 A(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=s=>{let o=e[s];return o?` style="text-align:${o}"`:""},r=u.map((s,o)=>`<th${n(o)}>${T(s)}</th>`).join(""),a=t.map(s=>`<tr>${s.map((i,c)=>`<td${n(c)}>${T(i)}</td>`).join("")}</tr>`).join(`
|
|
12
|
+
`);return`<table>
|
|
13
|
+
<thead><tr>${r}</tr></thead>
|
|
14
|
+
<tbody>
|
|
15
|
+
${a}
|
|
16
|
+
</tbody>
|
|
17
|
+
</table>`}function T(u){let e=ne(u);return e=e.replace(/`([^`\n]+)`/g,(t,n)=>`<code>${n}</code>`),e=e.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(t,n,r)=>`<a href="${te(r)}">${n}</a>`),e=e.replace(/\*\*([^*\n]+)\*\*/g,(t,n)=>`<strong>${n}</strong>`),e=e.replace(/(^|[^*])\*([^*\n]+)\*(?!\*)/g,(t,n,r)=>`${n}<em>${r}</em>`),e=e.replace(/(^|[\s(])_([^_\n]+)_(?=[\s).,;:!?]|$)/g,(t,n,r)=>`${n}<em>${r}</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"},H={publisher:"kanonak.org",package_:"derivation",name:"tokens"},U={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},_={publisher:"kanonak.org",package_:"core-rdf",name:"label"},re={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"},se={publisher:"kanonak.org",package_:"look",name:"Markdown"},V={publisher:"kanonak.org",package_:"look",name:"NavGroup"},M={publisher:"kanonak.org",package_:"look",name:"NavLink"},oe={publisher:"kanonak.org",package_:"look",name:"target"},Re={publisher:"kanonak.org",package_:"look",name:"ResourceGrid"};var ve={publisher:"kanonak.org",package_:"look",name:"semanticSvg"},$e={publisher:"kanonak.org",package_:"look",name:"tierChip"},Ke={publisher:"kanonak.org",package_:"look",name:"tierIcon"},Se={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"},I={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:F(e),package_:(e.namespace||"").split("/")[1]?.split("@")[0]??"",name:e.name}};let n=new Set,r=S(e);for(;r.length>0;){let a=r.shift(),s=w(a.subject);if(n.has(s))continue;n.add(s);let o=b(this.catalog,a.subject);if(!o)continue;let i=Y(o);if(i)return{declaration:i,sourceClass:{publisher:a.subject.publisher,package_:a.subject.package_,name:a.subject.name}};for(let c of x(o))r.push(c)}if(!n.has(w(U))){let a=b(this.catalog,U);if(a){let s=Y(a);if(s)return{declaration:s,sourceClass:{...U}}}}}findCascadedTokens(e){let t=new Map;for(let[a,s]of q(e))t.has(a)||t.set(a,s);let n=new Set,r=S(e);for(;r.length>0;){let a=r.shift(),s=w(a.subject);if(n.has(s))continue;n.add(s);let o=B(this.catalog,a.subject);if(o.length!==0)for(let i of o){for(let[c,l]of q(i))t.has(c)||t.set(c,l);for(let c of x(i))r.push(c)}}if(!n.has(w(U))){let a=B(this.catalog,U);for(let s of a)for(let[o,i]of q(s))t.has(o)||t.set(o,i)}return t}renderSvg(e){let t=g(e,_)??e.name,n=(t.trim().charAt(0)||"?").toUpperCase(),r=`${e.namespace??""}/${e.name}`,a={label:t,firstLetter:n,uri:r},s=this.collectCascadedSvgTiers(e),o=h=>this.applyPlaceholders(h,e,a),i=o(s.tierChip??""),c=o(s.tierIcon??""),l=o(s.tierCard??""),p=o(s.tierFull??""),E=[...this.findCascadedTokens(e)].map(([h,y])=>`--kan-${h}: ${y};`).join(" ");return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400" width="400" height="400" style="${z(E)}">
|
|
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">${i}</g>
|
|
26
|
+
<g class="tier-icon">${c}</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,(r,a)=>{let s=a.trim();if(n[s]!==void 0)return z(n[s]);let o=this.resolvePath(t,s);return o===void 0?`{{${s}}}`:z(o)})}resolvePath(e,t){let n=t.split("/").map(o=>o.trim()).filter(o=>o.length>0);if(n.length===0)return;let r=e;for(let o=0;o<n.length-1;o++){if(!r)return;let i=le(n[o]),c=fe(r,i);if(!c)return;if(c instanceof m&&c.object instanceof d){let l=b(this.catalog,c.object.subject);if(!l)return;r=l}else if(c instanceof C)r=c.object;else return}if(!r)return;let a=le(n[n.length-1]),s=fe(r,a);if(s){if(s instanceof K||s instanceof Q||s instanceof X)return String(s.object);if(s instanceof m&&s.object instanceof d){let o=s.object,i=b(this.catalog,o.subject);return i?g(i,_)??o.subject.name:o.subject.name}}}collectCascadedSvgTiers(e){let t={},n=s=>{let o=O(s,ve);if(!(o instanceof C))return;let i=o.object,c=g(i,$e),l=g(i,Ke),p=g(i,Se),k=g(i,ye);t.tierChip===void 0&&c!==void 0&&(t.tierChip=c),t.tierIcon===void 0&&l!==void 0&&(t.tierIcon=l),t.tierCard===void 0&&p!==void 0&&(t.tierCard=p),t.tierFull===void 0&&k!==void 0&&(t.tierFull=k)};n(e);let r=new Set,a=S(e);for(;a.length>0;){let s=a.shift(),o=w(s.subject);if(r.has(o))continue;r.add(o);let i=B(this.catalog,s.subject);for(let c of i){n(c);for(let l of x(c))a.push(l)}}if(!r.has(w(U)))for(let s of B(this.catalog,U))n(s);return t}renderStylesheet(e){let t=this.findCascadedTokens(e),n=[];for(let[s,o]of t)n.push(` --kan-${s}: ${o};`);let r=n.length>0?`:root {
|
|
30
|
+
${n.join(`
|
|
31
|
+
`)}
|
|
32
|
+
}`:":root { /* no tokens resolved */ }",a=this.findBaseStylesheet(F(e))??"";return`${r}
|
|
33
|
+
${a}`}findBaseStylesheet(e){let t="kanonak.org/site/content",n,r;for(let s of this.catalog){if(!(s instanceof L)||s.name!=="base-stylesheet")continue;let o=s.namespace||"";o.startsWith(`${e}/look-styles@`)?n=s:o.startsWith("kanonak.org/look-styles@")&&(r=s)}let a=n??r;if(a)for(let s of a.statement){let o=s.predicate?.subject;if(!o)continue;if(`${o.publisher}/${o.package_}/${o.name}`===t&&s instanceof K)return s.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 r=F(e),a=[];for(let s of n)a.push(this.renderBand(s,e,r));return a.join(`
|
|
34
|
+
`)}renderDocument(e){let t=this.renderHtml(e),n=this.readPropertyValueText(e,_)??e.name,r=`${e.name}.css`,a=this.hasSvgDerivation(e)?`<figure class="kan-figure"><img src="${f(e.name)}.svg" alt=""></figure>
|
|
35
|
+
`:"",s=F(e),o=this.renderNavGroup(e,s),i=this.renderBreadcrumb(e,s);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(r)}">
|
|
42
|
+
</head>
|
|
43
|
+
<body>
|
|
44
|
+
${o}
|
|
45
|
+
${i}
|
|
46
|
+
<main class="kan-main">
|
|
47
|
+
${a}${t}
|
|
48
|
+
</main>
|
|
49
|
+
</body>
|
|
50
|
+
</html>
|
|
51
|
+
`}hasSvgDerivation(e){let t=new Set,n=S(e);for(;n.length>0;){let r=n.shift(),a=w(r.subject);if(t.has(a))continue;t.add(a);let s=b(this.catalog,r.subject);if(s){for(let o of s.statement)if(o instanceof j&&$(o,"kanonak.org","derivation","derivations")){for(let i of o.object??[])if(i instanceof P)for(let c of i.statement){if(!(c instanceof m)||!$(c,"kanonak.org","derivation","format")||!(c.object instanceof d))continue;let l=c.object.subject;if(l.publisher==="kanonak.org"&&l.package_==="formats"&&l.name==="svg")return!0}}for(let o of x(s))n.push(o)}}return!1}renderBand(e,t,n){let r=ce(e);return r?v(r,he)?this.renderHero(e,t,n):v(r,me)?this.renderPropertyList(e,t,n):v(r,be)?this.renderBadgeRow(e,t,n):v(r,je)?this.renderChipRow(e,t,n):v(r,_e)?this.renderReferenceList(e,t,n):v(r,se)?this.renderMarkdown(e,t):v(r,V)?this.renderNavGroup(t,n):v(r,Re)?this.renderResourceGrid(e,n,t):`<!-- LookRenderer: unsupported band ${r.publisher}/${r.package_}/${r.name} -->`:"<!-- LookRenderer: band has no rdf:type -->"}renderResourceGrid(e,t,n){let r=R(e,I);if(!r)return"<!-- LookRenderer.ResourceGrid: no look.source -->";let a=b(this.catalog,r),s=a?S(a).some(c=>{let l=c.subject.name;return l==="ObjectProperty"||l==="DatatypeProperty"||l==="Property"}):!1,o=[];if(s&&n){let c=this.readPropertyValueReferences(n,r);for(let l of c){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&&o.push(p)}}else o=this.findInstancesOfClass(r);if(o.length===0)return`<!-- LookRenderer.ResourceGrid: no resources for ${r.publisher}/${r.package_}/${r.name} -->`;let i=[];for(let c of o){let l=g(c,_)??c.name,p=g(c,re),k=c.namespace||"",E=k.split("/")[1]?.split("@")[0]??"",h=k.split("@")[1]??"",y=h?this.parseVersion(h):void 0,pe=N.formatResourceUrl({publisher:F(c),package_:E,name:c.name,...y?{version:y}:{}},"=",{contextPublisher:t}),de=p?`<p class="kan-resource-card-subtitle">${f(p)}</p>`:"";i.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">
|
|
52
|
+
${i.join(`
|
|
53
|
+
`)}
|
|
54
|
+
</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 L))continue;S(n).map(s=>s.subject).some(s=>s.publisher===e.publisher&&s.package_===e.package_&&s.name===e.name)&&t.push(n)}return t}renderBreadcrumb(e,t){let r=(e.namespace||"").split("/");if(r.length<2)return"";let a=r[0],s=r[1]??"",o=s.split("@")[0]??"",i=s.split("@")[1]??"";if(!a||!o)return"";let c=g(e,_)??e.name,l=o,p=b(this.catalog,{publisher:a,package_:o,name:o}),k=!!p;if(p){let y=g(p,_);y&&(l=y)}let E=e.name===o,h=[];return h.push(`<li><a href="/">${f(a)}</a></li>`),h.push(k?`<li><a href="/${f(o)}/${f(o)}">${f(l)}</a></li>`:`<li>${f(l)}</li>`),i&&(E?h.push(`<li aria-current="page">${f(i)}</li>`):h.push(k?`<li><a href="/${f(o)}/${f(i)}/${f(o)}">${f(i)}</a></li>`:`<li>${f(i)}</li>`)),E||h.push(`<li aria-current="page">${f(c)}</li>`),`<nav class="kan-breadcrumb"><ol>
|
|
55
|
+
${h.join(`
|
|
56
|
+
`)}
|
|
57
|
+
</ol></nav>`}renderNavGroup(e,t){let n=this.findNavGroupForPublisher(t);if(!n)return"";let r=O(n,W);if(!(r instanceof j))return"";let a=r.object??[];if(a.length===0)return"";let s=[];for(let o of a){if(!(o instanceof d))continue;let i=b(this.catalog,{publisher:o.subject.publisher,package_:o.subject.package_,name:o.subject.name}),{href:c,label:l}=this.resolveNavEntry(o,i,t),p=`/${e.namespace?.split("/")[1]?.split("@")[0]}/${(e.namespace||"").split("@")[1]}/${e.name}`,k=c===p?' aria-current="page"':"";s.push(`<li><a class="kan-nav-link" href="${f(c)}"${k}>${f(l)}</a></li>`)}return`<nav class="kan-site-nav"><ul>
|
|
58
|
+
${s.join(`
|
|
59
|
+
`)}
|
|
60
|
+
</ul></nav>`}resolveNavEntry(e,t,n){if(t&&S(t).map(i=>i.subject).some(i=>i.publisher===M.publisher&&i.package_===M.package_&&i.name===M.name)){let i=g(t,_),c=O(t,oe);if(c instanceof m&&c.object instanceof d){let l=c.object,p=this.readLabelForUri({publisher:l.subject.publisher,package_:l.subject.package_,name:l.subject.name});return{href:this.urlForReference(l,oe,n),label:i??p??l.subject.name}}}let r=N.formatResourceUrl({publisher:e.subject.publisher,package_:e.subject.package_,...e.subject.version?{version:e.subject.version}:{},name:e.subject.name},"*",{contextPublisher:n}),a=t?g(t,_)??e.subject.name:e.subject.name;return{href:r,label:a}}findNavGroupForPublisher(e){for(let t of this.catalog){if(!(t instanceof L)||!(t.namespace||"").startsWith(`${e}/`))continue;if(S(t).map(s=>s.subject).some(s=>s.publisher===V.publisher&&s.package_===V.package_&&s.name===V.name))return t}}renderMarkdown(e,t){let n=R(e,I);if(!n)return"<!-- LookRenderer.Markdown: no look.source -->";let r=this.readPropertyValueText(t,n);return r?`<section class="kan-markdown">
|
|
61
|
+
${ee(r)}
|
|
62
|
+
</section>`:""}renderRawMarkdown(e){let t=this.findCascadedLook(e);if(!t)return;let n=ie(t.declaration),r=[];for(let a of n){let s=ce(a);if(!s||!v(s,se))continue;let o=R(a,I);if(!o)continue;let i=this.readPropertyValueText(e,o);i&&r.push(i)}return r.length>0?r.join(`
|
|
63
|
+
|
|
64
|
+
`):void 0}renderHero(e,t,n){let r=['<header class="kan-hero">'],a=R(e,Ue);if(a){let l=this.readPropertyValueText(t,a);l&&r.push(`<span class="kan-hero-eyebrow">${f(l)}</span>`)}let s=R(e,Le),o="";s&&(o=this.readPropertyValueText(t,s)??""),o||(o=t.name),r.push(`<h1 class="kan-hero-title">${f(o)}</h1>`);let i=R(e,Ie);if(i){let l=this.readPropertyValueText(t,i);l&&r.push(`<p class="kan-hero-subtitle">${f(l)}</p>`)}let c=R(e,ae);if(c){let l=this.readPropertyValueReferences(t,c);if(l.length>0){let p=l.map(k=>this.renderBadge(k,ae,n)).join("");r.push(`<div class="kan-hero-badges">${p}</div>`)}}return r.push("</header>"),r.join(`
|
|
65
|
+
`)}renderPropertyList(e,t,n){let r=R(e,I);if(!r)return"<!-- LookRenderer: PropertyList missing look.source -->";let a=this.readLabelForUri(r)??r.name,s=O(t,r),o=this.gatherValueItems(s),i=o.length>0?o.map(c=>`<li>${this.renderInlineValue(c,I,n)}</li>`).join(""):'<li class="kan-empty">(no values)</li>';return['<section class="kan-property-list">',`<h3 class="kan-property-list-title">${f(a)}</h3>`,`<ul class="kan-property-list-items">${i}</ul>`,"</section>"].join(`
|
|
66
|
+
`)}renderBadgeRow(e,t,n){let r=R(e,I);if(!r)return"<!-- LookRenderer: BadgeRow missing look.source -->";let a=this.readPropertyValueReferences(t,r);return a.length===0?"":`<div class="kan-badge-row">${a.map(o=>this.renderBadge(o,I,n)).join("")}</div>`}renderChipRow(e,t,n){let r=ue(e,Oe);if(r.length===0)return"<!-- LookRenderer: ChipRow has no look.chips -->";let a=[];for(let s of r){let o=O(t,s);if(!o)continue;let i=this.readLabelForUri(s)??s.name,c=this.renderStatementInlineValue(o,s,n);c&&a.push(`<span class="kan-chip"><span class="kan-chip-key">${f(i)}</span> <span class="kan-chip-val">${c}</span></span>`)}return a.length===0?"":`<div class="kan-chip-row">${a.join("")}</div>`}renderReferenceList(e,t,n){let r=ue(e,W);if(r.length===0)return"<!-- LookRenderer: ReferenceList has no look.entries -->";let a=[];for(let s of r){let o=this.readPropertyValueReferences(t,s);if(o.length===0)continue;let i=this.readLabelForUri(s)??s.name,c=o.map(l=>this.renderReferenceLink(l,W,n)).join(", ");a.push(`<dt>${f(i)}</dt><dd>${c}</dd>`)}return a.length===0?"":`<dl class="kan-reference-list">${a.join("")}</dl>`}readPropertyValueText(e,t){let n=O(e,t);if(n){if(n instanceof K)return n.object;if(n instanceof m){let r=n.object;return this.readLabelForUri({publisher:r.subject.publisher,package_:r.subject.package_,name:r.subject.name})??r.subject.name}if(n instanceof j)return(n.object??[]).map(a=>a instanceof d?this.readLabelForUri({publisher:a.subject.publisher,package_:a.subject.package_,name:a.subject.name})??a.subject.name:a instanceof P?a.name??"":String(a)).filter(a=>a).join(", ")}}readPropertyValueReferences(e,t){let n=O(e,t);if(!n)return[];if(n instanceof m)return[n.object];if(n instanceof j){let r=[];for(let a of n.object??[])a instanceof d&&r.push(a);return r}return[]}gatherValueItems(e){return e?e instanceof j?e.object??[]:e instanceof m?[e.object]:e instanceof C?[e.object]:e instanceof K?[e.object]:[]:[]}renderInlineValue(e,t,n){return e instanceof d?this.renderReferenceLink(e,t,n):e instanceof P?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 m?this.renderReferenceLink(e.object,t,n):e instanceof j?(e.object??[]).map(a=>this.renderInlineValue(a,t,n)).filter(a=>a).join(", "):""}renderReferenceLink(e,t,n){let r=this.readLabelForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name})??e.subject.name,a=this.urlForReference(e,t,n);return`<a class="kan-link" href="${f(a)}">${f(r)}</a>`}renderBadge(e,t,n){let r=this.readLabelForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name})??e.subject.name,a=this.readCommentForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name}),s=this.urlForReference(e,t,n),o=a?` title="${f(a)}"`:"";return`<a class="kan-badge" href="${f(s)}"${o}>${f(r)}</a>`}urlForReference(e,t,n){let r=t?this.getUrlFormForProperty(t):"=";return N.formatResourceUrl({publisher:e.subject.publisher,package_:e.subject.package_,...e.subject.version?{version:e.subject.version}:{},name:e.subject.name},r,{contextPublisher:n})}getUrlFormForProperty(e){let t=b(this.catalog,e);if(!t)return"=";let n=g(t,we);return n==="*"||n==="^"||n==="~"||n==="="?n:"="}readLabelForUri(e){let t=b(this.catalog,e);if(t)return g(t,_)}readCommentForUri(e){let t=b(this.catalog,e);if(t)return g(t,re)}};function q(u){let e=new Map;for(let t of u.statement){if(!(t instanceof C)||!$(t,H.publisher,H.package_,H.name))continue;let n=t.object;for(let r of n.statement){if(!(r instanceof K))continue;let a=r.predicate?.subject?.name;if(!a)continue;let s=r.object;e.has(a)||e.set(a,s)}}return e}function Y(u){for(let e of u.statement)if(e instanceof C&&$(e,G.publisher,G.package_,G.name))return e.object}function ie(u){for(let e of u.statement){if(!(e instanceof j)||!$(e,D.publisher,D.package_,D.name))continue;let t=[];for(let n of e.object??[])n instanceof P&&t.push(n);return t}return[]}function ce(u){for(let e of u.statement)if(e instanceof m&&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 R(u,e){for(let t of u.statement)if(t instanceof m&&$(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 j)||!$(t,e.publisher,e.package_,e.name))continue;let n=[];for(let r of t.object??[])r instanceof d&&n.push({publisher:r.subject.publisher,package_:r.subject.package_,name:r.subject.name});return n}return[]}function O(u,e){for(let t of u.statement)if($(t,e.publisher,e.package_,e.name))return t}function g(u,e){for(let t of u.statement)if(t instanceof K&&$(t,e.publisher,e.package_,e.name))return t.object}function S(u){let e=[];for(let t of u.statement)if(t instanceof m){if(t.predicate?.subject?.name!=="type")continue;t.object instanceof d&&e.push(t.object)}else if(t instanceof j){if(t.predicate?.subject?.name!=="type")continue;for(let n of t.object??[])n instanceof d&&e.push(n)}return e}function x(u){let e=[];for(let t of u.statement)if(t instanceof m){if(t.predicate?.subject?.name!=="subClassOf")continue;t.object instanceof d&&e.push(t.object)}else if(t instanceof j){if(t.predicate?.subject?.name!=="subClassOf")continue;for(let n of t.object??[])n instanceof d&&e.push(n)}return e}function B(u,e){let t=[];for(let n of u){if(!(n instanceof L)||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 r of u)if(r instanceof L&&r.name===e.name&&r.namespace===n)return r}for(let n of u){if(!(n instanceof L)||n.name!==e.name)continue;if((n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`))return n}}function $(u,e,t,n){let r=u.predicate?.subject;return r?r.publisher===e&&r.package_===t&&r.name===n:!1}function v(u,e){return u.publisher===e.publisher&&u.package_===e.package_&&u.name===e.name}function w(u){return`${u.publisher}/${u.package_}/${u.name}`}function F(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};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d as V}from"./chunk-
|
|
1
|
+
import{d as V}from"./chunk-4YHWMYAZ.js";import{a as E}from"./chunk-7CUTGGH3.js";var L=class{propertyUri;propertyType;range;rangeUri;isImported;definedInNamespace};import{parseDocument as O,LineCounter as R,isMap as h,isPair as f,isScalar as g,isSeq as I}from"yaml";var K=class i{entities=new Map;entityBlocks=new Map;properties=new Map;propertyValues=new Map;valueListItems=new Map;importPackages=new Map;nestedKeys=new Map;nestedValues=new Map;static fromContent(e){let t=new i,n=new R,r=O(e,{lineCounter:n});if(r.errors.length>0||!h(r.contents))return t;N(r.contents,[],n,t);for(let o of r.contents.items){if(!f(o)||!g(o.key))continue;let a=String(o.key.value),u=o.key.range;if(!u)continue;t.entities.set(a,d(u,n));let s=o.value,c=s&&typeof s=="object"&&"range"in s?s.range:void 0;if(c?t.entityBlocks.set(a,d([u[0],u[1],c[2]],n)):t.entityBlocks.set(a,d(u,n)),h(o.value)){let k=new Map,m=new Map,l=new Map;for(let P of o.value.items){if(!f(P)||!g(P.key))continue;let b=String(P.key.value),p=P.key.range;p&&k.set(b,d(p,n));let S=P.value;if(S&&typeof S=="object"&&"range"in S&&Array.isArray(S.range)){let v=S.range;m.set(b,d(v,n))}if(I(S)){let v=[];for(let M of S.items)M&&typeof M=="object"&&"range"in M&&Array.isArray(M.range)&&v.push(d(M.range,n));v.length>0&&l.set(b,v)}}k.size>0&&t.properties.set(a,k),m.size>0&&t.propertyValues.set(a,m),l.size>0&&t.valueListItems.set(a,l);let y=j(o.value,n);y.length>0&&t.importPackages.set(a,y)}}return t}getEntityPosition(e){return this.entities.get(e)}getEntityBlockPosition(e){return this.entityBlocks.get(e)}findEntityAtPosition(e,t){for(let[n,r]of this.entityBlocks)if(w(r,e,t))return n}findPropertyAtPosition(e,t){let n=this.findEntityAtPosition(e,t);if(!n)return;let r=this.properties.get(n),o=this.propertyValues.get(n);if(!r&&!o)return{entityName:n};let a,u;if(o)for(let[s,c]of o)w(c,e,t)&&(!u||C(c,u))&&(a=s,u=c);if(r)for(let[s,c]of r)w(c,e,t)&&(!u||C(c,u))&&(a=s,u=c);return a?{entityName:n,propertyName:a}:{entityName:n}}getPropertyPosition(e,t){return this.properties.get(e)?.get(t)}getPropertyValuePosition(e,t){return this.propertyValues.get(e)?.get(t)}getImportPackages(e){return this.importPackages.get(e)??[]}getAllImportPackages(){let e=[];for(let[t,n]of this.importPackages)for(let r of n)e.push({entityName:t,entry:r});return e}findPropertySourceName(e,t){let n=this.properties.get(e);if(n){if(n.has(t))return t;for(let r of n.keys()){let o=r.lastIndexOf(".");if((o===-1?r:r.substring(o+1))===t)return r}}}getListItemPosition(e,t,n){let r=this.valueListItems.get(e)?.get(t);if(!(!r||n<0||n>=r.length))return r[n]}getNodeKeyPosition(e){return this.nestedKeys.get(JSON.stringify(e))}getNodeValuePosition(e){return this.nestedValues.get(JSON.stringify(e))}setNestedKeyPosition(e,t){this.nestedKeys.set(e,t)}setNestedValuePosition(e,t){this.nestedValues.set(e,t)}getMostSpecificPosition(e,t,n){if(e){if(t!==void 0){if(n!==void 0){let a=this.getListItemPosition(e,t,n);if(a)return a}let r=this.getPropertyValuePosition(e,t);if(r)return r;let o=this.getPropertyPosition(e,t);if(o)return o}return this.getEntityPosition(e)}}};function j(i,e){let t=[];if(!h(i))return t;let n=i.items.find(r=>f(r)&&g(r.key)&&String(r.key.value)==="imports");if(!n||!f(n)||!I(n.value))return t;for(let r of n.value.items){if(!h(r))continue;let o=r.items.find(s=>f(s)&&g(s.key)&&String(s.key.value)==="publisher");if(!o||!f(o)||!g(o.value))continue;let a=String(o.value.value),u=r.items.find(s=>f(s)&&g(s.key)&&String(s.key.value)==="packages");if(!(!u||!f(u)||!I(u.value)))for(let s of u.value.items){if(!h(s))continue;let c=s.items.find(p=>f(p)&&g(p.key)&&String(p.key.value)==="package");if(!c||!f(c)||!g(c.value)||!c.value.range)continue;let k=String(c.value.value),m=s.items.find(p=>f(p)&&g(p.key)&&String(p.key.value)==="version"),l=m&&f(m)&&g(m.value)?String(m.value.value):"",y=s.items.find(p=>f(p)&&g(p.key)&&String(p.key.value)==="alias"),P=y&&f(y)&&g(y.value)?String(y.value.value):void 0,b=P!==void 0?{publisher:a,package_:k,version:l,alias:P,position:d(c.value.range,e)}:{publisher:a,package_:k,version:l,position:d(c.value.range,e)};t.push(b)}}return t}function w(i,e,t){return!(e<i.line||e>i.endLine||e===i.line&&t<i.column||e===i.endLine&&t>i.endColumn)}function C(i,e){let t=i.endLine-i.line,n=e.endLine-e.line;if(t!==n)return t<n;let r=i.endLine===i.line?i.endColumn-i.column:Number.MAX_SAFE_INTEGER,o=e.endLine===e.line?e.endColumn-e.column:Number.MAX_SAFE_INTEGER;return r<o}function N(i,e,t,n){if(h(i)){for(let r of i.items){if(!f(r)||!g(r.key))continue;let o=String(r.key.value),a=[...e,o],u=JSON.stringify(a);r.key.range&&n.setNestedKeyPosition(u,d(r.key.range,t));let s=r.value,c=D(s);c&&n.setNestedValuePosition(u,d(c,t)),N(s,a,t,n)}return}if(I(i)){for(let r=0;r<i.items.length;r++){let o=i.items[r],a=[...e,r],u=JSON.stringify(a),s=D(o);s&&n.setNestedValuePosition(u,d(s,t)),N(o,a,t,n)}return}}function D(i){if(!i||typeof i!="object"||!("range"in i))return;let e=i.range;return Array.isArray(e)&&e.length>=3?e:void 0}function d(i,e){let t=e.linePos(i[0]),n=e.linePos(i[2]);return{line:t.line-1,column:t.col-1,endLine:n.line-1,endColumn:n.col-1}}function x(i,e){let n=(e??new E).parse(i),r=K.fromContent(i);return{document:n,positions:r}}function W(i,e,t,n,r){if(e<n.line||e>n.endLine||e===n.line&&t<n.column||e===n.endLine&&t>=n.endColumn)return;let o=A(r,n.line,n.column),a=A(r,n.endLine,n.endColumn);if(o<0||a<0)return;let u=r.substring(o,a),s=V(u);if(s.length!==i.links.length)return;let c=e-n.line,k=e===n.line?t-n.column:t,m=A(u,c,k);if(!(m<0))for(let l=0;l<s.length;l++){let y=s[l];if(m>=y.startOffset&&m<y.endOffset)return i.links[l]}}function A(i,e,t){let n=0,r=0;for(let o=0;o<i.length;o++){if(n===e)return Math.min(r+t,i.length);i[o]===`
|
|
2
2
|
`&&(n++,r=o+1)}return n===e?Math.min(r+t,i.length):-1}export{L as a,K as b,x as c,W as d};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as h}from"./chunk-4TJZIM7A.js";import{c as S,e as R}from"./chunk-
|
|
1
|
+
import{a as h}from"./chunk-4TJZIM7A.js";import{c as S,e as R}from"./chunk-4YHWMYAZ.js";var E=(t=>(t.Class="Class",t.DatatypeProperty="DatatypeProperty",t.ObjectProperty="ObjectProperty",t.AnnotationProperty="AnnotationProperty",t.Instance="Instance",t.Datatype="Datatype",t.Unknown="Unknown",t))(E||{}),A=(o=>(o.InstanceOf="instanceOf",o.SubClassOf="subClassOf",o.Domain="domain",o.Range="range",o.ObjectRelationship="objectRelationship",o.SubPropertyOf="subPropertyOf",o.PropertyValue="propertyValue",o.EmbeddedLink="embeddedLink",o))(A||{}),$=class{static async buildFromRepository(n){let l=await new R().parseKanonaks(n),p=await n.getAllDocumentsAsync(),a=[],s=[],t=new Set,o=new Set,d=new Map;for(let y of l){let c=y;c.name&&(h.isClassType(c)&&t.add(c.name),(h.isObjectPropertyType(c)||h.isGenericPropertyType(c))&&o.add(c.name))}for(let y of p)for(let[c,g]of Object.entries(y.body))o.has(c)&&g?.range&&typeof g.range=="string"&&d.set(c,g.range);let u=new Map;for(let y of l){let c=y;c.name&&u.set(c.name,c)}for(let y of p){let c=y.metadata.namespace_,g=c?`${c.publisher}/${c.package_}`:"",i=c?.version?`${c.version.major}.${c.version.minor}.${c.version.patch}`:"",f=x(y);for(let[m,b]of Object.entries(y.body)){if(!b||typeof b!="object")continue;let P=u.get(m),k="Unknown";if(P){let T=P;h.isClassType(T)?k="Class":h.isObjectPropertyType(T)?k="ObjectProperty":h.isDatatypePropertyType(T)?k="DatatypeProperty":h.isAnnotationPropertyType(T)?k="AnnotationProperty":h.isDatatypeType(T)?k="Datatype":h.isGenericPropertyType(T)?k="ObjectProperty":h.isInstanceOfKnownClass(T,t)&&(k="Instance")}let j=g&&i?`${g}/${m}@${i}`:m,C={};for(let[T,O]of Object.entries(b))T!=="type"&&(typeof O!="object"||O===null)&&(C[T]=O);a.push({id:j,label:b.label??m,type:k,namespace:g,properties:C}),v(j,b,k,t,o,s,g,i,f),N(j,b,o,d,a,s,g,i,f),L(j,P,s)}}return{nodes:a,edges:s}}static buildFromDocument(n){let r=[],l=[],p=n.metadata.namespace_,a=p?.version?`${p.version.major}.${p.version.minor}.${p.version.patch}`:"",s=p?`${p.publisher}/${p.package_}`:"",t=new Set,o=new Set,d=new Map,u=x(n);for(let[g,i]of Object.entries(n.body)){let f=i?.type;f&&(K(f,u)&&t.add(g),M(f,u)&&(o.add(g),i.range&&typeof i.range=="string"&&d.set(g,i.range)))}for(let[g,i]of Object.entries(n.body)){if(!i||typeof i!="object")continue;let f=i.type,m=U(f,g,t,u),b=s&&a?`${s}/${g}@${a}`:g,P={};for(let[k,j]of Object.entries(i))k!=="type"&&(typeof j!="object"||j===null)&&(P[k]=j);r.push({id:b,label:i.label??g,type:m,namespace:s,properties:P}),v(b,i,m,t,o,l,s,a,u),N(b,i,o,d,r,l,s,a,u)}let y=new Set(r.map(g=>g.id)),c=l.filter(g=>y.has(g.source)&&y.has(g.target));return{nodes:r,edges:c}}};function x(e,n){let r=new Map;if(e.metadata?.imports)for(let[l,p]of Object.entries(e.metadata.imports))for(let a of p){let s=a.alias??a.packageName,t=a.version,o=`${t.major}.${t.minor}.${t.patch}`;r.set(s,{publisher:l,package_:a.packageName,version:o})}return r}var _={"kanonak.org/core-rdf/Class":"Class","kanonak.org/core-owl/Class":"Class","kanonak.org/core-rdfs/Class":"Class","kanonak.org/core-owl/ObjectProperty":"ObjectProperty","kanonak.org/core-owl/DatatypeProperty":"DatatypeProperty","kanonak.org/core-owl/AnnotationProperty":"AnnotationProperty","kanonak.org/core-rdf/Property":"ObjectProperty","kanonak.org/core-rdfs/Datatype":"Datatype"},G=new Set(["kanonak.org/core-owl/ObjectProperty","kanonak.org/core-owl/DatatypeProperty","kanonak.org/core-owl/AnnotationProperty","kanonak.org/core-rdf/Property"]);function D(e,n){if(e.includes(".")){let r=e.indexOf("."),l=e.substring(0,r),p=e.substring(r+1),a=n.get(l);if(a)return`${a.publisher}/${a.package_}/${p}`}return null}function K(e,n){let r=D(e,n);return r?_[r]==="Class":!1}function M(e,n){let r=D(e,n);return r?G.has(r):!1}function U(e,n,r,l){if(!e||e==="Package")return"Unknown";let p=D(e,l);if(p){let s=_[p];if(s)return s;let t=p.split("/").pop()?.split("@")[0]??"";return r.has(t)?"Instance":"Unknown"}let a=e.split(".").pop()??e;return r.has(a)?"Instance":"Unknown"}var I=new Set(["type","label","comment","version","publisher","imports","license","match","alias","package"]);function v(e,n,r,l,p,a,s,t,o){let d=n.type,u=n.subClassOf;if(u){let i=Array.isArray(u)?u:[u];for(let f of i)typeof f=="string"&&a.push({source:e,target:w(f,s,t,o),type:"subClassOf",label:"subClassOf"})}let y=n.subPropertyOf;if(y){let i=Array.isArray(y)?y:[y];for(let f of i)typeof f=="string"&&a.push({source:e,target:w(f,s,t,o),type:"subPropertyOf",label:"subPropertyOf"})}if(r==="Instance"&&d){let i=d.split(".").pop()??d;a.push({source:e,target:w(i,s,t,o),type:"instanceOf",label:"type"})}if(r==="Instance")for(let[i,f]of Object.entries(n)){if(I.has(i)||!p.has(i))continue;let m=Array.isArray(f)?f:[f];for(let b of m)typeof b=="string"&&V(b)&&a.push({source:e,target:w(b,s,t,o),type:"propertyValue",label:i,propertyId:w(i,s,t,o)})}let c=r==="ObjectProperty"||r==="DatatypeProperty",g=n.domain&&n.range;if((c||g)&&n.domain&&n.range){let i=typeof n.domain=="string"?n.domain:null,f=typeof n.range=="string"?n.range:null;i&&f&&a.push({source:w(i,s,t,o),target:w(f,s,t,o),type:"objectRelationship",label:n.label??e.split("/").pop()??"",propertyId:e})}}function N(e,n,r,l,p,a,s,t,o){for(let[d,u]of Object.entries(n)){if(I.has(d)||typeof u!="object"||u===null||Array.isArray(u))continue;let y=u,c=`${e}/${d}`,g=l.get(d),i=g?g.split(".").pop()??g:"Unknown",f={};for(let[b,P]of Object.entries(y))(typeof P!="object"||P===null)&&(f[b]=P);p.push({id:c,label:`${i} (embedded)`,type:"Instance",namespace:s,properties:f});let m=s&&t?`${s}/${d}@${t}`:d;a.push({source:e,target:c,type:"propertyValue",label:d,propertyId:r.has(d)?m:void 0}),g&&a.push({source:c,target:w(i,s,t,o),type:"instanceOf",label:"type (inferred)"}),N(c,y,r,l,p,a,s,t,o)}}function L(e,n,r){let l=n?.statement;if(Array.isArray(l))for(let p of l){if(!(p instanceof S))continue;let a=p.predicate?.subject?.name??"";for(let s of p.links){let t=s.target?.subject;if(!t)continue;let o=t.version,d=o&&typeof o.major=="number"?`@${o.major}.${o.minor}.${o.patch}`:"";r.push({source:e,target:`${t.publisher}/${t.package_}/${t.name}${d}`,type:"embeddedLink",label:a})}}}function V(e){return!(!e||e.includes(" ")||e.includes(`
|
|
2
2
|
`)||e.startsWith("http://")||e.startsWith("https://")||/^\d{4}-\d{2}/.test(e)||/^\d+(\.\d+)?$/.test(e))}function w(e,n,r,l){if(e.includes("@")&&e.includes("/"))return e;if(e.includes(".")){let p=e.indexOf("."),a=e.substring(0,p),s=e.substring(p+1);if(l){let t=l.get(a);if(t)return`${t.publisher}/${t.package_}/${s}@${t.version}`}return n&&r?`${n}/${s}@${r}`:s}return n&&r?`${n}/${e}@${r}`:e}function Y(e){if(!e.expiresAt)return!1;let n=new Date(e.expiresAt),r=300*1e3;return n.getTime()<=Date.now()+r}function Q(e){return!!e.accessToken&&!Y(e)}function X(e){let n=e.replace(/^https?:\/\//,"").replace(/^git:\/\//,"").replace(/\/+$/,"").trim();if(!n)throw new Error("Publisher host cannot be empty");return n}export{E as a,A as b,$ as c,Y as d,Q as e,X as f};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as v}from"./chunk-
|
|
1
|
+
import{a as v}from"./chunk-7CUTGGH3.js";import{a as h,b as d,f as y,g as k}from"./chunk-FQHALFRR.js";var P=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 s=[];for(let n of this.documents.values())n.metadata?.namespace_?.publisher===t&&n.metadata?.namespace_?.package_===e&&s.push(n);return s}async getHighestCompatibleVersionAsync(t,e){let s=[];for(let r of this.documents.values())r.metadata?.namespace_?.publisher===t&&r.metadata?.namespace_?.package_===e.packageName&&r.metadata?.namespace_?.version!==void 0&&s.push(r);if(s.length===0)return null;let n=s.filter(r=>{let a=r.metadata.namespace_.version;if(!a)return!1;switch(e.versionOperator){case 0:return d(a,e.version);case 1:return y(a,e.version);case 2:return k(a,e.version);case 3:return h(a,e.minVersion)>=0;default:return!1}});return n.length===0?null:(n.sort((r,a)=>{let o=r.metadata.namespace_.version,i=a.metadata.namespace_.version;return!o&&!i?0:o?i?h(i,o):-1:1}),n[0])}async saveDocumentAsync(t,e){this.documents.set(e,t);let s=this.parser.save(t);this.documentContents.set(e,s)}async deleteDocumentAsync(t){this.documents.delete(t),this.documentContents.delete(t)}async clearNamespaceAsync(t,e){let s=[];for(let[n,r]of this.documents.entries())r.metadata?.namespace_?.publisher===t&&r.metadata?.namespace_?.package_===e&&s.push(n);for(let n of s)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 s=this.documents.get(t);return s!==void 0?this.parser.save(s):null}async getDocumentUriAsync(t){let e=this.documents.get(t);return e?e.metadata?.namespace_?`kanonak://${e.metadata.namespace_}`:`kanonak://${t}`:null}};var x="https://{publisher}/index.txt",F="https://{publisher}/{package}/{version}.kan.yml",C={version:1},m=class{cache=new Map;async getConfig(t){let e=this.cache.get(t);if(e)return e;let s=await this.fetchConfig(t);return this.cache.set(t,s),s}async fetchConfig(t){let e=`https://${t}/.well-known/kanonak.json`,s;try{s=await fetch(e)}catch{return C}if(s.status===404)return C;if(!s.ok)throw new Error(`Failed to fetch publisher config: ${e} (${s.status} ${s.statusText})`);let n=await s.json();if(typeof n.version!="number")throw new Error(`Invalid publisher config at ${e}: missing or invalid "version" field`);let r={version:n.version};return typeof n.index=="string"&&(r.index=n.index),typeof n.package=="string"&&(r.package=n.package),(n.auth==="none"||n.auth==="oauth"||n.auth==="bearer")&&(r.auth=n.auth),r}resolveIndexUrl(t,e){let s=e.index??x;return w(s,{publisher:t})}resolvePackageUrl(t,e,s,n){let r=n.package??F;return w(r,{publisher:t,package:e,version:s})}};function w(c,t){let e=c;for(let[n,r]of Object.entries(t))e=e.replaceAll(`{${n}}`,r);let s=e.match(/\{[a-z]+\}/);if(s)throw new Error(`Unresolved variable ${s[0]} in URL template: ${c}`);return e}import{VersionOperator as g}from"@kanonak-protocol/types/document/models/enums";var u=class c{indexCache=new Map;configResolver;fetchFn;constructor(t){this.configResolver=t?.configResolver??new m,this.fetchFn=t?.fetchFn}async resolveVersion(t,e){let s=await this.getPackageVersions(t,e.packageName);if(s.length===0)return null;let n=s.filter(r=>this.isVersionCompatible(r,e.version,e.versionOperator));return n.length===0?null:(n.sort((r,a)=>this.compareVersionStrings(a,r)),n[0])}async getHighestVersion(t,e){let s=await this.getPackageVersions(t,e);return s.length===0?null:[...s].sort((r,a)=>this.compareVersionStrings(a,r))[0]}async listLatestPackages(t){let e=this.indexCache.get(t);e||(e=await this.fetchIndex(t),this.indexCache.set(t,e));let s=[];for(let[n,r]of e){if(r.length===0)continue;let a=[...r].sort((o,i)=>this.compareVersionStrings(i,o));s.push({packageName:n,version:a[0]})}return s.sort((n,r)=>n.packageName.localeCompare(r.packageName)),s}async getPackageUrl(t,e,s){let n=await this.configResolver.getConfig(t);return this.configResolver.resolvePackageUrl(t,e,s,n)}async getPackageVersions(t,e){let s=this.indexCache.get(t);return s||(s=await this.fetchIndex(t),this.indexCache.set(t,s)),s.get(e)??[]}async fetchIndex(t){let e=await this.configResolver.getConfig(t),s=this.configResolver.resolveIndexUrl(t,e),n=this.fetchFn?await this.fetchFn(s,t):await fetch(s);if(!n.ok)throw new Error(`Failed to fetch publisher index: ${s} (${n.status} ${n.statusText})`);let r=await n.text();return c.parseIndex(r)}static parseIndex(t){let e=new Map;for(let s of t.split(`
|
|
2
2
|
`)){let n=s.trim();if(!n||n.startsWith("#"))continue;let r=n.indexOf("/");if(r===-1)continue;let a=n.substring(0,r),o=n.substring(r+1);if(!a||!o)continue;let i=e.get(a);i?i.push(o):e.set(a,[o])}return e}isVersionCompatible(t,e,s){let n=c.parseVersion(t);if(!n)return!1;switch(s){case g.Any:return!0;case g.Exact:return n.major===e.major&&n.minor===e.minor&&n.patch===e.patch;case g.Compatible:return n.major===e.major&&n.minor===e.minor&&n.patch>=e.patch;case g.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 s=parseInt(e[0],10),n=parseInt(e[1],10),r=e.length>=3?parseInt(e[2],10):0;return isNaN(s)||isNaN(n)||isNaN(r)?null:{major:s,minor:n,patch:r}}compareVersionStrings(t,e){let s=c.parseVersion(t),n=c.parseVersion(e);return!s&&!n?0:s?n?s.major!==n.major?s.major-n.major:s.minor!==n.minor?s.minor-n.minor:s.patch-n.patch:1:-1}};var D=class{parser=new v;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 u({fetchFn:t.fetchFn}):new u}async getHighestCompatibleVersionAsync(t,e){let s=await this.publisherIndex.resolveVersion(t,e);if(!s)return null;let n=`${t}/${e.packageName}@${s}`,r=this.documents.get(n);if(r)return r;if(this.getFromCache){let l=this.getFromCache(t,e.packageName,s);if(l){let f=this.parser.parse(l);return this.documents.set(n,f),this.contentCache.set(n,l),f}}let a=await this.publisherIndex.getPackageUrl(t,e.packageName,s),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 i=await o.text();this.onFetch&&this.onFetch(t,e.packageName,s,i);let p=this.parser.parse(i);return this.documents.set(n,p),this.contentCache.set(n,i),p}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(s=>{let n=s.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[,s,n,r]=e;return this.publisherIndex.getPackageUrl(s,n,r)}};export{P as a,m as b,u as c,D as d};
|
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-
|
|
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-2BQ6SOU6.js";import{b as Yt}from"./chunk-BNSBR6LR.js";import{a as qe,b as Ye,c as Xe,d as b,e as S,f as i}from"./chunk-REH5YNFQ.js";import{a as qt}from"./chunk-2VCFHCFN.js";import{a as Te,b as je,c as Le,d as Fe,e as Ne}from"./chunk-5AH6GIPO.js";import{a as Be,b as De,c as Oe,d as Ae}from"./chunk-VQFL5C7Q.js";import{a as lt,b as dt,c as ut,d as pt}from"./chunk-IIP6J4EP.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-A2JTW3ON.js";import"./chunk-FJ35VIV6.js";import{a as F,b as D,c as Me,e as We}from"./chunk-4YHWMYAZ.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-7CUTGGH3.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)}
|
package/dist/parsing/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as c,b as d,c as e,d as f}from"../chunk-
|
|
1
|
+
import{a as c,b as d,c as e,d as f}from"../chunk-IIP6J4EP.js";import{e as b}from"../chunk-4YHWMYAZ.js";import"../chunk-W6T7MOKY.js";import{a}from"../chunk-7CUTGGH3.js";import"../chunk-5ILSX24H.js";import"../chunk-FUUTGGJS.js";export{d as KanonakDocumentPositions,b as KanonakObjectParser,a as KanonakParser,c as PropertyMetadata,f as findMarkdownLinkAt,e as parseWithPositions};
|
package/dist/reasoning/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j}from"../chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j}from"../chunk-2BQ6SOU6.js";import"../chunk-4YHWMYAZ.js";import"../chunk-W6T7MOKY.js";import"../chunk-7CUTGGH3.js";import"../chunk-5ILSX24H.js";import"../chunk-FUUTGGJS.js";export{f as KanonakVocabulary,h as OWL_RL_CLASSIFICATION_RULES,g as RDFS_RULES,j as Reasoner,i as ReasoningResult,e as TripleStore,b as makeUriKey,c as tripleKey,a as uriKey,d as uriTriple};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o,b as e,c as r,d as n}from"../chunk-
|
|
1
|
+
import{a as o,b as e,c as r,d as n}from"../chunk-VQFL5C7Q.js";import"../chunk-7CUTGGH3.js";import"../chunk-FQHALFRR.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}from"../chunk-
|
|
1
|
+
import{a as b,b as c,c as d,d as e,e as f}from"../chunk-5AH6GIPO.js";import{a,b as g,c as h,d as i}from"../chunk-VQFL5C7Q.js";import"../chunk-7CUTGGH3.js";import"../chunk-FQHALFRR.js";export{d as CompositeKanonakDocumentRepository,c as DocumentLocation,b as FileSystemKanonakDocumentRepository,i as HttpKanonakDocumentRepository,a as InMemoryKanonakDocumentRepository,g as PublisherConfigResolver,h as PublisherIndex,f as RepositoryFactory,e as getGlobalCachePath};
|
|
@@ -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-BNSBR6LR.js";import{a as Oe}from"../chunk-2VCFHCFN.js";import"../chunk-IIP6J4EP.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-4YHWMYAZ.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-7CUTGGH3.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/dist/validation/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A,B,C,D,E,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../chunk-
|
|
1
|
+
import{A,B,C,D,E,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../chunk-A2JTW3ON.js";import"../chunk-FJ35VIV6.js";import"../chunk-4YHWMYAZ.js";import"../chunk-W6T7MOKY.js";import"../chunk-7CUTGGH3.js";import"../chunk-FQHALFRR.js";import"../chunk-5ILSX24H.js";import"../chunk-FUUTGGJS.js";export{w as AmbiguousReferenceRule,C as ClassDefinitionRule,n as ClassHierarchyCycleRule,u as DefinitionPropertyReferenceRule,j as EmbeddedKanonakTypeRule,k as ImportExistenceRule,t as InstancePropertyReferenceRule,E as KanonakObjectValidator,D as MarkdownLinkRule,s as NamespaceImportCycleRule,f as NamespacePrefixRule,y as ObjectPropertyImportRule,z as ObjectPropertyValueValidationRule,c as OntologyValidationError,a as OntologyValidationResult,A as PropertyDomainRule,o as PropertyHierarchyCycleRule,x as PropertyRangeReferenceRule,p as PropertyRangeRequiredRule,h as PropertyTypeSpecificityRule,B as PropertyValueTypeRule,g as ResourceNamingRule,q as SubClassOfReferenceRule,r as SubPropertyOfReferenceRule,i as SubjectKanonakTypeRequiredRule,m as TypeAmbiguityRule,l as UnresolvedReferenceRule,e as ValidationCache,d as ValidationContext,b as ValidationSeverity,v as XsdImportRule};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanonak-protocol/sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.29.1",
|
|
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.
|
|
116
|
+
"@kanonak-protocol/types": "^3.29.1",
|
|
117
117
|
"ignore": "^7.0.5",
|
|
118
118
|
"js-yaml": "^4.1.0",
|
|
119
119
|
"yaml": "^2.7.0"
|
package/dist/chunk-ITS5BOWM.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import{a as N}from"./chunk-NIGFQYVA.js";import{a as P}from"./chunk-QIIQ4G2Q.js";import{c as L,d,g as $,h as Q,i as X,j as h,k as E,l as j}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 r=e[n];if(r.trim()===""){n++;continue}let o=/^(\s*)```(\S*)\s*$/.exec(r);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 s=/^(#{1,6})\s+(.*)$/.exec(r);if(s){let c=s[1].length,i=C(s[2].trim());t.push(`<h${c}>${i}</h${c}>`),n++;continue}if(r.includes("|")&&n+1<e.length&&Z(e[n+1])){let c=B(r),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(r)){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>${C(i.join(" ").trim())}</li>`)}t.push(`<ul>
|
|
5
|
-
${c.join(`
|
|
6
|
-
`)}
|
|
7
|
-
</ul>`);continue}if(/^\s*\d+\.\s+/.test(r)){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>${C(i.join(" ").trim())}</li>`)}t.push(`<ol>
|
|
8
|
-
${c.join(`
|
|
9
|
-
`)}
|
|
10
|
-
</ol>`);continue}let a=[r];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>${C(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=s=>{let a=e[s];return a?` style="text-align:${a}"`:""},r=u.map((s,a)=>`<th${n(a)}>${C(s)}</th>`).join(""),o=t.map(s=>`<tr>${s.map((c,i)=>`<td${n(i)}>${C(c)}</td>`).join("")}</tr>`).join(`
|
|
12
|
-
`);return`<table>
|
|
13
|
-
<thead><tr>${r}</tr></thead>
|
|
14
|
-
<tbody>
|
|
15
|
-
${o}
|
|
16
|
-
</tbody>
|
|
17
|
-
</table>`}function C(u){let e=ne(u);return e=e.replace(/`([^`\n]+)`/g,(t,n)=>`<code>${n}</code>`),e=e.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(t,n,r)=>`<a href="${te(r)}">${n}</a>`),e=e.replace(/\*\*([^*\n]+)\*\*/g,(t,n)=>`<strong>${n}</strong>`),e=e.replace(/(^|[^*])\*([^*\n]+)\*(?!\*)/g,(t,n,r)=>`${n}<em>${r}</em>`),e=e.replace(/(^|[\s(])_([^_\n]+)_(?=[\s).,;:!?]|$)/g,(t,n,r)=>`${n}<em>${r}</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"},H={publisher:"kanonak.org",package_:"derivation",name:"tokens"},U={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},_={publisher:"kanonak.org",package_:"core-rdf",name:"label"},re={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"},se={publisher:"kanonak.org",package_:"look",name:"Markdown"},V={publisher:"kanonak.org",package_:"look",name:"NavGroup"},M={publisher:"kanonak.org",package_:"look",name:"NavLink"},oe={publisher:"kanonak.org",package_:"look",name:"target"},Re={publisher:"kanonak.org",package_:"look",name:"ResourceGrid"};var ve={publisher:"kanonak.org",package_:"look",name:"semanticSvg"},Ke={publisher:"kanonak.org",package_:"look",name:"tierChip"},$e={publisher:"kanonak.org",package_:"look",name:"tierIcon"},Se={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"},I={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:F(e),package_:(e.namespace||"").split("/")[1]?.split("@")[0]??"",name:e.name}};let n=new Set,r=S(e);for(;r.length>0;){let o=r.shift(),s=w(o.subject);if(n.has(s))continue;n.add(s);let a=m(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 x(a))r.push(i)}if(!n.has(w(U))){let o=m(this.catalog,U);if(o){let s=Y(o);if(s)return{declaration:s,sourceClass:{...U}}}}}findCascadedTokens(e){let t=new Map;for(let[o,s]of q(e))t.has(o)||t.set(o,s);let n=new Set,r=S(e);for(;r.length>0;){let o=r.shift(),s=w(o.subject);if(n.has(s))continue;n.add(s);let a=A(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 x(c))r.push(i)}}if(!n.has(w(U))){let o=A(this.catalog,U);for(let s of o)for(let[a,c]of q(s))t.has(a)||t.set(a,c)}return t}renderSvg(e){let t=g(e,_)??e.name,n=(t.trim().charAt(0)||"?").toUpperCase(),r=`${e.namespace??""}/${e.name}`,o={label:t,firstLetter:n,uri:r},s=this.collectCascadedSvgTiers(e),a=b=>this.applyPlaceholders(b,e,o),c=a(s.tierChip??""),i=a(s.tierIcon??""),l=a(s.tierCard??""),p=a(s.tierFull??""),T=[...this.findCascadedTokens(e)].map(([b,y])=>`--kan-${b}: ${y};`).join(" ");return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400" width="400" height="400" style="${z(T)}">
|
|
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,(r,o)=>{let s=o.trim();if(n[s]!==void 0)return z(n[s]);let a=this.resolvePath(t,s);return a===void 0?`{{${s}}}`:z(a)})}resolvePath(e,t){let n=t.split("/").map(a=>a.trim()).filter(a=>a.length>0);if(n.length===0)return;let r=e;for(let a=0;a<n.length-1;a++){if(!r)return;let c=le(n[a]),i=fe(r,c);if(!i)return;if(i instanceof h&&i.object instanceof d){let l=m(this.catalog,i.object.subject);if(!l)return;r=l}else if(i instanceof E)r=i.object;else return}if(!r)return;let o=le(n[n.length-1]),s=fe(r,o);if(s){if(s instanceof $||s instanceof Q||s instanceof X)return String(s.object);if(s instanceof h&&s.object instanceof d){let a=s.object,c=m(this.catalog,a.subject);return c?g(c,_)??a.subject.name:a.subject.name}}}collectCascadedSvgTiers(e){let t={},n=s=>{let a=O(s,ve);if(!(a instanceof E))return;let c=a.object,i=g(c,Ke),l=g(c,$e),p=g(c,Se),k=g(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&&k!==void 0&&(t.tierFull=k)};n(e);let r=new Set,o=S(e);for(;o.length>0;){let s=o.shift(),a=w(s.subject);if(r.has(a))continue;r.add(a);let c=A(this.catalog,s.subject);for(let i of c){n(i);for(let l of x(i))o.push(l)}}if(!r.has(w(U)))for(let s of A(this.catalog,U))n(s);return t}renderStylesheet(e){let t=this.findCascadedTokens(e),n=[];for(let[s,a]of t)n.push(` --kan-${s}: ${a};`);let r=n.length>0?`:root {
|
|
30
|
-
${n.join(`
|
|
31
|
-
`)}
|
|
32
|
-
}`:":root { /* no tokens resolved */ }",o=this.findBaseStylesheet(F(e))??"";return`${r}
|
|
33
|
-
${o}`}findBaseStylesheet(e){let t="kanonak.org/site/content",n,r;for(let s of this.catalog){if(!(s instanceof L)||s.name!=="base-stylesheet")continue;let a=s.namespace||"";a.startsWith(`${e}/look-styles@`)?n=s:a.startsWith("kanonak.org/look-styles@")&&(r=s)}let o=n??r;if(o)for(let s of o.statement){let a=s.predicate?.subject;if(!a)continue;if(`${a.publisher}/${a.package_}/${a.name}`===t&&s instanceof $)return s.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 r=F(e),o=[];for(let s of n)o.push(this.renderBand(s,e,r));return o.join(`
|
|
34
|
-
`)}renderDocument(e){let t=this.renderHtml(e),n=this.readPropertyValueText(e,_)??e.name,r=`${e.name}.css`,o=this.hasSvgDerivation(e)?`<figure class="kan-figure"><img src="${f(e.name)}.svg" alt=""></figure>
|
|
35
|
-
`:"",s=F(e),a=this.renderNavGroup(e,s),c=this.renderBreadcrumb(e,s);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(r)}">
|
|
42
|
-
</head>
|
|
43
|
-
<body>
|
|
44
|
-
${a}
|
|
45
|
-
${c}
|
|
46
|
-
<main class="kan-main">
|
|
47
|
-
${o}${t}
|
|
48
|
-
</main>
|
|
49
|
-
</body>
|
|
50
|
-
</html>
|
|
51
|
-
`}hasSvgDerivation(e){let t=new Set,n=S(e);for(;n.length>0;){let r=n.shift(),o=w(r.subject);if(t.has(o))continue;t.add(o);let s=m(this.catalog,r.subject);if(s){for(let a of s.statement)if(a instanceof j&&K(a,"kanonak.org","derivation","derivations")){for(let c of a.object??[])if(c instanceof P)for(let i of c.statement){if(!(i instanceof h)||!K(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 x(s))n.push(a)}}return!1}renderBand(e,t,n){let r=ce(e);return r?v(r,he)?this.renderHero(e,t,n):v(r,me)?this.renderPropertyList(e,t,n):v(r,be)?this.renderBadgeRow(e,t,n):v(r,je)?this.renderChipRow(e,t,n):v(r,_e)?this.renderReferenceList(e,t,n):v(r,se)?this.renderMarkdown(e,t):v(r,V)?this.renderNavGroup(t,n):v(r,Re)?this.renderResourceGrid(e,n,t):`<!-- LookRenderer: unsupported band ${r.publisher}/${r.package_}/${r.name} -->`:"<!-- LookRenderer: band has no rdf:type -->"}renderResourceGrid(e,t,n){let r=R(e,I);if(!r)return"<!-- LookRenderer.ResourceGrid: no look.source -->";let o=m(this.catalog,r),s=o?S(o).some(i=>{let l=i.subject.name;return l==="ObjectProperty"||l==="DatatypeProperty"||l==="Property"}):!1,a=[];if(s&&n){let i=this.readPropertyValueReferences(n,r);for(let l of i){let p=m(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(r);if(a.length===0)return`<!-- LookRenderer.ResourceGrid: no resources for ${r.publisher}/${r.package_}/${r.name} -->`;let c=[];for(let i of a){let l=g(i,_)??i.name,p=g(i,re),k=i.namespace||"",T=k.split("/")[1]?.split("@")[0]??"",b=k.split("@")[1]??"",y=b?this.parseVersion(b):void 0,pe=N.formatResourceUrl({publisher:F(i),package_:T,name:i.name,...y?{version:y}:{}},"=",{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">
|
|
52
|
-
${c.join(`
|
|
53
|
-
`)}
|
|
54
|
-
</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 L))continue;S(n).map(s=>s.subject).some(s=>s.publisher===e.publisher&&s.package_===e.package_&&s.name===e.name)&&t.push(n)}return t}renderBreadcrumb(e,t){let r=(e.namespace||"").split("/");if(r.length<2)return"";let o=r[0],a=(r[1]??"").split("@")[0]??"";if(!o||!a)return"";let c=g(e,_)??e.name,i=a,l,p=m(this.catalog,{publisher:o,package_:a,name:a});if(p){let y=g(p,_);y&&(i=y),l=`/${a}/${a}`}let k=e.name===a,T=o,b=[];return b.push(`<li><a href="/">${f(T)}</a></li>`),k||b.push(l?`<li><a href="${f(l)}">${f(i)}</a></li>`:`<li>${f(i)}</li>`),b.push(`<li aria-current="page">${f(c)}</li>`),`<nav class="kan-breadcrumb"><ol>
|
|
55
|
-
${b.join(`
|
|
56
|
-
`)}
|
|
57
|
-
</ol></nav>`}renderNavGroup(e,t){let n=this.findNavGroupForPublisher(t);if(!n)return"";let r=O(n,W);if(!(r instanceof j))return"";let o=r.object??[];if(o.length===0)return"";let s=[];for(let a of o){if(!(a instanceof d))continue;let c=m(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}`,k=i===p?' aria-current="page"':"";s.push(`<li><a class="kan-nav-link" href="${f(i)}"${k}>${f(l)}</a></li>`)}return`<nav class="kan-site-nav"><ul>
|
|
58
|
-
${s.join(`
|
|
59
|
-
`)}
|
|
60
|
-
</ul></nav>`}resolveNavEntry(e,t,n){if(t&&S(t).map(c=>c.subject).some(c=>c.publisher===M.publisher&&c.package_===M.package_&&c.name===M.name)){let c=g(t,_),i=O(t,oe);if(i instanceof h&&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 r=N.formatResourceUrl({publisher:e.subject.publisher,package_:e.subject.package_,...e.subject.version?{version:e.subject.version}:{},name:e.subject.name},"*",{contextPublisher:n}),o=t?g(t,_)??e.subject.name:e.subject.name;return{href:r,label:o}}findNavGroupForPublisher(e){for(let t of this.catalog){if(!(t instanceof L)||!(t.namespace||"").startsWith(`${e}/`))continue;if(S(t).map(s=>s.subject).some(s=>s.publisher===V.publisher&&s.package_===V.package_&&s.name===V.name))return t}}renderMarkdown(e,t){let n=R(e,I);if(!n)return"<!-- LookRenderer.Markdown: no look.source -->";let r=this.readPropertyValueText(t,n);return r?`<section class="kan-markdown">
|
|
61
|
-
${ee(r)}
|
|
62
|
-
</section>`:""}renderRawMarkdown(e){let t=this.findCascadedLook(e);if(!t)return;let n=ie(t.declaration),r=[];for(let o of n){let s=ce(o);if(!s||!v(s,se))continue;let a=R(o,I);if(!a)continue;let c=this.readPropertyValueText(e,a);c&&r.push(c)}return r.length>0?r.join(`
|
|
63
|
-
|
|
64
|
-
`):void 0}renderHero(e,t,n){let r=['<header class="kan-hero">'],o=R(e,Ue);if(o){let l=this.readPropertyValueText(t,o);l&&r.push(`<span class="kan-hero-eyebrow">${f(l)}</span>`)}let s=R(e,Le),a="";s&&(a=this.readPropertyValueText(t,s)??""),a||(a=t.name),r.push(`<h1 class="kan-hero-title">${f(a)}</h1>`);let c=R(e,Ie);if(c){let l=this.readPropertyValueText(t,c);l&&r.push(`<p class="kan-hero-subtitle">${f(l)}</p>`)}let i=R(e,ae);if(i){let l=this.readPropertyValueReferences(t,i);if(l.length>0){let p=l.map(k=>this.renderBadge(k,ae,n)).join("");r.push(`<div class="kan-hero-badges">${p}</div>`)}}return r.push("</header>"),r.join(`
|
|
65
|
-
`)}renderPropertyList(e,t,n){let r=R(e,I);if(!r)return"<!-- LookRenderer: PropertyList missing look.source -->";let o=this.readLabelForUri(r)??r.name,s=O(t,r),a=this.gatherValueItems(s),c=a.length>0?a.map(i=>`<li>${this.renderInlineValue(i,I,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(`
|
|
66
|
-
`)}renderBadgeRow(e,t,n){let r=R(e,I);if(!r)return"<!-- LookRenderer: BadgeRow missing look.source -->";let o=this.readPropertyValueReferences(t,r);return o.length===0?"":`<div class="kan-badge-row">${o.map(a=>this.renderBadge(a,I,n)).join("")}</div>`}renderChipRow(e,t,n){let r=ue(e,Oe);if(r.length===0)return"<!-- LookRenderer: ChipRow has no look.chips -->";let o=[];for(let s of r){let a=O(t,s);if(!a)continue;let c=this.readLabelForUri(s)??s.name,i=this.renderStatementInlineValue(a,s,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 r=ue(e,W);if(r.length===0)return"<!-- LookRenderer: ReferenceList has no look.entries -->";let o=[];for(let s of r){let a=this.readPropertyValueReferences(t,s);if(a.length===0)continue;let c=this.readLabelForUri(s)??s.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=O(e,t);if(n){if(n instanceof $)return n.object;if(n instanceof h){let r=n.object;return this.readLabelForUri({publisher:r.subject.publisher,package_:r.subject.package_,name:r.subject.name})??r.subject.name}if(n instanceof j)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 P?o.name??"":String(o)).filter(o=>o).join(", ")}}readPropertyValueReferences(e,t){let n=O(e,t);if(!n)return[];if(n instanceof h)return[n.object];if(n instanceof j){let r=[];for(let o of n.object??[])o instanceof d&&r.push(o);return r}return[]}gatherValueItems(e){return e?e instanceof j?e.object??[]:e instanceof h?[e.object]:e instanceof E?[e.object]:e instanceof $?[e.object]:[]:[]}renderInlineValue(e,t,n){return e instanceof d?this.renderReferenceLink(e,t,n):e instanceof P?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 $?f(e.object):e instanceof h?this.renderReferenceLink(e.object,t,n):e instanceof j?(e.object??[]).map(o=>this.renderInlineValue(o,t,n)).filter(o=>o).join(", "):""}renderReferenceLink(e,t,n){let r=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(r)}</a>`}renderBadge(e,t,n){let r=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}),s=this.urlForReference(e,t,n),a=o?` title="${f(o)}"`:"";return`<a class="kan-badge" href="${f(s)}"${a}>${f(r)}</a>`}urlForReference(e,t,n){let r=t?this.getUrlFormForProperty(t):"=";return N.formatResourceUrl({publisher:e.subject.publisher,package_:e.subject.package_,...e.subject.version?{version:e.subject.version}:{},name:e.subject.name},r,{contextPublisher:n})}getUrlFormForProperty(e){let t=m(this.catalog,e);if(!t)return"=";let n=g(t,we);return n==="*"||n==="^"||n==="~"||n==="="?n:"="}readLabelForUri(e){let t=m(this.catalog,e);if(t)return g(t,_)}readCommentForUri(e){let t=m(this.catalog,e);if(t)return g(t,re)}};function q(u){let e=new Map;for(let t of u.statement){if(!(t instanceof E)||!K(t,H.publisher,H.package_,H.name))continue;let n=t.object;for(let r of n.statement){if(!(r instanceof $))continue;let o=r.predicate?.subject?.name;if(!o)continue;let s=r.object;e.has(o)||e.set(o,s)}}return e}function Y(u){for(let e of u.statement)if(e instanceof E&&K(e,G.publisher,G.package_,G.name))return e.object}function ie(u){for(let e of u.statement){if(!(e instanceof j)||!K(e,D.publisher,D.package_,D.name))continue;let t=[];for(let n of e.object??[])n instanceof P&&t.push(n);return t}return[]}function ce(u){for(let e of u.statement)if(e instanceof h&&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 R(u,e){for(let t of u.statement)if(t instanceof h&&K(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 j)||!K(t,e.publisher,e.package_,e.name))continue;let n=[];for(let r of t.object??[])r instanceof d&&n.push({publisher:r.subject.publisher,package_:r.subject.package_,name:r.subject.name});return n}return[]}function O(u,e){for(let t of u.statement)if(K(t,e.publisher,e.package_,e.name))return t}function g(u,e){for(let t of u.statement)if(t instanceof $&&K(t,e.publisher,e.package_,e.name))return t.object}function S(u){let e=[];for(let t of u.statement)if(t instanceof h){if(t.predicate?.subject?.name!=="type")continue;t.object instanceof d&&e.push(t.object)}else if(t instanceof j){if(t.predicate?.subject?.name!=="type")continue;for(let n of t.object??[])n instanceof d&&e.push(n)}return e}function x(u){let e=[];for(let t of u.statement)if(t instanceof h){if(t.predicate?.subject?.name!=="subClassOf")continue;t.object instanceof d&&e.push(t.object)}else if(t instanceof j){if(t.predicate?.subject?.name!=="subClassOf")continue;for(let n of t.object??[])n instanceof d&&e.push(n)}return e}function A(u,e){let t=[];for(let n of u){if(!(n instanceof L)||n.name!==e.name)continue;(n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`)&&t.push(n)}return t}function m(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 r of u)if(r instanceof L&&r.name===e.name&&r.namespace===n)return r}for(let n of u){if(!(n instanceof L)||n.name!==e.name)continue;if((n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`))return n}}function K(u,e,t,n){let r=u.predicate?.subject;return r?r.publisher===e&&r.package_===t&&r.name===n:!1}function v(u,e){return u.publisher===e.publisher&&u.package_===e.package_&&u.name===e.name}function w(u){return`${u.publisher}/${u.package_}/${u.name}`}function F(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/chunk-MYITGTGJ.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import*as h from"js-yaml";var g=class{parse(r){let t=this.parseWithErrors(r);if(!t.isValid){let a=t.errors[0];throw new Error(`YAML parse error at line ${a.line}, column ${a.column}: ${a.message}`)}return t.document}parseWithErrors(r){let t=[],a;try{r=r.replace(/^\uFEFF/,"");let s=h.load(r);if(!s||typeof s!="object")return a={metadata:this.createEmptyMetadata(),body:{},toString:()=>"KanonakDocument(empty)"},{document:a,errors:t,isValid:!0};let e=this.extractMetadata(s),n=this.extractBody(s,e);return a={metadata:e,body:n,toString:function(){return this.metadata.namespace_?`KanonakDocument(${this.metadata.namespace_.publisher}/${this.metadata.namespace_.package_})`:"KanonakDocument(no namespace)"}},{document:a,errors:t,isValid:!0}}catch(s){let e=s,n={message:e.message||"Unknown parse error",line:e.mark?.line??0,column:e.mark?.column??0,errorType:e.name==="YAMLException"?"SyntaxError":"Unknown",toString:()=>`${e.name==="YAMLException"?"SyntaxError":"Unknown"} at line ${e.mark?.line??0}: ${e.message||"Unknown parse error"}`};return t.push(n),{document:void 0,errors:t,isValid:!1}}}save(r){let t={};if(r.metadata.namespace_){let a=r.metadata.namespace_,s={type:"Package",publisher:a.publisher};a.version&&(s.version=`${a.version.major}.${a.version.minor}.${a.version.patch}`),r.metadata.imports&&(s.imports=this.serializeImports(r.metadata.imports)),t[a.package_]=s}return Object.assign(t,r.body),h.dump(t,{indent:2,noRefs:!0,sortKeys:!1})}createEmptyMetadata(){return{get allImports(){return[]}}}addAllImportsGetter(r){let t=r.imports;return Object.defineProperty(r,"allImports",{get:function(){if(!t)return[];let a=[];for(let s of Object.values(t))a.push(...s);return a},enumerable:!0,configurable:!0}),r}createVersion(r,t,a){return{major:r,minor:t,patch:a,toString:()=>`${r}.${t}.${a}`,equals:e=>!e||typeof e!="object"?!1:e.major===r&&e.minor===t&&e.patch===a,getHashCode:()=>r<<20|t<<10|a,compareTo:e=>r!==e.major?r-e.major:t!==e.minor?t-e.minor:a-e.patch}}extractMetadata(r){let t=this.createEmptyMetadata();for(let[a,s]of Object.entries(r))if(s&&typeof s=="object"&&s.type==="Package"){t.type_="Package";let e=a,n=s.publisher,i=s.version?this.parseVersion(s.version):void 0;return n&&e&&(t.namespace_={publisher:n,package_:e,version:i,toString:function(){return`${this.publisher}/${this.package_}@${this.version?.major??1}.${this.version?.minor??0}.${this.version?.patch??0}`},equals:o=>!o||typeof o!="object"?!1:o.publisher===n&&o.package_===e&&(!i||!o.version||i.equals(o.version)),getHashCode:()=>{let o=0;for(let c=0;c<n.length;c++)o=(o<<5)-o+n.charCodeAt(c);for(let c=0;c<e.length;c++)o=(o<<5)-o+e.charCodeAt(c);return o|0}}),s.imports&&Array.isArray(s.imports)&&(t.imports=this.parseImportsV3(s.imports)),this.addAllImportsGetter(t)}if(r.kanonak&&typeof r.kanonak=="object"){let a=r.kanonak;return(a.publisher||a.package||a.version)&&(t.namespace_=this.parseNamespace(a)),a.imports&&typeof a.imports=="object"&&(t.imports=this.parseImportsLegacy(a.imports)),this.addAllImportsGetter(t)}return t}extractBody(r,t){let a={},s;for(let[e,n]of Object.entries(r))if(n&&typeof n=="object"&&n.type==="Package"){s=e;break}for(let[e,n]of Object.entries(r))e!==s&&e!=="kanonak"&&e!=="namespace"&&e!=="imports"&&(a[e]=n);return a}parseNamespace(r){if(typeof r=="string"){let e=r.match(/^([^/]+)\/([^@]+)(?:@(.+))?$/);if(e){let n=e[3]?this.parseVersion(e[3]):this.createVersion(1,0,0);return{publisher:e[1],package_:e[2],version:n,toString:()=>r,equals:i=>!i||typeof i!="object"?!1:i.publisher===e[1]&&i.package_===e[2]&&(!n||!i.version||n.equals(i.version)),getHashCode:()=>{let i=0;for(let o=0;o<e[1].length;o++)i=(i<<5)-i+e[1].charCodeAt(o);for(let o=0;o<e[2].length;o++)i=(i<<5)-i+e[2].charCodeAt(o);return i|0}}}}let t=r.publisher||"",a=r.package||"",s=r.version?this.parseVersion(r.version):this.createVersion(1,0,0);return{publisher:t,package_:a,version:s,toString:function(){return`${this.publisher}/${this.package_}@${this.version?.major??1}.${this.version?.minor??0}.${this.version?.patch??0}`},equals:e=>!e||typeof e!="object"?!1:e.publisher===t&&e.package_===a&&(!s||!e.version||s.equals(e.version)),getHashCode:()=>{let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n);for(let n=0;n<a.length;n++)e=(e<<5)-e+a.charCodeAt(n);return e|0}}}parseVersion(r){if(typeof r=="string"){let t=r.split(".").map(Number);return this.createVersion(t[0]||0,t[1]||0,t[2]||0)}return this.createVersion(r.major||0,r.minor||0,r.patch||0)}parseImportsV3(r){let t={};for(let a of r)if(!(!a||typeof a!="object"))if(a.packages&&Array.isArray(a.packages)){let s=a.publisher;if(!s)throw new Error("PublisherImport requires 'publisher' property");t[s]||(t[s]=[]);for(let e of a.packages){if(!e||typeof e!="object")continue;let n=this.parseImportFromEmbeddedObject(e,s);t[s].push(n)}}else{let s=this.parseImportFromEmbeddedObject(a,a.publisher),e=s.publisher||"";t[e]||(t[e]=[]),t[e].push(s)}return t}parseImportsLegacy(r){let t={};for(let[a,s]of Object.entries(r))Array.isArray(s)&&(t[a]=s.map(e=>this.parseImport(e,a)));return t}parseImportFromEmbeddedObject(r,t){let a=r.package;if(!a)throw new Error("Import requires 'package' property");let s=r.match;if(!s)throw new Error("Import requires 'match' property");let e=r.version;if(!e)throw new Error("Import requires 'version' property");let n=this.parseVersion(e),i=this.parseVersionOperator(s),o=this.calculateMaxVersion(s,n),c=r.alias;return{package_:`${a} ${s} ${n.toString()}`,publisher:t,packageName:a,versionOperator:i,version:n,alias:c,minVersion:n,maxVersion:o,toEmbeddedObject:()=>{let m={package:a,match:s,version:n.toString()};return c&&(m.alias=c),m},toString:()=>c?`${a} ${s} ${n.toString()} as ${c}`:`${a} ${s} ${n.toString()}`}}parseImport(r,t){if(typeof r=="string"){let o=r.match(/^(.+?)\s*([~^=*])\s*(\S+)\s+as\s+(\S+)$/);if(o){let m=o[1].trim(),u=o[2],p=this.parseVersion(o[3].trim()),l=o[4].trim(),d=this.parseVersionOperator(u),y=this.calculateMaxVersion(u,p);return{package_:r,publisher:t,packageName:m,versionOperator:d,version:p,alias:l,minVersion:p,maxVersion:y,toEmbeddedObject:()=>{let f={package:m,match:u,version:p.toString()};return l&&(f.alias=l),f},toString:()=>`${m} ${u} ${p.toString()} as ${l}`}}let c=r.match(/^(.+?)\s*([~^=*])\s*(.+)$/);if(c){let m=c[1].trim(),u=c[2],p=this.parseVersion(c[3].trim()),l=this.parseVersionOperator(u),d=this.calculateMaxVersion(u,p);return{package_:r,publisher:t,packageName:m,versionOperator:l,version:p,alias:void 0,minVersion:p,maxVersion:d,toEmbeddedObject:()=>({package:m,match:u,version:p.toString()}),toString:()=>`${m} ${u} ${p.toString()}`}}}let a=this.parseVersionOperator(r.operator||"~"),s=this.parseVersion(r.version||"1.0.0"),e=r.packageName||r.package||"",n=["=","~","^","*"][a],i=this.calculateMaxVersion(r.operator||"~",s);return{package_:r.package||"",publisher:t,packageName:e,versionOperator:a,version:s,alias:r.alias,minVersion:s,maxVersion:i,toEmbeddedObject:()=>{let o={package:e,match:n,version:s.toString()};return r.alias&&(o.alias=r.alias),o},toString:()=>`${e} ${n} ${s.toString()}`}}parseVersionOperator(r){switch(r){case"=":return 0;case"~":return 1;case"^":return 2;case"*":return 3;default:return 1}}calculateMaxVersion(r,t){switch(r){case"~":return this.createVersion(t.major,t.minor+1,0);case"^":return t.major===0?this.createVersion(0,t.minor+1,0):this.createVersion(t.major+1,0,0);default:return this.createVersion(999,999,999)}}serializeImports(r){let t=[];for(let[a,s]of Object.entries(r)){let e={publisher:a,packages:s.map(n=>{let i=["=","~","^","*"][n.versionOperator],o={package:n.packageName,match:i,version:`${n.version.major}.${n.version.minor}.${n.version.patch}`};return n.alias&&(o.alias=n.alias),o})};t.push(e)}return t}};export{g as a};
|